mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Update to selectors 0.15
This commit is contained in:
parent
a89ba50180
commit
82b13d50e3
21 changed files with 215 additions and 146 deletions
|
@ -4,11 +4,17 @@
|
|||
|
||||
//! The pseudo-classes and pseudo-elements supported by the style system.
|
||||
|
||||
use cssparser::Parser as CssParser;
|
||||
use matching::{common_style_affecting_attributes, CommonStyleAffectingAttributeMode};
|
||||
use selectors::Element;
|
||||
use selectors::parser::{AttrSelector, SelectorImpl};
|
||||
use selectors::parser::{AttrSelector, SelectorList};
|
||||
use stylesheets::{Origin, Namespaces};
|
||||
|
||||
pub type AttrValue = <TheSelectorImpl as SelectorImpl>::AttrValue;
|
||||
pub type AttrValue = <TheSelectorImpl as ::selectors::SelectorImpl>::AttrValue;
|
||||
|
||||
// FIXME remove
|
||||
pub use self::SelectorImpl as TheSelectorImpl;
|
||||
pub use self::SelectorImpl as ServoSelectorImpl;
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
pub use servo::selector_parser::*;
|
||||
|
@ -16,12 +22,6 @@ pub use servo::selector_parser::*;
|
|||
#[cfg(feature = "gecko")]
|
||||
pub use gecko::selector_parser::*;
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
pub use servo::selector_parser::ServoSelectorImpl as TheSelectorImpl;
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use gecko::selector_parser::GeckoSelectorImpl as TheSelectorImpl;
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
pub use servo::selector_parser::ServoElementSnapshot as Snapshot;
|
||||
|
||||
|
@ -34,6 +34,28 @@ pub use servo::restyle_damage::ServoRestyleDamage as RestyleDamage;
|
|||
#[cfg(feature = "gecko")]
|
||||
pub use gecko::restyle_damage::GeckoRestyleDamage as RestyleDamage;
|
||||
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SelectorParser<'a> {
|
||||
pub stylesheet_origin: Origin,
|
||||
pub namespaces: &'a Namespaces,
|
||||
}
|
||||
|
||||
impl<'a> SelectorParser<'a> {
|
||||
pub fn parse_author_origin_no_namespace(input: &str)
|
||||
-> Result<SelectorList<SelectorImpl>, ()> {
|
||||
let namespaces = Namespaces::default();
|
||||
let parser = SelectorParser {
|
||||
stylesheet_origin: Origin::Author,
|
||||
namespaces: &namespaces,
|
||||
};
|
||||
SelectorList::parse(&parser, &mut CssParser::new(input))
|
||||
}
|
||||
|
||||
pub fn in_user_agent_stylesheet(&self) -> bool {
|
||||
matches!(self.stylesheet_origin, Origin::UserAgent)
|
||||
}
|
||||
}
|
||||
|
||||
/// This function determines if a pseudo-element is eagerly cascaded or not.
|
||||
///
|
||||
/// Eagerly cascaded pseudo-elements are "normal" pseudo-elements (i.e.
|
||||
|
@ -85,7 +107,7 @@ pub trait ElementExt: Element<Impl=TheSelectorImpl> {
|
|||
fn is_link(&self) -> bool;
|
||||
}
|
||||
|
||||
impl TheSelectorImpl {
|
||||
impl SelectorImpl {
|
||||
#[inline]
|
||||
pub fn each_eagerly_cascaded_pseudo_element<F>(mut fun: F)
|
||||
where F: FnMut(PseudoElement)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue