Bug 925907 - Check for IN_SELECT_IN_TABLE in "reset the insertion mode" in HTML5 parser. r=hsivonen
authorWilliam Chen <wchen@mozilla.com>
Thu, 17 Oct 2013 13:26:49 -0700
changeset 165931 253257d650a6b201e3acc6326d6344ccad969ca4
parent 165930 a6c52aabcdece06451ad7bbe26c0e75681de1681
child 165932 5349c5c0d9f86856d847e1d6a8f8e6d5f68a9114
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsivonen
bugs925907
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 925907 - Check for IN_SELECT_IN_TABLE in "reset the insertion mode" in HTML5 parser. r=hsivonen
parser/html/javasrc/TreeBuilder.java
parser/html/nsHtml5TreeBuilder.cpp
--- a/parser/html/javasrc/TreeBuilder.java
+++ b/parser/html/javasrc/TreeBuilder.java
@@ -4320,17 +4320,29 @@ public abstract class TreeBuilder<T> imp
                     name = contextName;
                     ns = contextNamespace;
                 } else {
                     mode = framesetOk ? FRAMESET_OK : IN_BODY; // XXX from Hixie's email
                     return;
                 }
             }
             if ("select" == name) {
-                // TODO: Fragment case. Add error reporting.
+                int ancestorIndex = i;
+                while (ancestorIndex > 0) {
+                    StackNode<T> ancestor = stack[ancestorIndex--];
+                    if ("http://www.w3.org/1999/xhtml" == ancestor.ns) {
+                        if ("template" == ancestor.name) {
+                            break;
+                        }
+                        if ("table" == ancestor.name) {
+                            mode = IN_SELECT_IN_TABLE;
+                            return;
+                        }
+                    }
+                }
                 mode = IN_SELECT;
                 return;
             } else if ("td" == name || "th" == name) {
                 mode = IN_CELL;
                 return;
             } else if ("tr" == name) {
                 mode = IN_ROW;
                 return;
--- a/parser/html/nsHtml5TreeBuilder.cpp
+++ b/parser/html/nsHtml5TreeBuilder.cpp
@@ -3257,16 +3257,29 @@ nsHtml5TreeBuilder::resetTheInsertionMod
         name = contextName;
         ns = contextNamespace;
       } else {
         mode = framesetOk ? NS_HTML5TREE_BUILDER_FRAMESET_OK : NS_HTML5TREE_BUILDER_IN_BODY;
         return;
       }
     }
     if (nsHtml5Atoms::select == name) {
+      int32_t ancestorIndex = i;
+      while (ancestorIndex > 0) {
+        nsHtml5StackNode* ancestor = stack[ancestorIndex--];
+        if (kNameSpaceID_XHTML == ancestor->ns) {
+          if (nsHtml5Atoms::template_ == ancestor->name) {
+            break;
+          }
+          if (nsHtml5Atoms::table == ancestor->name) {
+            mode = NS_HTML5TREE_BUILDER_IN_SELECT_IN_TABLE;
+            return;
+          }
+        }
+      }
       mode = NS_HTML5TREE_BUILDER_IN_SELECT;
       return;
     } else if (nsHtml5Atoms::td == name || nsHtml5Atoms::th == name) {
       mode = NS_HTML5TREE_BUILDER_IN_CELL;
       return;
     } else if (nsHtml5Atoms::tr == name) {
       mode = NS_HTML5TREE_BUILDER_IN_ROW;
       return;