Skip to content

Commit

Permalink
Implement :required/:optional support for stylo.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky committed Mar 23, 2017
1 parent e0f1855 commit 5a5a6cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion components/style/element_state.rs
Expand Up @@ -57,7 +57,11 @@ bitflags! {
const IN_HANDLER_DISABLED_STATE = 1 << 18,
#[doc = "Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-handler-crashed"]
const IN_HANDLER_CRASHED_STATE = 1 << 19,
#[doc = "https://html.spec.whatwg.org/multipage/#selector-required"]
const IN_REQUIRED_STATE = 1 << 20,
#[doc = "https://html.spec.whatwg.org/multipage/#selector-optional"]
const IN_OPTIONAL_STATE = 1 << 21,
#[doc = "https://html.spec.whatwg.org/multipage/#selector-read-write"]
const IN_READ_WRITE_STATE = 1 << 20,
const IN_READ_WRITE_STATE = 1 << 22,
}
}
2 changes: 2 additions & 0 deletions components/style/gecko/non_ts_pseudo_class_list.rs
Expand Up @@ -59,6 +59,8 @@ macro_rules! apply_non_ts_list {
PSEUDO_CLASS_INTERNAL),
("-moz-handler-crashed", MozHandlerCrashed, mozHandlerCrashed, IN_HANDLER_CRASHED_STATE,
PSEUDO_CLASS_INTERNAL),
("required", Required, required, IN_REQUIRED_STATE, _),
("optional", Optional, optional, IN_OPTIONAL_STATE, _),
("read-write", ReadWrite, _, IN_READ_WRITE_STATE, _),
("read-only", ReadOnly, _, IN_READ_WRITE_STATE, _),

Expand Down
4 changes: 3 additions & 1 deletion components/style/gecko/wrapper.rs
Expand Up @@ -707,7 +707,9 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
NonTSPseudoClass::MozLoading |
NonTSPseudoClass::MozHandlerBlocked |
NonTSPseudoClass::MozHandlerDisabled |
NonTSPseudoClass::MozHandlerCrashed => {
NonTSPseudoClass::MozHandlerCrashed |
NonTSPseudoClass::Required |
NonTSPseudoClass::Optional => {
self.get_state().contains(pseudo_class.state_flag())
},
NonTSPseudoClass::ReadOnly => {
Expand Down

0 comments on commit 5a5a6cd

Please sign in to comment.