aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/gecko/wrapper.rs
diff options
context:
space:
mode:
authorZach Hoffman <zach@zrhoffman.net>2023-03-14 21:23:05 +0000
committerMartin Robinson <mrobinson@igalia.com>2023-11-21 15:36:35 +0100
commit744b21e72a00f9fdb27e6bb52a4a010155aa7067 (patch)
treee5bf00f1d730c4c30f3885854a6251bac8d9dad0 /components/style/gecko/wrapper.rs
parent11a04d9d93635a0145c65e1eb81a3b61c9255bb3 (diff)
downloadservo-744b21e72a00f9fdb27e6bb52a4a010155aa7067.tar.gz
servo-744b21e72a00f9fdb27e6bb52a4a010155aa7067.zip
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
Diffstat (limited to 'components/style/gecko/wrapper.rs')
-rw-r--r--components/style/gecko/wrapper.rs28
1 files changed, 22 insertions, 6 deletions
diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs
index 0e914bc1ff5..8d4fb224639 100644
--- a/components/style/gecko/wrapper.rs
+++ b/components/style/gecko/wrapper.rs
@@ -269,6 +269,11 @@ impl<'ln> GeckoNode<'ln> {
}
#[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;
let flags: &Cell<u32> = &(self.0)._base._base_1.mFlags;
@@ -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(