mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Remove unneeded bounds in SelectorMap and related code.
MozReview-Commit-ID: CWwdVCwWijn
This commit is contained in:
parent
ebfc8f5858
commit
9394ea9644
3 changed files with 4 additions and 27 deletions
|
@ -109,10 +109,6 @@ impl SelectorMapEntry for Dependency {
|
|||
fn selector(&self) -> SelectorIter<SelectorImpl> {
|
||||
self.selector.iter_from(self.selector_offset)
|
||||
}
|
||||
|
||||
fn hashes(&self) -> &AncestorHashes {
|
||||
&self.hashes
|
||||
}
|
||||
}
|
||||
|
||||
/// The same, but for state selectors, which can track more exactly what state
|
||||
|
@ -128,11 +124,7 @@ pub struct StateDependency {
|
|||
|
||||
impl SelectorMapEntry for StateDependency {
|
||||
fn selector(&self) -> SelectorIter<SelectorImpl> {
|
||||
self.dep.selector.iter_from(self.dep.selector_offset)
|
||||
}
|
||||
|
||||
fn hashes(&self) -> &AncestorHashes {
|
||||
&self.dep.hashes
|
||||
self.dep.selector()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use pdqsort::sort_by;
|
|||
use rule_tree::CascadeLevel;
|
||||
use selector_parser::SelectorImpl;
|
||||
use selectors::matching::{matches_selector, MatchingContext, ElementSelectorFlags};
|
||||
use selectors::parser::{AncestorHashes, Component, Combinator, SelectorAndHashes, SelectorIter};
|
||||
use selectors::parser::{Component, Combinator, SelectorAndHashes, SelectorIter};
|
||||
use selectors::parser::LocalName as LocalNameSelector;
|
||||
use smallvec::VecLike;
|
||||
use std::collections::HashMap;
|
||||
|
@ -26,19 +26,12 @@ use stylist::Rule;
|
|||
pub trait SelectorMapEntry : Sized + Clone {
|
||||
/// Gets the selector we should use to index in the selector map.
|
||||
fn selector(&self) -> SelectorIter<SelectorImpl>;
|
||||
|
||||
/// Gets the ancestor hashes associated with the selector.
|
||||
fn hashes(&self) -> &AncestorHashes;
|
||||
}
|
||||
|
||||
impl SelectorMapEntry for SelectorAndHashes<SelectorImpl> {
|
||||
fn selector(&self) -> SelectorIter<SelectorImpl> {
|
||||
self.selector.iter()
|
||||
}
|
||||
|
||||
fn hashes(&self) -> &AncestorHashes {
|
||||
&self.hashes
|
||||
}
|
||||
}
|
||||
|
||||
/// Map element data to selector-providing objects for which the last simple
|
||||
|
@ -65,7 +58,7 @@ impl SelectorMapEntry for SelectorAndHashes<SelectorImpl> {
|
|||
/// TODO: Tune the initial capacity of the HashMap
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SelectorMap<T: SelectorMapEntry> {
|
||||
pub struct SelectorMap<T> {
|
||||
/// A hash from an ID to rules which contain that ID selector.
|
||||
pub id_hash: MaybeCaseInsensitiveHashMap<Atom, Vec<T>>,
|
||||
/// A hash from a class name to rules which contain that class selector.
|
||||
|
@ -83,7 +76,7 @@ fn sort_by_key<T, F: Fn(&T) -> K, K: Ord>(v: &mut [T], f: F) {
|
|||
sort_by(v, |a, b| f(a).cmp(&f(b)))
|
||||
}
|
||||
|
||||
impl<T: SelectorMapEntry> SelectorMap<T> {
|
||||
impl<T> SelectorMap<T> {
|
||||
/// Trivially constructs an empty `SelectorMap`.
|
||||
pub fn new() -> Self {
|
||||
SelectorMap {
|
||||
|
|
|
@ -1461,10 +1461,6 @@ impl SelectorMapEntry for RevalidationSelectorAndHashes {
|
|||
fn selector(&self) -> SelectorIter<SelectorImpl> {
|
||||
self.selector.iter_from(self.selector_offset)
|
||||
}
|
||||
|
||||
fn hashes(&self) -> &AncestorHashes {
|
||||
&self.hashes
|
||||
}
|
||||
}
|
||||
|
||||
/// Visitor to determine whether a selector requires cache revalidation.
|
||||
|
@ -1609,10 +1605,6 @@ impl SelectorMapEntry for Rule {
|
|||
fn selector(&self) -> SelectorIter<SelectorImpl> {
|
||||
self.selector.iter()
|
||||
}
|
||||
|
||||
fn hashes(&self) -> &AncestorHashes {
|
||||
&self.hashes
|
||||
}
|
||||
}
|
||||
|
||||
impl Rule {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue