Bug 1140579 - Additional tests and code comment update.
authorMats Palmgren <mats@mozilla.com>
Mon, 09 Mar 2015 17:29:00 +0000
changeset 232591 364c12f1eddebd47f70abc5492456a37aca17085
parent 232590 dbfa7096402f72ff77305c09143291d551d4a73f
child 232592 fb6a64fc61842e2490eb414201fa2b2565b0a69a
push id28386
push userkwierso@gmail.com
push dateTue, 10 Mar 2015 01:27:56 +0000
treeherdermozilla-central@9d54f24596e9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1140579
milestone39.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 1140579 - Additional tests and code comment update.
layout/base/crashtests/497519-3.xhtml
layout/base/crashtests/497519-4.xhtml
layout/base/crashtests/crashtests.list
layout/base/nsCSSFrameConstructor.cpp
layout/reftests/forms/legend/reftest.list
layout/reftests/forms/legend/shadow-dom-ref.html
layout/reftests/forms/legend/shadow-dom.html
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/497519-3.xhtml
@@ -0,0 +1,26 @@
+<html xmlns="http://www.w3.org/1999/xhtml" style="-moz-binding: url(#foo)">
+<head>
+
+<xbl:bindings xmlns:xbl="http://www.mozilla.org/xbl">
+<xbl:binding id="foo"><xbl:content><fieldset><xbl:children/></fieldset></xbl:content></xbl:binding>
+</xbl:bindings>
+
+<script type="text/javascript">
+
+function boom()
+{
+  var dE = document.documentElement;
+  var leg = document.createElementNS("http://www.w3.org/1999/xhtml", "legend");
+  leg.appendChild(document.createTextNode("legend"));
+  dE.appendChild(leg);
+  document.documentElement.offsetHeight;
+  dE.removeChild(leg);
+}
+
+</script>
+
+</head>
+
+<body onload="boom();"></body>
+
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/497519-4.xhtml
@@ -0,0 +1,26 @@
+<html xmlns="http://www.w3.org/1999/xhtml" style="-moz-binding: url(#foo)">
+<head>
+
+<xbl:bindings xmlns:xbl="http://www.mozilla.org/xbl">
+<xbl:binding id="foo"><xbl:content><fieldset><xbl:children/></fieldset></xbl:content></xbl:binding>
+</xbl:bindings>
+
+<script type="text/javascript">
+
+function boom()
+{
+  var dE = document.documentElement;
+  var leg = document.createElementNS("http://www.w3.org/1999/xhtml", "legend");
+  leg.style.position = "absolute";
+  dE.appendChild(leg);
+  document.documentElement.offsetHeight;
+  dE.removeChild(leg);
+}
+
+</script>
+
+</head>
+
+<body onload="boom();"></body>
+
+</html>
--- a/layout/base/crashtests/crashtests.list
+++ b/layout/base/crashtests/crashtests.list
@@ -313,16 +313,18 @@ load 491547-1.xul
 load 491547-2.xul
 load 492014.xhtml
 load 492112-1.xhtml
 load 492163-1.xhtml
 load 495350-1.html
 load 496011-1.xhtml
 load 497519-1.xhtml
 load 497519-2.xhtml
+load 497519-3.xhtml
+load 497519-4.xhtml
 load 499741-1.xhtml
 load 499841-1.xhtml
 load 499858-1.xhtml
 load 500467-1.html
 load 501878-1.html
 load 503936-1.html
 load 507119.html
 load 514104-1.xul
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -3468,24 +3468,21 @@ nsCSSFrameConstructor::FindHTMLData(Elem
                  nsCSSAnonBoxes::fieldsetContent ||
                aParentFrame->GetParent()->GetType() == nsGkAtoms::fieldSetFrame,
                "Unexpected parent for fieldset content anon box");
   if (aTag == nsGkAtoms::legend &&
       (!aParentFrame ||
        !IsFrameForFieldSet(aParentFrame, aParentFrame->GetType()) ||
        aStyleContext->StyleDisplay()->IsFloatingStyle() ||
        aStyleContext->StyleDisplay()->IsAbsolutelyPositionedStyle())) {
-    // <legend> is only special inside fieldset, check both the frame tree
-    // parent and content tree parent due to XBL issues. For floated or
-    // absolutely positioned legends we want to construct by display type and
+    // <legend> is only special inside fieldset, we only check the frame tree
+    // parent because the content tree parent may not be a <fieldset> due to
+    // display:contents, Shadow DOM, or XBL. For floated or absolutely
+    // positioned legends we want to construct by display type and
     // not do special legend stuff.
-    // XXXbz it would be nice if we could just decide this based on the parent
-    // tag, and hence just use a SIMPLE_TAG_CHAIN for legend below, but the
-    // fact that with XBL we could end up with this legend element in some
-    // totally weird insertion point makes that chancy, I think.
     return nullptr;
   }
 
   static const FrameConstructionDataByTag sHTMLData[] = {
     SIMPLE_TAG_CHAIN(img, nsCSSFrameConstructor::FindImgData),
     SIMPLE_TAG_CHAIN(mozgeneratedcontentimage,
                      nsCSSFrameConstructor::FindImgData),
     { &nsGkAtoms::br,
--- a/layout/reftests/forms/legend/reftest.list
+++ b/layout/reftests/forms/legend/reftest.list
@@ -1,1 +1,2 @@
 skip-if(B2G) == legend.html legend-ref.html
+pref(dom.webcomponents.enabled,true) == shadow-dom.html shadow-dom-ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/forms/legend/shadow-dom-ref.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html lang="en-US">
+  <head>
+  <title>Test LEGEND placed into FIELDSET shadow DOM</title>
+  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1140579">
+<style>
+html,body {
+    color:black; background-color:white; font-size:16px; padding:0; margin:0;
+}
+.inline { display:inline; }
+z,.b { color:blue; }
+</style>
+  </head>
+  <body>
+    <fieldset id="host1"><legend>1</legend>a c</fieldset>
+    <fieldset id="host2"><legend>2</legend>a c</fieldset>
+    <fieldset id="host3"><legend>3</legend>a c</fieldset>
+    <fieldset id="host4"><legend>4</legend>a c</fieldset>
+    <fieldset id="host5"><legend>5</legend>a c</fieldset>
+    <fieldset id="host6"><legend class="b">6</legend>a c</fieldset>
+    <fieldset id="host7"><legend>7</legend>a <legend class="inline">L</legend> B</fieldset>
+    <fieldset id="host8"><legend>a 8</legend>A <legend class="inline">L c</legend> B</fieldset>
+    <fieldset id="host9"><legend>a 9</legend>A <legend class="inline p0">a L2 c</legend><z>a<legend>L3</legend>c</z> B</fieldset>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/forms/legend/shadow-dom.html
@@ -0,0 +1,111 @@
+<!DOCTYPE html>
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html class="reftest-wait" lang="en-US">
+  <head>
+  <title>Test LEGEND placed into FIELDSET shadow DOM</title>
+  <link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1140579">
+  <link rel="match" href="shadow-dom-ref.html">
+<style>
+html,body {
+    color:black; background-color:white; font-size:16px; padding:0; margin:0;
+}
+.before::before {content: "a ";}
+.after::after {content: " c";}
+div.before::before {content: "X ";}
+div.after::after {content: " Y";}
+.b,.c { display:contents; }
+</style>
+  </head>
+  <body>
+    <fieldset id="host1" class="before"></fieldset>
+    <fieldset id="host2"></fieldset>
+    <fieldset id="host3" class="after"></fieldset>
+    <fieldset id="host4" class="before after"></fieldset>
+    <fieldset id="host5" class="after"></fieldset>
+    <fieldset id="host6" class="before"></fieldset>
+    <fieldset id="host7"></fieldset>
+    <fieldset id="host8"></fieldset>
+    <fieldset id="host9"></fieldset>
+
+   <script>
+      function shadow(id) {
+        return document.getElementById(id).createShadowRoot();
+      }
+      function legend(s) {
+        var e = document.createElement("legend");
+        var t = document.createTextNode(s);
+        e.appendChild(t);
+        return e;
+      }
+      function contents(n) {
+        var e = document.createElement("z");
+        e.style.display = "contents";
+        e.style.color = "blue"; 
+        if (n) e.appendChild(n);
+        return e;
+      }
+
+      document.body.offsetHeight;
+
+      shadow("host1").innerHTML = '<content></content> c';
+      shadow("host2").innerHTML = 'a <content></content> c';
+      shadow("host3").innerHTML = 'a <content></content>';
+      shadow("host4").innerHTML = '<content></content>';
+      shadow("host5").innerHTML = 'a <content></content>';
+      shadow("host6").innerHTML = '<z style="color:blue; display:contents"><content></content></z> c';
+      shadow("host7").innerHTML = 'a <content select=".c"></content> <content select=".b"></content> B';
+      shadow("host8").innerHTML = 'A <content select=".c"></content> <content select=".b"></content> B';
+      shadow("host9").innerHTML = 'A <content select=".c"></content> <content select=".b"></content> B <content select=".b"></content>';
+
+      function tweak() {
+        document.body.offsetHeight;
+
+        host1.appendChild(legend("1"));
+        host2.appendChild(legend("2"));
+        host3.appendChild(legend("3"));
+        host4.appendChild(legend("4"));
+
+        var e = legend("5");
+        e.style.display = "contents";
+        host5.appendChild(e);
+
+        host6.appendChild(legend("6"));
+
+        var e = legend("L");
+        e.className = "b";
+        host7.appendChild(e);
+        var e = legend("7");
+        e.className = "c";
+        host7.appendChild(e);
+
+        var e = legend("L");
+        e.className = "b after";
+        host8.appendChild(e);
+        var e = legend("8");
+        e.className = "c  before";
+        host8.appendChild(e);
+
+        var e = legend("L2");
+        e.className = "b before after";
+        host9.appendChild(e);
+        var e = contents(legend(" L3"));
+        e.className = "b before after";
+        host9.appendChild(e);
+        var e = legend("9");
+        e.className = "c  before";
+        host9.appendChild(e);
+
+        document.body.offsetHeight;
+        setTimeout(function() {
+            document.body.offsetHeight;
+            document.documentElement.removeAttribute("class");
+          },0);
+      }
+
+      window.addEventListener("MozReftestInvalidate", tweak, false);
+    </script>
+  </body>
+</html>