Bug 1077559 - Do some cleanup on APZCCallbackHandler. r=botond

This commit is contained in:
Kartikaya Gupta 2015-04-24 22:26:51 -04:00
parent 678e25c39d
commit dd9da9919b
3 changed files with 14 additions and 43 deletions

View File

@ -4,29 +4,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "APZCCallbackHandler.h"
#include "mozilla/layers/APZCCallbackHelper.h"
#include "mozilla/layers/APZCTreeManager.h"
#include "nsAppShell.h"
#include "nsLayoutUtils.h"
#include "nsPrintfCString.h"
#include "nsThreadUtils.h"
#include "base/message_loop.h"
#include "nsWindow.h"
#include "nsIInterfaceRequestorUtils.h"
#include "AndroidBridge.h"
#include "nsIContent.h"
using mozilla::layers::APZCCallbackHelper;
using mozilla::layers::APZCTreeManager;
using mozilla::layers::FrameMetrics;
using mozilla::layers::ScrollableLayerGuid;
namespace mozilla {
namespace widget {
namespace android {
StaticRefPtr<APZCCallbackHandler> APZCCallbackHandler::sInstance;
NativePanZoomController::GlobalRef APZCCallbackHandler::sNativePanZoomController = nullptr;
NativePanZoomController::LocalRef
@ -45,8 +33,8 @@ APZCCallbackHandler::NotifyDefaultPrevented(uint64_t aInputBlockId,
// 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(NewRunnableMethod(
this, &APZCCallbackHandler::NotifyDefaultPrevented,
AndroidBridge::Bridge()->PostTaskToUiThread(NewRunnableFunction(
&APZCCallbackHandler::NotifyDefaultPrevented,
aInputBlockId, aDefaultPrevented), 0);
return;
}

View File

@ -21,34 +21,20 @@ namespace android {
class APZCCallbackHandler final : public mozilla::layers::ChromeProcessController
{
private:
static StaticRefPtr<APZCCallbackHandler> sInstance;
static NativePanZoomController::GlobalRef sNativePanZoomController;
private:
public:
APZCCallbackHandler(nsIWidget* aWidget, mozilla::layers::APZEventState* aAPZEventState)
: mozilla::layers::ChromeProcessController(aWidget, aAPZEventState)
{}
public:
static void Initialize(nsIWidget* aWidget, mozilla::layers::APZEventState* aAPZEventState) {
MOZ_ASSERT(!sInstance.get(), "APZCCallbackHandler.Initialize() got called twice");
sInstance = new APZCCallbackHandler(aWidget, aAPZEventState);
}
static APZCCallbackHandler* GetInstance() {
MOZ_ASSERT(sInstance.get(), "Calling APZCCallbackHandler.GetInstance() before it's initialization");
return sInstance.get();
}
static NativePanZoomController::LocalRef SetNativePanZoomController(NativePanZoomController::Param obj);
void NotifyDefaultPrevented(uint64_t aInputBlockId, bool aDefaultPrevented);
public: // ChromeProcessController methods
// ChromeProcessController methods
void PostDelayedTask(Task* aTask, int aDelayMs) override;
public:
static NativePanZoomController::LocalRef SetNativePanZoomController(NativePanZoomController::Param obj);
static void NotifyDefaultPrevented(uint64_t aInputBlockId, bool aDefaultPrevented);
private:
static NativePanZoomController::GlobalRef sNativePanZoomController;
};
} // namespace android

View File

@ -1077,7 +1077,7 @@ bool nsWindow::OnMultitouchEvent(AndroidGeckoEvent *ae)
// previous block should not be default-prevented
bool defaultPrevented = isDownEvent ? false : preventDefaultActions;
if (ae->Type() == AndroidGeckoEvent::APZ_INPUT_EVENT) {
widget::android::APZCCallbackHandler::GetInstance()->NotifyDefaultPrevented(ae->ApzInputBlockId(), defaultPrevented);
widget::android::APZCCallbackHandler::NotifyDefaultPrevented(ae->ApzInputBlockId(), defaultPrevented);
} else {
GeckoAppShell::NotifyDefaultPrevented(defaultPrevented);
}
@ -1090,7 +1090,7 @@ bool nsWindow::OnMultitouchEvent(AndroidGeckoEvent *ae)
if (isDownEvent) {
if (preventDefaultActions) {
if (ae->Type() == AndroidGeckoEvent::APZ_INPUT_EVENT) {
widget::android::APZCCallbackHandler::GetInstance()->NotifyDefaultPrevented(ae->ApzInputBlockId(), true);
widget::android::APZCCallbackHandler::NotifyDefaultPrevented(ae->ApzInputBlockId(), true);
} else {
GeckoAppShell::NotifyDefaultPrevented(true);
}
@ -2492,10 +2492,7 @@ nsWindow::ConfigureAPZControllerThread()
already_AddRefed<GeckoContentController>
nsWindow::CreateRootContentController()
{
widget::android::APZCCallbackHandler::Initialize(this, mAPZEventState);
nsRefPtr<widget::android::APZCCallbackHandler> controller =
widget::android::APZCCallbackHandler::GetInstance();
nsRefPtr<GeckoContentController> controller = new widget::android::APZCCallbackHandler(this, mAPZEventState);
return controller.forget();
}