diff --git a/widget/gonk/ParentProcessController.cpp b/widget/gonk/ParentProcessController.cpp new file mode 100644 index 000000000000..06ffca72a0b9 --- /dev/null +++ b/widget/gonk/ParentProcessController.cpp @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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 "ParentProcessController.h" +#include "nsIContent.h" +#include "nsLayoutUtils.h" +#include "APZCCallbackHelper.h" +#include "base/message_loop.h" + +namespace mozilla { +namespace widget { + +class RequestContentRepaintEvent : public nsRunnable +{ + typedef mozilla::layers::FrameMetrics FrameMetrics; + +public: + RequestContentRepaintEvent(const FrameMetrics& aFrameMetrics) + : mFrameMetrics(aFrameMetrics) + { + } + + NS_IMETHOD Run() { + MOZ_ASSERT(NS_IsMainThread()); + nsCOMPtr content = nsLayoutUtils::FindContentFor(mFrameMetrics.mScrollId); + if (content) { + APZCCallbackHelper::UpdateSubFrame(content, mFrameMetrics); + } + return NS_OK; + } + +protected: + const FrameMetrics mFrameMetrics; +}; + +void +ParentProcessController::RequestContentRepaint(const FrameMetrics& aFrameMetrics) +{ + if (aFrameMetrics.mScrollId == FrameMetrics::NULL_SCROLL_ID) { + return; + } + + nsCOMPtr r = new RequestContentRepaintEvent(aFrameMetrics); + if (!NS_IsMainThread()) { + NS_DispatchToMainThread(r); + } else { + r->Run(); + } +} + +void +ParentProcessController::PostDelayedTask(Task* aTask, int aDelayMs) +{ + MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs); +} + +} +} diff --git a/widget/gonk/ParentProcessController.h b/widget/gonk/ParentProcessController.h new file mode 100644 index 000000000000..43ac895d9498 --- /dev/null +++ b/widget/gonk/ParentProcessController.h @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. */ + +#ifndef __mozilla_widget_DynamicToolbarController_h__ +#define __mozilla_widget_DynamicToolbarController_h__ + +#include "mozilla/layers/GeckoContentController.h" + +namespace mozilla { +namespace widget { + +class ParentProcessController : public mozilla::layers::GeckoContentController +{ + typedef mozilla::layers::FrameMetrics FrameMetrics; + +public: + virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) MOZ_OVERRIDE; + virtual void PostDelayedTask(Task* aTask, int aDelayMs) MOZ_OVERRIDE; + + // No-ops + virtual void HandleDoubleTap(const CSSIntPoint& aPoint) MOZ_OVERRIDE {} + virtual void HandleSingleTap(const CSSIntPoint& aPoint) MOZ_OVERRIDE {} + virtual void HandleLongTap(const CSSIntPoint& aPoint) MOZ_OVERRIDE {} + virtual void SendAsyncScrollDOMEvent(bool aIsRoot, + const CSSRect &aContentRect, + const CSSSize &aScrollableSize) MOZ_OVERRIDE {} +}; + +} +} + +#endif /*__mozilla_widget_DynamicToolbarController_h__ */ diff --git a/widget/gonk/moz.build b/widget/gonk/moz.build index 6cbb987d4aa2..2ec804659dba 100644 --- a/widget/gonk/moz.build +++ b/widget/gonk/moz.build @@ -54,6 +54,7 @@ SOURCES += [ 'nsWidgetFactory.cpp', 'nsWindow.cpp', 'OrientationObserver.cpp', + 'ParentProcessController.cpp', 'ProcessOrientation.cpp' ] diff --git a/widget/gonk/nsWindow.cpp b/widget/gonk/nsWindow.cpp index 93918e8aec10..3720d06f6f91 100644 --- a/widget/gonk/nsWindow.cpp +++ b/widget/gonk/nsWindow.cpp @@ -44,6 +44,8 @@ #include "libdisplay/GonkDisplay.h" #include "pixelflinger/format.h" #include "mozilla/BasicEvents.h" +#include "mozilla/layers/CompositorParent.h" +#include "ParentProcessController.h" #include "HwcComposer2D.h" @@ -589,6 +591,10 @@ nsWindow::GetLayerManager(PLayerTransactionChild* aShadowManager, if (sUsingOMTC) { CreateCompositor(); + if (mCompositorParent) { + uint64_t rootLayerTreeId = mCompositorParent->RootLayerTreeId(); + CompositorParent::SetControllerForLayerTree(rootLayerTreeId, new ParentProcessController()); + } if (mLayerManager) return mLayerManager; }