Bug 1466991 - Part 1: Factor out ShouldUseXBLScope.

This commit is contained in:
wolfbeast
2018-09-11 15:33:44 +02:00
parent 9830cd079d
commit a6d4e65dbf
+17 -1
View File
@@ -3439,13 +3439,29 @@ 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;
}