From 53652961ac462bfa0ecb25a6d5c5c5419ca046ff Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Fri, 13 Oct 2023 16:48:22 +0000 Subject: [PATCH] Bug 1838450 - Refine attribute handling. r=emilio https://github.com/whatwg/dom/pull/1176 https://dom.spec.whatwg.org/#concept-element-attributes-change-ext "attribute change steps" at https://html.spec.whatwg.org/multipage/popover.html#attr-popover Differential Revision: https://phabricator.services.mozilla.com/D181880 UltraBlame original commit: 00b027478170756439b780282f9cfdf15edea985 --- dom/html/nsGenericHTMLElement.cpp | 132 ++-- .../popovers/popover-attribute-basic.html.ini | 720 ------------------ 2 files changed, 58 insertions(+), 794 deletions(-) diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index 774076bee6b9a..2c42946431bfc 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -3393,38 +3393,29 @@ AfterSetPopoverAttr ( ) { -const -nsAttrValue -* -newValue -= -GetParsedAttr -( -nsGkAtoms -: -: -popover -) -; -const -PopoverAttributeState -newState +auto +mapPopoverState = [ -& -newValue ] ( +const +nsAttrValue +* +value ) +- +> +PopoverAttributeState { if ( -newValue +value ) { MOZ_ASSERT ( -newValue +value - > Type @@ -3447,7 +3438,7 @@ static_cast PopoverAttributeKeyword > ( -newValue +value - > GetEnumValue @@ -3469,7 +3460,19 @@ PopoverAttributeState None ; } +; +PopoverAttributeState +newState += +mapPopoverState ( +GetParsedAttr +( +nsGkAtoms +: +: +popover +) ) ; const @@ -3488,15 +3491,19 @@ newState oldState ) { -EnsurePopoverData +PopoverPseudoStateUpdate ( +false +true ) -. -SetPopoverAttributeState +; +if +( +IsPopoverOpen ( -newState ) -; +) +{ HidePopoverInternal ( true @@ -3506,16 +3513,20 @@ IgnoreErrors ) ) ; -if -( newState = -= -GetPopoverAttributeState +mapPopoverState +( +GetParsedAttr ( +nsGkAtoms +: +: +popover ) ) -{ +; +} if ( newState @@ -3527,6 +3538,13 @@ PopoverAttributeState None ) { +if +( +GetPopoverData +( +) +) +{ OwnerDoc ( ) @@ -3538,6 +3556,7 @@ RemovePopoverFromTopLayer this ) ; +} ClearPopoverData ( ) @@ -3553,16 +3572,18 @@ POPOVER_OPEN } else { -PopoverPseudoStateUpdate +EnsurePopoverData ( -false -true +) +. +SetPopoverAttributeState +( +newState ) ; } } } -} void nsGenericHTMLElement : @@ -16277,24 +16298,8 @@ ErrorResult aRv ) { -const -PopoverData -* -data -= -GetPopoverData -( -) -; if ( -! -data -| -| -data -- -> GetPopoverAttributeState ( ) @@ -16306,18 +16311,6 @@ PopoverAttributeState None ) { -MOZ_ASSERT -( -! -HasAttr -( -nsGkAtoms -: -: -popover -) -) -; aRv . ThrowNotSupportedError @@ -16337,20 +16330,11 @@ return false ; } -MOZ_ASSERT +if ( -HasAttr +GetPopoverData ( -nsGkAtoms -: -: -popover ) -) -; -if -( -data - > GetPopoverVisibilityState diff --git a/testing/web-platform/meta/html/semantics/popovers/popover-attribute-basic.html.ini b/testing/web-platform/meta/html/semantics/popovers/popover-attribute-basic.html.ini index f86ff65dd6a65..05fb9ee2da133 100644 --- a/testing/web-platform/meta/html/semantics/popovers/popover-attribute-basic.html.ini +++ b/testing/web-platform/meta/html/semantics/popovers/popover-attribute-basic.html.ini @@ -12,726 +12,6 @@ Changing a popover from -auto -to -undefined -( -via -attr -) -and -then -auto -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -auto -to -undefined -( -via -attr -) -and -then -manual -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -auto -to -undefined -( -via -attr -) -and -then -invalid -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -auto -to -undefined -( -via -attr -) -and -then -null -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -manual -to -undefined -( -via -attr -) -and -then -auto -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -manual -to -undefined -( -via -attr -) -and -then -manual -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -manual -to -undefined -( -via -attr -) -and -then -invalid -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -manual -to -undefined -( -via -attr -) -and -then -null -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -auto -to -null -( -via -idl -) -and -then -auto -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -auto -to -undefined -( -via -idl -) -and -then -auto -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -manual -to -null -( -via -idl -) -and -then -auto -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -manual -to -undefined -( -via -idl -) -and -then -auto -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -auto -to -null -( -via -idl -) -and -then -manual -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -auto -to -null -( -via -idl -) -and -then -invalid -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -auto -to -undefined -( -via -idl -) -and -then -manual -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -auto -to -undefined -( -via -idl -) -and -then -invalid -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -manual -to -null -( -via -idl -) -and -then -manual -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -manual -to -null -( -via -idl -) -and -then -invalid -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -manual -to -undefined -( -via -idl -) -and -then -manual -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -manual -to -undefined -( -via -idl -) -and -then -invalid -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -auto -to -undefined -( -via -attr -) -and -then -undefined -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -manual -to -undefined -( -via -attr -) -and -then -undefined -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -auto -to -null -( -via -idl -) -and -then -null -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -auto -to -null -( -via -idl -) -and -then -undefined -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -auto -to -undefined -( -via -idl -) -and -then -null -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -auto -to -undefined -( -via -idl -) -and -then -undefined -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -manual -to -null -( -via -idl -) -and -then -null -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -manual -to -null -( -via -idl -) -and -then -undefined -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -manual -to -undefined -( -via -idl -) -and -then -null -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from -manual -to -undefined -( -via -idl -) -and -then -undefined -during -' -beforetoggle -' -works -] -expected -: -FAIL -[ -Changing -a -popover -from manual to auto