Bug 1250505 - Convert SynthesizeNativeTouchPoint and SynthesizeNativeTouchTap to take a LayoutDeviceIntPoint instead of a ScreenPoint. r=njn

MozReview-Commit-ID: EybGq9b1B8Z

--HG--
extra : rebase_source : defc16fc066a3a40480fa4c94f3a742a267344a8
This commit is contained in:
Kartikaya Gupta 2016-04-15 06:39:36 -04:00
parent e8aa4cfeed
commit f72cd76655
17 changed files with 56 additions and 58 deletions

View File

@ -1097,10 +1097,10 @@ nsDOMWindowUtils::SendNativeTouchPoint(uint32_t aPointerId,
}
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
<uint32_t, nsIWidget::TouchPointerState, ScreenIntPoint, double, uint32_t, nsIObserver*>
<uint32_t, nsIWidget::TouchPointerState, LayoutDeviceIntPoint, double, uint32_t, nsIObserver*>
(widget, &nsIWidget::SynthesizeNativeTouchPoint, aPointerId,
(nsIWidget::TouchPointerState)aTouchState,
ScreenIntPoint(aScreenX, aScreenY),
LayoutDeviceIntPoint(aScreenX, aScreenY),
aPressure, aOrientation, aObserver));
return NS_OK;
}
@ -1117,9 +1117,9 @@ nsDOMWindowUtils::SendNativeTouchTap(int32_t aScreenX,
}
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
<ScreenIntPoint, bool, nsIObserver*>
<LayoutDeviceIntPoint, bool, nsIObserver*>
(widget, &nsIWidget::SynthesizeNativeTouchTap,
ScreenIntPoint(aScreenX, aScreenY), aLongTap, aObserver));
LayoutDeviceIntPoint(aScreenX, aScreenY), aLongTap, aObserver));
return NS_OK;
}

View File

@ -462,11 +462,11 @@ parent:
uint64_t aObserverId);
async SynthesizeNativeTouchPoint(uint32_t aPointerId,
TouchPointerState aPointerState,
ScreenIntPoint aPointerScreenPoint,
LayoutDeviceIntPoint aPoint,
double aPointerPressure,
uint32_t aPointerOrientation,
uint64_t aObserverId);
async SynthesizeNativeTouchTap(ScreenIntPoint aPointerScreenPoint,
async SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint,
bool aLongTap,
uint64_t aObserverId);
async ClearNativeTouchSequence(uint64_t aObserverId);

View File

@ -1462,7 +1462,7 @@ TabParent::RecvSynthesizeNativeMouseScrollEvent(const LayoutDeviceIntPoint& aPoi
bool
TabParent::RecvSynthesizeNativeTouchPoint(const uint32_t& aPointerId,
const TouchPointerState& aPointerState,
const ScreenIntPoint& aPointerScreenPoint,
const LayoutDeviceIntPoint& aPoint,
const double& aPointerPressure,
const uint32_t& aPointerOrientation,
const uint64_t& aObserverId)
@ -1470,22 +1470,21 @@ TabParent::RecvSynthesizeNativeTouchPoint(const uint32_t& aPointerId,
AutoSynthesizedEventResponder responder(this, aObserverId, "touchpoint");
nsCOMPtr<nsIWidget> widget = GetWidget();
if (widget) {
widget->SynthesizeNativeTouchPoint(aPointerId, aPointerState, aPointerScreenPoint,
widget->SynthesizeNativeTouchPoint(aPointerId, aPointerState, aPoint,
aPointerPressure, aPointerOrientation, responder.GetObserver());
}
return true;
}
bool
TabParent::RecvSynthesizeNativeTouchTap(const ScreenIntPoint& aPointerScreenPoint,
TabParent::RecvSynthesizeNativeTouchTap(const LayoutDeviceIntPoint& aPoint,
const bool& aLongTap,
const uint64_t& aObserverId)
{
AutoSynthesizedEventResponder responder(this, aObserverId, "touchtap");
nsCOMPtr<nsIWidget> widget = GetWidget();
if (widget) {
widget->SynthesizeNativeTouchTap(aPointerScreenPoint, aLongTap,
responder.GetObserver());
widget->SynthesizeNativeTouchTap(aPoint, aLongTap, responder.GetObserver());
}
return true;
}

View File

@ -397,13 +397,13 @@ public:
virtual bool
RecvSynthesizeNativeTouchPoint(const uint32_t& aPointerId,
const TouchPointerState& aPointerState,
const ScreenIntPoint& aPointerScreenPoint,
const LayoutDeviceIntPoint& aPoint,
const double& aPointerPressure,
const uint32_t& aPointerOrientation,
const uint64_t& aObserverId) override;
virtual bool
RecvSynthesizeNativeTouchTap(const ScreenIntPoint& aPointerScreenPoint,
RecvSynthesizeNativeTouchTap(const LayoutDeviceIntPoint& aPoint,
const bool& aLongTap,
const uint64_t& aObserverId) override;

View File

@ -450,7 +450,7 @@ PuppetWidget::SynthesizeNativeMouseScrollEvent(mozilla::LayoutDeviceIntPoint aPo
nsresult
PuppetWidget::SynthesizeNativeTouchPoint(uint32_t aPointerId,
TouchPointerState aPointerState,
ScreenIntPoint aPointerScreenPoint,
LayoutDeviceIntPoint aPoint,
double aPointerPressure,
uint32_t aPointerOrientation,
nsIObserver* aObserver)
@ -460,13 +460,13 @@ PuppetWidget::SynthesizeNativeTouchPoint(uint32_t aPointerId,
return NS_ERROR_FAILURE;
}
mTabChild->SendSynthesizeNativeTouchPoint(aPointerId, aPointerState,
aPointerScreenPoint, aPointerPressure, aPointerOrientation,
aPoint, aPointerPressure, aPointerOrientation,
notifier.SaveObserver());
return NS_OK;
}
nsresult
PuppetWidget::SynthesizeNativeTouchTap(ScreenIntPoint aPointerScreenPoint,
PuppetWidget::SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint,
bool aLongTap,
nsIObserver* aObserver)
{
@ -474,7 +474,7 @@ PuppetWidget::SynthesizeNativeTouchTap(ScreenIntPoint aPointerScreenPoint,
if (!mTabChild) {
return NS_ERROR_FAILURE;
}
mTabChild->SendSynthesizeNativeTouchTap(aPointerScreenPoint, aLongTap,
mTabChild->SendSynthesizeNativeTouchTap(aPoint, aLongTap,
notifier.SaveObserver());
return NS_OK;
}

View File

@ -240,11 +240,11 @@ public:
nsIObserver* aObserver) override;
virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
TouchPointerState aPointerState,
ScreenIntPoint aPointerScreenPoint,
LayoutDeviceIntPoint aPoint,
double aPointerPressure,
uint32_t aPointerOrientation,
nsIObserver* aObserver) override;
virtual nsresult SynthesizeNativeTouchTap(ScreenIntPoint aPointerScreenPoint,
virtual nsresult SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint,
bool aLongTap,
nsIObserver* aObserver) override;
virtual nsresult ClearNativeTouchSequence(nsIObserver* aObserver) override;

View File

@ -3369,7 +3369,7 @@ nsWindow::GetIMEUpdatePreference()
nsresult
nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
TouchPointerState aPointerState,
ScreenIntPoint aPointerScreenPoint,
LayoutDeviceIntPoint aPoint,
double aPointerPressure,
uint32_t aPointerOrientation,
nsIObserver* aObserver)
@ -3398,8 +3398,7 @@ nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
MOZ_ASSERT(mGLControllerSupport);
GeckoLayerClient::LocalRef client = mGLControllerSupport->GetLayerClient();
client->SynthesizeNativeTouchPoint(aPointerId, eventType,
aPointerScreenPoint.x, aPointerScreenPoint.y, aPointerPressure,
aPointerOrientation);
aPoint.x, aPoint.y, aPointerPressure, aPointerOrientation);
return NS_OK;
}

View File

@ -190,7 +190,7 @@ public:
nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
TouchPointerState aPointerState,
ScreenIntPoint aPointerScreenPoint,
LayoutDeviceIntPoint aPoint,
double aPointerPressure,
uint32_t aPointerOrientation,
nsIObserver* aObserver) override;

View File

@ -255,7 +255,7 @@ private:
nsresult
nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
TouchPointerState aPointerState,
ScreenIntPoint aPointerScreenPoint,
LayoutDeviceIntPoint aPoint,
double aPointerPressure,
uint32_t aPointerOrientation,
nsIObserver* aObserver)
@ -270,6 +270,9 @@ nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
mSynthesizedTouchInput = new MultiTouchInput();
}
ScreenIntPoint pointerScreenPoint = ViewAs<ScreenPixel>(aPoint,
PixelCastJustification::LayoutDeviceIsScreenForBounds);
// We can't dispatch mSynthesizedTouchInput directly because (a) dispatching
// it might inadvertently modify it and (b) in the case of touchend or
// touchcancel events mSynthesizedTouchInput will hold the touches that are
@ -283,7 +286,7 @@ nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
if (index >= 0) {
// found an existing touch point, update it
SingleTouchData& point = mSynthesizedTouchInput->mTouches[index];
point.mScreenPoint = aPointerScreenPoint;
point.mScreenPoint = pointerScreenPoint;
point.mRotationAngle = (float)aPointerOrientation;
point.mForce = (float)aPointerPressure;
inputToDispatch.mType = MultiTouchInput::MULTITOUCH_MOVE;
@ -291,7 +294,7 @@ nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
// new touch point, add it
mSynthesizedTouchInput->mTouches.AppendElement(SingleTouchData(
(int32_t)aPointerId,
aPointerScreenPoint,
pointerScreenPoint,
ScreenSize(0, 0),
(float)aPointerOrientation,
(float)aPointerPressure));
@ -309,7 +312,7 @@ nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
: MultiTouchInput::MULTITOUCH_CANCEL);
inputToDispatch.mTouches.AppendElement(SingleTouchData(
(int32_t)aPointerId,
aPointerScreenPoint,
pointerScreenPoint,
ScreenSize(0, 0),
(float)aPointerOrientation,
(float)aPointerPressure));

View File

@ -89,7 +89,7 @@ public:
nsEventStatus& aStatus);
virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
TouchPointerState aPointerState,
ScreenIntPoint aPointerScreenPoint,
LayoutDeviceIntPoint aPoint,
double aPointerPressure,
uint32_t aPointerOrientation,
nsIObserver* aObserver) override;

View File

@ -6876,7 +6876,7 @@ nsWindow::SynthesizeNativeMouseScrollEvent(mozilla::LayoutDeviceIntPoint aPoint,
nsresult
nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
TouchPointerState aPointerState,
ScreenIntPoint aPointerScreenPoint,
LayoutDeviceIntPoint aPoint,
double aPointerPressure,
uint32_t aPointerOrientation,
nsIObserver* aObserver)
@ -6938,13 +6938,10 @@ nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
GdkDeviceManager* device_manager = gdk_display_get_device_manager(display);
event.touch.device = gdk_device_manager_get_client_pointer(device_manager);
event.touch.x_root = DevicePixelsToGdkCoordRoundDown(aPointerScreenPoint.x);
event.touch.y_root = DevicePixelsToGdkCoordRoundDown(aPointerScreenPoint.y);
event.touch.x_root = DevicePixelsToGdkCoordRoundDown(aPoint.x);
event.touch.y_root = DevicePixelsToGdkCoordRoundDown(aPoint.y);
LayoutDeviceIntPoint pointInWindow =
ViewAs<LayoutDevicePixel>(aPointerScreenPoint,
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent)
- WidgetToScreenOffset();
LayoutDeviceIntPoint pointInWindow = aPoint - WidgetToScreenOffset();
event.touch.x = DevicePixelsToGdkCoordRoundDown(pointInWindow.x);
event.touch.y = DevicePixelsToGdkCoordRoundDown(pointInWindow.y);

View File

@ -347,7 +347,7 @@ public:
#if GTK_CHECK_VERSION(3,4,0)
virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
TouchPointerState aPointerState,
ScreenIntPoint aPointerScreenPoint,
LayoutDeviceIntPoint aPoint,
double aPointerPressure,
uint32_t aPointerOrientation,
nsIObserver* aObserver) override;

View File

@ -1922,7 +1922,7 @@ nsBaseWidget::GetWidgetScreen()
}
nsresult
nsIWidget::SynthesizeNativeTouchTap(ScreenIntPoint aPointerScreenPoint, bool aLongTap,
nsIWidget::SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint, bool aLongTap,
nsIObserver* aObserver)
{
AutoObserverNotifier notifier(aObserver, "touchtap");
@ -1933,14 +1933,14 @@ nsIWidget::SynthesizeNativeTouchTap(ScreenIntPoint aPointerScreenPoint, bool aLo
int pointerId = sPointerIdCounter;
sPointerIdCounter++;
nsresult rv = SynthesizeNativeTouchPoint(pointerId, TOUCH_CONTACT,
aPointerScreenPoint, 1.0, 90, nullptr);
aPoint, 1.0, 90, nullptr);
if (NS_FAILED(rv)) {
return rv;
}
if (!aLongTap) {
nsresult rv = SynthesizeNativeTouchPoint(pointerId, TOUCH_REMOVE,
aPointerScreenPoint, 0, 0, nullptr);
aPoint, 0, 0, nullptr);
return rv;
}
@ -1951,7 +1951,7 @@ nsIWidget::SynthesizeNativeTouchTap(ScreenIntPoint aPointerScreenPoint, bool aLo
mLongTapTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
SynthesizeNativeTouchPoint(pointerId, TOUCH_CANCEL,
aPointerScreenPoint, 0, 0, nullptr);
aPoint, 0, 0, nullptr);
return NS_ERROR_UNEXPECTED;
}
// Windows requires recuring events, so we set this to a smaller window
@ -1972,7 +1972,7 @@ nsIWidget::SynthesizeNativeTouchTap(ScreenIntPoint aPointerScreenPoint, bool aLo
mLongTapTouchPoint->mPosition, 0, 0, nullptr);
}
mLongTapTouchPoint = new LongTapInfo(pointerId, aPointerScreenPoint,
mLongTapTouchPoint = new LongTapInfo(pointerId, aPoint,
TimeDuration::FromMilliseconds(elapse),
aObserver);
notifier.SkipNotification(); // we'll do it in the long-tap callback

View File

@ -423,7 +423,7 @@ protected:
virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
TouchPointerState aPointerState,
ScreenIntPoint aPointerScreenPoint,
LayoutDeviceIntPoint aPoint,
double aPointerPressure,
uint32_t aPointerOrientation,
nsIObserver* aObserver) override

View File

@ -1686,7 +1686,7 @@ class nsIWidget : public nsISupports {
*
* @param aPointerId The touch point id to create or update.
* @param aPointerState one or more of the touch states listed above
* @param aScreenX, aScreenY screen coords of this event
* @param aPoint coords of this event
* @param aPressure 0.0 -> 1.0 float val indicating pressure
* @param aOrientation 0 -> 359 degree value indicating the
* orientation of the pointer. Use 90 for normal taps.
@ -1695,7 +1695,7 @@ class nsIWidget : public nsISupports {
*/
virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
TouchPointerState aPointerState,
ScreenIntPoint aPointerScreenPoint,
LayoutDeviceIntPoint aPoint,
double aPointerPressure,
uint32_t aPointerOrientation,
nsIObserver* aObserver) = 0;
@ -1708,7 +1708,7 @@ class nsIWidget : public nsISupports {
* @param aObserver The observer that will get notified once the events
* have been dispatched.
*/
virtual nsresult SynthesizeNativeTouchTap(ScreenIntPoint aPointerScreenPoint,
virtual nsresult SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint,
bool aLongTap,
nsIObserver* aObserver);
@ -1727,7 +1727,7 @@ private:
class LongTapInfo
{
public:
LongTapInfo(int32_t aPointerId, ScreenIntPoint& aPoint,
LongTapInfo(int32_t aPointerId, LayoutDeviceIntPoint& aPoint,
mozilla::TimeDuration aDuration,
nsIObserver* aObserver) :
mPointerId(aPointerId),
@ -1739,7 +1739,7 @@ private:
}
int32_t mPointerId;
ScreenIntPoint mPosition;
LayoutDeviceIntPoint mPosition;
mozilla::TimeDuration mDuration;
nsCOMPtr<nsIObserver> mObserver;
mozilla::TimeStamp mStamp;

View File

@ -70,7 +70,7 @@ nsWindowBase::InitTouchInjection()
}
bool
nsWindowBase::InjectTouchPoint(uint32_t aId, ScreenIntPoint& aPointerScreenPoint,
nsWindowBase::InjectTouchPoint(uint32_t aId, LayoutDeviceIntPoint& aPoint,
POINTER_FLAGS aFlags, uint32_t aPressure,
uint32_t aOrientation)
{
@ -90,8 +90,8 @@ nsWindowBase::InjectTouchPoint(uint32_t aId, ScreenIntPoint& aPointerScreenPoint
info.pointerInfo.pointerFlags = aFlags;
info.pointerInfo.pointerType = PT_TOUCH;
info.pointerInfo.pointerId = aId;
info.pointerInfo.ptPixelLocation.x = aPointerScreenPoint.x;
info.pointerInfo.ptPixelLocation.y = aPointerScreenPoint.y;
info.pointerInfo.ptPixelLocation.x = aPoint.x;
info.pointerInfo.ptPixelLocation.y = aPoint.y;
info.rcContact.top = info.pointerInfo.ptPixelLocation.y - 2;
info.rcContact.bottom = info.pointerInfo.ptPixelLocation.y + 2;
@ -119,7 +119,7 @@ void nsWindowBase::ChangedDPI()
nsresult
nsWindowBase::SynthesizeNativeTouchPoint(uint32_t aPointerId,
nsIWidget::TouchPointerState aPointerState,
ScreenIntPoint aPointerScreenPoint,
LayoutDeviceIntPoint aPoint,
double aPointerPressure,
uint32_t aPointerOrientation,
nsIObserver* aObserver)
@ -160,7 +160,7 @@ nsWindowBase::SynthesizeNativeTouchPoint(uint32_t aPointerId,
flags |= POINTER_FLAG_CANCELED;
}
return !InjectTouchPoint(aPointerId, aPointerScreenPoint, flags,
return !InjectTouchPoint(aPointerId, aPoint, flags,
pressure, aPointerOrientation) ?
NS_ERROR_UNEXPECTED : NS_OK;
}
@ -171,7 +171,7 @@ nsWindowBase::SynthesizeNativeTouchPoint(uint32_t aPointerId,
}
// Create a new pointer
info = new PointerInfo(aPointerId, aPointerScreenPoint);
info = new PointerInfo(aPointerId, aPoint);
POINTER_FLAGS flags = POINTER_FLAG_INRANGE;
if (contact) {
@ -179,7 +179,7 @@ nsWindowBase::SynthesizeNativeTouchPoint(uint32_t aPointerId,
}
mActivePointers.Put(aPointerId, info);
return !InjectTouchPoint(aPointerId, aPointerScreenPoint, flags,
return !InjectTouchPoint(aPointerId, aPoint, flags,
pressure, aPointerOrientation) ?
NS_ERROR_UNEXPECTED : NS_OK;
}

View File

@ -90,7 +90,7 @@ public:
*/
virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
TouchPointerState aPointerState,
ScreenIntPoint aPointerScreenPoint,
LayoutDeviceIntPoint aPoint,
double aPointerPressure,
uint32_t aPointerOrientation,
nsIObserver* aObserver) override;
@ -108,21 +108,21 @@ protected:
void ChangedDPI();
static bool InitTouchInjection();
bool InjectTouchPoint(uint32_t aId, ScreenIntPoint& aPointerScreenPoint,
bool InjectTouchPoint(uint32_t aId, LayoutDeviceIntPoint& aPoint,
POINTER_FLAGS aFlags, uint32_t aPressure = 1024,
uint32_t aOrientation = 90);
class PointerInfo
{
public:
PointerInfo(int32_t aPointerId, ScreenIntPoint& aPoint) :
PointerInfo(int32_t aPointerId, LayoutDeviceIntPoint& aPoint) :
mPointerId(aPointerId),
mPosition(aPoint)
{
}
int32_t mPointerId;
ScreenIntPoint mPosition;
LayoutDeviceIntPoint mPosition;
};
nsClassHashtable<nsUint32HashKey, PointerInfo> mActivePointers;