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

Unified Diff: ui/accessibility/ax_node.cc

Issue 2437473003: Fixed line start offsets. (Closed)
Patch Set: Fixed tests and nits. Created 4 years, 2 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 | « ui/accessibility/ax_node.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accessibility/ax_node.cc
diff --git a/ui/accessibility/ax_node.cc b/ui/accessibility/ax_node.cc
index 459095eef929ad0b4aa66e1e92efda852674b993..c55bf97fa92a48784c74d52520f18744d2d702ac 100644
--- a/ui/accessibility/ax_node.cc
+++ b/ui/accessibility/ax_node.cc
@@ -60,27 +60,34 @@ std::vector<int> AXNode::GetOrComputeLineStartOffsets() {
if (data().GetIntListAttribute(AX_ATTR_CACHED_LINE_STARTS, &line_offsets))
return line_offsets;
- int end_offset = 0;
- ComputeLineStartOffsets(&line_offsets, &end_offset);
+ int start_offset = 0;
+ ComputeLineStartOffsets(&line_offsets, &start_offset);
data_.AddIntListAttribute(AX_ATTR_CACHED_LINE_STARTS, line_offsets);
return line_offsets;
}
void AXNode::ComputeLineStartOffsets(std::vector<int>* line_offsets,
- int* end_offset) const {
+ int* start_offset) const {
DCHECK(line_offsets);
- DCHECK(end_offset);
+ DCHECK(start_offset);
for (const AXNode* child : children()) {
DCHECK(child);
if (child->child_count()) {
- child->ComputeLineStartOffsets(line_offsets, end_offset);
+ child->ComputeLineStartOffsets(line_offsets, start_offset);
continue;
}
+ // Don't report if the first piece of text starts a new line or not.
+ if (*start_offset &&
+ !child->data().HasIntAttribute(ui::AX_ATTR_PREVIOUS_ON_LINE_ID)) {
+ // If there are multiple objects with an empty accessible label at the
+ // start of a line, only include a single line start offset.
+ if (line_offsets->empty() || line_offsets->back() != *start_offset)
+ line_offsets->push_back(*start_offset);
+ }
+
base::string16 text = child->data().GetString16Attribute(ui::AX_ATTR_NAME);
- *end_offset += static_cast<int>(text.length());
- if (!child->data().HasIntAttribute(ui::AX_ATTR_NEXT_ON_LINE_ID))
- line_offsets->push_back(*end_offset);
+ *start_offset += static_cast<int>(text.length());
}
}
« no previous file with comments | « ui/accessibility/ax_node.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698