| 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 return ui::AXSnapshotNodeAndroid::AXRoleToAndroidClassName( | 337 return ui::AXSnapshotNodeAndroid::AXRoleToAndroidClassName( |
| 338 GetRole(), PlatformGetParent() != nullptr); | 338 GetRole(), PlatformGetParent() != nullptr); |
| 339 } | 339 } |
| 340 | 340 |
| 341 base::string16 BrowserAccessibilityAndroid::GetText() const { | 341 base::string16 BrowserAccessibilityAndroid::GetText() const { |
| 342 if (IsIframe() || | 342 if (IsIframe() || |
| 343 GetRole() == ui::AX_ROLE_WEB_AREA) { | 343 GetRole() == ui::AX_ROLE_WEB_AREA) { |
| 344 return base::string16(); | 344 return base::string16(); |
| 345 } | 345 } |
| 346 | 346 |
| 347 // In accordance with ARIA, some elements use their contents as an | |
| 348 // accessibility name, so some elements will have the same name as their | |
| 349 // child. While most platforms expect this, it causes Android to speak the | |
| 350 // name twice. So in this case we should remove the name from the parent. | |
| 351 if (GetRole() == ui::AX_ROLE_LIST_ITEM && | |
| 352 GetIntAttribute(ui::AX_ATTR_NAME_FROM) == ui::AX_NAME_FROM_CONTENTS) { | |
| 353 // This is an approximation of "PlatformChildCount() > 0" because we can't | |
| 354 // call PlatformChildCount from here. | |
| 355 if (InternalChildCount() > 0 && !HasOnlyTextChildren()) | |
| 356 return base::string16(); | |
| 357 } | |
| 358 | |
| 359 // We can only expose one accessible name on Android, | 347 // We can only expose one accessible name on Android, |
| 360 // not 2 or 3 like on Windows or Mac. | 348 // not 2 or 3 like on Windows or Mac. |
| 361 | 349 |
| 362 // First, always return the |value| attribute if this is an | 350 // First, always return the |value| attribute if this is an |
| 363 // input field. | 351 // input field. |
| 364 base::string16 value = GetValue(); | 352 base::string16 value = GetValue(); |
| 365 if (!value.empty()) { | 353 if (!value.empty()) { |
| 366 if (HasState(ui::AX_STATE_EDITABLE)) | 354 if (HasState(ui::AX_STATE_EDITABLE)) |
| 367 return value; | 355 return value; |
| 368 | 356 |
| (...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { | 1414 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { |
| 1427 int count = 0; | 1415 int count = 0; |
| 1428 for (uint32_t i = 0; i < PlatformChildCount(); i++) { | 1416 for (uint32_t i = 0; i < PlatformChildCount(); i++) { |
| 1429 if (PlatformGetChild(i)->GetRole() == role) | 1417 if (PlatformGetChild(i)->GetRole() == role) |
| 1430 count++; | 1418 count++; |
| 1431 } | 1419 } |
| 1432 return count; | 1420 return count; |
| 1433 } | 1421 } |
| 1434 | 1422 |
| 1435 } // namespace content | 1423 } // namespace content |
| OLD | NEW |