kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 1 | /* |
| 2 | This file is part of the KDE libraries |
| 3 | |
| 4 | Copyright (C) 1997 Martin Jones (mjones@kde.org) |
| 5 | (C) 1997 Torben Weis (weis@kde.org) |
| 6 | (C) 1998 Waldo Bastian (bastian@kde.org) |
| 7 | (C) 2001 Dirk Mueller (mueller@kde.org) |
darin | 85c3a50 | 2006-02-17 01:08:41 +0000 | [diff] [blame] | 8 | Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 9 | |
| 10 | This library is free software; you can redistribute it and/or |
| 11 | modify it under the terms of the GNU Library General Public |
| 12 | License as published by the Free Software Foundation; either |
| 13 | version 2 of the License, or (at your option) any later version. |
| 14 | |
| 15 | This library is distributed in the hope that it will be useful, |
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | Library General Public License for more details. |
| 19 | |
| 20 | You should have received a copy of the GNU Library General Public License |
| 21 | along with this library; see the file COPYING.LIB. If not, write to |
| 22 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 23 | Boston, MA 02111-1307, USA. |
| 24 | */ |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 25 | |
| 26 | #ifndef HTMLTOKENIZER_H |
| 27 | #define HTMLTOKENIZER_H |
| 28 | |
darin | b53ebdc | 2006-07-09 15:10:21 +0000 | [diff] [blame] | 29 | #include "DeprecatedPtrQueue.h" |
eseidel | 40eb1b9 | 2006-03-25 22:20:36 +0000 | [diff] [blame] | 30 | #include "NamedMappedAttrMap.h" |
darin | d03140b | 2006-01-19 08:59:31 +0000 | [diff] [blame] | 31 | #include "SegmentedString.h" |
darin | a52f4e1 | 2006-02-02 02:51:03 +0000 | [diff] [blame] | 32 | #include "Timer.h" |
darin | b53ebdc | 2006-07-09 15:10:21 +0000 | [diff] [blame] | 33 | #include "XMLTokenizer.h" |
darin | e775cf7 | 2006-07-09 22:48:56 +0000 | [diff] [blame] | 34 | #include "CachedResourceClient.h" |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 35 | |
darin | d03140b | 2006-01-19 08:59:31 +0000 | [diff] [blame] | 36 | namespace WebCore { |
hyatt | 3b4f6d4 | 2004-02-07 01:19:44 +0000 | [diff] [blame] | 37 | |
| 38 | class CachedScript; |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 39 | class DocumentFragment; |
| 40 | class Document; |
hyatt | 3ad2407 | 2006-06-26 23:53:02 +0000 | [diff] [blame] | 41 | class HTMLDocument; |
| 42 | class HTMLViewSourceDocument; |
darin | ffd93c3 | 2006-01-31 17:09:20 +0000 | [diff] [blame] | 43 | class FrameView; |
darin | 644b75e | 2006-02-21 06:59:15 +0000 | [diff] [blame] | 44 | class HTMLParser; |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 45 | class Node; |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 46 | |
hyatt | 3b4f6d4 | 2004-02-07 01:19:44 +0000 | [diff] [blame] | 47 | /** |
| 48 | * @internal |
| 49 | * represents one HTML tag. Consists of a numerical id, and the list |
| 50 | * of attributes. Can also represent text. In this case the id = 0 and |
| 51 | * text contains the text. |
| 52 | */ |
| 53 | class Token |
| 54 | { |
| 55 | public: |
darin | 2a4c374 | 2005-12-27 18:26:16 +0000 | [diff] [blame] | 56 | Token() : beginTag(true), flat(false) { } |
hyatt | 59136b7 | 2005-07-09 20:19:28 +0000 | [diff] [blame] | 57 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 58 | void addAttribute(Document*, const AtomicString& attrName, const AtomicString& v); |
hyatt | 59136b7 | 2005-07-09 20:19:28 +0000 | [diff] [blame] | 59 | |
darin | d03140b | 2006-01-19 08:59:31 +0000 | [diff] [blame] | 60 | bool isOpenTag(const QualifiedName& fullName) const { return beginTag && fullName.localName() == tagName; } |
| 61 | bool isCloseTag(const QualifiedName& fullName) const { return !beginTag && fullName.localName() == tagName; } |
hyatt | 59136b7 | 2005-07-09 20:19:28 +0000 | [diff] [blame] | 62 | |
hyatt | 3b4f6d4 | 2004-02-07 01:19:44 +0000 | [diff] [blame] | 63 | void reset() |
| 64 | { |
darin | 2a4c374 | 2005-12-27 18:26:16 +0000 | [diff] [blame] | 65 | attrs = 0; |
| 66 | text = 0; |
darin | d03140b | 2006-01-19 08:59:31 +0000 | [diff] [blame] | 67 | tagName = nullAtom; |
hyatt | 59136b7 | 2005-07-09 20:19:28 +0000 | [diff] [blame] | 68 | beginTag = true; |
hyatt | 3b4f6d4 | 2004-02-07 01:19:44 +0000 | [diff] [blame] | 69 | flat = false; |
| 70 | } |
hyatt | 59136b7 | 2005-07-09 20:19:28 +0000 | [diff] [blame] | 71 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 72 | RefPtr<NamedMappedAttrMap> attrs; |
| 73 | RefPtr<StringImpl> text; |
darin | d03140b | 2006-01-19 08:59:31 +0000 | [diff] [blame] | 74 | AtomicString tagName; |
darin | 2a4c374 | 2005-12-27 18:26:16 +0000 | [diff] [blame] | 75 | bool beginTag; |
| 76 | bool flat; |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 77 | }; |
| 78 | |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 79 | //----------------------------------------------------------------------------- |
| 80 | |
darin | e775cf7 | 2006-07-09 22:48:56 +0000 | [diff] [blame] | 81 | class HTMLTokenizer : public Tokenizer, public CachedResourceClient |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 82 | { |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 83 | public: |
hyatt | 3ad2407 | 2006-06-26 23:53:02 +0000 | [diff] [blame] | 84 | HTMLTokenizer(HTMLDocument*); |
| 85 | HTMLTokenizer(HTMLViewSourceDocument*); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 86 | HTMLTokenizer(DocumentFragment*); |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 87 | virtual ~HTMLTokenizer(); |
| 88 | |
darin | 7ab3109 | 2006-05-10 04:59:57 +0000 | [diff] [blame] | 89 | virtual bool write(const SegmentedString&, bool appendData); |
darin | a3cce73 | 2004-07-22 20:50:10 +0000 | [diff] [blame] | 90 | virtual void finish(); |
jens | d7ffc9e | 2005-02-17 19:53:50 +0000 | [diff] [blame] | 91 | virtual void setForceSynchronous(bool force); |
darin | ed60ff2 | 2004-11-12 22:04:26 +0000 | [diff] [blame] | 92 | virtual bool isWaitingForScripts() const; |
ggaren | 33e6544 | 2005-10-22 01:41:36 +0000 | [diff] [blame] | 93 | virtual void stopParsing(); |
hyatt | 9c4ba9b | 2004-11-10 03:47:56 +0000 | [diff] [blame] | 94 | virtual bool processingData() const; |
eseidel | 25c8c22 | 2006-03-21 06:46:47 +0000 | [diff] [blame] | 95 | virtual int executingScript() const { return m_executingScript; } |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 96 | |
darin | a52f4e1 | 2006-02-02 02:51:03 +0000 | [diff] [blame] | 97 | private: |
mjs | b1c8f66 | 2005-10-18 03:15:31 +0000 | [diff] [blame] | 98 | class State; |
| 99 | |
| 100 | // Where we are in parsing a tag |
darin | a3cce73 | 2004-07-22 20:50:10 +0000 | [diff] [blame] | 101 | void begin(); |
| 102 | void end(); |
| 103 | |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 104 | void reset(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 105 | PassRefPtr<Node> processToken(); |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 106 | |
hyatt | d2c53f2 | 2006-01-15 07:12:43 +0000 | [diff] [blame] | 107 | State processListing(SegmentedString, State); |
| 108 | State parseComment(SegmentedString&, State); |
| 109 | State parseServer(SegmentedString&, State); |
| 110 | State parseText(SegmentedString&, State); |
| 111 | State parseSpecial(SegmentedString&, State); |
| 112 | State parseTag(SegmentedString&, State); |
darin | 7ab3109 | 2006-05-10 04:59:57 +0000 | [diff] [blame] | 113 | State parseEntity(SegmentedString&, UChar*& dest, State, unsigned& _cBufferPos, bool start, bool parsingTag); |
hyatt | d2c53f2 | 2006-01-15 07:12:43 +0000 | [diff] [blame] | 114 | State parseProcessingInstruction(SegmentedString&, State); |
mjs | b1c8f66 | 2005-10-18 03:15:31 +0000 | [diff] [blame] | 115 | State scriptHandler(State); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 116 | State scriptExecution(const DeprecatedString& script, State state, DeprecatedString scriptURL = DeprecatedString(), int baseLine = 0); |
darin | 7ab3109 | 2006-05-10 04:59:57 +0000 | [diff] [blame] | 117 | void setSrc(const SegmentedString&); |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 118 | |
| 119 | // check if we have enough space in the buffer. |
| 120 | // if not enlarge it |
| 121 | inline void checkBuffer(int len = 10) |
| 122 | { |
| 123 | if ( (dest - buffer) > size-len ) |
| 124 | enlargeBuffer(len); |
| 125 | } |
| 126 | inline void checkScriptBuffer(int len = 10) |
| 127 | { |
| 128 | if ( scriptCodeSize + len >= scriptCodeMaxSize ) |
| 129 | enlargeScriptBuffer(len); |
| 130 | } |
| 131 | |
| 132 | void enlargeBuffer(int len); |
| 133 | void enlargeScriptBuffer(int len); |
| 134 | |
darin | 7ab3109 | 2006-05-10 04:59:57 +0000 | [diff] [blame] | 135 | bool continueProcessing(int& processedCount, double startTime, State&); |
darin | a52f4e1 | 2006-02-02 02:51:03 +0000 | [diff] [blame] | 136 | void timerFired(Timer<HTMLTokenizer>*); |
hyatt | 9c4ba9b | 2004-11-10 03:47:56 +0000 | [diff] [blame] | 137 | void allDataProcessed(); |
| 138 | |
darin | e775cf7 | 2006-07-09 22:48:56 +0000 | [diff] [blame] | 139 | // from CachedResourceClient |
| 140 | void notifyFinished(CachedResource *finishedObj); |
mjs | 9d0f55f | 2003-11-17 23:27:42 +0000 | [diff] [blame] | 141 | |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 142 | // Internal buffers |
| 143 | /////////////////// |
darin | 7ab3109 | 2006-05-10 04:59:57 +0000 | [diff] [blame] | 144 | UChar* buffer; |
| 145 | UChar* dest; |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 146 | |
hyatt | 3b4f6d4 | 2004-02-07 01:19:44 +0000 | [diff] [blame] | 147 | Token currToken; |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 148 | |
| 149 | // the size of buffer |
| 150 | int size; |
| 151 | |
| 152 | // Tokenizer flags |
| 153 | ////////////////// |
| 154 | // are we in quotes within a html tag |
darin | 7ab3109 | 2006-05-10 04:59:57 +0000 | [diff] [blame] | 155 | enum { NoQuote, SingleQuote, DoubleQuote } tquote; |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 156 | |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 157 | // Are we in a &... character entity description? |
mjs | b1c8f66 | 2005-10-18 03:15:31 +0000 | [diff] [blame] | 158 | enum EntityState { |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 159 | NoEntity = 0, |
mjs | b1c8f66 | 2005-10-18 03:15:31 +0000 | [diff] [blame] | 160 | SearchEntity = 1, |
| 161 | NumericSearch = 2, |
| 162 | Hexadecimal = 3, |
| 163 | Decimal = 4, |
| 164 | EntityName = 5, |
| 165 | SearchSemicolon = 6 |
| 166 | }; |
darin | 4526522 | 2003-05-07 16:01:49 +0000 | [diff] [blame] | 167 | unsigned EntityUnicodeValue; |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 168 | |
mjs | b1c8f66 | 2005-10-18 03:15:31 +0000 | [diff] [blame] | 169 | enum TagState { |
| 170 | NoTag = 0, |
| 171 | TagName = 1, |
| 172 | SearchAttribute = 2, |
| 173 | AttributeName = 3, |
| 174 | SearchEqual = 4, |
| 175 | SearchValue = 5, |
| 176 | QuotedValue = 6, |
| 177 | Value = 7, |
| 178 | SearchEnd = 8 |
| 179 | }; |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 180 | |
mjs | b1c8f66 | 2005-10-18 03:15:31 +0000 | [diff] [blame] | 181 | class State { |
| 182 | public: |
| 183 | State() : m_bits(0) {} |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 184 | |
mjs | b1c8f66 | 2005-10-18 03:15:31 +0000 | [diff] [blame] | 185 | TagState tagState() const { return static_cast<TagState>(m_bits & TagMask); } |
| 186 | void setTagState(TagState t) { m_bits = (m_bits & ~TagMask) | t; } |
| 187 | EntityState entityState() const { return static_cast<EntityState>((m_bits & EntityMask) >> EntityShift); } |
| 188 | void setEntityState(EntityState e) { m_bits = (m_bits & ~EntityMask) | (e << EntityShift); } |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 189 | |
mjs | b1c8f66 | 2005-10-18 03:15:31 +0000 | [diff] [blame] | 190 | bool inScript() const { return testBit(InScript); } |
| 191 | void setInScript(bool v) { setBit(InScript, v); } |
| 192 | bool inStyle() const { return testBit(InStyle); } |
| 193 | void setInStyle(bool v) { setBit(InStyle, v); } |
| 194 | bool inSelect() const { return testBit(InSelect); } |
| 195 | void setInSelect(bool v) { setBit(InSelect, v); } |
| 196 | bool inXmp() const { return testBit(InXmp); } |
| 197 | void setInXmp(bool v) { setBit(InXmp, v); } |
| 198 | bool inTitle() const { return testBit(InTitle); } |
| 199 | void setInTitle(bool v) { setBit(InTitle, v); } |
| 200 | bool inPlainText() const { return testBit(InPlainText); } |
| 201 | void setInPlainText(bool v) { setBit(InPlainText, v); } |
| 202 | bool inProcessingInstruction() const { return testBit(InProcessingInstruction); } |
| 203 | void setInProcessingInstruction(bool v) { return setBit(InProcessingInstruction, v); } |
| 204 | bool inComment() const { return testBit(InComment); } |
| 205 | void setInComment(bool v) { setBit(InComment, v); } |
| 206 | bool inTextArea() const { return testBit(InTextArea); } |
| 207 | void setInTextArea(bool v) { setBit(InTextArea, v); } |
| 208 | bool escaped() const { return testBit(Escaped); } |
| 209 | void setEscaped(bool v) { setBit(Escaped, v); } |
| 210 | bool inServer() const { return testBit(InServer); } |
| 211 | void setInServer(bool v) { setBit(InServer, v); } |
| 212 | bool skipLF() const { return testBit(SkipLF); } |
| 213 | void setSkipLF(bool v) { setBit(SkipLF, v); } |
| 214 | bool startTag() const { return testBit(StartTag); } |
| 215 | void setStartTag(bool v) { setBit(StartTag, v); } |
| 216 | bool discardLF() const { return testBit(DiscardLF); } |
| 217 | void setDiscardLF(bool v) { setBit(DiscardLF, v); } |
| 218 | bool allowYield() const { return testBit(AllowYield); } |
| 219 | void setAllowYield(bool v) { setBit(AllowYield, v); } |
| 220 | bool loadingExtScript() const { return testBit(LoadingExtScript); } |
| 221 | void setLoadingExtScript(bool v) { setBit(LoadingExtScript, v); } |
| 222 | bool forceSynchronous() const { return testBit(ForceSynchronous); } |
| 223 | void setForceSynchronous(bool v) { setBit(ForceSynchronous, v); } |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 224 | |
mjs | b1c8f66 | 2005-10-18 03:15:31 +0000 | [diff] [blame] | 225 | bool inAnySpecial() const { return m_bits & (InScript | InStyle | InXmp | InTextArea | InTitle); } |
| 226 | bool hasTagState() const { return m_bits & TagMask; } |
| 227 | bool hasEntityState() const { return m_bits & EntityMask; } |
darin | f028f81 | 2002-06-10 20:08:04 +0000 | [diff] [blame] | 228 | |
mjs | b1c8f66 | 2005-10-18 03:15:31 +0000 | [diff] [blame] | 229 | bool needsSpecialWriteHandling() const { return m_bits & (InScript | InStyle | InXmp | InTextArea | InTitle | TagMask | EntityMask | InPlainText | InComment | InServer | InProcessingInstruction | StartTag); } |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 230 | |
mjs | b1c8f66 | 2005-10-18 03:15:31 +0000 | [diff] [blame] | 231 | private: |
| 232 | static const int EntityShift = 4; |
| 233 | enum StateBits { |
| 234 | TagMask = (1 << 4) - 1, |
| 235 | EntityMask = (1 << 7) - (1 << 4), |
| 236 | InScript = 1 << 7, |
| 237 | InStyle = 1 << 8, |
| 238 | InSelect = 1 << 9, |
| 239 | InXmp = 1 << 10, |
| 240 | InTitle = 1 << 11, |
| 241 | InPlainText = 1 << 12, |
| 242 | InProcessingInstruction = 1 << 13, |
| 243 | InComment = 1 << 14, |
| 244 | InTextArea = 1 << 15, |
| 245 | Escaped = 1 << 16, |
| 246 | InServer = 1 << 17, |
| 247 | SkipLF = 1 << 18, |
| 248 | StartTag = 1 << 19, |
| 249 | DiscardLF = 1 << 20, // FIXME: should clarify difference between skip and discard |
| 250 | AllowYield = 1 << 21, |
| 251 | LoadingExtScript = 1 << 22, |
weinig | ab5f09e | 2006-07-29 23:15:25 +0000 | [diff] [blame] | 252 | ForceSynchronous = 1 << 23 |
mjs | b1c8f66 | 2005-10-18 03:15:31 +0000 | [diff] [blame] | 253 | }; |
| 254 | |
| 255 | void setBit(StateBits bit, bool value) |
| 256 | { |
| 257 | if (value) |
| 258 | m_bits |= bit; |
| 259 | else |
| 260 | m_bits &= ~bit; |
| 261 | } |
| 262 | bool testBit(StateBits bit) const { return m_bits & bit; } |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 263 | |
mjs | b1c8f66 | 2005-10-18 03:15:31 +0000 | [diff] [blame] | 264 | unsigned m_bits; |
| 265 | }; |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 266 | |
mjs | b1c8f66 | 2005-10-18 03:15:31 +0000 | [diff] [blame] | 267 | State m_state; |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 268 | |
| 269 | bool brokenServer; |
| 270 | |
hyatt | 2773dff | 2005-07-18 21:44:31 +0000 | [diff] [blame] | 271 | // Name of an attribute that we just scanned. |
darin | d03140b | 2006-01-19 08:59:31 +0000 | [diff] [blame] | 272 | AtomicString attrName; |
hyatt | baa79d0 | 2002-12-16 01:51:51 +0000 | [diff] [blame] | 273 | |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 274 | // Used to store the code of a srcipting sequence |
darin | 7ab3109 | 2006-05-10 04:59:57 +0000 | [diff] [blame] | 275 | UChar* scriptCode; |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 276 | // Size of the script sequenze stored in @ref #scriptCode |
| 277 | int scriptCodeSize; |
| 278 | // Maximal size that can be stored in @ref #scriptCode |
| 279 | int scriptCodeMaxSize; |
gramps | 0aed4d6 | 2001-09-19 15:53:27 +0000 | [diff] [blame] | 280 | // resync point of script code size |
| 281 | int scriptCodeResync; |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 282 | |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 283 | // Stores characters if we are scanning for a string like "</script>" |
darin | 7ab3109 | 2006-05-10 04:59:57 +0000 | [diff] [blame] | 284 | UChar searchBuffer[10]; |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 285 | // Counts where we are in the string we are scanning for |
| 286 | int searchCount; |
| 287 | // The string we are searching for |
darin | 7ab3109 | 2006-05-10 04:59:57 +0000 | [diff] [blame] | 288 | const UChar* searchFor; |
gramps | 0aed4d6 | 2001-09-19 15:53:27 +0000 | [diff] [blame] | 289 | // the stopper string |
| 290 | const char* searchStopper; |
| 291 | // the stopper len |
| 292 | int searchStopperLen; |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 293 | // if no more data is coming, just parse what we have (including ext scripts that |
| 294 | // may be still downloading) and finish |
| 295 | bool noMoreData; |
| 296 | // URL to get source code of script from |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 297 | DeprecatedString scriptSrc; |
darin | b3547a3 | 2006-09-06 04:40:44 +0000 | [diff] [blame] | 298 | String scriptSrcCharset; |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 299 | bool javascript; |
| 300 | // the HTML code we will parse after the external script we are waiting for has loaded |
hyatt | d2c53f2 | 2006-01-15 07:12:43 +0000 | [diff] [blame] | 301 | SegmentedString pendingSrc; |
mjs | 4ed3d11 | 2004-07-20 20:45:22 +0000 | [diff] [blame] | 302 | |
| 303 | // the HTML code we will parse after this particular script has |
| 304 | // loaded, but before all pending HTML |
hyatt | d2c53f2 | 2006-01-15 07:12:43 +0000 | [diff] [blame] | 305 | SegmentedString *currentPrependingSrc; |
mjs | 4ed3d11 | 2004-07-20 20:45:22 +0000 | [diff] [blame] | 306 | |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 307 | // true if we are executing a script while parsing a document. This causes the parsing of |
| 308 | // the output of the script to be postponed until after the script has finished executing |
| 309 | int m_executingScript; |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 310 | DeprecatedPtrQueue<CachedScript> pendingScripts; |
| 311 | RefPtr<Node> scriptNode; |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 312 | |
ddkilzer | 24652a9 | 2006-07-02 11:39:43 +0000 | [diff] [blame] | 313 | bool m_requestingScript; |
| 314 | |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 315 | // if we found one broken comment, there are most likely others as well |
| 316 | // store a flag to get rid of the O(n^2) behaviour in such a case. |
| 317 | bool brokenComments; |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 318 | // current line number |
| 319 | int lineno; |
| 320 | // line number at which the current <script> started |
| 321 | int scriptStartLineno; |
| 322 | int tagStartLineno; |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 323 | |
hyatt | 9c4ba9b | 2004-11-10 03:47:56 +0000 | [diff] [blame] | 324 | // The timer for continued processing. |
darin | a52f4e1 | 2006-02-02 02:51:03 +0000 | [diff] [blame] | 325 | Timer<HTMLTokenizer> m_timer; |
hyatt | 9c4ba9b | 2004-11-10 03:47:56 +0000 | [diff] [blame] | 326 | |
sullivan | 6062ecb | 2003-07-24 22:43:50 +0000 | [diff] [blame] | 327 | // This buffer can hold arbitrarily long user-defined attribute names, such as in EMBED tags. |
| 328 | // So any fixed number might be too small, but rather than rewriting all usage of this buffer |
| 329 | // we'll just make it large enough to handle all imaginable cases. |
| 330 | #define CBUFLEN 1024 |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 331 | char cBuffer[CBUFLEN+2]; |
mjs | b1c8f66 | 2005-10-18 03:15:31 +0000 | [diff] [blame] | 332 | unsigned int m_cBufferPos; |
kdecker | 2e74e95 | 2005-03-15 21:44:32 +0000 | [diff] [blame] | 333 | |
hyatt | d2c53f2 | 2006-01-15 07:12:43 +0000 | [diff] [blame] | 334 | SegmentedString src; |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 335 | Document* m_doc; |
darin | 644b75e | 2006-02-21 06:59:15 +0000 | [diff] [blame] | 336 | HTMLParser* parser; |
darin | 895eae1 | 2003-01-12 17:01:13 +0000 | [diff] [blame] | 337 | bool inWrite; |
darin | e9700da | 2006-03-06 23:09:48 +0000 | [diff] [blame] | 338 | bool m_fragment; |
kocienda | bb0c24b | 2001-08-24 14:24:40 +0000 | [diff] [blame] | 339 | }; |
darin | b95d6c4 | 2002-06-04 00:19:07 +0000 | [diff] [blame] | 340 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 341 | void parseHTMLDocumentFragment(const String&, DocumentFragment*); |
darin | 644b75e | 2006-02-21 06:59:15 +0000 | [diff] [blame] | 342 | |
darin | 7ab3109 | 2006-05-10 04:59:57 +0000 | [diff] [blame] | 343 | UChar decodeNamedEntity(const char*); |
eseidel | 363bc0d | 2005-10-27 06:03:33 +0000 | [diff] [blame] | 344 | |
hyatt | 3b4f6d4 | 2004-02-07 01:19:44 +0000 | [diff] [blame] | 345 | } |
| 346 | |
darin | 644b75e | 2006-02-21 06:59:15 +0000 | [diff] [blame] | 347 | #endif |