Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: Split style resolution and dynamic change computation. #17688

Merged
merged 11 commits into from Jul 12, 2017

style: Remove StyleRelations.

They're unused now. We can add them back if needed.

MozReview-Commit-ID: 92Y2Na0ZbVn
  • Loading branch information
emilio committed Jul 12, 2017
commit 6d6c80e79b9e62b38557125f509158a5fca75253
@@ -5,19 +5,6 @@
use attr::CaseSensitivity;
use bloom::BloomFilter;

bitflags! {
/// Set of flags that determine the different kind of elements affected by
/// the selector matching process.
///
/// This is used to implement efficient sharing.
#[derive(Default)]
pub flags StyleRelations: usize {
/// Whether this element is affected by presentational hints. This is
/// computed externally (that is, in Servo).
const AFFECTED_BY_PRESENTATIONAL_HINTS = 1 << 0,
}
}

/// What kind of selector matching mode we should use.
///
/// There are two modes of selector matching. The difference is only noticeable
@@ -87,9 +74,6 @@ impl QuirksMode {
/// transient data that applies to only a single selector.
#[derive(Clone)]
pub struct MatchingContext<'a> {
/// Output that records certains relations between elements noticed during
/// matching (and also extended after matching).
pub relations: StyleRelations,
/// Input with the matching mode we should use when matching selectors.
pub matching_mode: MatchingMode,
/// Input with the bloom filter used to fast-reject selectors.
@@ -114,7 +98,6 @@ impl<'a> MatchingContext<'a> {
-> Self
{
Self {
relations: StyleRelations::empty(),
matching_mode: matching_mode,
bloom_filter: bloom_filter,
visited_handling: VisitedHandlingMode::AllLinksUnvisited,
@@ -132,7 +115,6 @@ impl<'a> MatchingContext<'a> {
-> Self
{
Self {
relations: StyleRelations::empty(),
matching_mode: matching_mode,
bloom_filter: bloom_filter,
visited_handling: visited_handling,
@@ -714,8 +714,6 @@ fn matches_simple_selector<E, F>(
matches_last_child(element, flags_setter)
}
Component::Root => {
// We never share styles with an element with no parent, so no point
// in creating a new StyleRelation.
element.is_root()
}
Component::Empty => {
@@ -26,7 +26,7 @@ use selector_parser::{SelectorImpl, PseudoElement};
use selectors::attr::NamespaceConstraint;
use selectors::bloom::BloomFilter;
use selectors::matching::{ElementSelectorFlags, matches_selector, MatchingContext, MatchingMode};
use selectors::matching::{VisitedHandlingMode, AFFECTED_BY_PRESENTATIONAL_HINTS};
use selectors::matching::VisitedHandlingMode;
use selectors::parser::{AncestorHashes, Combinator, Component, Selector, SelectorAndHashes};
use selectors::parser::{SelectorIter, SelectorMethods};
use selectors::sink::Push;
@@ -1145,7 +1145,6 @@ impl Stylist {
self.quirks_mode,
flags_setter,
CascadeLevel::UANormal);
debug!("UA normal: {:?}", context.relations);

if pseudo_element.is_none() && !only_default_rules {
// Step 2: Presentational hints.
@@ -1160,12 +1159,7 @@ impl Stylist {
assert_eq!(declaration.level(), CascadeLevel::PresHints);
}
}
// Note the existence of presentational attributes so that the
// style sharing cache can avoid re-querying them if they don't
// exist.
context.relations |= AFFECTED_BY_PRESENTATIONAL_HINTS;
}
debug!("preshints: {:?}", context.relations);
}

// NB: the following condition, although it may look somewhat
@@ -1185,7 +1179,6 @@ impl Stylist {
self.quirks_mode,
flags_setter,
CascadeLevel::UserNormal);
debug!("user normal: {:?}", context.relations);
} else {
debug!("skipping user rules");
}
@@ -1194,7 +1187,6 @@ impl Stylist {
let cut_off_inheritance =
element.get_declarations_from_xbl_bindings(pseudo_element,
applicable_declarations);
debug!("XBL: {:?}", context.relations);

if rule_hash_target.matches_user_and_author_rules() && !only_default_rules {
// Gecko skips author normal rules if cutting off inheritance.
@@ -1208,7 +1200,6 @@ impl Stylist {
self.quirks_mode,
flags_setter,
CascadeLevel::AuthorNormal);
debug!("author normal: {:?}", context.relations);
} else {
debug!("skipping author normal rules due to cut off inheritance");
}
@@ -1224,7 +1215,6 @@ impl Stylist {
ApplicableDeclarationBlock::from_declarations(sa.clone(),
CascadeLevel::StyleAttributeNormal));
}
debug!("style attr: {:?}", context.relations);

// Step 5: SMIL override.
// Declarations from SVG SMIL animation elements.
@@ -1234,7 +1224,6 @@ impl Stylist {
ApplicableDeclarationBlock::from_declarations(so.clone(),
CascadeLevel::SMILOverride));
}
debug!("SMIL: {:?}", context.relations);

// Step 6: Animations.
// The animations sheet (CSS animations, script-generated animations,
@@ -1245,7 +1234,6 @@ impl Stylist {
ApplicableDeclarationBlock::from_declarations(anim.clone(),
CascadeLevel::Animations));
}
debug!("animation: {:?}", context.relations);
} else {
debug!("skipping style attr and SMIL & animation rules");
}
@@ -1264,12 +1252,9 @@ impl Stylist {
ApplicableDeclarationBlock::from_declarations(anim.clone(),
CascadeLevel::Transitions));
}
debug!("transition: {:?}", context.relations);
} else {
debug!("skipping transition rules");
}

debug!("push_applicable_declarations: shareable: {:?}", context.relations);
}

/// Given an id, returns whether there might be any rules for that id in any
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.