mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Use an Atom to represent Direction values in pseudo-classes.
Differential Revision: https://phabricator.services.mozilla.com/D4730
This commit is contained in:
parent
1e6aa62c6f
commit
4ee3b56d54
5 changed files with 54 additions and 58 deletions
|
@ -69,7 +69,7 @@ use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock};
|
|||
use properties::animated_properties::{AnimationValue, AnimationValueMap};
|
||||
use properties::style_structs::Font;
|
||||
use rule_tree::CascadeLevel as ServoCascadeLevel;
|
||||
use selector_parser::{AttrValue, Direction, PseudoClassStringArg};
|
||||
use selector_parser::{AttrValue, HorizontalDirection, PseudoClassStringArg};
|
||||
use selectors::{Element, OpaqueElement};
|
||||
use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator};
|
||||
use selectors::attr::{CaseSensitivity, NamespaceConstraint};
|
||||
|
@ -2237,24 +2237,22 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
NonTSPseudoClass::MozLocaleDir(ref dir) => {
|
||||
let state_bit = DocumentState::NS_DOCUMENT_STATE_RTL_LOCALE;
|
||||
if context.extra_data.document_state.intersects(state_bit) {
|
||||
// NOTE(emilio): We could still return false for
|
||||
// Direction::Other(..), but we don't bother.
|
||||
// NOTE(emilio): We could still return false for values
|
||||
// other than "ltr" and "rtl", but we don't bother.
|
||||
return !context.in_negation();
|
||||
}
|
||||
|
||||
let doc_is_rtl = self.document_state().contains(state_bit);
|
||||
|
||||
match **dir {
|
||||
Direction::Ltr => !doc_is_rtl,
|
||||
Direction::Rtl => doc_is_rtl,
|
||||
Direction::Other(..) => false,
|
||||
match dir.as_horizontal_direction() {
|
||||
Some(HorizontalDirection::Ltr) => !doc_is_rtl,
|
||||
Some(HorizontalDirection::Rtl) => doc_is_rtl,
|
||||
None => false,
|
||||
}
|
||||
},
|
||||
NonTSPseudoClass::Dir(ref dir) => match **dir {
|
||||
Direction::Ltr => self.state().intersects(ElementState::IN_LTR_STATE),
|
||||
Direction::Rtl => self.state().intersects(ElementState::IN_RTL_STATE),
|
||||
Direction::Other(..) => false,
|
||||
},
|
||||
NonTSPseudoClass::Dir(ref dir) => {
|
||||
self.state().intersects(dir.element_state())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue