2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*-
|
2014-08-09 01:42:20 +04:00
|
|
|
* 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/. */
|
|
|
|
|
2015-04-25 05:26:51 +03:00
|
|
|
#include "AndroidContentController.h"
|
2015-11-14 01:14:45 +03:00
|
|
|
|
|
|
|
#include "AndroidBridge.h"
|
2014-08-09 01:42:20 +04:00
|
|
|
#include "base/message_loop.h"
|
2015-11-14 01:14:45 +03:00
|
|
|
#include "mozilla/layers/APZCCallbackHelper.h"
|
2016-07-20 14:37:00 +03:00
|
|
|
#include "mozilla/layers/IAPZCTreeManager.h"
|
2016-02-25 19:15:14 +03:00
|
|
|
#include "nsIObserverService.h"
|
2015-11-14 01:14:45 +03:00
|
|
|
#include "nsLayoutUtils.h"
|
2014-08-09 01:42:20 +04:00
|
|
|
#include "nsWindow.h"
|
|
|
|
|
2016-07-20 14:37:00 +03:00
|
|
|
using mozilla::layers::IAPZCTreeManager;
|
2014-08-09 01:42:20 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
|
2016-01-26 04:32:33 +03:00
|
|
|
void AndroidContentController::Destroy() {
|
|
|
|
mAndroidWindow = nullptr;
|
|
|
|
ChromeProcessController::Destroy();
|
|
|
|
}
|
|
|
|
|
2016-08-19 21:37:23 +03:00
|
|
|
void AndroidContentController::UpdateOverscrollVelocity(
|
|
|
|
const float aX, const float aY, const bool aIsRootContent) {
|
|
|
|
if (aIsRootContent && mAndroidWindow) {
|
2016-01-26 04:32:33 +03:00
|
|
|
mAndroidWindow->UpdateOverscrollVelocity(aX, aY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-19 21:37:23 +03:00
|
|
|
void AndroidContentController::UpdateOverscrollOffset(
|
|
|
|
const float aX, const float aY, const bool aIsRootContent) {
|
|
|
|
if (aIsRootContent && mAndroidWindow) {
|
2016-01-26 04:32:33 +03:00
|
|
|
mAndroidWindow->UpdateOverscrollOffset(aX, aY);
|
|
|
|
}
|
|
|
|
}
|
2014-08-09 01:42:20 +04:00
|
|
|
|
2016-02-25 19:15:14 +03:00
|
|
|
void AndroidContentController::NotifyAPZStateChange(
|
|
|
|
const ScrollableLayerGuid& aGuid, APZStateChange aChange, int aArg) {
|
|
|
|
// This function may get invoked twice, if the first invocation is not on
|
|
|
|
// the main thread then the ChromeProcessController version of this function
|
|
|
|
// will redispatch to the main thread. We want to make sure that our handling
|
|
|
|
// only happens on the main thread.
|
|
|
|
ChromeProcessController::NotifyAPZStateChange(aGuid, aChange, aArg);
|
2016-04-19 03:08:47 +03:00
|
|
|
if (NS_IsMainThread()) {
|
2016-02-25 19:15:14 +03:00
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
|
|
|
mozilla::services::GetObserverService();
|
2016-07-04 21:44:08 +03:00
|
|
|
if (aChange ==
|
|
|
|
layers::GeckoContentController::APZStateChange::eTransformEnd) {
|
2016-04-19 03:08:47 +03:00
|
|
|
// This is used by tests to determine when the APZ is done doing whatever
|
|
|
|
// it's doing. XXX generify this as needed when writing additional tests.
|
|
|
|
observerService->NotifyObservers(nullptr, "APZ:TransformEnd", nullptr);
|
2016-07-21 08:03:25 +03:00
|
|
|
observerService->NotifyObservers(nullptr, "PanZoom:StateChange",
|
|
|
|
u"NOTHING");
|
2016-07-04 21:44:08 +03:00
|
|
|
} else if (aChange == layers::GeckoContentController::APZStateChange::
|
|
|
|
eTransformBegin) {
|
2016-07-21 08:03:25 +03:00
|
|
|
observerService->NotifyObservers(nullptr, "PanZoom:StateChange",
|
|
|
|
u"PANNING");
|
2016-04-19 03:08:47 +03:00
|
|
|
}
|
2016-02-25 19:15:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-09 01:42:20 +04:00
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|