| OLD | NEW |
| 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 "content/browser/accessibility/browser_accessibility_android.h" | 5 #include "content/browser/accessibility/browser_accessibility_android.h" |
| 6 | 6 |
| 7 #include "base/i18n/break_iterator.h" | 7 #include "base/i18n/break_iterator.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 bool BrowserAccessibilityAndroid::IsSlider() const { | 272 bool BrowserAccessibilityAndroid::IsSlider() const { |
| 273 return GetRole() == ui::AX_ROLE_SLIDER; | 273 return GetRole() == ui::AX_ROLE_SLIDER; |
| 274 } | 274 } |
| 275 | 275 |
| 276 bool BrowserAccessibilityAndroid::IsVisibleToUser() const { | 276 bool BrowserAccessibilityAndroid::IsVisibleToUser() const { |
| 277 return !HasState(ui::AX_STATE_INVISIBLE); | 277 return !HasState(ui::AX_STATE_INVISIBLE); |
| 278 } | 278 } |
| 279 | 279 |
| 280 bool BrowserAccessibilityAndroid::IsInterestingOnAndroid() const { | 280 bool BrowserAccessibilityAndroid::IsInterestingOnAndroid() const { |
| 281 // The root is not interesting if it doesn't have a title, even |
| 282 // though it's focusable. |
| 283 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && GetText().empty()) |
| 284 return false; |
| 285 |
| 281 // Focusable nodes are always interesting. Note that IsFocusable() | 286 // Focusable nodes are always interesting. Note that IsFocusable() |
| 282 // already skips over things like iframes and child frames that are | 287 // already skips over things like iframes and child frames that are |
| 283 // technically focusable but shouldn't be exposed as focusable on Android. | 288 // technically focusable but shouldn't be exposed as focusable on Android. |
| 284 if (IsFocusable()) | 289 if (IsFocusable()) |
| 285 return true; | 290 return true; |
| 286 | 291 |
| 287 // If it's not focusable but has a control role, then it's interesting. | 292 // If it's not focusable but has a control role, then it's interesting. |
| 288 if (IsControl()) | 293 if (IsControl()) |
| 289 return true; | 294 return true; |
| 290 | 295 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION); | 451 base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION); |
| 447 if (!description.empty()) { | 452 if (!description.empty()) { |
| 448 if (!text.empty()) | 453 if (!text.empty()) |
| 449 text += base::ASCIIToUTF16(" "); | 454 text += base::ASCIIToUTF16(" "); |
| 450 text += description; | 455 text += description; |
| 451 } | 456 } |
| 452 | 457 |
| 453 if (text.empty()) | 458 if (text.empty()) |
| 454 text = value; | 459 text = value; |
| 455 | 460 |
| 461 // If this is the root element, give up now, allow it to have no |
| 462 // accessible text. For almost all other focusable nodes we try to |
| 463 // get text from contents, but for the root element that's redundant |
| 464 // and often way too verbose. |
| 465 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA) |
| 466 return text; |
| 467 |
| 456 // This is called from PlatformIsLeaf, so don't call PlatformChildCount | 468 // This is called from PlatformIsLeaf, so don't call PlatformChildCount |
| 457 // from within this! | 469 // from within this! |
| 458 if (text.empty() && (HasOnlyTextChildren() || | 470 if (text.empty() && (HasOnlyTextChildren() || |
| 459 (IsFocusable() && HasOnlyTextAndImageChildren()))) { | 471 (IsFocusable() && HasOnlyTextAndImageChildren()))) { |
| 460 for (uint32_t i = 0; i < InternalChildCount(); i++) { | 472 for (uint32_t i = 0; i < InternalChildCount(); i++) { |
| 461 BrowserAccessibility* child = InternalGetChild(i); | 473 BrowserAccessibility* child = InternalGetChild(i); |
| 462 text += static_cast<BrowserAccessibilityAndroid*>(child)->GetText(); | 474 text += static_cast<BrowserAccessibilityAndroid*>(child)->GetText(); |
| 463 } | 475 } |
| 464 } | 476 } |
| 465 | 477 |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1465 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { | 1477 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { |
| 1466 int count = 0; | 1478 int count = 0; |
| 1467 for (uint32_t i = 0; i < PlatformChildCount(); i++) { | 1479 for (uint32_t i = 0; i < PlatformChildCount(); i++) { |
| 1468 if (PlatformGetChild(i)->GetRole() == role) | 1480 if (PlatformGetChild(i)->GetRole() == role) |
| 1469 count++; | 1481 count++; |
| 1470 } | 1482 } |
| 1471 return count; | 1483 return count; |
| 1472 } | 1484 } |
| 1473 | 1485 |
| 1474 } // namespace content | 1486 } // namespace content |
| OLD | NEW |