mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
style: Implement a more fine-grained invalidation method.
This commit also removes the old restyle_hints module and splits it into multiple modules under components/style/invalidation/element/. The basic approach is to walk down the tree using compound selectors as needed, in order to do as little selector-matching as possible. Bug: 1368240 MozReview-Commit-ID: 2YO8fKFygZI
This commit is contained in:
parent
fd10729941
commit
cb06375fe2
21 changed files with 1673 additions and 1486 deletions
|
@ -13,13 +13,14 @@ use context::{SelectorFlagsMap, SharedStyleContext, StyleContext};
|
|||
use data::{ComputedStyle, ElementData, RestyleData};
|
||||
use dom::{TElement, TNode};
|
||||
use font_metrics::FontMetricsProvider;
|
||||
use invalidation::element::restyle_hints::{RESTYLE_CSS_ANIMATIONS, RESTYLE_CSS_TRANSITIONS};
|
||||
use invalidation::element::restyle_hints::{RESTYLE_SMIL, RESTYLE_STYLE_ATTRIBUTE};
|
||||
use invalidation::element::restyle_hints::RestyleHint;
|
||||
use log::LogLevel::Trace;
|
||||
use properties::{ALLOW_SET_ROOT_FONT_SIZE, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP};
|
||||
use properties::{AnimationRules, CascadeFlags, ComputedValues};
|
||||
use properties::{VISITED_DEPENDENT_ONLY, cascade};
|
||||
use properties::longhands::display::computed_value as display;
|
||||
use restyle_hints::{RESTYLE_CSS_ANIMATIONS, RESTYLE_CSS_TRANSITIONS, RestyleReplacements};
|
||||
use restyle_hints::{RESTYLE_STYLE_ATTRIBUTE, RESTYLE_SMIL};
|
||||
use rule_tree::{CascadeLevel, StrongRuleNode};
|
||||
use selector_parser::{PseudoElement, RestyleDamage, SelectorImpl};
|
||||
use selectors::matching::{ElementSelectorFlags, MatchingContext, MatchingMode, StyleRelations};
|
||||
|
@ -1276,11 +1277,12 @@ pub trait MatchMethods : TElement {
|
|||
/// the rule tree.
|
||||
///
|
||||
/// Returns true if an !important rule was replaced.
|
||||
fn replace_rules(&self,
|
||||
replacements: RestyleReplacements,
|
||||
context: &StyleContext<Self>,
|
||||
data: &mut ElementData)
|
||||
-> bool {
|
||||
fn replace_rules(
|
||||
&self,
|
||||
replacements: RestyleHint,
|
||||
context: &StyleContext<Self>,
|
||||
data: &mut ElementData
|
||||
) -> bool {
|
||||
let mut result = false;
|
||||
result |= self.replace_rules_internal(replacements, context, data,
|
||||
CascadeVisitedMode::Unvisited);
|
||||
|
@ -1295,15 +1297,19 @@ pub trait MatchMethods : TElement {
|
|||
/// the rule tree, for a specific visited mode.
|
||||
///
|
||||
/// Returns true if an !important rule was replaced.
|
||||
fn replace_rules_internal(&self,
|
||||
replacements: RestyleReplacements,
|
||||
context: &StyleContext<Self>,
|
||||
data: &mut ElementData,
|
||||
cascade_visited: CascadeVisitedMode)
|
||||
-> bool {
|
||||
fn replace_rules_internal(
|
||||
&self,
|
||||
replacements: RestyleHint,
|
||||
context: &StyleContext<Self>,
|
||||
data: &mut ElementData,
|
||||
cascade_visited: CascadeVisitedMode
|
||||
) -> bool {
|
||||
use properties::PropertyDeclarationBlock;
|
||||
use shared_lock::Locked;
|
||||
|
||||
debug_assert!(replacements.intersects(RestyleHint::replacements()) &&
|
||||
(replacements & !RestyleHint::replacements()).is_empty());
|
||||
|
||||
let element_styles = &mut data.styles_mut();
|
||||
let primary_rules = match cascade_visited.get_rules_mut(&mut element_styles.primary) {
|
||||
Some(r) => r,
|
||||
|
@ -1344,7 +1350,7 @@ pub trait MatchMethods : TElement {
|
|||
//
|
||||
// Non-animation restyle hints will be processed in a subsequent
|
||||
// normal traversal.
|
||||
if replacements.intersects(RestyleReplacements::for_animations()) {
|
||||
if replacements.intersects(RestyleHint::for_animations()) {
|
||||
debug_assert!(context.shared.traversal_flags.for_animation_only());
|
||||
|
||||
if replacements.contains(RESTYLE_SMIL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue