OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 class AtomicHTMLToken; | 43 class AtomicHTMLToken; |
44 class DocumentFragment; | 44 class DocumentFragment; |
45 class Element; | 45 class Element; |
46 class HTMLDocument; | 46 class HTMLDocument; |
47 class HTMLDocumentParser; | 47 class HTMLDocumentParser; |
48 | 48 |
49 class HTMLTreeBuilder final : public GarbageCollectedFinalized<HTMLTreeBuilder>
{ | 49 class HTMLTreeBuilder final : public GarbageCollectedFinalized<HTMLTreeBuilder>
{ |
50 WTF_MAKE_NONCOPYABLE(HTMLTreeBuilder); | 50 WTF_MAKE_NONCOPYABLE(HTMLTreeBuilder); |
51 public: | 51 public: |
52 static HTMLTreeBuilder* create(HTMLDocumentParser* parser, HTMLDocument* doc
ument, ParserContentPolicy parserContentPolicy, const HTMLParserOptions& options
) | 52 // HTMLTreeBuilder can be created for non-HTMLDocument (XHTMLDocument) from
editing code. |
| 53 // TODO(kouhei): Fix editing code to always invoke HTML parser on HTMLDocume
nt. |
| 54 static HTMLTreeBuilder* create(HTMLDocumentParser* parser, Document& documen
t, ParserContentPolicy parserContentPolicy, const HTMLParserOptions& options) |
53 { | 55 { |
54 return new HTMLTreeBuilder(parser, document, parserContentPolicy, option
s); | 56 return new HTMLTreeBuilder(parser, document, parserContentPolicy, option
s); |
55 } | 57 } |
56 static HTMLTreeBuilder* create(HTMLDocumentParser* parser, DocumentFragment*
fragment, Element* contextElement, ParserContentPolicy parserContentPolicy, con
st HTMLParserOptions& options) | 58 static HTMLTreeBuilder* create(HTMLDocumentParser* parser, DocumentFragment*
fragment, Element* contextElement, ParserContentPolicy parserContentPolicy, con
st HTMLParserOptions& options) |
57 { | 59 { |
58 return new HTMLTreeBuilder(parser, fragment, contextElement, parserConte
ntPolicy, options); | 60 return new HTMLTreeBuilder(parser, fragment, contextElement, parserConte
ntPolicy, options); |
59 } | 61 } |
60 ~HTMLTreeBuilder(); | 62 ~HTMLTreeBuilder(); |
61 DECLARE_TRACE(); | 63 DECLARE_TRACE(); |
62 | 64 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 InCellMode, | 108 InCellMode, |
107 InSelectMode, | 109 InSelectMode, |
108 InSelectInTableMode, | 110 InSelectInTableMode, |
109 AfterBodyMode, | 111 AfterBodyMode, |
110 InFramesetMode, | 112 InFramesetMode, |
111 AfterFramesetMode, | 113 AfterFramesetMode, |
112 AfterAfterBodyMode, | 114 AfterAfterBodyMode, |
113 AfterAfterFramesetMode, | 115 AfterAfterFramesetMode, |
114 }; | 116 }; |
115 | 117 |
116 HTMLTreeBuilder(HTMLDocumentParser*, HTMLDocument*, ParserContentPolicy, con
st HTMLParserOptions&); | 118 HTMLTreeBuilder(HTMLDocumentParser*, Document&, ParserContentPolicy, const H
TMLParserOptions&); |
117 HTMLTreeBuilder(HTMLDocumentParser*, DocumentFragment*, Element* contextElem
ent, ParserContentPolicy, const HTMLParserOptions&); | 119 HTMLTreeBuilder(HTMLDocumentParser*, DocumentFragment*, Element* contextElem
ent, ParserContentPolicy, const HTMLParserOptions&); |
118 | 120 |
119 void processToken(AtomicHTMLToken*); | 121 void processToken(AtomicHTMLToken*); |
120 | 122 |
121 void processDoctypeToken(AtomicHTMLToken*); | 123 void processDoctypeToken(AtomicHTMLToken*); |
122 void processStartTag(AtomicHTMLToken*); | 124 void processStartTag(AtomicHTMLToken*); |
123 void processEndTag(AtomicHTMLToken*); | 125 void processEndTag(AtomicHTMLToken*); |
124 void processComment(AtomicHTMLToken*); | 126 void processComment(AtomicHTMLToken*); |
125 void processCharacter(AtomicHTMLToken*); | 127 void processCharacter(AtomicHTMLToken*); |
126 void processEndOfFile(AtomicHTMLToken*); | 128 void processEndOfFile(AtomicHTMLToken*); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 void resetInsertionModeAppropriately(); | 186 void resetInsertionModeAppropriately(); |
185 | 187 |
186 void processTemplateStartTag(AtomicHTMLToken*); | 188 void processTemplateStartTag(AtomicHTMLToken*); |
187 bool processTemplateEndTag(AtomicHTMLToken*); | 189 bool processTemplateEndTag(AtomicHTMLToken*); |
188 bool processEndOfFileForInTemplateContents(AtomicHTMLToken*); | 190 bool processEndOfFileForInTemplateContents(AtomicHTMLToken*); |
189 | 191 |
190 class FragmentParsingContext { | 192 class FragmentParsingContext { |
191 WTF_MAKE_NONCOPYABLE(FragmentParsingContext); | 193 WTF_MAKE_NONCOPYABLE(FragmentParsingContext); |
192 DISALLOW_NEW(); | 194 DISALLOW_NEW(); |
193 public: | 195 public: |
194 FragmentParsingContext(); | 196 FragmentParsingContext() = default; |
195 FragmentParsingContext(DocumentFragment*, Element* contextElement); | 197 void init(DocumentFragment*, Element* contextElement); |
196 ~FragmentParsingContext(); | |
197 | 198 |
198 DocumentFragment* fragment() const { return m_fragment; } | 199 DocumentFragment* fragment() const { return m_fragment; } |
199 Element* contextElement() const { ASSERT(m_fragment); return m_contextEl
ementStackItem->element(); } | 200 Element* contextElement() const { ASSERT(m_fragment); return m_contextEl
ementStackItem->element(); } |
200 HTMLStackItem* contextElementStackItem() const { ASSERT(m_fragment); ret
urn m_contextElementStackItem.get(); } | 201 HTMLStackItem* contextElementStackItem() const { ASSERT(m_fragment); ret
urn m_contextElementStackItem.get(); } |
201 | 202 |
202 DECLARE_TRACE(); | 203 DECLARE_TRACE(); |
203 | 204 |
204 private: | 205 private: |
205 Member<DocumentFragment> m_fragment; | 206 Member<DocumentFragment> m_fragment; |
206 Member<HTMLStackItem> m_contextElementStackItem; | 207 Member<HTMLStackItem> m_contextElementStackItem; |
(...skipping 26 matching lines...) Expand all Loading... |
233 | 234 |
234 Member<Element> m_scriptToProcess; // <script> tag which needs processing be
fore resuming the parser. | 235 Member<Element> m_scriptToProcess; // <script> tag which needs processing be
fore resuming the parser. |
235 TextPosition m_scriptToProcessStartPosition; // Starting line number of the
script tag needing processing. | 236 TextPosition m_scriptToProcessStartPosition; // Starting line number of the
script tag needing processing. |
236 | 237 |
237 HTMLParserOptions m_options; | 238 HTMLParserOptions m_options; |
238 }; | 239 }; |
239 | 240 |
240 } // namespace blink | 241 } // namespace blink |
241 | 242 |
242 #endif | 243 #endif |
OLD | NEW |