Skip to content

Commit

Permalink
style: Implement :defined pseudo-class for custom elements.
Browse files Browse the repository at this point in the history
Bug: 1331334
Reviewed-by: emilio
  • Loading branch information
Olli Pettay authored and emilio committed Jun 30, 2018
1 parent 06fa340 commit b68e4c2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/style/element_state.rs
Expand Up @@ -71,7 +71,8 @@ bitflags! {
const IN_OPTIONAL_STATE = 1 << 22;
/// <https://html.spec.whatwg.org/multipage/#selector-read-write>
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>
const IN_VISITED_STATE = 1 << 24;
/// <https://html.spec.whatwg.org/multipage/#selector-link>
Expand Down
1 change: 1 addition & 0 deletions components/style/gecko/non_ts_pseudo_class_list.rs
Expand Up @@ -47,6 +47,7 @@ macro_rules! apply_non_ts_list {
("visited", Visited, visited, IN_VISITED_STATE, _),
("active", Active, active, IN_ACTIVE_STATE, _),
("checked", Checked, checked, IN_CHECKED_STATE, _),
("defined", Defined, defined, IN_DEFINED_STATE, _),
("disabled", Disabled, disabled, IN_DISABLED_STATE, _),
("enabled", Enabled, enabled, IN_ENABLED_STATE, _),
("focus", Focus, focus, IN_FOCUS_STATE, _),
Expand Down
3 changes: 3 additions & 0 deletions components/style/gecko/selector_parser.rs
Expand Up @@ -187,6 +187,9 @@ impl NonTSPseudoClass {
NonTSPseudoClass::Fullscreen => unsafe {
mozilla::StaticPrefs_sVarCache_full_screen_api_unprefix_enabled
},
NonTSPseudoClass::Defined => unsafe {
structs::nsContentUtils_sIsCustomElementsEnabled
},
// Otherwise, a pseudo-class is enabled in content when it
// doesn't have any enabled flag.
_ => !self.has_any_flag(
Expand Down
1 change: 1 addition & 0 deletions components/style/gecko/wrapper.rs
Expand Up @@ -2124,6 +2124,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
{
use selectors::matching::*;
match *pseudo_class {
NonTSPseudoClass::Defined |
NonTSPseudoClass::Focus |
NonTSPseudoClass::Enabled |
NonTSPseudoClass::Disabled |
Expand Down

0 comments on commit b68e4c2

Please sign in to comment.