Bug 1125040: Use LayoutDeviceIntPoint for nsIWidget::WidgetToScreen r=botond

This commit is contained in:
David Zbarsky 2015-02-04 15:21:03 -05:00
parent dcc3953291
commit c73ec42d2d
42 changed files with 113 additions and 125 deletions

View File

@ -1344,7 +1344,7 @@ HyperTextAccessible::GetCaretRect(nsIWidget** aWidget)
nsIntRect caretRect;
caretRect = rect.ToOutsidePixels(frame->PresContext()->AppUnitsPerDevPixel());
// ((content screen origin) - (content offset in the widget)) = widget origin on the screen
caretRect.MoveBy((*aWidget)->WidgetToScreenOffset() - (*aWidget)->GetClientOffset());
caretRect.MoveBy((*aWidget)->WidgetToScreenOffsetUntyped() - (*aWidget)->GetClientOffset());
// Correct for character size, so that caret always matches the size of
// the character. This is important for font size transitions, and is

View File

@ -2195,8 +2195,7 @@ nsDOMWindowUtils::SendQueryContentEvent(uint32_t aType,
}
}
pt += LayoutDeviceIntPoint::FromUntyped(
widget->WidgetToScreenOffset() - targetWidget->WidgetToScreenOffset());
pt += widget->WidgetToScreenOffset() - targetWidget->WidgetToScreenOffset();
WidgetQueryContentEvent queryEvent(true, aType, targetWidget);
InitEvent(queryEvent, &pt);

View File

@ -147,7 +147,7 @@ nsQueryContentEventResult::SetEventResult(nsIWidget* aWidget,
}
// Convert the top widget related coordinates to the given widget's.
nsIntPoint offset =
LayoutDeviceIntPoint offset =
aWidget->WidgetToScreenOffset() - topWidget->WidgetToScreenOffset();
mRect.MoveBy(-offset);
mRect.MoveBy(-LayoutDeviceIntPoint::ToUntyped(offset));
}

View File

@ -1149,9 +1149,8 @@ ContentEventHandler::OnQueryCharacterAtPoint(WidgetQueryContentEvent* aEvent)
eventOnRoot.mUseNativeLineBreak = aEvent->mUseNativeLineBreak;
eventOnRoot.refPoint = aEvent->refPoint;
if (rootWidget != aEvent->widget) {
eventOnRoot.refPoint += LayoutDeviceIntPoint::FromUntyped(
aEvent->widget->WidgetToScreenOffset() -
rootWidget->WidgetToScreenOffset());
eventOnRoot.refPoint += aEvent->widget->WidgetToScreenOffset() -
rootWidget->WidgetToScreenOffset();
}
nsPoint ptInRoot =
nsLayoutUtils::GetEventCoordinatesRelativeTo(&eventOnRoot, rootFrame);
@ -1214,8 +1213,7 @@ ContentEventHandler::OnQueryDOMWidgetHittest(WidgetQueryContentEvent* aEvent)
nsIFrame* docFrame = mPresShell->GetRootFrame();
NS_ENSURE_TRUE(docFrame, NS_ERROR_FAILURE);
LayoutDeviceIntPoint eventLoc = aEvent->refPoint +
LayoutDeviceIntPoint::FromUntyped(aEvent->widget->WidgetToScreenOffset());
LayoutDeviceIntPoint eventLoc = aEvent->refPoint + aEvent->widget->WidgetToScreenOffset();
nsIntRect docFrameRect = docFrame->GetScreenRect(); // Returns CSS pixels
CSSIntPoint eventLocCSS(
mPresContext->DevPixelsToIntCSSPixels(eventLoc.x) - docFrameRect.x,

View File

@ -902,8 +902,7 @@ Event::GetScreenCoords(nsPresContext* aPresContext,
return LayoutDeviceIntPoint::ToUntyped(aPoint);
}
LayoutDeviceIntPoint offset = aPoint +
LayoutDeviceIntPoint::FromUntyped(guiEvent->widget->WidgetToScreenOffset());
LayoutDeviceIntPoint offset = aPoint + guiEvent->widget->WidgetToScreenOffset();
nscoord factor =
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),

View File

@ -1505,8 +1505,7 @@ EventStateManager::BeginTrackingDragGesture(nsPresContext* aPresContext,
// Note that |inDownEvent| could be either a mouse down event or a
// synthesized mouse move event.
mGestureDownPoint = inDownEvent->refPoint +
LayoutDeviceIntPoint::FromUntyped(inDownEvent->widget->WidgetToScreenOffset());
mGestureDownPoint = inDownEvent->refPoint + inDownEvent->widget->WidgetToScreenOffset();
inDownFrame->GetContentForEvent(inDownEvent,
getter_AddRefs(mGestureDownContent));
@ -1544,8 +1543,7 @@ EventStateManager::FillInEventFromGestureDown(WidgetMouseEvent* 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
aEvent->refPoint = mGestureDownPoint -
LayoutDeviceIntPoint::FromUntyped(aEvent->widget->WidgetToScreenOffset());
aEvent->refPoint = mGestureDownPoint - aEvent->widget->WidgetToScreenOffset();
aEvent->modifiers = mGestureModifiers;
aEvent->buttons = mGestureDownButtons;
}
@ -1601,8 +1599,7 @@ EventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
}
// fire drag gesture if mouse has moved enough
LayoutDeviceIntPoint pt = aEvent->refPoint +
LayoutDeviceIntPoint::FromUntyped(aEvent->widget->WidgetToScreenOffset());
LayoutDeviceIntPoint pt = aEvent->refPoint + aEvent->widget->WidgetToScreenOffset();
LayoutDeviceIntPoint distance = pt - mGestureDownPoint;
if (Abs(distance.x) > AssertedCast<uint32_t>(pixelThresholdX) ||
Abs(distance.y) > AssertedCast<uint32_t>(pixelThresholdY)) {
@ -3216,9 +3213,9 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
event.refPoint = mouseEvent->refPoint;
if (mouseEvent->widget) {
event.refPoint += LayoutDeviceIntPoint::FromUntyped(mouseEvent->widget->WidgetToScreenOffset());
event.refPoint += mouseEvent->widget->WidgetToScreenOffset();
}
event.refPoint -= LayoutDeviceIntPoint::FromUntyped(widget->WidgetToScreenOffset());
event.refPoint -= widget->WidgetToScreenOffset();
event.modifiers = mouseEvent->modifiers;
event.buttons = mouseEvent->buttons;
event.inputSource = mouseEvent->inputSource;
@ -4023,8 +4020,8 @@ EventStateManager::GenerateMouseEnterExit(WidgetMouseEvent* aMouseEvent)
// in the other branch here.
sSynthCenteringPoint = center;
aMouseEvent->widget->SynthesizeNativeMouseMove(
LayoutDeviceIntPoint::ToUntyped(center) +
aMouseEvent->widget->WidgetToScreenOffset());
LayoutDeviceIntPoint::ToUntyped(center +
aMouseEvent->widget->WidgetToScreenOffset()));
} else if (aMouseEvent->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.
@ -4160,7 +4157,7 @@ EventStateManager::SetPointerLock(nsIWidget* aWidget,
aWidget,
mPresContext);
aWidget->SynthesizeNativeMouseMove(
LayoutDeviceIntPoint::ToUntyped(sLastRefPoint) + aWidget->WidgetToScreenOffset());
LayoutDeviceIntPoint::ToUntyped(sLastRefPoint + aWidget->WidgetToScreenOffset()));
// Retarget all events to this element via capture.
nsIPresShell::SetCapturingContent(aElement, CAPTURE_POINTERLOCK);
@ -4176,7 +4173,7 @@ EventStateManager::SetPointerLock(nsIWidget* aWidget,
// no movement.
sLastRefPoint = mPreLockPoint;
aWidget->SynthesizeNativeMouseMove(
LayoutDeviceIntPoint::ToUntyped(mPreLockPoint) + aWidget->WidgetToScreenOffset());
LayoutDeviceIntPoint::ToUntyped(mPreLockPoint + aWidget->WidgetToScreenOffset()));
// Don't retarget events to this element any more.
nsIPresShell::SetCapturingContent(nullptr, CAPTURE_POINTERLOCK);

View File

@ -449,15 +449,14 @@ IMEContentObserver::OnMouseButtonEvent(nsPresContext* aPresContext,
nsIWidget* topLevelWidget = mWidget->GetTopLevelWidget();
if (topLevelWidget && topLevelWidget != mWidget) {
charAtPt.mReply.mRect.MoveBy(
topLevelWidget->WidgetToScreenOffset() -
mWidget->WidgetToScreenOffset());
topLevelWidget->WidgetToScreenOffsetUntyped() -
mWidget->WidgetToScreenOffsetUntyped());
}
// The refPt is relative to its widget.
// We should notify it with offset in the widget.
if (aMouseEvent->widget != mWidget) {
charAtPt.refPoint += LayoutDeviceIntPoint::FromUntyped(
aMouseEvent->widget->WidgetToScreenOffset() -
mWidget->WidgetToScreenOffset());
charAtPt.refPoint += aMouseEvent->widget->WidgetToScreenOffset() -
mWidget->WidgetToScreenOffset();
}
IMENotification notification(NOTIFY_IME_OF_MOUSE_BUTTON_EVENT);

View File

@ -57,8 +57,7 @@ public:
return LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint);
}
LayoutDeviceIntPoint offset = aEvent->refPoint +
LayoutDeviceIntPoint::FromUntyped(event->widget->WidgetToScreenOffset());
LayoutDeviceIntPoint offset = aEvent->refPoint + event->widget->WidgetToScreenOffset();
nscoord factor =
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),

View File

@ -293,8 +293,8 @@ WheelTransaction::GetScreenPoint(WidgetGUIEvent* aEvent)
{
NS_ASSERTION(aEvent, "aEvent is null");
NS_ASSERTION(aEvent->widget, "aEvent-widget is null");
return LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint) +
aEvent->widget->WidgetToScreenOffset();
return LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint +
aEvent->widget->WidgetToScreenOffset());
}
/* static */ uint32_t

View File

@ -2116,8 +2116,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
// Get reference point relative to screen:
LayoutDeviceIntPoint rootPoint(-1, -1);
if (widget)
rootPoint = anEvent.refPoint +
LayoutDeviceIntPoint::FromUntyped(widget->WidgetToScreenOffset());
rootPoint = anEvent.refPoint + widget->WidgetToScreenOffset();
#ifdef MOZ_WIDGET_GTK
Window root = GDK_ROOT_WINDOW();
#elif defined(MOZ_WIDGET_QT)

View File

@ -1452,7 +1452,7 @@ ChromeTooltipListener::sTooltipCallback(nsITimer *aTimer,
if (textFound) {
nsString tipText(tooltipText);
nsIntPoint screenDot = widget->WidgetToScreenOffset();
LayoutDeviceIntPoint screenDot = widget->WidgetToScreenOffset();
self->ShowTooltip(self->mMouseScreenX - screenDot.x,
self->mMouseScreenY - screenDot.y,
tipText);

View File

@ -71,7 +71,7 @@ public:
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) MOZ_OVERRIDE { return NS_OK; }
NS_IMETHOD Invalidate(const nsIntRect &aRect) MOZ_OVERRIDE { return NS_OK; }
NS_IMETHOD SetTitle(const nsAString& title) MOZ_OVERRIDE { return NS_OK; }
virtual nsIntPoint WidgetToScreenOffset() MOZ_OVERRIDE { return nsIntPoint(0, 0); }
virtual LayoutDeviceIntPoint WidgetToScreenOffset() MOZ_OVERRIDE { return LayoutDeviceIntPoint(0, 0); }
NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
nsEventStatus& aStatus) MOZ_OVERRIDE { return NS_OK; }
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, bool aDoCapture) MOZ_OVERRIDE { return NS_OK; }

View File

@ -473,11 +473,11 @@ FindFrameTargetedByInputEvent(WidgetGUIEvent* aEvent,
if (!view) {
return target;
}
nsIntPoint widgetPoint = nsLayoutUtils::TranslateViewToWidget(
LayoutDeviceIntPoint widgetPoint = nsLayoutUtils::TranslateViewToWidget(
aRootFrame->PresContext(), view, point, aEvent->widget);
if (widgetPoint.x != NS_UNCONSTRAINEDSIZE) {
// If that succeeded, we update the point in the event
aEvent->refPoint = LayoutDeviceIntPoint::FromUntyped(widgetPoint);
aEvent->refPoint = widgetPoint;
}
return target;
}

View File

@ -2627,8 +2627,8 @@ nsLayoutUtils::TransformFrameRectToAncestor(nsIFrame* aFrame,
NSFloatPixelsToAppUnits(float(result.height), destAppUnitsPerDevPixel));
}
static nsIntPoint GetWidgetOffset(nsIWidget* aWidget, nsIWidget*& aRootWidget) {
nsIntPoint offset(0, 0);
static LayoutDeviceIntPoint GetWidgetOffset(nsIWidget* aWidget, nsIWidget*& aRootWidget) {
LayoutDeviceIntPoint offset(0, 0);
while ((aWidget->WindowType() == eWindowType_child ||
aWidget->IsPlugin())) {
nsIWidget* parent = aWidget->GetParent();
@ -2637,18 +2637,19 @@ static nsIntPoint GetWidgetOffset(nsIWidget* aWidget, nsIWidget*& aRootWidget) {
}
nsIntRect bounds;
aWidget->GetBounds(bounds);
offset += bounds.TopLeft();
offset += LayoutDeviceIntPoint::FromUntyped(bounds.TopLeft());
aWidget = parent;
}
aRootWidget = aWidget;
return offset;
}
static nsIntPoint WidgetToWidgetOffset(nsIWidget* aFrom, nsIWidget* aTo) {
static LayoutDeviceIntPoint
WidgetToWidgetOffset(nsIWidget* aFrom, nsIWidget* aTo) {
nsIWidget* fromRoot;
nsIntPoint fromOffset = GetWidgetOffset(aFrom, fromRoot);
LayoutDeviceIntPoint fromOffset = GetWidgetOffset(aFrom, fromRoot);
nsIWidget* toRoot;
nsIntPoint toOffset = GetWidgetOffset(aTo, toRoot);
LayoutDeviceIntPoint toOffset = GetWidgetOffset(aTo, toRoot);
if (fromRoot == toRoot) {
return fromOffset - toOffset;
@ -2667,14 +2668,13 @@ nsLayoutUtils::TranslateWidgetToView(nsPresContext* aPresContext,
return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
}
LayoutDeviceIntPoint widgetPoint = aPt +
LayoutDeviceIntPoint::FromUntyped(WidgetToWidgetOffset(aWidget, viewWidget));
LayoutDeviceIntPoint widgetPoint = aPt + WidgetToWidgetOffset(aWidget, viewWidget);
nsPoint widgetAppUnits(aPresContext->DevPixelsToAppUnits(widgetPoint.x),
aPresContext->DevPixelsToAppUnits(widgetPoint.y));
return widgetAppUnits - viewOffset;
}
nsIntPoint
LayoutDeviceIntPoint
nsLayoutUtils::TranslateViewToWidget(nsPresContext* aPresContext,
nsView* aView, nsPoint aPt,
nsIWidget* aWidget)
@ -2682,11 +2682,11 @@ nsLayoutUtils::TranslateViewToWidget(nsPresContext* aPresContext,
nsPoint viewOffset;
nsIWidget* viewWidget = aView->GetNearestWidget(&viewOffset);
if (!viewWidget) {
return nsIntPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
return LayoutDeviceIntPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
}
nsIntPoint relativeToViewWidget(aPresContext->AppUnitsToDevPixels(aPt.x + viewOffset.x),
aPresContext->AppUnitsToDevPixels(aPt.y + viewOffset.y));
LayoutDeviceIntPoint relativeToViewWidget(aPresContext->AppUnitsToDevPixels(aPt.x + viewOffset.x),
aPresContext->AppUnitsToDevPixels(aPt.y + viewOffset.y));
return relativeToViewWidget + WidgetToWidgetOffset(viewWidget, aWidget);
}

View File

@ -728,9 +728,10 @@ public:
* @param aWidget the widget to which returned coordinates are relative
* @return the point in the view's coordinates
*/
static nsIntPoint TranslateViewToWidget(nsPresContext* aPresContext,
nsView* aView, nsPoint aPt,
nsIWidget* aWidget);
static mozilla::LayoutDeviceIntPoint
TranslateViewToWidget(nsPresContext* aPresContext,
nsView* aView, nsPoint aPt,
nsIWidget* aWidget);
enum FrameForPointFlags {
/**

View File

@ -8474,9 +8474,9 @@ PresShell::AdjustContextMenuKeyEvent(WidgetMouseEvent* aEvent)
nsCOMPtr<nsIWidget> widget = popupFrame->GetNearestWidget();
aEvent->widget = widget;
nsIntPoint widgetPoint = widget->WidgetToScreenOffset();
LayoutDeviceIntPoint widgetPoint = widget->WidgetToScreenOffset();
aEvent->refPoint = LayoutDeviceIntPoint::FromUntyped(
itemFrame->GetScreenRect().BottomLeft() - widgetPoint);
itemFrame->GetScreenRect().BottomLeft()) - widgetPoint;
mCurrentEventContent = itemFrame->GetContent();
mCurrentEventFrame = itemFrame;

View File

@ -4815,7 +4815,7 @@ nsRect nsIFrame::GetScreenRectInAppUnits() const
nsCOMPtr<nsIWidget> rootWidget;
presContext->PresShell()->GetViewManager()->GetRootWidget(getter_AddRefs(rootWidget));
if (rootWidget) {
nsIntPoint rootDevPx = rootWidget->WidgetToScreenOffset();
LayoutDeviceIntPoint rootDevPx = rootWidget->WidgetToScreenOffset();
rootScreenPos.x = presContext->DevPixelsToAppUnits(rootDevPx.x);
rootScreenPos.y = presContext->DevPixelsToAppUnits(rootDevPx.y);
}

View File

@ -117,8 +117,7 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
LayoutDeviceIntPoint refPoint;
if (!GetEventPoint(aEvent, refPoint))
return NS_OK;
mMouseDownPoint = refPoint +
LayoutDeviceIntPoint::FromUntyped(aEvent->widget->WidgetToScreenOffset());
mMouseDownPoint = refPoint + aEvent->widget->WidgetToScreenOffset();
// we're tracking
mTrackingMouseMove = true;
@ -166,8 +165,7 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
LayoutDeviceIntPoint refPoint;
if (!GetEventPoint(aEvent, refPoint))
return NS_OK;
LayoutDeviceIntPoint screenPoint = refPoint +
LayoutDeviceIntPoint::FromUntyped(aEvent->widget->WidgetToScreenOffset());
LayoutDeviceIntPoint screenPoint = refPoint + aEvent->widget->WidgetToScreenOffset();
LayoutDeviceIntPoint mouseMove(screenPoint - mMouseDownPoint);
// Determine which direction to resize by checking the dir attribute.

View File

@ -746,7 +746,7 @@ nsXULPopupManager::ShowTooltipAtScreen(nsIContent* aPopup,
if (rootPresContext) {
nsIWidget *rootWidget = rootPresContext->GetRootWidget();
if (rootWidget) {
mCachedMousePoint -= rootWidget->WidgetToScreenOffset();
mCachedMousePoint -= rootWidget->WidgetToScreenOffsetUntyped();
}
}

View File

@ -220,7 +220,7 @@ nsIntRect nsView::CalcWidgetBounds(nsWindowType aType)
if (parentWidget && aType == eWindowType_popup &&
IsEffectivelyVisible()) {
// put offset into screen coordinates. (based on client area origin)
nsIntPoint screenPoint = parentWidget->WidgetToScreenOffset();
LayoutDeviceIntPoint screenPoint = parentWidget->WidgetToScreenOffset();
viewBounds += nsPoint(NSIntPixelsToAppUnits(screenPoint.x, p2a),
NSIntPixelsToAppUnits(screenPoint.y, p2a));
}

View File

@ -126,8 +126,8 @@ public:
{ return NS_ERROR_UNEXPECTED; }
// PuppetWidgets are always at <0, 0>.
virtual nsIntPoint WidgetToScreenOffset() MOZ_OVERRIDE
{ return nsIntPoint(0, 0); }
virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset() MOZ_OVERRIDE
{ return mozilla::LayoutDeviceIntPoint(0, 0); }
void InitEvent(WidgetGUIEvent& aEvent, nsIntPoint* aPoint = nullptr);

View File

@ -730,7 +730,7 @@ AndroidGeckoEvent::MakeTouchEvent(nsIWidget* widget)
event.modifiers = DOMModifiers();
event.time = Time();
const nsIntPoint& offset = widget->WidgetToScreenOffset();
const LayoutDeviceIntPoint& offset = widget->WidgetToScreenOffset();
event.touches.SetCapacity(endIndex - startIndex);
for (int i = startIndex; i < endIndex; i++) {
// In this code branch, we are dispatching this event directly
@ -796,7 +796,7 @@ AndroidGeckoEvent::MakeMultiTouchInput(nsIWidget* widget)
return event;
}
const nsIntPoint& offset = widget->WidgetToScreenOffset();
const nsIntPoint& offset = widget->WidgetToScreenOffsetUntyped();
event.mTouches.SetCapacity(endIndex - startIndex);
for (int i = startIndex; i < endIndex; i++) {
nsIntPoint point = Points()[i] - offset;
@ -853,11 +853,10 @@ AndroidGeckoEvent::MakeMouseEvent(nsIWidget* widget)
// We are dispatching this event directly into Gecko (as opposed to going
// through the AsyncPanZoomController), and the Points() array has points
// in CSS pixels, which we need to convert to LayoutDevice pixels.
const nsIntPoint& offset = widget->WidgetToScreenOffset();
const LayoutDeviceIntPoint& offset = widget->WidgetToScreenOffset();
CSSToLayoutDeviceScale scale = widget->GetDefaultScale();
event.refPoint = LayoutDeviceIntPoint((Points()[0].x * scale.scale) - offset.x,
(Points()[0].y * scale.scale) - offset.y);
return event;
}

View File

@ -630,7 +630,7 @@ nsWindow::BringToFront()
NS_IMETHODIMP
nsWindow::GetScreenBounds(nsIntRect &aRect)
{
nsIntPoint p = WidgetToScreenOffset();
LayoutDeviceIntPoint p = WidgetToScreenOffset();
aRect.x = p.x;
aRect.y = p.y;
@ -640,10 +640,10 @@ nsWindow::GetScreenBounds(nsIntRect &aRect)
return NS_OK;
}
nsIntPoint
LayoutDeviceIntPoint
nsWindow::WidgetToScreenOffset()
{
nsIntPoint p(0, 0);
LayoutDeviceIntPoint p(0, 0);
nsWindow *w = this;
while (w && !w->IsTopLevel()) {
@ -1041,8 +1041,7 @@ nsWindow::OnContextmenuEvent(AndroidGeckoEvent *ae)
WidgetMouseEvent contextMenuEvent(true, NS_CONTEXTMENU, this,
WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
contextMenuEvent.refPoint =
LayoutDeviceIntPoint(RoundedToInt(pt * GetDefaultScale())) -
LayoutDeviceIntPoint::FromUntyped(WidgetToScreenOffset());
RoundedToInt(pt * GetDefaultScale()) - WidgetToScreenOffset();
contextMenuEvent.ignoreRootScrollFrame = true;
contextMenuEvent.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;

View File

@ -100,7 +100,7 @@ public:
NS_IMETHOD Invalidate(const nsIntRect &aRect);
NS_IMETHOD SetFocus(bool aRaise = false);
NS_IMETHOD GetScreenBounds(nsIntRect &aRect);
virtual nsIntPoint WidgetToScreenOffset();
virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset();
NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
nsEventStatus& aStatus);
nsEventStatus DispatchEvent(mozilla::WidgetGUIEvent* aEvent);

View File

@ -401,7 +401,7 @@ public:
virtual void* GetNativeData(uint32_t aDataType) MOZ_OVERRIDE;
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) MOZ_OVERRIDE;
virtual nsIntPoint WidgetToScreenOffset() MOZ_OVERRIDE;
virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset() MOZ_OVERRIDE;
virtual bool ShowsResizeIndicator(nsIntRect* aResizerRect) MOZ_OVERRIDE;
static bool ConvertStatus(nsEventStatus aStatus)

View File

@ -923,7 +923,7 @@ NS_IMETHODIMP nsChildView::GetClientBounds(nsIntRect &aRect)
if (!mParentWidget) {
// For top level widgets we want the position on screen, not the position
// of this view inside the window.
aRect.MoveTo(WidgetToScreenOffset());
aRect.MoveTo(WidgetToScreenOffsetUntyped());
}
return NS_OK;
}
@ -931,7 +931,7 @@ NS_IMETHODIMP nsChildView::GetClientBounds(nsIntRect &aRect)
NS_IMETHODIMP nsChildView::GetScreenBounds(nsIntRect &aRect)
{
GetBounds(aRect);
aRect.MoveTo(WidgetToScreenOffset());
aRect.MoveTo(WidgetToScreenOffsetUntyped());
return NS_OK;
}
@ -1482,7 +1482,7 @@ void nsChildView::ReportSizeEvent()
// Return the offset between this child view and the screen.
// @return -- widget origin in device-pixel coords
nsIntPoint nsChildView::WidgetToScreenOffset()
LayoutDeviceIntPoint nsChildView::WidgetToScreenOffset()
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
@ -1500,9 +1500,9 @@ nsIntPoint nsChildView::WidgetToScreenOffset()
FlipCocoaScreenCoordinate(origin);
// convert to device pixels
return CocoaPointsToDevPixels(origin);
return LayoutDeviceIntPoint::FromUntyped(CocoaPointsToDevPixels(origin));
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(nsIntPoint(0,0));
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(LayoutDeviceIntPoint(0,0));
}
NS_IMETHODIMP nsChildView::CaptureRollupEvents(nsIRollupListener * aListener,

View File

@ -260,7 +260,7 @@ public:
NS_IMETHOD SetModal(bool aState) MOZ_OVERRIDE;
virtual bool IsVisible() const MOZ_OVERRIDE;
NS_IMETHOD SetFocus(bool aState=false) MOZ_OVERRIDE;
virtual nsIntPoint WidgetToScreenOffset() MOZ_OVERRIDE;
virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset() MOZ_OVERRIDE;
virtual nsIntPoint GetClientOffset() MOZ_OVERRIDE;
virtual nsIntSize ClientToWindowSize(const nsIntSize& aClientSize) MOZ_OVERRIDE;

View File

@ -1812,7 +1812,7 @@ NS_IMETHODIMP nsCocoaWindow::SetFocus(bool aState)
return NS_OK;
}
nsIntPoint nsCocoaWindow::WidgetToScreenOffset()
LayoutDeviceIntPoint nsCocoaWindow::WidgetToScreenOffset()
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
@ -1823,9 +1823,9 @@ nsIntPoint nsCocoaWindow::WidgetToScreenOffset()
}
r = nsCocoaUtils::CocoaRectToGeckoRectDevPix(rect, BackingScaleFactor());
return r.TopLeft();
return LayoutDeviceIntPoint::FromUntyped(r.TopLeft());
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(nsIntPoint(0,0));
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(LayoutDeviceIntPoint(0,0));
}
nsIntPoint nsCocoaWindow::GetClientOffset()

View File

@ -505,10 +505,10 @@ nsWindow::Invalidate(const nsIntRect &aRect)
return NS_OK;
}
nsIntPoint
LayoutDeviceIntPoint
nsWindow::WidgetToScreenOffset()
{
nsIntPoint p(0, 0);
LayoutDeviceIntPoint p(0, 0);
nsWindow *w = this;
while (w && w->mParent) {

View File

@ -86,7 +86,7 @@ public:
{
return NS_OK;
}
virtual nsIntPoint WidgetToScreenOffset();
virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset();
void DispatchTouchInputViaAPZ(mozilla::MultiTouchInput& aInput);
NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
nsEventStatus& aStatus);

View File

@ -1755,7 +1755,7 @@ nsDragService::ScheduleDropEvent(nsWindow *aWindow,
return FALSE;
}
SetDragEndPoint(aWindowPoint + aWindow->WidgetToScreenOffset());
SetDragEndPoint(aWindowPoint + aWindow->WidgetToScreenOffsetUntyped());
// We'll reply with gtk_drag_finish().
return TRUE;

View File

@ -1473,10 +1473,10 @@ nsWindow::GetScreenBounds(nsIntRect &aRect)
// use the point including window decorations
gint x, y;
gdk_window_get_root_origin(gtk_widget_get_window(GTK_WIDGET(mContainer)), &x, &y);
aRect.MoveTo(GdkPointToDevicePixels({ x, y }));
aRect.MoveTo(LayoutDevicePixel::ToUntyped(GdkPointToDevicePixels({ x, y })));
}
else {
aRect.MoveTo(WidgetToScreenOffset());
aRect.MoveTo(WidgetToScreenOffsetUntyped());
}
// mBounds.Size() is the window bounds, not the window-manager frame
// bounds (bug 581863). gdk_window_get_frame_extents would give the
@ -1797,7 +1797,7 @@ nsWindow::SetIcon(const nsAString& aIconSpec)
}
nsIntPoint
LayoutDeviceIntPoint
nsWindow::WidgetToScreenOffset()
{
gint x = 0, y = 0;
@ -2617,8 +2617,7 @@ nsWindow::OnMotionNotifyEvent(GdkEventMotion *aEvent)
} else {
LayoutDeviceIntPoint point(NSToIntFloor(aEvent->x_root),
NSToIntFloor(aEvent->y_root));
event.refPoint = point -
LayoutDeviceIntPoint::FromUntyped(WidgetToScreenOffset());
event.refPoint = point - WidgetToScreenOffset();
}
modifierState = aEvent->state;
@ -2696,8 +2695,7 @@ nsWindow::InitButtonEvent(WidgetMouseEvent& aEvent,
} else {
LayoutDeviceIntPoint point(NSToIntFloor(aGdkEvent->x_root),
NSToIntFloor(aGdkEvent->y_root));
aEvent.refPoint = point -
LayoutDeviceIntPoint::FromUntyped(WidgetToScreenOffset());
aEvent.refPoint = point - WidgetToScreenOffset();
}
guint modifierState = aGdkEvent->state;
@ -3209,8 +3207,7 @@ nsWindow::OnScrollEvent(GdkEventScroll *aEvent)
// coordinates relative to this widget.
LayoutDeviceIntPoint point(NSToIntFloor(aEvent->x_root),
NSToIntFloor(aEvent->y_root));
wheelEvent.refPoint = point -
LayoutDeviceIntPoint::FromUntyped(WidgetToScreenOffset());
wheelEvent.refPoint = point - WidgetToScreenOffset();
}
KeymapWrapper::InitInputEvent(wheelEvent, aEvent->state);
@ -6338,7 +6335,7 @@ nsWindow::GetDragInfo(WidgetMouseEvent* aMouseEvent,
// moved since the mousedown. (On the other hand, it's quite likely
// that the mouse has moved, which is why we use the mouse position
// from the event.)
nsIntPoint offset = aMouseEvent->widget->WidgetToScreenOffset();
LayoutDeviceIntPoint offset = aMouseEvent->widget->WidgetToScreenOffset();
*aRootX = aMouseEvent->refPoint.x + offset.x;
*aRootY = aMouseEvent->refPoint.y + offset.y;
@ -6499,11 +6496,11 @@ nsWindow::GdkCoordToDevicePixels(gint coord) {
return coord * GdkScaleFactor();
}
nsIntPoint
LayoutDeviceIntPoint
nsWindow::GdkPointToDevicePixels(GdkPoint point) {
gint scale = GdkScaleFactor();
return nsIntPoint(point.x * scale,
point.y * scale);
return LayoutDeviceIntPoint(point.x * scale,
point.y * scale);
}
nsIntRect

View File

@ -138,7 +138,7 @@ public:
NS_IMETHOD SetTitle(const nsAString& aTitle) MOZ_OVERRIDE;
NS_IMETHOD SetIcon(const nsAString& aIconSpec) MOZ_OVERRIDE;
NS_IMETHOD SetWindowClass(const nsAString& xulWinType) MOZ_OVERRIDE;
virtual nsIntPoint WidgetToScreenOffset() MOZ_OVERRIDE;
virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset() MOZ_OVERRIDE;
NS_IMETHOD EnableDragDrop(bool aEnable) MOZ_OVERRIDE;
NS_IMETHOD CaptureMouse(bool aCapture) MOZ_OVERRIDE;
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
@ -498,7 +498,7 @@ private:
// From GDK
int GdkCoordToDevicePixels(gint coord);
nsIntPoint GdkPointToDevicePixels(GdkPoint point);
mozilla::LayoutDeviceIntPoint GdkPointToDevicePixels(GdkPoint point);
nsIntRect GdkRectToDevicePixels(GdkRectangle rect);
};

View File

@ -1668,12 +1668,16 @@ class nsIWidget : public nsISupports {
NS_IMETHOD SetIcon(const nsAString& anIconSpec) = 0;
/**
* Return this widget's origin in screen coordinates.
* Return this widget's origin in screen coordinates. The untyped version
* exists temporarily to ease conversion to typed coordinates.
*
* @return screen coordinates stored in the x,y members
*/
virtual nsIntPoint WidgetToScreenOffset() = 0;
virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset() = 0;
virtual nsIntPoint WidgetToScreenOffsetUntyped() {
return mozilla::LayoutDeviceIntPoint::ToUntyped(WidgetToScreenOffset());
}
/**
* Given the specified client size, return the corresponding window size,

View File

@ -626,7 +626,7 @@ nsWindow::Invalidate(const nsIntRect &aRect)
return NS_OK;
}
nsIntPoint
LayoutDeviceIntPoint
nsWindow::WidgetToScreenOffset()
{
NS_ENSURE_TRUE(mWidget, nsIntPoint(0,0));
@ -634,7 +634,7 @@ nsWindow::WidgetToScreenOffset()
QPoint origin(0, 0);
origin = mWidget->mapToGlobal(origin);
return nsIntPoint(origin.x(), origin.y());
return LayoutDeviceIntPoint(origin.x(), origin.y());
}
void*

View File

@ -124,7 +124,7 @@ public:
{
return NS_OK;
}
virtual nsIntPoint WidgetToScreenOffset();
virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset();
NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
nsEventStatus& aStatus);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,

View File

@ -1957,7 +1957,7 @@ nsIMM32Handler::SetIMERelatedWindowsPosOnPlugin(nsWindow* aWindow,
// window needs to be specified the position in the client area.
nsWindow* toplevelWindow = aWindow->GetTopLevelWindow(false);
nsIntRect pluginRectInScreen =
editorRectEvent.mReply.mRect + toplevelWindow->WidgetToScreenOffset();
editorRectEvent.mReply.mRect + toplevelWindow->WidgetToScreenOffsetUntyped();
nsIntRect winRectInScreen;
aWindow->GetClientBounds(winRectInScreen);
// composition window cannot be positioned on the edge of client area.
@ -1974,7 +1974,7 @@ nsIMM32Handler::SetIMERelatedWindowsPosOnPlugin(nsWindow* aWindow,
int32_t yMost = std::min(pluginRectInScreen.YMost(), winRectInScreen.YMost());
clippedPluginRect.width = std::max(0, xMost - clippedPluginRect.x);
clippedPluginRect.height = std::max(0, yMost - clippedPluginRect.y);
clippedPluginRect -= aWindow->WidgetToScreenOffset();
clippedPluginRect -= aWindow->WidgetToScreenOffsetUntyped();
// Cover the plugin with native caret. This prevents IME's window and plugin
// overlap.
@ -2013,10 +2013,10 @@ nsIMM32Handler::ResolveIMECaretPos(nsIWidget* aReferenceWidget,
return;
if (aReferenceWidget)
aOutRect.MoveBy(aReferenceWidget->WidgetToScreenOffset());
aOutRect.MoveBy(aReferenceWidget->WidgetToScreenOffsetUntyped());
if (aNewOriginWidget)
aOutRect.MoveBy(-aNewOriginWidget->WidgetToScreenOffset());
aOutRect.MoveBy(-aNewOriginWidget->WidgetToScreenOffsetUntyped());
}
/* static */ nsresult

View File

@ -3198,7 +3198,7 @@ nsTextStore::GetTextExt(TsViewCookie vcView,
return E_FAIL;
}
event.mReply.mRect.MoveBy(refWindow->WidgetToScreenOffset());
event.mReply.mRect.MoveBy(refWindow->WidgetToScreenOffsetUntyped());
}
// get bounding screen rect to test for clipping
@ -3336,7 +3336,7 @@ nsTextStore::GetScreenExtInternal(RECT &aScreenExt)
// Clip frame rect to window rect
boundRect.IntersectRect(event.mReply.mRect, boundRect);
if (!boundRect.IsEmpty()) {
boundRect.MoveBy(refWindow->WidgetToScreenOffset());
boundRect.MoveBy(refWindow->WidgetToScreenOffsetUntyped());
::SetRect(&aScreenExt, boundRect.x, boundRect.y,
boundRect.XMost(), boundRect.YMost());
} else {
@ -4325,8 +4325,8 @@ nsTextStore::CreateNativeCaret()
}
if (toplevelWindow != window) {
caretRect.MoveBy(toplevelWindow->WidgetToScreenOffset());
caretRect.MoveBy(-window->WidgetToScreenOffset());
caretRect.MoveBy(toplevelWindow->WidgetToScreenOffsetUntyped());
caretRect.MoveBy(-window->WidgetToScreenOffsetUntyped());
}
::SetCaretPos(caretRect.x, caretRect.y);

View File

@ -1991,7 +1991,7 @@ nsIntPoint nsWindow::GetClientOffset()
RECT r1;
GetWindowRect(mWnd, &r1);
nsIntPoint pt = WidgetToScreenOffset();
LayoutDeviceIntPoint pt = WidgetToScreenOffset();
return nsIntPoint(pt.x - r1.left, pt.y - r1.top);
}
@ -3061,13 +3061,13 @@ NS_METHOD nsWindow::SetIcon(const nsAString& aIconSpec)
*
**************************************************************/
nsIntPoint nsWindow::WidgetToScreenOffset()
LayoutDeviceIntPoint nsWindow::WidgetToScreenOffset()
{
POINT point;
point.x = 0;
point.y = 0;
::ClientToScreen(mWnd, &point);
return nsIntPoint(point.x, point.y);
return LayoutDeviceIntPoint(point.x, point.y);
}
nsIntSize nsWindow::ClientToWindowSize(const nsIntSize& aClientSize)
@ -3819,7 +3819,7 @@ bool nsWindow::DispatchMouseEvent(uint32_t aEventType, WPARAM wParam,
aInputSource == nsIDOMMouseEvent::MOZ_SOURCE_PEN ||
!(WinUtils::GetIsMouseFromTouch(aEventType) && mTouchWindow);
nsIntPoint mpScreen = eventPoint + WidgetToScreenOffset();
nsIntPoint mpScreen = eventPoint + WidgetToScreenOffsetUntyped();
// Suppress mouse moves caused by widget creation
if (aEventType == NS_MOUSE_MOVE)

View File

@ -136,7 +136,7 @@ public:
virtual void FreeNativeData(void * data, uint32_t aDataType);
NS_IMETHOD SetTitle(const nsAString& aTitle);
NS_IMETHOD SetIcon(const nsAString& aIconSpec);
virtual nsIntPoint WidgetToScreenOffset();
virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset();
virtual nsIntSize ClientToWindowSize(const nsIntSize& aClientSize);
NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
nsEventStatus& aStatus);

View File

@ -1492,10 +1492,10 @@ MetroWidget::SetTitle(const nsAString& aTitle)
return NS_OK;
}
nsIntPoint
LayoutDeviceIntPoint
MetroWidget::WidgetToScreenOffset()
{
return nsIntPoint(0,0);
return LayoutDeviceIntPoint(0,0);
}
NS_IMETHODIMP

View File

@ -172,7 +172,7 @@ public:
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations);
virtual void* GetNativeData(uint32_t aDataType);
virtual void FreeNativeData(void * data, uint32_t aDataType);
virtual nsIntPoint WidgetToScreenOffset();
virtual mozilla::LayoutDeviceIntPoint WidgetToScreenOffset();
already_AddRefed<nsIPresShell> GetPresShell();