mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +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
|
@ -2,10 +2,12 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::ToCss;
|
||||
use element_state::ElementState;
|
||||
use selector_impl::PseudoElementCascadeType;
|
||||
use selector_impl::{attr_exists_selector_is_shareable, attr_equals_selector_is_shareable};
|
||||
use selectors::parser::{ParserContext, SelectorImpl, AttrSelector};
|
||||
use std::fmt;
|
||||
use string_cache::{Atom, WeakAtom, Namespace, WeakNamespace};
|
||||
use stylesheets::Stylesheet;
|
||||
|
||||
|
@ -93,6 +95,16 @@ impl PseudoElement {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToCss for PseudoElement {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
// FIXME: why does the atom contain one colon? Pseudo-element has two
|
||||
debug_assert!(self.0.as_slice().starts_with(&[b':' as u16]) &&
|
||||
!self.0.as_slice().starts_with(&[b':' as u16, b':' as u16]));
|
||||
try!(dest.write_char(':'));
|
||||
write!(dest, "{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum NonTSPseudoClass {
|
||||
AnyLink,
|
||||
|
@ -109,6 +121,26 @@ pub enum NonTSPseudoClass {
|
|||
ReadOnly,
|
||||
}
|
||||
|
||||
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",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl NonTSPseudoClass {
|
||||
pub fn state_flag(&self) -> ElementState {
|
||||
use element_state::*;
|
||||
|
@ -135,8 +167,9 @@ impl SelectorImpl for GeckoSelectorImpl {
|
|||
type Identifier = Atom;
|
||||
type ClassName = Atom;
|
||||
type LocalName = Atom;
|
||||
type Namespace = Namespace;
|
||||
type BorrowedNamespace = WeakNamespace;
|
||||
type NamespacePrefix = String;
|
||||
type NamespaceUrl = Namespace;
|
||||
type BorrowedNamespaceUrl = WeakNamespace;
|
||||
type BorrowedLocalName = WeakAtom;
|
||||
|
||||
type PseudoElement = PseudoElement;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue