2010-07-12 Eric Seidel <eric@webkit.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Jul 2010 21:13:09 +0000 (21:13 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Jul 2010 21:13:09 +0000 (21:13 +0000)
        Reviewed by Adam Barth.

        HTMLTreeBuilder needs to support mixing SVG and MathML content
        https://bugs.webkit.org/show_bug.cgi?id=42096

        * html5lib/runner-expected-html5.txt:
2010-07-12  Eric Seidel  <eric@webkit.org>

        Reviewed by Adam Barth.

        HTMLTreeBuilder needs to support mixing SVG and MathML content
        https://bugs.webkit.org/show_bug.cgi?id=42096

        This is just a direct transcription of another paragraph of the
        HTML5 spec.

        This improved a couple results in html5lib/runner.html, but more
        work to do yet to pass all the foreign content tests.

        * html/HTMLTreeBuilder.cpp:
        (WebCore::HTMLTreeBuilder::processStartTag):
        (WebCore::HTMLTreeBuilder::processEndTag):
        (WebCore::HTMLTreeBuilder::processUsingSecondaryInsertionModeAndAdjustInsertionMode):
        * html/HTMLTreeBuilder.h:
        * mathml/mathtags.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@63116 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/html5lib/runner-expected-html5.txt
WebCore/ChangeLog
WebCore/html/HTMLTreeBuilder.cpp
WebCore/html/HTMLTreeBuilder.h
WebCore/mathml/mathtags.in

index 56629e7..a0e780f 100644 (file)
@@ -2,6 +2,15 @@
 
         Reviewed by Adam Barth.
 
+        HTMLTreeBuilder needs to support mixing SVG and MathML content
+        https://bugs.webkit.org/show_bug.cgi?id=42096
+
+        * html5lib/runner-expected-html5.txt:
+
+2010-07-12  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Adam Barth.
+
         Update HTMLTreeBuilder now that MathMLNames is always generated
         https://bugs.webkit.org/show_bug.cgi?id=42059
 
index 6d86342..59e5ee9 100644 (file)
@@ -728,24 +728,25 @@ Got:
 |       "foo"
 |       <math math>
 |         <math mtext>
-|           <math i>
+|           <i>
 |             "baz"
 |         <math annotation-xml>
-|           <math svg>
-|             <math desc>
-|               <math b>
+|           <svg svg>
+|             <svg desc>
+|               <b>
 |                 "eggs"
-|             <math g>
-|               <math foreignobject>
-|                 <math p>
+|             <svg g>
+|               <svg foreignObject>
+|                 <p>
 |                   "spam"
-|                   <math table>
-|                     <math tr>
-|                       <math td>
-|                         <math img>
-|                           <math g>
-|                             "quux"
-|                           "bar"
+|                 <table>
+|                   <tbody>
+|                     <tr>
+|                       <td>
+|                         <img>
+|                 <g>
+|                   "quux"
+|                 "bar"
 Expected:
 | <!DOCTYPE html>
 | <html>
@@ -785,24 +786,25 @@ Got:
 |     "foo"
 |     <math math>
 |       <math mtext>
-|         <math i>
+|         <i>
 |           "baz"
 |       <math annotation-xml>
-|         <math svg>
-|           <math desc>
-|             <math b>
+|         <svg svg>
+|           <svg desc>
+|             <b>
 |               "eggs"
-|           <math g>
-|             <math foreignobject>
-|               <math p>
+|           <svg g>
+|             <svg foreignObject>
+|               <p>
 |                 "spam"
-|                 <math table>
-|                   <math tr>
-|                     <math td>
-|                       <math img>
-|                         <math g>
-|                           "quux"
-|                         "bar"
+|               <table>
+|                 <tbody>
+|                   <tr>
+|                     <td>
+|                       <img>
+|               <g>
+|                 "quux"
+|               "bar"
 Expected:
 | <!DOCTYPE html>
 | <html>
index ebd9816..dcea761 100644 (file)
@@ -2,6 +2,26 @@
 
         Reviewed by Adam Barth.
 
+        HTMLTreeBuilder needs to support mixing SVG and MathML content
+        https://bugs.webkit.org/show_bug.cgi?id=42096
+
+        This is just a direct transcription of another paragraph of the
+        HTML5 spec.
+
+        This improved a couple results in html5lib/runner.html, but more
+        work to do yet to pass all the foreign content tests.
+
+        * html/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processStartTag):
+        (WebCore::HTMLTreeBuilder::processEndTag):
+        (WebCore::HTMLTreeBuilder::processUsingSecondaryInsertionModeAndAdjustInsertionMode):
+        * html/HTMLTreeBuilder.h:
+        * mathml/mathtags.in:
+
+2010-07-12  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Adam Barth.
+
         Update HTMLTreeBuilder now that MathMLNames is always generated
         https://bugs.webkit.org/show_bug.cgi?id=42059
 
index 00f94c8..c3761b0 100644 (file)
@@ -1148,6 +1148,30 @@ void HTMLTreeBuilder::processStartTagForInTable(AtomicHTMLToken& token)
     processStartTagForInBody(token);
 }
 
+namespace {
+
+bool shouldProcessUsingSecondaryInsertionMode(AtomicHTMLToken& token, Element* currentElement)
+{
+    ASSERT(token.type() == HTMLToken::StartTag);
+    if (currentElement->hasTagName(MathMLNames::miTag)
+        || currentElement->hasTagName(MathMLNames::moTag)
+        || currentElement->hasTagName(MathMLNames::mnTag)
+        || currentElement->hasTagName(MathMLNames::msTag)
+        || currentElement->hasTagName(MathMLNames::mtextTag)) {
+        return token.name() != MathMLNames::mglyphTag
+            && token.name() != MathMLNames::malignmarkTag;
+    }
+    if (currentElement->hasTagName(MathMLNames::annotation_xmlTag))
+        return token.name() == SVGNames::svgTag;
+    if (currentElement->hasTagName(SVGNames::foreignObjectTag)
+        || currentElement->hasTagName(SVGNames::descTag)
+        || currentElement->hasTagName(SVGNames::titleTag))
+        return true;
+    return currentElement->namespaceURI() == HTMLNames::xhtmlNamespaceURI;
+}
+
+}
+
 void HTMLTreeBuilder::processStartTag(AtomicHTMLToken& token)
 {
     ASSERT(token.type() == HTMLToken::StartTag);
@@ -1463,6 +1487,10 @@ void HTMLTreeBuilder::processStartTag(AtomicHTMLToken& token)
         break;
     case InForeignContentMode: {
         // FIXME: We're missing a bunch of if branches here.
+        if (shouldProcessUsingSecondaryInsertionMode(token, m_tree.currentElement())) {
+            processUsingSecondaryInsertionModeAndAdjustInsertionMode(token);
+            return;
+        }
         notImplemented();
         const AtomicString& currentNamespace = m_tree.currentElement()->namespaceURI();
         if (currentNamespace == MathMLNames::mathmlNamespaceURI)
@@ -2278,11 +2306,11 @@ void HTMLTreeBuilder::processEndTag(AtomicHTMLToken& token)
                 }
                 nodeRecord = nodeRecord->next();
                 if (nodeRecord->element()->namespaceURI() == xhtmlNamespaceURI)
-                    processEndTagUsingSecondaryInsertionModeAndAdjustInsertionMode(token);
+                    processUsingSecondaryInsertionModeAndAdjustInsertionMode(token);
             }
             return;
         }
-        processEndTagUsingSecondaryInsertionModeAndAdjustInsertionMode(token);
+        processUsingSecondaryInsertionModeAndAdjustInsertionMode(token);
         break;
     }
 }
@@ -2310,11 +2338,12 @@ private:
 // This handles both secondary insertion mode processing, as well as updating
 // the insertion mode.  These are separate steps in the spec, but always occur
 // right after one another.
-void HTMLTreeBuilder::processEndTagUsingSecondaryInsertionModeAndAdjustInsertionMode(AtomicHTMLToken& token)
+void HTMLTreeBuilder::processUsingSecondaryInsertionModeAndAdjustInsertionMode(AtomicHTMLToken& token)
 {
+    ASSERT(token.type() == HTMLToken::StartTag || token.type() == HTMLToken::EndTag);
     {
         FakeInsertionMode fakeMode(this, m_secondaryInsertionMode);
-        processEndTag(token);
+        processToken(token);
     }
     if (insertionMode() == InForeignContentMode && m_tree.openElements()->hasOnlyHTMLElementsInScope())
         setInsertionMode(m_secondaryInsertionMode);
index 5784217..74e3398 100644 (file)
@@ -153,7 +153,7 @@ private:
     void processDefaultForAfterHeadMode(AtomicHTMLToken&);
     void processDefaultForInTableTextMode(AtomicHTMLToken&);
 
-    void processEndTagUsingSecondaryInsertionModeAndAdjustInsertionMode(AtomicHTMLToken&);
+    void processUsingSecondaryInsertionModeAndAdjustInsertionMode(AtomicHTMLToken&);
 
     PassRefPtr<NamedNodeMap> attributesForIsindexInput(AtomicHTMLToken&);
 
index e9cc4ad..5bb369a 100644 (file)
@@ -18,3 +18,10 @@ mo interfaceName=MathMLTextElement
 mtext interfaceName=MathMLTextElement
 msub interfaceName=MathMLElement
 msup interfaceName=MathMLElement
+
+#if 0 // Curently only for MathMLNames used by HTMLTreeBuilder.
+ms
+mglyph
+malignmark
+annotation-xml
+#endif