Skip to content

Commit

Permalink
Bug 1367312 - stylo: Implement :-moz-lwtheme* pseudo-classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrubeck committed Jun 28, 2017
1 parent 522d24d commit e0b864d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions components/style/gecko/generated/bindings.rs
Expand Up @@ -11,6 +11,8 @@ use gecko_bindings::structs::mozilla::css::URLValue;
use gecko_bindings::structs::mozilla::MallocSizeOf;
use gecko_bindings::structs::mozilla::Side;
use gecko_bindings::structs::nsIContent;
use gecko_bindings::structs::nsIDocument;
use gecko_bindings::structs::nsIDocument_DocumentTheme;
use gecko_bindings::structs::RawGeckoAnimationPropertySegment;
use gecko_bindings::structs::RawGeckoComputedTiming;
use gecko_bindings::structs::RawGeckoCSSPropertyIDList;
Expand Down Expand Up @@ -583,6 +585,10 @@ extern "C" {
pub fn Gecko_GetXMLLangValue(element: RawGeckoElementBorrowed)
-> *mut nsIAtom;
}
extern "C" {
pub fn Gecko_GetDocumentLWTheme(aDocument: *const nsIDocument)
-> nsIDocument_DocumentTheme;
}
extern "C" {
pub fn Gecko_AtomAttrValue(element: RawGeckoElementBorrowed,
attribute: *mut nsIAtom) -> *mut nsIAtom;
Expand Down
4 changes: 3 additions & 1 deletion components/style/gecko/non_ts_pseudo_class_list.rs
Expand Up @@ -26,7 +26,6 @@
*
* Pending pseudo-classes:
*
* :-moz-lwtheme, :-moz-lwtheme-brighttext, :-moz-lwtheme-darktext,
* :-moz-window-inactive.
*
* :scope -> <style scoped>, pending discussion.
Expand Down Expand Up @@ -114,6 +113,9 @@ macro_rules! apply_non_ts_list {
("-moz-use-shadow-tree-root", MozUseShadowTreeRoot, mozUseShadowTreeRoot, _, PSEUDO_CLASS_INTERNAL),
("-moz-is-html", MozIsHTML, mozIsHTML, _, _),
("-moz-placeholder", MozPlaceholder, mozPlaceholder, _, _),
("-moz-lwtheme", MozLWTheme, mozLWTheme, _, _),
("-moz-lwtheme-brighttext", MozLWThemeBrightText, mozLWThemeBrightText, _, _),
("-moz-lwtheme-darktext", MozLWThemeDarkText, mozLWThemeDarkText, _, _),
],
string: [
("-moz-system-metric", MozSystemMetric, mozSystemMetric, _, PSEUDO_CLASS_INTERNAL),
Expand Down
19 changes: 18 additions & 1 deletion components/style/gecko/wrapper.rs
Expand Up @@ -31,7 +31,8 @@ use gecko::selector_parser::{SelectorImpl, NonTSPseudoClass, PseudoElement};
use gecko::snapshot_helpers;
use gecko_bindings::bindings;
use gecko_bindings::bindings::{Gecko_DropStyleChildrenIterator, Gecko_MaybeCreateStyleChildrenIterator};
use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetLastChild, Gecko_GetNextStyleChild};
use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentLWTheme};
use gecko_bindings::bindings::{Gecko_GetLastChild, Gecko_GetNextStyleChild};
use gecko_bindings::bindings::{Gecko_IsRootElement, Gecko_MatchesElement, Gecko_Namespace};
use gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags};
use gecko_bindings::bindings::Gecko_ClassOrClassList;
Expand Down Expand Up @@ -62,6 +63,7 @@ use gecko_bindings::structs::ELEMENT_HAS_SNAPSHOT;
use gecko_bindings::structs::EffectCompositor_CascadeLevel as CascadeLevel;
use gecko_bindings::structs::NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE;
use gecko_bindings::structs::NODE_IS_NATIVE_ANONYMOUS;
use gecko_bindings::structs::nsIDocument_DocumentTheme as DocumentTheme;
use gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI};
use logical_geometry::WritingMode;
use media_queries::Device;
Expand Down Expand Up @@ -586,6 +588,12 @@ impl<'le> GeckoElement<'le> {
fn may_have_style_attribute(&self) -> bool {
self.as_node().get_bool_flag(nsINode_BooleanFlag::ElementMayHaveStyle)
}

#[inline]
fn get_document_theme(&self) -> DocumentTheme {
let node = self.as_node();
unsafe { Gecko_GetDocumentLWTheme(node.owner_doc()) }
}
}

/// Converts flags from the layout used by rust-selectors to the layout used
Expand Down Expand Up @@ -1659,6 +1667,15 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
NonTSPseudoClass::MozIsHTML => {
self.is_html_element_in_html_document()
}
NonTSPseudoClass::MozLWTheme => {
self.get_document_theme() != DocumentTheme::Doc_Theme_None
}
NonTSPseudoClass::MozLWThemeBrightText => {
self.get_document_theme() == DocumentTheme::Doc_Theme_Bright
}
NonTSPseudoClass::MozLWThemeDarkText => {
self.get_document_theme() == DocumentTheme::Doc_Theme_Dark
}
NonTSPseudoClass::MozPlaceholder => false,
NonTSPseudoClass::MozAny(ref sels) => {
let old_value = context.hover_active_quirk_disabled;
Expand Down

0 comments on commit e0b864d

Please sign in to comment.