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 0c3b0b2 commit a69e444
Show file tree
Hide file tree
Showing 24 changed files with 746 additions and 618 deletions.
152 changes: 68 additions & 84 deletions dom/base/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79614,169 +79614,153 @@ 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
currentWC
)
{
return
;
}
Document
*
document
=
docShell
currentWC
-
>
GetDocument
NotifyUserGestureActivation
(
)
;
if
for
(
!
document
)
{
return
WindowContext
*
wc
=
currentWC
;
}
if
(
NodePrincipal
(
)
-
>
Equals
(
document
wc
;
wc
=
wc
-
>
NodePrincipal
GetParentWindowContext
(
)
)
)
{
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 a69e444

Please sign in to comment.