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: 7c84c5fc7d0002a8bee64ebc66899437638331c6
  • Loading branch information
marco-c committed Oct 13, 2023
1 parent bb78efe commit 661e8ba
Show file tree
Hide file tree
Showing 24 changed files with 745 additions and 626 deletions.
159 changes: 67 additions & 92 deletions dom/base/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79614,169 +79614,144 @@ NotifyUserGestureActivation
(
)
{
if
(
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
)
{
return
;
}
Document
*
document
=
docShell
currentWC
-
>
GetDocument
NotifyUserGestureActivation
(
)
;
if
for
(
!
document
)
{
return
WindowContext
*
wc
=
currentWC
;
}
if
(
NodePrincipal
(
)
wc
;
wc
=
wc
-
>
Equals
GetParentWindowContext
(
document
-
>
NodePrincipal
(
)
)
)
{
windowContext
wc
-
>
NotifyUserGestureActivation
(
)
;
}
}
)
;
for
currentBC
-
>
PreOrderWalk
(
[
&
]
(
BrowsingContext
*
bc
)
{
WindowContext
*
wc
=
bc
-
>
GetParent
GetCurrentWindowContext
(
)
;
bc
if
(
!
wc
)
{
return
;
bc
}
WindowGlobalChild
*
wgc
=
bc
wc
-
>
GetParent
GetWindowGlobalChild
(
)
)
{
;
if
(
WindowContext
*
windowContext
=
bc
!
wgc
|
|
!
wgc
-
>
GetCurrentWindowContext
IsSameOriginWith
(
currentWC
)
)
{
windowContext
return
;
}
wc
-
>
NotifyUserGestureActivation
(
)
;
}
}
}
)
;
}
bool
Document
Expand Down
57 changes: 57 additions & 0 deletions dom/base/Navigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,17 @@ mozilla
/
dom
/
UserActivation
.
h
"
#
include
"
mozilla
/
dom
/
VRDisplay
.
h
Expand Down Expand Up @@ -1021,6 +1032,10 @@ mLocks
)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE
(
mUserActivation
)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE
(
mWindow
)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE
Expand Down Expand Up @@ -1264,6 +1279,10 @@ mLocks
nullptr
;
}
mUserActivation
=
nullptr
;
mSharePromise
=
nullptr
Expand Down Expand Up @@ -11117,4 +11136,42 @@ aContext
)
;
}
already_AddRefed
<
UserActivation
>
Navigator
:
:
UserActivation
(
)
{
if
(
!
mUserActivation
)
{
mUserActivation
=
new
dom
:
:
UserActivation
(
GetWindow
(
)
)
;
}
return
do_AddRef
(
mUserActivation
)
;
}
}
20 changes: 20 additions & 0 deletions dom/base/Navigator.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ MediaCapabilities
class
MediaSession
;
class
UserActivation
;
struct
ShareData
;
Expand Down Expand Up @@ -1159,6 +1162,14 @@ AudioContext
aContext
)
;
already_AddRefed
<
UserActivation
>
UserActivation
(
)
;
private
:
void
Expand Down Expand Up @@ -1416,6 +1427,15 @@ LockManager
>
mLocks
;
RefPtr
<
dom
:
:
UserActivation
>
mUserActivation
;
}
;
}
Expand Down
Loading

0 comments on commit 661e8ba

Please sign in to comment.