mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
Bug 1769640 - P2: Translate parent bounds to sceen bounds. r=geckoview-reviewers,agi
We used to get screen bounds from the gecko layer and needed to strip the screen offsets for parent-relative offsets. It is now the opposite, the bounds we get from gecko do not have the screen offsets of the top View. Differential Revision: https://phabricator.services.mozilla.com/D146508
This commit is contained in:
parent
c42dbc8b0f
commit
4cc4578c5b
@ -2,9 +2,21 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
iframe {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
Some stuff
|
||||
<iframe src="../hello.html" id="iframe" width="100%" height="100%"></iframe>
|
||||
<iframe src="../hello.html" id="iframe"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -2,9 +2,20 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
iframe {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
Some stuff
|
||||
<iframe src="https://example.org/tests/junit/hello.html" id="iframe" width="100%" height="100%"></iframe>
|
||||
<iframe src="https://example.org/tests/junit/hello.html" id="iframe"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1317,8 +1317,15 @@ class AccessibilityTest : BaseSessionTest() {
|
||||
|
||||
val rootNode = createNodeInfo(View.NO_ID)
|
||||
assertThat("Document has 3 children", rootNode.childCount, equalTo(3))
|
||||
var rootBounds = Rect()
|
||||
rootNode.getBoundsInScreen(rootBounds)
|
||||
assertThat("Root node bounds are not empty", rootBounds.isEmpty, equalTo(false))
|
||||
|
||||
var labelBounds = Rect()
|
||||
val labelNode = createNodeInfo(rootNode.getChildId(0))
|
||||
labelNode.getBoundsInScreen(labelBounds)
|
||||
|
||||
assertThat("Label bounds are in parent", rootBounds.contains(labelBounds), equalTo(true))
|
||||
assertThat("First node is a label", labelNode.className.toString(), equalTo("android.view.View"))
|
||||
assertThat("Label has text", labelNode.text.toString(), equalTo("Name:"))
|
||||
|
||||
@ -1398,6 +1405,9 @@ class AccessibilityTest : BaseSessionTest() {
|
||||
|
||||
val rootNode = createNodeInfo(View.NO_ID)
|
||||
assertThat("Document has 2 children", rootNode.childCount, equalTo(2))
|
||||
var rootBounds = Rect()
|
||||
rootNode.getBoundsInScreen(rootBounds)
|
||||
assertThat("Root bounds are not empty", rootBounds.isEmpty, equalTo(false))
|
||||
|
||||
val labelNode = createNodeInfo(rootNode.getChildId(0))
|
||||
assertThat("First node has text", labelNode.text.toString(), equalTo("Some stuff "))
|
||||
@ -1405,15 +1415,25 @@ class AccessibilityTest : BaseSessionTest() {
|
||||
val iframeNode = createNodeInfo(rootNode.getChildId(1))
|
||||
assertThat("iframe has vieIdwResourceName of 'iframe'", iframeNode.viewIdResourceName, equalTo("iframe"))
|
||||
assertThat("iframe has 1 child", iframeNode.childCount, equalTo(1))
|
||||
var iframeBounds = Rect()
|
||||
iframeNode.getBoundsInScreen(iframeBounds)
|
||||
assertThat("iframe bounds in root bounds", rootBounds.contains(iframeBounds), equalTo(true))
|
||||
|
||||
val innerDocNode = createNodeInfo(iframeNode.getChildId(0))
|
||||
assertThat("Inner doc has one child", innerDocNode.childCount, equalTo(1))
|
||||
var innerDocBounds = Rect()
|
||||
innerDocNode.getBoundsInScreen(innerDocBounds)
|
||||
assertThat("iframe bounds match inner doc bounds", iframeBounds.contains(innerDocBounds), equalTo(true))
|
||||
|
||||
val section = createNodeInfo(innerDocNode.getChildId(0))
|
||||
assertThat("section has one child", innerDocNode.childCount, equalTo(1))
|
||||
|
||||
val node = createNodeInfo(section.getChildId(0))
|
||||
assertThat("Text node has text", node.text as String, equalTo("Hello, world!"))
|
||||
var nodeBounds = Rect()
|
||||
node.getBoundsInScreen(nodeBounds)
|
||||
assertThat("inner node in inner doc bounds", innerDocBounds.contains(nodeBounds), equalTo(true))
|
||||
|
||||
}
|
||||
|
||||
@Setting(key = Setting.Key.FULL_ACCESSIBILITY_TREE, value = "true")
|
||||
|
@ -8,7 +8,6 @@ package org.mozilla.geckoview;
|
||||
import android.content.Context;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
@ -393,13 +392,14 @@ public class SessionAccessibility {
|
||||
// We set the bounds in parent here because we need to use the client-to-screen matrix
|
||||
// and it is only available in the UI thread.
|
||||
final Rect bounds = new Rect();
|
||||
node.getBoundsInScreen(bounds);
|
||||
node.getBoundsInParent(bounds);
|
||||
|
||||
final Matrix matrix = new Matrix();
|
||||
mSession.getClientToScreenMatrix(matrix);
|
||||
final RectF floatBounds = new RectF(bounds);
|
||||
matrix.mapRect(floatBounds);
|
||||
floatBounds.roundOut(bounds);
|
||||
node.setBoundsInParent(bounds);
|
||||
final float[] origin = new float[2];
|
||||
matrix.mapPoints(origin);
|
||||
bounds.offset((int) origin[0], (int) origin[1]);
|
||||
node.setBoundsInScreen(bounds);
|
||||
|
||||
return node;
|
||||
}
|
||||
@ -1220,8 +1220,8 @@ public class SessionAccessibility {
|
||||
}
|
||||
node.setFocused(mFocusedNode == id);
|
||||
|
||||
final Rect screenBounds = new Rect(bounds[0], bounds[1], bounds[2], bounds[3]);
|
||||
node.setBoundsInScreen(screenBounds);
|
||||
final Rect parentBounds = new Rect(bounds[0], bounds[1], bounds[2], bounds[3]);
|
||||
node.setBoundsInParent(parentBounds);
|
||||
|
||||
for (final int childId : children) {
|
||||
node.addChild(mView, childId);
|
||||
|
Loading…
Reference in New Issue
Block a user