Skip to content

Commit

Permalink
Auto merge of #17577 - mbrubeck:inactive, r=emilio
Browse files Browse the repository at this point in the history
Bug 1348489 - stylo: Implement :-moz-window-inactive.

https://bugzilla.mozilla.org/show_bug.cgi?id=1348489

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17577)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Jun 30, 2017
2 parents ff19e69 + 17f4d0c commit a24600d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
13 changes: 13 additions & 0 deletions components/style/element_state.rs
Expand Up @@ -138,3 +138,16 @@ bitflags! {
const IN_AUTOFILL_PREVIEW_STATE = 1 << 51,
}
}

bitflags! {
/// Event-based document states.
///
/// NB: Is important for this to remain in sync with Gecko's
/// dom/base/nsIDocument.h.
pub flags DocumentState: u64 {
/// RTL locale: specific to the XUL localedir attribute
const NS_DOCUMENT_STATE_RTL_LOCALE = 1 << 0,
/// Window activation status
const NS_DOCUMENT_STATE_WINDOW_INACTIVE = 1 << 1,
}
}
3 changes: 3 additions & 0 deletions components/style/gecko/generated/bindings.rs
Expand Up @@ -552,6 +552,9 @@ extern "C" {
extern "C" {
pub fn Gecko_ElementState(element: RawGeckoElementBorrowed) -> u64;
}
extern "C" {
pub fn Gecko_DocumentState(aDocument: *const nsIDocument) -> u64;
}
extern "C" {
pub fn Gecko_IsTextNode(node: RawGeckoNodeBorrowed) -> bool;
}
Expand Down
3 changes: 1 addition & 2 deletions components/style/gecko/non_ts_pseudo_class_list.rs
Expand Up @@ -26,8 +26,6 @@
*
* Pending pseudo-classes:
*
* :-moz-window-inactive.
*
* :scope -> <style scoped>, pending discussion.
*
* This follows the order defined in layout/style/nsCSSPseudoClassList.h when
Expand Down Expand Up @@ -117,6 +115,7 @@ macro_rules! apply_non_ts_list {
("-moz-lwtheme", MozLWTheme, mozLWTheme, _, _),
("-moz-lwtheme-brighttext", MozLWThemeBrightText, mozLWThemeBrightText, _, _),
("-moz-lwtheme-darktext", MozLWThemeDarkText, mozLWThemeDarkText, _, _),
("-moz-window-inactive", MozWindowInactive, mozWindowInactive, _, _),
],
string: [
("-moz-system-metric", MozSystemMetric, mozSystemMetric, _, PSEUDO_CLASS_INTERNAL),
Expand Down
15 changes: 13 additions & 2 deletions components/style/gecko/wrapper.rs
Expand Up @@ -22,7 +22,7 @@ use context::{QuirksMode, SharedStyleContext, UpdateAnimationsTasks};
use data::ElementData;
use dom::{self, DescendantsBit, LayoutIterator, NodeInfo, TElement, TNode, UnsafeNode};
use dom::{OpaqueNode, PresentationalHintsSynthesizer};
use element_state::ElementState;
use element_state::{ElementState, DocumentState, NS_DOCUMENT_STATE_WINDOW_INACTIVE};
use error_reporting::create_error_reporter;
use font_metrics::{FontMetrics, FontMetricsProvider, FontMetricsQueryResult};
use gecko::data::PerDocumentStyleData;
Expand All @@ -31,7 +31,7 @@ use gecko::selector_parser::{SelectorImpl, NonTSPseudoClass, PseudoElement};
use gecko::snapshot_helpers;
use gecko_bindings::bindings;
use gecko_bindings::bindings::{Gecko_ConstructStyleChildrenIterator, Gecko_DestroyStyleChildrenIterator};
use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentLWTheme};
use gecko_bindings::bindings::{Gecko_DocumentState, 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};
Expand Down Expand Up @@ -652,6 +652,14 @@ impl<'le> GeckoElement<'le> {
unsafe { Gecko_ElementState(self.0) }
}

fn document_state(&self) -> DocumentState {
let node = self.as_node();
unsafe {
let states = Gecko_DocumentState(node.owner_doc());
DocumentState::from_bits_truncate(states)
}
}

#[inline]
fn may_have_class(&self) -> bool {
self.as_node().get_bool_flag(nsINode_BooleanFlag::ElementMayHaveClass)
Expand Down Expand Up @@ -1759,6 +1767,9 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
NonTSPseudoClass::MozLWThemeDarkText => {
self.get_document_theme() == DocumentTheme::Doc_Theme_Dark
}
NonTSPseudoClass::MozWindowInactive => {
self.document_state().contains(NS_DOCUMENT_STATE_WINDOW_INACTIVE)
}
NonTSPseudoClass::MozPlaceholder => false,
NonTSPseudoClass::MozAny(ref sels) => {
let old_value = context.hover_active_quirk_disabled;
Expand Down

0 comments on commit a24600d

Please sign in to comment.