Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Unified Diff: content/browser/accessibility/browser_accessibility.cc

Issue 2579323002: Clamps the character ranges for which bounds are requested so that they fall within the number of p… (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/accessibility/browser_accessibility.cc
diff --git a/content/browser/accessibility/browser_accessibility.cc b/content/browser/accessibility/browser_accessibility.cc
index 6ae417ff521e5fd8d2e37ba3b282de6a2358ea80..3343feb263caae9858ead1ff1dbe898df0d99532 100644
--- a/content/browser/accessibility/browser_accessibility.cc
+++ b/content/browser/accessibility/browser_accessibility.cc
@@ -456,8 +456,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 =
@@ -497,8 +502,6 @@ gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start, int len)
child_rect.width(), bottom - top);
break;
}
- default:
- NOTREACHED();
}
if (bounds.width() == 0 && bounds.height() == 0)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698