mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +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
|
@ -268,6 +268,11 @@ impl<'ln> GeckoNode<'ln> {
|
|||
GeckoNode(&content._base)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_flags(&self, flags: u32) {
|
||||
self.flags_atomic().fetch_or(flags, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn flags_atomic(&self) -> &AtomicU32 {
|
||||
use std::cell::Cell;
|
||||
|
@ -672,9 +677,7 @@ impl<'le> GeckoElement<'le> {
|
|||
|
||||
#[inline]
|
||||
fn set_flags(&self, flags: u32) {
|
||||
self.as_node()
|
||||
.flags_atomic()
|
||||
.fetch_or(flags, Ordering::Relaxed);
|
||||
self.as_node().set_flags(flags);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -1866,9 +1869,22 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
None
|
||||
}
|
||||
|
||||
fn set_selector_flags(&self, flags: ElementSelectorFlags) {
|
||||
debug_assert!(!flags.is_empty());
|
||||
self.set_flags(selector_flags_to_node_flags(flags));
|
||||
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_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(
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue