Commit 69c6cded authored by nektar's avatar nektar Committed by Commit bot

Clamps the character ranges for which bounds are requested so that they fall...

Clamps the character ranges for which bounds are requested so that they fall within the number of pixel offsets provided by Blink.

Blink doesn't always return the location of all the characters in  an inline text box.
BUG=674273
R=dmazzoni@chromium.org
TESTED=manually using NVDA's Python Console and by calling get_characterExtents(offset, 0) and (offset, 1) on a few paragraphs

Review-Url: https://codereview.chromium.org/2579323002
Cr-Commit-Position: refs/heads/master@{#439165}
parent 2bfe7389
......@@ -455,8 +455,13 @@ gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start, int len)
const std::vector<int32_t>& character_offsets =
child->GetIntListAttribute(ui::AX_ATTR_CHARACTER_OFFSETS);
if (static_cast<int>(character_offsets.size()) != child_length)
continue;
int character_offsets_length = static_cast<int>(character_offsets.size());
if (character_offsets_length < child_length) {
// Blink might not return pixel offsets for all characters.
// Clamp the character range to be within the number of provided pixels.
local_start = std::min(local_start, character_offsets_length);
local_end = std::min(local_end, character_offsets_length);
}
int start_pixel_offset =
local_start > 0 ? character_offsets[local_start - 1] : 0;
int end_pixel_offset =
......@@ -496,8 +501,6 @@ gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start, int len)
child_rect.width(), bottom - top);
break;
}
default:
NOTREACHED();
}
if (bounds.width() == 0 && bounds.height() == 0)
......
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