| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/accessibility/browser_accessibility.h" | 5 #include "content/browser/accessibility/browser_accessibility.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 const BrowserAccessibility* leaf_object = PlatformDeepestLastChild(); | 222 const BrowserAccessibility* leaf_object = PlatformDeepestLastChild(); |
| 223 if (!leaf_object) | 223 if (!leaf_object) |
| 224 leaf_object = this; | 224 leaf_object = this; |
| 225 | 225 |
| 226 int32_t next_on_line_id; | 226 int32_t next_on_line_id; |
| 227 if (leaf_object->GetIntAttribute(ui::AX_ATTR_NEXT_ON_LINE_ID, | 227 if (leaf_object->GetIntAttribute(ui::AX_ATTR_NEXT_ON_LINE_ID, |
| 228 &next_on_line_id)) { | 228 &next_on_line_id)) { |
| 229 const BrowserAccessibility* next_on_line = | 229 const BrowserAccessibility* next_on_line = |
| 230 manager()->GetFromID(next_on_line_id); | 230 manager()->GetFromID(next_on_line_id); |
| 231 // In the case of a static text sibling, the object designated to be the | 231 // In the case of a static text sibling, the object designated to be the |
| 232 // next object on this line might be one of its children, i.e. the last | 232 // next object on this line might be one of its children, i.e. the first |
| 233 // inline text box. | 233 // inline text box. |
| 234 return next_on_line && next_on_line->IsDescendantOf(next_sibling); | 234 return next_on_line && next_on_line->IsDescendantOf(next_sibling); |
| 235 } | 235 } |
| 236 return false; | 236 return false; |
| 237 } | 237 } |
| 238 | 238 |
| 239 BrowserAccessibility* BrowserAccessibility::PlatformDeepestFirstChild() const { | 239 BrowserAccessibility* BrowserAccessibility::PlatformDeepestFirstChild() const { |
| 240 if (!PlatformChildCount()) | 240 if (!PlatformChildCount()) |
| 241 return nullptr; | 241 return nullptr; |
| 242 | 242 |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 } | 526 } |
| 527 | 527 |
| 528 int BrowserAccessibility::GetLineStartBoundary( | 528 int BrowserAccessibility::GetLineStartBoundary( |
| 529 int start, | 529 int start, |
| 530 ui::TextBoundaryDirection direction, | 530 ui::TextBoundaryDirection direction, |
| 531 ui::AXTextAffinity affinity) const { | 531 ui::AXTextAffinity affinity) const { |
| 532 DCHECK_GE(start, 0); | 532 DCHECK_GE(start, 0); |
| 533 DCHECK_LE(start, static_cast<int>(GetText().length())); | 533 DCHECK_LE(start, static_cast<int>(GetText().length())); |
| 534 | 534 |
| 535 if (IsSimpleTextControl()) { | 535 if (IsSimpleTextControl()) { |
| 536 const std::vector<int32_t>& line_breaks = | 536 return ui::FindAccessibleTextBoundary(GetText(), GetLineStartOffsets(), |
| 537 GetIntListAttribute(ui::AX_ATTR_LINE_BREAKS); | |
| 538 return ui::FindAccessibleTextBoundary(GetText(), line_breaks, | |
| 539 ui::LINE_BOUNDARY, start, direction, | 537 ui::LINE_BOUNDARY, start, direction, |
| 540 affinity); | 538 affinity); |
| 541 } | 539 } |
| 542 | 540 |
| 543 // Keeps track of the start offset of each consecutive line. | 541 // Keeps track of the start offset of each consecutive line. |
| 544 int line_start = 0; | 542 int line_start = 0; |
| 545 // Keeps track of the length of each consecutive line. | 543 // Keeps track of the length of each consecutive line. |
| 546 int line_length = 0; | 544 int line_length = 0; |
| 547 for (size_t i = 0; i < InternalChildCount(); ++i) { | 545 for (size_t i = 0; i < InternalChildCount(); ++i) { |
| 548 const BrowserAccessibility* child = InternalGetChild(i); | 546 const BrowserAccessibility* child = InternalGetChild(i); |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 if (!name.empty()) | 1133 if (!name.empty()) |
| 1136 name += " "; | 1134 name += " "; |
| 1137 name += child_name; | 1135 name += child_name; |
| 1138 } | 1136 } |
| 1139 } | 1137 } |
| 1140 } | 1138 } |
| 1141 | 1139 |
| 1142 return name; | 1140 return name; |
| 1143 } | 1141 } |
| 1144 | 1142 |
| 1143 std::vector<int> BrowserAccessibility::GetLineStartOffsets() const { |
| 1144 if (!instance_active()) |
| 1145 return std::vector<int>(); |
| 1146 return node()->GetOrComputeLineStartOffsets(); |
| 1147 } |
| 1148 |
| 1145 base::string16 BrowserAccessibility::GetInnerText() const { | 1149 base::string16 BrowserAccessibility::GetInnerText() const { |
| 1146 if (IsTextOnlyObject()) | 1150 if (IsTextOnlyObject()) |
| 1147 return GetString16Attribute(ui::AX_ATTR_NAME); | 1151 return GetString16Attribute(ui::AX_ATTR_NAME); |
| 1148 | 1152 |
| 1149 base::string16 text; | 1153 base::string16 text; |
| 1150 for (size_t i = 0; i < InternalChildCount(); ++i) | 1154 for (size_t i = 0; i < InternalChildCount(); ++i) |
| 1151 text += InternalGetChild(i)->GetInnerText(); | 1155 text += InternalGetChild(i)->GetInnerText(); |
| 1152 return text; | 1156 return text; |
| 1153 } | 1157 } |
| 1154 | 1158 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 } | 1216 } |
| 1213 } | 1217 } |
| 1214 | 1218 |
| 1215 node = container; | 1219 node = container; |
| 1216 } | 1220 } |
| 1217 | 1221 |
| 1218 return gfx::ToEnclosingRect(bounds); | 1222 return gfx::ToEnclosingRect(bounds); |
| 1219 } | 1223 } |
| 1220 | 1224 |
| 1221 } // namespace content | 1225 } // namespace content |
| OLD | NEW |