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

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

Issue 1951353002: Fixed a bug that assumed that static text object span only one line (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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 98aff68113beac47edc8483f18789104f58c5587..4f61fba7c511dbbdf605aefce7df7e519ca6f477 100644
--- a/content/browser/accessibility/browser_accessibility.cc
+++ b/content/browser/accessibility/browser_accessibility.cc
@@ -521,12 +521,10 @@ int BrowserAccessibility::GetLineStartBoundary(
DCHECK_GE(start, 0);
DCHECK_LE(start, static_cast<int>(GetText().length()));
- if (IsSimpleTextControl()) {
- const std::vector<int32_t>& line_breaks =
- GetIntListAttribute(ui::AX_ATTR_LINE_BREAKS);
- return ui::FindAccessibleTextBoundary(GetText(), line_breaks,
- ui::LINE_BOUNDARY, start, direction);
- }
+ // Standard text fields such as textarea have an embedded div inside them that
+ // holds all the text.
+ if (IsSimpleTextControl() && InternalChildCount() == 1)
dmazzoni 2016/05/05 18:35:04 Why doesn't it work if you just delete this if sta
+ return InternalGetChild(0)->GetLineStartBoundary(start, direction);
// Keeps track of the start offset of each consecutive line.
int line_start = 0;
@@ -541,31 +539,33 @@ int BrowserAccessibility::GetLineStartBoundary(
if (child->IsTextOnlyObject())
child_length = static_cast<int>(child->GetText().length());
line_length += child_length;
- start -= child_length;
- // Stop when we reach both the object containing our start offset and the
- // end of the line on which this object is located.
- if (start < 0 && !child->IsNextSiblingOnSameLine())
+ // Stop when we reach both the child containing our start offset and the
+ // child that is at the end of the line on which this object is located.
+ if (start < child_length && !child->IsNextSiblingOnSameLine()) {
+ // Recurse into the inline text boxes.
+ if (child->GetRole() == ui::AX_ROLE_STATIC_TEXT)
+ return line_start + child->GetLineStartBoundary(start, direction);
+
+ // There are no inline text boxes to look at.
break;
+ }
if (!child->IsNextSiblingOnSameLine()) {
line_start += line_length;
line_length = 0;
}
+ start -= child_length;
}
- int result = 0;
switch (direction) {
case ui::FORWARDS_DIRECTION:
- result = line_start + line_length;
- break;
+ return line_start + line_length;
case ui::BACKWARDS_DIRECTION:
- result = line_start;
- break;
- default:
- NOTREACHED();
+ return line_start;
}
- return result;
+ NOTREACHED();
+ return 0;
}
int BrowserAccessibility::GetWordStartBoundary(
« 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