mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 727942 - childAtPoint may return incorrect accessibles when page zoomed, r=marcoz
This commit is contained in:
parent
9c5863240f
commit
a2ea25b37d
@ -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<nsIPresShell> presShell = presContext->PresShell();
|
||||
nsIFrame *foundFrame = presShell->GetFrameForPoint(frame, offset);
|
||||
|
@ -20,19 +20,14 @@
|
||||
<script type="application/javascript">
|
||||
function doTest()
|
||||
{
|
||||
var p1 = currentTabDocument().body.firstElementChild;
|
||||
var p2 = currentTabDocument().body.lastElementChild;
|
||||
var tabDocument = currentTabDocument();
|
||||
var p1 = tabDocument.body.firstElementChild;
|
||||
var p2 = tabDocument.body.lastElementChild;
|
||||
|
||||
testBounds(p1);
|
||||
testBounds(p2);
|
||||
|
||||
var docShell = currentTabWindow().
|
||||
QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIWebNavigation).
|
||||
QueryInterface(Components.interfaces.nsIDocShell);
|
||||
var docViewer = docShell.contentViewer.
|
||||
QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);
|
||||
docViewer.fullZoom = 2.0;
|
||||
zoomDocument(tabDocument, 2.0);
|
||||
|
||||
testBounds(p1);
|
||||
testBounds(p2);
|
||||
|
@ -98,6 +98,21 @@ function reloadButton()
|
||||
return browserWindow().document.getElementById("urlbar-reload-button");
|
||||
}
|
||||
|
||||
/**
|
||||
* Zoom the given document.
|
||||
*/
|
||||
function zoomDocument(aDocument, aZoom)
|
||||
{
|
||||
var docShell = aDocument.defaultView.
|
||||
QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIWebNavigation).
|
||||
QueryInterface(Components.interfaces.nsIDocShell);
|
||||
var docViewer = docShell.contentViewer.
|
||||
QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);
|
||||
|
||||
docViewer.fullZoom = aZoom;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// private section
|
||||
|
||||
|
@ -46,9 +46,10 @@ include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_TEST_FILES = \
|
||||
test_browser.html \
|
||||
test_general.html \
|
||||
test_general.xul \
|
||||
test_browser.html \
|
||||
test_zoom.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
|
57
accessible/tests/mochitest/hittest/test_zoom.html
Normal file
57
accessible/tests/mochitest/hittest/test_zoom.html
Normal file
@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>childAtPoint when page is zoomed</title>
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="../common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../role.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../layout.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../browser.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function doTest()
|
||||
{
|
||||
var tabDocument = currentTabDocument();
|
||||
var p1 = tabDocument.body.firstElementChild;
|
||||
var p2 = tabDocument.body.lastElementChild;
|
||||
|
||||
hitTest(tabDocument, p1, p1.firstChild);
|
||||
hitTest(tabDocument, p2, p2.firstChild);
|
||||
|
||||
zoomDocument(tabDocument, 2.0);
|
||||
|
||||
hitTest(tabDocument, p1, p1.firstChild);
|
||||
hitTest(tabDocument, p2, p2.firstChild);
|
||||
|
||||
closeBrowserWindow();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
openBrowserWindow(doTest,
|
||||
"data:text/html,<html><body><p>para 1</p><p>para 2</p></body></html>",
|
||||
{ left: 100, top: 100 });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=727942"
|
||||
title="childAtPoint may return incorrect accessibles when page zoomed">
|
||||
Mozilla Bug 727942
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -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.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user