style: Record DocumentState dependencies.

This commit is contained in:
Cameron McCormack 2017-10-18 14:17:32 +08:00
parent c22dba0b87
commit d58c967efa
4 changed files with 39 additions and 3 deletions

View file

@ -5,7 +5,7 @@
//! Gecko-specific bits for selector-parsing.
use cssparser::{BasicParseError, BasicParseErrorKind, Parser, ToCss, Token, CowRcStr, SourceLocation};
use element_state::ElementState;
use element_state::{self, DocumentState, ElementState};
use gecko_bindings::structs::CSSPseudoClassType;
use gecko_bindings::structs::RawServoSelectorList;
use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
@ -195,6 +195,15 @@ impl NonTSPseudoClass {
apply_non_ts_list!(pseudo_class_state)
}
/// Get the document state flag associated with a pseudo-class, if any.
pub fn document_state_flag(&self) -> DocumentState {
match *self {
NonTSPseudoClass::MozLocaleDir(..) => element_state::NS_DOCUMENT_STATE_RTL_LOCALE,
NonTSPseudoClass::MozWindowInactive => element_state::NS_DOCUMENT_STATE_WINDOW_INACTIVE,
_ => DocumentState::empty(),
}
}
/// Returns true if the given pseudoclass should trigger style sharing cache
/// revalidation.
pub fn needs_cache_revalidation(&self) -> bool {