mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Apply selector flags to the shadow root
Because restyle events cannot be posted for non-element nodes like the shadow root, a child's siblings are restyled directly if its parent has NODE_HAS_SLOW_SELECTOR or NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS but that parent is the shadow root. Drive-by, but braces were also added to some single-line "if" statements in RestyleManager. Differential Revision: https://phabricator.services.mozilla.com/D172352
This commit is contained in:
parent
11a04d9d93
commit
744b21e72a
3 changed files with 27 additions and 30 deletions
|
@ -92,29 +92,10 @@ pub trait Element: Sized + Clone + Debug {
|
||||||
context: &mut MatchingContext<Self::Impl>,
|
context: &mut MatchingContext<Self::Impl>,
|
||||||
) -> bool;
|
) -> bool;
|
||||||
|
|
||||||
/// Sets selector flags, which indicate what kinds of selectors may have
|
/// Sets selector flags on the elemnt itself or the parent, depending on the
|
||||||
/// matched on this element and therefore what kind of work may need to
|
/// flags, which indicate what kind of work may need to be performed when
|
||||||
/// be performed when DOM state changes.
|
/// DOM state changes.
|
||||||
///
|
fn apply_selector_flags(&self, flags: ElementSelectorFlags);
|
||||||
/// You probably don't want to use this directly and want to use
|
|
||||||
/// apply_selector_flags, since that sets flags on the parent as needed.
|
|
||||||
fn set_selector_flags(&self, flags: ElementSelectorFlags);
|
|
||||||
|
|
||||||
fn apply_selector_flags(&self, flags: ElementSelectorFlags) {
|
|
||||||
// Handle flags that apply to the element.
|
|
||||||
let self_flags = flags.for_self();
|
|
||||||
if !self_flags.is_empty() {
|
|
||||||
self.set_selector_flags(self_flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle flags that apply to the parent.
|
|
||||||
let parent_flags = flags.for_parent();
|
|
||||||
if !parent_flags.is_empty() {
|
|
||||||
if let Some(p) = self.parent_element() {
|
|
||||||
p.set_selector_flags(parent_flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Whether this element is a `link`.
|
/// Whether this element is a `link`.
|
||||||
fn is_link(&self) -> bool;
|
fn is_link(&self) -> bool;
|
||||||
|
|
|
@ -268,6 +268,11 @@ impl<'ln> GeckoNode<'ln> {
|
||||||
GeckoNode(&content._base)
|
GeckoNode(&content._base)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn set_flags(&self, flags: u32) {
|
||||||
|
self.flags_atomic().fetch_or(flags, Ordering::Relaxed);
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn flags_atomic(&self) -> &AtomicU32 {
|
fn flags_atomic(&self) -> &AtomicU32 {
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
@ -672,9 +677,7 @@ impl<'le> GeckoElement<'le> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set_flags(&self, flags: u32) {
|
fn set_flags(&self, flags: u32) {
|
||||||
self.as_node()
|
self.as_node().set_flags(flags);
|
||||||
.flags_atomic()
|
|
||||||
.fetch_or(flags, Ordering::Relaxed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1866,9 +1869,22 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_selector_flags(&self, flags: ElementSelectorFlags) {
|
fn apply_selector_flags(&self, flags: ElementSelectorFlags) {
|
||||||
debug_assert!(!flags.is_empty());
|
// Handle flags that apply to the element.
|
||||||
self.set_flags(selector_flags_to_node_flags(flags));
|
let self_flags = flags.for_self();
|
||||||
|
if !self_flags.is_empty() {
|
||||||
|
self.set_flags(selector_flags_to_node_flags(flags))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle flags that apply to the parent.
|
||||||
|
let parent_flags = flags.for_parent();
|
||||||
|
if !parent_flags.is_empty() {
|
||||||
|
if let Some(p) = self.as_node().parent_node() {
|
||||||
|
if p.is_element() || p.is_shadow_root() {
|
||||||
|
p.set_flags(selector_flags_to_node_flags(parent_flags));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn attr_matches(
|
fn attr_matches(
|
||||||
|
|
|
@ -238,7 +238,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_selector_flags(&self, _flags: ElementSelectorFlags) {
|
fn apply_selector_flags(&self, _flags: ElementSelectorFlags) {
|
||||||
debug_assert!(false, "Shouldn't need selector flags for invalidation");
|
debug_assert!(false, "Shouldn't need selector flags for invalidation");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue