Bug 833795 - Use screen relative co-ordinates for gestures; r=drs
This commit is contained in:
@@ -637,6 +637,10 @@ TabParent::TryCapture(const nsGUIEvent& aEvent)
|
|||||||
{
|
{
|
||||||
MOZ_ASSERT(sEventCapturer == this && mEventCaptureDepth > 0);
|
MOZ_ASSERT(sEventCapturer == this && mEventCaptureDepth > 0);
|
||||||
|
|
||||||
|
if (mIsDestroyed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (aEvent.eventStructType != NS_TOUCH_EVENT) {
|
if (aEvent.eventStructType != NS_TOUCH_EVENT) {
|
||||||
// Only capture of touch events is implemented, for now.
|
// Only capture of touch events is implemented, for now.
|
||||||
return false;
|
return false;
|
||||||
@@ -657,6 +661,11 @@ TabParent::TryCapture(const nsGUIEvent& aEvent)
|
|||||||
return false;
|
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.
|
// Adjust the widget coordinates to be relative to our frame.
|
||||||
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||||
|
|
||||||
@@ -666,10 +675,15 @@ TabParent::TryCapture(const nsGUIEvent& aEvent)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsEventStateManager::MapEventCoordinatesForChildProcess(frameLoader, &event);
|
// Remove the frame offset and compensate for zoom.
|
||||||
|
nsEventStateManager::MapEventCoordinatesForChildProcess(frameLoader,
|
||||||
|
&event);
|
||||||
|
rfp->ApplyZoomCompensationToEvent(&event);
|
||||||
|
}
|
||||||
|
|
||||||
SendRealTouchEvent(event);
|
return (event.message == NS_TOUCH_MOVE) ?
|
||||||
return true;
|
PBrowserParent::SendRealTouchMoveEvent(event) :
|
||||||
|
PBrowserParent::SendRealTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -1381,7 +1395,8 @@ TabParent::MaybeForwardEventToRenderFrame(const nsInputEvent& aEvent,
|
|||||||
nsInputEvent* aOutEvent)
|
nsInputEvent* aOutEvent)
|
||||||
{
|
{
|
||||||
if (RenderFrameParent* rfp = GetRenderFrame()) {
|
if (RenderFrameParent* rfp = GetRenderFrame()) {
|
||||||
rfp->NotifyInputEvent(aEvent, aOutEvent);
|
rfp->NotifyInputEvent(aEvent);
|
||||||
|
rfp->ApplyZoomCompensationToEvent(aOutEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -225,20 +225,8 @@ WidgetSpaceToCompensatedViewportSpace(const gfx::Point& aPoint,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsEventStatus
|
nsEventStatus
|
||||||
AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent,
|
AsyncPanZoomController::ReceiveMainThreadInputEvent(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;
|
nsEventStatus status;
|
||||||
switch (aEvent.eventStructType) {
|
switch (aEvent.eventStructType) {
|
||||||
case NS_TOUCH_EVENT: {
|
case NS_TOUCH_EVENT: {
|
||||||
@@ -256,9 +244,21 @@ AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (aEvent.eventStructType) {
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AsyncPanZoomController::ApplyZoomCompensationToEvent(nsInputEvent* aEvent)
|
||||||
|
{
|
||||||
|
gfxFloat currentResolution;
|
||||||
|
{
|
||||||
|
MonitorAutoLock monitor(mMonitor);
|
||||||
|
currentResolution = CalculateResolution(mFrameMetrics).width;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (aEvent->eventStructType) {
|
||||||
case NS_TOUCH_EVENT: {
|
case NS_TOUCH_EVENT: {
|
||||||
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aOutEvent);
|
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
|
||||||
const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
|
const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
|
||||||
for (uint32_t i = 0; i < touches.Length(); ++i) {
|
for (uint32_t i = 0; i < touches.Length(); ++i) {
|
||||||
nsIDOMTouch* touch = touches[i];
|
nsIDOMTouch* touch = touches[i];
|
||||||
@@ -273,14 +273,12 @@ AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent,
|
|||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
gfx::Point refPoint = WidgetSpaceToCompensatedViewportSpace(
|
gfx::Point refPoint = WidgetSpaceToCompensatedViewportSpace(
|
||||||
gfx::Point(aOutEvent->refPoint.x, aOutEvent->refPoint.y),
|
gfx::Point(aEvent->refPoint.x, aEvent->refPoint.y),
|
||||||
currentResolution);
|
currentResolution);
|
||||||
aOutEvent->refPoint = nsIntPoint(refPoint.x, refPoint.y);
|
aEvent->refPoint = nsIntPoint(refPoint.x, refPoint.y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent) {
|
nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent) {
|
||||||
|
|||||||
@@ -92,17 +92,22 @@ public:
|
|||||||
nsEventStatus ReceiveInputEvent(const InputData& aEvent);
|
nsEventStatus ReceiveInputEvent(const InputData& aEvent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special handler for nsInputEvents. Also sets |aOutEvent| (which is assumed
|
* Special handler for nsInputEvents. |aEvent| is in screen relative
|
||||||
* to be an already-existing instance of an nsInputEvent which may be an
|
* co-ordinates.
|
||||||
* 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: Be careful of invoking the nsInputEvent variant. This can only be
|
* NOTE: This can only be called on the main thread. See widget/InputData.h
|
||||||
* called on the main thread. See widget/InputData.h for more information on
|
* for more information on why we have InputData and nsInputEvent separated.
|
||||||
* why we have InputData and nsInputEvent separated.
|
|
||||||
*/
|
*/
|
||||||
nsEventStatus ReceiveInputEvent(const nsInputEvent& aEvent,
|
nsEventStatus ReceiveMainThreadInputEvent(const nsInputEvent& aEvent);
|
||||||
nsInputEvent* aOutEvent);
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the composition bounds, i.e. the dimensions of the final size of
|
* Updates the composition bounds, i.e. the dimensions of the final size of
|
||||||
|
|||||||
@@ -781,11 +781,18 @@ RenderFrameParent::OwnerContentChanged(nsIContent* aContent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RenderFrameParent::NotifyInputEvent(const nsInputEvent& aEvent,
|
RenderFrameParent::NotifyInputEvent(const nsInputEvent& aEvent)
|
||||||
nsInputEvent* aOutEvent)
|
|
||||||
{
|
{
|
||||||
if (mPanZoomController) {
|
if (mPanZoomController) {
|
||||||
mPanZoomController->ReceiveInputEvent(aEvent, aOutEvent);
|
mPanZoomController->ReceiveMainThreadInputEvent(aEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
RenderFrameParent::ApplyZoomCompensationToEvent(nsInputEvent* aEvent)
|
||||||
|
{
|
||||||
|
if (mPanZoomController) {
|
||||||
|
mPanZoomController->ApplyZoomCompensationToEvent(aEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,8 +92,9 @@ public:
|
|||||||
|
|
||||||
void SetBackgroundColor(nscolor aColor) { mBackgroundColor = gfxRGBA(aColor); };
|
void SetBackgroundColor(nscolor aColor) { mBackgroundColor = gfxRGBA(aColor); };
|
||||||
|
|
||||||
void NotifyInputEvent(const nsInputEvent& aEvent,
|
void NotifyInputEvent(const nsInputEvent& aEvent);
|
||||||
nsInputEvent* aOutEvent);
|
|
||||||
|
void ApplyZoomCompensationToEvent(nsInputEvent* aEvent);
|
||||||
|
|
||||||
void NotifyDimensionsChanged(int width, int height);
|
void NotifyDimensionsChanged(int width, int height);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user