Bug 1223946 - Part 1: Clean up and support needed for converting WidgetWheelEvent to ScrollWheelInput. r=kats

--HG--
extra : commitid : Cihc6iEBezl
This commit is contained in:
Randall Barker 2015-11-18 19:32:37 -05:00
Родитель 9a1bc2b629
Коммит 47968a20fd
7 изменённых файлов: 45 добавлений и 13 удалений

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

@ -1003,7 +1003,7 @@ APZCTreeManager::UpdateWheelTransaction(WidgetInputEvent& aEvent)
}
ScreenIntPoint point =
ViewAs<ScreenPixel>(aEvent.refPoint, PixelCastJustification::LayoutDeviceToScreenForUntransformedEvent);
ViewAs<ScreenPixel>(aEvent.refPoint, PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent);
txn->OnMouseMove(point);
return;
}

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

@ -98,6 +98,16 @@ APZThreadUtils::RunDelayedTaskOnCurrentThread(Task* aTask,
}
}
/*static*/ bool
APZThreadUtils::IsControllerThread()
{
#ifdef MOZ_ANDROID_APZ
return AndroidBridge::IsJavaUiThread();
#else
return sControllerThread == MessageLoop::current();
#endif
}
NS_IMPL_ISUPPORTS(GenericTimerCallbackBase, nsITimerCallback)
} // namespace layers

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

@ -57,6 +57,11 @@ public:
*/
static void RunDelayedTaskOnCurrentThread(Task* aTask,
const TimeDuration& aDelay);
/**
* Returns true if currently on APZ "controller thread".
*/
static bool IsControllerThread();
};
// A base class for GenericTimerCallback<Function>.

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

@ -38,9 +38,10 @@ enum class PixelCastJustification : uint8_t {
// When an OS event is initially constructed, its reference point is
// technically in screen pixels, as it has not yet accounted for any
// asynchronous transforms. This justification is for viewing the initial
// reference point as a screen point.
LayoutDeviceToScreenForUntransformedEvent,
// Similar to LayoutDeviceToScreenForUntransformedEvent, PBrowser handles
// reference point as a screen point. The reverse is useful when synthetically
// created WidgetEvents need to be converted back to InputData.
LayoutDeviceIsScreenForUntransformedEvent,
// Similar to LayoutDeviceIsScreenForUntransformedEvent, PBrowser handles
// some widget/tab dimension information as the OS does -- in screen units.
LayoutDeviceIsScreenForTabDims
};

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

@ -120,9 +120,8 @@ MultiTouchInput::MultiTouchInput(const WidgetTouchEvent& aTouchEvent)
float force = domTouch->Force();
SingleTouchData data(identifier,
ScreenIntPoint::FromUnknownPoint(
gfx::IntPoint(domTouch->mRefPoint.x,
domTouch->mRefPoint.y)),
ViewAs<ScreenPixel>(domTouch->mRefPoint,
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent),
ScreenSize(radiusX, radiusY),
rotationAngle,
force);
@ -263,9 +262,8 @@ MultiTouchInput::MultiTouchInput(const WidgetMouseEvent& aMouseEvent)
}
mTouches.AppendElement(SingleTouchData(0,
ScreenIntPoint::FromUnknownPoint(
gfx::IntPoint(aMouseEvent.refPoint.x,
aMouseEvent.refPoint.y)),
ViewAs<ScreenPixel>(aMouseEvent.refPoint,
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent),
ScreenSize(1, 1),
180.0f,
1.0f));
@ -306,7 +304,7 @@ PanGestureInput::ToWidgetWheelEvent(nsIWidget* aWidget) const
wheelEvent.timeStamp = mTimeStamp;
wheelEvent.refPoint =
RoundedToInt(ViewAs<LayoutDevicePixel>(mPanStartPoint,
PixelCastJustification::LayoutDeviceToScreenForUntransformedEvent));
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent));
wheelEvent.buttons = 0;
wheelEvent.deltaMode = nsIDOMWheelEvent::DOM_DELTA_PIXEL;
wheelEvent.isMomentum = IsMomentum();
@ -369,6 +367,22 @@ DeltaModeForDeltaType(ScrollWheelInput::ScrollDeltaType aDeltaType)
}
}
ScrollWheelInput::ScrollWheelInput(const WidgetWheelEvent& aWheelEvent) :
InputData(SCROLLWHEEL_INPUT, aWheelEvent.time, aWheelEvent.timeStamp, aWheelEvent.modifiers),
mDeltaType(DeltaTypeForDeltaMode(aWheelEvent.deltaMode)),
mScrollMode(SCROLLMODE_INSTANT),
mHandledByAPZ(aWheelEvent.mFlags.mHandledByAPZ),
mDeltaX(aWheelEvent.deltaX),
mDeltaY(aWheelEvent.deltaY),
mLineOrPageDeltaX(aWheelEvent.lineOrPageDeltaX),
mLineOrPageDeltaY(aWheelEvent.lineOrPageDeltaY),
mIsMomentum(aWheelEvent.isMomentum)
{
mOrigin =
ScreenPoint(ViewAs<ScreenPixel>(aWheelEvent.refPoint,
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent));
}
WidgetWheelEvent
ScrollWheelInput::ToWidgetWheelEvent(nsIWidget* aWidget) const
{
@ -378,7 +392,7 @@ ScrollWheelInput::ToWidgetWheelEvent(nsIWidget* aWidget) const
wheelEvent.timeStamp = mTimeStamp;
wheelEvent.refPoint =
RoundedToInt(ViewAs<LayoutDevicePixel>(mOrigin,
PixelCastJustification::LayoutDeviceToScreenForUntransformedEvent));
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent));
wheelEvent.buttons = 0;
wheelEvent.deltaMode = DeltaModeForDeltaType(mDeltaType);
wheelEvent.isMomentum = mIsMomentum;

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

@ -582,6 +582,8 @@ public:
mIsMomentum(false)
{}
explicit ScrollWheelInput(const WidgetWheelEvent& aEvent);
WidgetWheelEvent ToWidgetWheelEvent(nsIWidget* aWidget) const;
bool TransformToLocal(const gfx::Matrix4x4& aTransform);

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

@ -41,7 +41,7 @@ SwipeTracker::SwipeTracker(nsChildView& aWidget,
, mRefreshDriver(GetRefreshDriver(mWidget))
, mAxis(0.0, 0.0, 0.0, kSpringForce, 1.0)
, mEventPosition(RoundedToInt(ViewAs<LayoutDevicePixel>(aSwipeStartEvent.mPanStartPoint,
PixelCastJustification::LayoutDeviceToScreenForUntransformedEvent)))
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent)))
, mLastEventTimeStamp(aSwipeStartEvent.mTimeStamp)
, mAllowedDirections(aAllowedDirections)
, mSwipeDirection(aSwipeDirection)