Commit 120547ee authored by Aaron Leventhal's avatar Aaron Leventhal Committed by Commit Bot

Reland: Return unclipped bounds for get_characterExtents

For get_characterExtents():
- The x,y position should be unclipped (allowed to be negative or larger than the screen width/height).
- The width/height should not be changed to 1 for offscreen objects.

TBR=dmazzoni@chromium.org

Bug: 864195
Change-Id: Ib8a57bee7f3b70f46c1c6791ea4c5a294c5ccfe5
Reviewed-on: https://chromium-review.googlesource.com/1146877Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577285}
parent 3b6994b4
......@@ -1290,16 +1290,12 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
EXPECT_EQ(previous_height, height) << "at offset " << offset;
}
// Vertically offscreen objects should have a height of 1px so that if an
// assistive aid ignores the offscreen state, they will still be too small
// to be visible and thus not appear outside the window. Note that a height
// of 0 is not used because it signifies an invalid size.
EXPECT_HRESULT_SUCCEEDED(editable_container->get_characterExtents(
last_line_start, coordinate_type, &x, &y, &width, &height));
EXPECT_LT(0, x) << "at offset " << last_line_start;
EXPECT_LT(previous_y, y) << "at offset " << last_line_start;
EXPECT_LT(1, width) << "at offset " << last_line_start;
EXPECT_EQ(1, height) << "at offset " << last_line_start;
EXPECT_EQ(previous_height, height) << "at offset " << last_line_start;
for (LONG offset = last_line_start + 1; offset < n_characters; ++offset) {
previous_x = x;
......@@ -1310,7 +1306,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
EXPECT_LT(previous_x, x) << "at offset " << offset;
EXPECT_EQ(previous_y, y) << "at offset " << offset;
EXPECT_LT(1, width) << "at offset " << offset;
EXPECT_EQ(1, height) << "at offset " << offset;
EXPECT_EQ(previous_height, height) << "at offset " << offset;
}
}
}
......@@ -1334,21 +1330,13 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
coordinate <= IA2_COORDTYPE_PARENT_RELATIVE; ++coordinate) {
auto coordinate_type = static_cast<IA2CoordinateType>(coordinate);
// Horizontally offscreen objects should have a width of 1px so that if an
// assistive aid ignores the offscreen state, they will still be too small
// to be visible and thus not appear outside the window. Note that a width
// of 0 is not used because it signifies an invalid size.
EXPECT_HRESULT_SUCCEEDED(input_text->get_characterExtents(
0, coordinate_type, &x, &y, &width, &height));
EXPECT_LT(0, x + width) << "at offset 0";
EXPECT_GT(0, x + width) << "at offset 0";
EXPECT_LT(0, y) << "at offset 0";
EXPECT_EQ(1, width) << "at offset 0";
EXPECT_LT(1, width) << "at offset 0";
EXPECT_LT(1, height) << "at offset 0";
// Test that characters at the start of the input field are offscreen by
// checking that their x coordinate is at the start of the field and their
// width is 1.
// Exclude the character that is partly visible.
for (LONG offset = 1; offset < (visible_characters_start - 1); ++offset) {
previous_x = x;
previous_y = y;
......@@ -1356,9 +1344,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
EXPECT_HRESULT_SUCCEEDED(input_text->get_characterExtents(
offset, coordinate_type, &x, &y, &width, &height));
EXPECT_EQ(previous_x, x) << "at offset " << offset;
EXPECT_LT(previous_x, x) << "at offset " << offset;
EXPECT_EQ(previous_y, y) << "at offset " << offset;
EXPECT_EQ(1, width) << "at offset " << offset;
EXPECT_LT(1, width) << "at offset " << offset;
EXPECT_EQ(previous_height, height) << "at offset " << offset;
}
......@@ -1366,7 +1354,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
// width that is greater than 1px.
EXPECT_HRESULT_SUCCEEDED(input_text->get_characterExtents(
visible_characters_start, coordinate_type, &x, &y, &width, &height));
EXPECT_EQ(previous_x, x) << "at offset " << visible_characters_start;
EXPECT_LT(previous_x, x) << "at offset " << visible_characters_start;
EXPECT_EQ(previous_y, y) << "at offset " << visible_characters_start;
EXPECT_LT(1, width) << "at offset " << visible_characters_start;
EXPECT_EQ(previous_height, height)
......
......@@ -343,8 +343,9 @@ gfx::Rect BrowserAccessibility::GetPageBoundsRect(bool* offscreen,
return RelativeToAbsoluteBounds(gfx::RectF(), false, offscreen, clip_bounds);
}
gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start, int len)
const {
gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start,
int len,
bool clipped) const {
DCHECK_GE(start, 0);
DCHECK_GE(len, 0);
......@@ -464,9 +465,11 @@ gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start, int len)
}
}
// Don't clip bounds. Some screen magnifiers (e.g. ZoomText) prefer to
// get unclipped bounds so that they can make smooth scrolling calculations.
gfx::Rect absolute_child_rect = child->RelativeToAbsoluteBounds(
child_overlap_rect, false /* frame_only */, nullptr /* offscreen */,
true /* clip_bounds */);
clipped /* clip_bounds */);
if (bounds.width() == 0 && bounds.height() == 0) {
bounds = absolute_child_rect;
} else {
......@@ -477,9 +480,10 @@ gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start, int len)
return bounds;
}
gfx::Rect BrowserAccessibility::GetScreenBoundsForRange(int start, int len)
const {
gfx::Rect bounds = GetPageBoundsForRange(start, len);
gfx::Rect BrowserAccessibility::GetScreenBoundsForRange(int start,
int len,
bool clipped) const {
gfx::Rect bounds = GetPageBoundsForRange(start, len, clipped);
// Adjust the bounds by the top left corner of the containing view's bounds
// in screen coordinates.
......
......@@ -160,10 +160,14 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate {
// Returns the bounds of the given range in coordinates relative to the
// top-left corner of the overall web area. Only valid when the
// role is WebAXRoleStaticText.
gfx::Rect GetPageBoundsForRange(int start, int len) const;
gfx::Rect GetPageBoundsForRange(int start,
int len,
bool clipped = false) const;
// Same as |GetPageBoundsForRange| but in screen coordinates.
gfx::Rect GetScreenBoundsForRange(int start, int len) const;
gfx::Rect GetScreenBoundsForRange(int start,
int len,
bool clipped = false) const;
// Convert a bounding rectangle from this node's coordinate system
// (which is relative to its nearest scrollable ancestor) to
......
......@@ -1189,7 +1189,7 @@ WebContentsAccessibilityAndroid::GetCharacterBoundingBoxes(
gfx::Rect object_bounds = node->GetPageBoundsRect();
int coords[4 * len];
for (int i = 0; i < len; i++) {
gfx::Rect char_bounds = node->GetPageBoundsForRange(start + i, 1);
gfx::Rect char_bounds = node->GetPageBoundsForRange(start + i, 1, false);
if (char_bounds.IsEmpty())
char_bounds = object_bounds;
coords[4 * i + 0] = char_bounds.x();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment