| 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 29 matching lines...) Expand all Loading... |
| 40 #include "wtf/text/TextPosition.h" | 40 #include "wtf/text/TextPosition.h" |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 class AtomicHTMLToken; | 44 class AtomicHTMLToken; |
| 45 class DocumentFragment; | 45 class DocumentFragment; |
| 46 class Element; | 46 class Element; |
| 47 class HTMLDocument; | 47 class HTMLDocument; |
| 48 class HTMLDocumentParser; | 48 class HTMLDocumentParser; |
| 49 | 49 |
| 50 class HTMLTreeBuilder final : public NoBaseWillBeGarbageCollectedFinalized<HTMLT
reeBuilder> { | 50 class HTMLTreeBuilder final : public GarbageCollectedFinalized<HTMLTreeBuilder>
{ |
| 51 WTF_MAKE_NONCOPYABLE(HTMLTreeBuilder); USING_FAST_MALLOC_WILL_BE_REMOVED(HTM
LTreeBuilder); | 51 WTF_MAKE_NONCOPYABLE(HTMLTreeBuilder); |
| 52 public: | 52 public: |
| 53 static PassOwnPtrWillBeRawPtr<HTMLTreeBuilder> create(HTMLDocumentParser* pa
rser, HTMLDocument* document, ParserContentPolicy parserContentPolicy, bool repo
rtErrors, const HTMLParserOptions& options) | 53 static RawPtr<HTMLTreeBuilder> create(HTMLDocumentParser* parser, HTMLDocume
nt* document, ParserContentPolicy parserContentPolicy, bool reportErrors, const
HTMLParserOptions& options) |
| 54 { | 54 { |
| 55 return adoptPtrWillBeNoop(new HTMLTreeBuilder(parser, document, parserCo
ntentPolicy, reportErrors, options)); | 55 return new HTMLTreeBuilder(parser, document, parserContentPolicy, report
Errors, options); |
| 56 } | 56 } |
| 57 static PassOwnPtrWillBeRawPtr<HTMLTreeBuilder> create(HTMLDocumentParser* pa
rser, DocumentFragment* fragment, Element* contextElement, ParserContentPolicy p
arserContentPolicy, const HTMLParserOptions& options) | 57 static RawPtr<HTMLTreeBuilder> create(HTMLDocumentParser* parser, DocumentFr
agment* fragment, Element* contextElement, ParserContentPolicy parserContentPoli
cy, const HTMLParserOptions& options) |
| 58 { | 58 { |
| 59 return adoptPtrWillBeNoop(new HTMLTreeBuilder(parser, fragment, contextE
lement, parserContentPolicy, options)); | 59 return new HTMLTreeBuilder(parser, fragment, contextElement, parserConte
ntPolicy, options); |
| 60 } | 60 } |
| 61 ~HTMLTreeBuilder(); | 61 ~HTMLTreeBuilder(); |
| 62 DECLARE_TRACE(); | 62 DECLARE_TRACE(); |
| 63 | 63 |
| 64 const HTMLElementStack* openElements() const { return m_tree.openElements();
} | 64 const HTMLElementStack* openElements() const { return m_tree.openElements();
} |
| 65 | 65 |
| 66 bool isParsingFragment() const { return !!m_fragmentContext.fragment(); } | 66 bool isParsingFragment() const { return !!m_fragmentContext.fragment(); } |
| 67 bool isParsingTemplateContents() const { return m_tree.openElements()->hasTe
mplateInHTMLScope(); } | 67 bool isParsingTemplateContents() const { return m_tree.openElements()->hasTe
mplateInHTMLScope(); } |
| 68 bool isParsingFragmentOrTemplateContents() const { return isParsingFragment(
) || isParsingTemplateContents(); } | 68 bool isParsingFragmentOrTemplateContents() const { return isParsingFragment(
) || isParsingTemplateContents(); } |
| 69 | 69 |
| 70 void detach(); | 70 void detach(); |
| 71 | 71 |
| 72 void constructTree(AtomicHTMLToken*); | 72 void constructTree(AtomicHTMLToken*); |
| 73 | 73 |
| 74 bool hasParserBlockingScript() const { return !!m_scriptToProcess; } | 74 bool hasParserBlockingScript() const { return !!m_scriptToProcess; } |
| 75 // Must be called to take the parser-blocking script before calling the pars
er again. | 75 // Must be called to take the parser-blocking script before calling the pars
er again. |
| 76 PassRefPtrWillBeRawPtr<Element> takeScriptToProcess(TextPosition& scriptStar
tPosition); | 76 RawPtr<Element> takeScriptToProcess(TextPosition& scriptStartPosition); |
| 77 | 77 |
| 78 // Done, close any open tags, etc. | 78 // Done, close any open tags, etc. |
| 79 void finished(); | 79 void finished(); |
| 80 | 80 |
| 81 // Synchronously flush pending text and queued tasks, possibly creating more
DOM nodes. | 81 // Synchronously flush pending text and queued tasks, possibly creating more
DOM nodes. |
| 82 // Flushing pending text depends on |mode|. | 82 // Flushing pending text depends on |mode|. |
| 83 void flush(FlushMode mode) { m_tree.flush(mode); } | 83 void flush(FlushMode mode) { m_tree.flush(mode); } |
| 84 | 84 |
| 85 void setShouldSkipLeadingNewline(bool shouldSkip) { m_shouldSkipLeadingNewli
ne = shouldSkip; } | 85 void setShouldSkipLeadingNewline(bool shouldSkip) { m_shouldSkipLeadingNewli
ne = shouldSkip; } |
| 86 | 86 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 FragmentParsingContext(DocumentFragment*, Element* contextElement); | 196 FragmentParsingContext(DocumentFragment*, Element* contextElement); |
| 197 ~FragmentParsingContext(); | 197 ~FragmentParsingContext(); |
| 198 | 198 |
| 199 DocumentFragment* fragment() const { return m_fragment; } | 199 DocumentFragment* fragment() const { return m_fragment; } |
| 200 Element* contextElement() const { ASSERT(m_fragment); return m_contextEl
ementStackItem->element(); } | 200 Element* contextElement() const { ASSERT(m_fragment); return m_contextEl
ementStackItem->element(); } |
| 201 HTMLStackItem* contextElementStackItem() const { ASSERT(m_fragment); ret
urn m_contextElementStackItem.get(); } | 201 HTMLStackItem* contextElementStackItem() const { ASSERT(m_fragment); ret
urn m_contextElementStackItem.get(); } |
| 202 | 202 |
| 203 DECLARE_TRACE(); | 203 DECLARE_TRACE(); |
| 204 | 204 |
| 205 private: | 205 private: |
| 206 RawPtrWillBeMember<DocumentFragment> m_fragment; | 206 Member<DocumentFragment> m_fragment; |
| 207 RefPtrWillBeMember<HTMLStackItem> m_contextElementStackItem; | 207 Member<HTMLStackItem> m_contextElementStackItem; |
| 208 }; | 208 }; |
| 209 | 209 |
| 210 // https://html.spec.whatwg.org/#frameset-ok-flag | 210 // https://html.spec.whatwg.org/#frameset-ok-flag |
| 211 bool m_framesetOk; | 211 bool m_framesetOk; |
| 212 #if ENABLE(ASSERT) | 212 #if ENABLE(ASSERT) |
| 213 bool m_isAttached; | 213 bool m_isAttached; |
| 214 #endif | 214 #endif |
| 215 FragmentParsingContext m_fragmentContext; | 215 FragmentParsingContext m_fragmentContext; |
| 216 HTMLConstructionSite m_tree; | 216 HTMLConstructionSite m_tree; |
| 217 | 217 |
| 218 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#
insertion-mode | 218 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#
insertion-mode |
| 219 InsertionMode m_insertionMode; | 219 InsertionMode m_insertionMode; |
| 220 | 220 |
| 221 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#
original-insertion-mode | 221 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#
original-insertion-mode |
| 222 InsertionMode m_originalInsertionMode; | 222 InsertionMode m_originalInsertionMode; |
| 223 | 223 |
| 224 Vector<InsertionMode> m_templateInsertionModes; | 224 Vector<InsertionMode> m_templateInsertionModes; |
| 225 | 225 |
| 226 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.
html#pending-table-character-tokens | 226 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.
html#pending-table-character-tokens |
| 227 StringBuilder m_pendingTableCharacters; | 227 StringBuilder m_pendingTableCharacters; |
| 228 | 228 |
| 229 bool m_shouldSkipLeadingNewline; | 229 bool m_shouldSkipLeadingNewline; |
| 230 | 230 |
| 231 // We access parser because HTML5 spec requires that we be able to change th
e state of the tokenizer | 231 // We access parser because HTML5 spec requires that we be able to change th
e state of the tokenizer |
| 232 // from within parser actions. We also need it to track the current position
. | 232 // from within parser actions. We also need it to track the current position
. |
| 233 RawPtrWillBeMember<HTMLDocumentParser> m_parser; | 233 Member<HTMLDocumentParser> m_parser; |
| 234 | 234 |
| 235 RefPtrWillBeMember<Element> m_scriptToProcess; // <script> tag which needs p
rocessing before resuming the parser. | 235 Member<Element> m_scriptToProcess; // <script> tag which needs processing be
fore resuming the parser. |
| 236 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. |
| 237 | 237 |
| 238 HTMLParserOptions m_options; | 238 HTMLParserOptions m_options; |
| 239 }; | 239 }; |
| 240 | 240 |
| 241 } // namespace blink | 241 } // namespace blink |
| 242 | 242 |
| 243 #endif | 243 #endif |
| OLD | NEW |