forked from mirrors/gecko-dev
Bug 1127066 - Use (nsBaseWidget's) APZEventState in ChromeProcessController. r=kats
--HG-- extra : source : 65d5458b6f6af13ebaf424ccef87d4a0654646c4
This commit is contained in:
parent
f17fd2d285
commit
65a2a78c03
3 changed files with 75 additions and 13 deletions
|
|
@ -7,9 +7,12 @@
|
|||
|
||||
#include "MainThreadUtils.h" // for NS_IsMainThread()
|
||||
#include "base/message_loop.h" // for MessageLoop
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/layers/CompositorParent.h"
|
||||
#include "mozilla/layers/APZCCallbackHelper.h"
|
||||
#include "mozilla/layers/APZEventState.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsView.h"
|
||||
|
|
@ -18,8 +21,10 @@ using namespace mozilla;
|
|||
using namespace mozilla::layers;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
ChromeProcessController::ChromeProcessController(nsIWidget* aWidget)
|
||||
ChromeProcessController::ChromeProcessController(nsIWidget* aWidget,
|
||||
APZEventState* aAPZEventState)
|
||||
: mWidget(aWidget)
|
||||
, mAPZEventState(aAPZEventState)
|
||||
, mUILoop(MessageLoop::current())
|
||||
{
|
||||
// Otherwise we're initializing mUILoop incorrectly.
|
||||
|
|
@ -40,9 +45,7 @@ ChromeProcessController::InitializeRoot()
|
|||
// The displayport is zero-margin because this element is generally not
|
||||
// actually scrollable (if it is, APZC will set proper margins when it's
|
||||
// scrolled).
|
||||
nsView* view = nsView::GetViewFor(mWidget);
|
||||
MOZ_ASSERT(view);
|
||||
nsIPresShell* presShell = view->GetPresShell();
|
||||
nsIPresShell* presShell = GetPresShell();
|
||||
MOZ_ASSERT(presShell);
|
||||
MOZ_ASSERT(presShell->GetDocument());
|
||||
nsIContent* content = presShell->GetDocument()->GetDocumentElement();
|
||||
|
|
@ -106,6 +109,24 @@ ChromeProcessController::GetPresShellResolution() const
|
|||
return 1.0f;
|
||||
}
|
||||
|
||||
nsIPresShell*
|
||||
ChromeProcessController::GetPresShell() const
|
||||
{
|
||||
nsView* view = nsView::GetViewFor(mWidget);
|
||||
MOZ_ASSERT(view);
|
||||
return view->GetPresShell();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMWindowUtils>
|
||||
ChromeProcessController::GetDOMWindowUtils() const
|
||||
{
|
||||
if (nsIDocument* doc = GetPresShell()->GetDocument()) {
|
||||
nsCOMPtr<nsIDOMWindowUtils> result = do_GetInterface(doc->GetWindow());
|
||||
return result.forget();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
ChromeProcessController::HandleSingleTap(const CSSPoint& aPoint,
|
||||
int32_t aModifiers,
|
||||
|
|
@ -119,9 +140,40 @@ ChromeProcessController::HandleSingleTap(const CSSPoint& aPoint,
|
|||
return;
|
||||
}
|
||||
|
||||
LayoutDevicePoint point =
|
||||
APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid, GetPresShellResolution())
|
||||
* mWidget->GetDefaultScale();
|
||||
|
||||
APZCCallbackHelper::FireSingleTapEvent(point, mWidget);
|
||||
mAPZEventState->ProcessSingleTap(aPoint, aGuid, GetPresShellResolution());
|
||||
}
|
||||
|
||||
void
|
||||
ChromeProcessController::HandleLongTap(const mozilla::CSSPoint& aPoint, int32_t aModifiers,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
uint64_t aInputBlockId)
|
||||
{
|
||||
if (MessageLoop::current() != mUILoop) {
|
||||
mUILoop->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableMethod(this, &ChromeProcessController::HandleLongTap,
|
||||
aPoint, aModifiers, aGuid, aInputBlockId));
|
||||
return;
|
||||
}
|
||||
|
||||
mAPZEventState->ProcessLongTap(GetDOMWindowUtils(), aPoint, aGuid,
|
||||
aInputBlockId, GetPresShellResolution());
|
||||
}
|
||||
|
||||
void
|
||||
ChromeProcessController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
|
||||
APZStateChange aChange,
|
||||
int aArg)
|
||||
{
|
||||
if (MessageLoop::current() != mUILoop) {
|
||||
mUILoop->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableMethod(this, &ChromeProcessController::NotifyAPZStateChange,
|
||||
aGuid, aChange, aArg));
|
||||
return;
|
||||
}
|
||||
|
||||
mAPZEventState->ProcessAPZStateChange(GetPresShell()->GetDocument(), aGuid.mScrollId, aChange, aArg);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@
|
|||
|
||||
#include "mozilla/layers/GeckoContentController.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsRefPtr.h"
|
||||
|
||||
class nsIDOMWindowUtils;
|
||||
class nsIPresShell;
|
||||
class nsIWidget;
|
||||
|
||||
class MessageLoop;
|
||||
|
|
@ -16,6 +19,8 @@ class MessageLoop;
|
|||
namespace mozilla {
|
||||
|
||||
namespace layers {
|
||||
|
||||
class APZEventState;
|
||||
class CompositorParent;
|
||||
|
||||
// A ChromeProcessController is attached to the root of a compositor's layer
|
||||
|
|
@ -26,7 +31,7 @@ class ChromeProcessController : public mozilla::layers::GeckoContentController
|
|||
typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
|
||||
|
||||
public:
|
||||
explicit ChromeProcessController(nsIWidget* aWidget);
|
||||
explicit ChromeProcessController(nsIWidget* aWidget, APZEventState* aAPZEventState);
|
||||
virtual void Destroy() MOZ_OVERRIDE;
|
||||
|
||||
// GeckoContentController interface
|
||||
|
|
@ -41,18 +46,23 @@ public:
|
|||
const ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
|
||||
virtual void HandleLongTap(const mozilla::CSSPoint& aPoint, int32_t aModifiers,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
uint64_t aInputBlockId) MOZ_OVERRIDE {}
|
||||
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 {}
|
||||
|
||||
virtual void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
|
||||
APZStateChange aChange,
|
||||
int aArg) MOZ_OVERRIDE;
|
||||
private:
|
||||
nsCOMPtr<nsIWidget> mWidget;
|
||||
nsRefPtr<APZEventState> mAPZEventState;
|
||||
MessageLoop* mUILoop;
|
||||
|
||||
void InitializeRoot();
|
||||
float GetPresShellResolution() const;
|
||||
nsIPresShell* GetPresShell() const;
|
||||
already_AddRefed<nsIDOMWindowUtils> GetDOMWindowUtils() const;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
|
|
|
|||
|
|
@ -914,7 +914,7 @@ void nsBaseWidget::CreateCompositor()
|
|||
already_AddRefed<GeckoContentController>
|
||||
nsBaseWidget::CreateRootContentController()
|
||||
{
|
||||
nsRefPtr<GeckoContentController> controller = new ChromeProcessController(this);
|
||||
nsRefPtr<GeckoContentController> controller = new ChromeProcessController(this, mAPZEventState);
|
||||
return controller.forget();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue