зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1220925 - Event::GetScreenCoords should return CSSIntPoint instead of LayoutDevicePoint. r=botond
This patch converts Event::GetScreenCoords to return the same type as Event::GetClientCoords and Event::GetPageCoords which is a CSSIntPoint. When the function was originally updated it was switched to returning LayoutDevicePoint. Additionally the redundant functions UIEvent::CalculateClientPoint and UIEvent::CalculateScreenPoint were removed. --HG-- extra : commitid : 9BNUzLVMIZ6
This commit is contained in:
Родитель
7c5e9caf26
Коммит
658205dc3e
|
@ -899,7 +899,8 @@ Event::Shutdown()
|
|||
}
|
||||
}
|
||||
|
||||
LayoutDeviceIntPoint
|
||||
// static
|
||||
CSSIntPoint
|
||||
Event::GetScreenCoords(nsPresContext* aPresContext,
|
||||
WidgetEvent* aEvent,
|
||||
LayoutDeviceIntPoint aPoint)
|
||||
|
@ -907,8 +908,7 @@ Event::GetScreenCoords(nsPresContext* aPresContext,
|
|||
if (!nsContentUtils::LegacyIsCallerChromeOrNativeCode() &&
|
||||
nsContentUtils::ResistFingerprinting()) {
|
||||
// When resisting fingerprinting, return client coordinates instead.
|
||||
CSSIntPoint clientCoords = GetClientCoords(aPresContext, aEvent, aPoint, CSSIntPoint(0, 0));
|
||||
return LayoutDeviceIntPoint(clientCoords.x, clientCoords.y);
|
||||
return GetClientCoords(aPresContext, aEvent, aPoint, CSSIntPoint(0, 0));
|
||||
}
|
||||
|
||||
if (EventStateManager::sIsPointerLocked) {
|
||||
|
@ -923,19 +923,26 @@ Event::GetScreenCoords(nsPresContext* aPresContext,
|
|||
aEvent->mClass != eTouchEventClass &&
|
||||
aEvent->mClass != eDragEventClass &&
|
||||
aEvent->mClass != eSimpleGestureEventClass)) {
|
||||
return LayoutDeviceIntPoint(0, 0);
|
||||
return CSSIntPoint(0, 0);
|
||||
}
|
||||
|
||||
// Doing a straight conversion from LayoutDeviceIntPoint to CSSIntPoint
|
||||
// seem incorrect, but it is needed to maintain legacy functionality.
|
||||
if (!aPresContext) {
|
||||
return CSSIntPoint(aPoint.x, aPoint.y);
|
||||
}
|
||||
|
||||
LayoutDeviceIntPoint offset = aPoint;
|
||||
|
||||
WidgetGUIEvent* guiEvent = aEvent->AsGUIEvent();
|
||||
if (!guiEvent->widget) {
|
||||
return aPoint;
|
||||
if (guiEvent && guiEvent->widget) {
|
||||
offset += guiEvent->widget->WidgetToScreenOffset();
|
||||
}
|
||||
|
||||
LayoutDeviceIntPoint offset = aPoint + guiEvent->widget->WidgetToScreenOffset();
|
||||
nscoord factor =
|
||||
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
|
||||
return LayoutDeviceIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
|
||||
nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
|
||||
nsPoint pt =
|
||||
LayoutDevicePixel::ToAppUnits(offset, aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom());
|
||||
|
||||
return CSSPixel::FromAppUnitsRounded(pt);
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -133,9 +133,9 @@ public:
|
|||
WidgetEvent* aEvent,
|
||||
LayoutDeviceIntPoint aPoint,
|
||||
CSSIntPoint aDefaultPoint);
|
||||
static LayoutDeviceIntPoint GetScreenCoords(nsPresContext* aPresContext,
|
||||
WidgetEvent* aEvent,
|
||||
LayoutDeviceIntPoint aPoint);
|
||||
static CSSIntPoint GetScreenCoords(nsPresContext* aPresContext,
|
||||
WidgetEvent* aEvent,
|
||||
LayoutDeviceIntPoint aPoint);
|
||||
static CSSIntPoint GetOffsetCoords(nsPresContext* aPresContext,
|
||||
WidgetEvent* aEvent,
|
||||
LayoutDeviceIntPoint aPoint,
|
||||
|
|
|
@ -270,7 +270,7 @@ EventStateManager* EventStateManager::sActiveESM = nullptr;
|
|||
nsIDocument* EventStateManager::sMouseOverDocument = nullptr;
|
||||
nsWeakFrame EventStateManager::sLastDragOverFrame = nullptr;
|
||||
LayoutDeviceIntPoint EventStateManager::sLastRefPoint = kInvalidRefPoint;
|
||||
LayoutDeviceIntPoint EventStateManager::sLastScreenPoint = LayoutDeviceIntPoint(0, 0);
|
||||
CSSIntPoint EventStateManager::sLastScreenPoint = CSSIntPoint(0, 0);
|
||||
LayoutDeviceIntPoint EventStateManager::sSynthCenteringPoint = kInvalidRefPoint;
|
||||
CSSIntPoint EventStateManager::sLastClientPoint = CSSIntPoint(0, 0);
|
||||
bool EventStateManager::sIsPointerLocked = false;
|
||||
|
@ -560,9 +560,9 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
|||
aEvent->mClass == eWheelEventClass) &&
|
||||
!sIsPointerLocked) {
|
||||
sLastScreenPoint =
|
||||
UIEvent::CalculateScreenPoint(aPresContext, aEvent);
|
||||
Event::GetScreenCoords(aPresContext, aEvent, aEvent->refPoint);
|
||||
sLastClientPoint =
|
||||
UIEvent::CalculateClientPoint(aPresContext, aEvent, nullptr);
|
||||
Event::GetClientCoords(aPresContext, aEvent, aEvent->refPoint, CSSIntPoint(0, 0));
|
||||
}
|
||||
|
||||
*aStatus = nsEventStatus_eIgnore;
|
||||
|
|
|
@ -256,7 +256,7 @@ public:
|
|||
// locked. This is used by dom::Event::GetScreenCoords() to make mouse
|
||||
// events' screen coord appear frozen at the last mouse position while
|
||||
// the pointer is locked.
|
||||
static LayoutDeviceIntPoint sLastScreenPoint;
|
||||
static CSSIntPoint sLastScreenPoint;
|
||||
|
||||
// Holds the point in client coords of the last mouse event. Used by
|
||||
// dom::Event::GetClientCoords() to make mouse events' client coords appear
|
||||
|
|
|
@ -32,7 +32,7 @@ Touch::Touch(EventTarget* aTarget,
|
|||
mTarget = aTarget;
|
||||
mIdentifier = aIdentifier;
|
||||
mPagePoint = CSSIntPoint(aPageX, aPageY);
|
||||
mScreenPoint = LayoutDeviceIntPoint(aScreenX, aScreenY);
|
||||
mScreenPoint = CSSIntPoint(aScreenX, aScreenY);
|
||||
mClientPoint = CSSIntPoint(aClientX, aClientY);
|
||||
mRefPoint = LayoutDeviceIntPoint(0, 0);
|
||||
mPointsInitialized = true;
|
||||
|
@ -54,7 +54,7 @@ Touch::Touch(int32_t aIdentifier,
|
|||
{
|
||||
mIdentifier = aIdentifier;
|
||||
mPagePoint = CSSIntPoint(0, 0);
|
||||
mScreenPoint = LayoutDeviceIntPoint(0, 0);
|
||||
mScreenPoint = CSSIntPoint(0, 0);
|
||||
mClientPoint = CSSIntPoint(0, 0);
|
||||
mRefPoint = aPoint;
|
||||
mPointsInitialized = false;
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
int32_t mIdentifier;
|
||||
CSSIntPoint mPagePoint;
|
||||
CSSIntPoint mClientPoint;
|
||||
LayoutDeviceIntPoint mScreenPoint;
|
||||
CSSIntPoint mScreenPoint;
|
||||
LayoutDeviceIntPoint mRadius;
|
||||
float mRotationAngle;
|
||||
float mForce;
|
||||
|
|
|
@ -359,11 +359,13 @@ UIEvent::DuplicatePrivateData()
|
|||
mPagePoint =
|
||||
Event::GetPageCoords(mPresContext, mEvent, mEvent->refPoint, mClientPoint);
|
||||
// GetScreenPoint converts mEvent->refPoint to right coordinates.
|
||||
LayoutDeviceIntPoint screenPoint =
|
||||
CSSIntPoint screenPoint =
|
||||
Event::GetScreenCoords(mPresContext, mEvent, mEvent->refPoint);
|
||||
nsresult rv = Event::DuplicatePrivateData();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mEvent->refPoint = screenPoint;
|
||||
CSSToLayoutDeviceScale scale = mPresContext ? mPresContext->CSSToDevPixelScale()
|
||||
: CSSToLayoutDeviceScale(1);
|
||||
mEvent->refPoint = RoundedToInt(screenPoint * scale);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -40,62 +40,6 @@ public:
|
|||
NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override;
|
||||
NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, void** aIter) override;
|
||||
|
||||
static LayoutDeviceIntPoint CalculateScreenPoint(nsPresContext* aPresContext,
|
||||
WidgetEvent* aEvent)
|
||||
{
|
||||
if (!aEvent ||
|
||||
(aEvent->mClass != eMouseEventClass &&
|
||||
aEvent->mClass != eMouseScrollEventClass &&
|
||||
aEvent->mClass != eWheelEventClass &&
|
||||
aEvent->mClass != eDragEventClass &&
|
||||
aEvent->mClass != ePointerEventClass &&
|
||||
aEvent->mClass != eSimpleGestureEventClass)) {
|
||||
return LayoutDeviceIntPoint(0, 0);
|
||||
}
|
||||
|
||||
WidgetGUIEvent* event = aEvent->AsGUIEvent();
|
||||
if (!event->widget) {
|
||||
return aEvent->refPoint;
|
||||
}
|
||||
|
||||
LayoutDeviceIntPoint offset = aEvent->refPoint + event->widget->WidgetToScreenOffset();
|
||||
nscoord factor =
|
||||
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
|
||||
return LayoutDeviceIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
|
||||
nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
|
||||
}
|
||||
|
||||
static CSSIntPoint CalculateClientPoint(nsPresContext* aPresContext,
|
||||
WidgetEvent* aEvent,
|
||||
CSSIntPoint* aDefaultClientPoint)
|
||||
{
|
||||
if (!aEvent ||
|
||||
(aEvent->mClass != eMouseEventClass &&
|
||||
aEvent->mClass != eMouseScrollEventClass &&
|
||||
aEvent->mClass != eWheelEventClass &&
|
||||
aEvent->mClass != eDragEventClass &&
|
||||
aEvent->mClass != ePointerEventClass &&
|
||||
aEvent->mClass != eSimpleGestureEventClass) ||
|
||||
!aPresContext ||
|
||||
!aEvent->AsGUIEvent()->widget) {
|
||||
return aDefaultClientPoint
|
||||
? *aDefaultClientPoint
|
||||
: CSSIntPoint(0, 0);
|
||||
}
|
||||
|
||||
nsIPresShell* shell = aPresContext->GetPresShell();
|
||||
if (!shell) {
|
||||
return CSSIntPoint(0, 0);
|
||||
}
|
||||
nsIFrame* rootFrame = shell->GetRootFrame();
|
||||
if (!rootFrame) {
|
||||
return CSSIntPoint(0, 0);
|
||||
}
|
||||
nsPoint pt =
|
||||
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, rootFrame);
|
||||
|
||||
return CSSIntPoint::FromAppUnitsRounded(pt);
|
||||
}
|
||||
|
||||
static already_AddRefed<UIEvent> Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aType,
|
||||
|
|
|
@ -124,7 +124,6 @@ skip-if = toolkit == 'android' #CRASH_DUMP, RANDOM
|
|||
skip-if = toolkit == 'android' #CRASH_DUMP, RANDOM
|
||||
[test_bug704423.html]
|
||||
[test_bug741666.html]
|
||||
skip-if = toolkit == 'android'
|
||||
[test_bug742376.html]
|
||||
[test_bug812744.html]
|
||||
[test_bug855741.html]
|
||||
|
|
|
@ -289,6 +289,11 @@ struct LayoutDevicePixel {
|
|||
NSAppUnitsToIntPixels(aSize.height, aAppUnitsPerDevPixel));
|
||||
}
|
||||
|
||||
static nsPoint ToAppUnits(const LayoutDeviceIntPoint& aPoint, nscoord aAppUnitsPerDevPixel) {
|
||||
return nsPoint(aPoint.x * aAppUnitsPerDevPixel,
|
||||
aPoint.y * aAppUnitsPerDevPixel);
|
||||
}
|
||||
|
||||
static nsSize ToAppUnits(const LayoutDeviceIntSize& aSize, nscoord aAppUnitsPerDevPixel) {
|
||||
return nsSize(aSize.width * aAppUnitsPerDevPixel,
|
||||
aSize.height * aAppUnitsPerDevPixel);
|
||||
|
|
Загрузка…
Ссылка в новой задаче