1 /* -*- Mode: c++; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "AndroidContentController.h"
8 #include "AndroidBridge.h"
9 #include "base/message_loop.h"
10 #include "mozilla/layers/APZCCallbackHelper.h"
11 #include "mozilla/layers/IAPZCTreeManager.h"
12 #include "nsIObserverService.h"
13 #include "nsLayoutUtils.h"
16 using mozilla::layers::IAPZCTreeManager
;
21 void AndroidContentController::Destroy() {
22 mAndroidWindow
= nullptr;
23 ChromeProcessController::Destroy();
26 void AndroidContentController::UpdateOverscrollVelocity(
27 const float aX
, const float aY
, const bool aIsRootContent
) {
28 if (aIsRootContent
&& mAndroidWindow
) {
29 mAndroidWindow
->UpdateOverscrollVelocity(aX
, aY
);
33 void AndroidContentController::UpdateOverscrollOffset(
34 const float aX
, const float aY
, const bool aIsRootContent
) {
35 if (aIsRootContent
&& mAndroidWindow
) {
36 mAndroidWindow
->UpdateOverscrollOffset(aX
, aY
);
40 void AndroidContentController::NotifyAPZStateChange(
41 const ScrollableLayerGuid
& aGuid
, APZStateChange aChange
, int aArg
) {
42 // This function may get invoked twice, if the first invocation is not on
43 // the main thread then the ChromeProcessController version of this function
44 // will redispatch to the main thread. We want to make sure that our handling
45 // only happens on the main thread.
46 ChromeProcessController::NotifyAPZStateChange(aGuid
, aChange
, aArg
);
47 if (NS_IsMainThread()) {
48 nsCOMPtr
<nsIObserverService
> observerService
=
49 mozilla::services::GetObserverService();
51 layers::GeckoContentController::APZStateChange::eTransformEnd
) {
52 // This is used by tests to determine when the APZ is done doing whatever
53 // it's doing. XXX generify this as needed when writing additional tests.
54 observerService
->NotifyObservers(nullptr, "APZ:TransformEnd", nullptr);
55 observerService
->NotifyObservers(nullptr, "PanZoom:StateChange",
57 } else if (aChange
== layers::GeckoContentController::APZStateChange::
59 observerService
->NotifyObservers(nullptr, "PanZoom:StateChange",
66 } // namespace mozilla