Bug 976605 - Turn GeckoCC::NotifyTransform[Begin|End] into an extensible APZ state change notification mechanism. r=kats

--HG--
extra : source : 5353e86dcfe8b2ff6f02e577a4c69a1de6808d9b
This commit is contained in:
Botond Ballo 2014-04-15 13:39:20 -04:00
Родитель 413a506d07
Коммит 3391efa3ea
11 изменённых файлов: 116 добавлений и 79 удалений

Просмотреть файл

@ -50,6 +50,7 @@ using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/Comp
using mozilla::CSSPoint from "Units.h";
using mozilla::CSSToScreenScale from "Units.h";
using mozilla::CommandInt from "mozilla/EventForwards.h";
using mozilla::layers::GeckoContentController::APZStateChange from "mozilla/layers/GeckoContentController.h";
namespace mozilla {
namespace dom {
@ -410,11 +411,10 @@ child:
HandleLongTapUp(CSSPoint point, ScrollableLayerGuid aGuid);
/**
* Notifies the child that the parent has begun or finished transforming
* the visible child content area. Useful for showing/hiding scrollbars.
* Notifies the child about various APZ state changes.
* See GeckoContentController::NotifyAPZStateChange() for details.
*/
NotifyTransformBegin(ViewID aViewId);
NotifyTransformEnd(ViewID aViewId);
NotifyAPZStateChange(ViewID aViewId, APZStateChange aChange, int aArg);
/**
* Sending an activate message moves focus to the child.

Просмотреть файл

@ -1730,23 +1730,34 @@ TabChild::RecvHandleLongTapUp(const CSSPoint& aPoint, const ScrollableLayerGuid&
}
bool
TabChild::RecvNotifyTransformBegin(const ViewID& aViewId)
TabChild::RecvNotifyAPZStateChange(const ViewID& aViewId,
const APZStateChange& aChange,
const int& aArg)
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(sf);
if (scrollbarOwner) {
scrollbarOwner->ScrollbarActivityStarted();
switch (aChange)
{
case APZStateChange::TransformBegin:
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(sf);
if (scrollbarOwner) {
scrollbarOwner->ScrollbarActivityStarted();
}
break;
}
return true;
}
bool
TabChild::RecvNotifyTransformEnd(const ViewID& aViewId)
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(sf);
if (scrollbarOwner) {
scrollbarOwner->ScrollbarActivityStopped();
case APZStateChange::TransformEnd:
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(sf);
if (scrollbarOwner) {
scrollbarOwner->ScrollbarActivityStopped();
}
break;
}
default:
// APZStateChange has a 'sentinel' value, and the compiler complains
// if an enumerator is not handled and there is no 'default' case.
break;
}
return true;
}

Просмотреть файл

@ -296,8 +296,9 @@ public:
const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
virtual bool RecvHandleLongTapUp(const CSSPoint& aPoint,
const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
virtual bool RecvNotifyTransformBegin(const ViewID& aViewId) MOZ_OVERRIDE;
virtual bool RecvNotifyTransformEnd(const ViewID& aViewId) MOZ_OVERRIDE;
virtual bool RecvNotifyAPZStateChange(const ViewID& aViewId,
const APZStateChange& aChange,
const int& aArg) MOZ_OVERRIDE;
virtual bool RecvActivate() MOZ_OVERRIDE;
virtual bool RecvDeactivate() MOZ_OVERRIDE;
virtual bool RecvMouseEvent(const nsString& aType,

Просмотреть файл

@ -554,17 +554,12 @@ void TabParent::HandleLongTapUp(const CSSPoint& aPoint,
}
}
void TabParent::NotifyTransformBegin(ViewID aViewId)
void TabParent::NotifyAPZStateChange(ViewID aViewId,
APZStateChange aChange,
int aArg)
{
if (!mIsDestroyed) {
unused << SendNotifyTransformBegin(aViewId);
}
}
void TabParent::NotifyTransformEnd(ViewID aViewId)
{
if (!mIsDestroyed) {
unused << SendNotifyTransformEnd(aViewId);
unused << SendNotifyAPZStateChange(aViewId, aChange, aArg);
}
}

Просмотреть файл

@ -212,8 +212,9 @@ public:
void HandleLongTapUp(const CSSPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid);
void NotifyTransformBegin(ViewID aViewId);
void NotifyTransformEnd(ViewID aViewId);
void NotifyAPZStateChange(ViewID aViewId,
APZStateChange aChange,
int aArg);
void Activate();
void Deactivate();

Просмотреть файл

@ -26,6 +26,7 @@
#include "mozilla/layers/CompositorTypes.h"
#include "FrameMetrics.h"
#include "FilterSupport.h"
#include "mozilla/layers/GeckoContentController.h"
#ifdef _MSC_VER
#pragma warning( disable : 4800 )
@ -1069,6 +1070,16 @@ struct ParamTraits<mozilla::gfx::FilterDescription>
}
};
typedef mozilla::layers::GeckoContentController::APZStateChange APZStateChange;
template <>
struct ParamTraits<APZStateChange>
: public ContiguousTypedEnumSerializer<
APZStateChange,
APZStateChange::TransformBegin,
APZStateChange::APZStateChangeSentinel>
{};
} /* namespace IPC */
#endif /* __GFXMESSAGEUTILS_H__ */

Просмотреть файл

@ -132,6 +132,7 @@ namespace mozilla {
namespace layers {
typedef mozilla::layers::AllowedTouchBehavior AllowedTouchBehavior;
typedef GeckoContentController::APZStateChange APZStateChange;
/*
* The following prefs are used to control the behaviour of the APZC.
@ -1992,11 +1993,11 @@ void AsyncPanZoomController::SetState(PanZoomState aNewState) {
if (mGeckoContentController) {
if (!IsTransformingState(oldState) && IsTransformingState(aNewState)) {
mGeckoContentController->NotifyTransformBegin(
ScrollableLayerGuid(mLayersId, mFrameMetrics.mPresShellId, mFrameMetrics.GetScrollId()));
mGeckoContentController->NotifyAPZStateChange(
GetGuid(), APZStateChange::TransformBegin);
} else if (IsTransformingState(oldState) && !IsTransformingState(aNewState)) {
mGeckoContentController->NotifyTransformEnd(
ScrollableLayerGuid(mLayersId, mFrameMetrics.mPresShellId, mFrameMetrics.GetScrollId()));
mGeckoContentController->NotifyAPZStateChange(
GetGuid(), APZStateChange::TransformEnd);
}
}
}

Просмотреть файл

@ -113,13 +113,28 @@ public:
return false;
}
MOZ_BEGIN_NESTED_ENUM_CLASS(APZStateChange, int8_t)
/**
* APZ started modifying the view (including panning, zooming, and fling).
*/
TransformBegin,
/**
* APZ finished modifying the view.
*/
TransformEnd,
APZStateChangeSentinel
MOZ_END_NESTED_ENUM_CLASS(APZStateChange)
/**
* General tranformation notices for consumers. These fire any time
* the apzc is modifying the view, including panning, zooming, and
* fling.
* General notices of APZ state changes for consumers.
* |aGuid| identifies the APZC originating the state change.
* |aChange| identifies the type of state change
* |aArg| is used by some state changes to pass extra information (see
* the documentation for each state change above)
*/
virtual void NotifyTransformBegin(const ScrollableLayerGuid& aGuid) {}
virtual void NotifyTransformEnd(const ScrollableLayerGuid& aGuid) {}
virtual void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
APZStateChange aChange,
int aArg = 0) {}
GeckoContentController() {}
@ -128,6 +143,8 @@ protected:
virtual ~GeckoContentController() {}
};
MOZ_FINISH_NESTED_ENUM_CLASS(GeckoContentController::APZStateChange)
}
}

Просмотреть файл

@ -658,33 +658,20 @@ public:
return true;
}
virtual void NotifyTransformBegin(const ScrollableLayerGuid& aGuid)
virtual void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
APZStateChange aChange,
int aArg)
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &RemoteContentController::NotifyTransformBegin,
aGuid));
NewRunnableMethod(this, &RemoteContentController::NotifyAPZStateChange,
aGuid, aChange, aArg));
return;
}
if (mRenderFrame) {
TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager());
browser->NotifyTransformBegin(aGuid.mScrollId);
}
}
virtual void NotifyTransformEnd(const ScrollableLayerGuid& aGuid)
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &RemoteContentController::NotifyTransformEnd,
aGuid));
return;
}
if (mRenderFrame) {
TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager());
browser->NotifyTransformEnd(aGuid.mScrollId);
browser->NotifyAPZStateChange(aGuid.mScrollId, aChange, aArg);
}
}

Просмотреть файл

@ -303,25 +303,37 @@ class TransformedEndEvent : public nsRunnable
};
void
APZController::NotifyTransformBegin(const ScrollableLayerGuid& aGuid)
APZController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
APZStateChange aChange,
int aArg)
{
if (NS_IsMainThread()) {
MetroUtils::FireObserver("apzc-transform-begin", L"");
return;
switch (aChange) {
case APZStateChange::TransformBegin:
{
if (NS_IsMainThread()) {
MetroUtils::FireObserver("apzc-transform-begin", L"");
return;
}
nsCOMPtr<nsIRunnable> runnable = new TransformedStartEvent();
NS_DispatchToMainThread(runnable);
break;
}
case APZStateChange::TransformEnd:
{
if (NS_IsMainThread()) {
MetroUtils::FireObserver("apzc-transform-end", L"");
return;
}
nsCOMPtr<nsIRunnable> runnable = new TransformedEndEvent();
NS_DispatchToMainThread(runnable);
break;
}
default:
{
// We don't currently care about other state changes.
break;
}
}
nsCOMPtr<nsIRunnable> runnable = new TransformedStartEvent();
NS_DispatchToMainThread(runnable);
}
void
APZController::NotifyTransformEnd(const ScrollableLayerGuid& aGuid)
{
if (NS_IsMainThread()) {
MetroUtils::FireObserver("apzc-transform-end", L"");
return;
}
nsCOMPtr<nsIRunnable> runnable = new TransformedEndEvent();
NS_DispatchToMainThread(runnable);
}
} } }

Просмотреть файл

@ -49,8 +49,9 @@ public:
virtual void SendAsyncScrollDOMEvent(bool aIsRoot, const mozilla::CSSRect &aContentRect, const mozilla::CSSSize &aScrollableSize);
virtual void PostDelayedTask(Task* aTask, int aDelayMs);
virtual bool GetRootZoomConstraints(ZoomConstraints* aOutConstraints);
virtual void NotifyTransformBegin(const ScrollableLayerGuid& aGuid);
virtual void NotifyTransformEnd(const ScrollableLayerGuid& aGuid);
virtual void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
APZStateChange aChange,
int aArg);
void SetWidgetListener(nsIWidgetListener* aWidgetListener);