aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-01-19 23:05:18 -0600
committerGitHub <noreply@github.com>2018-01-19 23:05:18 -0600
commit6fc71a7644bd7afcccf83f67cfdaf01897e1a3bc (patch)
tree340a0cfcbb9065a62c57490786e2754f50db6518
parent3b07be555310a3a31445fae1150720cc3ff7d5d5 (diff)
parentbe4c0fecd8f997823850e3968a58e688bb8397bb (diff)
downloadservo-6fc71a7644bd7afcccf83f67cfdaf01897e1a3bc.tar.gz
servo-6fc71a7644bd7afcccf83f67cfdaf01897e1a3bc.zip
Auto merge of #19822 - emilio:less-match-public, r=KiChjang
style: More tiny selector-matching cleanup See each commit individually. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19822) <!-- Reviewable:end -->
-rw-r--r--components/selectors/context.rs8
-rw-r--r--components/selectors/matching.rs4
-rw-r--r--components/style/selector_map.rs64
-rw-r--r--components/style/stylist.rs7
4 files changed, 47 insertions, 36 deletions
diff --git a/components/selectors/context.rs b/components/selectors/context.rs
index f61823a626d..257a29afc44 100644
--- a/components/selectors/context.rs
+++ b/components/selectors/context.rs
@@ -100,7 +100,7 @@ where
Impl: SelectorImpl,
{
/// Input with the matching mode we should use when matching selectors.
- pub matching_mode: MatchingMode,
+ matching_mode: MatchingMode,
/// Input with the bloom filter used to fast-reject selectors.
pub bloom_filter: Option<&'a BloomFilter>,
/// An optional cache to speed up nth-index-like selectors.
@@ -204,6 +204,12 @@ where
self.quirks_mode
}
+ /// The matching-mode for this selector-matching operation.
+ #[inline]
+ pub fn matching_mode(&self) -> MatchingMode {
+ self.matching_mode
+ }
+
/// The case-sensitivity for class and ID selectors
#[inline]
pub fn classes_and_ids_case_sensitivity(&self) -> CaseSensitivity {
diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs
index d52b51d7270..eda52011ac7 100644
--- a/components/selectors/matching.rs
+++ b/components/selectors/matching.rs
@@ -285,7 +285,7 @@ where
{
// If this is the special pseudo-element mode, consume the ::pseudo-element
// before proceeding, since the caller has already handled that part.
- if context.matching_mode == MatchingMode::ForStatelessPseudoElement &&
+ if context.matching_mode() == MatchingMode::ForStatelessPseudoElement &&
!context.is_nested() {
// Consume the pseudo.
match *iter.next().unwrap() {
@@ -349,7 +349,7 @@ fn matches_hover_and_active_quirk<Impl: SelectorImpl>(
// This compound selector had a pseudo-element to the right that we
// intentionally skipped.
if rightmost == Rightmost::Yes &&
- context.matching_mode == MatchingMode::ForStatelessPseudoElement {
+ context.matching_mode() == MatchingMode::ForStatelessPseudoElement {
return MatchesHoverAndActiveQuirk::No;
}
diff --git a/components/style/selector_map.rs b/components/style/selector_map.rs
index 1ebf5cea6b6..0678f0ec922 100644
--- a/components/style/selector_map.rs
+++ b/components/style/selector_map.rs
@@ -159,7 +159,6 @@ impl SelectorMap<Rule> {
rule_hash_target: E,
matching_rules_list: &mut ApplicableDeclarationList,
context: &mut MatchingContext<E::Impl>,
- quirks_mode: QuirksMode,
flags_setter: &mut F,
cascade_level: CascadeLevel,
)
@@ -171,45 +170,56 @@ impl SelectorMap<Rule> {
return
}
- // At the end, we're going to sort the rules that we added, so remember where we began.
+ let quirks_mode = context.quirks_mode();
+
+ // At the end, we're going to sort the rules that we added, so remember
+ // where we began.
let init_len = matching_rules_list.len();
if let Some(id) = rule_hash_target.get_id() {
if let Some(rules) = self.id_hash.get(&id, quirks_mode) {
- SelectorMap::get_matching_rules(element,
- rules,
- matching_rules_list,
- context,
- flags_setter,
- cascade_level)
+ SelectorMap::get_matching_rules(
+ element,
+ rules,
+ matching_rules_list,
+ context,
+ flags_setter,
+ cascade_level,
+ )
}
}
rule_hash_target.each_class(|class| {
if let Some(rules) = self.class_hash.get(&class, quirks_mode) {
- SelectorMap::get_matching_rules(element,
- rules,
- matching_rules_list,
- context,
- flags_setter,
- cascade_level)
+ SelectorMap::get_matching_rules(
+ element,
+ rules,
+ matching_rules_list,
+ context,
+ flags_setter,
+ cascade_level,
+ )
}
});
if let Some(rules) = self.local_name_hash.get(rule_hash_target.get_local_name()) {
- SelectorMap::get_matching_rules(element,
- rules,
- matching_rules_list,
- context,
- flags_setter,
- cascade_level)
+ SelectorMap::get_matching_rules(
+ element,
+ rules,
+ matching_rules_list,
+ context,
+ flags_setter,
+ cascade_level,
+ )
}
- SelectorMap::get_matching_rules(element,
- &self.other,
- matching_rules_list,
- context,
- flags_setter,
- cascade_level);
+ SelectorMap::get_matching_rules(
+ element,
+ &self.other,
+ matching_rules_list,
+ context,
+ flags_setter,
+ cascade_level,
+ );
// Sort only the rules we just added.
matching_rules_list[init_len..].sort_unstable_by_key(|block| (block.specificity, block.source_order()));
@@ -247,7 +257,7 @@ impl<T: SelectorMapEntry> SelectorMap<T> {
pub fn insert(
&mut self,
entry: T,
- quirks_mode: QuirksMode
+ quirks_mode: QuirksMode,
) -> Result<(), FailedAllocationError> {
self.count += 1;
diff --git a/components/style/stylist.rs b/components/style/stylist.rs
index ec8b738bccd..88689d92890 100644
--- a/components/style/stylist.rs
+++ b/components/style/stylist.rs
@@ -1236,7 +1236,6 @@ impl Stylist {
rule_hash_target,
applicable_declarations,
context,
- self.quirks_mode,
flags_setter,
CascadeLevel::UANormal
);
@@ -1274,7 +1273,6 @@ impl Stylist {
rule_hash_target,
applicable_declarations,
context,
- self.quirks_mode,
flags_setter,
CascadeLevel::UserNormal,
);
@@ -1305,7 +1303,6 @@ impl Stylist {
rule_hash_target,
applicable_declarations,
context,
- self.quirks_mode,
flags_setter,
CascadeLevel::AuthorNormal
);
@@ -1327,7 +1324,7 @@ impl Stylist {
// as `context`, write a test-case of :visited not working on
// Shadow DOM and fix it!
let mut matching_context = MatchingContext::new(
- context.matching_mode,
+ context.matching_mode(),
context.bloom_filter,
context.nth_index_cache.as_mut().map(|s| &mut **s),
stylist.quirks_mode,
@@ -1339,7 +1336,6 @@ impl Stylist {
rule_hash_target,
applicable_declarations,
&mut matching_context,
- stylist.quirks_mode,
flags_setter,
CascadeLevel::AuthorNormal,
);
@@ -1356,7 +1352,6 @@ impl Stylist {
rule_hash_target,
applicable_declarations,
context,
- self.quirks_mode,
flags_setter,
CascadeLevel::AuthorNormal
);