style: Refactor RestyleHint to be a struct.

Later PRs will add additional data to it that is not so easy to
represent using bitflags.
This commit is contained in:
Cameron McCormack 2017-05-19 17:39:15 +08:00 committed by Emilio Cobos Álvarez
parent c13be5cd13
commit a397590838
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
9 changed files with 294 additions and 111 deletions

View file

@ -19,7 +19,7 @@ use font_metrics::FontMetricsProvider;
use log::LogLevel::Trace;
use properties::{CascadeFlags, ComputedValues, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, cascade};
use properties::longhands::display::computed_value as display;
use restyle_hints::{RESTYLE_CSS_ANIMATIONS, RESTYLE_CSS_TRANSITIONS, RestyleHint};
use restyle_hints::{RESTYLE_CSS_ANIMATIONS, RESTYLE_CSS_TRANSITIONS, RestyleReplacements};
use restyle_hints::{RESTYLE_STYLE_ATTRIBUTE, RESTYLE_SMIL};
use rule_tree::{CascadeLevel, RuleTree, StrongRuleNode};
use selector_parser::{PseudoElement, RestyleDamage, SelectorImpl};
@ -1327,7 +1327,7 @@ pub trait MatchMethods : TElement {
/// the rule tree. Returns RulesChanged which indicates whether the rule nodes changed
/// and whether the important rules changed.
fn replace_rules(&self,
hint: RestyleHint,
replacements: RestyleReplacements,
context: &StyleContext<Self>,
data: &mut AtomicRefMut<ElementData>)
-> RulesChanged {
@ -1359,10 +1359,10 @@ pub trait MatchMethods : TElement {
//
// Non-animation restyle hints will be processed in a subsequent
// normal traversal.
if hint.intersects(RestyleHint::for_animations()) {
if replacements.intersects(RestyleReplacements::for_animations()) {
debug_assert!(context.shared.traversal_flags.for_animation_only());
if hint.contains(RESTYLE_SMIL) {
if replacements.contains(RESTYLE_SMIL) {
replace_rule_node(CascadeLevel::SMILOverride,
self.get_smil_override(),
primary_rules);
@ -1378,16 +1378,16 @@ pub trait MatchMethods : TElement {
// Apply Transition rules and Animation rules if the corresponding restyle hint
// is contained.
if hint.contains(RESTYLE_CSS_TRANSITIONS) {
if replacements.contains(RESTYLE_CSS_TRANSITIONS) {
replace_rule_node_for_animation(CascadeLevel::Transitions,
primary_rules);
}
if hint.contains(RESTYLE_CSS_ANIMATIONS) {
if replacements.contains(RESTYLE_CSS_ANIMATIONS) {
replace_rule_node_for_animation(CascadeLevel::Animations,
primary_rules);
}
} else if hint.contains(RESTYLE_STYLE_ATTRIBUTE) {
} else if replacements.contains(RESTYLE_STYLE_ATTRIBUTE) {
let style_attribute = self.style_attribute();
replace_rule_node(CascadeLevel::StyleAttributeNormal,
style_attribute,