| 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, 2014 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011, 2014 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 27 matching lines...) Expand all Loading... |
| 38 #include "core/html/parser/HTMLToken.h" | 38 #include "core/html/parser/HTMLToken.h" |
| 39 #include "core/html/parser/HTMLTokenizer.h" | 39 #include "core/html/parser/HTMLTokenizer.h" |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 static TextPosition uninitializedPositionValue1() | 43 static TextPosition uninitializedPositionValue1() |
| 44 { | 44 { |
| 45 return TextPosition(OrdinalNumber::fromOneBasedInt(-1), OrdinalNumber::first
()); | 45 return TextPosition(OrdinalNumber::fromOneBasedInt(-1), OrdinalNumber::first
()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, HTMLDocument* docum
ent, bool, const HTMLParserOptions& options) | 48 HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, HTMLDocument* docum
ent, bool) |
| 49 : | 49 : |
| 50 #if ENABLE(ASSERT) | 50 #if ENABLE(ASSERT) |
| 51 m_isAttached(true), | 51 m_isAttached(true), |
| 52 #endif | 52 #endif |
| 53 m_tree(document) | 53 m_tree(document) |
| 54 , m_insertionMode(HTMLMode) | 54 , m_insertionMode(HTMLMode) |
| 55 , m_originalInsertionMode(HTMLMode) | 55 , m_originalInsertionMode(HTMLMode) |
| 56 , m_parser(parser) | 56 , m_parser(parser) |
| 57 , m_scriptToProcessStartPosition(uninitializedPositionValue1()) | 57 , m_scriptToProcessStartPosition(uninitializedPositionValue1()) |
| 58 , m_options(options) | |
| 59 { | 58 { |
| 60 m_tree.openElements()->pushRootNode(document); | 59 m_tree.openElements()->pushRootNode(document); |
| 61 } | 60 } |
| 62 | 61 |
| 63 // FIXME: Member variables should be grouped into self-initializing structs to | |
| 64 // minimize code duplication between these constructors. | |
| 65 HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, DocumentFragment* f
ragment, Element* contextElement, const HTMLParserOptions& options) | |
| 66 : | |
| 67 #if ENABLE(ASSERT) | |
| 68 m_isAttached(true), | |
| 69 #endif | |
| 70 m_fragmentContext(fragment, contextElement) | |
| 71 , m_tree(fragment) | |
| 72 , m_insertionMode(HTMLMode) | |
| 73 , m_originalInsertionMode(HTMLMode) | |
| 74 , m_parser(parser) | |
| 75 , m_scriptToProcessStartPosition(uninitializedPositionValue1()) | |
| 76 , m_options(options) | |
| 77 { | |
| 78 ASSERT(isMainThread()); | |
| 79 ASSERT(contextElement); | |
| 80 | |
| 81 // Steps 4.2-4.6 of the HTML5 Fragment Case parsing algorithm: | |
| 82 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#
fragment-case | |
| 83 // For efficiency, we skip step 4.2 ("Let root be a new html element with no
attributes") | |
| 84 // and instead use the DocumentFragment as a root node. | |
| 85 m_tree.openElements()->pushRootNode(fragment); | |
| 86 } | |
| 87 | |
| 88 HTMLTreeBuilder::~HTMLTreeBuilder() | 62 HTMLTreeBuilder::~HTMLTreeBuilder() |
| 89 { | 63 { |
| 90 } | 64 } |
| 91 | 65 |
| 92 void HTMLTreeBuilder::trace(Visitor* visitor) | |
| 93 { | |
| 94 visitor->trace(m_fragmentContext); | |
| 95 visitor->trace(m_tree); | |
| 96 visitor->trace(m_parser); | |
| 97 visitor->trace(m_scriptToProcess); | |
| 98 } | |
| 99 | |
| 100 void HTMLTreeBuilder::detach() | 66 void HTMLTreeBuilder::detach() |
| 101 { | 67 { |
| 102 #if ENABLE(ASSERT) | 68 #if ENABLE(ASSERT) |
| 103 // This call makes little sense in fragment mode, but for consistency | 69 // This call makes little sense in fragment mode, but for consistency |
| 104 // DocumentParser expects detach() to always be called before it's destroyed
. | 70 // DocumentParser expects detach() to always be called before it's destroyed
. |
| 105 m_isAttached = false; | 71 m_isAttached = false; |
| 106 #endif | 72 #endif |
| 107 // HTMLConstructionSite might be on the callstack when detach() is called | 73 // HTMLConstructionSite might be on the callstack when detach() is called |
| 108 // otherwise we'd just call m_tree.clear() here instead. | 74 // otherwise we'd just call m_tree.clear() here instead. |
| 109 m_tree.detach(); | 75 m_tree.detach(); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 void HTMLTreeBuilder::finished() | 217 void HTMLTreeBuilder::finished() |
| 252 { | 218 { |
| 253 if (isParsingFragment()) | 219 if (isParsingFragment()) |
| 254 return; | 220 return; |
| 255 ASSERT(m_isAttached); | 221 ASSERT(m_isAttached); |
| 256 // Warning, this may detach the parser. Do not do anything else after this. | 222 // Warning, this may detach the parser. Do not do anything else after this. |
| 257 m_tree.finishedParsing(); | 223 m_tree.finishedParsing(); |
| 258 } | 224 } |
| 259 | 225 |
| 260 } // namespace blink | 226 } // namespace blink |
| OLD | NEW |