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:
Zach Hoffman 2023-03-14 21:23:05 +00:00 committed by Martin Robinson
parent 11a04d9d93
commit 744b21e72a
3 changed files with 27 additions and 30 deletions

View file

@ -92,29 +92,10 @@ pub trait Element: Sized + Clone + Debug {
context: &mut MatchingContext<Self::Impl>,
) -> bool;
/// Sets selector flags, which indicate what kinds of selectors may have
/// matched on this element and therefore what kind of work may need to
/// be performed when DOM state changes.
///
/// 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);
}
}
}
/// Sets selector flags on the elemnt itself or the parent, depending on the
/// flags, which indicate what kind of work may need to be performed when
/// DOM state changes.
fn apply_selector_flags(&self, flags: ElementSelectorFlags);
/// Whether this element is a `link`.
fn is_link(&self) -> bool;