Bug 1261351: Look past ShadowRoots when looking for the parent for the UndisplayedMap. r=dbaron
authorKyle Huey <khuey@kylehuey.com>
Tue, 07 Jun 2016 14:09:22 -0700
changeset 300988 f31f71abd55183c110b01b2a2b53e619e53be8b6
parent 300987 482236eb497ac358272e22690145cb6a41d4d91e
child 300989 daecf88f04277b9f6fd6c948c1e01418140a6686
push id19599
push usercbook@mozilla.com
push dateWed, 08 Jun 2016 10:16:21 +0000
treeherderfx-team@81f4cc3f6f4c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1261351
milestone50.0a1
Bug 1261351: Look past ShadowRoots when looking for the parent for the UndisplayedMap. r=dbaron
layout/base/crashtests/1261351-iframe.html
layout/base/crashtests/1261351.html
layout/base/crashtests/crashtests.list
layout/base/nsFrameManager.cpp
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/1261351-iframe.html
@@ -0,0 +1,26 @@
+<body>
+<script type="application/javascript">
+  'use strict';
+  // -sp-context: content
+  (function () {
+    let proto = Object.create(HTMLDivElement.prototype);
+    proto.template = `<style></style>`;
+    proto.createdCallback = function() {
+    let shadow = this.createShadowRoot();
+    if (this.template) {
+      let te = document.createElement('template');
+      te.innerHTML = this.template;
+      shadow.appendChild(document.importNode(te.content, true));
+    }
+  };
+
+  let UiComponentTest = document.registerElement('ui-component-test', {
+    prototype: proto,
+  });
+
+  let uic = new UiComponentTest();
+  document.body.appendChild(uic);
+
+  })();
+</script>
+</body>
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/1261351.html
@@ -0,0 +1,7 @@
+<iframe id="iframe" src="1261351-iframe.html"></iframe>
+<script type="application/javascript">
+  let iframe = document.getElementById("iframe");
+  iframe.addEventListener("load", function() {
+    document.getElementsByTagName("iframe")[0].marginWidth = "5";
+  });
+</script>
--- a/layout/base/crashtests/crashtests.list
+++ b/layout/base/crashtests/crashtests.list
@@ -465,9 +465,10 @@ load 1107508-1.html
 load 1116104.html
 load 1127198-1.html
 load 1140198.html
 pref(layout.css.grid.enabled,true) load 1156588.html
 load 1162813.xul
 load 1163583.html
 load 1234622-1.html
 load 1235467-1.html
+pref(dom.webcomponents.enabled,true) load 1261351.html
 load 1270797-1.html
--- a/layout/base/nsFrameManager.cpp
+++ b/layout/base/nsFrameManager.cpp
@@ -250,17 +250,18 @@ nsFrameManager::SetStyleContextInMap(Und
 #if defined(DEBUG_UNDISPLAYED_MAP) || defined(DEBUG_DISPLAY_BOX_CONTENTS_MAP)
   static int i = 0;
   printf("SetStyleContextInMap(%d): p=%p \n", i++, (void *)aContent);
 #endif
 
   NS_ASSERTION(!GetStyleContextInMap(aMap, aContent),
                "Already have an entry for aContent");
 
-  nsIContent* parent = aContent->GetParent();
+  nsIContent* parent = aContent->GetParentElementCrossingShadowRoot();
+  MOZ_ASSERT(parent || !aContent->GetParent(), "no non-elements");
 #ifdef DEBUG
   nsIPresShell* shell = aStyleContext->PresContext()->PresShell();
   NS_ASSERTION(parent || (shell && shell->GetDocument() &&
                           shell->GetDocument()->GetRootElement() == aContent),
                "undisplayed content must have a parent, unless it's the root "
                "element");
 #endif
   aMap->AddNodeFor(parent, aContent, aStyleContext);