Skip to content

Commit 73f8dff

Browse files
emilioMoggers
authored andcommitted
style: Fix IsInAnonymousSubtree to account for XBL in Shadow DOM.
Bug: 1453206 Reviewed-by: smaug MozReview-Commit-ID: B2aYury8K7i
1 parent 22f03ac commit 73f8dff

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

components/style/gecko/wrapper.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,11 @@ impl<'le> GeckoElement<'le> {
637637
!self.xbl_binding_with_content().is_none()
638638
}
639639

640-
/// This and has_xbl_binding_parent duplicate the logic in Gecko's virtual
641-
/// nsINode::GetBindingParent function, which only has two implementations:
642-
/// one for XUL elements, and one for other elements. We just hard code in
643-
/// our knowledge of those two implementations here.
640+
/// This duplicates the logic in Gecko's virtual nsINode::GetBindingParent
641+
/// function, which only has two implementations: one for XUL elements, and
642+
/// one for other elements.
643+
///
644+
/// We just hard code in our knowledge of those two implementations here.
644645
fn xbl_binding_parent(&self) -> Option<Self> {
645646
if self.is_xul_element() {
646647
// FIXME(heycam): Having trouble with bindgen on nsXULElement,
@@ -667,17 +668,6 @@ impl<'le> GeckoElement<'le> {
667668
.map_or(ptr::null_mut(), |slots| slots._base.mBindingParent)
668669
}
669670

670-
fn has_xbl_binding_parent(&self) -> bool {
671-
if self.is_xul_element() {
672-
// FIXME(heycam): Having trouble with bindgen on nsXULElement,
673-
// where the binding parent is stored in a member variable
674-
// rather than in slots. So just get it through FFI for now.
675-
unsafe { bindings::Gecko_GetBindingParent(self.0).is_some() }
676-
} else {
677-
!self.non_xul_xbl_binding_parent_raw_content().is_null()
678-
}
679-
}
680-
681671
#[inline]
682672
fn namespace_id(&self) -> i32 {
683673
self.as_node().node_info().mInner.mNamespaceID
@@ -815,8 +805,16 @@ impl<'le> GeckoElement<'le> {
815805
/// This logic is duplicated in Gecko's nsIContent::IsInAnonymousSubtree.
816806
#[inline]
817807
fn is_in_anonymous_subtree(&self) -> bool {
818-
self.is_in_native_anonymous_subtree() ||
819-
(!self.as_node().is_in_shadow_tree() && self.has_xbl_binding_parent())
808+
if self.is_in_native_anonymous_subtree() {
809+
return true;
810+
}
811+
812+
let binding_parent = match self.xbl_binding_parent() {
813+
Some(p) => p,
814+
None => return false,
815+
};
816+
817+
binding_parent.shadow_root().is_none()
820818
}
821819

822820
/// Returns true if this node is the shadow root of an use-element shadow tree.

0 commit comments

Comments
 (0)