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

Side by Side Diff: ui/accessibility/ax_node.cc

Issue 2437473003: Fixed line start offsets. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « ui/accessibility/ax_node.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/accessibility/ax_node.h" 5 #include "ui/accessibility/ax_node.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "ui/gfx/transform.h" 10 #include "ui/gfx/transform.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return parent()->IsDescendantOf(ancestor); 53 return parent()->IsDescendantOf(ancestor);
54 54
55 return false; 55 return false;
56 } 56 }
57 57
58 std::vector<int> AXNode::GetOrComputeLineStartOffsets() { 58 std::vector<int> AXNode::GetOrComputeLineStartOffsets() {
59 std::vector<int> line_offsets; 59 std::vector<int> line_offsets;
60 if (data().GetIntListAttribute(AX_ATTR_CACHED_LINE_STARTS, &line_offsets)) 60 if (data().GetIntListAttribute(AX_ATTR_CACHED_LINE_STARTS, &line_offsets))
61 return line_offsets; 61 return line_offsets;
62 62
63 int end_offset = 0; 63 int start_offset = 0;
64 ComputeLineStartOffsets(&line_offsets, &end_offset); 64 ComputeLineStartOffsets(&line_offsets, &start_offset);
65 data_.AddIntListAttribute(AX_ATTR_CACHED_LINE_STARTS, line_offsets); 65 data_.AddIntListAttribute(AX_ATTR_CACHED_LINE_STARTS, line_offsets);
66 return line_offsets; 66 return line_offsets;
67 } 67 }
68 68
69 void AXNode::ComputeLineStartOffsets(std::vector<int>* line_offsets, 69 void AXNode::ComputeLineStartOffsets(std::vector<int>* line_offsets,
70 int* end_offset) const { 70 int* start_offset) const {
71 DCHECK(line_offsets); 71 DCHECK(line_offsets);
72 DCHECK(end_offset); 72 DCHECK(start_offset);
73 for (const AXNode* child : children()) { 73 for (const AXNode* child : children()) {
74 DCHECK(child); 74 DCHECK(child);
75 if (child->child_count()) { 75 if (child->child_count()) {
76 child->ComputeLineStartOffsets(line_offsets, end_offset); 76 child->ComputeLineStartOffsets(line_offsets, start_offset);
77 continue; 77 continue;
78 } 78 }
79 79
80 if (!child->data().HasIntAttribute(ui::AX_ATTR_PREVIOUS_ON_LINE_ID))
David Tseng 2016/10/19 17:39:42 This is still wrong... - this would include 0; th
81 line_offsets->push_back(*start_offset);
80 base::string16 text = child->data().GetString16Attribute(ui::AX_ATTR_NAME); 82 base::string16 text = child->data().GetString16Attribute(ui::AX_ATTR_NAME);
81 *end_offset += static_cast<int>(text.length()); 83 *start_offset += static_cast<int>(text.length());
82 if (!child->data().HasIntAttribute(ui::AX_ATTR_NEXT_ON_LINE_ID))
83 line_offsets->push_back(*end_offset);
84 } 84 }
85 } 85 }
86 86
87 } // namespace ui 87 } // namespace ui
OLDNEW
« 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