mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 650241 - Location returned by accessibles sometimes incorrect when page zoomed, r=marcoz
This commit is contained in:
parent
a4b60fe14a
commit
d997c09ad5
@ -1060,7 +1060,8 @@ nsAccessible::GetBounds(PRInt32* aX, PRInt32* aY,
|
||||
*aHeight = presContext->AppUnitsToDevPixels(unionRectTwips.height);
|
||||
|
||||
// We have the union of the rectangle, now we need to put it in absolute screen coords
|
||||
nsIntRect orgRectPixels = boundingFrame->GetScreenRectExternal();
|
||||
nsIntRect orgRectPixels = boundingFrame->GetScreenRectInAppUnits().
|
||||
ToNearestPixels(presContext->AppUnitsPerDevPixel());
|
||||
*aX += orgRectPixels.x;
|
||||
*aY += orgRectPixels.y;
|
||||
|
||||
|
@ -45,6 +45,7 @@ relativesrcdir = accessible
|
||||
DIRS = \
|
||||
actions \
|
||||
attributes \
|
||||
bounds \
|
||||
editabletext \
|
||||
elm \
|
||||
events \
|
||||
|
53
accessible/tests/mochitest/bounds/Makefile.in
Normal file
53
accessible/tests/mochitest/bounds/Makefile.in
Normal file
@ -0,0 +1,53 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2012
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Alexander Surkov <surkov.alexander@gmail.com> (original author)
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
relativesrcdir = accessible/bounds
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_TEST_FILES =\
|
||||
test_zoom.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/a11y/$(relativesrcdir)
|
74
accessible/tests/mochitest/bounds/test_zoom.html
Normal file
74
accessible/tests/mochitest/bounds/test_zoom.html
Normal file
@ -0,0 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Accessible boundaries 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">
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// If your patch changes UI or default styles then please tweek the numbers.
|
||||
// Accessibility exposes coordinates and size in device pixels while DOM
|
||||
// operates with CSS pixels. Thus it seems we don't have another way for
|
||||
// accessibility testing rather than numbers hardcode.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function doTest()
|
||||
{
|
||||
var [outerX, outerY] = getBounds(getAccessible(currentTabDocument()).parent);
|
||||
|
||||
var p1 = currentTabDocument().body.firstElementChild;
|
||||
var p2 = currentTabDocument().body.lastElementChild;
|
||||
|
||||
var deltaX = 8, deltaY = 8, indentY = 16, w = 584, h = (WIN ? 20 : 19);
|
||||
testBounds(p1, outerX + deltaX, outerY + deltaY, w, h);
|
||||
testBounds(p2, outerX + deltaX, outerY + deltaY + h + indentY, w, h);
|
||||
|
||||
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;
|
||||
|
||||
testBounds(p1, outerX + deltaX * 2, outerY + deltaY * 2, w * 2, h * 2);
|
||||
testBounds(p2, outerX + deltaX * 2, outerY + (deltaY + h + indentY) * 2,
|
||||
w * 2, h * 2);
|
||||
|
||||
closeBrowserWindow();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
openBrowserWindow(doTest,
|
||||
"data:text/html,<html><body><p>para 1</p><p>para 2</p></body></html>",
|
||||
{ left: 0, top: 0, width: 600, height: 600 });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=650241"
|
||||
title="Location returned by accessibles incorrect when page zoomed">
|
||||
Mozilla Bug 650241
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -1,10 +1,11 @@
|
||||
/**
|
||||
* Load the browser with the given url and then invokes the given function.
|
||||
*/
|
||||
function openBrowserWindow(aFunc, aURL)
|
||||
function openBrowserWindow(aFunc, aURL, aRect)
|
||||
{
|
||||
gBrowserContext.testFunc = aFunc;
|
||||
gBrowserContext.startURL = aURL;
|
||||
gBrowserContext.browserRect = aRect;
|
||||
|
||||
addLoadEvent(openBrowserWindowIntl);
|
||||
}
|
||||
@ -57,6 +58,14 @@ function currentTabDocument()
|
||||
return currentBrowser().contentDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return window of the current tab.
|
||||
*/
|
||||
function currentTabWindow()
|
||||
{
|
||||
return currentTabDocument().defaultView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return browser element of the tab at the given index.
|
||||
*/
|
||||
@ -103,9 +112,22 @@ var gBrowserContext =
|
||||
|
||||
function openBrowserWindowIntl()
|
||||
{
|
||||
var params = "chrome,all,dialog=no";
|
||||
var rect = gBrowserContext.browserRect;
|
||||
if (rect) {
|
||||
if ("left" in rect)
|
||||
params += ",left=" + rect.left;
|
||||
if ("top" in rect)
|
||||
params += ",top=" + rect.top;
|
||||
if ("width" in rect)
|
||||
params += ",width=" + rect.width;
|
||||
if ("height" in rect)
|
||||
params += ",height=" + rect.height;
|
||||
}
|
||||
|
||||
gBrowserContext.browserWnd =
|
||||
window.openDialog(Services.prefs.getCharPref("browser.chromeURL"),
|
||||
"_blank", "chrome,all,dialog=no",
|
||||
"_blank", params,
|
||||
gBrowserContext.startURL);
|
||||
|
||||
addA11yLoadEvent(startBrowserTests, browserWindow());
|
||||
|
@ -55,6 +55,29 @@ function getChildAtPoint(aIdentifier, aX, aY, aFindDeepestChild)
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the accessible boundaries.
|
||||
*/
|
||||
function testBounds(aID, aX, aY, aWidth, aHeight)
|
||||
{
|
||||
var [x, y, width, height] = getBounds(aID);
|
||||
is(x, aX, "Wrong x coordinate of " + prettyName(aID));
|
||||
is(y, aY, "Wrong y coordinate of " + prettyName(aID));
|
||||
is(width, aWidth, "Wrong width of " + prettyName(aID));
|
||||
is(height, aHeight, "Wrong height of " + prettyName(aID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the accessible coordinates and size relative to the screen.
|
||||
*/
|
||||
function getBounds(aID)
|
||||
{
|
||||
var accessible = getAccessible(aID);
|
||||
var x = {}, y = {}, width = {}, height = {};
|
||||
accessible.getBounds(x, y, width, height);
|
||||
return [x.value, y.value, width.value, height.value];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return DOM node coordinates relative screen as pair (x, y).
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user