mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
style: Simplify selector flags setup even more
In my investigation for bug 1766439, I am digging into why selector matching regressed. It doesn't help that the selector-matching code is instantiated a gazillion times (so there's a ton of copies of the relevant functions). This was needed in the past because we had different ways of setting the selector flags on elements, but I unified that recently and now we only need to either set them or not. That is the kind of thing that MatchingContext is really good for, so pass that instead on MatchingContext creation. Differential Revision: https://phabricator.services.mozilla.com/D145428
This commit is contained in:
parent
db53845694
commit
4878422c93
14 changed files with 176 additions and 211 deletions
|
@ -13,7 +13,7 @@ use crate::selector_parser::PseudoElement;
|
|||
use crate::shared_lock::Locked;
|
||||
use crate::stylesheets::{layer_rule::LayerOrder, Origin};
|
||||
use crate::stylist::{AuthorStylesEnabled, CascadeData, Rule, RuleInclusion, Stylist};
|
||||
use selectors::matching::{ElementSelectorFlags, MatchingContext, MatchingMode};
|
||||
use selectors::matching::{MatchingContext, MatchingMode};
|
||||
use servo_arc::ArcBorrow;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
|
@ -59,7 +59,7 @@ pub fn containing_shadow_ignoring_svg_use<E: TElement>(
|
|||
///
|
||||
/// This is done basically to be able to organize the cascade in smaller
|
||||
/// functions, and be able to reason about it easily.
|
||||
pub struct RuleCollector<'a, 'b: 'a, E, F: 'a>
|
||||
pub struct RuleCollector<'a, 'b: 'a, E>
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
|
@ -73,16 +73,14 @@ where
|
|||
rule_inclusion: RuleInclusion,
|
||||
rules: &'a mut ApplicableDeclarationList,
|
||||
context: &'a mut MatchingContext<'b, E::Impl>,
|
||||
flags_setter: &'a mut F,
|
||||
matches_user_and_author_rules: bool,
|
||||
matches_document_author_rules: bool,
|
||||
in_sort_scope: bool,
|
||||
}
|
||||
|
||||
impl<'a, 'b: 'a, E, F: 'a> RuleCollector<'a, 'b, E, F>
|
||||
impl<'a, 'b: 'a, E> RuleCollector<'a, 'b, E>
|
||||
where
|
||||
E: TElement,
|
||||
F: FnMut(&E, ElementSelectorFlags),
|
||||
{
|
||||
/// Trivially construct a new collector.
|
||||
pub fn new(
|
||||
|
@ -95,7 +93,6 @@ where
|
|||
rule_inclusion: RuleInclusion,
|
||||
rules: &'a mut ApplicableDeclarationList,
|
||||
context: &'a mut MatchingContext<'b, E::Impl>,
|
||||
flags_setter: &'a mut F,
|
||||
) -> Self {
|
||||
// When we're matching with matching_mode =
|
||||
// `ForStatelessPseudoeElement`, the "target" for the rule hash is the
|
||||
|
@ -125,7 +122,6 @@ where
|
|||
animation_declarations,
|
||||
rule_inclusion,
|
||||
context,
|
||||
flags_setter,
|
||||
rules,
|
||||
matches_user_and_author_rules,
|
||||
matches_document_author_rules: matches_user_and_author_rules,
|
||||
|
@ -227,7 +223,6 @@ where
|
|||
part_rules,
|
||||
&mut self.rules,
|
||||
&mut self.context,
|
||||
&mut self.flags_setter,
|
||||
cascade_level,
|
||||
cascade_data,
|
||||
);
|
||||
|
@ -246,7 +241,6 @@ where
|
|||
self.rule_hash_target,
|
||||
&mut self.rules,
|
||||
&mut self.context,
|
||||
&mut self.flags_setter,
|
||||
cascade_level,
|
||||
cascade_data,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue