diff --git a/components/style/gecko/generated/structs_debug.rs b/components/style/gecko/generated/structs_debug.rs index 04581692a4c..beff8e966e4 100644 --- a/components/style/gecko/generated/structs_debug.rs +++ b/components/style/gecko/generated/structs_debug.rs @@ -9216,6 +9216,11 @@ pub mod root { "_ZN7mozilla10StylePrefs28sFramesTimingFunctionEnabledE"] pub static mut StylePrefs_sFramesTimingFunctionEnabled: bool; } + extern "C" { + #[link_name = + "_ZN7mozilla10StylePrefs31sUnprefixedFullscreenApiEnabledE"] + pub static mut StylePrefs_sUnprefixedFullscreenApiEnabled: bool; + } #[test] fn bindgen_test_layout_StylePrefs() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! diff --git a/components/style/gecko/generated/structs_release.rs b/components/style/gecko/generated/structs_release.rs index 0eaf91144ae..19b98dce992 100644 --- a/components/style/gecko/generated/structs_release.rs +++ b/components/style/gecko/generated/structs_release.rs @@ -9062,6 +9062,11 @@ pub mod root { "_ZN7mozilla10StylePrefs28sFramesTimingFunctionEnabledE"] pub static mut StylePrefs_sFramesTimingFunctionEnabled: bool; } + extern "C" { + #[link_name = + "_ZN7mozilla10StylePrefs31sUnprefixedFullscreenApiEnabledE"] + pub static mut StylePrefs_sUnprefixedFullscreenApiEnabled: bool; + } #[test] fn bindgen_test_layout_StylePrefs() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! diff --git a/components/style/gecko/non_ts_pseudo_class_list.rs b/components/style/gecko/non_ts_pseudo_class_list.rs index 9b30e4a5ee2..17dce94c989 100644 --- a/components/style/gecko/non_ts_pseudo_class_list.rs +++ b/components/style/gecko/non_ts_pseudo_class_list.rs @@ -61,9 +61,7 @@ macro_rules! apply_non_ts_list { ("indeterminate", Indeterminate, indeterminate, IN_INDETERMINATE_STATE, _), ("-moz-devtools-highlighted", MozDevtoolsHighlighted, mozDevtoolsHighlighted, IN_DEVTOOLS_HIGHLIGHTED_STATE, _), ("-moz-styleeditor-transitioning", MozStyleeditorTransitioning, mozStyleeditorTransitioning, IN_STYLEEDITOR_TRANSITIONING_STATE, _), - // TODO(emilio): Needs pref check for full-screen-api.unprefix.enabled! - // TODO(TYLin): Needs to use CSS_PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME? - ("fullscreen", Fullscreen, fullscreen, IN_FULLSCREEN_STATE, _), + ("fullscreen", Fullscreen, fullscreen, IN_FULLSCREEN_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME), ("-moz-full-screen", MozFullScreen, mozFullScreen, IN_FULLSCREEN_STATE, _), // TODO(emilio): This is inconsistently named (the capital R). ("-moz-focusring", MozFocusRing, mozFocusRing, IN_FOCUSRING_STATE, _), diff --git a/components/style/gecko/selector_parser.rs b/components/style/gecko/selector_parser.rs index 8327ae5c05c..b5ec344b0f2 100644 --- a/components/style/gecko/selector_parser.rs +++ b/components/style/gecko/selector_parser.rs @@ -125,12 +125,11 @@ impl SelectorMethods for NonTSPseudoClass { impl NonTSPseudoClass { - /// Returns true if this pseudo-class is enabled under the context of - /// the given flag. - fn is_enabled_in(&self, flag: NonTSPseudoClassFlag) -> bool { + /// Returns true if this pseudo-class has any of the given flags set. + fn has_any_flag(&self, flags: NonTSPseudoClassFlag) -> bool { macro_rules! check_flag { (_) => (false); - ($flags:expr) => ($flags.contains(flag)); + ($flags:expr) => ($flags.intersects(flags)); } macro_rules! pseudo_class_check_is_enabled_in { (bare: [$(($css:expr, $name:ident, $gecko_type:tt, $state:tt, $flags:tt),)*], @@ -147,6 +146,20 @@ impl NonTSPseudoClass { apply_non_ts_list!(pseudo_class_check_is_enabled_in) } + /// Returns whether the pseudo-class is enabled in content sheets. + fn is_enabled_in_content(&self) -> bool { + use gecko_bindings::structs::mozilla; + match self { + // For pseudo-classes with pref, the availability in content + // depends on the pref. + &NonTSPseudoClass::Fullscreen => + unsafe { mozilla::StylePrefs_sUnprefixedFullscreenApiEnabled }, + // Otherwise, a pseudo-class is enabled in content when it + // doesn't have any enabled flag. + _ => !self.has_any_flag(PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME), + } + } + /// https://drafts.csswg.org/selectors-4/#useraction-pseudos /// /// We intentionally skip the link-related ones. @@ -270,14 +283,11 @@ impl<'a> SelectorParser<'a> { fn is_pseudo_class_enabled(&self, pseudo_class: &NonTSPseudoClass) -> bool { - let enabled_in_ua = pseudo_class.is_enabled_in(PSEUDO_CLASS_ENABLED_IN_UA_SHEETS); - let enabled_in_chrome = pseudo_class.is_enabled_in(PSEUDO_CLASS_ENABLED_IN_CHROME); - if !enabled_in_ua && !enabled_in_chrome { - true - } else { - (enabled_in_ua && self.in_user_agent_stylesheet()) || - (enabled_in_chrome && self.in_chrome_stylesheet()) - } + pseudo_class.is_enabled_in_content() || + (self.in_user_agent_stylesheet() && + pseudo_class.has_any_flag(PSEUDO_CLASS_ENABLED_IN_UA_SHEETS)) || + (self.in_chrome_stylesheet() && + pseudo_class.has_any_flag(PSEUDO_CLASS_ENABLED_IN_CHROME)) } }