mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
style: Remove IS_STYLE_IF_VISITED.
Bug: 1474959 Reviewed-by: xidorn MozReview-Commit-ID: 8rnlaMOJisA
This commit is contained in:
parent
4e1606bfaf
commit
08dcd7fca0
4 changed files with 7 additions and 43 deletions
|
@ -56,13 +56,10 @@ bitflags! {
|
||||||
/// Whether the child explicitly inherits any reset property.
|
/// Whether the child explicitly inherits any reset property.
|
||||||
const INHERITS_RESET_STYLE = 1 << 8;
|
const INHERITS_RESET_STYLE = 1 << 8;
|
||||||
|
|
||||||
/// A flag to mark a style which is a visited style.
|
|
||||||
const IS_STYLE_IF_VISITED = 1 << 9;
|
|
||||||
|
|
||||||
/// Whether the style or any of the ancestors has a multicol style.
|
/// Whether the style or any of the ancestors has a multicol style.
|
||||||
///
|
///
|
||||||
/// Only used in Servo.
|
/// Only used in Servo.
|
||||||
const CAN_BE_FRAGMENTED = 1 << 10;
|
const CAN_BE_FRAGMENTED = 1 << 9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +67,6 @@ impl ComputedValueFlags {
|
||||||
/// Flags that are unconditionally propagated to descendants.
|
/// Flags that are unconditionally propagated to descendants.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn inherited_flags() -> Self {
|
fn inherited_flags() -> Self {
|
||||||
ComputedValueFlags::IS_STYLE_IF_VISITED |
|
|
||||||
ComputedValueFlags::IS_RELEVANT_LINK_VISITED |
|
ComputedValueFlags::IS_RELEVANT_LINK_VISITED |
|
||||||
ComputedValueFlags::CAN_BE_FRAGMENTED |
|
ComputedValueFlags::CAN_BE_FRAGMENTED |
|
||||||
ComputedValueFlags::IS_IN_PSEUDO_ELEMENT_SUBTREE |
|
ComputedValueFlags::IS_IN_PSEUDO_ELEMENT_SUBTREE |
|
||||||
|
|
|
@ -2692,11 +2692,6 @@ impl ComputedValues {
|
||||||
self.get_box().clone_display().is_contents()
|
self.get_box().clone_display().is_contents()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether we're a visited style.
|
|
||||||
pub fn is_style_if_visited(&self) -> bool {
|
|
||||||
self.flags.contains(ComputedValueFlags::IS_STYLE_IF_VISITED)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets a reference to the rule node. Panic if no rule node exists.
|
/// Gets a reference to the rule node. Panic if no rule node exists.
|
||||||
pub fn rules(&self) -> &StrongRuleNode {
|
pub fn rules(&self) -> &StrongRuleNode {
|
||||||
self.rules.as_ref().unwrap()
|
self.rules.as_ref().unwrap()
|
||||||
|
@ -3225,7 +3220,6 @@ impl<'a> StyleBuilder<'a> {
|
||||||
parent_style: Option<<&'a ComputedValues>,
|
parent_style: Option<<&'a ComputedValues>,
|
||||||
parent_style_ignoring_first_line: Option<<&'a ComputedValues>,
|
parent_style_ignoring_first_line: Option<<&'a ComputedValues>,
|
||||||
pseudo: Option<<&'a PseudoElement>,
|
pseudo: Option<<&'a PseudoElement>,
|
||||||
cascade_mode: CascadeMode,
|
|
||||||
rules: Option<StrongRuleNode>,
|
rules: Option<StrongRuleNode>,
|
||||||
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -3248,10 +3242,7 @@ impl<'a> StyleBuilder<'a> {
|
||||||
reset_style
|
reset_style
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut flags = inherited_style.flags.inherited();
|
let flags = inherited_style.flags.inherited();
|
||||||
if matches!(cascade_mode, CascadeMode::Visited { .. }) {
|
|
||||||
flags.insert(ComputedValueFlags::IS_STYLE_IF_VISITED);
|
|
||||||
}
|
|
||||||
|
|
||||||
StyleBuilder {
|
StyleBuilder {
|
||||||
device,
|
device,
|
||||||
|
@ -3275,11 +3266,6 @@ impl<'a> StyleBuilder<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether we're a visited style.
|
|
||||||
pub fn is_style_if_visited(&self) -> bool {
|
|
||||||
self.flags.contains(ComputedValueFlags::IS_STYLE_IF_VISITED)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// NOTE(emilio): This is done so we can compute relative units with respect
|
/// NOTE(emilio): This is done so we can compute relative units with respect
|
||||||
/// to the parent style, but all the early properties / writing-mode / etc
|
/// to the parent style, but all the early properties / writing-mode / etc
|
||||||
/// are already set to the right ones on the kid.
|
/// are already set to the right ones on the kid.
|
||||||
|
@ -3420,11 +3406,6 @@ impl<'a> StyleBuilder<'a> {
|
||||||
// produced by this builder. This assumes that the caller doesn't need
|
// produced by this builder. This assumes that the caller doesn't need
|
||||||
// to adjust or process visited style, so we can just build visited
|
// to adjust or process visited style, so we can just build visited
|
||||||
// style here for simplicity.
|
// style here for simplicity.
|
||||||
//
|
|
||||||
// FIXME(emilio): This doesn't set the IS_STYLE_IF_VISITED flag
|
|
||||||
// correctly, though right now it doesn't matter.
|
|
||||||
//
|
|
||||||
// We can probably kill that flag now.
|
|
||||||
let visited_style = parent.and_then(|parent| {
|
let visited_style = parent.and_then(|parent| {
|
||||||
parent.visited_style().map(|style| {
|
parent.visited_style().map(|style| {
|
||||||
Self::for_inheritance(
|
Self::for_inheritance(
|
||||||
|
@ -3439,7 +3420,6 @@ impl<'a> StyleBuilder<'a> {
|
||||||
parent,
|
parent,
|
||||||
parent,
|
parent,
|
||||||
pseudo,
|
pseudo,
|
||||||
CascadeMode::Unvisited { visited_rules: None },
|
|
||||||
/* rules = */ None,
|
/* rules = */ None,
|
||||||
parent.and_then(|p| p.custom_properties().cloned()),
|
parent.and_then(|p| p.custom_properties().cloned()),
|
||||||
);
|
);
|
||||||
|
@ -3851,7 +3831,6 @@ where
|
||||||
parent_style,
|
parent_style,
|
||||||
parent_style_ignoring_first_line,
|
parent_style_ignoring_first_line,
|
||||||
pseudo,
|
pseudo,
|
||||||
cascade_mode,
|
|
||||||
Some(rules.clone()),
|
Some(rules.clone()),
|
||||||
custom_properties,
|
custom_properties,
|
||||||
),
|
),
|
||||||
|
@ -4012,7 +3991,11 @@ where
|
||||||
font_metrics_provider,
|
font_metrics_provider,
|
||||||
CascadeMode::Visited { writing_mode },
|
CascadeMode::Visited { writing_mode },
|
||||||
quirks_mode,
|
quirks_mode,
|
||||||
rule_cache,
|
// The rule cache doesn't care about caching :visited
|
||||||
|
// styles, we cache the unvisited style instead. We still do
|
||||||
|
// need to set the caching dependencies properly if present
|
||||||
|
// though, so the cache conditions need to match.
|
||||||
|
/* rule_cache = */ None,
|
||||||
&mut *context.rule_cache_conditions.borrow_mut(),
|
&mut *context.rule_cache_conditions.borrow_mut(),
|
||||||
element,
|
element,
|
||||||
));
|
));
|
||||||
|
|
|
@ -124,11 +124,6 @@ impl RuleCache {
|
||||||
guards: &StylesheetGuards,
|
guards: &StylesheetGuards,
|
||||||
builder_with_early_props: &StyleBuilder,
|
builder_with_early_props: &StyleBuilder,
|
||||||
) -> Option<&ComputedValues> {
|
) -> Option<&ComputedValues> {
|
||||||
if builder_with_early_props.is_style_if_visited() {
|
|
||||||
// FIXME(emilio): We can probably do better, does it matter much?
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
// A pseudo-element with property restrictions can result in different
|
// A pseudo-element with property restrictions can result in different
|
||||||
// computed values if it's also used for a non-pseudo.
|
// computed values if it's also used for a non-pseudo.
|
||||||
if builder_with_early_props
|
if builder_with_early_props
|
||||||
|
@ -166,11 +161,6 @@ impl RuleCache {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if style.is_style_if_visited() {
|
|
||||||
// FIXME(emilio): We can probably do better, does it matter much?
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// A pseudo-element with property restrictions can result in different
|
// A pseudo-element with property restrictions can result in different
|
||||||
// computed values if it's also used for a non-pseudo.
|
// computed values if it's also used for a non-pseudo.
|
||||||
if pseudo.and_then(|p| p.property_restriction()).is_some() {
|
if pseudo.and_then(|p| p.property_restriction()).is_some() {
|
||||||
|
|
|
@ -684,11 +684,6 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
) where
|
) where
|
||||||
E: TElement,
|
E: TElement,
|
||||||
{
|
{
|
||||||
debug_assert!(
|
|
||||||
!self.style.flags.contains(ComputedValueFlags::IS_STYLE_IF_VISITED),
|
|
||||||
"Adjusting visited styles is wasted work"
|
|
||||||
);
|
|
||||||
|
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
if element
|
if element
|
||||||
.and_then(|e| e.implemented_pseudo_element())
|
.and_then(|e| e.implemented_pseudo_element())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue