mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Allow storing a DocumentState for invalidation.
This commit is contained in:
parent
1e27f2883b
commit
cb1a951477
2 changed files with 26 additions and 6 deletions
|
@ -277,8 +277,15 @@ impl NonTSPseudoClass {
|
|||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct SelectorImpl;
|
||||
|
||||
/// A struct holding the members necessary to invalidate document state
|
||||
/// selectors.
|
||||
pub struct InvalidationMatchingData {
|
||||
/// The document state that has changed, which makes it always match.
|
||||
pub document_state: DocumentState,
|
||||
}
|
||||
|
||||
impl ::selectors::SelectorImpl for SelectorImpl {
|
||||
type ExtraMatchingData = ();
|
||||
type ExtraMatchingData = InvalidationMatchingData;
|
||||
type AttrValue = Atom;
|
||||
type Identifier = Atom;
|
||||
type ClassName = Atom;
|
||||
|
|
|
@ -2110,8 +2110,14 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
self.get_document_theme() == DocumentTheme::Doc_Theme_Dark
|
||||
}
|
||||
NonTSPseudoClass::MozWindowInactive => {
|
||||
self.document_state()
|
||||
.contains(DocumentState::NS_DOCUMENT_STATE_WINDOW_INACTIVE)
|
||||
let state_bit = DocumentState::NS_DOCUMENT_STATE_WINDOW_INACTIVE;
|
||||
if let Some(ref invalidation_data) = context.extra_data {
|
||||
if invalidation_data.document_state.intersects(state_bit) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
self.document_state().contains(state_bit)
|
||||
}
|
||||
NonTSPseudoClass::MozPlaceholder => false,
|
||||
NonTSPseudoClass::MozAny(ref sels) => {
|
||||
|
@ -2126,9 +2132,16 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
self.match_element_lang(None, lang_arg)
|
||||
}
|
||||
NonTSPseudoClass::MozLocaleDir(ref dir) => {
|
||||
let doc_is_rtl =
|
||||
self.document_state()
|
||||
.contains(DocumentState::NS_DOCUMENT_STATE_RTL_LOCALE);
|
||||
let state_bit = DocumentState::NS_DOCUMENT_STATE_RTL_LOCALE;
|
||||
if let Some(ref invalidation_data) = context.extra_data {
|
||||
// NOTE(emilio): We could still return false for
|
||||
// Direction::Other(..), but we don't bother.
|
||||
if invalidation_data.document_state.intersects(state_bit) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
let doc_is_rtl = self.document_state().contains(state_bit);
|
||||
|
||||
match **dir {
|
||||
Direction::Ltr => !doc_is_rtl,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue