Title: [143830] trunk/Source/WebCore
Revision
143830
Author
to...@chromium.org
Date
2013-02-22 19:28:41 -0800 (Fri, 22 Feb 2013)

Log Message

Threaded HTML parser fails resources/plain-text-unsafe.dat
https://bugs.webkit.org/show_bug.cgi?id=110538

Reviewed by Eric Seidel.

With this patch, the background HTML parser passes all tests in plain-text-unsafe.dat.

No new tests because covered by existing tests.

* html/parser/BackgroundHTMLParser.cpp:
(WebCore::tokenExitsSVG):
(WebCore):
(WebCore::tokenExitsMath):
(WebCore::BackgroundHTMLParser::simulateTreeBuilder):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (143829 => 143830)


--- trunk/Source/WebCore/ChangeLog	2013-02-23 03:18:36 UTC (rev 143829)
+++ trunk/Source/WebCore/ChangeLog	2013-02-23 03:28:41 UTC (rev 143830)
@@ -1,5 +1,22 @@
 2013-02-22  Tony Gentilcore  <to...@chromium.org>
 
+        Threaded HTML parser fails resources/plain-text-unsafe.dat
+        https://bugs.webkit.org/show_bug.cgi?id=110538
+
+        Reviewed by Eric Seidel.
+
+        With this patch, the background HTML parser passes all tests in plain-text-unsafe.dat.
+
+        No new tests because covered by existing tests.
+
+        * html/parser/BackgroundHTMLParser.cpp:
+        (WebCore::tokenExitsSVG):
+        (WebCore):
+        (WebCore::tokenExitsMath):
+        (WebCore::BackgroundHTMLParser::simulateTreeBuilder):
+
+2013-02-22  Tony Gentilcore  <to...@chromium.org>
+
         Correct InspectorInstrumentation for background HTML parser
         https://bugs.webkit.org/show_bug.cgi?id=110678
 

Modified: trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp (143829 => 143830)


--- trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp	2013-02-23 03:18:36 UTC (rev 143829)
+++ trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp	2013-02-23 03:28:41 UTC (rev 143830)
@@ -61,7 +61,7 @@
 
 #endif
 
-static inline bool tokenExitsForeignContent(const CompactHTMLToken& token)
+static bool tokenExitsForeignContent(const CompactHTMLToken& token)
 {
     // FIXME: This is copied from HTMLTreeBuilder::processTokenInForeignContent and changed to use threadSafeMatch.
     const String& tagName = token.data();
@@ -112,6 +112,23 @@
         || (threadSafeMatch(tagName, fontTag) && (token.getAttributeItem(colorAttr) || token.getAttributeItem(faceAttr) || token.getAttributeItem(sizeAttr)));
 }
 
+static bool tokenExitsSVG(const CompactHTMLToken& token)
+{
+    const String& tagName = token.data();
+    return equalIgnoringCase(tagName, SVGNames::foreignObjectTag.localName());
+}
+
+static bool tokenExitsMath(const CompactHTMLToken& token)
+{
+    // FIXME: This is copied from HTMLElementStack::isMathMLTextIntegrationPoint and changed to use threadSafeMatch.
+    const String& tagName = token.data();
+    return threadSafeMatch(tagName, MathMLNames::miTag)
+        || threadSafeMatch(tagName, MathMLNames::moTag)
+        || threadSafeMatch(tagName, MathMLNames::mnTag)
+        || threadSafeMatch(tagName, MathMLNames::msTag)
+        || threadSafeMatch(tagName, MathMLNames::mtextTag);
+}
+
 static const size_t pendingTokenLimit = 1000;
 
 BackgroundHTMLParser::BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser> > reference, PassOwnPtr<Configuration> config)
@@ -179,8 +196,8 @@
             m_namespaceStack.append(MathML);
         if (inForeignContent() && tokenExitsForeignContent(token))
             m_namespaceStack.removeLast();
-        // FIXME: Support tags that exit MathML.
-        if (m_namespaceStack.last() == SVG && equalIgnoringCase(tagName, SVGNames::foreignObjectTag.localName()))
+        if ((m_namespaceStack.last() == SVG && tokenExitsSVG(token))
+            || (m_namespaceStack.last() == MathML && tokenExitsMath(token)))
             m_namespaceStack.append(HTML);
         if (!inForeignContent()) {
             // FIXME: This is just a copy of Tokenizer::updateStateFor which uses threadSafeMatches.
@@ -202,10 +219,10 @@
 
     if (token.type() == HTMLToken::EndTag) {
         const String& tagName = token.data();
-        // FIXME: Support tags that exit MathML.
         if ((m_namespaceStack.last() == SVG && threadSafeMatch(tagName, SVGNames::svgTag))
             || (m_namespaceStack.last() == MathML && threadSafeMatch(tagName, MathMLNames::mathTag))
-            || (m_namespaceStack.contains(SVG) && m_namespaceStack.last() == HTML && equalIgnoringCase(tagName, SVGNames::foreignObjectTag.localName())))
+            || (m_namespaceStack.contains(SVG) && m_namespaceStack.last() == HTML && tokenExitsSVG(token))
+            || (m_namespaceStack.contains(MathML) && m_namespaceStack.last() == HTML && tokenExitsMath(token)))
             m_namespaceStack.removeLast();
         if (threadSafeMatch(tagName, scriptTag)) {
             if (!inForeignContent())
@@ -214,7 +231,8 @@
         }
     }
 
-    // FIXME: Need to set setForceNullCharacterReplacement based on m_inForeignContent as well.
+    // FIXME: Also setForceNullCharacterReplacement when in text mode.
+    m_tokenizer->setForceNullCharacterReplacement(inForeignContent());
     m_tokenizer->setShouldAllowCDATA(inForeignContent());
     return true;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to