Chromium Code Reviews| 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) |
| 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) | 58 , m_options(options) |
| 59 { | 59 { |
| 60 m_tree.openElements()->pushRootNode(document); | 60 m_tree.openElements()->pushRootNode(document); |
| 61 } | 61 } |
| 62 | 62 |
| 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) | |
|
eseidel
2014/10/25 05:08:38
Do we no longer parse fragments? If not, we can r
| |
| 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() | 63 HTMLTreeBuilder::~HTMLTreeBuilder() |
| 89 { | 64 { |
| 90 } | 65 } |
| 91 | 66 |
| 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() | 67 void HTMLTreeBuilder::detach() |
| 101 { | 68 { |
| 102 #if ENABLE(ASSERT) | 69 #if ENABLE(ASSERT) |
| 103 // This call makes little sense in fragment mode, but for consistency | 70 // This call makes little sense in fragment mode, but for consistency |
| 104 // DocumentParser expects detach() to always be called before it's destroyed . | 71 // DocumentParser expects detach() to always be called before it's destroyed . |
| 105 m_isAttached = false; | 72 m_isAttached = false; |
| 106 #endif | 73 #endif |
| 107 // HTMLConstructionSite might be on the callstack when detach() is called | 74 // HTMLConstructionSite might be on the callstack when detach() is called |
| 108 // otherwise we'd just call m_tree.clear() here instead. | 75 // otherwise we'd just call m_tree.clear() here instead. |
| 109 m_tree.detach(); | 76 m_tree.detach(); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 void HTMLTreeBuilder::finished() | 218 void HTMLTreeBuilder::finished() |
| 252 { | 219 { |
| 253 if (isParsingFragment()) | 220 if (isParsingFragment()) |
| 254 return; | 221 return; |
| 255 ASSERT(m_isAttached); | 222 ASSERT(m_isAttached); |
| 256 // Warning, this may detach the parser. Do not do anything else after this. | 223 // Warning, this may detach the parser. Do not do anything else after this. |
| 257 m_tree.finishedParsing(); | 224 m_tree.finishedParsing(); |
| 258 } | 225 } |
| 259 | 226 |
| 260 } // namespace blink | 227 } // namespace blink |
| OLD | NEW |