Bug 1511138 - Never return styles for disconnected elements. r=smaug
☠☠ backed out by 5fcc6bd202c4 ☠ ☠
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 30 Nov 2018 18:01:48 +0100
changeset 508892 4df286b234b3daf6c315ae2f3f58f857664f88c7
parent 508891 5e6e283f0e0080fc9d2be472b51d738e8d790ed4
child 508893 4ef293b908879b56b27c1f473127db680c099a60
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1511138
milestone65.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 1511138 - Never return styles for disconnected elements. r=smaug https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle says: > If elt is connected, part of the flat tree, and its shadow-including root... WebKit and Blink already do this, and we do it already except for cross-document situations, where we can end up with a PresShell even if GetPresShellForContent returns null. The style system should be able to rely on ShadowRoots having a non-null shadow host. Differential Revision: https://phabricator.services.mozilla.com/D13472
layout/style/nsComputedDOMStyle.cpp
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -503,21 +503,22 @@ already_AddRefed<ComputedStyle> nsComput
     }
   }
 
   CSSPseudoElementType pseudoType = GetPseudoType(aPseudo);
   if (aPseudo && pseudoType >= CSSPseudoElementType::Count) {
     return nullptr;
   }
 
-  if (aElement->IsInNativeAnonymousSubtree() && !aElement->IsInComposedDoc()) {
-    // Normal web content can't access NAC, but Accessibility, DevTools and
-    // Editor use this same API and this may get called for anonymous content.
-    // Computing the style of a pseudo-element that doesn't have a parent
-    // doesn't really make sense.
+  if (!aElement->IsInComposedDoc()) {
+    // Don't return styles for disconnected elements, that makes no sense. This
+    // can only happen with a non-null presShell for cross-document calls.
+    //
+    // FIXME(emilio, bug 1483798): This should also not return styles for
+    // elements outside of the flat tree, not just outside of the document.
     return nullptr;
   }
 
   // XXX the !aElement->IsHTMLElement(nsGkAtoms::area)
   // check is needed due to bug 135040 (to avoid using
   // mPrimaryFrame). Remove it once that's fixed.
   if (inDocWithShell && aStyleType == eAll &&
       !aElement->IsHTMLElement(nsGkAtoms::area)) {