Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 21cbde5

Browse files
committed
servo: Merge #19424 - Remove unused generic from push_applicable_declarations (from mbrubeck:veclike); r=emilio
This function is only ever used with one type. This gets rid of the only use of the `smallvec::VecLike` trait, which we may want to deprecate (servo/rust-smallvec#35). If we do need to make this function generic in the future, we can do it using standard traits instead. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because they are removing unused code Source-Repo: https://github.com/servo/servo Source-Revision: dbe3136a055008d2c27c7d96f20e0c9ce4b1cb1c --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : fd711a25e3eeb999712269c39a74c99981975a63
1 parent 235e31c commit 21cbde5

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

servo/components/style/selector_map.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! name, ids and hash.
77
88
use {Atom, LocalName};
9-
use applicable_declarations::ApplicableDeclarationBlock;
9+
use applicable_declarations::ApplicableDeclarationList;
1010
use context::QuirksMode;
1111
use dom::TElement;
1212
use fallible::FallibleVec;
@@ -18,7 +18,7 @@ use rule_tree::CascadeLevel;
1818
use selector_parser::SelectorImpl;
1919
use selectors::matching::{matches_selector, MatchingContext, ElementSelectorFlags};
2020
use selectors::parser::{Component, Combinator, SelectorIter};
21-
use smallvec::{SmallVec, VecLike};
21+
use smallvec::SmallVec;
2222
use std::hash::{BuildHasherDefault, Hash, Hasher};
2323
use stylist::Rule;
2424

@@ -146,19 +146,18 @@ impl SelectorMap<Rule> {
146146
///
147147
/// Extract matching rules as per element's ID, classes, tag name, etc..
148148
/// Sort the Rules at the end to maintain cascading order.
149-
pub fn get_all_matching_rules<E, V, F>(
149+
pub fn get_all_matching_rules<E, F>(
150150
&self,
151151
element: &E,
152152
rule_hash_target: &E,
153-
matching_rules_list: &mut V,
153+
matching_rules_list: &mut ApplicableDeclarationList,
154154
context: &mut MatchingContext<E::Impl>,
155155
quirks_mode: QuirksMode,
156156
flags_setter: &mut F,
157157
cascade_level: CascadeLevel,
158158
)
159159
where
160160
E: TElement,
161-
V: VecLike<ApplicableDeclarationBlock>,
162161
F: FnMut(&E, ElementSelectorFlags),
163162
{
164163
if self.is_empty() {
@@ -210,17 +209,16 @@ impl SelectorMap<Rule> {
210209
}
211210

212211
/// Adds rules in `rules` that match `element` to the `matching_rules` list.
213-
fn get_matching_rules<E, V, F>(
212+
fn get_matching_rules<E, F>(
214213
element: &E,
215214
rules: &[Rule],
216-
matching_rules: &mut V,
215+
matching_rules: &mut ApplicableDeclarationList,
217216
context: &mut MatchingContext<E::Impl>,
218217
flags_setter: &mut F,
219218
cascade_level: CascadeLevel,
220219
)
221220
where
222221
E: TElement,
223-
V: VecLike<ApplicableDeclarationBlock>,
224222
F: FnMut(&E, ElementSelectorFlags),
225223
{
226224
for rule in rules {

servo/components/style/stylist.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,10 @@ use selectors::matching::{ElementSelectorFlags, matches_selector, MatchingContex
3232
use selectors::matching::VisitedHandlingMode;
3333
use selectors::parser::{AncestorHashes, Combinator, Component, Selector};
3434
use selectors::parser::{SelectorIter, SelectorMethods};
35-
use selectors::sink::Push;
3635
use selectors::visitor::SelectorVisitor;
3736
use servo_arc::{Arc, ArcBorrow};
3837
use shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
3938
use smallbitvec::SmallBitVec;
40-
use smallvec::VecLike;
41-
use std::fmt::Debug;
4239
use std::ops;
4340
use std::sync::Mutex;
4441
use style_traits::viewport::ViewportConstraints;
@@ -1205,21 +1202,20 @@ impl Stylist {
12051202
/// Returns the applicable CSS declarations for the given element.
12061203
///
12071204
/// This corresponds to `ElementRuleCollector` in WebKit.
1208-
pub fn push_applicable_declarations<E, V, F>(
1205+
pub fn push_applicable_declarations<E, F>(
12091206
&self,
12101207
element: &E,
12111208
pseudo_element: Option<&PseudoElement>,
12121209
style_attribute: Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>,
12131210
smil_override: Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>,
12141211
animation_rules: AnimationRules,
12151212
rule_inclusion: RuleInclusion,
1216-
applicable_declarations: &mut V,
1213+
applicable_declarations: &mut ApplicableDeclarationList,
12171214
context: &mut MatchingContext<E::Impl>,
12181215
flags_setter: &mut F,
12191216
)
12201217
where
12211218
E: TElement,
1222-
V: Push<ApplicableDeclarationBlock> + VecLike<ApplicableDeclarationBlock> + Debug,
12231219
F: FnMut(&E, ElementSelectorFlags),
12241220
{
12251221
// Gecko definitely has pseudo-elements with style attributes, like
@@ -1343,8 +1339,7 @@ impl Stylist {
13431339
if !only_default_rules {
13441340
// Step 4: Normal style attributes.
13451341
if let Some(sa) = style_attribute {
1346-
Push::push(
1347-
applicable_declarations,
1342+
applicable_declarations.push(
13481343
ApplicableDeclarationBlock::from_declarations(
13491344
sa.clone_arc(),
13501345
CascadeLevel::StyleAttributeNormal
@@ -1355,8 +1350,7 @@ impl Stylist {
13551350
// Step 5: SMIL override.
13561351
// Declarations from SVG SMIL animation elements.
13571352
if let Some(so) = smil_override {
1358-
Push::push(
1359-
applicable_declarations,
1353+
applicable_declarations.push(
13601354
ApplicableDeclarationBlock::from_declarations(
13611355
so.clone_arc(),
13621356
CascadeLevel::SMILOverride
@@ -1368,8 +1362,7 @@ impl Stylist {
13681362
// The animations sheet (CSS animations, script-generated animations,
13691363
// and CSS transitions that are no longer tied to CSS markup)
13701364
if let Some(anim) = animation_rules.0 {
1371-
Push::push(
1372-
applicable_declarations,
1365+
applicable_declarations.push(
13731366
ApplicableDeclarationBlock::from_declarations(
13741367
anim.clone(),
13751368
CascadeLevel::Animations
@@ -1389,8 +1382,7 @@ impl Stylist {
13891382
// Step 11: Transitions.
13901383
// The transitions sheet (CSS transitions that are tied to CSS markup)
13911384
if let Some(anim) = animation_rules.1 {
1392-
Push::push(
1393-
applicable_declarations,
1385+
applicable_declarations.push(
13941386
ApplicableDeclarationBlock::from_declarations(
13951387
anim.clone(),
13961388
CascadeLevel::Transitions

0 commit comments

Comments
 (0)