Bug 1825807: part 1) Replace popover's ':open' and ':closed' pseudo-classes with ':popover-open'. r=emilio

See https://github.com/whatwg/html/pull/9077.

Differential Revision: https://phabricator.services.mozilla.com/D175223
This commit is contained in:
Mirko Brodesser 2023-04-17 12:18:03 +00:00
parent 5b77c8cf62
commit c47bb134d2
6 changed files with 18 additions and 29 deletions

View File

@ -124,13 +124,9 @@ bitflags! {
const VALUE_EMPTY = 1u64 << 47;
/// For :-moz-revealed.
const REVEALED = 1u64 << 48;
/// https://html.spec.whatwg.org/#selector-open
/// https://html.spec.whatwg.org/#selector-popover-open
/// Match element's popover visibility state of showing
const OPEN = 1u64 << 49;
/// https://html.spec.whatwg.org/#selector-closed
/// Match element's popover visibility state of hidden
const CLOSED = 1u64 << 50;
const POPOVER_OPEN = 1u64 << 49;
/// Some convenience unions.
const DIR_STATES = Self::LTR.bits | Self::RTL.bits;
@ -142,8 +138,6 @@ bitflags! {
const DISABLED_STATES = Self::DISABLED.bits | Self::ENABLED.bits;
const POPOVER_STATES = Self::OPEN.bits | Self::CLOSED.bits;
const REQUIRED_STATES = Self::REQUIRED.bits | Self::OPTIONAL_.bits;
/// Event states that can be added and removed through
@ -171,7 +165,7 @@ bitflags! {
Self::FOCUSRING.bits |
Self::FOCUS_WITHIN.bits |
Self::FULLSCREEN.bits |
Self::POPOVER_STATES.bits |
Self::POPOVER_OPEN.bits |
Self::HOVER.bits |
Self::URLTARGET.bits |
Self::MODAL.bits |

View File

@ -692,7 +692,7 @@ nsresult nsGenericHTMLElement::AfterSetAttr(
PopoverPseudoStateUpdate(false, true);
} else {
ClearPopoverData();
RemoveStates(ElementState::OPEN | ElementState::CLOSED);
RemoveStates(ElementState::POPOVER_OPEN);
}
}
} else if (aName == nsGkAtoms::dir) {
@ -3208,17 +3208,14 @@ PopoverState nsGenericHTMLElement::GetPopoverState() const {
}
void nsGenericHTMLElement::PopoverPseudoStateUpdate(bool aOpen, bool aNotify) {
ElementState popoverStates;
ElementState newPopoverState;
if (aOpen) {
popoverStates |= ElementState::OPEN;
popoverStates &= ~ElementState::CLOSED;
} else {
popoverStates |= ElementState::CLOSED;
popoverStates &= ~ElementState::OPEN;
newPopoverState = ElementState::POPOVER_OPEN;
}
ElementState oldPopoverStates = State() & ElementState::POPOVER_STATES;
ElementState changedStates = popoverStates ^ oldPopoverStates;
ToggleStates(changedStates, aNotify);
ElementState oldPopoverState = State() & ElementState::POPOVER_OPEN;
ElementState changedState = newPopoverState ^ oldPopoverState;
ToggleStates(changedState, aNotify);
}
bool nsGenericHTMLElement::FireBeforeToggle(bool aIsOpen) {

View File

@ -906,12 +906,12 @@ slot {
/* Popover UA style, https://html.spec.whatwg.org/#flow-content-3 */
@media (-moz-popover-enabled) {
[popover]:closed:not(dialog[open]) {
display: none;
[popover]:not(:popover-open):not(dialog[open]) {
display:none;
}
dialog[popover]:not(:closed) {
display: block;
dialog:popover-open {
display:block;
}
[popover] {
@ -927,7 +927,7 @@ slot {
background-color: Canvas;
}
[popover]:open::backdrop {
:popover-open::backdrop {
position: fixed;
inset: 0;
pointer-events: none !important;

View File

@ -39,7 +39,6 @@ macro_rules! apply_non_ts_list {
("active", Active, ACTIVE, _),
("autofill", Autofill, AUTOFILL, _),
("checked", Checked, CHECKED, _),
("closed", Closed, CLOSED, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
("defined", Defined, DEFINED, _),
("disabled", Disabled, DISABLED, _),
("enabled", Enabled, ENABLED, _),
@ -70,7 +69,7 @@ macro_rules! apply_non_ts_list {
("-moz-math-increment-script-level", MozMathIncrementScriptLevel, INCREMENT_SCRIPT_LEVEL, _),
("required", Required, REQUIRED, _),
("open", Open, OPEN, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
("popover-open", PopoverOpen, POPOVER_OPEN, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
("optional", Optional, OPTIONAL_, _),
("valid", Valid, VALID, _),
("invalid", Invalid, INVALID, _),

View File

@ -144,7 +144,7 @@ impl NonTSPseudoClass {
/// Returns whether the pseudo-class is enabled in content sheets.
#[inline]
fn is_enabled_in_content(&self) -> bool {
if matches!(*self, Self::Open | Self::Closed) {
if matches!(*self, Self::PopoverOpen) {
return static_prefs::pref!("dom.element.popover.enabled");
}
!self.has_any_flag(NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME)

View File

@ -2001,11 +2001,10 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
NonTSPseudoClass::Enabled |
NonTSPseudoClass::Disabled |
NonTSPseudoClass::Checked |
NonTSPseudoClass::Closed |
NonTSPseudoClass::Fullscreen |
NonTSPseudoClass::Indeterminate |
NonTSPseudoClass::MozInert |
NonTSPseudoClass::Open |
NonTSPseudoClass::PopoverOpen |
NonTSPseudoClass::PlaceholderShown |
NonTSPseudoClass::Target |
NonTSPseudoClass::Valid |