Commit 6cbfd306 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Revert "Return unclipped bounds for get_characterExtents"

This reverts commit 84c92630.

Reason for revert: Suspected to cause compile failure at https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/Android%20Release%20%28Nexus%205X%29/8033

Original change's description:
> 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.
> 
> Bug: 864195
> Change-Id: Ibea1f3ecb0b8f5f72c6fc967892ac9e6b1af135b
> Reviewed-on: https://chromium-review.googlesource.com/1138800
> Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
> Reviewed-by: Dominic Mazzoni <dmazzoni@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#575831}

TBR=dmazzoni@chromium.org,aleventhal@chromium.org

Change-Id: I5efff2e628b9518039777b8317a581c4c0bc326e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 864195
Reviewed-on: https://chromium-review.googlesource.com/1140459Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575842}
parent 4c64e737
...@@ -1290,12 +1290,16 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, ...@@ -1290,12 +1290,16 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
EXPECT_EQ(previous_height, height) << "at offset " << offset; 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( EXPECT_HRESULT_SUCCEEDED(editable_container->get_characterExtents(
last_line_start, coordinate_type, &x, &y, &width, &height)); last_line_start, coordinate_type, &x, &y, &width, &height));
EXPECT_LT(0, x) << "at offset " << last_line_start; EXPECT_LT(0, x) << "at offset " << last_line_start;
EXPECT_LT(previous_y, y) << "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_LT(1, width) << "at offset " << last_line_start;
EXPECT_EQ(previous_height, height) << "at offset " << last_line_start; EXPECT_EQ(1, height) << "at offset " << last_line_start;
for (LONG offset = last_line_start + 1; offset < n_characters; ++offset) { for (LONG offset = last_line_start + 1; offset < n_characters; ++offset) {
previous_x = x; previous_x = x;
...@@ -1306,7 +1310,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, ...@@ -1306,7 +1310,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
EXPECT_LT(previous_x, x) << "at offset " << offset; EXPECT_LT(previous_x, x) << "at offset " << offset;
EXPECT_EQ(previous_y, y) << "at offset " << offset; EXPECT_EQ(previous_y, y) << "at offset " << offset;
EXPECT_LT(1, width) << "at offset " << offset; EXPECT_LT(1, width) << "at offset " << offset;
EXPECT_EQ(previous_height, height) << "at offset " << offset; EXPECT_EQ(1, height) << "at offset " << offset;
} }
} }
} }
...@@ -1330,13 +1334,21 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, ...@@ -1330,13 +1334,21 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
coordinate <= IA2_COORDTYPE_PARENT_RELATIVE; ++coordinate) { coordinate <= IA2_COORDTYPE_PARENT_RELATIVE; ++coordinate) {
auto coordinate_type = static_cast<IA2CoordinateType>(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( EXPECT_HRESULT_SUCCEEDED(input_text->get_characterExtents(
0, coordinate_type, &x, &y, &width, &height)); 0, coordinate_type, &x, &y, &width, &height));
EXPECT_GT(0, x + width) << "at offset 0"; EXPECT_LT(0, x + width) << "at offset 0";
EXPECT_LT(0, y) << "at offset 0"; EXPECT_LT(0, y) << "at offset 0";
EXPECT_LT(1, width) << "at offset 0"; EXPECT_EQ(1, width) << "at offset 0";
EXPECT_LT(1, height) << "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) { for (LONG offset = 1; offset < (visible_characters_start - 1); ++offset) {
previous_x = x; previous_x = x;
previous_y = y; previous_y = y;
...@@ -1344,9 +1356,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, ...@@ -1344,9 +1356,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
EXPECT_HRESULT_SUCCEEDED(input_text->get_characterExtents( EXPECT_HRESULT_SUCCEEDED(input_text->get_characterExtents(
offset, coordinate_type, &x, &y, &width, &height)); offset, coordinate_type, &x, &y, &width, &height));
EXPECT_LT(previous_x, x) << "at offset " << offset; EXPECT_EQ(previous_x, x) << "at offset " << offset;
EXPECT_EQ(previous_y, y) << "at offset " << offset; EXPECT_EQ(previous_y, y) << "at offset " << offset;
EXPECT_LT(1, width) << "at offset " << offset; EXPECT_EQ(1, width) << "at offset " << offset;
EXPECT_EQ(previous_height, height) << "at offset " << offset; EXPECT_EQ(previous_height, height) << "at offset " << offset;
} }
...@@ -1354,7 +1366,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, ...@@ -1354,7 +1366,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
// width that is greater than 1px. // width that is greater than 1px.
EXPECT_HRESULT_SUCCEEDED(input_text->get_characterExtents( EXPECT_HRESULT_SUCCEEDED(input_text->get_characterExtents(
visible_characters_start, coordinate_type, &x, &y, &width, &height)); visible_characters_start, coordinate_type, &x, &y, &width, &height));
EXPECT_LT(previous_x, x) << "at offset " << visible_characters_start; EXPECT_EQ(previous_x, x) << "at offset " << visible_characters_start;
EXPECT_EQ(previous_y, y) << "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_LT(1, width) << "at offset " << visible_characters_start;
EXPECT_EQ(previous_height, height) EXPECT_EQ(previous_height, height)
......
...@@ -343,9 +343,8 @@ gfx::Rect BrowserAccessibility::GetPageBoundsRect(bool* offscreen, ...@@ -343,9 +343,8 @@ gfx::Rect BrowserAccessibility::GetPageBoundsRect(bool* offscreen,
return RelativeToAbsoluteBounds(gfx::RectF(), false, offscreen, clip_bounds); return RelativeToAbsoluteBounds(gfx::RectF(), false, offscreen, clip_bounds);
} }
gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start, gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start, int len)
int len, const {
bool clipped) const {
DCHECK_GE(start, 0); DCHECK_GE(start, 0);
DCHECK_GE(len, 0); DCHECK_GE(len, 0);
...@@ -465,11 +464,9 @@ gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start, ...@@ -465,11 +464,9 @@ gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start,
} }
} }
// 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( gfx::Rect absolute_child_rect = child->RelativeToAbsoluteBounds(
child_overlap_rect, false /* frame_only */, nullptr /* offscreen */, child_overlap_rect, false /* frame_only */, nullptr /* offscreen */,
clipped /* clip_bounds */); true /* clip_bounds */);
if (bounds.width() == 0 && bounds.height() == 0) { if (bounds.width() == 0 && bounds.height() == 0) {
bounds = absolute_child_rect; bounds = absolute_child_rect;
} else { } else {
...@@ -480,10 +477,9 @@ gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start, ...@@ -480,10 +477,9 @@ gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start,
return bounds; return bounds;
} }
gfx::Rect BrowserAccessibility::GetScreenBoundsForRange(int start, gfx::Rect BrowserAccessibility::GetScreenBoundsForRange(int start, int len)
int len, const {
bool clipped) const { gfx::Rect bounds = GetPageBoundsForRange(start, len);
gfx::Rect bounds = GetPageBoundsForRange(start, len, clipped);
// Adjust the bounds by the top left corner of the containing view's bounds // Adjust the bounds by the top left corner of the containing view's bounds
// in screen coordinates. // in screen coordinates.
......
...@@ -160,14 +160,10 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate { ...@@ -160,14 +160,10 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate {
// Returns the bounds of the given range in coordinates relative to the // Returns the bounds of the given range in coordinates relative to the
// top-left corner of the overall web area. Only valid when the // top-left corner of the overall web area. Only valid when the
// role is WebAXRoleStaticText. // role is WebAXRoleStaticText.
gfx::Rect GetPageBoundsForRange(int start, gfx::Rect GetPageBoundsForRange(int start, int len) const;
int len,
bool clipped = false) const;
// Same as |GetPageBoundsForRange| but in screen coordinates. // Same as |GetPageBoundsForRange| but in screen coordinates.
gfx::Rect GetScreenBoundsForRange(int start, gfx::Rect GetScreenBoundsForRange(int start, int len) const;
int len,
bool clipped = false) const;
// Convert a bounding rectangle from this node's coordinate system // Convert a bounding rectangle from this node's coordinate system
// (which is relative to its nearest scrollable ancestor) to // (which is relative to its nearest scrollable ancestor) to
......
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