mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Auto merge of #12924 - servo:selectors-ser, r=nox
Update selectors to 0.10, with ToCss serialization. <!-- Please describe your changes on the following line: --> r? @emilio --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12924) <!-- Reviewable:end -->
This commit is contained in:
commit
07b217368f
22 changed files with 203 additions and 69 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 = Atom;
|
||||
type NamespaceUrl = Namespace;
|
||||
type BorrowedNamespaceUrl = WeakNamespace;
|
||||
type BorrowedLocalName = WeakAtom;
|
||||
|
||||
type PseudoElement = PseudoElement;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue