| 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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "content/app/strings/grit/content_strings.h" | 12 #include "content/app/strings/grit/content_strings.h" |
| 13 #include "content/browser/accessibility/browser_accessibility_manager_android.h" | 13 #include "content/browser/accessibility/browser_accessibility_manager_android.h" |
| 14 #include "content/common/accessibility_messages.h" | 14 #include "content/common/accessibility_messages.h" |
| 15 #include "content/public/common/content_client.h" | 15 #include "content/public/common/content_client.h" |
| 16 #include "third_party/skia/include/core/SkColor.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 // These are enums from android.text.InputType in Java: | 20 // These are enums from android.text.InputType in Java: |
| 20 enum { | 21 enum { |
| 21 ANDROID_TEXT_INPUTTYPE_TYPE_NULL = 0, | 22 ANDROID_TEXT_INPUTTYPE_TYPE_NULL = 0, |
| 22 ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME = 0x4, | 23 ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME = 0x4, |
| 23 ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME_DATE = 0x14, | 24 ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME_DATE = 0x14, |
| 24 ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME_TIME = 0x24, | 25 ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME_TIME = 0x24, |
| 25 ANDROID_TEXT_INPUTTYPE_TYPE_NUMBER = 0x2, | 26 ANDROID_TEXT_INPUTTYPE_TYPE_NUMBER = 0x2, |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 case ui::AX_ROLE_COMBO_BOX: | 356 case ui::AX_ROLE_COMBO_BOX: |
| 356 case ui::AX_ROLE_POP_UP_BUTTON: | 357 case ui::AX_ROLE_POP_UP_BUTTON: |
| 357 case ui::AX_ROLE_TEXT_FIELD: | 358 case ui::AX_ROLE_TEXT_FIELD: |
| 358 return value; | 359 return value; |
| 359 } | 360 } |
| 360 } | 361 } |
| 361 | 362 |
| 362 // For color wells, the color is stored in separate attributes. | 363 // For color wells, the color is stored in separate attributes. |
| 363 // Perhaps we could return color names in the future? | 364 // Perhaps we could return color names in the future? |
| 364 if (GetRole() == ui::AX_ROLE_COLOR_WELL) { | 365 if (GetRole() == ui::AX_ROLE_COLOR_WELL) { |
| 365 int color = GetIntAttribute(ui::AX_ATTR_COLOR_VALUE); | 366 unsigned int color = |
| 366 int red = (color >> 16) & 0xFF; | 367 static_cast<unsigned int>(GetIntAttribute(ui::AX_ATTR_COLOR_VALUE)); |
| 367 int green = (color >> 8) & 0xFF; | 368 unsigned int red = SkColorGetR(color); |
| 368 int blue = color & 0xFF; | 369 unsigned int green = SkColorGetG(color); |
| 370 unsigned int blue = SkColorGetB(color); |
| 369 return base::UTF8ToUTF16( | 371 return base::UTF8ToUTF16( |
| 370 base::StringPrintf("#%02X%02X%02X", red, green, blue)); | 372 base::StringPrintf("#%02X%02X%02X", red, green, blue)); |
| 371 } | 373 } |
| 372 | 374 |
| 373 base::string16 text = GetString16Attribute(ui::AX_ATTR_NAME); | 375 base::string16 text = GetString16Attribute(ui::AX_ATTR_NAME); |
| 374 base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION); | 376 base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION); |
| 375 if (!description.empty()) { | 377 if (!description.empty()) { |
| 376 if (!text.empty()) | 378 if (!text.empty()) |
| 377 text += base::ASCIIToUTF16(" "); | 379 text += base::ASCIIToUTF16(" "); |
| 378 text += description; | 380 text += description; |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { | 1386 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { |
| 1385 int count = 0; | 1387 int count = 0; |
| 1386 for (uint32_t i = 0; i < PlatformChildCount(); i++) { | 1388 for (uint32_t i = 0; i < PlatformChildCount(); i++) { |
| 1387 if (PlatformGetChild(i)->GetRole() == role) | 1389 if (PlatformGetChild(i)->GetRole() == role) |
| 1388 count++; | 1390 count++; |
| 1389 } | 1391 } |
| 1390 return count; | 1392 return count; |
| 1391 } | 1393 } |
| 1392 | 1394 |
| 1393 } // namespace content | 1395 } // namespace content |
| OLD | NEW |