Backout 8a6cacf047a1 (bug 833795) to fix bug 856083

This commit is contained in:
Anthony Jones 2013-04-05 18:19:08 +13:00
parent e0bb05ab0e
commit 0bb08fbaa7
5 changed files with 44 additions and 70 deletions

View File

@ -646,10 +646,6 @@ TabParent::TryCapture(const nsGUIEvent& aEvent)
{
MOZ_ASSERT(sEventCapturer == this && mEventCaptureDepth > 0);
if (mIsDestroyed) {
return false;
}
if (aEvent.eventStructType != NS_TOUCH_EVENT) {
// Only capture of touch events is implemented, for now.
return false;
@ -670,29 +666,19 @@ TabParent::TryCapture(const nsGUIEvent& aEvent)
return false;
}
if (RenderFrameParent* rfp = GetRenderFrame()) {
// We need to process screen relative events co-ordinates for gestures to
// avoid phantom movement when the frame moves.
rfp->NotifyInputEvent(event);
// Adjust the widget coordinates to be relative to our frame.
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
// Adjust the widget coordinates to be relative to our frame.
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
if (!frameLoader) {
// No frame anymore?
sEventCapturer = nullptr;
return false;
}
// Remove the frame offset and compensate for zoom.
nsEventStateManager::MapEventCoordinatesForChildProcess(frameLoader,
&event);
rfp->ApplyZoomCompensationToEvent(&event);
if (!frameLoader) {
// No frame anymore?
sEventCapturer = nullptr;
return false;
}
return (event.message == NS_TOUCH_MOVE) ?
PBrowserParent::SendRealTouchMoveEvent(event) :
PBrowserParent::SendRealTouchEvent(event);
nsEventStateManager::MapEventCoordinatesForChildProcess(frameLoader, &event);
SendRealTouchEvent(event);
return true;
}
bool
@ -1404,8 +1390,7 @@ TabParent::MaybeForwardEventToRenderFrame(const nsInputEvent& aEvent,
nsInputEvent* aOutEvent)
{
if (RenderFrameParent* rfp = GetRenderFrame()) {
rfp->NotifyInputEvent(aEvent);
rfp->ApplyZoomCompensationToEvent(aOutEvent);
rfp->NotifyInputEvent(aEvent, aOutEvent);
}
}

View File

@ -225,8 +225,20 @@ WidgetSpaceToCompensatedViewportSpace(const gfx::Point& aPoint,
}
nsEventStatus
AsyncPanZoomController::ReceiveMainThreadInputEvent(const nsInputEvent& aEvent)
AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent,
nsInputEvent* aOutEvent)
{
gfxFloat currentResolution;
gfx::Point currentScrollOffset, lastScrollOffset;
{
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);
}
nsEventStatus status;
switch (aEvent.eventStructType) {
case NS_TOUCH_EVENT: {
@ -244,21 +256,9 @@ AsyncPanZoomController::ReceiveMainThreadInputEvent(const nsInputEvent& aEvent)
break;
}
return status;
}
void
AsyncPanZoomController::ApplyZoomCompensationToEvent(nsInputEvent* aEvent)
{
gfxFloat currentResolution;
{
MonitorAutoLock monitor(mMonitor);
currentResolution = CalculateResolution(mFrameMetrics).width;
}
switch (aEvent->eventStructType) {
switch (aEvent.eventStructType) {
case NS_TOUCH_EVENT: {
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aOutEvent);
const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
for (uint32_t i = 0; i < touches.Length(); ++i) {
nsIDOMTouch* touch = touches[i];
@ -273,12 +273,14 @@ AsyncPanZoomController::ApplyZoomCompensationToEvent(nsInputEvent* aEvent)
}
default: {
gfx::Point refPoint = WidgetSpaceToCompensatedViewportSpace(
gfx::Point(aEvent->refPoint.x, aEvent->refPoint.y),
gfx::Point(aOutEvent->refPoint.x, aOutEvent->refPoint.y),
currentResolution);
aEvent->refPoint = nsIntPoint(refPoint.x, refPoint.y);
aOutEvent->refPoint = nsIntPoint(refPoint.x, refPoint.y);
break;
}
}
return status;
}
nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent) {

View File

@ -92,22 +92,17 @@ public:
nsEventStatus ReceiveInputEvent(const InputData& aEvent);
/**
* Special handler for nsInputEvents. |aEvent| is in screen relative
* co-ordinates.
* Special handler for nsInputEvents. Also sets |aOutEvent| (which is assumed
* to be an already-existing instance of an nsInputEvent which may be an
* nsTouchEvent) to have its touch points in DOM space. This is so that the
* touches can be passed through the DOM and content can handle them.
*
* NOTE: This can only be called on the main thread. See widget/InputData.h
* for more information on why we have InputData and nsInputEvent separated.
* NOTE: Be careful of invoking the nsInputEvent variant. This can only be
* called on the main thread. See widget/InputData.h for more information on
* why we have InputData and nsInputEvent separated.
*/
nsEventStatus ReceiveMainThreadInputEvent(const nsInputEvent& aEvent);
/**
* Transform from frame relative co-ordinates to DOM relative co-ordinates.
* This method updates |aEvent| (which is assumed to be an already-existing
* instance of an nsInputEvent which may be an nsTouchEvent) to have its touch
* points in DOM space. This is so that the touches can be passed through the
* DOM and content can handle them.
*/
void ApplyZoomCompensationToEvent(nsInputEvent* aEvent);
nsEventStatus ReceiveInputEvent(const nsInputEvent& aEvent,
nsInputEvent* aOutEvent);
/**
* Updates the composition bounds, i.e. the dimensions of the final size of

View File

@ -781,18 +781,11 @@ RenderFrameParent::OwnerContentChanged(nsIContent* aContent)
}
void
RenderFrameParent::NotifyInputEvent(const nsInputEvent& aEvent)
RenderFrameParent::NotifyInputEvent(const nsInputEvent& aEvent,
nsInputEvent* aOutEvent)
{
if (mPanZoomController) {
mPanZoomController->ReceiveMainThreadInputEvent(aEvent);
}
}
void
RenderFrameParent::ApplyZoomCompensationToEvent(nsInputEvent* aEvent)
{
if (mPanZoomController) {
mPanZoomController->ApplyZoomCompensationToEvent(aEvent);
mPanZoomController->ReceiveInputEvent(aEvent, aOutEvent);
}
}

View File

@ -92,9 +92,8 @@ public:
void SetBackgroundColor(nscolor aColor) { mBackgroundColor = gfxRGBA(aColor); };
void NotifyInputEvent(const nsInputEvent& aEvent);
void ApplyZoomCompensationToEvent(nsInputEvent* aEvent);
void NotifyInputEvent(const nsInputEvent& aEvent,
nsInputEvent* aOutEvent);
void NotifyDimensionsChanged(int width, int height);