Modified: trunk/Source/WebCore/ChangeLog (139041 => 139042)
--- trunk/Source/WebCore/ChangeLog 2013-01-08 08:15:16 UTC (rev 139041)
+++ trunk/Source/WebCore/ChangeLog 2013-01-08 08:23:01 UTC (rev 139042)
@@ -1,3 +1,37 @@
+2013-01-08 Adam Barth <[email protected]>
+
+ HTMLTreeBuilder shouldn't keep a Document pointer
+ https://bugs.webkit.org/show_bug.cgi?id=106268
+
+ Reviewed by Eric Seidel.
+
+ The tree builder shouldn't interact with the Document directly.
+ Instead, the tree builder should use the HTMLConstructionSite to
+ interact with the document.
+
+ Unfortunately, the HTMLTreeBuilder does need to read back one bit of
+ information (the quirks mode) from the Document. Currently the
+ HTMLConstructionSite reads the information directly from the Document.
+ If/when we move the parser onto its own thread, we'll need to keep
+ track of this bit on the parser thread. (We should be able to
+ encapsulate all that logic in the HTMLConstructionSite.)
+
+ * html/parser/HTMLConstructionSite.cpp:
+ (WebCore::HTMLConstructionSite::setDefaultCompatibilityMode):
+ (WebCore):
+ (WebCore::HTMLConstructionSite::finishedParsing):
+ (WebCore::HTMLConstructionSite::inQuirksMode):
+ * html/parser/HTMLConstructionSite.h:
+ (HTMLConstructionSite):
+ * html/parser/HTMLTreeBuilder.cpp:
+ (WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
+ (WebCore::HTMLTreeBuilder::detach):
+ (WebCore::HTMLTreeBuilder::processStartTagForInBody):
+ (WebCore::HTMLTreeBuilder::defaultForInitial):
+ (WebCore::HTMLTreeBuilder::finished):
+ * html/parser/HTMLTreeBuilder.h:
+ (HTMLTreeBuilder):
+
2013-01-08 Yuki Sekiguchi <[email protected]>
Float block's logical top margin is illegal in vertical writing mode.
Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp (139041 => 139042)
--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp 2013-01-08 08:15:16 UTC (rev 139041)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp 2013-01-08 08:23:01 UTC (rev 139042)
@@ -225,6 +225,20 @@
mergeAttributesFromTokenIntoElement(token, m_openElements.bodyElement());
}
+void HTMLConstructionSite::setDefaultCompatibilityMode()
+{
+ if (m_isParsingFragment)
+ return;
+ if (m_document->isSrcdocDocument())
+ return;
+ m_document->setCompatibilityMode(Document::QuirksMode);
+}
+
+void HTMLConstructionSite::finishedParsing()
+{
+ m_document->finishedParsing();
+}
+
void HTMLConstructionSite::insertDoctype(AtomicHTMLToken* token)
{
ASSERT(token->type() == HTMLTokenTypes::DOCTYPE);
@@ -480,6 +494,12 @@
m_openElements.pop();
}
+bool HTMLConstructionSite::inQuirksMode()
+{
+ // When we move the parser onto a background thread, we'll need to keep track of this bit on the parser thread.
+ return m_document->inQuirksMode();
+}
+
void HTMLConstructionSite::findFosterSite(HTMLConstructionSiteTask& task)
{
#if ENABLE(TEMPLATE_ELEMENT)
Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.h (139041 => 139042)
--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.h 2013-01-08 08:15:16 UTC (rev 139041)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.h 2013-01-08 08:23:01 UTC (rev 139042)
@@ -79,6 +79,9 @@
void detach();
void executeQueuedTasks();
+ void setDefaultCompatibilityMode();
+ void finishedParsing();
+
void insertDoctype(AtomicHTMLToken*);
void insertComment(AtomicHTMLToken*);
void insertCommentOnDocument(AtomicHTMLToken*);
@@ -108,6 +111,8 @@
void generateImpliedEndTags();
void generateImpliedEndTagsWithExclusion(const AtomicString& tagName);
+ bool inQuirksMode();
+
bool isEmpty() const { return !m_openElements.stackDepth(); }
HTMLElementStack::ElementRecord* currentElementRecord() const { return m_openElements.topRecord(); }
Element* currentElement() const { return m_openElements.top(); }
Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (139041 => 139042)
--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp 2013-01-08 08:15:16 UTC (rev 139041)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp 2013-01-08 08:23:01 UTC (rev 139042)
@@ -28,7 +28,6 @@
#include "HTMLTreeBuilder.h"
#include "Comment.h"
-#include "DOMWindow.h"
#include "DocumentFragment.h"
#include "DocumentType.h"
#include "HTMLDocument.h"
@@ -271,7 +270,9 @@
HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, HTMLDocument* document, bool, const HTMLParserOptions& options)
: m_framesetOk(true)
- , m_document(document)
+#ifndef NDEBUG
+ , m_isAttached(true)
+#endif
, m_tree(document, options.maximumDOMTreeDepth)
, m_insertionMode(InitialMode)
, m_originalInsertionMode(InitialMode)
@@ -286,8 +287,10 @@
// minimize code duplication between these constructors.
HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser, DocumentFragment* fragment, Element* contextElement, FragmentScriptingPermission scriptingPermission, const HTMLParserOptions& options)
: m_framesetOk(true)
+#ifndef NDEBUG
+ , m_isAttached(true)
+#endif
, m_fragmentContext(fragment, contextElement, scriptingPermission)
- , m_document(fragment->document())
, m_tree(fragment, scriptingPermission, options.maximumDOMTreeDepth)
, m_insertionMode(InitialMode)
, m_originalInsertionMode(InitialMode)
@@ -322,9 +325,11 @@
void HTMLTreeBuilder::detach()
{
+#ifndef NDEBUG
// This call makes little sense in fragment mode, but for consistency
// DocumentParser expects detach() to always be called before it's destroyed.
- m_document = 0;
+ m_isAttached = false;
+#endif
// HTMLConstructionSite might be on the callstack when detach() is called
// otherwise we'd just call m_tree.clear() here instead.
m_tree.detach();
@@ -824,7 +829,7 @@
return;
}
if (token->name() == tableTag) {
- if (!m_document->inQuirksMode() && m_tree.openElements()->inButtonScope(pTag))
+ if (!m_tree.inQuirksMode() && m_tree.openElements()->inButtonScope(pTag))
processFakeEndTag(pTag);
m_tree.insertHTMLElement(token);
m_framesetOk = false;
@@ -2612,8 +2617,7 @@
void HTMLTreeBuilder::defaultForInitial()
{
notImplemented();
- if (!m_fragmentContext.fragment() && !m_document->isSrcdocDocument())
- m_document->setCompatibilityMode(Document::QuirksMode);
+ m_tree.setDefaultCompatibilityMode();
// FIXME: parse error
setInsertionMode(BeforeHTMLMode);
}
@@ -2903,9 +2907,9 @@
ASSERT(m_templateInsertionModes.isEmpty());
#endif
- ASSERT(m_document);
+ ASSERT(m_isAttached);
// Warning, this may detach the parser. Do not do anything else after this.
- m_document->finishedParsing();
+ m_tree.finishedParsing();
}
void HTMLTreeBuilder::parseError(AtomicHTMLToken*)
Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h (139041 => 139042)
--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h 2013-01-08 08:15:16 UTC (rev 139041)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.h 2013-01-08 08:23:01 UTC (rev 139042)
@@ -187,8 +187,6 @@
template <bool shouldClose(const HTMLStackItem*)>
void processCloseWhenNestedTag(AtomicHTMLToken*);
- bool m_framesetOk;
-
void parseError(AtomicHTMLToken*);
InsertionMode insertionMode() const { return m_insertionMode; }
@@ -220,9 +218,11 @@
FragmentScriptingPermission m_scriptingPermission;
};
+ bool m_framesetOk;
+#ifndef NDEBUG
+ bool m_isAttached;
+#endif
FragmentParsingContext m_fragmentContext;
-
- Document* m_document;
HTMLConstructionSite m_tree;
// http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#insertion-mode