Changeset 139042 in webkit
- Timestamp:
- Jan 8, 2013, 12:23:01 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r139040 r139042 1 2013-01-08 Adam Barth <abarth@webkit.org> 2 3 HTMLTreeBuilder shouldn't keep a Document pointer 4 https://bugs.webkit.org/show_bug.cgi?id=106268 5 6 Reviewed by Eric Seidel. 7 8 The tree builder shouldn't interact with the Document directly. 9 Instead, the tree builder should use the HTMLConstructionSite to 10 interact with the document. 11 12 Unfortunately, the HTMLTreeBuilder does need to read back one bit of 13 information (the quirks mode) from the Document. Currently the 14 HTMLConstructionSite reads the information directly from the Document. 15 If/when we move the parser onto its own thread, we'll need to keep 16 track of this bit on the parser thread. (We should be able to 17 encapsulate all that logic in the HTMLConstructionSite.) 18 19 * html/parser/HTMLConstructionSite.cpp: 20 (WebCore::HTMLConstructionSite::setDefaultCompatibilityMode): 21 (WebCore): 22 (WebCore::HTMLConstructionSite::finishedParsing): 23 (WebCore::HTMLConstructionSite::inQuirksMode): 24 * html/parser/HTMLConstructionSite.h: 25 (HTMLConstructionSite): 26 * html/parser/HTMLTreeBuilder.cpp: 27 (WebCore::HTMLTreeBuilder::HTMLTreeBuilder): 28 (WebCore::HTMLTreeBuilder::detach): 29 (WebCore::HTMLTreeBuilder::processStartTagForInBody): 30 (WebCore::HTMLTreeBuilder::defaultForInitial): 31 (WebCore::HTMLTreeBuilder::finished): 32 * html/parser/HTMLTreeBuilder.h: 33 (HTMLTreeBuilder): 34 1 35 2013-01-08 Yuki Sekiguchi <yuki.sekiguchi@access-company.com> 2 36 -
trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp
r136467 r139042 226 226 } 227 227 228 void HTMLConstructionSite::setDefaultCompatibilityMode() 229 { 230 if (m_isParsingFragment) 231 return; 232 if (m_document->isSrcdocDocument()) 233 return; 234 m_document->setCompatibilityMode(Document::QuirksMode); 235 } 236 237 void HTMLConstructionSite::finishedParsing() 238 { 239 m_document->finishedParsing(); 240 } 241 228 242 void HTMLConstructionSite::insertDoctype(AtomicHTMLToken* token) 229 243 { … … 481 495 } 482 496 497 bool HTMLConstructionSite::inQuirksMode() 498 { 499 // When we move the parser onto a background thread, we'll need to keep track of this bit on the parser thread. 500 return m_document->inQuirksMode(); 501 } 502 483 503 void HTMLConstructionSite::findFosterSite(HTMLConstructionSiteTask& task) 484 504 { -
trunk/Source/WebCore/html/parser/HTMLConstructionSite.h
r136467 r139042 80 80 void executeQueuedTasks(); 81 81 82 void setDefaultCompatibilityMode(); 83 void finishedParsing(); 84 82 85 void insertDoctype(AtomicHTMLToken*); 83 86 void insertComment(AtomicHTMLToken*); … … 108 111 void generateImpliedEndTags(); 109 112 void generateImpliedEndTagsWithExclusion(const AtomicString& tagName); 113 114 bool inQuirksMode(); 110 115 111 116 bool isEmpty() const { return !m_openElements.stackDepth(); } -
trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp
r139020 r139042 29 29 30 30 #include "Comment.h" 31 #include "DOMWindow.h"32 31 #include "DocumentFragment.h" 33 32 #include "DocumentType.h" … … 272 271 HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, HTMLDocument* document, bool, const HTMLParserOptions& options) 273 272 : m_framesetOk(true) 274 , m_document(document) 273 #ifndef NDEBUG 274 , m_isAttached(true) 275 #endif 275 276 , m_tree(document, options.maximumDOMTreeDepth) 276 277 , m_insertionMode(InitialMode) … … 287 288 HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission scriptingPermission, const HTMLParserOptions& options) 288 289 : m_framesetOk(true) 290 #ifndef NDEBUG 291 , m_isAttached(true) 292 #endif 289 293 , m_fragmentContext(fragment, contextElement, scriptingPermission) 290 , m_document(fragment->document())291 294 , m_tree(fragment, scriptingPermission, options.maximumDOMTreeDepth) 292 295 , m_insertionMode(InitialMode) … … 323 326 void HTMLTreeBuilder::detach() 324 327 { 328 #ifndef NDEBUG 325 329 // This call makes little sense in fragment mode, but for consistency 326 330 // DocumentParser expects detach() to always be called before it's destroyed. 327 m_document = 0; 331 m_isAttached = false; 332 #endif 328 333 // HTMLConstructionSite might be on the callstack when detach() is called 329 334 // otherwise we'd just call m_tree.clear() here instead. … … 825 830 } 826 831 if (token->name() == tableTag) { 827 if (!m_ document->inQuirksMode() && m_tree.openElements()->inButtonScope(pTag))832 if (!m_tree.inQuirksMode() && m_tree.openElements()->inButtonScope(pTag)) 828 833 processFakeEndTag(pTag); 829 834 m_tree.insertHTMLElement(token); … … 2613 2618 { 2614 2619 notImplemented(); 2615 if (!m_fragmentContext.fragment() && !m_document->isSrcdocDocument()) 2616 m_document->setCompatibilityMode(Document::QuirksMode); 2620 m_tree.setDefaultCompatibilityMode(); 2617 2621 // FIXME: parse error 2618 2622 setInsertionMode(BeforeHTMLMode); … … 2904 2908 #endif 2905 2909 2906 ASSERT(m_ document);2910 ASSERT(m_isAttached); 2907 2911 // Warning, this may detach the parser. Do not do anything else after this. 2908 m_ document->finishedParsing();2912 m_tree.finishedParsing(); 2909 2913 } 2910 2914 -
trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h
r139020 r139042 188 188 void processCloseWhenNestedTag(AtomicHTMLToken*); 189 189 190 bool m_framesetOk;191 192 190 void parseError(AtomicHTMLToken*); 193 191 … … 221 219 }; 222 220 221 bool m_framesetOk; 222 #ifndef NDEBUG 223 bool m_isAttached; 224 #endif 223 225 FragmentParsingContext m_fragmentContext; 224 225 Document* m_document;226 226 HTMLConstructionSite m_tree; 227 227
Note:
See TracChangeset
for help on using the changeset viewer.