mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
Update selectors to 0.10, with ToCss serialization.
This commit is contained in:
parent
4e7c689a81
commit
d690bd2382
20 changed files with 186 additions and 62 deletions
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use attr::{AttrIdentifier, AttrValue};
|
||||
use cssparser::ToCss;
|
||||
use element_state::ElementState;
|
||||
use error_reporting::StdoutErrorReporter;
|
||||
use parser::ParserContextExtraData;
|
||||
|
@ -11,6 +12,7 @@ use selector_impl::{ElementExt, PseudoElementCascadeType, TheSelectorImpl};
|
|||
use selector_impl::{attr_exists_selector_is_shareable, attr_equals_selector_is_shareable};
|
||||
use selectors::parser::{AttrSelector, ParserContext, SelectorImpl};
|
||||
use selectors::{Element, MatchAttrGeneric};
|
||||
use std::fmt;
|
||||
use std::process;
|
||||
use string_cache::{Atom, Namespace};
|
||||
use stylesheets::{Stylesheet, Origin};
|
||||
|
@ -28,6 +30,20 @@ pub enum PseudoElement {
|
|||
DetailsContent,
|
||||
}
|
||||
|
||||
impl ToCss for PseudoElement {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
use self::PseudoElement::*;
|
||||
dest.write_str(match *self {
|
||||
Before => "::before",
|
||||
After => "::after",
|
||||
Selection => "::selection",
|
||||
DetailsSummary => "::-servo-details-summary",
|
||||
DetailsContent => "::-servo-details-content",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl PseudoElement {
|
||||
#[inline]
|
||||
pub fn is_before_or_after(&self) -> bool {
|
||||
|
@ -70,6 +86,29 @@ pub enum NonTSPseudoClass {
|
|||
Target,
|
||||
}
|
||||
|
||||
impl ToCss for NonTSPseudoClass {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
use self::NonTSPseudoClass::*;
|
||||
dest.write_str(match *self {
|
||||
AnyLink => ":any-link",
|
||||
Link => ":link",
|
||||
Visited => ":visited",
|
||||
Active => ":active",
|
||||
Focus => ":focus",
|
||||
Hover => ":hover",
|
||||
Enabled => ":enabled",
|
||||
Disabled => ":disabled",
|
||||
Checked => ":checked",
|
||||
Indeterminate => ":indeterminate",
|
||||
ReadWrite => ":read-write",
|
||||
ReadOnly => ":read-only",
|
||||
PlaceholderShown => ":placeholder-shown",
|
||||
Target => ":target",
|
||||
ServoNonZeroBorder => ":-servo-nonzero-border",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl NonTSPseudoClass {
|
||||
pub fn state_flag(&self) -> ElementState {
|
||||
use element_state::*;
|
||||
|
@ -106,9 +145,10 @@ impl SelectorImpl for ServoSelectorImpl {
|
|||
type Identifier = Atom;
|
||||
type ClassName = Atom;
|
||||
type LocalName = Atom;
|
||||
type Namespace = Namespace;
|
||||
type NamespacePrefix = String;
|
||||
type NamespaceUrl = Namespace;
|
||||
type BorrowedLocalName = Atom;
|
||||
type BorrowedNamespace = Namespace;
|
||||
type BorrowedNamespaceUrl = Namespace;
|
||||
|
||||
fn attr_exists_selector_is_shareable(attr_selector: &AttrSelector<Self>) -> bool {
|
||||
attr_exists_selector_is_shareable(attr_selector)
|
||||
|
@ -283,7 +323,7 @@ impl MatchAttrGeneric for ServoElementSnapshot {
|
|||
let html = self.is_html_element_in_html_document;
|
||||
let local_name = if html { &attr.lower_name } else { &attr.name };
|
||||
match attr.namespace {
|
||||
NamespaceConstraint::Specific(ref ns) => self.get_attr(ns, local_name),
|
||||
NamespaceConstraint::Specific(ref ns) => self.get_attr(&ns.url, local_name),
|
||||
NamespaceConstraint::Any => self.get_attr_ignore_ns(local_name),
|
||||
}.map_or(false, |v| test(v))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue