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

Side by Side Diff: content/browser/accessibility/browser_accessibility_android.cc

Issue 1768753003: Implemented the reporting of text style and language information on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit and dmp tree tests. Addressed all reviewer's comments. Created 4 years, 9 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
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 "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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 case ui::AX_ROLE_COMBO_BOX: 351 case ui::AX_ROLE_COMBO_BOX:
351 case ui::AX_ROLE_POP_UP_BUTTON: 352 case ui::AX_ROLE_POP_UP_BUTTON:
352 case ui::AX_ROLE_TEXT_FIELD: 353 case ui::AX_ROLE_TEXT_FIELD:
353 return value; 354 return value;
354 } 355 }
355 } 356 }
356 357
357 // For color wells, the color is stored in separate attributes. 358 // For color wells, the color is stored in separate attributes.
358 // Perhaps we could return color names in the future? 359 // Perhaps we could return color names in the future?
359 if (GetRole() == ui::AX_ROLE_COLOR_WELL) { 360 if (GetRole() == ui::AX_ROLE_COLOR_WELL) {
360 int color = GetIntAttribute(ui::AX_ATTR_COLOR_VALUE); 361 unsigned int color =
361 int red = (color >> 16) & 0xFF; 362 static_cast<unsigned int>(GetIntAttribute(ui::AX_ATTR_COLOR_VALUE));
362 int green = (color >> 8) & 0xFF; 363 unsigned int red = SkColorGetR(color);
363 int blue = color & 0xFF; 364 unsigned int green = SkColorGetG(color);
365 unsigned int blue = SkColorGetB(color);
364 return base::UTF8ToUTF16( 366 return base::UTF8ToUTF16(
365 base::StringPrintf("#%02X%02X%02X", red, green, blue)); 367 base::StringPrintf("#%02X%02X%02X", red, green, blue));
366 } 368 }
367 369
368 base::string16 text = GetString16Attribute(ui::AX_ATTR_NAME); 370 base::string16 text = GetString16Attribute(ui::AX_ATTR_NAME);
369 base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION); 371 base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION);
370 if (!description.empty()) { 372 if (!description.empty()) {
371 if (!text.empty()) 373 if (!text.empty())
372 text += base::ASCIIToUTF16(" "); 374 text += base::ASCIIToUTF16(" ");
373 text += description; 375 text += description;
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { 1381 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const {
1380 int count = 0; 1382 int count = 0;
1381 for (uint32_t i = 0; i < PlatformChildCount(); i++) { 1383 for (uint32_t i = 0; i < PlatformChildCount(); i++) {
1382 if (PlatformGetChild(i)->GetRole() == role) 1384 if (PlatformGetChild(i)->GetRole() == role)
1383 count++; 1385 count++;
1384 } 1386 }
1385 return count; 1387 return count;
1386 } 1388 }
1387 1389
1388 } // namespace content 1390 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698