Skip to content

Commit

Permalink
Bug 1791079 - Implement User Activation API r=dom-core,webidl,saschan…
Browse files Browse the repository at this point in the history
…az,edgar

Rewrote internal user activation tree (spreading state to other elements)
logic to match HTML spec:
https://html.spec.whatwg.org/multipage/interaction.html#user-activation-processing-model

Added navigator.userActivation API to expose internal user activation.

Also fixed a WPT test to conform to spec (siblings are not activated),
see also spec issue: whatwg/html#9831

Co-authored-by: Tom Schuster <evilpiesgmail.com>

Differential Revision: https://phabricator.services.mozilla.com/D185348

UltraBlame original commit: 73919dbff272db85ba6334dca0a9ddfd7f5f039d
  • Loading branch information
marco-c committed Oct 13, 2023
1 parent 262e04c commit b3ae461
Show file tree
Hide file tree
Showing 24 changed files with 1,018 additions and 631 deletions.
307 changes: 211 additions & 96 deletions dom/base/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104585,186 +104585,301 @@ NotifyUserGestureActivation
(
)
{
if
(
/
/
https
:
/
/
html
.
spec
.
whatwg
.
org
/
multipage
/
interaction
.
html
#
activation
-
notification
/
/
1
.
"
Assert
:
document
is
fully
active
.
"
RefPtr
<
BrowsingContext
>
bc
currentBC
=
GetBrowsingContext
(
)
)
{
bc
-
>
PreOrderWalk
(
[
&
]
(
BrowsingContext
*
aBC
)
{
WindowContext
*
windowContext
=
aBC
-
>
GetCurrentWindowContext
(
)
;
if
(
!
windowContext
currentBC
)
{
return
;
}
nsIDocShell
*
docShell
=
aBC
-
RefPtr
<
WindowContext
>
GetDocShell
currentWC
=
GetWindowContext
(
)
;
if
(
!
docShell
currentWC
)
{
return
;
}
Document
*
/
/
2
.
"
Let
windows
be
document
=
docShell
'
s
relevant
global
object
"
/
/
Instead
of
assembling
a
list
we
just
call
notify
for
wanted
windows
as
we
/
/
find
them
currentWC
-
>
GetDocument
(
)
;
if
NotifyUserGestureActivation
(
!
document
)
{
return
;
}
/
/
XXXedgar
we
probably
could
just
check
IsInProcess
(
)
after
fission
3
.
"
.
.
.
windows
with
the
active
window
of
each
of
document
'
s
ancestor
/
/
enable
navigables
.
if
(
NodePrincipal
(
)
-
>
Equals
"
for
(
document
WindowContext
*
wc
=
currentWC
;
wc
;
wc
=
wc
-
>
NodePrincipal
GetParentWindowContext
(
)
)
)
{
windowContext
wc
-
>
NotifyUserGestureActivation
(
)
;
}
}
)
;
for
/
/
4
.
"
windows
with
the
active
window
of
each
of
document
'
s
descendant
/
/
navigables
filtered
to
include
only
those
navigables
whose
active
/
/
document
'
s
origin
is
same
origin
with
document
'
s
origin
"
currentBC
-
>
PreOrderWalk
(
[
&
]
(
BrowsingContext
*
bc
)
{
WindowContext
*
wc
=
bc
-
>
GetParent
GetCurrentWindowContext
(
)
;
bc
if
(
!
wc
)
{
return
;
bc
}
/
/
Check
same
-
origin
as
current
document
WindowGlobalChild
*
wgc
=
bc
wc
-
>
GetParent
GetWindowGlobalChild
(
)
)
{
;
if
(
WindowContext
*
windowContext
=
bc
!
wgc
|
|
!
wgc
-
>
GetCurrentWindowContext
IsSameOriginWith
(
currentWC
)
)
{
windowContext
return
;
}
wc
-
>
NotifyUserGestureActivation
(
)
;
}
}
}
)
;
}
bool
Document
Expand Down
Loading

0 comments on commit b3ae461

Please sign in to comment.