Skip to content

Commit 5365296

Browse files
committed
Bug 1838450 - Refine attribute handling. r=emilio
whatwg/dom#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
1 parent 20df61f commit 5365296

File tree

2 files changed

+58
-794
lines changed

2 files changed

+58
-794
lines changed

dom/html/nsGenericHTMLElement.cpp

Lines changed: 58 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -3393,38 +3393,29 @@ AfterSetPopoverAttr
33933393
(
33943394
)
33953395
{
3396-
const
3397-
nsAttrValue
3398-
*
3399-
newValue
3400-
=
3401-
GetParsedAttr
3402-
(
3403-
nsGkAtoms
3404-
:
3405-
:
3406-
popover
3407-
)
3408-
;
3409-
const
3410-
PopoverAttributeState
3411-
newState
3396+
auto
3397+
mapPopoverState
34123398
=
34133399
[
3414-
&
3415-
newValue
34163400
]
34173401
(
3402+
const
3403+
nsAttrValue
3404+
*
3405+
value
34183406
)
3407+
-
3408+
>
3409+
PopoverAttributeState
34193410
{
34203411
if
34213412
(
3422-
newValue
3413+
value
34233414
)
34243415
{
34253416
MOZ_ASSERT
34263417
(
3427-
newValue
3418+
value
34283419
-
34293420
>
34303421
Type
@@ -3447,7 +3438,7 @@ static_cast
34473438
PopoverAttributeKeyword
34483439
>
34493440
(
3450-
newValue
3441+
value
34513442
-
34523443
>
34533444
GetEnumValue
@@ -3469,7 +3460,19 @@ PopoverAttributeState
34693460
None
34703461
;
34713462
}
3463+
;
3464+
PopoverAttributeState
3465+
newState
3466+
=
3467+
mapPopoverState
34723468
(
3469+
GetParsedAttr
3470+
(
3471+
nsGkAtoms
3472+
:
3473+
:
3474+
popover
3475+
)
34733476
)
34743477
;
34753478
const
@@ -3488,15 +3491,19 @@ newState
34883491
oldState
34893492
)
34903493
{
3491-
EnsurePopoverData
3494+
PopoverPseudoStateUpdate
34923495
(
3496+
false
3497+
true
34933498
)
3494-
.
3495-
SetPopoverAttributeState
3499+
;
3500+
if
3501+
(
3502+
IsPopoverOpen
34963503
(
3497-
newState
34983504
)
3499-
;
3505+
)
3506+
{
35003507
HidePopoverInternal
35013508
(
35023509
true
@@ -3506,16 +3513,20 @@ IgnoreErrors
35063513
)
35073514
)
35083515
;
3509-
if
3510-
(
35113516
newState
35123517
=
3513-
=
3514-
GetPopoverAttributeState
3518+
mapPopoverState
3519+
(
3520+
GetParsedAttr
35153521
(
3522+
nsGkAtoms
3523+
:
3524+
:
3525+
popover
35163526
)
35173527
)
3518-
{
3528+
;
3529+
}
35193530
if
35203531
(
35213532
newState
@@ -3527,6 +3538,13 @@ PopoverAttributeState
35273538
None
35283539
)
35293540
{
3541+
if
3542+
(
3543+
GetPopoverData
3544+
(
3545+
)
3546+
)
3547+
{
35303548
OwnerDoc
35313549
(
35323550
)
@@ -3538,6 +3556,7 @@ RemovePopoverFromTopLayer
35383556
this
35393557
)
35403558
;
3559+
}
35413560
ClearPopoverData
35423561
(
35433562
)
@@ -3553,16 +3572,18 @@ POPOVER_OPEN
35533572
}
35543573
else
35553574
{
3556-
PopoverPseudoStateUpdate
3575+
EnsurePopoverData
35573576
(
3558-
false
3559-
true
3577+
)
3578+
.
3579+
SetPopoverAttributeState
3580+
(
3581+
newState
35603582
)
35613583
;
35623584
}
35633585
}
35643586
}
3565-
}
35663587
void
35673588
nsGenericHTMLElement
35683589
:
@@ -16277,24 +16298,8 @@ ErrorResult
1627716298
aRv
1627816299
)
1627916300
{
16280-
const
16281-
PopoverData
16282-
*
16283-
data
16284-
=
16285-
GetPopoverData
16286-
(
16287-
)
16288-
;
1628916301
if
1629016302
(
16291-
!
16292-
data
16293-
|
16294-
|
16295-
data
16296-
-
16297-
>
1629816303
GetPopoverAttributeState
1629916304
(
1630016305
)
@@ -16306,18 +16311,6 @@ PopoverAttributeState
1630616311
None
1630716312
)
1630816313
{
16309-
MOZ_ASSERT
16310-
(
16311-
!
16312-
HasAttr
16313-
(
16314-
nsGkAtoms
16315-
:
16316-
:
16317-
popover
16318-
)
16319-
)
16320-
;
1632116314
aRv
1632216315
.
1632316316
ThrowNotSupportedError
@@ -16337,20 +16330,11 @@ return
1633716330
false
1633816331
;
1633916332
}
16340-
MOZ_ASSERT
16333+
if
1634116334
(
16342-
HasAttr
16335+
GetPopoverData
1634316336
(
16344-
nsGkAtoms
16345-
:
16346-
:
16347-
popover
1634816337
)
16349-
)
16350-
;
16351-
if
16352-
(
16353-
data
1635416338
-
1635516339
>
1635616340
GetPopoverVisibilityState

0 commit comments

Comments
 (0)