style: Implement :defined pseudo-class for custom elements.

Bug: 1331334
Reviewed-by: emilio
This commit is contained in:
Olli Pettay 2018-06-28 14:55:45 +03:00 committed by Emilio Cobos Álvarez
parent 06fa3406de
commit b68e4c2352
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 7 additions and 1 deletions

View file

@ -71,7 +71,8 @@ bitflags! {
const IN_OPTIONAL_STATE = 1 << 22; const IN_OPTIONAL_STATE = 1 << 22;
/// <https://html.spec.whatwg.org/multipage/#selector-read-write> /// <https://html.spec.whatwg.org/multipage/#selector-read-write>
const IN_READ_WRITE_STATE = 1 << 22; const IN_READ_WRITE_STATE = 1 << 22;
/// There is a free bit at 23. /// <https://html.spec.whatwg.org/multipage/semantics-other.html#selector-defined>
const IN_DEFINED_STATE = 1 << 23;
/// <https://html.spec.whatwg.org/multipage/#selector-visited> /// <https://html.spec.whatwg.org/multipage/#selector-visited>
const IN_VISITED_STATE = 1 << 24; const IN_VISITED_STATE = 1 << 24;
/// <https://html.spec.whatwg.org/multipage/#selector-link> /// <https://html.spec.whatwg.org/multipage/#selector-link>

View file

@ -47,6 +47,7 @@ macro_rules! apply_non_ts_list {
("visited", Visited, visited, IN_VISITED_STATE, _), ("visited", Visited, visited, IN_VISITED_STATE, _),
("active", Active, active, IN_ACTIVE_STATE, _), ("active", Active, active, IN_ACTIVE_STATE, _),
("checked", Checked, checked, IN_CHECKED_STATE, _), ("checked", Checked, checked, IN_CHECKED_STATE, _),
("defined", Defined, defined, IN_DEFINED_STATE, _),
("disabled", Disabled, disabled, IN_DISABLED_STATE, _), ("disabled", Disabled, disabled, IN_DISABLED_STATE, _),
("enabled", Enabled, enabled, IN_ENABLED_STATE, _), ("enabled", Enabled, enabled, IN_ENABLED_STATE, _),
("focus", Focus, focus, IN_FOCUS_STATE, _), ("focus", Focus, focus, IN_FOCUS_STATE, _),

View file

@ -187,6 +187,9 @@ impl NonTSPseudoClass {
NonTSPseudoClass::Fullscreen => unsafe { NonTSPseudoClass::Fullscreen => unsafe {
mozilla::StaticPrefs_sVarCache_full_screen_api_unprefix_enabled mozilla::StaticPrefs_sVarCache_full_screen_api_unprefix_enabled
}, },
NonTSPseudoClass::Defined => unsafe {
structs::nsContentUtils_sIsCustomElementsEnabled
},
// Otherwise, a pseudo-class is enabled in content when it // Otherwise, a pseudo-class is enabled in content when it
// doesn't have any enabled flag. // doesn't have any enabled flag.
_ => !self.has_any_flag( _ => !self.has_any_flag(

View file

@ -2124,6 +2124,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
{ {
use selectors::matching::*; use selectors::matching::*;
match *pseudo_class { match *pseudo_class {
NonTSPseudoClass::Defined |
NonTSPseudoClass::Focus | NonTSPseudoClass::Focus |
NonTSPseudoClass::Enabled | NonTSPseudoClass::Enabled |
NonTSPseudoClass::Disabled | NonTSPseudoClass::Disabled |