From a5307d1c9712289e3f1d2d124f6b79f0276425c6 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Wed, 27 Feb 2013 15:12:39 +0100 Subject: [PATCH] Bug 845595 - Make nsIDOMWindowUtils::selectAtPoint coordinates relative to the DWU's document. r=jimm --- dom/base/nsDOMWindowUtils.cpp | 5 +++-- dom/tests/mochitest/chrome/selectAtPoint.html | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index a55bdeb4cc84..f069f92269e1 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -3011,8 +3011,9 @@ nsDOMWindowUtils::SelectAtPoint(float aX, float aY, uint32_t aSelectBehavior, } // Get the target frame at the client coordinates passed to us - nsCOMPtr widget = GetWidget(); - nsIntPoint pt(aX, aY); + nsPoint offset; + nsCOMPtr widget = GetWidget(&offset); + nsIntPoint pt = ToWidgetPoint(aX, aY, offset, GetPresContext()); nsPoint ptInRoot = nsLayoutUtils::GetEventCoordinatesRelativeTo(widget, pt, rootFrame); nsIFrame* targetFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, ptInRoot); diff --git a/dom/tests/mochitest/chrome/selectAtPoint.html b/dom/tests/mochitest/chrome/selectAtPoint.html index 798aff4386e2..cfe2e350f77d 100644 --- a/dom/tests/mochitest/chrome/selectAtPoint.html +++ b/dom/tests/mochitest/chrome/selectAtPoint.html @@ -164,8 +164,8 @@ let rect = frame.getBoundingClientRect(); - let targetPoint = { xPos: rect.left + (charDims.width / 2), - yPos: rect.top + (charDims.height / 2) }; + let targetPoint = { xPos: charDims.width / 2, + yPos: charDims.height / 2 }; setSingle(dwuFrame, targetPoint.xPos, targetPoint.yPos, Ci.nsIDOMWindowUtils.SELECT_WORDNOSPACE); checkSelection(frame.contentWindow.document, "SELECT_WORDNOSPACE", "ttestselection2"); setSingle(dwuFrame, targetPoint.xPos, targetPoint.yPos, Ci.nsIDOMWindowUtils.SELECT_WORD);