mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
parent
e6b05fa204
commit
10f3ef42bb
7 changed files with 73 additions and 27 deletions
|
@ -182,9 +182,9 @@ impl<'a, E> Element for ElementWrapper<'a, E>
|
|||
// FIXME(bz): How can I set this up so once Servo adds :dir()
|
||||
// support we don't forget to update this code?
|
||||
#[cfg(feature = "gecko")]
|
||||
NonTSPseudoClass::Dir(ref s) => {
|
||||
NonTSPseudoClass::Dir(ref dir) => {
|
||||
use invalidation::element::invalidation_map::dir_selector_to_state;
|
||||
let selector_flag = dir_selector_to_state(s);
|
||||
let selector_flag = dir_selector_to_state(dir);
|
||||
if selector_flag.is_empty() {
|
||||
// :dir() with some random argument; does not match.
|
||||
return false;
|
||||
|
|
|
@ -10,6 +10,8 @@ use element_state::ElementState;
|
|||
use fallible::FallibleVec;
|
||||
use hashglobe::FailedAllocationError;
|
||||
use selector_map::{MaybeCaseInsensitiveHashMap, SelectorMap, SelectorMapEntry};
|
||||
#[cfg(feature = "gecko")]
|
||||
use selector_parser::Direction;
|
||||
use selector_parser::SelectorImpl;
|
||||
use selectors::attr::NamespaceConstraint;
|
||||
use selectors::parser::{Combinator, Component};
|
||||
|
@ -19,21 +21,15 @@ use smallvec::SmallVec;
|
|||
|
||||
#[cfg(feature = "gecko")]
|
||||
/// Gets the element state relevant to the given `:dir` pseudo-class selector.
|
||||
pub fn dir_selector_to_state(s: &[u16]) -> ElementState {
|
||||
use element_state::ElementState;
|
||||
|
||||
// Jump through some hoops to deal with our Box<[u16]> thing.
|
||||
const LTR: [u16; 4] = [b'l' as u16, b't' as u16, b'r' as u16, 0];
|
||||
const RTL: [u16; 4] = [b'r' as u16, b't' as u16, b'l' as u16, 0];
|
||||
|
||||
if LTR == *s {
|
||||
ElementState::IN_LTR_STATE
|
||||
} else if RTL == *s {
|
||||
ElementState::IN_RTL_STATE
|
||||
} else {
|
||||
// :dir(something-random) is a valid selector, but shouldn't
|
||||
// match anything.
|
||||
ElementState::empty()
|
||||
pub fn dir_selector_to_state(dir: &Direction) -> ElementState {
|
||||
match *dir {
|
||||
Direction::Ltr => ElementState::IN_LTR_STATE,
|
||||
Direction::Rtl => ElementState::IN_RTL_STATE,
|
||||
Direction::Other(_) => {
|
||||
// :dir(something-random) is a valid selector, but shouldn't
|
||||
// match anything.
|
||||
ElementState::empty()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -342,8 +338,8 @@ impl SelectorVisitor for CompoundSelectorDependencyCollector {
|
|||
self.other_attributes |= pc.is_attr_based();
|
||||
self.state |= match *pc {
|
||||
#[cfg(feature = "gecko")]
|
||||
NonTSPseudoClass::Dir(ref s) => {
|
||||
dir_selector_to_state(s)
|
||||
NonTSPseudoClass::Dir(ref dir) => {
|
||||
dir_selector_to_state(dir)
|
||||
}
|
||||
_ => pc.state_flag(),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue