Filter visited cascade to only visited dependent properties

Speed up the visited cascade by only running it for the properties that are
actually visited dependent.  (These are only the properties where the separate
set of visited styles is even read at all, so running the rest is wasted work.)

MozReview-Commit-ID: 5B7wYtuH974
This commit is contained in:
J. Ryan Stinnett 2017-05-11 16:30:26 -05:00
parent 47c8574c54
commit f12af6c8d6
2 changed files with 74 additions and 18 deletions

View file

@ -13,7 +13,8 @@ use data::{ComputedStyle, ElementData, RestyleData};
use dom::{TElement, TNode};
use font_metrics::FontMetricsProvider;
use log::LogLevel::Trace;
use properties::{AnimationRules, CascadeFlags, ComputedValues, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, cascade};
use properties::{AnimationRules, CascadeFlags, ComputedValues};
use properties::{SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, 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};
@ -188,7 +189,7 @@ impl CascadeVisitedMode {
*self == CascadeVisitedMode::Unvisited
}
/// Returns whether animations should be processed based on the cascade
/// Returns whether animations should be processed based on the cascade
/// mode. At the moment, it appears we don't need to support animating
/// visited styles.
fn should_process_animations(&self) -> bool {
@ -202,6 +203,12 @@ impl CascadeVisitedMode {
fn should_accumulate_damage(&self) -> bool {
*self == CascadeVisitedMode::Unvisited
}
/// Returns whether the cascade should filter to only visited dependent
/// properties based on the cascade mode.
fn visited_dependent_only(&self) -> bool {
*self == CascadeVisitedMode::Visited
}
}
trait PrivateMatchMethods: TElement {
@ -246,6 +253,9 @@ trait PrivateMatchMethods: TElement {
if self.skip_root_and_item_based_display_fixup() {
cascade_flags.insert(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP)
}
if cascade_visited.visited_dependent_only() {
cascade_flags.insert(VISITED_DEPENDENT_ONLY);
}
// Grab the inherited values.
let parent_el;