Bug 1835712 - Add a new flag to InputAPZContext to indicate the state we didn't handle the event on the main-thread. r=botond

And use it to tell whether it's safe to inform the handled result to APZ.

Differential Revision: https://phabricator.services.mozilla.com/D180760
This commit is contained in:
Hiroyuki Ikezoe 2023-06-22 03:01:44 +00:00
Родитель de8eca7976
Коммит c146abc3d5
5 изменённых файлов: 29 добавлений и 9 удалений

Просмотреть файл

@ -20,12 +20,8 @@ var subtests = [
["apz.overscroll.test_async_scroll_offset.enabled", true],
["apz.test.logging_enabled", true],
]},
{"file": "helper_bug1719855.html?prevent=contextmenu", "prefs": [
["android.touch_resampling.enabled", false],
]},
{"file": "helper_bug1719855.html", "prefs": [
["android.touch_resampling.enabled", false],
]},
{"file": "helper_bug1719855.html?prevent=contextmenu"},
{"file": "helper_bug1719855.html"},
// Add new subtests here. If this starts timing out because it's taking too
// long, create a test_group_touchevents-6.html file. Refer to 1423011#c57
// for more details.

Просмотреть файл

@ -14,6 +14,7 @@ uint64_t InputAPZContext::sBlockId = 0;
nsEventStatus InputAPZContext::sApzResponse = nsEventStatus_eSentinel;
bool InputAPZContext::sPendingLayerization = false;
bool InputAPZContext::sRoutedToChildProcess = false;
bool InputAPZContext::sDropped = false;
/*static*/
ScrollableLayerGuid InputAPZContext::GetTargetLayerGuid() { return sGuid; }
@ -32,6 +33,9 @@ bool InputAPZContext::WasRoutedToChildProcess() {
return sRoutedToChildProcess;
}
/*static*/
bool InputAPZContext::WasDropped() { return sDropped; }
InputAPZContext::InputAPZContext(const ScrollableLayerGuid& aGuid,
const uint64_t& aBlockId,
const nsEventStatus& aApzResponse,
@ -40,12 +44,14 @@ InputAPZContext::InputAPZContext(const ScrollableLayerGuid& aGuid,
mOldBlockId(sBlockId),
mOldApzResponse(sApzResponse),
mOldPendingLayerization(sPendingLayerization),
mOldRoutedToChildProcess(sRoutedToChildProcess) {
mOldRoutedToChildProcess(sRoutedToChildProcess),
mOldDropped(sDropped) {
sGuid = aGuid;
sBlockId = aBlockId;
sApzResponse = aApzResponse;
sPendingLayerization = aPendingLayerization;
sRoutedToChildProcess = false;
sDropped = false;
}
InputAPZContext::~InputAPZContext() {
@ -54,6 +60,7 @@ InputAPZContext::~InputAPZContext() {
sApzResponse = mOldApzResponse;
sPendingLayerization = mOldPendingLayerization;
sRoutedToChildProcess = mOldRoutedToChildProcess;
sDropped = mOldDropped;
}
/*static*/
@ -61,5 +68,8 @@ void InputAPZContext::SetRoutedToChildProcess() {
sRoutedToChildProcess = true;
}
/*static*/
void InputAPZContext::SetDropped() { sDropped = true; }
} // namespace layers
} // namespace mozilla

Просмотреть файл

@ -34,6 +34,9 @@ class MOZ_STACK_CLASS InputAPZContext {
// State that is set in deeper code and propagated upwards.
static bool sRoutedToChildProcess;
// True if the WidgetInputEvent was dropped (which means the event wasn't
// dispatched) on the main-thread.
static bool sDropped;
public:
// Functions to access downwards-propagated data
@ -45,6 +48,8 @@ class MOZ_STACK_CLASS InputAPZContext {
// Functions to access upwards-propagated data
static bool WasRoutedToChildProcess();
static bool WasDropped();
// Constructor sets the data to be propagated downwards
InputAPZContext(const ScrollableLayerGuid& aGuid, const uint64_t& aBlockId,
const nsEventStatus& aApzResponse,
@ -53,6 +58,7 @@ class MOZ_STACK_CLASS InputAPZContext {
// Functions to set data to be propagated upwards
static void SetRoutedToChildProcess();
static void SetDropped();
private:
ScrollableLayerGuid mOldGuid;
@ -61,6 +67,7 @@ class MOZ_STACK_CLASS InputAPZContext {
bool mOldPendingLayerization;
bool mOldRoutedToChildProcess;
bool mOldDropped;
};
} // namespace layers

Просмотреть файл

@ -10,6 +10,7 @@
#include "mozilla/dom/Document.h"
#include "mozilla/dom/EventTarget.h"
#include "mozilla/PresShell.h"
#include "mozilla/layers/InputAPZContext.h"
#include "nsIContent.h"
#include "nsIFrame.h"
#include "nsLayoutUtils.h"
@ -328,6 +329,10 @@ bool TouchManager::PreHandleEvent(WidgetEvent* aEvent, nsEventStatus* aStatus,
}
}
} else {
// This touch event isn't going to be dispatched on the main-thread,
// we need to tell it to APZ because returned nsEventStatus is
// unreliable to tell whether the event was preventDefaulted or not.
layers::InputAPZContext::SetDropped();
return false;
}
}

Просмотреть файл

@ -1092,8 +1092,10 @@ nsEventStatus nsBaseWidget::ProcessUntransformedAPZEvent(
UniquePtr<WidgetEvent> original(aEvent->Duplicate());
DispatchEvent(aEvent, status);
if (mAPZC && !InputAPZContext::WasRoutedToChildProcess() && inputBlockId) {
// EventStateManager did not route the event into the child process.
if (mAPZC && !InputAPZContext::WasRoutedToChildProcess() &&
!InputAPZContext::WasDropped() && inputBlockId) {
// EventStateManager did not route the event into the child process and
// the event was dispatched in the parent process.
// It's safe to communicate to APZ that the event has been processed.
// Note that here aGuid.mLayersId might be different from
// mCompositorSession->RootLayerTreeId() because the event might have gotten