Skip to content

Commit 1a540d3

Browse files
committed
browser(webkit): mark user gesture in frames
1 parent a61d066 commit 1a540d3

File tree

2 files changed

+99
-2
lines changed

2 files changed

+99
-2
lines changed

browser_patches/webkit/BUILD_NUMBER

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1169
1+
1170

browser_patches/webkit/patches/bootstrap.diff

+98-1
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,20 @@ index ddba948c2a08f4a3789773c7ce6c1c1f16d5f11e..c8399e021f1975ada36a7c07de295e1b
16801680
2D8B92F4203D13E1009C868F /* UnifiedSource519.cpp in Sources */,
16811681
2D8B92F5203D13E1009C868F /* UnifiedSource520.cpp in Sources */,
16821682
2D8B92F6203D13E1009C868F /* UnifiedSource521.cpp in Sources */,
1683+
diff --git a/Source/WebCore/dom/UserGestureIndicator.cpp b/Source/WebCore/dom/UserGestureIndicator.cpp
1684+
index dfec93b644f72a51bad0bebf396da61c57f6e428..353833a7614a55566862c196bafc598a475536a1 100644
1685+
--- a/Source/WebCore/dom/UserGestureIndicator.cpp
1686+
+++ b/Source/WebCore/dom/UserGestureIndicator.cpp
1687+
@@ -56,8 +56,7 @@ UserGestureIndicator::UserGestureIndicator(Optional<ProcessingUserGestureState>
1688+
1689+
if (state)
1690+
currentToken() = UserGestureToken::create(state.value(), gestureType);
1691+
-
1692+
- if (document && currentToken()->processingUserGesture() && state) {
1693+
+ if (document && state && currentToken()->processingUserGesture()) {
1694+
document->updateLastHandledUserGestureTimestamp(currentToken()->startTime());
1695+
if (processInteractionStyle == ProcessInteractionStyle::Immediate)
1696+
ResourceLoadObserver::shared().logUserInteractionWithReducedTimeResolution(document->topDocument());
16831697
diff --git a/Source/WebCore/html/FileInputType.cpp b/Source/WebCore/html/FileInputType.cpp
16841698
index 4e41fd3f807e8f34bfef3f63f0ba6119a619821e..1f7be602cb2134f8867bf95afe0c9337bce57055 100644
16851699
--- a/Source/WebCore/html/FileInputType.cpp
@@ -3794,8 +3808,33 @@ index 5b7d17a424be41789f73e795736defb8fdf4ed1b..ee571acbf3a4c34cd7039ddd04febe36
37943808
}
37953809

37963810
void InspectorWorkerAgent::disconnectFromWorkerInspectorProxy(WorkerInspectorProxy* proxy)
3811+
diff --git a/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp b/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp
3812+
index cc0b0526f19f806ce621521d0771cc5f30d43840..6b54fa315ac22af78f2bf1befef204ca48308200 100644
3813+
--- a/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp
3814+
+++ b/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp
3815+
@@ -38,6 +38,7 @@
3816+
#include "Frame.h"
3817+
#include "InspectorPageAgent.h"
3818+
#include "InstrumentingAgents.h"
3819+
+#include "JSDOMWindowBase.h"
3820+
#include "Page.h"
3821+
#include "PageConsoleClient.h"
3822+
#include "PageScriptDebugServer.h"
3823+
@@ -70,8 +71,11 @@ bool PageDebuggerAgent::enabled() const
3824+
3825+
void PageDebuggerAgent::evaluateOnCallFrame(ErrorString& errorString, const String& callFrameId, const String& expression, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, const bool* saveResult, const bool* emulateUserGesture, RefPtr<Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex)
3826+
{
3827+
+ InjectedScript injectedScript = injectedScriptManager().injectedScriptForObjectId(callFrameId);
3828+
+ JSC::JSGlobalObject* globalObject = injectedScript.globalObject();
3829+
+ Document* document = globalObject ? activeDOMWindow(*globalObject).document() : nullptr;
3830+
auto shouldEmulateUserGesture = emulateUserGesture && *emulateUserGesture;
3831+
- UserGestureEmulationScope userGestureScope(m_inspectedPage, shouldEmulateUserGesture);
3832+
+ UserGestureEmulationScope userGestureScope(m_inspectedPage, shouldEmulateUserGesture, document);
3833+
3834+
WebDebuggerAgent::evaluateOnCallFrame(errorString, callFrameId, expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, saveResult, emulateUserGesture, result, wasThrown, savedResultIndex);
3835+
}
37973836
diff --git a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp
3798-
index 63336051bb0050d6a55eb5543b0349eb964bbb7a..71abd08516e93b087e506f54b8e093ea300dfe71 100644
3837+
index 63336051bb0050d6a55eb5543b0349eb964bbb7a..eecfb5a50196c6d9ca353e9b7aedbd4d6feb690c 100644
37993838
--- a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp
38003839
+++ b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp
38013840
@@ -35,12 +35,14 @@
@@ -3829,6 +3868,30 @@ index 63336051bb0050d6a55eb5543b0349eb964bbb7a..71abd08516e93b087e506f54b8e093ea
38293868
InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString& errorString, const int* executionContextId)
38303869
{
38313870
if (!executionContextId) {
3871+
@@ -194,13 +205,21 @@ void PageRuntimeAgent::notifyContextCreated(const String& frameId, JSC::JSGlobal
3872+
3873+
void PageRuntimeAgent::evaluate(ErrorString& errorString, const String& expression, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* returnByValue, const bool* generatePreview, const bool* saveResult, const bool* emulateUserGesture, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex)
3874+
{
3875+
- UserGestureEmulationScope userGestureScope(m_inspectedPage, asBool(emulateUserGesture));
3876+
+ InjectedScript injectedScript = injectedScriptForEval(errorString, executionContextId);
3877+
+ if (!errorString.isEmpty())
3878+
+ return;
3879+
+ JSC::JSGlobalObject* globalObject = injectedScript.globalObject();
3880+
+ Document* document = globalObject ? activeDOMWindow(*globalObject).document() : nullptr;
3881+
+ UserGestureEmulationScope userGestureScope(m_inspectedPage, asBool(emulateUserGesture), document);
3882+
InspectorRuntimeAgent::evaluate(errorString, expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, executionContextId, returnByValue, generatePreview, saveResult, emulateUserGesture, result, wasThrown, savedResultIndex);
3883+
}
3884+
3885+
void PageRuntimeAgent::callFunctionOn(ErrorString& errorString, const String& objectId, const String& expression, const JSON::Array* optionalArguments, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, const bool* emulateUserGesture, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown)
3886+
{
3887+
- UserGestureEmulationScope userGestureScope(m_inspectedPage, asBool(emulateUserGesture));
3888+
+ InjectedScript injectedScript = injectedScriptManager().injectedScriptForObjectId(objectId);
3889+
+ JSC::JSGlobalObject* globalObject = injectedScript.globalObject();
3890+
+ Document* document = globalObject ? activeDOMWindow(*globalObject).document() : nullptr;
3891+
+ UserGestureEmulationScope userGestureScope(m_inspectedPage, asBool(emulateUserGesture), document);
3892+
InspectorRuntimeAgent::callFunctionOn(errorString, objectId, expression, optionalArguments, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, emulateUserGesture, result, wasThrown);
3893+
}
3894+
38323895
diff --git a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h
38333896
index 2af3739b7fe7c16faa7d8d2797ce6d010215398d..80bfde6120874e16fb173f707fd0bd8a3e5067a0 100644
38343897
--- a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h
@@ -3849,6 +3912,40 @@ index 2af3739b7fe7c16faa7d8d2797ce6d010215398d..80bfde6120874e16fb173f707fd0bd8a
38493912
InstrumentingAgents& m_instrumentingAgents;
38503913

38513914
Page& m_inspectedPage;
3915+
diff --git a/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.cpp b/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.cpp
3916+
index 633bce6e8f3c0785632eb7f26d172f6016b3efd9..14f531504bb2b96646d1a48092a0b132b0510f55 100644
3917+
--- a/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.cpp
3918+
+++ b/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.cpp
3919+
@@ -39,9 +39,9 @@
3920+
3921+
namespace WebCore {
3922+
3923+
-UserGestureEmulationScope::UserGestureEmulationScope(Page& inspectedPage, bool emulateUserGesture)
3924+
+UserGestureEmulationScope::UserGestureEmulationScope(Page& inspectedPage, bool emulateUserGesture, Document* document)
3925+
: m_pageChromeClient(inspectedPage.chrome().client())
3926+
- , m_gestureIndicator(emulateUserGesture ? Optional<ProcessingUserGestureState>(ProcessingUserGesture) : WTF::nullopt)
3927+
+ , m_gestureIndicator(emulateUserGesture ? Optional<ProcessingUserGestureState>(ProcessingUserGesture) : WTF::nullopt, document)
3928+
, m_emulateUserGesture(emulateUserGesture)
3929+
, m_userWasInteracting(false)
3930+
{
3931+
diff --git a/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.h b/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.h
3932+
index b94ed78ad3dbea19543c1fd54653f0481e52fb7c..6341c7ff7ef53577f33c19ecad1b8bfbd674d051 100644
3933+
--- a/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.h
3934+
+++ b/Source/WebCore/inspector/agents/page/UserGestureEmulationScope.h
3935+
@@ -38,11 +38,12 @@ namespace WebCore {
3936+
3937+
class ChromeClient;
3938+
class Page;
3939+
+class Document;
3940+
3941+
class UserGestureEmulationScope {
3942+
WTF_MAKE_NONCOPYABLE(UserGestureEmulationScope);
3943+
public:
3944+
- UserGestureEmulationScope(Page& inspectedPage, bool emulateUserGesture);
3945+
+ UserGestureEmulationScope(Page& inspectedPage, bool emulateUserGesture, Document* document);
3946+
~UserGestureEmulationScope();
3947+
3948+
private:
38523949
diff --git a/Source/WebCore/loader/DocumentLoader.cpp b/Source/WebCore/loader/DocumentLoader.cpp
38533950
index da50315d2160833e02ab19b250ea19ab652246a9..f93887308eba26272449efd1c48afa68d77c4408 100644
38543951
--- a/Source/WebCore/loader/DocumentLoader.cpp

0 commit comments

Comments
 (0)