Bug 711049 - Adjust MathML text integration point treatment to comply with spec changes. rs=smaug.
authorHenri Sivonen <hsivonen@iki.fi>
Mon, 02 Jan 2012 16:18:29 +0200
changeset 84882 f50dc1ff3794dbc313133276dbed60482db9742e
parent 84881 2f3dbb399dbfb981b293c70f8171b7924d6e8236
child 84883 f4f47800d2ff0b6736979f117d78bf13276f161d
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs711049
milestone12.0a1
Bug 711049 - Adjust MathML text integration point treatment to comply with spec changes. rs=smaug.
parser/html/javasrc/TreeBuilder.java
parser/html/nsHtml5TreeBuilder.cpp
parser/html/nsHtml5TreeBuilder.h
parser/htmlparser/tests/mochitest/html5_tree_construction_exceptions.js
--- a/parser/html/javasrc/TreeBuilder.java
+++ b/parser/html/javasrc/TreeBuilder.java
@@ -934,17 +934,17 @@ public abstract class TreeBuilder<T> imp
             }
         }
 
         // optimize the most common case
         switch (mode) {
             case IN_BODY:
             case IN_CELL:
             case IN_CAPTION:
-                if (!isInForeignButNotHtmlIntegrationPoint()) {
+                if (!isInForeignButNotHtmlOrMathTextIntegrationPoint()) {
                     reconstructTheActiveFormattingElements();
                 }
                 // fall through
             case TEXT:
                 accumulateCharacters(buf, start, length);
                 return;
             case IN_TABLE:
             case IN_TABLE_BODY:
@@ -993,17 +993,17 @@ public abstract class TreeBuilder<T> imp
                                                 - start);
                                         start = i;
                                     }
 
                                     /*
                                      * Reconstruct the active formatting
                                      * elements, if any.
                                      */
-                                    if (!isInForeignButNotHtmlIntegrationPoint()) {
+                                    if (!isInForeignButNotHtmlOrMathTextIntegrationPoint()) {
                                         flushCharacters();
                                         reconstructTheActiveFormattingElements();
                                     }
                                     /*
                                      * Append the token's character to the
                                      * current node.
                                      */
                                     break charactersloop;
@@ -1190,17 +1190,17 @@ public abstract class TreeBuilder<T> imp
                                         accumulateCharacters(buf, start, i
                                                 - start);
                                         start = i;
                                     }
                                     /*
                                      * Reconstruct the active formatting
                                      * elements, if any.
                                      */
-                                    if (!isInForeignButNotHtmlIntegrationPoint()) {
+                                    if (!isInForeignButNotHtmlOrMathTextIntegrationPoint()) {
                                         flushCharacters();
                                         reconstructTheActiveFormattingElements();
                                     }
                                     /*
                                      * Append the token's character to the
                                      * current node.
                                      */
                                     break charactersloop;
@@ -1305,21 +1305,17 @@ public abstract class TreeBuilder<T> imp
      * @see nu.validator.htmlparser.common.TokenHandler#zeroOriginatingReplacementCharacter()
      */
     public void zeroOriginatingReplacementCharacter() throws SAXException {
         if (mode == TEXT) {
             accumulateCharacters(REPLACEMENT_CHARACTER, 0, 1);
             return;
         }
         if (currentPtr >= 0) {
-            StackNode<T> stackNode = stack[currentPtr];
-            if (stackNode.ns == "http://www.w3.org/1999/xhtml") {
-                return;
-            }
-            if (stackNode.isHtmlIntegrationPoint()) {
+            if (isSpecialParentInForeign(stack[currentPtr])) {
                 return;
             }
             accumulateCharacters(REPLACEMENT_CHARACTER, 0, 1);
         }
     }
 
     public final void eof() throws SAXException {
         flushCharacters();
@@ -5275,20 +5271,21 @@ public abstract class TreeBuilder<T> imp
         return isInForeign();
     }
     
     private boolean isInForeign() {
         return currentPtr >= 0
                 && stack[currentPtr].ns != "http://www.w3.org/1999/xhtml";
     }
 
-    private boolean isInForeignButNotHtmlIntegrationPoint() {
-        return currentPtr >= 0
-                && stack[currentPtr].ns != "http://www.w3.org/1999/xhtml"
-                && !stack[currentPtr].isHtmlIntegrationPoint();
+    private boolean isInForeignButNotHtmlOrMathTextIntegrationPoint() {
+        if (currentPtr < 0) {
+            return false;
+        }
+        return !isSpecialParentInForeign(stack[currentPtr]);
     }
 
     /**
      * The argument MUST be an interned string or <code>null</code>.
      * 
      * @param context
      */
     public final void setFragmentContext(@Local String context,
--- a/parser/html/nsHtml5TreeBuilder.cpp
+++ b/parser/html/nsHtml5TreeBuilder.cpp
@@ -195,17 +195,17 @@ nsHtml5TreeBuilder::characters(const PRU
         return;
       }
     }
   }
   switch(mode) {
     case NS_HTML5TREE_BUILDER_IN_BODY:
     case NS_HTML5TREE_BUILDER_IN_CELL:
     case NS_HTML5TREE_BUILDER_IN_CAPTION: {
-      if (!isInForeignButNotHtmlIntegrationPoint()) {
+      if (!isInForeignButNotHtmlOrMathTextIntegrationPoint()) {
         reconstructTheActiveFormattingElements();
       }
     }
     case NS_HTML5TREE_BUILDER_TEXT: {
       accumulateCharacters(buf, start, length);
       return;
     }
     case NS_HTML5TREE_BUILDER_IN_TABLE:
@@ -241,17 +241,17 @@ nsHtml5TreeBuilder::characters(const PRU
               case NS_HTML5TREE_BUILDER_FRAMESET_OK:
               case NS_HTML5TREE_BUILDER_IN_BODY:
               case NS_HTML5TREE_BUILDER_IN_CELL:
               case NS_HTML5TREE_BUILDER_IN_CAPTION: {
                 if (start < i) {
                   accumulateCharacters(buf, start, i - start);
                   start = i;
                 }
-                if (!isInForeignButNotHtmlIntegrationPoint()) {
+                if (!isInForeignButNotHtmlOrMathTextIntegrationPoint()) {
                   flushCharacters();
                   reconstructTheActiveFormattingElements();
                 }
                 NS_HTML5_BREAK(charactersloop);
               }
               case NS_HTML5TREE_BUILDER_IN_SELECT:
               case NS_HTML5TREE_BUILDER_IN_SELECT_IN_TABLE: {
                 NS_HTML5_BREAK(charactersloop);
@@ -343,17 +343,17 @@ nsHtml5TreeBuilder::characters(const PRU
               }
               case NS_HTML5TREE_BUILDER_IN_BODY:
               case NS_HTML5TREE_BUILDER_IN_CELL:
               case NS_HTML5TREE_BUILDER_IN_CAPTION: {
                 if (start < i) {
                   accumulateCharacters(buf, start, i - start);
                   start = i;
                 }
-                if (!isInForeignButNotHtmlIntegrationPoint()) {
+                if (!isInForeignButNotHtmlOrMathTextIntegrationPoint()) {
                   flushCharacters();
                   reconstructTheActiveFormattingElements();
                 }
                 NS_HTML5_BREAK(charactersloop);
               }
               case NS_HTML5TREE_BUILDER_IN_TABLE:
               case NS_HTML5TREE_BUILDER_IN_TABLE_BODY:
               case NS_HTML5TREE_BUILDER_IN_ROW: {
@@ -433,21 +433,17 @@ nsHtml5TreeBuilder::characters(const PRU
 void 
 nsHtml5TreeBuilder::zeroOriginatingReplacementCharacter()
 {
   if (mode == NS_HTML5TREE_BUILDER_TEXT) {
     accumulateCharacters(REPLACEMENT_CHARACTER, 0, 1);
     return;
   }
   if (currentPtr >= 0) {
-    nsHtml5StackNode* stackNode = stack[currentPtr];
-    if (stackNode->ns == kNameSpaceID_XHTML) {
-      return;
-    }
-    if (stackNode->isHtmlIntegrationPoint()) {
+    if (isSpecialParentInForeign(stack[currentPtr])) {
       return;
     }
     accumulateCharacters(REPLACEMENT_CHARACTER, 0, 1);
   }
 }
 
 void 
 nsHtml5TreeBuilder::eof()
@@ -3813,19 +3809,22 @@ nsHtml5TreeBuilder::requestSuspension()
 
 bool 
 nsHtml5TreeBuilder::isInForeign()
 {
   return currentPtr >= 0 && stack[currentPtr]->ns != kNameSpaceID_XHTML;
 }
 
 bool 
-nsHtml5TreeBuilder::isInForeignButNotHtmlIntegrationPoint()
+nsHtml5TreeBuilder::isInForeignButNotHtmlOrMathTextIntegrationPoint()
 {
-  return currentPtr >= 0 && stack[currentPtr]->ns != kNameSpaceID_XHTML && !stack[currentPtr]->isHtmlIntegrationPoint();
+  if (currentPtr < 0) {
+    return false;
+  }
+  return !isSpecialParentInForeign(stack[currentPtr]);
 }
 
 void 
 nsHtml5TreeBuilder::setFragmentContext(nsIAtom* context, PRInt32 ns, nsIContent** node, bool quirks)
 {
   this->contextName = context;
   this->contextNamespace = ns;
   this->contextNode = node;
--- a/parser/html/nsHtml5TreeBuilder.h
+++ b/parser/html/nsHtml5TreeBuilder.h
@@ -213,17 +213,17 @@ class nsHtml5TreeBuilder : public nsAHtm
   public:
     inline bool cdataSectionAllowed()
     {
       return isInForeign();
     }
 
   private:
     bool isInForeign();
-    bool isInForeignButNotHtmlIntegrationPoint();
+    bool isInForeignButNotHtmlOrMathTextIntegrationPoint();
   public:
     void setFragmentContext(nsIAtom* context, PRInt32 ns, nsIContent** node, bool quirks);
   protected:
     nsIContent** currentNode();
   public:
     bool isScriptingEnabled();
     void setScriptingEnabled(bool scriptingEnabled);
     void flushCharacters();
--- a/parser/htmlparser/tests/mochitest/html5_tree_construction_exceptions.js
+++ b/parser/htmlparser/tests/mochitest/html5_tree_construction_exceptions.js
@@ -3,17 +3,9 @@
  * files under html5lib_tree_construction/. Please see
  * html5lib_tree_construction/html5lib_license.txt for the license for these
  * tests.
  */
 var html5Exceptions = {
   "<!doctype html><keygen><frameset>" : true, // Bug 101019
   "<select><keygen>" : true, // Bug 101019
   "<!DOCTYPE html><body><keygen>A" : true, // Bug 101019
-  "<!DOCTYPE html><math><mtext><p><i></p>a" : true, // Bug 711049
-  "<!DOCTYPE html><table><tr><td><math><mtext><p><i></p>a" : true, // Bug 711049
-  "<!DOCTYPE html><table><tr><td><math><mtext>\u0000a" : true, // Bug 711049
-  "<!DOCTYPE html><math><mi>a\u0000b" : true, // Bug 711049
-  "<!DOCTYPE html><math><mo>a\u0000b" : true, // Bug 711049
-  "<!DOCTYPE html><math><mn>a\u0000b" : true, // Bug 711049
-  "<!DOCTYPE html><math><ms>a\u0000b" : true, // Bug 711049
-  "<!DOCTYPE html><math><mtext>a\u0000b" : true, // Bug 711049
 }