Bug 896251 - Make nsEvent::{refPoint, lastRefPoint} LayoutDeviceIntPoints; r=smaug+kats

This commit is contained in:
Ms2ger 2013-08-02 09:05:16 +02:00
parent 047e8751d6
commit 78f9e66db8
35 changed files with 202 additions and 166 deletions

View File

@ -41,6 +41,8 @@
#include "nsITreeBoxObject.h"
#include "nsITreeColumns.h"
using namespace mozilla;
////////////////////////////////////////////////////////////////////////////////
// nsCoreUtils
////////////////////////////////////////////////////////////////////////////////
@ -130,7 +132,7 @@ nsCoreUtils::DispatchMouseEvent(uint32_t aEventType, int32_t aX, int32_t aY,
nsMouseEvent event(true, aEventType, aRootWidget,
nsMouseEvent::eReal, nsMouseEvent::eNormal);
event.refPoint = nsIntPoint(aX, aY);
event.refPoint = LayoutDeviceIntPoint(aX, aY);
event.clickCount = 1;
event.button = nsMouseEvent::eLeftButton;

View File

@ -840,7 +840,7 @@ Accessible::ChildAtPoint(int32_t aX, int32_t aY,
nsMouseEvent dummyEvent(true, NS_MOUSE_MOVE, rootWidget,
nsMouseEvent::eSynthesized);
dummyEvent.refPoint = nsIntPoint(aX - rootRect.x, aY - rootRect.y);
dummyEvent.refPoint = LayoutDeviceIntPoint(aX - rootRect.x, aY - rootRect.y);
nsIFrame* popupFrame = nsLayoutUtils::
GetPopupFrameForEventCoordinates(accDocument->PresContext()->GetRootPresContext(),

View File

@ -134,15 +134,14 @@ Touch::InitializePoints(nsPresContext* aPresContext, nsEvent* aEvent)
if (mPointsInitialized) {
return;
}
mClientPoint = nsDOMEvent::GetClientCoords(aPresContext,
aEvent,
mRefPoint,
mClientPoint);
mPagePoint = nsDOMEvent::GetPageCoords(aPresContext,
aEvent,
mRefPoint,
mClientPoint);
mScreenPoint = nsDOMEvent::GetScreenCoords(aPresContext, aEvent, mRefPoint);
mClientPoint = nsDOMEvent::GetClientCoords(
aPresContext, aEvent, LayoutDeviceIntPoint::FromUntyped(mRefPoint),
mClientPoint);
mPagePoint = nsDOMEvent::GetPageCoords(
aPresContext, aEvent, LayoutDeviceIntPoint::FromUntyped(mRefPoint),
mClientPoint);
mScreenPoint = nsDOMEvent::GetScreenCoords(aPresContext, aEvent,
LayoutDeviceIntPoint::FromUntyped(mRefPoint));
mPointsInitialized = true;
}

View File

@ -29,6 +29,7 @@
#include "mozilla/dom/Element.h"
#include <algorithm>
using namespace mozilla;
using namespace mozilla::dom;
/******************************************************************/
@ -832,8 +833,8 @@ nsContentEventHandler::OnQueryCharacterAtPoint(nsQueryContentEvent* aEvent)
rootWidget);
eventOnRoot.refPoint = aEvent->refPoint;
if (rootWidget != aEvent->widget) {
eventOnRoot.refPoint += aEvent->widget->WidgetToScreenOffset();
eventOnRoot.refPoint -= rootWidget->WidgetToScreenOffset();
eventOnRoot.refPoint += LayoutDeviceIntPoint::FromUntyped(
aEvent->widget->WidgetToScreenOffset() - rootWidget->WidgetToScreenOffset());
}
nsPoint ptInRoot =
nsLayoutUtils::GetEventCoordinatesRelativeTo(&eventOnRoot, rootFrame);
@ -891,16 +892,15 @@ nsContentEventHandler::OnQueryDOMWidgetHittest(nsQueryContentEvent* aEvent)
nsIFrame* docFrame = mPresShell->GetRootFrame();
NS_ENSURE_TRUE(docFrame, NS_ERROR_FAILURE);
nsIntPoint eventLoc =
aEvent->refPoint + aEvent->widget->WidgetToScreenOffset();
LayoutDeviceIntPoint eventLoc = aEvent->refPoint +
LayoutDeviceIntPoint::FromUntyped(aEvent->widget->WidgetToScreenOffset());
nsIntRect docFrameRect = docFrame->GetScreenRect(); // Returns CSS pixels
eventLoc.x = mPresContext->DevPixelsToIntCSSPixels(eventLoc.x);
eventLoc.y = mPresContext->DevPixelsToIntCSSPixels(eventLoc.y);
eventLoc.x -= docFrameRect.x;
eventLoc.y -= docFrameRect.y;
CSSIntPoint eventLocCSS(
mPresContext->DevPixelsToIntCSSPixels(eventLoc.x) - docFrameRect.x,
mPresContext->DevPixelsToIntCSSPixels(eventLoc.y) - docFrameRect.y);
Element* contentUnderMouse =
doc->ElementFromPointHelper(eventLoc.x, eventLoc.y, false, false);
doc->ElementFromPointHelper(eventLocCSS.x, eventLocCSS.y, false, false);
if (contentUnderMouse) {
nsIWidget* targetWidget = nullptr;
nsIFrame* targetFrame = contentUnderMouse->GetPrimaryFrame();

View File

@ -1063,7 +1063,7 @@ nsDOMEvent::Shutdown()
nsIntPoint
nsDOMEvent::GetScreenCoords(nsPresContext* aPresContext,
nsEvent* aEvent,
nsIntPoint aPoint)
LayoutDeviceIntPoint aPoint)
{
if (nsEventStateManager::sIsPointerLocked) {
return nsEventStateManager::sLastScreenPoint;
@ -1081,10 +1081,11 @@ nsDOMEvent::GetScreenCoords(nsPresContext* aPresContext,
nsGUIEvent* guiEvent = static_cast<nsGUIEvent*>(aEvent);
if (!guiEvent->widget) {
return aPoint;
return LayoutDeviceIntPoint::ToUntyped(aPoint);
}
nsIntPoint offset = aPoint + guiEvent->widget->WidgetToScreenOffset();
LayoutDeviceIntPoint offset = aPoint +
LayoutDeviceIntPoint::FromUntyped(guiEvent->widget->WidgetToScreenOffset());
nscoord factor = aPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
@ -1094,7 +1095,7 @@ nsDOMEvent::GetScreenCoords(nsPresContext* aPresContext,
CSSIntPoint
nsDOMEvent::GetPageCoords(nsPresContext* aPresContext,
nsEvent* aEvent,
nsIntPoint aPoint,
LayoutDeviceIntPoint aPoint,
CSSIntPoint aDefaultPoint)
{
CSSIntPoint pagePoint = nsDOMEvent::GetClientCoords(aPresContext,
@ -1118,7 +1119,7 @@ nsDOMEvent::GetPageCoords(nsPresContext* aPresContext,
CSSIntPoint
nsDOMEvent::GetClientCoords(nsPresContext* aPresContext,
nsEvent* aEvent,
nsIntPoint aPoint,
LayoutDeviceIntPoint aPoint,
CSSIntPoint aDefaultPoint)
{
if (nsEventStateManager::sIsPointerLocked) {
@ -1147,7 +1148,8 @@ nsDOMEvent::GetClientCoords(nsPresContext* aPresContext,
return CSSIntPoint(0, 0);
}
nsPoint pt =
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, aPoint, rootFrame);
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
LayoutDeviceIntPoint::ToUntyped(aPoint), rootFrame);
return CSSIntPoint::FromAppUnitsRounded(pt);
}

View File

@ -102,13 +102,15 @@ public:
static const char* GetEventName(uint32_t aEventType);
static mozilla::CSSIntPoint
GetClientCoords(nsPresContext* aPresContext, nsEvent* aEvent,
nsIntPoint aPoint, mozilla::CSSIntPoint aDefaultPoint);
mozilla::LayoutDeviceIntPoint aPoint,
mozilla::CSSIntPoint aDefaultPoint);
static mozilla::CSSIntPoint
GetPageCoords(nsPresContext* aPresContext, nsEvent* aEvent, nsIntPoint aPoint,
GetPageCoords(nsPresContext* aPresContext, nsEvent* aEvent,
mozilla::LayoutDeviceIntPoint aPoint,
mozilla::CSSIntPoint aDefaultPoint);
static nsIntPoint GetScreenCoords(nsPresContext* aPresContext,
nsEvent* aEvent,
nsIntPoint aPoint);
static nsIntPoint
GetScreenCoords(nsPresContext* aPresContext, nsEvent* aEvent,
mozilla::LayoutDeviceIntPoint aPoint);
static already_AddRefed<nsDOMEvent> Constructor(const mozilla::dom::GlobalObject& aGlobal,
const nsAString& aType,

View File

@ -102,7 +102,8 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMUIEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
static nsIntPoint
DevPixelsToCSSPixels(const nsIntPoint& aPoint, nsPresContext* aContext)
DevPixelsToCSSPixels(const LayoutDeviceIntPoint& aPoint,
nsPresContext* aContext)
{
return nsIntPoint(aContext->DevPixelsToIntCSSPixels(aPoint.x),
aContext->DevPixelsToIntCSSPixels(aPoint.y));
@ -375,7 +376,7 @@ nsDOMUIEvent::DuplicatePrivateData()
mEvent->refPoint);
nsresult rv = nsDOMEvent::DuplicatePrivateData();
if (NS_SUCCEEDED(rv)) {
mEvent->refPoint = screenPoint;
mEvent->refPoint = LayoutDeviceIntPoint::FromUntyped(screenPoint);
}
return rv;
}

View File

@ -34,8 +34,8 @@ public:
NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) MOZ_OVERRIDE;
NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, void** aIter) MOZ_OVERRIDE;
static nsIntPoint CalculateScreenPoint(nsPresContext* aPresContext,
nsEvent* aEvent)
static nsIntPoint
CalculateScreenPoint(nsPresContext* aPresContext, nsEvent* aEvent)
{
if (!aEvent ||
(aEvent->eventStructType != NS_MOUSE_EVENT &&
@ -46,12 +46,13 @@ public:
return nsIntPoint(0, 0);
}
if (!((nsGUIEvent*)aEvent)->widget ) {
return aEvent->refPoint;
nsGUIEvent* event = static_cast<nsGUIEvent*>(aEvent);
if (!event->widget) {
return mozilla::LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint);
}
nsIntPoint offset = aEvent->refPoint +
((nsGUIEvent*)aEvent)->widget->WidgetToScreenOffset();
mozilla::LayoutDeviceIntPoint offset = aEvent->refPoint +
mozilla::LayoutDeviceIntPoint::FromUntyped(event->widget->WidgetToScreenOffset());
nscoord factor = aPresContext->DeviceContext()->UnscaledAppUnitsPerDevPixel();
return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));

View File

@ -109,7 +109,7 @@ using namespace mozilla::dom;
#define NS_USER_INTERACTION_INTERVAL 5000 // ms
static const nsIntPoint kInvalidRefPoint = nsIntPoint(-1,-1);
static const LayoutDeviceIntPoint kInvalidRefPoint = LayoutDeviceIntPoint(-1,-1);
static bool sLeftClickOnly = true;
static bool sKeyCausesActivation = true;
@ -120,9 +120,9 @@ bool nsEventStateManager::sNormalLMouseEventInProcess = false;
nsEventStateManager* nsEventStateManager::sActiveESM = nullptr;
nsIDocument* nsEventStateManager::sMouseOverDocument = nullptr;
nsWeakFrame nsEventStateManager::sLastDragOverFrame = nullptr;
nsIntPoint nsEventStateManager::sLastRefPoint = kInvalidRefPoint;
nsIntPoint nsEventStateManager::sLastScreenPoint = nsIntPoint(0,0);
nsIntPoint nsEventStateManager::sSynthCenteringPoint = kInvalidRefPoint;
LayoutDeviceIntPoint nsEventStateManager::sLastRefPoint = kInvalidRefPoint;
nsIntPoint nsEventStateManager::sLastScreenPoint = nsIntPoint(0, 0);
LayoutDeviceIntPoint nsEventStateManager::sSynthCenteringPoint = kInvalidRefPoint;
CSSIntPoint nsEventStateManager::sLastClientPoint = CSSIntPoint(0, 0);
bool nsEventStateManager::sIsPointerLocked = false;
// Reference to the pointer locked element.
@ -567,7 +567,8 @@ nsMouseWheelTransaction::GetScreenPoint(nsGUIEvent* aEvent)
{
NS_ASSERTION(aEvent, "aEvent is null");
NS_ASSERTION(aEvent->widget, "aEvent-widget is null");
return aEvent->refPoint + aEvent->widget->WidgetToScreenOffset();
return LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint) +
aEvent->widget->WidgetToScreenOffset();
}
uint32_t
@ -1547,11 +1548,10 @@ nsEventStateManager::GetChildProcessOffset(nsFrameLoader* aFrameLoader,
nsEventStateManager::MapEventCoordinatesForChildProcess(
const LayoutDeviceIntPoint& aOffset, nsEvent* aEvent)
{
nsIntPoint aOffsetIntPoint(aOffset.x, aOffset.y);
if (aEvent->eventStructType != NS_TOUCH_EVENT) {
aEvent->refPoint = aOffsetIntPoint;
aEvent->refPoint = aOffset;
} else {
aEvent->refPoint = nsIntPoint();
aEvent->refPoint = LayoutDeviceIntPoint();
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
// Then offset all the touch points by that distance, to put them
// in the space where top-left is 0,0.
@ -1559,7 +1559,7 @@ nsEventStateManager::MapEventCoordinatesForChildProcess(
for (uint32_t i = 0; i < touches.Length(); ++i) {
nsIDOMTouch* touch = touches[i];
if (touch) {
touch->mRefPoint += aOffsetIntPoint;
touch->mRefPoint += LayoutDeviceIntPoint::ToUntyped(aOffset);
}
}
}
@ -1921,7 +1921,7 @@ nsEventStateManager::BeginTrackingDragGesture(nsPresContext* aPresContext,
// Note that |inDownEvent| could be either a mouse down event or a
// synthesized mouse move event.
mGestureDownPoint = inDownEvent->refPoint +
inDownEvent->widget->WidgetToScreenOffset();
LayoutDeviceIntPoint::FromUntyped(inDownEvent->widget->WidgetToScreenOffset());
inDownFrame->GetContentForEvent(inDownEvent,
getter_AddRefs(mGestureDownContent));
@ -1959,8 +1959,8 @@ nsEventStateManager::FillInEventFromGestureDown(nsMouseEvent* aEvent)
// Set the coordinates in the new event to the coordinates of
// the old event, adjusted for the fact that the widget might be
// different
nsIntPoint tmpPoint = aEvent->widget->WidgetToScreenOffset();
aEvent->refPoint = mGestureDownPoint - tmpPoint;
aEvent->refPoint = mGestureDownPoint -
LayoutDeviceIntPoint::FromUntyped(aEvent->widget->WidgetToScreenOffset());
aEvent->modifiers = mGestureModifiers;
aEvent->buttons = mGestureDownButtons;
}
@ -2016,7 +2016,8 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
}
// fire drag gesture if mouse has moved enough
nsIntPoint pt = aEvent->refPoint + aEvent->widget->WidgetToScreenOffset();
LayoutDeviceIntPoint pt = aEvent->refPoint +
LayoutDeviceIntPoint::FromUntyped(aEvent->widget->WidgetToScreenOffset());
if (DeprecatedAbs(pt.x - mGestureDownPoint.x) > pixelThresholdX ||
DeprecatedAbs(pt.y - mGestureDownPoint.y) > pixelThresholdY) {
if (mClickHoldContextMenu) {
@ -3486,9 +3487,9 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
nsMouseEvent* mouseEvent = static_cast<nsMouseEvent*>(aEvent);
event.refPoint = mouseEvent->refPoint;
if (mouseEvent->widget) {
event.refPoint += mouseEvent->widget->WidgetToScreenOffset();
event.refPoint += LayoutDeviceIntPoint::FromUntyped(mouseEvent->widget->WidgetToScreenOffset());
}
event.refPoint -= widget->WidgetToScreenOffset();
event.refPoint -= LayoutDeviceIntPoint::FromUntyped(widget->WidgetToScreenOffset());
event.modifiers = mouseEvent->modifiers;
event.buttons = mouseEvent->buttons;
event.inputSource = mouseEvent->inputSource;
@ -4145,12 +4146,12 @@ nsEventStateManager::NotifyMouseOver(nsGUIEvent* aEvent, nsIContent* aContent)
// mode (see bug 799523 comment 35, and bug 729011). Using integer CSS pix
// makes us throw away the fractional error that results, rather than having
// it manifest as a potential one-device-pix discrepancy.
static nsIntPoint
static LayoutDeviceIntPoint
GetWindowInnerRectCenter(nsPIDOMWindow* aWindow,
nsIWidget* aWidget,
nsPresContext* aContext)
{
NS_ENSURE_TRUE(aWindow && aWidget && aContext, nsIntPoint(0,0));
NS_ENSURE_TRUE(aWindow && aWidget && aContext, LayoutDeviceIntPoint(0, 0));
float cssInnerX = 0.0;
aWindow->GetMozInnerScreenX(&cssInnerX);
@ -4172,7 +4173,7 @@ GetWindowInnerRectCenter(nsPIDOMWindow* aWindow,
int32_t cssScreenX = aContext->DevPixelsToIntCSSPixels(screen.x);
int32_t cssScreenY = aContext->DevPixelsToIntCSSPixels(screen.y);
return nsIntPoint(
return LayoutDeviceIntPoint(
aContext->CSSPixelsToDevPixels(innerX - cssScreenX + innerWidth / 2),
aContext->CSSPixelsToDevPixels(innerY - cssScreenY + innerHeight / 2));
}
@ -4200,9 +4201,9 @@ nsEventStateManager::GenerateMouseEnterExit(nsGUIEvent* aEvent)
// (locked) pointer can continue moving and won't stop at the screen
// boundary. We cancel the synthetic event so that we don't end up
// dispatching the centering move event to content.
nsIntPoint center = GetWindowInnerRectCenter(mDocument->GetWindow(),
aEvent->widget,
mPresContext);
LayoutDeviceIntPoint center =
GetWindowInnerRectCenter(mDocument->GetWindow(), aEvent->widget,
mPresContext);
aEvent->lastRefPoint = center;
if (aEvent->refPoint != center) {
// Mouse move doesn't finish at the center of the window. Dispatch a
@ -4212,7 +4213,7 @@ nsEventStateManager::GenerateMouseEnterExit(nsGUIEvent* aEvent)
// in the other branch here.
sSynthCenteringPoint = center;
aEvent->widget->SynthesizeNativeMouseMove(
center + aEvent->widget->WidgetToScreenOffset());
LayoutDeviceIntPoint::ToUntyped(center) + aEvent->widget->WidgetToScreenOffset());
} else if (aEvent->refPoint == sSynthCenteringPoint) {
// This is the "synthetic native" event we dispatched to re-center the
// pointer. Cancel it so we don't expose the centering move to content.
@ -4302,7 +4303,7 @@ nsEventStateManager::SetPointerLock(nsIWidget* aWidget,
aWidget,
mPresContext);
aWidget->SynthesizeNativeMouseMove(
sLastRefPoint + aWidget->WidgetToScreenOffset());
LayoutDeviceIntPoint::ToUntyped(sLastRefPoint) + aWidget->WidgetToScreenOffset());
// Retarget all events to this element via capture.
nsIPresShell::SetCapturingContent(aElement, CAPTURE_POINTERLOCK);
@ -4318,7 +4319,7 @@ nsEventStateManager::SetPointerLock(nsIWidget* aWidget,
// no movement.
sLastRefPoint = mPreLockPoint;
aWidget->SynthesizeNativeMouseMove(
mPreLockPoint + aWidget->WidgetToScreenOffset());
LayoutDeviceIntPoint::ToUntyped(mPreLockPoint) + aWidget->WidgetToScreenOffset());
// Don't retarget events to this element any more.
nsIPresShell::SetCapturingContent(nullptr, CAPTURE_POINTERLOCK);

View File

@ -713,14 +713,14 @@ private:
// Last mouse event refPoint (the offset from the widget's origin in
// device pixels) when mouse was locked, used to restore mouse position
// after unlocking.
nsIntPoint mPreLockPoint;
mozilla::LayoutDeviceIntPoint mPreLockPoint;
// Stores the refPoint of the last synthetic mouse move we dispatched
// to re-center the mouse when we were pointer locked. If this is (-1,-1) it
// means we've not recently dispatched a centering event. We use this to
// detect when we receive the synth event, so we can cancel and not send it
// to content.
static nsIntPoint sSynthCenteringPoint;
static mozilla::LayoutDeviceIntPoint sSynthCenteringPoint;
nsWeakFrame mCurrentTarget;
nsCOMPtr<nsIContent> mCurrentTargetContent;
@ -730,10 +730,10 @@ private:
// Stores the refPoint (the offset from the widget's origin in device
// pixels) of the last mouse event.
static nsIntPoint sLastRefPoint;
static mozilla::LayoutDeviceIntPoint sLastRefPoint;
// member variables for the d&d gesture state machine
nsIntPoint mGestureDownPoint; // screen coordinates
mozilla::LayoutDeviceIntPoint mGestureDownPoint; // screen coordinates
// The content to use as target if we start a d&d (what we drag).
nsCOMPtr<nsIContent> mGestureDownContent;
// The content of the frame where the mouse-down event occurred. It's the same

View File

@ -115,7 +115,7 @@ DestroyMouseDownPoint(void * /*aObject*/,
void * aPropertyValue,
void * /*aData*/)
{
nsIntPoint* pt = static_cast<nsIntPoint*>(aPropertyValue);
LayoutDeviceIntPoint* pt = static_cast<LayoutDeviceIntPoint*>(aPropertyValue);
delete pt;
}
@ -145,9 +145,10 @@ HTMLLabelElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
nsMouseEvent::eLeftButton) {
// We reset the mouse-down point on every event because there is
// no guarantee we will reach the NS_MOUSE_CLICK code below.
nsIntPoint *curPoint = new nsIntPoint(aVisitor.mEvent->refPoint);
LayoutDeviceIntPoint* curPoint =
new LayoutDeviceIntPoint(aVisitor.mEvent->refPoint);
SetProperty(nsGkAtoms::labelMouseDownPtProperty,
static_cast<void *>(curPoint),
static_cast<void*>(curPoint),
DestroyMouseDownPoint);
}
break;
@ -156,12 +157,13 @@ HTMLLabelElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
if (NS_IS_MOUSE_LEFT_CLICK(aVisitor.mEvent)) {
const nsMouseEvent* event =
static_cast<const nsMouseEvent*>(aVisitor.mEvent);
nsIntPoint *mouseDownPoint = static_cast<nsIntPoint *>
(GetProperty(nsGkAtoms::labelMouseDownPtProperty));
LayoutDeviceIntPoint* mouseDownPoint =
static_cast<LayoutDeviceIntPoint*>(
GetProperty(nsGkAtoms::labelMouseDownPtProperty));
bool dragSelect = false;
if (mouseDownPoint) {
nsIntPoint dragDistance = *mouseDownPoint;
LayoutDeviceIntPoint dragDistance = *mouseDownPoint;
DeleteProperty(nsGkAtoms::labelMouseDownPtProperty);
dragDistance -= aVisitor.mEvent->refPoint;

View File

@ -620,14 +620,13 @@ nsDOMWindowUtils::SendMouseEventToWindow(const nsAString& aType,
aInputSourceArg, true, nullptr);
}
static nsIntPoint
ToWidgetPoint(float aX, float aY, const nsPoint& aOffset,
static LayoutDeviceIntPoint
ToWidgetPoint(const CSSPoint& aPoint, const nsPoint& aOffset,
nsPresContext* aPresContext)
{
double appPerDev = aPresContext->AppUnitsPerDevPixel();
nscoord appPerCSS = nsPresContext::AppUnitsPerCSSPixel();
return nsIntPoint(NSToIntRound((aX*appPerCSS + aOffset.x)/appPerDev),
NSToIntRound((aY*appPerCSS + aOffset.y)/appPerDev));
return LayoutDeviceIntPoint::FromAppUnits(
CSSPoint::ToAppUnits(aPoint) + aOffset,
aPresContext->AppUnitsPerDevPixel());
}
static inline int16_t
@ -714,7 +713,7 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType,
if (!presContext)
return NS_ERROR_FAILURE;
event.refPoint = ToWidgetPoint(aX, aY, offset, presContext);
event.refPoint = ToWidgetPoint(CSSPoint(aX, aY), offset, presContext);
event.ignoreRootScrollFrame = aIgnoreRootScrollFrame;
nsEventStatus status;
@ -786,7 +785,7 @@ nsDOMWindowUtils::SendWheelEvent(float aX,
nsPresContext* presContext = GetPresContext();
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
wheelEvent.refPoint = ToWidgetPoint(aX, aY, offset, presContext);
wheelEvent.refPoint = ToWidgetPoint(CSSPoint(aX, aY), offset, presContext);
nsEventStatus status;
nsresult rv = widget->DispatchEvent(&wheelEvent, status);
@ -882,9 +881,10 @@ nsDOMWindowUtils::SendTouchEvent(const nsAString& aType,
}
event.touches.SetCapacity(aCount);
for (uint32_t i = 0; i < aCount; ++i) {
nsIntPoint pt = ToWidgetPoint(aXs[i], aYs[i], offset, presContext);
LayoutDeviceIntPoint pt =
ToWidgetPoint(CSSPoint(aXs[i], aYs[i]), offset, presContext);
nsRefPtr<Touch> t = new Touch(aIdentifiers[i],
pt,
LayoutDeviceIntPoint::ToUntyped(pt),
nsIntPoint(aRxs[i], aRys[i]),
aRotationAngles[i],
aForces[i]);
@ -1266,7 +1266,7 @@ nsDOMWindowUtils::SendSimpleGestureEvent(const nsAString& aType,
if (!presContext)
return NS_ERROR_FAILURE;
event.refPoint = ToWidgetPoint(aX, aY, offset, presContext);
event.refPoint = ToWidgetPoint(CSSPoint(aX, aY), offset, presContext);
nsEventStatus status;
return widget->DispatchEvent(&event, status);
@ -1756,7 +1756,7 @@ nsDOMWindowUtils::DispatchDOMEventViaPresShell(nsIDOMNode* aTarget,
}
static void
InitEvent(nsGUIEvent &aEvent, nsIntPoint *aPt = nullptr)
InitEvent(nsGUIEvent& aEvent, LayoutDeviceIntPoint* aPt = nullptr)
{
if (aPt) {
aEvent.refPoint = *aPt;
@ -1924,7 +1924,7 @@ nsDOMWindowUtils::SendQueryContentEvent(uint32_t aType,
}
nsCOMPtr<nsIWidget> targetWidget = widget;
nsIntPoint pt(aX, aY);
LayoutDeviceIntPoint pt(aX, aY);
if (aType == QUERY_CHARACTER_AT_POINT) {
// Looking for the widget at the point.
@ -1940,7 +1940,8 @@ nsDOMWindowUtils::SendQueryContentEvent(uint32_t aType,
// There is no popup frame at the point and the point isn't in our widget,
// we cannot process this request.
NS_ENSURE_TRUE(popupFrame || widgetBounds.Contains(pt),
NS_ENSURE_TRUE(popupFrame ||
widgetBounds.Contains(LayoutDeviceIntPoint::ToUntyped(pt)),
NS_ERROR_FAILURE);
// Fire the event on the widget at the point
@ -1949,7 +1950,8 @@ nsDOMWindowUtils::SendQueryContentEvent(uint32_t aType,
}
}
pt += widget->WidgetToScreenOffset() - targetWidget->WidgetToScreenOffset();
pt += LayoutDeviceIntPoint::FromUntyped(
widget->WidgetToScreenOffset() - targetWidget->WidgetToScreenOffset());
nsQueryContentEvent queryEvent(true, aType, targetWidget);
InitEvent(queryEvent, &pt);
@ -3159,7 +3161,8 @@ nsDOMWindowUtils::SelectAtPoint(float aX, float aY, uint32_t aSelectBehavior,
// Get the target frame at the client coordinates passed to us
nsPoint offset;
nsCOMPtr<nsIWidget> widget = GetWidget(&offset);
nsIntPoint pt = ToWidgetPoint(aX, aY, offset, GetPresContext());
nsIntPoint pt = LayoutDeviceIntPoint::ToUntyped(
ToWidgetPoint(CSSPoint(aX, aY), offset, GetPresContext()));
nsPoint ptInRoot =
nsLayoutUtils::GetEventCoordinatesRelativeTo(widget, pt, rootFrame);
nsIFrame* targetFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, ptInRoot);

View File

@ -1706,7 +1706,7 @@ TabChild::DispatchSynthesizedMouseEvent(uint32_t aMsg, uint64_t aTime,
nsMouseEvent event(true, aMsg, NULL,
nsMouseEvent::eReal, nsMouseEvent::eNormal);
event.refPoint = nsIntPoint(aRefPoint.x, aRefPoint.y);
event.refPoint = LayoutDeviceIntPoint(aRefPoint.x, aRefPoint.y);
event.time = aTime;
event.button = nsMouseEvent::eLeftButton;
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;

View File

@ -2225,9 +2225,10 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent)
const nsMouseEvent& mouseEvent =
static_cast<const nsMouseEvent&>(anEvent);
// Get reference point relative to screen:
nsIntPoint rootPoint(-1,-1);
LayoutDeviceIntPoint rootPoint(-1, -1);
if (widget)
rootPoint = anEvent.refPoint + widget->WidgetToScreenOffset();
rootPoint = anEvent.refPoint +
LayoutDeviceIntPoint::FromUntyped(widget->WidgetToScreenOffset());
#ifdef MOZ_WIDGET_GTK
Window root = GDK_ROOT_WINDOW();
#elif defined(MOZ_WIDGET_QT)

View File

@ -297,7 +297,7 @@ AsyncPanZoomController::ReceiveInputEvent(const nsInputEvent& aEvent,
aOutEvent->refPoint.x, aOutEvent->refPoint.y)),
currentResolution);
LayoutDevicePoint refPoint = refCSSPoint * mFrameMetrics.mDevPixelsPerCSSPixel;
aOutEvent->refPoint = nsIntPoint(refPoint.x, refPoint.y);
aOutEvent->refPoint = LayoutDeviceIntPoint(refPoint.x, refPoint.y);
break;
}
}

View File

@ -132,9 +132,23 @@ struct CSSPixel {
* 2) the "widget scale" (see nsIWidget::GetDefaultScale)
*/
struct LayoutDevicePixel {
static LayoutDeviceIntPoint FromUntyped(const nsIntPoint& aPoint)
{
return LayoutDeviceIntPoint(aPoint.x, aPoint.y);
}
static nsIntPoint ToUntyped(const LayoutDeviceIntPoint& aPoint)
{
return nsIntPoint(aPoint.x, aPoint.y);
}
static LayoutDeviceIntPoint FromAppUnits(const nsPoint& aPoint, nscoord aAppUnitsPerDevPixel)
{
return LayoutDeviceIntPoint(NSAppUnitsToIntPixels(aPoint.x, aAppUnitsPerDevPixel),
NSAppUnitsToIntPixels(aPoint.y, aAppUnitsPerDevPixel));
}
static LayoutDeviceIntPoint FromAppUnitsToNearest(const nsPoint& aPoint, nscoord appUnitsPerDevPixel) {
nsIntPoint result = aPoint.ToNearestPixels(appUnitsPerDevPixel);
return LayoutDeviceIntPoint(result.x, result.y);
return FromUntyped(aPoint.ToNearestPixels(appUnitsPerDevPixel));
}
};

View File

@ -1260,7 +1260,7 @@ nsLayoutUtils::GetEventCoordinatesRelativeTo(const nsEvent* aEvent, nsIFrame* aF
const nsGUIEvent* GUIEvent = static_cast<const nsGUIEvent*>(aEvent);
return GetEventCoordinatesRelativeTo(aEvent,
GUIEvent->refPoint,
LayoutDeviceIntPoint::ToUntyped(GUIEvent->refPoint),
aFrame);
}

View File

@ -5275,7 +5275,7 @@ PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll)
NS_ASSERTION(view->GetWidget(), "view should have a widget here");
nsMouseEvent event(true, NS_MOUSE_MOVE, view->GetWidget(),
nsMouseEvent::eSynthesized);
event.refPoint = refpoint.ToNearestPixels(viewAPD);
event.refPoint = LayoutDeviceIntPoint::FromAppUnitsToNearest(refpoint, viewAPD);
event.time = PR_IntervalNow();
// XXX set event.modifiers ?
// XXX mnakano I think that we should get the latest information from widget.
@ -5842,7 +5842,8 @@ PresShell::RecordMouseLocation(nsGUIEvent* aEvent)
if (!rootFrame) {
nsView* rootView = mViewManager->GetRootView();
mMouseLocation = nsLayoutUtils::TranslateWidgetToView(mPresContext,
aEvent->widget, aEvent->refPoint, rootView);
aEvent->widget, LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint),
rootView);
} else {
mMouseLocation =
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, rootFrame);
@ -7022,7 +7023,8 @@ PresShell::AdjustContextMenuKeyEvent(nsMouseEvent* aEvent)
nsCOMPtr<nsIWidget> widget = popupFrame->GetNearestWidget();
aEvent->widget = widget;
nsIntPoint widgetPoint = widget->WidgetToScreenOffset();
aEvent->refPoint = itemFrame->GetScreenRect().BottomLeft() - widgetPoint;
aEvent->refPoint = LayoutDeviceIntPoint::FromUntyped(
itemFrame->GetScreenRect().BottomLeft() - widgetPoint);
mCurrentEventContent = itemFrame->GetContent();
mCurrentEventFrame = itemFrame;
@ -7055,7 +7057,7 @@ PresShell::AdjustContextMenuKeyEvent(nsMouseEvent* aEvent)
nsView* view = rootFrame->GetClosestView(&offset);
offset += view->GetOffsetToWidget(aEvent->widget);
aEvent->refPoint =
offset.ToNearestPixels(mPresContext->AppUnitsPerDevPixel());
LayoutDeviceIntPoint::FromAppUnitsToNearest(offset, mPresContext->AppUnitsPerDevPixel());
}
}
} else {
@ -7068,7 +7070,7 @@ PresShell::AdjustContextMenuKeyEvent(nsMouseEvent* aEvent)
// ScrollSelectionIntoView.
if (PrepareToUseCaretPosition(aEvent->widget, caretPoint)) {
// caret position is good
aEvent->refPoint = caretPoint;
aEvent->refPoint = LayoutDeviceIntPoint::FromUntyped(caretPoint);
return true;
}
@ -7220,7 +7222,7 @@ PresShell::PrepareToUseCaretPosition(nsIWidget* aEventWidget, nsIntPoint& aTarge
void
PresShell::GetCurrentItemAndPositionForElement(nsIDOMElement *aCurrentEl,
nsIContent** aTargetToUse,
nsIntPoint& aTargetPt,
LayoutDeviceIntPoint& aTargetPt,
nsIWidget *aRootWidget)
{
nsCOMPtr<nsIContent> focusedContent(do_QueryInterface(aCurrentEl));

View File

@ -690,7 +690,7 @@ protected:
// document's root view for element, first ensuring the element is onscreen
void GetCurrentItemAndPositionForElement(nsIDOMElement *aCurrentEl,
nsIContent **aTargetToUse,
nsIntPoint& aTargetPt,
mozilla::LayoutDeviceIntPoint& aTargetPt,
nsIWidget *aRootWidget);
void FireResizeEvent();

View File

@ -476,16 +476,18 @@ nsRangeFrame::GetValueAtEventPoint(nsGUIEvent* aEvent)
}
Decimal range = maximum - minimum;
nsIntPoint absPoint;
LayoutDeviceIntPoint absPoint;
if (aEvent->eventStructType == NS_TOUCH_EVENT) {
MOZ_ASSERT(static_cast<nsTouchEvent*>(aEvent)->touches.Length() == 1,
"Unexpected number of touches");
absPoint = static_cast<nsTouchEvent*>(aEvent)->touches[0]->mRefPoint;
absPoint = LayoutDeviceIntPoint::FromUntyped(
static_cast<nsTouchEvent*>(aEvent)->touches[0]->mRefPoint);
} else {
absPoint = aEvent->refPoint;
}
nsPoint point =
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, absPoint, this);
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
LayoutDeviceIntPoint::ToUntyped(absPoint), this);
if (point == nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE)) {
// We don't want to change the current value for this error state.

View File

@ -1312,7 +1312,7 @@ nsHTMLFramesetFrame::StartMouseDrag(nsPresContext* aPresContext,
mDragger = aBorder;
mFirstDragPoint = aEvent->refPoint;
mFirstDragPoint = LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint);
// Store the original frame sizes
if (mDragger->mVertical) {

View File

@ -2084,7 +2084,7 @@ nsBoxFrame::GetEventPoint(nsGUIEvent* aEvent, nsIntPoint &aPoint) {
Touch* domtouch = static_cast<Touch*>(touch);
aPoint = domtouch->mRefPoint;
} else {
aPoint = aEvent->refPoint;
aPoint = LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint);
}
return true;
}

View File

@ -19,6 +19,8 @@
#include "nsDisplayList.h"
#include "nsContentUtils.h"
using namespace mozilla;
//
// NS_NewTitleBarFrame
//
@ -86,7 +88,7 @@ nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext,
nsIPresShell::SetCapturingContent(GetContent(), CAPTURE_IGNOREALLOWED);
// remember current mouse coordinates.
mLastPoint = aEvent->refPoint;
mLastPoint = LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint);
}
}
@ -117,7 +119,7 @@ nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext,
case NS_MOUSE_MOVE: {
if(mTrackingMouseMove)
{
nsIntPoint nsMoveBy = aEvent->refPoint - mLastPoint;
nsIntPoint nsMoveBy = LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint) - mLastPoint;
nsIFrame* parent = GetParent();
while (parent) {

View File

@ -1183,7 +1183,7 @@ nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup,
event.widget = nullptr;
}
event.refPoint = mCachedMousePoint;
event.refPoint = LayoutDeviceIntPoint::FromUntyped(mCachedMousePoint);
event.modifiers = mCachedModifiers;
nsEventDispatcher::Dispatch(popup, presContext, &event, nullptr, &status);

View File

@ -1310,7 +1310,7 @@ nsWindow::DispatchGestureEvent(uint32_t msg, uint32_t direction, double delta,
event.modifiers = 0;
event.time = time;
event.refPoint = refPoint;
event.refPoint = LayoutDeviceIntPoint::FromUntyped(refPoint);
DispatchEvent(&event);
}
@ -1327,7 +1327,7 @@ nsWindow::DispatchMotionEvent(nsInputEvent &event, AndroidGeckoEvent *ae,
// XXX possibly bound the range of event.refPoint here.
// some code may get confused.
event.refPoint = refPoint - offset;
event.refPoint = LayoutDeviceIntPoint::FromUntyped(refPoint - offset);
DispatchEvent(&event);
}

View File

@ -781,7 +781,7 @@ TISInputSourceWrapper::InitKeyEvent(NSEvent *aNativeKeyEvent,
// call), so there is no need to retain and release this data.
aKeyEvent.mNativeKeyEvent = aNativeKeyEvent;
aKeyEvent.refPoint = nsIntPoint(0, 0);
aKeyEvent.refPoint = LayoutDeviceIntPoint(0, 0);
// If a keyboard layout override is set, we also need to force the keyboard
// type to something ANSI to avoid test failures on machines with JIS

View File

@ -4497,7 +4497,8 @@ NSEvent* gLastDragMouseDownEvent = nil;
uint32_t msg = aEnter ? NS_MOUSE_ENTER : NS_MOUSE_EXIT;
nsMouseEvent event(true, msg, mGeckoChild, nsMouseEvent::eReal);
event.refPoint = mGeckoChild->CocoaPointsToDevPixels(localEventLocation);
event.refPoint = LayoutDeviceIntPoint::FromUntyped(
mGeckoChild->CocoaPointsToDevPixels(localEventLocation));
// Create event for use by plugins.
// This is going to our child view so we don't need to look up the destination
@ -4939,7 +4940,8 @@ static int32_t RoundUp(double aDouble)
NSPoint locationInWindow = nsCocoaUtils::EventLocationForWindow(aMouseEvent, [self window]);
NSPoint localPoint = [self convertPoint:locationInWindow fromView:nil];
outGeckoEvent->refPoint = mGeckoChild->CocoaPointsToDevPixels(localPoint);
outGeckoEvent->refPoint = LayoutDeviceIntPoint::FromUntyped(
mGeckoChild->CocoaPointsToDevPixels(localPoint));
nsMouseEvent_base* mouseEvent =
static_cast<nsMouseEvent_base*>(outGeckoEvent);
@ -5361,8 +5363,9 @@ static int32_t RoundUp(double aDouble)
// hitTest needs coordinates in device pixels
NSPoint eventLoc = nsCocoaUtils::ScreenLocationForEvent(currentEvent);
eventLoc.y = nsCocoaUtils::FlippedScreenY(eventLoc.y);
nsIntPoint widgetLoc = mGeckoChild->CocoaPointsToDevPixels(eventLoc) -
mGeckoChild->WidgetToScreenOffset();
LayoutDeviceIntPoint widgetLoc = LayoutDeviceIntPoint::FromUntyped(
mGeckoChild->CocoaPointsToDevPixels(eventLoc) -
mGeckoChild->WidgetToScreenOffset());
nsQueryContentEvent hitTest(true, NS_QUERY_DOM_WIDGET_HITTEST, mGeckoChild);
hitTest.InitForQueryDOMWidgetHittest(widgetLoc);
@ -5594,7 +5597,8 @@ static int32_t RoundUp(double aDouble)
NSPoint draggingLoc = [aSender draggingLocation];
NSPoint localPoint = [self convertPoint:draggingLoc fromView:nil];
geckoEvent.refPoint = mGeckoChild->CocoaPointsToDevPixels(localPoint);
geckoEvent.refPoint = LayoutDeviceIntPoint::FromUntyped(
mGeckoChild->CocoaPointsToDevPixels(localPoint));
nsAutoRetainCocoaObject kungFuDeathGrip(self);
mGeckoChild->DispatchWindowEvent(geckoEvent);

View File

@ -2528,8 +2528,10 @@ nsWindow::OnMotionNotifyEvent(GdkEventMotion *aEvent)
event.refPoint.x = nscoord(aEvent->x);
event.refPoint.y = nscoord(aEvent->y);
} else {
nsIntPoint point(NSToIntFloor(aEvent->x_root), NSToIntFloor(aEvent->y_root));
event.refPoint = point - WidgetToScreenOffset();
LayoutDeviceIntPoint point(NSToIntFloor(aEvent->x_root),
NSToIntFloor(aEvent->y_root));
event.refPoint = point -
LayoutDeviceIntPoint::FromUntyped(WidgetToScreenOffset());
}
modifierState = aEvent->state;
@ -2605,8 +2607,10 @@ nsWindow::InitButtonEvent(nsMouseEvent &aEvent,
aEvent.refPoint.x = nscoord(aGdkEvent->x);
aEvent.refPoint.y = nscoord(aGdkEvent->y);
} else {
nsIntPoint point(NSToIntFloor(aGdkEvent->x_root), NSToIntFloor(aGdkEvent->y_root));
aEvent.refPoint = point - WidgetToScreenOffset();
LayoutDeviceIntPoint point(NSToIntFloor(aGdkEvent->x_root),
NSToIntFloor(aGdkEvent->y_root));
aEvent.refPoint = point -
LayoutDeviceIntPoint::FromUntyped(WidgetToScreenOffset());
}
guint modifierState = aGdkEvent->state;
@ -2997,7 +3001,7 @@ nsWindow::OnKeyPressEvent(GdkEventKey *aEvent)
nsMouseEvent::eReal,
nsMouseEvent::eContextMenuKey);
contextMenuEvent.refPoint = nsIntPoint(0, 0);
contextMenuEvent.refPoint = LayoutDeviceIntPoint(0, 0);
contextMenuEvent.time = aEvent->time;
contextMenuEvent.clickCount = 1;
KeymapWrapper::InitInputEvent(contextMenuEvent, aEvent->state);
@ -3088,8 +3092,10 @@ nsWindow::OnScrollEvent(GdkEventScroll *aEvent)
// XXX we're never quite sure which GdkWindow the event came from due to our custom bubbling
// in scroll_event_cb(), so use ScreenToWidget to translate the screen root coordinates into
// coordinates relative to this widget.
nsIntPoint point(NSToIntFloor(aEvent->x_root), NSToIntFloor(aEvent->y_root));
wheelEvent.refPoint = point - WidgetToScreenOffset();
LayoutDeviceIntPoint point(NSToIntFloor(aEvent->x_root),
NSToIntFloor(aEvent->y_root));
wheelEvent.refPoint = point -
LayoutDeviceIntPoint::FromUntyped(WidgetToScreenOffset());
}
KeymapWrapper::InitInputEvent(wheelEvent, aEvent->state);
@ -3239,7 +3245,7 @@ nsWindow::DispatchDragEvent(uint32_t aMsg, const nsIntPoint& aRefPoint,
InitDragEvent(event);
}
event.refPoint = aRefPoint;
event.refPoint = LayoutDeviceIntPoint::FromUntyped(aRefPoint);
event.time = aTime;
nsEventStatus status;

View File

@ -31,6 +31,7 @@
#include "nsAutoPtr.h"
#include "mozilla/dom/EventTarget.h"
#include "mozilla/dom/Touch.h"
#include "Units.h"
namespace mozilla {
namespace dom {
@ -677,9 +678,9 @@ public:
uint32_t message;
// Relative to the widget of the event, or if there is no widget then it is
// in screen coordinates. Not modified by layout code.
nsIntPoint refPoint;
mozilla::LayoutDeviceIntPoint refPoint;
// The previous refPoint, if known, used to calculate mouse movement deltas.
nsIntPoint lastRefPoint;
mozilla::LayoutDeviceIntPoint lastRefPoint;
// Elapsed time, in milliseconds, from a platform-specific zero time
// to the time the message was created
uint64_t time;
@ -1509,7 +1510,7 @@ public:
mInput.mLength = aLength;
}
void InitForQueryDOMWidgetHittest(nsIntPoint& aPoint)
void InitForQueryDOMWidgetHittest(const mozilla::LayoutDeviceIntPoint& aPoint)
{
NS_ASSERTION(message == NS_QUERY_DOM_WIDGET_HITTEST,
"wrong initializer is called");

View File

@ -227,7 +227,7 @@ struct ParamTraits<nsTouchEvent>
}
for (uint32_t i = 0; i < numTouches; ++i) {
int32_t identifier;
nsIntPoint refPoint;
mozilla::LayoutDeviceIntPoint refPoint;
nsIntPoint radius;
float rotationAngle;
float force;
@ -239,7 +239,9 @@ struct ParamTraits<nsTouchEvent>
return false;
}
aResult->touches.AppendElement(
new mozilla::dom::Touch(identifier, refPoint, radius, rotationAngle, force));
new mozilla::dom::Touch(
identifier, mozilla::LayoutDeviceIntPoint::ToUntyped(refPoint),
radius, rotationAngle, force));
}
return true;
}

View File

@ -2011,7 +2011,7 @@ nsEventStatus nsWindow::OnTouchEvent(QTouchEvent *event, bool &handled)
for (int i = touchPoints.count() -1; i >= 0; i--) {
QPointF fpos = touchPoints[i].pos();
nsGestureNotifyEvent gestureNotifyEvent(true, NS_GESTURENOTIFY_EVENT_START, this);
gestureNotifyEvent.refPoint = nsIntPoint(fpos.x(), fpos.y());
gestureNotifyEvent.refPoint = LayoutDeviceIntPoint(fpos.x(), fpos.y());
DispatchEvent(&gestureNotifyEvent);
}
}
@ -2117,7 +2117,7 @@ nsWindow::DispatchGestureEvent(uint32_t aMsg, uint32_t aDirection,
nsSimpleGestureEvent mozGesture(true, aMsg, this, 0, 0.0);
mozGesture.direction = aDirection;
mozGesture.delta = aDelta;
mozGesture.refPoint = aRefPoint;
mozGesture.refPoint = LayoutDeviceIntPoint::FromUntyped(aRefPoint);
Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
@ -2582,7 +2582,7 @@ void
key_event_to_context_menu_event(nsMouseEvent &aEvent,
QKeyEvent *aGdkEvent)
{
aEvent.refPoint = nsIntPoint(0, 0);
aEvent.refPoint = LayoutDeviceIntPoint(0, 0);
aEvent.modifiers = 0;
aEvent.time = 0;
aEvent.clickCount = 1;

View File

@ -334,8 +334,6 @@ nsWindow::nsWindow() : nsWindowBase()
mBorderStyle = eBorderStyle_default;
mOldSizeMode = nsSizeMode_Normal;
mLastSizeMode = nsSizeMode_Normal;
mLastPoint.x = 0;
mLastPoint.y = 0;
mLastSize.width = 0;
mLastSize.height = 0;
mOldStyle = 0;
@ -3570,7 +3568,6 @@ void nsWindow::InitEvent(nsGUIEvent& event, nsIntPoint* aPoint)
}
event.time = ::GetMessageTime();
mLastPoint = event.refPoint;
}
/**************************************************************
@ -3966,7 +3963,7 @@ bool nsWindow::DispatchMouseEvent(uint32_t aEventType, WPARAM wParam,
rect.x = 0;
rect.y = 0;
if (rect.Contains(event.refPoint)) {
if (rect.Contains(LayoutDeviceIntPoint::ToUntyped(event.refPoint))) {
if (sCurrentWindow == NULL || sCurrentWindow != this) {
if ((nullptr != sCurrentWindow) && (!sCurrentWindow->mInDtor)) {
LPARAM pos = sCurrentWindow->lParamToClient(lParamToScreen(lParam));
@ -4889,7 +4886,7 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
if (lParam != -1 && !result && mCustomNonClient) {
nsMouseEvent event(true, NS_MOUSE_MOZHITTEST, this, nsMouseEvent::eReal,
nsMouseEvent::eNormal);
event.refPoint = nsIntPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
event.refPoint = LayoutDeviceIntPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
event.inputSource = MOUSE_INPUT_SOURCE();
event.mFlags.mOnlyChromeDispatch = true;
if (DispatchWindowEvent(&event)) {
@ -5292,7 +5289,7 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
touchPoint = gestureinfo->ptsLocation;
touchPoint.ScreenToClient(mWnd);
nsGestureNotifyEvent gestureNotifyEvent(true, NS_GESTURENOTIFY_EVENT_START, this);
gestureNotifyEvent.refPoint = touchPoint;
gestureNotifyEvent.refPoint = LayoutDeviceIntPoint::FromUntyped(touchPoint);
nsEventStatus status;
DispatchEvent(&gestureNotifyEvent, status);
mDisplayPanFeedback = gestureNotifyEvent.displayPanFeedback;
@ -5574,7 +5571,7 @@ nsWindow::ClientMarginHitTestPoint(int32_t mx, int32_t my)
} else {
nsMouseEvent event(true, NS_MOUSE_MOZHITTEST, this, nsMouseEvent::eReal,
nsMouseEvent::eNormal);
event.refPoint = nsIntPoint(pt.x, pt.y);
event.refPoint = LayoutDeviceIntPoint(pt.x, pt.y);
event.inputSource = MOUSE_INPUT_SOURCE();
event.mFlags.mOnlyChromeDispatch = true;
bool result = DispatchWindowEvent(&event);

View File

@ -227,7 +227,6 @@ public:
* Misc.
*/
virtual bool AutoErase(HDC dc);
nsIntPoint* GetLastPoint() { return &mLastPoint; }
bool IsTopLevelWidget() { return mIsTopWidgetWindow; }
/**
* Start allowing Direct3D9 to be used by widgets when GetLayerManager is

View File

@ -325,7 +325,7 @@ MetroInput::OnPointerWheelChanged(UI::Core::ICoreWindow* aSender,
WheelEvent wheelEvent(true, NS_WHEEL_WHEEL, mWidget.Get());
mModifierKeyState.Update();
mModifierKeyState.InitInputEvent(wheelEvent);
wheelEvent.refPoint = MetroUtils::LogToPhys(position);
wheelEvent.refPoint = LayoutDeviceIntPoint::FromUntyped(MetroUtils::LogToPhys(position));
wheelEvent.time = timestamp;
wheelEvent.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_MOUSE;
wheelEvent.pressure = pressure;
@ -660,7 +660,7 @@ MetroInput::InitGeckoMouseEventFromPointerPoint(
mModifierKeyState.Update();
mModifierKeyState.InitInputEvent(aEvent);
aEvent.refPoint = MetroUtils::LogToPhys(position);
aEvent.refPoint = LayoutDeviceIntPoint::FromUntyped(MetroUtils::LogToPhys(position));
aEvent.time = timestamp;
if (!canBeDoubleTap) {
@ -776,7 +776,7 @@ MetroInput::ProcessManipulationDelta(
mModifierKeyState.InitInputEvent(magEvent);
magEvent.time = ::GetMessageTime();
magEvent.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
magEvent.refPoint = MetroUtils::LogToPhys(aPosition);
magEvent.refPoint = LayoutDeviceIntPoint::FromUntyped(MetroUtils::LogToPhys(aPosition));
DispatchEventIgnoreStatus(&magEvent);
// Send a gecko event indicating the rotation since the last update.
@ -788,7 +788,7 @@ MetroInput::ProcessManipulationDelta(
mModifierKeyState.InitInputEvent(rotEvent);
rotEvent.time = ::GetMessageTime();
rotEvent.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
rotEvent.refPoint = MetroUtils::LogToPhys(aPosition);
rotEvent.refPoint = LayoutDeviceIntPoint::FromUntyped(MetroUtils::LogToPhys(aPosition));
if (rotEvent.delta >= 0) {
rotEvent.direction = nsIDOMSimpleGestureEvent::ROTATION_COUNTERCLOCKWISE;
} else {
@ -924,7 +924,7 @@ MetroInput::OnManipulationCompleted(
mModifierKeyState.InitInputEvent(swipeEvent);
swipeEvent.time = ::GetMessageTime();
swipeEvent.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
swipeEvent.refPoint = MetroUtils::LogToPhys(position);
swipeEvent.refPoint = LayoutDeviceIntPoint::FromUntyped(MetroUtils::LogToPhys(position));
DispatchEventIgnoreStatus(&swipeEvent);
}
@ -939,7 +939,7 @@ MetroInput::OnManipulationCompleted(
mModifierKeyState.InitInputEvent(swipeEvent);
swipeEvent.time = ::GetMessageTime();
swipeEvent.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
swipeEvent.refPoint = MetroUtils::LogToPhys(position);
swipeEvent.refPoint = LayoutDeviceIntPoint::FromUntyped(MetroUtils::LogToPhys(position));
DispatchEventIgnoreStatus(&swipeEvent);
}
@ -969,10 +969,8 @@ MetroInput::OnTapped(UI::Input::IGestureRecognizer* aSender,
Foundation::Point position;
aArgs->get_Position(&position);
nsIntPoint pt = MetroUtils::LogToPhys(position);
LayoutDeviceIntPoint point(pt.x, pt.y);
HandleSingleTap(point);
HandleSingleTap(
LayoutDeviceIntPoint::FromUntyped(MetroUtils::LogToPhys(position)));
return S_OK;
}
@ -993,10 +991,8 @@ MetroInput::OnRightTapped(UI::Input::IGestureRecognizer* aSender,
Foundation::Point position;
aArgs->get_Position(&position);
nsIntPoint pt = MetroUtils::LogToPhys(position);
LayoutDeviceIntPoint point(pt.x, pt.y);
HandleLongTap(point);
HandleLongTap(
LayoutDeviceIntPoint::FromUntyped(MetroUtils::LogToPhys(position)));
return S_OK;
}
@ -1013,8 +1009,7 @@ MetroInput::HandleDoubleTap(const LayoutDeviceIntPoint& aPoint)
mModifierKeyState.InitInputEvent(geckoEvent);
geckoEvent.time = ::GetMessageTime();
geckoEvent.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
geckoEvent.refPoint.x = aPoint.x;
geckoEvent.refPoint.y = aPoint.y;
geckoEvent.refPoint = aPoint;
geckoEvent.clickCount = 2;
geckoEvent.pressure = 1;
DispatchEventIgnoreStatus(&geckoEvent);
@ -1036,8 +1031,7 @@ MetroInput::HandleSingleTap(const LayoutDeviceIntPoint& aPoint)
nsMouseEvent::eNormal);
mModifierKeyState.Update();
mModifierKeyState.InitInputEvent(mouseEvent);
mouseEvent.refPoint.x = aPoint.x;
mouseEvent.refPoint.y = aPoint.y;
mouseEvent.refPoint = aPoint;
mouseEvent.time = ::GetMessageTime();
mouseEvent.clickCount = 1;
mouseEvent.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
@ -1064,8 +1058,7 @@ MetroInput::HandleSingleTap(const LayoutDeviceIntPoint& aPoint)
Foundation::Point oldMousePosition;
oldMousePosition.X = static_cast<FLOAT>(point.x);
oldMousePosition.Y = static_cast<FLOAT>(point.y);
mouseEvent.refPoint.x = aPoint.x;
mouseEvent.refPoint.y = aPoint.y;
mouseEvent.refPoint = aPoint;
mouseEvent.message = NS_MOUSE_MOVE;
mouseEvent.button = 0;
@ -1088,8 +1081,7 @@ MetroInput::HandleLongTap(const LayoutDeviceIntPoint& aPoint)
nsMouseEvent::eNormal);
mModifierKeyState.Update();
mModifierKeyState.InitInputEvent(contextMenu);
contextMenu.refPoint.x = aPoint.x;
contextMenu.refPoint.y = aPoint.y;
contextMenu.refPoint = aPoint;
contextMenu.time = ::GetMessageTime();
contextMenu.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
DispatchEventIgnoreStatus(&contextMenu);

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */