diff --git a/gfx/layers/apz/util/ChromeProcessController.cpp b/gfx/layers/apz/util/ChromeProcessController.cpp new file mode 100644 index 000000000000..97fcb49b77e8 --- /dev/null +++ b/gfx/layers/apz/util/ChromeProcessController.cpp @@ -0,0 +1,38 @@ +/* -*- 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 "mozilla/layers/ChromeProcessController.h" +#include "mozilla/layers/CompositorParent.h" +#include "mozilla/layers/APZCCallbackHelper.h" +#include "nsLayoutUtils.h" + +using namespace mozilla; +using namespace mozilla::layers; +using namespace mozilla::widget; + +void +ChromeProcessController::RequestContentRepaint(const FrameMetrics& aFrameMetrics) +{ + MOZ_ASSERT(NS_IsMainThread()); + + nsCOMPtr targetContent = nsLayoutUtils::FindContentFor(aFrameMetrics.GetScrollId()); + if (targetContent) { + FrameMetrics metrics = aFrameMetrics; + APZCCallbackHelper::UpdateSubFrame(targetContent, metrics); + } +} + +void +ChromeProcessController::PostDelayedTask(Task* aTask, int aDelayMs) +{ + MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs); +} + +void +ChromeProcessController::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId, + const uint32_t& aScrollGeneration) +{ + APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration); +} diff --git a/gfx/layers/apz/util/ChromeProcessController.h b/gfx/layers/apz/util/ChromeProcessController.h new file mode 100644 index 000000000000..9ddbec0d47c2 --- /dev/null +++ b/gfx/layers/apz/util/ChromeProcessController.h @@ -0,0 +1,46 @@ +/* -*- 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_layers_ChromeProcessController_h +#define mozilla_layers_ChromeProcessController_h + +#include "mozilla/layers/GeckoContentController.h" + +namespace mozilla { + +namespace layers { +class CompositorParent; + +// A ChromeProcessController is attached to the root of a compositor's layer +// tree. +class ChromeProcessController : public mozilla::layers::GeckoContentController +{ + typedef mozilla::layers::FrameMetrics FrameMetrics; + typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid; + +public: + // GeckoContentController interface + virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) MOZ_OVERRIDE; + virtual void PostDelayedTask(Task* aTask, int aDelayMs) MOZ_OVERRIDE; + virtual void AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId, + const uint32_t& aScrollGeneration) MOZ_OVERRIDE; + + virtual void HandleDoubleTap(const mozilla::CSSPoint& aPoint, int32_t aModifiers, + const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE {} + virtual void HandleSingleTap(const mozilla::CSSPoint& aPoint, int32_t aModifiers, + const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE {} + virtual void HandleLongTap(const mozilla::CSSPoint& aPoint, int32_t aModifiers, + const ScrollableLayerGuid& aGuid, + uint64_t aInputBlockId) MOZ_OVERRIDE {} + virtual void HandleLongTapUp(const CSSPoint& aPoint, int32_t aModifiers, + const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE {} + virtual void SendAsyncScrollDOMEvent(bool aIsRoot, const mozilla::CSSRect &aContentRect, + const mozilla::CSSSize &aScrollableSize) MOZ_OVERRIDE {} +}; + +} // namespace layers +} // namespace mozilla + +#endif /* mozilla_layers_ChromeProcessController_h */ diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index ad1429c82315..de9556981f01 100644 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -113,6 +113,7 @@ EXPORTS.mozilla.layers += [ 'apz/testutil/APZTestData.h', 'apz/util/ActiveElementManager.h', 'apz/util/APZCCallbackHelper.h', + 'apz/util/ChromeProcessController.h', 'AtomicRefCountedWithFinalize.h', 'AxisPhysicsModel.h', 'AxisPhysicsMSDModel.h', @@ -244,6 +245,7 @@ UNIFIED_SOURCES += [ 'apz/testutil/APZTestData.cpp', 'apz/util/ActiveElementManager.cpp', 'apz/util/APZCCallbackHelper.cpp', + 'apz/util/ChromeProcessController.cpp', 'AxisPhysicsModel.cpp', 'AxisPhysicsMSDModel.cpp', 'basic/BasicCanvasLayer.cpp', diff --git a/widget/cocoa/nsChildView.h b/widget/cocoa/nsChildView.h index 3af6285d3a8e..a3845926bee7 100644 --- a/widget/cocoa/nsChildView.h +++ b/widget/cocoa/nsChildView.h @@ -549,7 +549,6 @@ protected: } void ConfigureAPZCTreeManager() MOZ_OVERRIDE; - already_AddRefed CreateRootContentController() MOZ_OVERRIDE; void DoRemoteComposition(const nsIntRect& aRenderRect); diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 0d3a6dcccc8f..697b1622f668 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -84,7 +84,7 @@ #include "GeckoProfiler.h" #include "nsIDOMWheelEvent.h" -#include "mozilla/layers/APZCCallbackHelper.h" +#include "mozilla/layers/ChromeProcessController.h" #include "nsLayoutUtils.h" #include "InputData.h" #include "VibrancyManager.h" @@ -393,48 +393,6 @@ protected: GLuint mQuadVBO; }; -class APZCTMController : public mozilla::layers::GeckoContentController -{ - typedef mozilla::layers::FrameMetrics FrameMetrics; - typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid; - -public: - // GeckoContentController interface - virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) - { - MOZ_ASSERT(NS_IsMainThread()); - - nsCOMPtr targetContent = nsLayoutUtils::FindContentFor(aFrameMetrics.GetScrollId()); - if (targetContent) { - FrameMetrics metrics = aFrameMetrics; - APZCCallbackHelper::UpdateSubFrame(targetContent, metrics); - } - } - - virtual void PostDelayedTask(Task* aTask, int aDelayMs) MOZ_OVERRIDE - { - MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs); - } - - virtual void AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId, - const uint32_t& aScrollGeneration) MOZ_OVERRIDE - { - APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration); - } - - virtual void HandleDoubleTap(const mozilla::CSSPoint& aPoint, int32_t aModifiers, - const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE {} - virtual void HandleSingleTap(const mozilla::CSSPoint& aPoint, int32_t aModifiers, - const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE {} - virtual void HandleLongTap(const mozilla::CSSPoint& aPoint, int32_t aModifiers, - const ScrollableLayerGuid& aGuid, - uint64_t aInputBlockId) MOZ_OVERRIDE {} - virtual void HandleLongTapUp(const CSSPoint& aPoint, int32_t aModifiers, - const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE {} - virtual void SendAsyncScrollDOMEvent(bool aIsRoot, const mozilla::CSSRect &aContentRect, - const mozilla::CSSSize &aScrollableSize) MOZ_OVERRIDE {} -}; - } // unnamed namespace #pragma mark - @@ -1884,13 +1842,6 @@ nsChildView::CreateCompositor() } } -already_AddRefed -nsChildView::CreateRootContentController() -{ - nsRefPtr controller = new APZCTMController(); - return controller.forget(); -} - void nsChildView::ConfigureAPZCTreeManager() { diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 5ca2be7f21e5..124246dddcb7 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -44,6 +44,7 @@ #include "GLConsts.h" #include "mozilla/unused.h" #include "mozilla/layers/APZCTreeManager.h" +#include "mozilla/layers/ChromeProcessController.h" #ifdef ACCESSIBILITY #include "nsAccessibilityService.h" @@ -915,7 +916,8 @@ void nsBaseWidget::CreateCompositor() already_AddRefed nsBaseWidget::CreateRootContentController() { - return nullptr; + nsRefPtr controller = new ChromeProcessController(); + return controller.forget(); } void nsBaseWidget::ConfigureAPZCTreeManager()