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 ScrollableLayerGuid
& aGuid
, const float aX
, const float aY
,
28 const bool aIsRootContent
) {
29 if (aIsRootContent
&& mAndroidWindow
) {
30 mAndroidWindow
->UpdateOverscrollVelocity(aX
, aY
);
34 void AndroidContentController::UpdateOverscrollOffset(
35 const ScrollableLayerGuid
& aGuid
, const float aX
, const float aY
,
36 const bool aIsRootContent
) {
37 if (aIsRootContent
&& mAndroidWindow
) {
38 mAndroidWindow
->UpdateOverscrollOffset(aX
, aY
);
42 void AndroidContentController::NotifyAPZStateChange(
43 const ScrollableLayerGuid
& aGuid
, APZStateChange aChange
, int aArg
) {
44 // This function may get invoked twice, if the first invocation is not on
45 // the main thread then the ChromeProcessController version of this function
46 // will redispatch to the main thread. We want to make sure that our handling
47 // only happens on the main thread.
48 ChromeProcessController::NotifyAPZStateChange(aGuid
, aChange
, aArg
);
49 if (NS_IsMainThread()) {
50 nsCOMPtr
<nsIObserverService
> observerService
=
51 mozilla::services::GetObserverService();
53 layers::GeckoContentController::APZStateChange::eTransformEnd
) {
54 // This is used by tests to determine when the APZ is done doing whatever
55 // it's doing. XXX generify this as needed when writing additional tests.
56 observerService
->NotifyObservers(nullptr, "APZ:TransformEnd", nullptr);
57 observerService
->NotifyObservers(nullptr, "PanZoom:StateChange",
59 } else if (aChange
== layers::GeckoContentController::APZStateChange::
61 observerService
->NotifyObservers(nullptr, "PanZoom:StateChange",
68 } // namespace mozilla