From 5f30ecc9b1f55c5851d9f3f4e317f47e2e1713bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 25 Oct 2019 12:19:21 +0000 Subject: [PATCH] style: Remove some XBL code in the style system. Differential Revision: https://phabricator.services.mozilla.com/D50554 --- components/selectors/context.rs | 9 -- components/style/Cargo.toml | 1 - components/style/dom.rs | 8 -- components/style/gecko/wrapper.rs | 93 +------------------ .../invalidation/element/document_state.rs | 3 - .../style/invalidation/element/invalidator.rs | 14 +-- 6 files changed, 3 insertions(+), 125 deletions(-) diff --git a/components/selectors/context.rs b/components/selectors/context.rs index d159891ff02..44d586c8d84 100644 --- a/components/selectors/context.rs +++ b/components/selectors/context.rs @@ -189,15 +189,6 @@ where } } - /// Override the quirks mode we're matching against. - /// - /// FIXME(emilio): This is a hack for XBL quirks-mode mismatches. - #[inline] - pub fn set_quirks_mode(&mut self, quirks_mode: QuirksMode) { - self.quirks_mode = quirks_mode; - self.classes_and_ids_case_sensitivity = quirks_mode.classes_and_ids_case_sensitivity(); - } - /// Whether we're matching a nested selector. #[inline] pub fn is_nested(&self) -> bool { diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 1a727387b7e..f15c64e2f56 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -25,7 +25,6 @@ servo-layout-2020 = [] gecko_debug = [] gecko_refcount_logging = [] gecko_profiler = [] -moz_xbl = [] [dependencies] app_units = "0.7" diff --git a/components/style/dom.rs b/components/style/dom.rs index 7d56cc543e7..2ea64bbb3dc 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -776,14 +776,6 @@ pub trait TElement: return data.hint.has_animation_hint(); } - /// Returns the anonymous content for the current element's XBL binding, - /// given if any. - /// - /// This is used in Gecko for XBL. - fn xbl_binding_anonymous_content(&self) -> Option { - None - } - /// The shadow root this element is a host of. fn shadow_root(&self) -> Option<::ConcreteShadowRoot>; diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index fd0ac9db8a6..c2c4a0c0feb 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -44,8 +44,6 @@ use crate::gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentLWThe use crate::gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags}; use crate::gecko_bindings::structs; use crate::gecko_bindings::structs::nsChangeHint; -#[cfg(feature = "moz_xbl")] -use crate::gecko_bindings::structs::nsXBLBinding as RawGeckoXBLBinding; use crate::gecko_bindings::structs::Document_DocumentTheme as DocumentTheme; use crate::gecko_bindings::structs::EffectCompositor_CascadeLevel as CascadeLevel; use crate::gecko_bindings::structs::ELEMENT_HANDLED_SNAPSHOT; @@ -86,8 +84,6 @@ use std::fmt; use std::hash::{Hash, Hasher}; use std::mem; use std::ptr; -#[cfg(not(feature = "moz_xbl"))] -use values::Impossible; #[inline] fn elements_with_id<'a, 'le>( @@ -317,7 +313,7 @@ impl<'ln> GeckoNode<'ln> { } if let Some(parent) = parent_el { - if parent.shadow_root().is_some() || parent.xbl_binding().is_some() { + if parent.shadow_root().is_some() { return false; } } @@ -530,52 +526,6 @@ impl<'a> Iterator for GeckoChildrenIterator<'a> { } } -/// A Simple wrapper over a non-null Gecko `nsXBLBinding` pointer. -#[cfg(feature = "moz_xbl")] -#[derive(Clone, Copy)] -pub struct GeckoXBLBinding<'lb>(pub &'lb RawGeckoXBLBinding); - -#[cfg(feature = "moz_xbl")] -impl<'lb> GeckoXBLBinding<'lb> { - #[inline] - fn base_binding(&self) -> Option { - unsafe { self.0.mNextBinding.mRawPtr.as_ref().map(GeckoXBLBinding) } - } - - #[inline] - fn anon_content(&self) -> *const nsIContent { - self.0.mContent.raw::() - } - - // This duplicates the logic in Gecko's - // nsBindingManager::GetBindingWithContent. - fn binding_with_content(&self) -> Option { - let mut binding = *self; - loop { - if !binding.anon_content().is_null() { - return Some(binding); - } - binding = binding.base_binding()?; - } - } -} - -/// A stub wraper for GeckoXBLBinding. -#[cfg(not(feature = "moz_xbl"))] -pub struct GeckoXBLBinding<'lb>(&'lb Impossible); - -#[cfg(not(feature = "moz_xbl"))] -impl<'lb> GeckoXBLBinding<'lb> { - #[inline] - fn anon_content(&self) -> *const nsIContent { - match *self.0 {} - } - - fn binding_with_content(&self) -> Option { - None - } -} - /// A simple wrapper over a non-null Gecko `Element` pointer. #[derive(Clone, Copy)] pub struct GeckoElement<'le>(pub &'le RawGeckoElement); @@ -701,39 +651,6 @@ impl<'le> GeckoElement<'le> { }) } - #[cfg(feature = "moz_xbl")] - #[inline] - fn may_be_in_binding_manager(&self) -> bool { - self.flags() & (structs::NODE_MAY_BE_IN_BINDING_MNGR as u32) != 0 - } - - #[cfg(feature = "moz_xbl")] - #[inline] - fn xbl_binding(&self) -> Option> { - if !self.may_be_in_binding_manager() { - return None; - } - - let slots = self.extended_slots()?; - unsafe { slots.mXBLBinding.mRawPtr.as_ref().map(GeckoXBLBinding) } - } - - #[cfg(not(feature = "moz_xbl"))] - #[inline] - fn xbl_binding(&self) -> Option> { - None - } - - #[inline] - fn xbl_binding_with_content(&self) -> Option> { - self.xbl_binding().and_then(|b| b.binding_with_content()) - } - - #[inline] - fn has_xbl_binding_with_content(&self) -> bool { - !self.xbl_binding_with_content().is_none() - } - #[inline] fn namespace_id(&self) -> i32 { self.as_node().node_info().mInner.mNamespaceID @@ -1107,9 +1024,8 @@ impl<'le> TElement for GeckoElement<'le> { // This condition is similar to the check that // StyleChildrenIterator::IsNeeded does, except that it might return // true if we used to (but no longer) have anonymous content from - // ::before/::after, XBL bindings, or nsIAnonymousContentCreators. + // ::before/::after, or nsIAnonymousContentCreators. if self.is_in_anonymous_subtree() || - self.has_xbl_binding_with_content() || self.is_html_slot_element() || self.shadow_root().is_some() || self.may_have_anonymous_children() @@ -1595,11 +1511,6 @@ impl<'le> TElement for GeckoElement<'le> { self.may_have_animations() && unsafe { Gecko_ElementHasCSSTransitions(self.0) } } - fn xbl_binding_anonymous_content(&self) -> Option> { - self.xbl_binding_with_content() - .map(|b| unsafe { GeckoNode::from_content(&*b.anon_content()) }) - } - fn might_need_transitions_update( &self, old_style: Option<&ComputedValues>, diff --git a/components/style/invalidation/element/document_state.rs b/components/style/invalidation/element/document_state.rs index 77b205f1b26..4e29e91eb0e 100644 --- a/components/style/invalidation/element/document_state.rs +++ b/components/style/invalidation/element/document_state.rs @@ -31,9 +31,6 @@ impl Default for InvalidationMatchingData { /// An invalidation processor for style changes due to state and attribute /// changes. pub struct DocumentStateInvalidationProcessor<'a, E: TElement, I> { - // TODO(emilio): We might want to just run everything for every possible - // binding along with the document data, or just apply the XBL stuff to the - // bound subtrees. rules: I, matching_context: MatchingContext<'a, E::Impl>, document_states_changed: DocumentState, diff --git a/components/style/invalidation/element/invalidator.rs b/components/style/invalidation/element/invalidator.rs index 2889c3e7b9d..3487d7b9353 100644 --- a/components/style/invalidation/element/invalidator.rs +++ b/components/style/invalidation/element/invalidator.rs @@ -28,7 +28,7 @@ where /// Whether the invalidation processor only cares about light-tree /// descendants of a given element, that is, doesn't invalidate - /// pseudo-elements, NAC, or XBL anon content. + /// pseudo-elements, NAC, shadow dom... fn light_tree_only(&self) -> bool { false } @@ -455,11 +455,6 @@ where let mut sibling_invalidations = InvalidationVector::new(); for child in parent.dom_children() { - // TODO(emilio): We handle fine, because they appear - // in selector-matching (note bug 1374247, though). - // - // This probably needs a shadow root check on `child` here, and - // recursing if that's the case. let child = match child.as_element() { Some(e) => e, None => continue, @@ -574,13 +569,6 @@ where any_descendant |= self.invalidate_dom_descendants_of(root.as_node(), invalidations); } - // This is needed for XBL (technically) unconditionally, because XBL - // bindings do not block combinators in any way. However this is kinda - // broken anyway, since we should be looking at XBL rules too. - if let Some(anon_content) = self.element.xbl_binding_anonymous_content() { - any_descendant |= self.invalidate_dom_descendants_of(anon_content, invalidations); - } - if let Some(marker) = self.element.marker_pseudo_element() { any_descendant |= self.invalidate_pseudo_element_or_nac(marker, invalidations); }