From a2ea25b37d675f1c1c973d80d03abe9fbe20a71c Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Thu, 23 Feb 2012 12:16:57 +0900 Subject: [PATCH] Bug 727942 - childAtPoint may return incorrect accessibles when page zoomed, r=marcoz --- accessible/src/base/nsAccessible.cpp | 6 +- .../tests/mochitest/bounds/test_zoom.html | 13 ++--- accessible/tests/mochitest/browser.js | 15 +++++ .../tests/mochitest/hittest/Makefile.in | 3 +- .../tests/mochitest/hittest/test_zoom.html | 57 +++++++++++++++++++ accessible/tests/mochitest/layout.js | 23 ++++++++ 6 files changed, 104 insertions(+), 13 deletions(-) create mode 100644 accessible/tests/mochitest/hittest/test_zoom.html diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index 870997c7bb3..f011d3e0aea 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -838,9 +838,9 @@ nsAccessible::ChildAtPoint(PRInt32 aX, PRInt32 aY, nsPresContext *presContext = frame->PresContext(); - nsIntRect screenRect = frame->GetScreenRectExternal(); - nsPoint offset(presContext->DevPixelsToAppUnits(aX - screenRect.x), - presContext->DevPixelsToAppUnits(aY - screenRect.y)); + nsRect screenRect = frame->GetScreenRectInAppUnits(); + nsPoint offset(presContext->DevPixelsToAppUnits(aX) - screenRect.x, + presContext->DevPixelsToAppUnits(aY) - screenRect.y); nsCOMPtr presShell = presContext->PresShell(); nsIFrame *foundFrame = presShell->GetFrameForPoint(frame, offset); diff --git a/accessible/tests/mochitest/bounds/test_zoom.html b/accessible/tests/mochitest/bounds/test_zoom.html index 70af0b096c2..ea79495f365 100644 --- a/accessible/tests/mochitest/bounds/test_zoom.html +++ b/accessible/tests/mochitest/bounds/test_zoom.html @@ -20,19 +20,14 @@ + + + + + + + + + + + + Mozilla Bug 727942 + +

+ +
+  
+ + diff --git a/accessible/tests/mochitest/layout.js b/accessible/tests/mochitest/layout.js index 5b94ccf4960..f22742575bc 100644 --- a/accessible/tests/mochitest/layout.js +++ b/accessible/tests/mochitest/layout.js @@ -22,6 +22,29 @@ function testChildAtPoint(aIdentifier, aX, aY, aFindDeepestChild, is(childAcc, actualChildAcc, msg); } +/** + * Test if getChildAtPoint returns the given child and grand child accessibles + * at coordinates of child accessible (direct and deep hit test). + */ +function hitTest(aContainerID, aChildID, aGrandChildID) +{ + var container = getAccessible(aContainerID); + var child = getAccessible(aChildID); + var grandChild = getAccessible(aGrandChildID); + + var [x, y] = getBoundsForDOMElm(child); + + var actualChild = container.getChildAtPoint(x + 1, y + 1); + is(actualChild, child, + "Wrong child, expected: " + prettyName(child) + + ", got: " + prettyName(actualChild)); + + var actualGrandChild = container.getDeepestChildAtPoint(x + 1, y + 1); + is(actualGrandChild, grandChild, + "Wrong deepest child, expected: " + prettyName(grandChild) + + ", got: " + prettyName(actualGrandChild)); +} + /** * Return child accessible at the given point. *