Bug 845595 - Make nsIDOMWindowUtils::selectAtPoint coordinates relative to the DWU's document. r=jimm
authorMarkus Stange <mstange@themasta.com>
Wed, 27 Feb 2013 15:12:39 +0100
changeset 123151 f223a4961926e7feed750ea41df1466c39fef185
parent 123150 36b60ec153af1319f15a4ad0454ed0d8b8656218
child 123152 6c59b73c8c4b908e2defbafce28b75636563da75
push id24373
push userryanvm@gmail.com
push dateThu, 28 Feb 2013 01:36:21 +0000
treeherdermozilla-central@8cb9d6981978 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs845595
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 845595 - Make nsIDOMWindowUtils::selectAtPoint coordinates relative to the DWU's document. r=jimm
dom/base/nsDOMWindowUtils.cpp
dom/tests/mochitest/chrome/selectAtPoint.html
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -3006,18 +3006,19 @@ nsDOMWindowUtils::SelectAtPoint(float aX
 
   // The root frame for this content window
   nsIFrame* rootFrame = presShell->FrameManager()->GetRootFrame();
   if (!rootFrame) {
     return NS_ERROR_UNEXPECTED;
   }
 
   // Get the target frame at the client coordinates passed to us
-  nsCOMPtr<nsIWidget> widget = GetWidget();
-  nsIntPoint pt(aX, aY);
+  nsPoint offset;
+  nsCOMPtr<nsIWidget> widget = GetWidget(&offset);
+  nsIntPoint pt = ToWidgetPoint(aX, aY, offset, GetPresContext());
   nsPoint ptInRoot =
     nsLayoutUtils::GetEventCoordinatesRelativeTo(widget, pt, rootFrame);
   nsIFrame* targetFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, ptInRoot);
   // This can happen if the page hasn't loaded yet or if the point
   // is outside the frame.
   if (!targetFrame) {
     return NS_ERROR_INVALID_ARG;
   }
--- a/dom/tests/mochitest/chrome/selectAtPoint.html
+++ b/dom/tests/mochitest/chrome/selectAtPoint.html
@@ -159,18 +159,18 @@
                         .defaultView
                         .QueryInterface(Ci.nsIInterfaceRequestor)
                         .getInterface(Ci.nsIDOMWindowUtils);
 
     frame.contentWindow.scrollTo(0, 0);
 
     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);
     if (isLinux || isMac) {
       checkSelection(frame.contentWindow.document, "SELECT_WORD", "ttestselection2");
     } else if (isWindows) {
       checkSelection(frame.contentWindow.document, "SELECT_WORD", "ttestselection2 ");
     }