mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Move ANCHORS_RELATIVE_SELECTOR
out of nsINode flags
Move the flag to ComputedValueFlags, like `CONSIDERED_RELATIVE_SELECTOR`. Differential Revision: https://phabricator.services.mozilla.com/D180726
This commit is contained in:
parent
9321265b38
commit
ae5e0d49d8
7 changed files with 59 additions and 43 deletions
|
@ -900,10 +900,6 @@ pub trait TElement:
|
|||
&self,
|
||||
display: &Display,
|
||||
) -> euclid::default::Size2D<Option<app_units::Au>>;
|
||||
|
||||
/// Returns true if this element anchors a relative selector, now or after
|
||||
/// a DOM mutation.
|
||||
fn anchors_relative_selector(&self) -> bool;
|
||||
}
|
||||
|
||||
/// TNode and TElement aren't Send because we want to be careful and explicit
|
||||
|
|
|
@ -894,9 +894,6 @@ fn selector_flags_to_node_flags(flags: ElementSelectorFlags) -> u32 {
|
|||
if flags.contains(ElementSelectorFlags::HAS_EMPTY_SELECTOR) {
|
||||
gecko_flags |= NODE_HAS_EMPTY_SELECTOR;
|
||||
}
|
||||
if flags.contains(ElementSelectorFlags::ANCHORS_RELATIVE_SELECTOR) {
|
||||
gecko_flags |= NODE_ANCHORS_RELATIVE_SELECTOR;
|
||||
}
|
||||
|
||||
gecko_flags
|
||||
}
|
||||
|
@ -1730,11 +1727,6 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn anchors_relative_selector(&self) -> bool {
|
||||
use crate::gecko_bindings::structs::NODE_ANCHORS_RELATIVE_SELECTOR;
|
||||
self.flags() & NODE_ANCHORS_RELATIVE_SELECTOR != 0
|
||||
}
|
||||
}
|
||||
|
||||
impl<'le> PartialEq for GeckoElement<'le> {
|
||||
|
|
|
@ -121,6 +121,10 @@ bitflags! {
|
|||
|
||||
/// Whether the style evaluated any relative selector.
|
||||
const CONSIDERED_RELATIVE_SELECTOR = 1 << 24;
|
||||
|
||||
/// Whether the style evaluated the matched element to be an anchor of
|
||||
/// a relative selector.
|
||||
const ANCHORS_RELATIVE_SELECTOR = 1 << 25;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,7 +157,9 @@ impl ComputedValueFlags {
|
|||
/// Flags that are an input to the cascade.
|
||||
#[inline]
|
||||
fn cascade_input_flags() -> Self {
|
||||
Self::USES_VIEWPORT_UNITS_ON_CONTAINER_QUERIES | Self::CONSIDERED_RELATIVE_SELECTOR
|
||||
Self::USES_VIEWPORT_UNITS_ON_CONTAINER_QUERIES |
|
||||
Self::CONSIDERED_RELATIVE_SELECTOR |
|
||||
Self::ANCHORS_RELATIVE_SELECTOR
|
||||
}
|
||||
|
||||
/// Returns the flags that are always propagated to descendants.
|
||||
|
|
|
@ -632,7 +632,11 @@ impl<E: TElement> StyleSharingCache<E> {
|
|||
// matching `.foo`, even if `:has()` may not even be used. Ideally we'd
|
||||
// have something like `RelativeSelectorConsidered::RightMost`, but the
|
||||
// element flag is required for invalidation, and this reduces more tracking.
|
||||
if element.anchors_relative_selector() {
|
||||
if style
|
||||
.style
|
||||
.0
|
||||
.flags
|
||||
.intersects(ComputedValueFlags::ANCHORS_RELATIVE_SELECTOR) {
|
||||
debug!("Failing to insert to the cache: may anchor relative selector");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ use crate::rule_tree::StrongRuleNode;
|
|||
use crate::selector_parser::{PseudoElement, SelectorImpl};
|
||||
use crate::stylist::RuleInclusion;
|
||||
use log::Level::Trace;
|
||||
use selectors::matching::{MatchingContext, NeedsSelectorFlags};
|
||||
use selectors::matching::{MatchingContext, NeedsSelectorFlags, RelativeSelectorMatchingState};
|
||||
use selectors::matching::{MatchingMode, VisitedHandlingMode};
|
||||
use servo_arc::Arc;
|
||||
|
||||
|
@ -503,16 +503,24 @@ where
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if matching_context.considered_relative_selector {
|
||||
// This is a bit awkward - ideally, the flag is set directly where `considered_relative_selector`
|
||||
// is; however, in that context, the implementation detail of `extra_data` is not visible, so
|
||||
// it's done here. A trait for manipulating the flags is an option, but not worth it for a single flag.
|
||||
matching_context
|
||||
.extra_data
|
||||
.cascade_input_flags
|
||||
.insert(ComputedValueFlags::CONSIDERED_RELATIVE_SELECTOR);
|
||||
}
|
||||
// This is a bit awkward - ideally, the flag is set directly where `considered_relative_selector`
|
||||
// is; however, in that context, the implementation detail of `extra_data` is not visible, so
|
||||
// it's done here. A trait for manipulating the flags is an option, but not worth it for a single flag.
|
||||
match matching_context.considered_relative_selector {
|
||||
RelativeSelectorMatchingState::None => (),
|
||||
RelativeSelectorMatchingState::Considered => {
|
||||
matching_context
|
||||
.extra_data
|
||||
.cascade_input_flags
|
||||
.insert(ComputedValueFlags::CONSIDERED_RELATIVE_SELECTOR);
|
||||
},
|
||||
RelativeSelectorMatchingState::ConsideredAnchor => {
|
||||
matching_context.extra_data.cascade_input_flags.insert(
|
||||
ComputedValueFlags::ANCHORS_RELATIVE_SELECTOR |
|
||||
ComputedValueFlags::CONSIDERED_RELATIVE_SELECTOR,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
MatchingResults {
|
||||
rule_node,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue