mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30: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)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct SelectorImpl;
|
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 {
|
impl ::selectors::SelectorImpl for SelectorImpl {
|
||||||
type ExtraMatchingData = ();
|
type ExtraMatchingData = InvalidationMatchingData;
|
||||||
type AttrValue = Atom;
|
type AttrValue = Atom;
|
||||||
type Identifier = Atom;
|
type Identifier = Atom;
|
||||||
type ClassName = Atom;
|
type ClassName = Atom;
|
||||||
|
|
|
@ -2110,8 +2110,14 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
self.get_document_theme() == DocumentTheme::Doc_Theme_Dark
|
self.get_document_theme() == DocumentTheme::Doc_Theme_Dark
|
||||||
}
|
}
|
||||||
NonTSPseudoClass::MozWindowInactive => {
|
NonTSPseudoClass::MozWindowInactive => {
|
||||||
self.document_state()
|
let state_bit = DocumentState::NS_DOCUMENT_STATE_WINDOW_INACTIVE;
|
||||||
.contains(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::MozPlaceholder => false,
|
||||||
NonTSPseudoClass::MozAny(ref sels) => {
|
NonTSPseudoClass::MozAny(ref sels) => {
|
||||||
|
@ -2126,9 +2132,16 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
self.match_element_lang(None, lang_arg)
|
self.match_element_lang(None, lang_arg)
|
||||||
}
|
}
|
||||||
NonTSPseudoClass::MozLocaleDir(ref dir) => {
|
NonTSPseudoClass::MozLocaleDir(ref dir) => {
|
||||||
let doc_is_rtl =
|
let state_bit = DocumentState::NS_DOCUMENT_STATE_RTL_LOCALE;
|
||||||
self.document_state()
|
if let Some(ref invalidation_data) = context.extra_data {
|
||||||
.contains(DocumentState::NS_DOCUMENT_STATE_RTL_LOCALE);
|
// 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 {
|
match **dir {
|
||||||
Direction::Ltr => !doc_is_rtl,
|
Direction::Ltr => !doc_is_rtl,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue