mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Stop special-casing a few attributes for style sharing, and use a visitor to track dependencies.
Also, simplify all the pre-snapshot attribute hacks in the script and style code. MozReview-Commit-ID: 6c9ipeb7Tnr Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
1748150497
commit
0ea58d1ffa
9 changed files with 161 additions and 312 deletions
|
@ -10,11 +10,12 @@ use gecko_bindings::structs::CSSPseudoClassType;
|
|||
use gecko_bindings::structs::nsIAtom;
|
||||
use restyle_hints::complex_selector_to_state;
|
||||
use selector_parser::{SelectorParser, PseudoElementCascadeType};
|
||||
use selector_parser::{attr_equals_selector_is_shareable, attr_exists_selector_is_shareable};
|
||||
use selectors::parser::{AttrSelector, ComplexSelector, SelectorMethods};
|
||||
use selectors::parser::{ComplexSelector, SelectorMethods};
|
||||
use selectors::visitor::SelectorVisitor;
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
use std::ptr;
|
||||
use std::sync::Arc;
|
||||
use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
|
||||
|
||||
/// A representation of a CSS pseudo-element.
|
||||
|
@ -218,7 +219,7 @@ macro_rules! pseudo_class_name {
|
|||
///
|
||||
/// TODO(emilio): We disallow combinators and pseudos here, so we
|
||||
/// should use SimpleSelector instead
|
||||
MozAny(Vec<ComplexSelector<SelectorImpl>>),
|
||||
MozAny(Vec<Arc<ComplexSelector<SelectorImpl>>>),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -261,24 +262,20 @@ impl ToCss for NonTSPseudoClass {
|
|||
}
|
||||
|
||||
impl SelectorMethods for NonTSPseudoClass {
|
||||
#[inline]
|
||||
fn affects_siblings(&self) -> bool {
|
||||
match *self {
|
||||
NonTSPseudoClass::MozAny(ref selectors) => {
|
||||
selectors.iter().any(|s| s.affects_siblings())
|
||||
}
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
type Impl = SelectorImpl;
|
||||
|
||||
#[inline]
|
||||
fn matches_non_common_style_affecting_attribute(&self) -> bool {
|
||||
match *self {
|
||||
NonTSPseudoClass::MozAny(ref selectors) => {
|
||||
selectors.iter().any(|s| s.matches_non_common_style_affecting_attribute())
|
||||
fn visit<V>(&self, visitor: &mut V) -> bool
|
||||
where V: SelectorVisitor<Impl = Self::Impl>,
|
||||
{
|
||||
if let NonTSPseudoClass::MozAny(ref selectors) = *self {
|
||||
for selector in selectors {
|
||||
if !selector.visit(visitor) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_ => false
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,15 +361,6 @@ impl ::selectors::SelectorImpl for SelectorImpl {
|
|||
|
||||
type PseudoElement = PseudoElement;
|
||||
type NonTSPseudoClass = NonTSPseudoClass;
|
||||
|
||||
fn attr_exists_selector_is_shareable(attr_selector: &AttrSelector<Self>) -> bool {
|
||||
attr_exists_selector_is_shareable(attr_selector)
|
||||
}
|
||||
|
||||
fn attr_equals_selector_is_shareable(attr_selector: &AttrSelector<Self>,
|
||||
value: &Self::AttrValue) -> bool {
|
||||
attr_equals_selector_is_shareable(attr_selector, value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ::selectors::Parser for SelectorParser<'a> {
|
||||
|
@ -413,7 +401,7 @@ impl<'a> ::selectors::Parser for SelectorParser<'a> {
|
|||
}, )*
|
||||
"-moz-any" => {
|
||||
let selectors = parser.parse_comma_separated(|input| {
|
||||
ComplexSelector::parse(self, input)
|
||||
ComplexSelector::parse(self, input).map(Arc::new)
|
||||
})?;
|
||||
// Selectors inside `:-moz-any` may not include combinators.
|
||||
if selectors.iter().any(|s| s.next.is_some()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue