Bug 1466991 - Part 1: Factor out ShouldUseXBLScope. r=smaug, a=IanN CLOSED TREE DONTBUILD SEAMONKEY_2_49_ESR_RELBRANCH
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 14 Jun 2018 19:17:41 -0400
changeset 357512 8265d50c2c1b91e5db2121867a46589534d65f16
parent 357511 efc9e31a5724c4f0309a19fdee4ae673424717a9
child 357513 e4802812e965cdb2418a6783d5b48bf4274661c9
push id7834
push userfrgrahl@gmx.net
push dateSun, 13 Jan 2019 12:17:02 +0000
treeherdermozilla-esr52@6e4ad8a8f2e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, IanN
Bug 1466991 - Part 1: Factor out ShouldUseXBLScope. r=smaug, a=IanN CLOSED TREE DONTBUILD mozilla-esr52 SEAMONKEY_2_49_ESR_RELBRANCH We're going to add another consumer in the next changeset.
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -3443,19 +3443,35 @@ nsINode::GetOwnerDocument() const
 inline nsINode*
 nsINode::OwnerDocAsNode() const
   return OwnerDoc();
+// ShouldUseXBLScope is defined here as a template so that we can get the faster
+// version of IsInAnonymousSubtree if we're statically known to be an
+// nsIContent.  we could try defining ShouldUseXBLScope separately on nsINode
+// and nsIContent, but then we couldn't put its nsINode implementation here
+// (because this header does not include nsIContent) and we can't put it in
+// nsIContent.h, because the definition of nsIContent::IsInAnonymousSubtree is
+// in nsIContentInlines.h.  And then we get include hell from people trying to
+// call nsINode::GetParentObject but not including nsIContentInlines.h and with
+// no really good way to include it.
+template<typename T>
+inline bool ShouldUseXBLScope(const T* aNode)
+  return aNode->IsInAnonymousSubtree() &&
+         !aNode->IsAnonymousContentInSVGUseSubtree();
 inline mozilla::dom::ParentObject
 nsINode::GetParentObject() const
   mozilla::dom::ParentObject p(OwnerDoc());
     // Note that mUseXBLScope is a no-op for chrome, and other places where we
     // don't use XBL scopes.
-  p.mUseXBLScope = IsInAnonymousSubtree() && !IsAnonymousContentInSVGUseSubtree();
+  p.mUseXBLScope = ShouldUseXBLScope(this);
   return p;
 #endif /* nsIDocument_h___ */