Bug 880676 - Convert WidgetSpaceToCompensatedViewportSpace to the new gfx types. r=kentuckyfriedtakahe

This commit is contained in:
Kartikaya Gupta 2013-06-14 16:11:32 -04:00
Родитель cf832e1e8c
Коммит e5cc885ca0
1 изменённых файлов: 27 добавлений и 33 удалений

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

@ -208,37 +208,29 @@ AsyncPanZoomController::GetTouchStartTolerance()
return gTouchStartTolerance;
}
static gfx::Point
WidgetSpaceToCompensatedViewportSpace(const gfx::Point& aPoint,
gfxFloat aCurrentZoom)
static CSSPoint
WidgetSpaceToCompensatedViewportSpace(const ScreenPoint& aPoint,
const CSSToScreenScale& aCurrentZoom)
{
// Transform the input point from local widget space to the content document
// space that the user is seeing, from last composite.
gfx::Point pt(aPoint);
pt = pt / aCurrentZoom;
// FIXME/bug 775451: this doesn't attempt to compensate for content transforms
// in effect on the compositor. The problem is that it's very hard for us to
// know what content CSS pixel is at widget point 0,0 based on information
// available here. So we use this hacky implementation for now, which works
// in quiescent states.
return pt;
return aPoint / aCurrentZoom;
}
nsEventStatus
AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent,
nsInputEvent* aOutEvent)
{
gfxFloat currentResolution;
gfx::Point currentScrollOffset, lastScrollOffset;
CSSToScreenScale currentResolution;
{
MonitorAutoLock monitor(mMonitor);
currentResolution = CalculateResolution(mFrameMetrics).width;
currentScrollOffset = gfx::Point(mFrameMetrics.mScrollOffset.x,
mFrameMetrics.mScrollOffset.y);
lastScrollOffset = gfx::Point(mLastContentPaintMetrics.mScrollOffset.x,
mLastContentPaintMetrics.mScrollOffset.y);
currentResolution = CSSToScreenScale(CalculateResolution(mFrameMetrics).width);
}
nsEventStatus status;
@ -265,8 +257,9 @@ AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent,
for (uint32_t i = 0; i < touches.Length(); ++i) {
nsIDOMTouch* touch = touches[i];
if (touch) {
gfx::Point refPoint = WidgetSpaceToCompensatedViewportSpace(
gfx::Point(touch->mRefPoint.x, touch->mRefPoint.y),
CSSPoint refPoint = WidgetSpaceToCompensatedViewportSpace(
ScreenPoint::FromUnknownPoint(gfx::Point(
touch->mRefPoint.x, touch->mRefPoint.y)),
currentResolution);
touch->mRefPoint = nsIntPoint(refPoint.x, refPoint.y);
}
@ -274,8 +267,9 @@ AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent,
break;
}
default: {
gfx::Point refPoint = WidgetSpaceToCompensatedViewportSpace(
gfx::Point(aOutEvent->refPoint.x, aOutEvent->refPoint.y),
CSSPoint refPoint = WidgetSpaceToCompensatedViewportSpace(
ScreenPoint::FromUnknownPoint(gfx::Point(
aOutEvent->refPoint.x, aOutEvent->refPoint.y)),
currentResolution);
aOutEvent->refPoint = nsIntPoint(refPoint.x, refPoint.y);
break;
@ -651,11 +645,11 @@ nsEventStatus AsyncPanZoomController::OnLongPress(const TapGestureInput& aEvent)
if (mGeckoContentController) {
MonitorAutoLock monitor(mMonitor);
gfxFloat resolution = CalculateResolution(mFrameMetrics).width;
CSSPoint point = CSSPoint::FromUnknownPoint(
WidgetSpaceToCompensatedViewportSpace(
gfx::Point(aEvent.mPoint.x, aEvent.mPoint.y),
resolution));
CSSToScreenScale resolution(CalculateResolution(mFrameMetrics).width);
CSSPoint point = WidgetSpaceToCompensatedViewportSpace(
ScreenPoint::FromUnknownPoint(gfx::Point(
aEvent.mPoint.x, aEvent.mPoint.y)),
resolution);
mGeckoContentController->HandleLongTap(gfx::RoundedToInt(point));
return nsEventStatus_eConsumeNoDefault;
}
@ -670,11 +664,11 @@ nsEventStatus AsyncPanZoomController::OnSingleTapConfirmed(const TapGestureInput
if (mGeckoContentController) {
MonitorAutoLock monitor(mMonitor);
gfxFloat resolution = CalculateResolution(mFrameMetrics).width;
CSSPoint point = CSSPoint::FromUnknownPoint(
WidgetSpaceToCompensatedViewportSpace(
gfx::Point(aEvent.mPoint.x, aEvent.mPoint.y),
resolution));
CSSToScreenScale resolution(CalculateResolution(mFrameMetrics).width);
CSSPoint point = WidgetSpaceToCompensatedViewportSpace(
ScreenPoint::FromUnknownPoint(gfx::Point(
aEvent.mPoint.x, aEvent.mPoint.y)),
resolution);
mGeckoContentController->HandleSingleTap(gfx::RoundedToInt(point));
return nsEventStatus_eConsumeNoDefault;
}
@ -686,11 +680,11 @@ nsEventStatus AsyncPanZoomController::OnDoubleTap(const TapGestureInput& aEvent)
MonitorAutoLock monitor(mMonitor);
if (mAllowZoom) {
gfxFloat resolution = CalculateResolution(mFrameMetrics).width;
CSSPoint point = CSSPoint::FromUnknownPoint(
WidgetSpaceToCompensatedViewportSpace(
gfx::Point(aEvent.mPoint.x, aEvent.mPoint.y),
resolution));
CSSToScreenScale resolution(CalculateResolution(mFrameMetrics).width);
CSSPoint point = WidgetSpaceToCompensatedViewportSpace(
ScreenPoint::FromUnknownPoint(gfx::Point(
aEvent.mPoint.x, aEvent.mPoint.y)),
resolution);
mGeckoContentController->HandleDoubleTap(gfx::RoundedToInt(point));
}