Bug 1424680: Fix appending in some situations to display: contents stuff. r=bz draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 11 Dec 2017 06:44:44 +0100
changeset 710632 ce280ed6fc0e37374b3ed853e0be078139352a1b
parent 710631 9ad050ee7a31326b83e9c2c97445556532e05c33
child 743617 789c969636078e41613e6faecef7c6fa5ae8bce3
push id92863
push userbmo:emilio@crisal.io
push dateMon, 11 Dec 2017 07:39:46 +0000
reviewersbz
bugs1424680
milestone59.0a1
Bug 1424680: Fix appending in some situations to display: contents stuff. r=bz I've verified that this asserts without the patch. MozReview-Commit-ID: 8j6x4xswrCe
layout/base/nsCSSFrameConstructor.cpp
layout/reftests/bugs/1424680-ref.html
layout/reftests/bugs/1424680.html
layout/reftests/bugs/reftest.list
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -7558,19 +7558,20 @@ nsCSSFrameConstructor::ContentAppended(n
   // contents.
   nsIFrame* nextSibling = nullptr;
   if (GetDisplayContentsStyleFor(insertion.mContainer) ||
       nsLayoutUtils::GetAfterFrame(insertion.mContainer)) {
     FlattenedChildIterator iter(insertion.mContainer);
     iter.Seek(insertion.mContainer->GetLastChild());
     StyleDisplay unused = UNSET_DISPLAY;
     nextSibling = FindNextSibling(iter, unused);
-    if (nextSibling) {
-      parentFrame = nextSibling->GetParent()->GetContentInsertionFrame();
-    }
+  }
+
+  if (nextSibling) {
+    parentFrame = nextSibling->GetParent()->GetContentInsertionFrame();
   } else {
     parentFrame =
       ::ContinuationToAppendTo(parentFrame);
   }
 
   nsContainerFrame* containingBlock = GetFloatContainingBlock(parentFrame);
 
   // See if the containing block has :first-letter style applied.
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1424680-ref.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+function boom()
+{
+  var floater = document.createElement("span");
+  floater.style.cssFloat = "right";
+  floater.appendChild(document.createTextNode("float"));
+
+  document.getElementById("s").appendChild(floater);
+}
+</script>
+</head>
+
+<body onload="boom();">
+
+<span><span id="s"><div></div></span></span>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1424680.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+function boom()
+{
+  var floater = document.createElement("span");
+  floater.style.cssFloat = "right";
+  floater.appendChild(document.createTextNode("float"));
+
+  document.getElementById("s").appendChild(floater);
+}
+</script>
+</head>
+
+<body onload="boom();">
+  <span><span><div style="display: contents" id="s"><div></div></div></span></span>
+</body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -2046,8 +2046,9 @@ needs-focus != 1377447-1.html 1377447-2.
 == 1405878-1.xml 1405878-1-ref.xml
 == 1404057.html 1404057-ref.html
 != 1404057.html 1404057-noref.html
 == 1406183-1.html 1406183-1-ref.html
 == 1410028.html 1410028-ref.html
 test-pref(font.size.systemFontScale,200) == 1412743.html 1412743-ref.html
 == 1419820-1.html 1419820-1-ref.html
 == 1420946-1.html 1420946-1-ref.html
+== 1424680.html 1424680-ref.html