Bug 1222943 (part 1) - Change Touch::mRadius from nsIntPoint to LayoutDeviceIntPoint. r=kats.

This adds a three missing unit conversions for touch radii.
This commit is contained in:
Nicholas Nethercote 2015-11-09 21:37:31 -08:00
parent 8f36fb2daa
commit 6474cc9afe
12 changed files with 41 additions and 38 deletions

View File

@ -150,7 +150,7 @@ nsCoreUtils::DispatchTouchEvent(EventMessage aMessage, int32_t aX, int32_t aY,
// XXX: Touch has an identifier of -1 to hint that it is synthesized.
RefPtr<dom::Touch> t = new dom::Touch(-1, LayoutDeviceIntPoint(aX, aY),
nsIntPoint(1, 1), 0.0f, 1.0f);
LayoutDeviceIntPoint(1, 1), 0.0f, 1.0f);
t->SetTarget(aContent);
event.touches.AppendElement(t);
nsEventStatus status = nsEventStatus_eIgnore;

View File

@ -951,11 +951,14 @@ nsDOMWindowUtils::SendTouchEventCommon(const nsAString& aType,
for (uint32_t i = 0; i < aCount; ++i) {
LayoutDeviceIntPoint pt =
nsContentUtils::ToWidgetPoint(CSSPoint(aXs[i], aYs[i]), offset, presContext);
RefPtr<Touch> t = new Touch(aIdentifiers[i],
pt,
nsIntPoint(aRxs[i], aRys[i]),
aRotationAngles[i],
aForces[i]);
LayoutDeviceIntPoint radius =
LayoutDeviceIntPoint::FromAppUnitsRounded(
CSSPoint::ToAppUnits(CSSPoint(aRxs[i], aRys[i])),
presContext->AppUnitsPerDevPixel());
RefPtr<Touch> t =
new Touch(aIdentifiers[i], pt, radius, aRotationAngles[i], aForces[i]);
event.touches.AppendElement(t);
}

View File

@ -10602,13 +10602,13 @@ nsIDocument::CreateTouch(nsIDOMWindow* aView,
float aForce)
{
RefPtr<Touch> touch = new Touch(aTarget,
aIdentifier,
aPageX, aPageY,
aScreenX, aScreenY,
aClientX, aClientY,
aRadiusX, aRadiusY,
aRotationAngle,
aForce);
aIdentifier,
aPageX, aPageY,
aScreenX, aScreenY,
aClientX, aClientY,
aRadiusX, aRadiusY,
aRotationAngle,
aForce);
return touch.forget();
}

View File

@ -48,7 +48,7 @@ Touch::Touch(EventTarget* aTarget,
Touch::Touch(int32_t aIdentifier,
LayoutDeviceIntPoint aPoint,
nsIntPoint aRadius,
LayoutDeviceIntPoint aRadius,
float aRotationAngle,
float aForce)
{

View File

@ -42,7 +42,7 @@ public:
float aForce);
Touch(int32_t aIdentifier,
LayoutDeviceIntPoint aPoint,
nsIntPoint aRadius,
LayoutDeviceIntPoint aRadius,
float aRotationAngle,
float aForce);
Touch(const Touch& aOther);
@ -82,7 +82,7 @@ public:
CSSIntPoint mPagePoint;
CSSIntPoint mClientPoint;
LayoutDeviceIntPoint mScreenPoint;
nsIntPoint mRadius;
LayoutDeviceIntPoint mRadius;
float mRotationAngle;
float mForce;
protected:

View File

@ -2878,11 +2878,13 @@ TabParent::InjectTouchEvent(const nsAString& aType,
CSSPoint::ToAppUnits(CSSPoint(aXs[i], aYs[i])),
presContext->AppUnitsPerDevPixel());
RefPtr<Touch> t = new Touch(aIdentifiers[i],
pt,
nsIntPoint(aRxs[i], aRys[i]),
aRotationAngles[i],
aForces[i]);
LayoutDeviceIntPoint radius =
LayoutDeviceIntPoint::FromAppUnitsRounded(
CSSPoint::ToAppUnits(CSSPoint(aRxs[i], aRys[i])),
presContext->AppUnitsPerDevPixel());
RefPtr<Touch> t =
new Touch(aIdentifiers[i], pt, radius, aRotationAngles[i], aForces[i]);
// Consider all injected touch events as changedTouches. For more details
// about the meaning of changedTouches for each event, see

View File

@ -145,7 +145,7 @@ public:
auto event = MakeUnique<WidgetTouchEvent>(true, aMessage, nullptr);
int32_t identifier = 0;
LayoutDeviceIntPoint point(aX, aY);
nsIntPoint radius(19, 19);
LayoutDeviceIntPoint radius(19, 19);
float rotationAngle = 0;
float force = 1;

View File

@ -21,10 +21,10 @@ already_AddRefed<Touch> SingleTouchData::ToNewDOMTouch() const
MOZ_ASSERT(NS_IsMainThread(),
"Can only create dom::Touch instances on main thread");
RefPtr<Touch> touch = new Touch(mIdentifier,
LayoutDeviceIntPoint(mScreenPoint.x, mScreenPoint.y),
nsIntPoint(mRadius.width, mRadius.height),
mRotationAngle,
mForce);
LayoutDeviceIntPoint(mScreenPoint.x, mScreenPoint.y),
LayoutDeviceIntPoint(mRadius.width, mRadius.height),
mRotationAngle,
mForce);
return touch.forget();
}

View File

@ -662,14 +662,14 @@ AndroidGeckoEvent::MakeTouchEvent(nsIWidget* widget)
LayoutDeviceIntPoint pt(
(Points()[i].x * scale.scale) - offset.x,
(Points()[i].y * scale.scale) - offset.y);
nsIntPoint radii(
LayoutDeviceIntPoint radius(
PointRadii()[i].x * scale.scale,
PointRadii()[i].y * scale.scale);
RefPtr<Touch> t = new Touch(PointIndicies()[i],
pt,
radii,
Orientations()[i],
Pressures()[i]);
pt,
radius,
Orientations()[i],
Pressures()[i]);
event.touches.AppendElement(t);
}

View File

@ -3411,7 +3411,8 @@ nsWindow::OnTouchEvent(GdkEventTouch* aEvent)
id = ++gLastTouchID & 0x7FFFFFFF;
}
touch = new dom::Touch(id, touchPoint, nsIntPoint(1,1), 0.0f, 0.0f);
touch = new dom::Touch(id, touchPoint, LayoutDeviceIntPoint(1, 1),
0.0f, 0.0f);
WidgetTouchEvent event(true, msg, this);
KeymapWrapper::InitInputEvent(event, aEvent->state);

View File

@ -323,7 +323,7 @@ struct ParamTraits<mozilla::WidgetTouchEvent>
for (uint32_t i = 0; i < numTouches; ++i) {
int32_t identifier;
mozilla::LayoutDeviceIntPoint refPoint;
nsIntPoint radius;
mozilla::LayoutDeviceIntPoint radius;
float rotationAngle;
float force;
if (!ReadParam(aMsg, aIter, &identifier) ||

View File

@ -173,6 +173,7 @@ private:
event.touches.SetCapacity(aTouches.count);
for (UITouch* touch in aTouches) {
LayoutDeviceIntPoint loc = UIKitPointsToDevPixels([touch locationInView:self], [self contentScaleFactor]);
LayoutDeviceIntPoint radius = UIKitPointsToDevPixels([touch majorRadius], [touch majorRadius]);
void* value;
if (!CFDictionaryGetValueIfPresent(mTouches, touch, (const void**)&value)) {
// This shouldn't happen.
@ -180,11 +181,7 @@ private:
continue;
}
int id = reinterpret_cast<int>(value);
RefPtr<Touch> t = new Touch(id,
loc,
nsIntPoint([touch majorRadius], [touch majorRadius]),
0.0f,
1.0f);
RefPtr<Touch> t = new Touch(id, loc, radius, 0.0f, 1.0f);
event.refPoint = loc;
event.touches.AppendElement(t);
}