forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAndroidContentController.cpp
57 lines (48 loc) · 1.91 KB
/
AndroidContentController.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AndroidContentController.h"
#include "mozilla/layers/APZCTreeManager.h"
#include "base/message_loop.h"
#include "nsWindow.h"
#include "AndroidBridge.h"
using mozilla::layers::APZCTreeManager;
namespace mozilla {
namespace widget {
namespace android {
NativePanZoomController::GlobalRef AndroidContentController::sNativePanZoomController = nullptr;
NativePanZoomController::LocalRef
AndroidContentController::SetNativePanZoomController(NativePanZoomController::Param obj)
{
NativePanZoomController::LocalRef old = sNativePanZoomController;
sNativePanZoomController = obj;
return old;
}
void
AndroidContentController::NotifyDefaultPrevented(uint64_t aInputBlockId,
bool aDefaultPrevented)
{
if (!AndroidBridge::IsJavaUiThread()) {
// The notification must reach the APZ on the Java UI thread (aka the
// APZ "controller" thread) but we get it from the Gecko thread, so we
// have to throw it onto the other thread.
AndroidBridge::Bridge()->PostTaskToUiThread(NewRunnableFunction(
&AndroidContentController::NotifyDefaultPrevented,
aInputBlockId, aDefaultPrevented), 0);
return;
}
MOZ_ASSERT(AndroidBridge::IsJavaUiThread());
APZCTreeManager* controller = nsWindow::GetAPZCTreeManager();
if (controller) {
controller->ContentReceivedInputBlock(aInputBlockId, aDefaultPrevented);
}
}
void
AndroidContentController::PostDelayedTask(Task* aTask, int aDelayMs)
{
AndroidBridge::Bridge()->PostTaskToUiThread(aTask, aDelayMs);
}
} // namespace android
} // namespace widget
} // namespace mozilla