Skip to content

Commit

Permalink
style: Provide whether we're styling or not to rust-selectors.
Browse files Browse the repository at this point in the history
This makes us not adding the flags to everything in servo.
  • Loading branch information
emilio committed Sep 1, 2016
1 parent bbfe38e commit 468b329
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 64 deletions.
2 changes: 1 addition & 1 deletion components/layout/Cargo.toml
Expand Up @@ -33,7 +33,7 @@ range = {path = "../range"}
rustc-serialize = "0.3"
script_layout_interface = {path = "../script_layout_interface"}
script_traits = {path = "../script_traits"}
selectors = {version = "0.12", features = ["heap_size"]}
selectors = {version = "0.13", features = ["heap_size"]}
serde_macros = "0.8"
smallvec = "0.1"
string_cache = {version = "0.2.26", features = ["heap_size"]}
Expand Down
2 changes: 1 addition & 1 deletion components/script/Cargo.toml
Expand Up @@ -61,7 +61,7 @@ regex = "0.1.43"
rustc-serialize = "0.3"
script_layout_interface = {path = "../script_layout_interface"}
script_traits = {path = "../script_traits"}
selectors = {version = "0.12", features = ["heap_size"]}
selectors = {version = "0.13", features = ["heap_size"]}
serde = "0.8"
smallvec = "0.1"
string_cache = {version = "0.2.26", features = ["heap_size", "unstable"]}
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/element.rs
Expand Up @@ -70,7 +70,7 @@ use html5ever::serialize::SerializeOpts;
use html5ever::serialize::TraversalScope;
use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode};
use html5ever::tree_builder::{LimitedQuirks, NoQuirks, Quirks};
use selectors::matching::{ElementFlags, matches};
use selectors::matching::{ElementFlags, MatchingReason, matches};
use selectors::matching::{HAS_SLOW_SELECTOR, HAS_EDGE_CHILD_SELECTOR, HAS_SLOW_SELECTOR_LATER_SIBLINGS};
use selectors::parser::{AttrSelector, NamespaceConstraint, parse_author_origin_selector_list_from_str};
use std::ascii::AsciiExt;
Expand Down Expand Up @@ -2006,7 +2006,7 @@ impl ElementMethods for Element {
match parse_author_origin_selector_list_from_str(&selectors) {
Err(()) => Err(Error::Syntax),
Ok(ref selectors) => {
Ok(matches(selectors, &Root::from_ref(self), None))
Ok(matches(selectors, &Root::from_ref(self), None, MatchingReason::Other))
}
}
}
Expand All @@ -2024,7 +2024,7 @@ impl ElementMethods for Element {
let root = self.upcast::<Node>();
for element in root.inclusive_ancestors() {
if let Some(element) = Root::downcast::<Element>(element) {
if matches(selectors, &element, None) {
if matches(selectors, &element, None, MatchingReason::Other) {
return Ok(Some(element));
}
}
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/node.rs
Expand Up @@ -63,7 +63,7 @@ use script_layout_interface::message::Msg;
use script_layout_interface::{HTMLCanvasData, OpaqueStyleAndLayoutData};
use script_layout_interface::{LayoutNodeType, LayoutElementType, TrustedNodeAddress};
use script_traits::UntrustedNodeAddress;
use selectors::matching::matches;
use selectors::matching::{MatchingReason, matches};
use selectors::parser::Selector;
use selectors::parser::parse_author_origin_selector_list_from_str;
use std::borrow::ToOwned;
Expand Down Expand Up @@ -319,7 +319,7 @@ impl<'a> Iterator for QuerySelectorIterator {
// (instead of passing `None`)? Probably.
self.iterator.by_ref().filter_map(|node| {
if let Some(element) = Root::downcast(node) {
if matches(selectors, &element, None) {
if matches(selectors, &element, None, MatchingReason::Other) {
return Some(Root::upcast(element));
}
}
Expand Down Expand Up @@ -711,7 +711,7 @@ impl Node {
// Step 3.
Ok(ref selectors) => {
Ok(self.traverse_preorder().filter_map(Root::downcast).find(|element| {
matches(selectors, element, None)
matches(selectors, element, None, MatchingReason::Other)
}))
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/script_layout_interface/Cargo.toml
Expand Up @@ -27,7 +27,7 @@ plugins = {path = "../plugins"}
profile_traits = {path = "../profile_traits"}
range = {path = "../range"}
script_traits = {path = "../script_traits"}
selectors = {version = "0.12", features = ["heap_size"]}
selectors = {version = "0.13", features = ["heap_size"]}
string_cache = {version = "0.2.26", features = ["heap_size"]}
style = {path = "../style"}
url = {version = "1.2", features = ["heap_size"]}
Expand Down
14 changes: 7 additions & 7 deletions components/servo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/style/Cargo.toml
Expand Up @@ -40,7 +40,7 @@ ordered-float = "0.2.2"
quickersort = "2.0.0"
rand = "0.3"
rustc-serialize = "0.3"
selectors = "0.12"
selectors = "0.13"
serde = {version = "0.8", optional = true}
serde_macros = {version = "0.8", optional = true}
smallvec = "0.1"
Expand Down
8 changes: 5 additions & 3 deletions components/style/matching.rs
Expand Up @@ -18,7 +18,7 @@ use properties::{ComputedValues, cascade, PropertyDeclarationBlock};
use selector_impl::{TheSelectorImpl, PseudoElement};
use selector_matching::{DeclarationBlock, Stylist};
use selectors::bloom::BloomFilter;
use selectors::matching::{StyleRelations, AFFECTED_BY_PSEUDO_ELEMENTS};
use selectors::matching::{MatchingReason, StyleRelations, AFFECTED_BY_PSEUDO_ELEMENTS};
use selectors::{Element, MatchAttr};
use sink::ForgetfulSink;
use smallvec::SmallVec;
Expand Down Expand Up @@ -658,7 +658,8 @@ pub trait ElementMatchMethods : TElement {
parent_bf,
style_attribute,
None,
&mut applicable_declarations.normal);
&mut applicable_declarations.normal,
MatchingReason::ForStyling);

applicable_declarations.normal_shareable = relations_are_shareable(&relations);

Expand All @@ -667,7 +668,8 @@ pub trait ElementMatchMethods : TElement {
parent_bf,
None,
Some(&pseudo.clone()),
applicable_declarations.per_pseudo.entry(pseudo).or_insert(vec![]));
applicable_declarations.per_pseudo.entry(pseudo).or_insert(vec![]),
MatchingReason::ForStyling);
});

let has_pseudos =
Expand Down
8 changes: 5 additions & 3 deletions components/style/restyle_hints.rs
Expand Up @@ -8,8 +8,8 @@ use element_state::*;
#[cfg(feature = "servo")]
use heapsize::HeapSizeOf;
use selector_impl::{ElementExt, TheSelectorImpl, NonTSPseudoClass, AttrValue};
use selectors::matching::StyleRelations;
use selectors::matching::matches_complex_selector;
use selectors::matching::{MatchingReason, StyleRelations};
use selectors::parser::{AttrSelector, Combinator, ComplexSelector, SimpleSelector, SelectorImpl};
use selectors::{Element, MatchAttr};
use std::clone::Clone;
Expand Down Expand Up @@ -476,10 +476,12 @@ impl DependencySet {
if (attrs_changed || state_changes.intersects(dep.sensitivities.states)) && !hint.intersects(dep.hint) {
let matched_then =
matches_complex_selector(&dep.selector, snapshot, None,
&mut StyleRelations::empty());
&mut StyleRelations::empty(),
MatchingReason::Other);
let matches_now =
matches_complex_selector(&dep.selector, element, None,
&mut StyleRelations::empty());
&mut StyleRelations::empty(),
MatchingReason::Other);
if matched_then != matches_now {
hint.insert(dep.hint);
}
Expand Down

0 comments on commit 468b329

Please sign in to comment.