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 164979 253257d650a6b201e3acc6326d6344ccad969ca4
parent 164978 a6c52aabcdece06451ad7bbe26c0e75681de1681
child 164980 5349c5c0d9f86856d847e1d6a8f8e6d5f68a9114
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [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;