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

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

Issue 2333333004: Track usage of Windows accessibility APIs with a UMA histogram (Closed)
Patch Set: Add period Created 4 years, 3 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_win.h" 5 #include "content/browser/accessibility/browser_accessibility_win.h"
6 6
7 #include <UIAutomationClient.h> 7 #include <UIAutomationClient.h>
8 #include <UIAutomationCoreApi.h> 8 #include <UIAutomationCoreApi.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <iterator> 11 #include <iterator>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/metrics/histogram_macros.h"
14 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "base/win/enum_variant.h" 19 #include "base/win/enum_variant.h"
19 #include "base/win/scoped_comptr.h" 20 #include "base/win/scoped_comptr.h"
20 #include "base/win/windows_version.h" 21 #include "base/win/windows_version.h"
21 #include "content/browser/accessibility/browser_accessibility_event_win.h" 22 #include "content/browser/accessibility/browser_accessibility_event_win.h"
22 #include "content/browser/accessibility/browser_accessibility_manager_win.h" 23 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
23 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 24 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
24 #include "content/common/accessibility_messages.h" 25 #include "content/common/accessibility_messages.h"
25 #include "content/public/common/content_client.h" 26 #include "content/public/common/content_client.h"
26 #include "third_party/skia/include/core/SkColor.h" 27 #include "third_party/skia/include/core/SkColor.h"
27 #include "ui/accessibility/ax_text_utils.h" 28 #include "ui/accessibility/ax_text_utils.h"
28 #include "ui/base/win/accessibility_ids_win.h" 29 #include "ui/base/win/accessibility_ids_win.h"
29 #include "ui/base/win/accessibility_misc_utils.h" 30 #include "ui/base/win/accessibility_misc_utils.h"
30 #include "ui/base/win/atl_module.h" 31 #include "ui/base/win/atl_module.h"
31 32
33 namespace {
34
35 // IMPORTANT!
36 // These values are written to logs. Do not renumber or delete
37 // existing items; add new entries to the end of the list.
38 enum {
39 UMA_API_ACC_DO_DEFAULT_ACTION = 0,
40 UMA_API_ACC_HIT_TEST = 1,
41 UMA_API_ACC_LOCATION = 2,
42 UMA_API_ACC_NAVIGATE = 3,
43 UMA_API_ACC_SELECT = 4,
44 UMA_API_ADD_SELECTION = 5,
45 UMA_API_CONVERT_RETURNED_ELEMENT = 6,
46 UMA_API_DO_ACTION = 7,
47 UMA_API_GET_ACCESSIBLE_AT = 8,
48 UMA_API_GET_ACC_CHILD = 9,
49 UMA_API_GET_ACC_CHILD_COUNT = 10,
50 UMA_API_GET_ACC_DEFAULT_ACTION = 11,
51 UMA_API_GET_ACC_DESCRIPTION = 12,
52 UMA_API_GET_ACC_FOCUS = 13,
53 UMA_API_GET_ACC_HELP = 14,
54 UMA_API_GET_ACC_HELP_TOPIC = 15,
55 UMA_API_GET_ACC_KEYBOARD_SHORTCUT = 16,
56 UMA_API_GET_ACC_NAME = 17,
57 UMA_API_GET_ACC_PARENT = 18,
58 UMA_API_GET_ACC_ROLE = 19,
59 UMA_API_GET_ACC_SELECTION = 20,
60 UMA_API_GET_ACC_STATE = 21,
61 UMA_API_GET_ACC_VALUE = 22,
62 UMA_API_GET_ANCHOR = 23,
63 UMA_API_GET_ANCHOR_TARGET = 24,
64 UMA_API_GET_APP_NAME = 25,
65 UMA_API_GET_APP_VERSION = 26,
66 UMA_API_GET_ATTRIBUTES_FOR_NAMES = 27,
67 UMA_API_GET_CAPTION = 28,
68 UMA_API_GET_CARET_OFFSET = 29,
69 UMA_API_GET_CELL_AT = 30,
70 UMA_API_GET_CHARACTER_EXTENTS = 31,
71 UMA_API_GET_CHILD_AT = 32,
72 UMA_API_GET_CHILD_INDEX = 33,
73 UMA_API_GET_CLIPPED_SUBSTRING_BOUNDS = 34,
74 UMA_API_GET_COLUMN_DESCRIPTION = 35,
75 UMA_API_GET_COLUMN_EXTENT = 36,
76 UMA_API_GET_COLUMN_EXTENT_AT = 37,
77 UMA_API_GET_COLUMN_HEADER = 38,
78 UMA_API_GET_COLUMN_HEADER_CELLS = 39,
79 UMA_API_GET_COLUMN_INDEX = 40,
80 UMA_API_GET_COMPUTED_STYLE = 41,
81 UMA_API_GET_COMPUTED_STYLE_FOR_PROPERTIES = 42,
82 UMA_API_GET_CURRENT_VALUE = 43,
83 UMA_API_GET_DESCRIPTION = 44,
84 UMA_API_GET_DOC_TYPE = 45,
85 UMA_API_GET_DOM_TEXT = 46,
86 UMA_API_GET_END_INDEX = 47,
87 UMA_API_GET_EXTENDED_ROLE = 48,
88 UMA_API_GET_EXTENDED_STATES = 49,
89 UMA_API_GET_FIRST_CHILD = 50,
90 UMA_API_GET_FONT_FAMILY = 51,
91 UMA_API_GET_GROUP_POSITION = 52,
92 UMA_API_GET_HOST_RAW_ELEMENT_PROVIDER = 53,
93 UMA_API_GET_HYPERLINK = 54,
94 UMA_API_GET_HYPERLINK_INDEX = 55,
95 UMA_API_GET_IACCESSIBLE_PAIR = 56,
96 UMA_API_GET_IMAGE_POSITION = 57,
97 UMA_API_GET_IMAGE_SIZE = 58,
98 UMA_API_GET_INDEX_IN_PARENT = 59,
99 UMA_API_GET_INNER_HTML = 60,
100 UMA_API_GET_IS_COLUMN_SELECTED = 61,
101 UMA_API_GET_IS_ROW_SELECTED = 62,
102 UMA_API_GET_IS_SELECTED = 63,
103 UMA_API_GET_KEY_BINDING = 64,
104 UMA_API_GET_LANGUAGE = 65,
105 UMA_API_GET_LAST_CHILD = 66,
106 UMA_API_GET_LOCALE = 67,
107 UMA_API_GET_LOCALIZED_EXTENDED_ROLE = 68,
108 UMA_API_GET_LOCALIZED_EXTENDED_STATES = 69,
109 UMA_API_GET_LOCALIZED_NAME = 70,
110 UMA_API_GET_LOCAL_INTERFACE = 71,
111 UMA_API_GET_MAXIMUM_VALUE = 72,
112 UMA_API_GET_MIME_TYPE = 73,
113 UMA_API_GET_MINIMUM_VALUE = 74,
114 UMA_API_GET_NAME = 75,
115 UMA_API_GET_NAMESPACE_URI_FOR_ID = 76,
116 UMA_API_GET_NEW_TEXT = 77,
117 UMA_API_GET_NEXT_SIBLING = 78,
118 UMA_API_GET_NODE_INFO = 79,
119 UMA_API_GET_N_CHARACTERS = 80,
120 UMA_API_GET_N_COLUMNS = 81,
121 UMA_API_GET_N_EXTENDED_STATES = 82,
122 UMA_API_GET_N_HYPERLINKS = 83,
123 UMA_API_GET_N_RELATIONS = 84,
124 UMA_API_GET_N_ROWS = 85,
125 UMA_API_GET_N_SELECTED_CELLS = 86,
126 UMA_API_GET_N_SELECTED_CHILDREN = 87,
127 UMA_API_GET_N_SELECTED_COLUMNS = 88,
128 UMA_API_GET_N_SELECTED_ROWS = 89,
129 UMA_API_GET_N_SELECTIONS = 90,
130 UMA_API_GET_OBJECT_FOR_CHILD = 91,
131 UMA_API_GET_OFFSET_AT_POINT = 92,
132 UMA_API_GET_OLD_TEXT = 93,
133 UMA_API_GET_PARENT_NODE = 94,
134 UMA_API_GET_PATTERN_PROVIDER = 95,
135 UMA_API_GET_PREVIOUS_SIBLING = 96,
136 UMA_API_GET_PROPERTY_VALUE = 97,
137 UMA_API_GET_PROVIDER_OPTIONS = 98,
138 UMA_API_GET_RELATION = 99,
139 UMA_API_GET_RELATIONS = 100,
140 UMA_API_GET_ROW_COLUMN_EXTENTS = 101,
141 UMA_API_GET_ROW_COLUMN_EXTENTS_AT_INDEX = 102,
142 UMA_API_GET_ROW_DESCRIPTION = 103,
143 UMA_API_GET_ROW_EXTENT = 104,
144 UMA_API_GET_ROW_EXTENT_AT = 105,
145 UMA_API_GET_ROW_HEADER = 106,
146 UMA_API_GET_ROW_HEADER_CELLS = 107,
147 UMA_API_GET_ROW_INDEX = 108,
148 UMA_API_GET_RUNTIME_ID = 109,
149 UMA_API_GET_SELECTED_CELLS = 110,
150 UMA_API_GET_SELECTED_CHILDREN = 111,
151 UMA_API_GET_SELECTED_COLUMNS = 112,
152 UMA_API_GET_SELECTED_ROWS = 113,
153 UMA_API_GET_SELECTION = 114,
154 UMA_API_GET_START_INDEX = 115,
155 UMA_API_GET_STATES = 116,
156 UMA_API_GET_SUMMARY = 117,
157 UMA_API_GET_TABLE = 118,
158 UMA_API_GET_TEXT = 119,
159 UMA_API_GET_TEXT_AFTER_OFFSET = 120,
160 UMA_API_GET_TEXT_AT_OFFSET = 121,
161 UMA_API_GET_TEXT_BEFORE_OFFSET = 122,
162 UMA_API_GET_TITLE = 123,
163 UMA_API_GET_TOOLKIT_NAME = 124,
164 UMA_API_GET_TOOLKIT_VERSION = 125,
165 UMA_API_GET_UNCLIPPED_SUBSTRING_BOUNDS = 126,
166 UMA_API_GET_UNIQUE_ID = 127,
167 UMA_API_GET_URL = 128,
168 UMA_API_GET_VALID = 129,
169 UMA_API_GET_WINDOW_HANDLE = 130,
170 UMA_API_IA2_GET_ATTRIBUTES = 131,
171 UMA_API_IA2_SCROLL_TO = 132,
172 UMA_API_IAACTION_GET_DESCRIPTION = 133,
173 UMA_API_IATEXT_GET_ATTRIBUTES = 134,
174 UMA_API_ISIMPLEDOMNODE_GET_ATTRIBUTES = 135,
175 UMA_API_ISIMPLEDOMNODE_SCROLL_TO = 136,
176 UMA_API_N_ACTIONS = 137,
177 UMA_API_PUT_ALTERNATE_VIEW_MEDIA_TYPES = 138,
178 UMA_API_QUERY_SERVICE = 139,
179 UMA_API_REMOVE_SELECTION = 140,
180 UMA_API_ROLE = 141,
181 UMA_API_SCROLL_SUBSTRING_TO = 142,
182 UMA_API_SCROLL_SUBSTRING_TO_POINT = 143,
183 UMA_API_SCROLL_TO_POINT = 144,
184 UMA_API_SCROLL_TO_SUBSTRING = 145,
185 UMA_API_SELECT_COLUMN = 146,
186 UMA_API_SELECT_ROW = 147,
187 UMA_API_SET_CARET_OFFSET = 148,
188 UMA_API_SET_CURRENT_VALUE = 149,
189 UMA_API_SET_SELECTION = 150,
190 UMA_API_TABLE2_GET_SELECTED_COLUMNS = 151,
191 UMA_API_TABLE2_GET_SELECTED_ROWS = 152,
192 UMA_API_TABLECELL_GET_COLUMN_INDEX = 153,
193 UMA_API_TABLECELL_GET_IS_SELECTED = 154,
194 UMA_API_TABLECELL_GET_ROW_INDEX = 155,
195 UMA_API_UNSELECT_COLUMN = 156,
196 UMA_API_UNSELECT_ROW = 157,
197
198 // This must always be the last enum. It's okay for its value to
199 // increase, but none of the other enum values may change.
200 UMA_API_MAX
201 };
202
203 #define WIN_ACCESSIBILITY_API_HISTOGRAM(enum_value) \
204 UMA_HISTOGRAM_ENUMERATION("Accessibility.WinAPIs", enum_value, UMA_API_MAX)
205
206 } // namespace
207
32 namespace content { 208 namespace content {
33 209
34 // These nonstandard GUIDs are taken directly from the Mozilla sources 210 // These nonstandard GUIDs are taken directly from the Mozilla sources
35 // (accessible/src/msaa/nsAccessNodeWrap.cpp); some documentation is here: 211 // (accessible/src/msaa/nsAccessNodeWrap.cpp); some documentation is here:
36 // http://developer.mozilla.org/en/Accessibility/AT-APIs/ImplementationFeatures/ MSAA 212 // http://developer.mozilla.org/en/Accessibility/AT-APIs/ImplementationFeatures/ MSAA
37 const GUID GUID_ISimpleDOM = {0x0c539790, 213 const GUID GUID_ISimpleDOM = {0x0c539790,
38 0x12e4, 214 0x12e4,
39 0x11cf, 215 0x11cf,
40 {0xb6, 0x61, 0x00, 0xaa, 0x00, 0x4c, 0xd6, 0xd8}}; 216 {0xb6, 0x61, 0x00, 0xaa, 0x00, 0x4c, 0xd6, 0xd8}};
41 const GUID GUID_IAccessibleContentDocument = { 217 const GUID GUID_IAccessibleContentDocument = {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 // 405 //
230 // IAccessible methods. 406 // IAccessible methods.
231 // 407 //
232 // Conventions: 408 // Conventions:
233 // * Always test for instance_active() first and return E_FAIL if it's false. 409 // * Always test for instance_active() first and return E_FAIL if it's false.
234 // * Always check for invalid arguments first, even if they're unused. 410 // * Always check for invalid arguments first, even if they're unused.
235 // * Return S_FALSE if the only output is a string argument and it's empty. 411 // * Return S_FALSE if the only output is a string argument and it's empty.
236 // 412 //
237 413
238 HRESULT BrowserAccessibilityWin::accDoDefaultAction(VARIANT var_id) { 414 HRESULT BrowserAccessibilityWin::accDoDefaultAction(VARIANT var_id) {
415 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_DO_DEFAULT_ACTION);
239 if (!instance_active()) 416 if (!instance_active())
240 return E_FAIL; 417 return E_FAIL;
241 418
242 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 419 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
243 if (!target) 420 if (!target)
244 return E_INVALIDARG; 421 return E_INVALIDARG;
245 422
246 // Return an error if it's not clickable. 423 // Return an error if it's not clickable.
247 if (!target->HasStringAttribute(ui::AX_ATTR_ACTION)) 424 if (!target->HasStringAttribute(ui::AX_ATTR_ACTION))
248 return DISP_E_MEMBERNOTFOUND; 425 return DISP_E_MEMBERNOTFOUND;
249 426
250 manager()->DoDefaultAction(*target); 427 manager()->DoDefaultAction(*target);
251 return S_OK; 428 return S_OK;
252 } 429 }
253 430
254 STDMETHODIMP BrowserAccessibilityWin::accHitTest(LONG x_left, 431 STDMETHODIMP BrowserAccessibilityWin::accHitTest(LONG x_left,
255 LONG y_top, 432 LONG y_top,
256 VARIANT* child) { 433 VARIANT* child) {
434 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_HIT_TEST);
257 if (!instance_active()) 435 if (!instance_active())
258 return E_FAIL; 436 return E_FAIL;
259 437
260 if (!child) 438 if (!child)
261 return E_INVALIDARG; 439 return E_INVALIDARG;
262 440
263 gfx::Point point(x_left, y_top); 441 gfx::Point point(x_left, y_top);
264 if (!GetScreenBoundsRect().Contains(point)) { 442 if (!GetScreenBoundsRect().Contains(point)) {
265 // Return S_FALSE and VT_EMPTY when outside the object's boundaries. 443 // Return S_FALSE and VT_EMPTY when outside the object's boundaries.
266 child->vt = VT_EMPTY; 444 child->vt = VT_EMPTY;
(...skipping 10 matching lines...) Expand all
277 child->pdispVal = ToBrowserAccessibilityWin(result)->NewReference(); 455 child->pdispVal = ToBrowserAccessibilityWin(result)->NewReference();
278 } 456 }
279 return S_OK; 457 return S_OK;
280 } 458 }
281 459
282 STDMETHODIMP BrowserAccessibilityWin::accLocation(LONG* x_left, 460 STDMETHODIMP BrowserAccessibilityWin::accLocation(LONG* x_left,
283 LONG* y_top, 461 LONG* y_top,
284 LONG* width, 462 LONG* width,
285 LONG* height, 463 LONG* height,
286 VARIANT var_id) { 464 VARIANT var_id) {
465 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_LOCATION);
287 if (!instance_active()) 466 if (!instance_active())
288 return E_FAIL; 467 return E_FAIL;
289 468
290 if (!x_left || !y_top || !width || !height) 469 if (!x_left || !y_top || !width || !height)
291 return E_INVALIDARG; 470 return E_INVALIDARG;
292 471
293 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 472 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
294 if (!target) 473 if (!target)
295 return E_INVALIDARG; 474 return E_INVALIDARG;
296 475
297 gfx::Rect bounds = target->GetScreenBoundsRect(); 476 gfx::Rect bounds = target->GetScreenBoundsRect();
298 *x_left = bounds.x(); 477 *x_left = bounds.x();
299 *y_top = bounds.y(); 478 *y_top = bounds.y();
300 *width = bounds.width(); 479 *width = bounds.width();
301 *height = bounds.height(); 480 *height = bounds.height();
302 481
303 return S_OK; 482 return S_OK;
304 } 483 }
305 484
306 STDMETHODIMP BrowserAccessibilityWin::accNavigate(LONG nav_dir, 485 STDMETHODIMP BrowserAccessibilityWin::accNavigate(LONG nav_dir,
307 VARIANT start, 486 VARIANT start,
308 VARIANT* end) { 487 VARIANT* end) {
488 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_NAVIGATE);
309 BrowserAccessibilityWin* target = GetTargetFromChildID(start); 489 BrowserAccessibilityWin* target = GetTargetFromChildID(start);
310 if (!target) 490 if (!target)
311 return E_INVALIDARG; 491 return E_INVALIDARG;
312 492
313 if ((nav_dir == NAVDIR_LASTCHILD || nav_dir == NAVDIR_FIRSTCHILD) && 493 if ((nav_dir == NAVDIR_LASTCHILD || nav_dir == NAVDIR_FIRSTCHILD) &&
314 start.lVal != CHILDID_SELF) { 494 start.lVal != CHILDID_SELF) {
315 // MSAA states that navigating to first/last child can only be from self. 495 // MSAA states that navigating to first/last child can only be from self.
316 return E_INVALIDARG; 496 return E_INVALIDARG;
317 } 497 }
318 498
(...skipping 28 matching lines...) Expand all
347 return S_FALSE; 527 return S_FALSE;
348 } 528 }
349 529
350 end->vt = VT_DISPATCH; 530 end->vt = VT_DISPATCH;
351 end->pdispVal = ToBrowserAccessibilityWin(result)->NewReference(); 531 end->pdispVal = ToBrowserAccessibilityWin(result)->NewReference();
352 return S_OK; 532 return S_OK;
353 } 533 }
354 534
355 STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child, 535 STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child,
356 IDispatch** disp_child) { 536 IDispatch** disp_child) {
537 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_CHILD);
357 if (!instance_active()) 538 if (!instance_active())
358 return E_FAIL; 539 return E_FAIL;
359 540
360 if (!disp_child) 541 if (!disp_child)
361 return E_INVALIDARG; 542 return E_INVALIDARG;
362 543
363 *disp_child = NULL; 544 *disp_child = NULL;
364 545
365 BrowserAccessibilityWin* target = GetTargetFromChildID(var_child); 546 BrowserAccessibilityWin* target = GetTargetFromChildID(var_child);
366 if (!target) 547 if (!target)
367 return E_INVALIDARG; 548 return E_INVALIDARG;
368 549
369 (*disp_child) = target->NewReference(); 550 (*disp_child) = target->NewReference();
370 return S_OK; 551 return S_OK;
371 } 552 }
372 553
373 STDMETHODIMP BrowserAccessibilityWin::get_accChildCount(LONG* child_count) { 554 STDMETHODIMP BrowserAccessibilityWin::get_accChildCount(LONG* child_count) {
555 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_CHILD_COUNT);
374 if (!instance_active()) 556 if (!instance_active())
375 return E_FAIL; 557 return E_FAIL;
376 558
377 if (!child_count) 559 if (!child_count)
378 return E_INVALIDARG; 560 return E_INVALIDARG;
379 561
380 *child_count = PlatformChildCount(); 562 *child_count = PlatformChildCount();
381 563
382 return S_OK; 564 return S_OK;
383 } 565 }
384 566
385 STDMETHODIMP BrowserAccessibilityWin::get_accDefaultAction(VARIANT var_id, 567 STDMETHODIMP BrowserAccessibilityWin::get_accDefaultAction(VARIANT var_id,
386 BSTR* def_action) { 568 BSTR* def_action) {
569 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DEFAULT_ACTION);
387 if (!instance_active()) 570 if (!instance_active())
388 return E_FAIL; 571 return E_FAIL;
389 572
390 if (!def_action) 573 if (!def_action)
391 return E_INVALIDARG; 574 return E_INVALIDARG;
392 575
393 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 576 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
394 if (!target) 577 if (!target)
395 return E_INVALIDARG; 578 return E_INVALIDARG;
396 579
397 return target->GetStringAttributeAsBstr( 580 return target->GetStringAttributeAsBstr(
398 ui::AX_ATTR_ACTION, def_action); 581 ui::AX_ATTR_ACTION, def_action);
399 } 582 }
400 583
401 STDMETHODIMP BrowserAccessibilityWin::get_accDescription(VARIANT var_id, 584 STDMETHODIMP BrowserAccessibilityWin::get_accDescription(VARIANT var_id,
402 BSTR* desc) { 585 BSTR* desc) {
586 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DESCRIPTION);
403 if (!instance_active()) 587 if (!instance_active())
404 return E_FAIL; 588 return E_FAIL;
405 589
406 if (!desc) 590 if (!desc)
407 return E_INVALIDARG; 591 return E_INVALIDARG;
408 592
409 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 593 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
410 if (!target) 594 if (!target)
411 return E_INVALIDARG; 595 return E_INVALIDARG;
412 596
413 base::string16 description_str = target->description(); 597 base::string16 description_str = target->description();
414 if (description_str.empty()) 598 if (description_str.empty())
415 return S_FALSE; 599 return S_FALSE;
416 600
417 *desc = SysAllocString(description_str.c_str()); 601 *desc = SysAllocString(description_str.c_str());
418 602
419 DCHECK(*desc); 603 DCHECK(*desc);
420 return S_OK; 604 return S_OK;
421 } 605 }
422 606
423 STDMETHODIMP BrowserAccessibilityWin::get_accFocus(VARIANT* focus_child) { 607 STDMETHODIMP BrowserAccessibilityWin::get_accFocus(VARIANT* focus_child) {
608 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_FOCUS);
424 if (!instance_active()) 609 if (!instance_active())
425 return E_FAIL; 610 return E_FAIL;
426 611
427 if (!focus_child) 612 if (!focus_child)
428 return E_INVALIDARG; 613 return E_INVALIDARG;
429 614
430 BrowserAccessibilityWin* focus = static_cast<BrowserAccessibilityWin*>( 615 BrowserAccessibilityWin* focus = static_cast<BrowserAccessibilityWin*>(
431 manager()->GetFocus()); 616 manager()->GetFocus());
432 if (focus == this) { 617 if (focus == this) {
433 focus_child->vt = VT_I4; 618 focus_child->vt = VT_I4;
434 focus_child->lVal = CHILDID_SELF; 619 focus_child->lVal = CHILDID_SELF;
435 } else if (focus == NULL) { 620 } else if (focus == NULL) {
436 focus_child->vt = VT_EMPTY; 621 focus_child->vt = VT_EMPTY;
437 } else { 622 } else {
438 focus_child->vt = VT_DISPATCH; 623 focus_child->vt = VT_DISPATCH;
439 focus_child->pdispVal = focus->NewReference(); 624 focus_child->pdispVal = focus->NewReference();
440 } 625 }
441 626
442 return S_OK; 627 return S_OK;
443 } 628 }
444 629
445 STDMETHODIMP BrowserAccessibilityWin::get_accHelp(VARIANT var_id, BSTR* help) { 630 STDMETHODIMP BrowserAccessibilityWin::get_accHelp(VARIANT var_id, BSTR* help) {
631 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP);
446 if (!instance_active()) 632 if (!instance_active())
447 return E_FAIL; 633 return E_FAIL;
448 634
449 if (!help) 635 if (!help)
450 return E_INVALIDARG; 636 return E_INVALIDARG;
451 637
452 return S_FALSE; 638 return S_FALSE;
453 } 639 }
454 640
455 STDMETHODIMP BrowserAccessibilityWin::get_accKeyboardShortcut(VARIANT var_id, 641 STDMETHODIMP BrowserAccessibilityWin::get_accKeyboardShortcut(VARIANT var_id,
456 BSTR* acc_key) { 642 BSTR* acc_key) {
643 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_KEYBOARD_SHORTCUT);
457 if (!instance_active()) 644 if (!instance_active())
458 return E_FAIL; 645 return E_FAIL;
459 646
460 if (!acc_key) 647 if (!acc_key)
461 return E_INVALIDARG; 648 return E_INVALIDARG;
462 649
463 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 650 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
464 if (!target) 651 if (!target)
465 return E_INVALIDARG; 652 return E_INVALIDARG;
466 653
467 return target->GetStringAttributeAsBstr( 654 return target->GetStringAttributeAsBstr(
468 ui::AX_ATTR_SHORTCUT, acc_key); 655 ui::AX_ATTR_SHORTCUT, acc_key);
469 } 656 }
470 657
471 STDMETHODIMP BrowserAccessibilityWin::get_accName(VARIANT var_id, BSTR* name) { 658 STDMETHODIMP BrowserAccessibilityWin::get_accName(VARIANT var_id, BSTR* name) {
659 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_NAME);
472 if (!instance_active()) 660 if (!instance_active())
473 return E_FAIL; 661 return E_FAIL;
474 662
475 if (!name) 663 if (!name)
476 return E_INVALIDARG; 664 return E_INVALIDARG;
477 665
478 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 666 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
479 if (!target) 667 if (!target)
480 return E_INVALIDARG; 668 return E_INVALIDARG;
481 669
482 base::string16 name_str = target->name(); 670 base::string16 name_str = target->name();
483 if (name_str.empty()) { 671 if (name_str.empty()) {
484 if (target->ia2_role() == ROLE_SYSTEM_DOCUMENT && GetParent()) { 672 if (target->ia2_role() == ROLE_SYSTEM_DOCUMENT && GetParent()) {
485 // Hack: Some versions of JAWS crash if they get an empty name on 673 // Hack: Some versions of JAWS crash if they get an empty name on
486 // a document that's the child of an iframe, so always return a 674 // a document that's the child of an iframe, so always return a
487 // nonempty string for this role. https://crbug.com/583057 675 // nonempty string for this role. https://crbug.com/583057
488 name_str = L" "; 676 name_str = L" ";
489 } else { 677 } else {
490 return S_FALSE; 678 return S_FALSE;
491 } 679 }
492 } 680 }
493 681
494 *name = SysAllocString(name_str.c_str()); 682 *name = SysAllocString(name_str.c_str());
495 683
496 DCHECK(*name); 684 DCHECK(*name);
497 return S_OK; 685 return S_OK;
498 } 686 }
499 687
500 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { 688 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) {
689 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_PARENT);
501 if (!instance_active()) 690 if (!instance_active())
502 return E_FAIL; 691 return E_FAIL;
503 692
504 if (!disp_parent) 693 if (!disp_parent)
505 return E_INVALIDARG; 694 return E_INVALIDARG;
506 695
507 IAccessible* parent_obj = ToBrowserAccessibilityWin(GetParent()); 696 IAccessible* parent_obj = ToBrowserAccessibilityWin(GetParent());
508 if (parent_obj == NULL) { 697 if (parent_obj == NULL) {
509 // This happens if we're the root of the tree; 698 // This happens if we're the root of the tree;
510 // return the IAccessible for the window. 699 // return the IAccessible for the window.
(...skipping 10 matching lines...) Expand all
521 return E_FAIL; 710 return E_FAIL;
522 } 711 }
523 } 712 }
524 parent_obj->AddRef(); 713 parent_obj->AddRef();
525 *disp_parent = parent_obj; 714 *disp_parent = parent_obj;
526 return S_OK; 715 return S_OK;
527 } 716 }
528 717
529 STDMETHODIMP BrowserAccessibilityWin::get_accRole(VARIANT var_id, 718 STDMETHODIMP BrowserAccessibilityWin::get_accRole(VARIANT var_id,
530 VARIANT* role) { 719 VARIANT* role) {
720 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_ROLE);
531 if (!instance_active()) 721 if (!instance_active())
532 return E_FAIL; 722 return E_FAIL;
533 723
534 if (!role) 724 if (!role)
535 return E_INVALIDARG; 725 return E_INVALIDARG;
536 726
537 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 727 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
538 if (!target) 728 if (!target)
539 return E_INVALIDARG; 729 return E_INVALIDARG;
540 730
541 if (!target->role_name().empty()) { 731 if (!target->role_name().empty()) {
542 role->vt = VT_BSTR; 732 role->vt = VT_BSTR;
543 role->bstrVal = SysAllocString(target->role_name().c_str()); 733 role->bstrVal = SysAllocString(target->role_name().c_str());
544 } else { 734 } else {
545 role->vt = VT_I4; 735 role->vt = VT_I4;
546 role->lVal = target->ia_role(); 736 role->lVal = target->ia_role();
547 } 737 }
548 return S_OK; 738 return S_OK;
549 } 739 }
550 740
551 STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id, 741 STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id,
552 VARIANT* state) { 742 VARIANT* state) {
743 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_STATE);
553 if (!instance_active()) 744 if (!instance_active())
554 return E_FAIL; 745 return E_FAIL;
555 746
556 if (!state) 747 if (!state)
557 return E_INVALIDARG; 748 return E_INVALIDARG;
558 749
559 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 750 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
560 if (!target) 751 if (!target)
561 return E_INVALIDARG; 752 return E_INVALIDARG;
562 753
563 state->vt = VT_I4; 754 state->vt = VT_I4;
564 state->lVal = target->ia_state(); 755 state->lVal = target->ia_state();
565 if (manager()->GetFocus() == this) 756 if (manager()->GetFocus() == this)
566 state->lVal |= STATE_SYSTEM_FOCUSED; 757 state->lVal |= STATE_SYSTEM_FOCUSED;
567 758
568 return S_OK; 759 return S_OK;
569 } 760 }
570 761
571 STDMETHODIMP BrowserAccessibilityWin::get_accValue(VARIANT var_id, 762 STDMETHODIMP BrowserAccessibilityWin::get_accValue(VARIANT var_id,
572 BSTR* value) { 763 BSTR* value) {
764 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_VALUE);
573 if (!instance_active()) 765 if (!instance_active())
574 return E_FAIL; 766 return E_FAIL;
575 767
576 if (!value) 768 if (!value)
577 return E_INVALIDARG; 769 return E_INVALIDARG;
578 770
579 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); 771 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id);
580 if (!target) 772 if (!target)
581 return E_INVALIDARG; 773 return E_INVALIDARG;
582 774
(...skipping 23 matching lines...) Expand all
606 } 798 }
607 799
608 *value = SysAllocString(target->value().c_str()); 800 *value = SysAllocString(target->value().c_str());
609 DCHECK(*value); 801 DCHECK(*value);
610 return S_OK; 802 return S_OK;
611 } 803 }
612 804
613 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file, 805 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file,
614 VARIANT var_id, 806 VARIANT var_id,
615 LONG* topic_id) { 807 LONG* topic_id) {
808 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP_TOPIC);
616 return E_NOTIMPL; 809 return E_NOTIMPL;
617 } 810 }
618 811
619 STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { 812 STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) {
813 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_SELECTION);
620 if (!instance_active()) 814 if (!instance_active())
621 return E_FAIL; 815 return E_FAIL;
622 816
623 if (GetRole() != ui::AX_ROLE_LIST_BOX) 817 if (GetRole() != ui::AX_ROLE_LIST_BOX)
624 return E_NOTIMPL; 818 return E_NOTIMPL;
625 819
626 unsigned long selected_count = 0; 820 unsigned long selected_count = 0;
627 for (size_t i = 0; i < InternalChildCount(); ++i) { 821 for (size_t i = 0; i < InternalChildCount(); ++i) {
628 if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) 822 if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED))
629 ++selected_count; 823 ++selected_count;
(...skipping 29 matching lines...) Expand all
659 } 853 }
660 } 854 }
661 selected->vt = VT_UNKNOWN; 855 selected->vt = VT_UNKNOWN;
662 selected->punkVal = static_cast<IUnknown*>( 856 selected->punkVal = static_cast<IUnknown*>(
663 static_cast<base::win::IUnknownImpl*>(enum_variant)); 857 static_cast<base::win::IUnknownImpl*>(enum_variant));
664 return S_OK; 858 return S_OK;
665 } 859 }
666 860
667 STDMETHODIMP BrowserAccessibilityWin::accSelect( 861 STDMETHODIMP BrowserAccessibilityWin::accSelect(
668 LONG flags_sel, VARIANT var_id) { 862 LONG flags_sel, VARIANT var_id) {
863 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_SELECT);
669 if (!instance_active()) 864 if (!instance_active())
670 return E_FAIL; 865 return E_FAIL;
671 866
672 if (flags_sel & SELFLAG_TAKEFOCUS) { 867 if (flags_sel & SELFLAG_TAKEFOCUS) {
673 manager()->SetFocus(*this); 868 manager()->SetFocus(*this);
674 return S_OK; 869 return S_OK;
675 } 870 }
676 871
677 return S_FALSE; 872 return S_FALSE;
678 } 873 }
679 874
680 STDMETHODIMP 875 STDMETHODIMP
681 BrowserAccessibilityWin::put_accName(VARIANT var_id, BSTR put_name) { 876 BrowserAccessibilityWin::put_accName(VARIANT var_id, BSTR put_name) {
682 return E_NOTIMPL; 877 return E_NOTIMPL;
683 } 878 }
684 STDMETHODIMP 879 STDMETHODIMP
685 BrowserAccessibilityWin::put_accValue(VARIANT var_id, BSTR put_val) { 880 BrowserAccessibilityWin::put_accValue(VARIANT var_id, BSTR put_val) {
686 return E_NOTIMPL; 881 return E_NOTIMPL;
687 } 882 }
688 883
689 // 884 //
690 // IAccessible2 methods. 885 // IAccessible2 methods.
691 // 886 //
692 887
693 STDMETHODIMP BrowserAccessibilityWin::role(LONG* role) { 888 STDMETHODIMP BrowserAccessibilityWin::role(LONG* role) {
889 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ROLE);
694 if (!instance_active()) 890 if (!instance_active())
695 return E_FAIL; 891 return E_FAIL;
696 892
697 if (!role) 893 if (!role)
698 return E_INVALIDARG; 894 return E_INVALIDARG;
699 895
700 *role = ia2_role(); 896 *role = ia2_role();
701 return S_OK; 897 return S_OK;
702 } 898 }
703 899
704 STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) { 900 STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) {
901 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_GET_ATTRIBUTES);
705 if (!attributes) 902 if (!attributes)
706 return E_INVALIDARG; 903 return E_INVALIDARG;
707 *attributes = nullptr; 904 *attributes = nullptr;
708 905
709 if (!instance_active()) 906 if (!instance_active())
710 return E_FAIL; 907 return E_FAIL;
711 908
712 base::string16 str; 909 base::string16 str;
713 for (const base::string16& attribute : ia2_attributes()) 910 for (const base::string16& attribute : ia2_attributes())
714 str += attribute + L';'; 911 str += attribute + L';';
715 912
716 if (str.empty()) 913 if (str.empty())
717 return S_FALSE; 914 return S_FALSE;
718 915
719 *attributes = SysAllocString(str.c_str()); 916 *attributes = SysAllocString(str.c_str());
720 DCHECK(*attributes); 917 DCHECK(*attributes);
721 return S_OK; 918 return S_OK;
722 } 919 }
723 920
724 STDMETHODIMP BrowserAccessibilityWin::get_states(AccessibleStates* states) { 921 STDMETHODIMP BrowserAccessibilityWin::get_states(AccessibleStates* states) {
922 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_STATES);
725 if (!instance_active()) 923 if (!instance_active())
726 return E_FAIL; 924 return E_FAIL;
727 925
728 if (!states) 926 if (!states)
729 return E_INVALIDARG; 927 return E_INVALIDARG;
730 928
731 *states = ia2_state(); 929 *states = ia2_state();
732 930
733 return S_OK; 931 return S_OK;
734 } 932 }
735 933
736 STDMETHODIMP BrowserAccessibilityWin::get_uniqueID(LONG* unique_id) { 934 STDMETHODIMP BrowserAccessibilityWin::get_uniqueID(LONG* unique_id) {
935 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNIQUE_ID);
737 if (!instance_active()) 936 if (!instance_active())
738 return E_FAIL; 937 return E_FAIL;
739 938
740 if (!unique_id) 939 if (!unique_id)
741 return E_INVALIDARG; 940 return E_INVALIDARG;
742 941
743 *unique_id = -this->unique_id(); 942 *unique_id = -this->unique_id();
744 return S_OK; 943 return S_OK;
745 } 944 }
746 945
747 STDMETHODIMP BrowserAccessibilityWin::get_windowHandle(HWND* window_handle) { 946 STDMETHODIMP BrowserAccessibilityWin::get_windowHandle(HWND* window_handle) {
947 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_WINDOW_HANDLE);
748 if (!instance_active()) 948 if (!instance_active())
749 return E_FAIL; 949 return E_FAIL;
750 950
751 if (!window_handle) 951 if (!window_handle)
752 return E_INVALIDARG; 952 return E_INVALIDARG;
753 953
754 *window_handle = 954 *window_handle =
755 manager()->ToBrowserAccessibilityManagerWin()->GetParentHWND(); 955 manager()->ToBrowserAccessibilityManagerWin()->GetParentHWND();
756 if (!*window_handle) 956 if (!*window_handle)
757 return E_FAIL; 957 return E_FAIL;
758 958
759 return S_OK; 959 return S_OK;
760 } 960 }
761 961
762 STDMETHODIMP BrowserAccessibilityWin::get_indexInParent(LONG* index_in_parent) { 962 STDMETHODIMP BrowserAccessibilityWin::get_indexInParent(LONG* index_in_parent) {
963 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INDEX_IN_PARENT);
763 if (!instance_active()) 964 if (!instance_active())
764 return E_FAIL; 965 return E_FAIL;
765 966
766 if (!index_in_parent) 967 if (!index_in_parent)
767 return E_INVALIDARG; 968 return E_INVALIDARG;
768 969
769 *index_in_parent = this->GetIndexInParent(); 970 *index_in_parent = this->GetIndexInParent();
770 return S_OK; 971 return S_OK;
771 } 972 }
772 973
773 STDMETHODIMP BrowserAccessibilityWin::get_nRelations(LONG* n_relations) { 974 STDMETHODIMP BrowserAccessibilityWin::get_nRelations(LONG* n_relations) {
975 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_RELATIONS);
774 if (!instance_active()) 976 if (!instance_active())
775 return E_FAIL; 977 return E_FAIL;
776 978
777 if (!n_relations) 979 if (!n_relations)
778 return E_INVALIDARG; 980 return E_INVALIDARG;
779 981
780 *n_relations = relations_.size(); 982 *n_relations = relations_.size();
781 return S_OK; 983 return S_OK;
782 } 984 }
783 985
784 STDMETHODIMP BrowserAccessibilityWin::get_relation( 986 STDMETHODIMP BrowserAccessibilityWin::get_relation(
785 LONG relation_index, 987 LONG relation_index,
786 IAccessibleRelation** relation) { 988 IAccessibleRelation** relation) {
989 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RELATION);
787 if (!instance_active()) 990 if (!instance_active())
788 return E_FAIL; 991 return E_FAIL;
789 992
790 if (relation_index < 0 || 993 if (relation_index < 0 ||
791 relation_index >= static_cast<long>(relations_.size())) { 994 relation_index >= static_cast<long>(relations_.size())) {
792 return E_INVALIDARG; 995 return E_INVALIDARG;
793 } 996 }
794 997
795 if (!relation) 998 if (!relation)
796 return E_INVALIDARG; 999 return E_INVALIDARG;
797 1000
798 relations_[relation_index]->AddRef(); 1001 relations_[relation_index]->AddRef();
799 *relation = relations_[relation_index]; 1002 *relation = relations_[relation_index];
800 return S_OK; 1003 return S_OK;
801 } 1004 }
802 1005
803 STDMETHODIMP BrowserAccessibilityWin::get_relations( 1006 STDMETHODIMP BrowserAccessibilityWin::get_relations(
804 LONG max_relations, 1007 LONG max_relations,
805 IAccessibleRelation** relations, 1008 IAccessibleRelation** relations,
806 LONG* n_relations) { 1009 LONG* n_relations) {
1010 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RELATIONS);
807 if (!instance_active()) 1011 if (!instance_active())
808 return E_FAIL; 1012 return E_FAIL;
809 1013
810 if (!relations || !n_relations) 1014 if (!relations || !n_relations)
811 return E_INVALIDARG; 1015 return E_INVALIDARG;
812 1016
813 long count = static_cast<long>(relations_.size()); 1017 long count = static_cast<long>(relations_.size());
814 *n_relations = count; 1018 *n_relations = count;
815 if (count == 0) 1019 if (count == 0)
816 return S_FALSE; 1020 return S_FALSE;
817 1021
818 for (long i = 0; i < count; ++i) { 1022 for (long i = 0; i < count; ++i) {
819 relations_[i]->AddRef(); 1023 relations_[i]->AddRef();
820 relations[i] = relations_[i]; 1024 relations[i] = relations_[i];
821 } 1025 }
822 1026
823 return S_OK; 1027 return S_OK;
824 } 1028 }
825 1029
826 STDMETHODIMP BrowserAccessibilityWin::scrollTo(IA2ScrollType scroll_type) { 1030 STDMETHODIMP BrowserAccessibilityWin::scrollTo(IA2ScrollType scroll_type) {
1031 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_SCROLL_TO);
827 if (!instance_active()) 1032 if (!instance_active())
828 return E_FAIL; 1033 return E_FAIL;
829 1034
830 gfx::Rect r = GetFrameBoundsRect(); 1035 gfx::Rect r = GetFrameBoundsRect();
831 switch(scroll_type) { 1036 switch(scroll_type) {
832 case IA2_SCROLL_TYPE_TOP_LEFT: 1037 case IA2_SCROLL_TYPE_TOP_LEFT:
833 manager()->ScrollToMakeVisible(*this, gfx::Rect(r.x(), r.y(), 0, 0)); 1038 manager()->ScrollToMakeVisible(*this, gfx::Rect(r.x(), r.y(), 0, 0));
834 break; 1039 break;
835 case IA2_SCROLL_TYPE_BOTTOM_RIGHT: 1040 case IA2_SCROLL_TYPE_BOTTOM_RIGHT:
836 manager()->ScrollToMakeVisible( 1041 manager()->ScrollToMakeVisible(
(...skipping 22 matching lines...) Expand all
859 } 1064 }
860 1065
861 manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); 1066 manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this);
862 return S_OK; 1067 return S_OK;
863 } 1068 }
864 1069
865 STDMETHODIMP BrowserAccessibilityWin::scrollToPoint( 1070 STDMETHODIMP BrowserAccessibilityWin::scrollToPoint(
866 IA2CoordinateType coordinate_type, 1071 IA2CoordinateType coordinate_type,
867 LONG x, 1072 LONG x,
868 LONG y) { 1073 LONG y) {
1074 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_TO_POINT);
869 if (!instance_active()) 1075 if (!instance_active())
870 return E_FAIL; 1076 return E_FAIL;
871 1077
872 gfx::Point scroll_to(x, y); 1078 gfx::Point scroll_to(x, y);
873 1079
874 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { 1080 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) {
875 scroll_to -= manager()->GetViewBounds().OffsetFromOrigin(); 1081 scroll_to -= manager()->GetViewBounds().OffsetFromOrigin();
876 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { 1082 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) {
877 if (GetParent()) 1083 if (GetParent())
878 scroll_to += GetParent()->GetFrameBoundsRect().OffsetFromOrigin(); 1084 scroll_to += GetParent()->GetFrameBoundsRect().OffsetFromOrigin();
879 } else { 1085 } else {
880 return E_INVALIDARG; 1086 return E_INVALIDARG;
881 } 1087 }
882 1088
883 manager()->ScrollToPoint(*this, scroll_to); 1089 manager()->ScrollToPoint(*this, scroll_to);
884 manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); 1090 manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this);
885 1091
886 return S_OK; 1092 return S_OK;
887 } 1093 }
888 1094
889 STDMETHODIMP BrowserAccessibilityWin::get_groupPosition( 1095 STDMETHODIMP BrowserAccessibilityWin::get_groupPosition(
890 LONG* group_level, 1096 LONG* group_level,
891 LONG* similar_items_in_group, 1097 LONG* similar_items_in_group,
892 LONG* position_in_group) { 1098 LONG* position_in_group) {
1099 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_GROUP_POSITION);
893 if (!instance_active()) 1100 if (!instance_active())
894 return E_FAIL; 1101 return E_FAIL;
895 1102
896 if (!group_level || !similar_items_in_group || !position_in_group) 1103 if (!group_level || !similar_items_in_group || !position_in_group)
897 return E_INVALIDARG; 1104 return E_INVALIDARG;
898 1105
899 *group_level = GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL); 1106 *group_level = GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL);
900 *similar_items_in_group = GetIntAttribute(ui::AX_ATTR_SET_SIZE); 1107 *similar_items_in_group = GetIntAttribute(ui::AX_ATTR_SET_SIZE);
901 *position_in_group = GetIntAttribute(ui::AX_ATTR_POS_IN_SET); 1108 *position_in_group = GetIntAttribute(ui::AX_ATTR_POS_IN_SET);
902 1109
903 if (*group_level == *similar_items_in_group == *position_in_group == 0) 1110 if (*group_level == *similar_items_in_group == *position_in_group == 0)
904 return S_FALSE; 1111 return S_FALSE;
905 return S_OK; 1112 return S_OK;
906 } 1113 }
907 1114
908 // 1115 //
909 // IAccessibleEx methods not implemented. 1116 // IAccessibleEx methods not implemented.
910 // 1117 //
911 1118
912 STDMETHODIMP BrowserAccessibilityWin::get_extendedRole(BSTR* extended_role) { 1119 STDMETHODIMP BrowserAccessibilityWin::get_extendedRole(BSTR* extended_role) {
1120 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_EXTENDED_ROLE);
913 return E_NOTIMPL; 1121 return E_NOTIMPL;
914 } 1122 }
915 STDMETHODIMP 1123 STDMETHODIMP
916 BrowserAccessibilityWin::get_localizedExtendedRole( 1124 BrowserAccessibilityWin::get_localizedExtendedRole(
917 BSTR* localized_extended_role) { 1125 BSTR* localized_extended_role) {
1126 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_EXTENDED_ROLE);
918 return E_NOTIMPL; 1127 return E_NOTIMPL;
919 } 1128 }
920 STDMETHODIMP 1129 STDMETHODIMP
921 BrowserAccessibilityWin::get_nExtendedStates(LONG* n_extended_states) { 1130 BrowserAccessibilityWin::get_nExtendedStates(LONG* n_extended_states) {
1131 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_EXTENDED_STATES);
922 return E_NOTIMPL; 1132 return E_NOTIMPL;
923 } 1133 }
924 STDMETHODIMP 1134 STDMETHODIMP
925 BrowserAccessibilityWin::get_extendedStates(LONG max_extended_states, 1135 BrowserAccessibilityWin::get_extendedStates(LONG max_extended_states,
926 BSTR** extended_states, 1136 BSTR** extended_states,
927 LONG* n_extended_states) { 1137 LONG* n_extended_states) {
1138 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_EXTENDED_STATES);
928 return E_NOTIMPL; 1139 return E_NOTIMPL;
929 } 1140 }
930 STDMETHODIMP 1141 STDMETHODIMP
931 BrowserAccessibilityWin::get_localizedExtendedStates( 1142 BrowserAccessibilityWin::get_localizedExtendedStates(
932 LONG max_localized_extended_states, 1143 LONG max_localized_extended_states,
933 BSTR** localized_extended_states, 1144 BSTR** localized_extended_states,
934 LONG* n_localized_extended_states) { 1145 LONG* n_localized_extended_states) {
1146 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_EXTENDED_STATES);
935 return E_NOTIMPL; 1147 return E_NOTIMPL;
936 } 1148 }
937 STDMETHODIMP BrowserAccessibilityWin::get_locale(IA2Locale* locale) { 1149 STDMETHODIMP BrowserAccessibilityWin::get_locale(IA2Locale* locale) {
1150 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALE);
938 return E_NOTIMPL; 1151 return E_NOTIMPL;
939 } 1152 }
940 1153
941 // 1154 //
942 // IAccessibleApplication methods. 1155 // IAccessibleApplication methods.
943 // 1156 //
944 1157
945 STDMETHODIMP BrowserAccessibilityWin::get_appName(BSTR* app_name) { 1158 STDMETHODIMP BrowserAccessibilityWin::get_appName(BSTR* app_name) {
1159 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_APP_NAME);
946 // No need to check |instance_active()| because this interface is 1160 // No need to check |instance_active()| because this interface is
947 // global, and doesn't depend on any local state. 1161 // global, and doesn't depend on any local state.
948 1162
949 if (!app_name) 1163 if (!app_name)
950 return E_INVALIDARG; 1164 return E_INVALIDARG;
951 1165
952 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out 1166 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out
953 // the part before the "/". 1167 // the part before the "/".
954 std::vector<std::string> product_components = base::SplitString( 1168 std::vector<std::string> product_components = base::SplitString(
955 GetContentClient()->GetProduct(), "/", 1169 GetContentClient()->GetProduct(), "/",
956 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 1170 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
957 DCHECK_EQ(2U, product_components.size()); 1171 DCHECK_EQ(2U, product_components.size());
958 if (product_components.size() != 2) 1172 if (product_components.size() != 2)
959 return E_FAIL; 1173 return E_FAIL;
960 *app_name = SysAllocString(base::UTF8ToUTF16(product_components[0]).c_str()); 1174 *app_name = SysAllocString(base::UTF8ToUTF16(product_components[0]).c_str());
961 DCHECK(*app_name); 1175 DCHECK(*app_name);
962 return *app_name ? S_OK : E_FAIL; 1176 return *app_name ? S_OK : E_FAIL;
963 } 1177 }
964 1178
965 STDMETHODIMP BrowserAccessibilityWin::get_appVersion(BSTR* app_version) { 1179 STDMETHODIMP BrowserAccessibilityWin::get_appVersion(BSTR* app_version) {
1180 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_APP_VERSION);
966 // No need to check |instance_active()| because this interface is 1181 // No need to check |instance_active()| because this interface is
967 // global, and doesn't depend on any local state. 1182 // global, and doesn't depend on any local state.
968 1183
969 if (!app_version) 1184 if (!app_version)
970 return E_INVALIDARG; 1185 return E_INVALIDARG;
971 1186
972 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out 1187 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out
973 // the part after the "/". 1188 // the part after the "/".
974 std::vector<std::string> product_components = base::SplitString( 1189 std::vector<std::string> product_components = base::SplitString(
975 GetContentClient()->GetProduct(), "/", 1190 GetContentClient()->GetProduct(), "/",
976 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 1191 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
977 DCHECK_EQ(2U, product_components.size()); 1192 DCHECK_EQ(2U, product_components.size());
978 if (product_components.size() != 2) 1193 if (product_components.size() != 2)
979 return E_FAIL; 1194 return E_FAIL;
980 *app_version = 1195 *app_version =
981 SysAllocString(base::UTF8ToUTF16(product_components[1]).c_str()); 1196 SysAllocString(base::UTF8ToUTF16(product_components[1]).c_str());
982 DCHECK(*app_version); 1197 DCHECK(*app_version);
983 return *app_version ? S_OK : E_FAIL; 1198 return *app_version ? S_OK : E_FAIL;
984 } 1199 }
985 1200
986 STDMETHODIMP BrowserAccessibilityWin::get_toolkitName(BSTR* toolkit_name) { 1201 STDMETHODIMP BrowserAccessibilityWin::get_toolkitName(BSTR* toolkit_name) {
1202 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TOOLKIT_NAME);
987 // No need to check |instance_active()| because this interface is 1203 // No need to check |instance_active()| because this interface is
988 // global, and doesn't depend on any local state. 1204 // global, and doesn't depend on any local state.
989 1205
990 if (!toolkit_name) 1206 if (!toolkit_name)
991 return E_INVALIDARG; 1207 return E_INVALIDARG;
992 1208
993 // This is hard-coded; all products based on the Chromium engine 1209 // This is hard-coded; all products based on the Chromium engine
994 // will have the same toolkit name, so that assistive technology can 1210 // will have the same toolkit name, so that assistive technology can
995 // detect any Chrome-based product. 1211 // detect any Chrome-based product.
996 *toolkit_name = SysAllocString(L"Chrome"); 1212 *toolkit_name = SysAllocString(L"Chrome");
997 DCHECK(*toolkit_name); 1213 DCHECK(*toolkit_name);
998 return *toolkit_name ? S_OK : E_FAIL; 1214 return *toolkit_name ? S_OK : E_FAIL;
999 } 1215 }
1000 1216
1001 STDMETHODIMP BrowserAccessibilityWin::get_toolkitVersion( 1217 STDMETHODIMP BrowserAccessibilityWin::get_toolkitVersion(
1002 BSTR* toolkit_version) { 1218 BSTR* toolkit_version) {
1219 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TOOLKIT_VERSION);
1003 // No need to check |instance_active()| because this interface is 1220 // No need to check |instance_active()| because this interface is
1004 // global, and doesn't depend on any local state. 1221 // global, and doesn't depend on any local state.
1005 1222
1006 if (!toolkit_version) 1223 if (!toolkit_version)
1007 return E_INVALIDARG; 1224 return E_INVALIDARG;
1008 1225
1009 std::string user_agent = GetContentClient()->GetUserAgent(); 1226 std::string user_agent = GetContentClient()->GetUserAgent();
1010 *toolkit_version = SysAllocString(base::UTF8ToUTF16(user_agent).c_str()); 1227 *toolkit_version = SysAllocString(base::UTF8ToUTF16(user_agent).c_str());
1011 DCHECK(*toolkit_version); 1228 DCHECK(*toolkit_version);
1012 return *toolkit_version ? S_OK : E_FAIL; 1229 return *toolkit_version ? S_OK : E_FAIL;
1013 } 1230 }
1014 1231
1015 // 1232 //
1016 // IAccessibleImage methods. 1233 // IAccessibleImage methods.
1017 // 1234 //
1018 1235
1019 STDMETHODIMP BrowserAccessibilityWin::get_description(BSTR* desc) { 1236 STDMETHODIMP BrowserAccessibilityWin::get_description(BSTR* desc) {
1237 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DESCRIPTION);
1020 if (!instance_active()) 1238 if (!instance_active())
1021 return E_FAIL; 1239 return E_FAIL;
1022 1240
1023 if (!desc) 1241 if (!desc)
1024 return E_INVALIDARG; 1242 return E_INVALIDARG;
1025 1243
1026 if (description().empty()) 1244 if (description().empty())
1027 return S_FALSE; 1245 return S_FALSE;
1028 1246
1029 *desc = SysAllocString(description().c_str()); 1247 *desc = SysAllocString(description().c_str());
1030 1248
1031 DCHECK(*desc); 1249 DCHECK(*desc);
1032 return S_OK; 1250 return S_OK;
1033 } 1251 }
1034 1252
1035 STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( 1253 STDMETHODIMP BrowserAccessibilityWin::get_imagePosition(
1036 IA2CoordinateType coordinate_type, 1254 IA2CoordinateType coordinate_type,
1037 LONG* x, 1255 LONG* x,
1038 LONG* y) { 1256 LONG* y) {
1257 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IMAGE_POSITION);
1039 if (!instance_active()) 1258 if (!instance_active())
1040 return E_FAIL; 1259 return E_FAIL;
1041 1260
1042 if (!x || !y) 1261 if (!x || !y)
1043 return E_INVALIDARG; 1262 return E_INVALIDARG;
1044 1263
1045 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { 1264 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) {
1046 gfx::Rect bounds = GetScreenBoundsRect(); 1265 gfx::Rect bounds = GetScreenBoundsRect();
1047 *x = bounds.x(); 1266 *x = bounds.x();
1048 *y = bounds.y(); 1267 *y = bounds.y();
1049 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { 1268 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) {
1050 gfx::Rect bounds = GetPageBoundsRect(); 1269 gfx::Rect bounds = GetPageBoundsRect();
1051 gfx::Rect parent_bounds = 1270 gfx::Rect parent_bounds =
1052 GetParent() ? GetParent()->GetPageBoundsRect() : gfx::Rect(); 1271 GetParent() ? GetParent()->GetPageBoundsRect() : gfx::Rect();
1053 *x = bounds.x() - parent_bounds.x(); 1272 *x = bounds.x() - parent_bounds.x();
1054 *y = bounds.y() - parent_bounds.y(); 1273 *y = bounds.y() - parent_bounds.y();
1055 } else { 1274 } else {
1056 return E_INVALIDARG; 1275 return E_INVALIDARG;
1057 } 1276 }
1058 1277
1059 return S_OK; 1278 return S_OK;
1060 } 1279 }
1061 1280
1062 STDMETHODIMP BrowserAccessibilityWin::get_imageSize(LONG* height, LONG* width) { 1281 STDMETHODIMP BrowserAccessibilityWin::get_imageSize(LONG* height, LONG* width) {
1282 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IMAGE_SIZE);
1063 if (!instance_active()) 1283 if (!instance_active())
1064 return E_FAIL; 1284 return E_FAIL;
1065 1285
1066 if (!height || !width) 1286 if (!height || !width)
1067 return E_INVALIDARG; 1287 return E_INVALIDARG;
1068 1288
1069 *height = GetPageBoundsRect().height(); 1289 *height = GetPageBoundsRect().height();
1070 *width = GetPageBoundsRect().width(); 1290 *width = GetPageBoundsRect().width();
1071 return S_OK; 1291 return S_OK;
1072 } 1292 }
1073 1293
1074 // 1294 //
1075 // IAccessibleTable methods. 1295 // IAccessibleTable methods.
1076 // 1296 //
1077 1297
1078 STDMETHODIMP BrowserAccessibilityWin::get_accessibleAt( 1298 STDMETHODIMP BrowserAccessibilityWin::get_accessibleAt(
1079 long row, 1299 long row,
1080 long column, 1300 long column,
1081 IUnknown** accessible) { 1301 IUnknown** accessible) {
1302 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACCESSIBLE_AT);
1082 if (!instance_active()) 1303 if (!instance_active())
1083 return E_FAIL; 1304 return E_FAIL;
1084 1305
1085 if (!accessible) 1306 if (!accessible)
1086 return E_INVALIDARG; 1307 return E_INVALIDARG;
1087 1308
1088 int columns; 1309 int columns;
1089 int rows; 1310 int rows;
1090 if (!GetIntAttribute( 1311 if (!GetIntAttribute(
1091 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || 1312 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) ||
(...skipping 16 matching lines...) Expand all
1108 if (cell) { 1329 if (cell) {
1109 *accessible = static_cast<IAccessible*>(cell->NewReference()); 1330 *accessible = static_cast<IAccessible*>(cell->NewReference());
1110 return S_OK; 1331 return S_OK;
1111 } 1332 }
1112 1333
1113 *accessible = NULL; 1334 *accessible = NULL;
1114 return E_INVALIDARG; 1335 return E_INVALIDARG;
1115 } 1336 }
1116 1337
1117 STDMETHODIMP BrowserAccessibilityWin::get_caption(IUnknown** accessible) { 1338 STDMETHODIMP BrowserAccessibilityWin::get_caption(IUnknown** accessible) {
1339 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CAPTION);
1118 if (!instance_active()) 1340 if (!instance_active())
1119 return E_FAIL; 1341 return E_FAIL;
1120 1342
1121 if (!accessible) 1343 if (!accessible)
1122 return E_INVALIDARG; 1344 return E_INVALIDARG;
1123 1345
1124 // TODO(dmazzoni): implement 1346 // TODO(dmazzoni): implement
1125 return S_FALSE; 1347 return S_FALSE;
1126 } 1348 }
1127 1349
1128 STDMETHODIMP BrowserAccessibilityWin::get_childIndex(long row, 1350 STDMETHODIMP BrowserAccessibilityWin::get_childIndex(long row,
1129 long column, 1351 long column,
1130 long* cell_index) { 1352 long* cell_index) {
1353 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_INDEX);
1131 if (!instance_active()) 1354 if (!instance_active())
1132 return E_FAIL; 1355 return E_FAIL;
1133 1356
1134 if (!cell_index) 1357 if (!cell_index)
1135 return E_INVALIDARG; 1358 return E_INVALIDARG;
1136 1359
1137 int columns; 1360 int columns;
1138 int rows; 1361 int rows;
1139 if (!GetIntAttribute( 1362 if (!GetIntAttribute(
1140 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || 1363 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) ||
(...skipping 18 matching lines...) Expand all
1159 *cell_index = (long)i; 1382 *cell_index = (long)i;
1160 return S_OK; 1383 return S_OK;
1161 } 1384 }
1162 } 1385 }
1163 1386
1164 return S_FALSE; 1387 return S_FALSE;
1165 } 1388 }
1166 1389
1167 STDMETHODIMP BrowserAccessibilityWin::get_columnDescription(long column, 1390 STDMETHODIMP BrowserAccessibilityWin::get_columnDescription(long column,
1168 BSTR* description) { 1391 BSTR* description) {
1392 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_DESCRIPTION);
1169 if (!instance_active()) 1393 if (!instance_active())
1170 return E_FAIL; 1394 return E_FAIL;
1171 1395
1172 if (!description) 1396 if (!description)
1173 return E_INVALIDARG; 1397 return E_INVALIDARG;
1174 1398
1175 int columns; 1399 int columns;
1176 int rows; 1400 int rows;
1177 if (!GetIntAttribute( 1401 if (!GetIntAttribute(
1178 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || 1402 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) ||
(...skipping 26 matching lines...) Expand all
1205 } 1429 }
1206 } 1430 }
1207 1431
1208 return S_FALSE; 1432 return S_FALSE;
1209 } 1433 }
1210 1434
1211 STDMETHODIMP BrowserAccessibilityWin::get_columnExtentAt( 1435 STDMETHODIMP BrowserAccessibilityWin::get_columnExtentAt(
1212 long row, 1436 long row,
1213 long column, 1437 long column,
1214 long* n_columns_spanned) { 1438 long* n_columns_spanned) {
1439 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_EXTENT_AT);
1215 if (!instance_active()) 1440 if (!instance_active())
1216 return E_FAIL; 1441 return E_FAIL;
1217 1442
1218 if (!n_columns_spanned) 1443 if (!n_columns_spanned)
1219 return E_INVALIDARG; 1444 return E_INVALIDARG;
1220 1445
1221 int columns; 1446 int columns;
1222 int rows; 1447 int rows;
1223 if (!GetIntAttribute( 1448 if (!GetIntAttribute(
1224 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || 1449 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) ||
(...skipping 18 matching lines...) Expand all
1243 *n_columns_spanned = colspan; 1468 *n_columns_spanned = colspan;
1244 return S_OK; 1469 return S_OK;
1245 } 1470 }
1246 1471
1247 return S_FALSE; 1472 return S_FALSE;
1248 } 1473 }
1249 1474
1250 STDMETHODIMP BrowserAccessibilityWin::get_columnHeader( 1475 STDMETHODIMP BrowserAccessibilityWin::get_columnHeader(
1251 IAccessibleTable** accessible_table, 1476 IAccessibleTable** accessible_table,
1252 long* starting_row_index) { 1477 long* starting_row_index) {
1478 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_HEADER);
1253 // TODO(dmazzoni): implement 1479 // TODO(dmazzoni): implement
1254 return E_NOTIMPL; 1480 return E_NOTIMPL;
1255 } 1481 }
1256 1482
1257 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long cell_index, 1483 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long cell_index,
1258 long* column_index) { 1484 long* column_index) {
1485 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_INDEX);
1259 if (!instance_active()) 1486 if (!instance_active())
1260 return E_FAIL; 1487 return E_FAIL;
1261 1488
1262 if (!column_index) 1489 if (!column_index)
1263 return E_INVALIDARG; 1490 return E_INVALIDARG;
1264 1491
1265 const std::vector<int32_t>& unique_cell_ids = 1492 const std::vector<int32_t>& unique_cell_ids =
1266 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); 1493 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS);
1267 int cell_id_count = static_cast<int>(unique_cell_ids.size()); 1494 int cell_id_count = static_cast<int>(unique_cell_ids.size());
1268 if (cell_index < 0) 1495 if (cell_index < 0)
1269 return E_INVALIDARG; 1496 return E_INVALIDARG;
1270 if (cell_index >= cell_id_count) 1497 if (cell_index >= cell_id_count)
1271 return S_FALSE; 1498 return S_FALSE;
1272 1499
1273 int cell_id = unique_cell_ids[cell_index]; 1500 int cell_id = unique_cell_ids[cell_index];
1274 BrowserAccessibilityWin* cell = GetFromID(cell_id); 1501 BrowserAccessibilityWin* cell = GetFromID(cell_id);
1275 int col_index; 1502 int col_index;
1276 if (cell && 1503 if (cell &&
1277 cell->GetIntAttribute( 1504 cell->GetIntAttribute(
1278 ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &col_index)) { 1505 ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &col_index)) {
1279 *column_index = col_index; 1506 *column_index = col_index;
1280 return S_OK; 1507 return S_OK;
1281 } 1508 }
1282 1509
1283 return S_FALSE; 1510 return S_FALSE;
1284 } 1511 }
1285 1512
1286 STDMETHODIMP BrowserAccessibilityWin::get_nColumns(long* column_count) { 1513 STDMETHODIMP BrowserAccessibilityWin::get_nColumns(long* column_count) {
1514 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_COLUMNS);
1287 if (!instance_active()) 1515 if (!instance_active())
1288 return E_FAIL; 1516 return E_FAIL;
1289 1517
1290 if (!column_count) 1518 if (!column_count)
1291 return E_INVALIDARG; 1519 return E_INVALIDARG;
1292 1520
1293 int columns; 1521 int columns;
1294 if (GetIntAttribute( 1522 if (GetIntAttribute(
1295 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns)) { 1523 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns)) {
1296 *column_count = columns; 1524 *column_count = columns;
1297 return S_OK; 1525 return S_OK;
1298 } 1526 }
1299 1527
1300 return S_FALSE; 1528 return S_FALSE;
1301 } 1529 }
1302 1530
1303 STDMETHODIMP BrowserAccessibilityWin::get_nRows(long* row_count) { 1531 STDMETHODIMP BrowserAccessibilityWin::get_nRows(long* row_count) {
1532 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_ROWS);
1304 if (!instance_active()) 1533 if (!instance_active())
1305 return E_FAIL; 1534 return E_FAIL;
1306 1535
1307 if (!row_count) 1536 if (!row_count)
1308 return E_INVALIDARG; 1537 return E_INVALIDARG;
1309 1538
1310 int rows; 1539 int rows;
1311 if (GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows)) { 1540 if (GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows)) {
1312 *row_count = rows; 1541 *row_count = rows;
1313 return S_OK; 1542 return S_OK;
1314 } 1543 }
1315 1544
1316 return S_FALSE; 1545 return S_FALSE;
1317 } 1546 }
1318 1547
1319 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedChildren(long* cell_count) { 1548 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedChildren(long* cell_count) {
1549 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_CHILDREN);
1320 if (!instance_active()) 1550 if (!instance_active())
1321 return E_FAIL; 1551 return E_FAIL;
1322 1552
1323 if (!cell_count) 1553 if (!cell_count)
1324 return E_INVALIDARG; 1554 return E_INVALIDARG;
1325 1555
1326 // TODO(dmazzoni): add support for selected cells/rows/columns in tables. 1556 // TODO(dmazzoni): add support for selected cells/rows/columns in tables.
1327 *cell_count = 0; 1557 *cell_count = 0;
1328 return S_OK; 1558 return S_OK;
1329 } 1559 }
1330 1560
1331 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedColumns(long* column_count) { 1561 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedColumns(long* column_count) {
1562 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_COLUMNS);
1332 if (!instance_active()) 1563 if (!instance_active())
1333 return E_FAIL; 1564 return E_FAIL;
1334 1565
1335 if (!column_count) 1566 if (!column_count)
1336 return E_INVALIDARG; 1567 return E_INVALIDARG;
1337 1568
1338 *column_count = 0; 1569 *column_count = 0;
1339 return S_OK; 1570 return S_OK;
1340 } 1571 }
1341 1572
1342 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedRows(long* row_count) { 1573 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedRows(long* row_count) {
1574 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_ROWS);
1343 if (!instance_active()) 1575 if (!instance_active())
1344 return E_FAIL; 1576 return E_FAIL;
1345 1577
1346 if (!row_count) 1578 if (!row_count)
1347 return E_INVALIDARG; 1579 return E_INVALIDARG;
1348 1580
1349 *row_count = 0; 1581 *row_count = 0;
1350 return S_OK; 1582 return S_OK;
1351 } 1583 }
1352 1584
1353 STDMETHODIMP BrowserAccessibilityWin::get_rowDescription(long row, 1585 STDMETHODIMP BrowserAccessibilityWin::get_rowDescription(long row,
1354 BSTR* description) { 1586 BSTR* description) {
1587 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_DESCRIPTION);
1355 if (!instance_active()) 1588 if (!instance_active())
1356 return E_FAIL; 1589 return E_FAIL;
1357 1590
1358 if (!description) 1591 if (!description)
1359 return E_INVALIDARG; 1592 return E_INVALIDARG;
1360 1593
1361 int columns; 1594 int columns;
1362 int rows; 1595 int rows;
1363 if (!GetIntAttribute( 1596 if (!GetIntAttribute(
1364 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || 1597 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) ||
(...skipping 25 matching lines...) Expand all
1390 } 1623 }
1391 } 1624 }
1392 } 1625 }
1393 1626
1394 return S_FALSE; 1627 return S_FALSE;
1395 } 1628 }
1396 1629
1397 STDMETHODIMP BrowserAccessibilityWin::get_rowExtentAt(long row, 1630 STDMETHODIMP BrowserAccessibilityWin::get_rowExtentAt(long row,
1398 long column, 1631 long column,
1399 long* n_rows_spanned) { 1632 long* n_rows_spanned) {
1633 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_EXTENT_AT);
1400 if (!instance_active()) 1634 if (!instance_active())
1401 return E_FAIL; 1635 return E_FAIL;
1402 1636
1403 if (!n_rows_spanned) 1637 if (!n_rows_spanned)
1404 return E_INVALIDARG; 1638 return E_INVALIDARG;
1405 1639
1406 int columns; 1640 int columns;
1407 int rows; 1641 int rows;
1408 if (!GetIntAttribute( 1642 if (!GetIntAttribute(
1409 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || 1643 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) ||
(...skipping 18 matching lines...) Expand all
1428 *n_rows_spanned = rowspan; 1662 *n_rows_spanned = rowspan;
1429 return S_OK; 1663 return S_OK;
1430 } 1664 }
1431 1665
1432 return S_FALSE; 1666 return S_FALSE;
1433 } 1667 }
1434 1668
1435 STDMETHODIMP BrowserAccessibilityWin::get_rowHeader( 1669 STDMETHODIMP BrowserAccessibilityWin::get_rowHeader(
1436 IAccessibleTable** accessible_table, 1670 IAccessibleTable** accessible_table,
1437 long* starting_column_index) { 1671 long* starting_column_index) {
1672 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_HEADER);
1438 // TODO(dmazzoni): implement 1673 // TODO(dmazzoni): implement
1439 return E_NOTIMPL; 1674 return E_NOTIMPL;
1440 } 1675 }
1441 1676
1442 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long cell_index, 1677 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long cell_index,
1443 long* row_index) { 1678 long* row_index) {
1679 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_INDEX);
1444 if (!instance_active()) 1680 if (!instance_active())
1445 return E_FAIL; 1681 return E_FAIL;
1446 1682
1447 if (!row_index) 1683 if (!row_index)
1448 return E_INVALIDARG; 1684 return E_INVALIDARG;
1449 1685
1450 const std::vector<int32_t>& unique_cell_ids = 1686 const std::vector<int32_t>& unique_cell_ids =
1451 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); 1687 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS);
1452 int cell_id_count = static_cast<int>(unique_cell_ids.size()); 1688 int cell_id_count = static_cast<int>(unique_cell_ids.size());
1453 if (cell_index < 0) 1689 if (cell_index < 0)
(...skipping 10 matching lines...) Expand all
1464 *row_index = cell_row_index; 1700 *row_index = cell_row_index;
1465 return S_OK; 1701 return S_OK;
1466 } 1702 }
1467 1703
1468 return S_FALSE; 1704 return S_FALSE;
1469 } 1705 }
1470 1706
1471 STDMETHODIMP BrowserAccessibilityWin::get_selectedChildren(long max_children, 1707 STDMETHODIMP BrowserAccessibilityWin::get_selectedChildren(long max_children,
1472 long** children, 1708 long** children,
1473 long* n_children) { 1709 long* n_children) {
1710 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_CHILDREN);
1474 if (!instance_active()) 1711 if (!instance_active())
1475 return E_FAIL; 1712 return E_FAIL;
1476 1713
1477 if (!children || !n_children) 1714 if (!children || !n_children)
1478 return E_INVALIDARG; 1715 return E_INVALIDARG;
1479 1716
1480 // TODO(dmazzoni): Implement this. 1717 // TODO(dmazzoni): Implement this.
1481 *n_children = 0; 1718 *n_children = 0;
1482 return S_OK; 1719 return S_OK;
1483 } 1720 }
1484 1721
1485 STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long max_columns, 1722 STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long max_columns,
1486 long** columns, 1723 long** columns,
1487 long* n_columns) { 1724 long* n_columns) {
1725 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_COLUMNS);
1488 if (!instance_active()) 1726 if (!instance_active())
1489 return E_FAIL; 1727 return E_FAIL;
1490 1728
1491 if (!columns || !n_columns) 1729 if (!columns || !n_columns)
1492 return E_INVALIDARG; 1730 return E_INVALIDARG;
1493 1731
1494 // TODO(dmazzoni): Implement this. 1732 // TODO(dmazzoni): Implement this.
1495 *n_columns = 0; 1733 *n_columns = 0;
1496 return S_OK; 1734 return S_OK;
1497 } 1735 }
1498 1736
1499 STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long max_rows, 1737 STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long max_rows,
1500 long** rows, 1738 long** rows,
1501 long* n_rows) { 1739 long* n_rows) {
1740 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_ROWS);
1502 if (!instance_active()) 1741 if (!instance_active())
1503 return E_FAIL; 1742 return E_FAIL;
1504 1743
1505 if (!rows || !n_rows) 1744 if (!rows || !n_rows)
1506 return E_INVALIDARG; 1745 return E_INVALIDARG;
1507 1746
1508 // TODO(dmazzoni): Implement this. 1747 // TODO(dmazzoni): Implement this.
1509 *n_rows = 0; 1748 *n_rows = 0;
1510 return S_OK; 1749 return S_OK;
1511 } 1750 }
1512 1751
1513 STDMETHODIMP BrowserAccessibilityWin::get_summary(IUnknown** accessible) { 1752 STDMETHODIMP BrowserAccessibilityWin::get_summary(IUnknown** accessible) {
1753 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SUMMARY);
1514 if (!instance_active()) 1754 if (!instance_active())
1515 return E_FAIL; 1755 return E_FAIL;
1516 1756
1517 if (!accessible) 1757 if (!accessible)
1518 return E_INVALIDARG; 1758 return E_INVALIDARG;
1519 1759
1520 // TODO(dmazzoni): implement 1760 // TODO(dmazzoni): implement
1521 return S_FALSE; 1761 return S_FALSE;
1522 } 1762 }
1523 1763
1524 STDMETHODIMP BrowserAccessibilityWin::get_isColumnSelected( 1764 STDMETHODIMP BrowserAccessibilityWin::get_isColumnSelected(
1525 long column, 1765 long column,
1526 boolean* is_selected) { 1766 boolean* is_selected) {
1767 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_COLUMN_SELECTED);
1527 if (!instance_active()) 1768 if (!instance_active())
1528 return E_FAIL; 1769 return E_FAIL;
1529 1770
1530 if (!is_selected) 1771 if (!is_selected)
1531 return E_INVALIDARG; 1772 return E_INVALIDARG;
1532 1773
1533 // TODO(dmazzoni): Implement this. 1774 // TODO(dmazzoni): Implement this.
1534 *is_selected = false; 1775 *is_selected = false;
1535 return S_OK; 1776 return S_OK;
1536 } 1777 }
1537 1778
1538 STDMETHODIMP BrowserAccessibilityWin::get_isRowSelected(long row, 1779 STDMETHODIMP BrowserAccessibilityWin::get_isRowSelected(long row,
1539 boolean* is_selected) { 1780 boolean* is_selected) {
1781 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_ROW_SELECTED);
1540 if (!instance_active()) 1782 if (!instance_active())
1541 return E_FAIL; 1783 return E_FAIL;
1542 1784
1543 if (!is_selected) 1785 if (!is_selected)
1544 return E_INVALIDARG; 1786 return E_INVALIDARG;
1545 1787
1546 // TODO(dmazzoni): Implement this. 1788 // TODO(dmazzoni): Implement this.
1547 *is_selected = false; 1789 *is_selected = false;
1548 return S_OK; 1790 return S_OK;
1549 } 1791 }
1550 1792
1551 STDMETHODIMP BrowserAccessibilityWin::get_isSelected(long row, 1793 STDMETHODIMP BrowserAccessibilityWin::get_isSelected(long row,
1552 long column, 1794 long column,
1553 boolean* is_selected) { 1795 boolean* is_selected) {
1796 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_SELECTED);
1554 if (!instance_active()) 1797 if (!instance_active())
1555 return E_FAIL; 1798 return E_FAIL;
1556 1799
1557 if (!is_selected) 1800 if (!is_selected)
1558 return E_INVALIDARG; 1801 return E_INVALIDARG;
1559 1802
1560 // TODO(dmazzoni): Implement this. 1803 // TODO(dmazzoni): Implement this.
1561 *is_selected = false; 1804 *is_selected = false;
1562 return S_OK; 1805 return S_OK;
1563 } 1806 }
1564 1807
1565 STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtentsAtIndex( 1808 STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtentsAtIndex(
1566 long index, 1809 long index,
1567 long* row, 1810 long* row,
1568 long* column, 1811 long* column,
1569 long* row_extents, 1812 long* row_extents,
1570 long* column_extents, 1813 long* column_extents,
1571 boolean* is_selected) { 1814 boolean* is_selected) {
1815 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_COLUMN_EXTENTS_AT_INDEX);
1572 if (!instance_active()) 1816 if (!instance_active())
1573 return E_FAIL; 1817 return E_FAIL;
1574 1818
1575 if (!row || !column || !row_extents || !column_extents || !is_selected) 1819 if (!row || !column || !row_extents || !column_extents || !is_selected)
1576 return E_INVALIDARG; 1820 return E_INVALIDARG;
1577 1821
1578 const std::vector<int32_t>& unique_cell_ids = 1822 const std::vector<int32_t>& unique_cell_ids =
1579 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); 1823 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS);
1580 int cell_id_count = static_cast<int>(unique_cell_ids.size()); 1824 int cell_id_count = static_cast<int>(unique_cell_ids.size());
1581 if (index < 0) 1825 if (index < 0)
(...skipping 14 matching lines...) Expand all
1596 colspan >= 1) { 1840 colspan >= 1) {
1597 *row_extents = rowspan; 1841 *row_extents = rowspan;
1598 *column_extents = colspan; 1842 *column_extents = colspan;
1599 return S_OK; 1843 return S_OK;
1600 } 1844 }
1601 1845
1602 return S_FALSE; 1846 return S_FALSE;
1603 } 1847 }
1604 1848
1605 STDMETHODIMP BrowserAccessibilityWin::selectRow(long row) { 1849 STDMETHODIMP BrowserAccessibilityWin::selectRow(long row) {
1850 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SELECT_ROW);
1606 return E_NOTIMPL; 1851 return E_NOTIMPL;
1607 } 1852 }
1608 1853
1609 STDMETHODIMP BrowserAccessibilityWin::selectColumn(long column) { 1854 STDMETHODIMP BrowserAccessibilityWin::selectColumn(long column) {
1855 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SELECT_COLUMN);
1610 return E_NOTIMPL; 1856 return E_NOTIMPL;
1611 } 1857 }
1612 1858
1613 STDMETHODIMP BrowserAccessibilityWin::unselectRow(long row) { 1859 STDMETHODIMP BrowserAccessibilityWin::unselectRow(long row) {
1860 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_UNSELECT_ROW);
1614 return E_NOTIMPL; 1861 return E_NOTIMPL;
1615 } 1862 }
1616 1863
1617 STDMETHODIMP BrowserAccessibilityWin::unselectColumn(long column) { 1864 STDMETHODIMP BrowserAccessibilityWin::unselectColumn(long column) {
1865 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_UNSELECT_COLUMN);
1618 return E_NOTIMPL; 1866 return E_NOTIMPL;
1619 } 1867 }
1620 1868
1621 STDMETHODIMP 1869 STDMETHODIMP
1622 BrowserAccessibilityWin::get_modelChange(IA2TableModelChange* model_change) { 1870 BrowserAccessibilityWin::get_modelChange(IA2TableModelChange* model_change) {
1623 return E_NOTIMPL; 1871 return E_NOTIMPL;
1624 } 1872 }
1625 1873
1626 // 1874 //
1627 // IAccessibleTable2 methods. 1875 // IAccessibleTable2 methods.
1628 // 1876 //
1629 1877
1630 STDMETHODIMP BrowserAccessibilityWin::get_cellAt(long row, 1878 STDMETHODIMP BrowserAccessibilityWin::get_cellAt(long row,
1631 long column, 1879 long column,
1632 IUnknown** cell) { 1880 IUnknown** cell) {
1881 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CELL_AT);
1633 return get_accessibleAt(row, column, cell); 1882 return get_accessibleAt(row, column, cell);
1634 } 1883 }
1635 1884
1636 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedCells(long* cell_count) { 1885 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedCells(long* cell_count) {
1886 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_CELLS);
1637 return get_nSelectedChildren(cell_count); 1887 return get_nSelectedChildren(cell_count);
1638 } 1888 }
1639 1889
1640 STDMETHODIMP BrowserAccessibilityWin::get_selectedCells( 1890 STDMETHODIMP BrowserAccessibilityWin::get_selectedCells(
1641 IUnknown*** cells, 1891 IUnknown*** cells,
1642 long* n_selected_cells) { 1892 long* n_selected_cells) {
1893 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_CELLS);
1643 if (!instance_active()) 1894 if (!instance_active())
1644 return E_FAIL; 1895 return E_FAIL;
1645 1896
1646 if (!cells || !n_selected_cells) 1897 if (!cells || !n_selected_cells)
1647 return E_INVALIDARG; 1898 return E_INVALIDARG;
1648 1899
1649 // TODO(dmazzoni): Implement this. 1900 // TODO(dmazzoni): Implement this.
1650 *n_selected_cells = 0; 1901 *n_selected_cells = 0;
1651 return S_OK; 1902 return S_OK;
1652 } 1903 }
1653 1904
1654 STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long** columns, 1905 STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long** columns,
1655 long* n_columns) { 1906 long* n_columns) {
1907 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLE2_GET_SELECTED_COLUMNS);
1656 if (!instance_active()) 1908 if (!instance_active())
1657 return E_FAIL; 1909 return E_FAIL;
1658 1910
1659 if (!columns || !n_columns) 1911 if (!columns || !n_columns)
1660 return E_INVALIDARG; 1912 return E_INVALIDARG;
1661 1913
1662 // TODO(dmazzoni): Implement this. 1914 // TODO(dmazzoni): Implement this.
1663 *n_columns = 0; 1915 *n_columns = 0;
1664 return S_OK; 1916 return S_OK;
1665 } 1917 }
1666 1918
1667 STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long** rows, 1919 STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long** rows,
1668 long* n_rows) { 1920 long* n_rows) {
1921 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLE2_GET_SELECTED_ROWS);
1669 if (!instance_active()) 1922 if (!instance_active())
1670 return E_FAIL; 1923 return E_FAIL;
1671 1924
1672 if (!rows || !n_rows) 1925 if (!rows || !n_rows)
1673 return E_INVALIDARG; 1926 return E_INVALIDARG;
1674 1927
1675 // TODO(dmazzoni): Implement this. 1928 // TODO(dmazzoni): Implement this.
1676 *n_rows = 0; 1929 *n_rows = 0;
1677 return S_OK; 1930 return S_OK;
1678 } 1931 }
1679 1932
1680 1933
1681 // 1934 //
1682 // IAccessibleTableCell methods. 1935 // IAccessibleTableCell methods.
1683 // 1936 //
1684 1937
1685 STDMETHODIMP BrowserAccessibilityWin::get_columnExtent( 1938 STDMETHODIMP BrowserAccessibilityWin::get_columnExtent(
1686 long* n_columns_spanned) { 1939 long* n_columns_spanned) {
1940 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_EXTENT);
1687 if (!instance_active()) 1941 if (!instance_active())
1688 return E_FAIL; 1942 return E_FAIL;
1689 1943
1690 if (!n_columns_spanned) 1944 if (!n_columns_spanned)
1691 return E_INVALIDARG; 1945 return E_INVALIDARG;
1692 1946
1693 int colspan; 1947 int colspan;
1694 if (GetIntAttribute( 1948 if (GetIntAttribute(
1695 ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && 1949 ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) &&
1696 colspan >= 1) { 1950 colspan >= 1) {
1697 *n_columns_spanned = colspan; 1951 *n_columns_spanned = colspan;
1698 return S_OK; 1952 return S_OK;
1699 } 1953 }
1700 1954
1701 return S_FALSE; 1955 return S_FALSE;
1702 } 1956 }
1703 1957
1704 STDMETHODIMP BrowserAccessibilityWin::get_columnHeaderCells( 1958 STDMETHODIMP BrowserAccessibilityWin::get_columnHeaderCells(
1705 IUnknown*** cell_accessibles, 1959 IUnknown*** cell_accessibles,
1706 long* n_column_header_cells) { 1960 long* n_column_header_cells) {
1961 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_HEADER_CELLS);
1707 if (!instance_active()) 1962 if (!instance_active())
1708 return E_FAIL; 1963 return E_FAIL;
1709 1964
1710 if (!cell_accessibles || !n_column_header_cells) 1965 if (!cell_accessibles || !n_column_header_cells)
1711 return E_INVALIDARG; 1966 return E_INVALIDARG;
1712 1967
1713 *n_column_header_cells = 0; 1968 *n_column_header_cells = 0;
1714 1969
1715 int column; 1970 int column;
1716 if (!GetIntAttribute( 1971 if (!GetIntAttribute(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 (*cell_accessibles)[index] = static_cast<IAccessible*>( 2012 (*cell_accessibles)[index] = static_cast<IAccessible*>(
1758 ToBrowserAccessibilityWin(cell)->NewReference()); 2013 ToBrowserAccessibilityWin(cell)->NewReference());
1759 ++index; 2014 ++index;
1760 } 2015 }
1761 } 2016 }
1762 2017
1763 return S_OK; 2018 return S_OK;
1764 } 2019 }
1765 2020
1766 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long* column_index) { 2021 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long* column_index) {
2022 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_COLUMN_INDEX);
1767 if (!instance_active()) 2023 if (!instance_active())
1768 return E_FAIL; 2024 return E_FAIL;
1769 2025
1770 if (!column_index) 2026 if (!column_index)
1771 return E_INVALIDARG; 2027 return E_INVALIDARG;
1772 2028
1773 int column; 2029 int column;
1774 if (GetIntAttribute( 2030 if (GetIntAttribute(
1775 ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &column)) { 2031 ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &column)) {
1776 *column_index = column; 2032 *column_index = column;
1777 return S_OK; 2033 return S_OK;
1778 } 2034 }
1779 2035
1780 return S_FALSE; 2036 return S_FALSE;
1781 } 2037 }
1782 2038
1783 STDMETHODIMP BrowserAccessibilityWin::get_rowExtent(long* n_rows_spanned) { 2039 STDMETHODIMP BrowserAccessibilityWin::get_rowExtent(long* n_rows_spanned) {
2040 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_EXTENT);
1784 if (!instance_active()) 2041 if (!instance_active())
1785 return E_FAIL; 2042 return E_FAIL;
1786 2043
1787 if (!n_rows_spanned) 2044 if (!n_rows_spanned)
1788 return E_INVALIDARG; 2045 return E_INVALIDARG;
1789 2046
1790 int rowspan; 2047 int rowspan;
1791 if (GetIntAttribute( 2048 if (GetIntAttribute(
1792 ui::AX_ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && 2049 ui::AX_ATTR_TABLE_CELL_ROW_SPAN, &rowspan) &&
1793 rowspan >= 1) { 2050 rowspan >= 1) {
1794 *n_rows_spanned = rowspan; 2051 *n_rows_spanned = rowspan;
1795 return S_OK; 2052 return S_OK;
1796 } 2053 }
1797 2054
1798 return S_FALSE; 2055 return S_FALSE;
1799 } 2056 }
1800 2057
1801 STDMETHODIMP BrowserAccessibilityWin::get_rowHeaderCells( 2058 STDMETHODIMP BrowserAccessibilityWin::get_rowHeaderCells(
1802 IUnknown*** cell_accessibles, 2059 IUnknown*** cell_accessibles,
1803 long* n_row_header_cells) { 2060 long* n_row_header_cells) {
2061 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_HEADER_CELLS);
1804 if (!instance_active()) 2062 if (!instance_active())
1805 return E_FAIL; 2063 return E_FAIL;
1806 2064
1807 if (!cell_accessibles || !n_row_header_cells) 2065 if (!cell_accessibles || !n_row_header_cells)
1808 return E_INVALIDARG; 2066 return E_INVALIDARG;
1809 2067
1810 *n_row_header_cells = 0; 2068 *n_row_header_cells = 0;
1811 2069
1812 int row; 2070 int row;
1813 if (!GetIntAttribute( 2071 if (!GetIntAttribute(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 (*cell_accessibles)[index] = static_cast<IAccessible*>( 2112 (*cell_accessibles)[index] = static_cast<IAccessible*>(
1855 ToBrowserAccessibilityWin(cell)->NewReference()); 2113 ToBrowserAccessibilityWin(cell)->NewReference());
1856 ++index; 2114 ++index;
1857 } 2115 }
1858 } 2116 }
1859 2117
1860 return S_OK; 2118 return S_OK;
1861 } 2119 }
1862 2120
1863 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long* row_index) { 2121 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long* row_index) {
2122 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_ROW_INDEX);
1864 if (!instance_active()) 2123 if (!instance_active())
1865 return E_FAIL; 2124 return E_FAIL;
1866 2125
1867 if (!row_index) 2126 if (!row_index)
1868 return E_INVALIDARG; 2127 return E_INVALIDARG;
1869 2128
1870 int row; 2129 int row;
1871 if (GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row)) { 2130 if (GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row)) {
1872 *row_index = row; 2131 *row_index = row;
1873 return S_OK; 2132 return S_OK;
1874 } 2133 }
1875 return S_FALSE; 2134 return S_FALSE;
1876 } 2135 }
1877 2136
1878 STDMETHODIMP BrowserAccessibilityWin::get_isSelected(boolean* is_selected) { 2137 STDMETHODIMP BrowserAccessibilityWin::get_isSelected(boolean* is_selected) {
2138 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_IS_SELECTED);
1879 if (!instance_active()) 2139 if (!instance_active())
1880 return E_FAIL; 2140 return E_FAIL;
1881 2141
1882 if (!is_selected) 2142 if (!is_selected)
1883 return E_INVALIDARG; 2143 return E_INVALIDARG;
1884 2144
1885 *is_selected = false; 2145 *is_selected = false;
1886 return S_OK; 2146 return S_OK;
1887 } 2147 }
1888 2148
1889 STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtents( 2149 STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtents(
1890 long* row_index, 2150 long* row_index,
1891 long* column_index, 2151 long* column_index,
1892 long* row_extents, 2152 long* row_extents,
1893 long* column_extents, 2153 long* column_extents,
1894 boolean* is_selected) { 2154 boolean* is_selected) {
2155 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_COLUMN_EXTENTS);
1895 if (!instance_active()) 2156 if (!instance_active())
1896 return E_FAIL; 2157 return E_FAIL;
1897 2158
1898 if (!row_index || 2159 if (!row_index ||
1899 !column_index || 2160 !column_index ||
1900 !row_extents || 2161 !row_extents ||
1901 !column_extents || 2162 !column_extents ||
1902 !is_selected) { 2163 !is_selected) {
1903 return E_INVALIDARG; 2164 return E_INVALIDARG;
1904 } 2165 }
(...skipping 14 matching lines...) Expand all
1919 *row_extents = rowspan; 2180 *row_extents = rowspan;
1920 *column_extents = colspan; 2181 *column_extents = colspan;
1921 *is_selected = false; 2182 *is_selected = false;
1922 return S_OK; 2183 return S_OK;
1923 } 2184 }
1924 2185
1925 return S_FALSE; 2186 return S_FALSE;
1926 } 2187 }
1927 2188
1928 STDMETHODIMP BrowserAccessibilityWin::get_table(IUnknown** table) { 2189 STDMETHODIMP BrowserAccessibilityWin::get_table(IUnknown** table) {
2190 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TABLE);
1929 if (!instance_active()) 2191 if (!instance_active())
1930 return E_FAIL; 2192 return E_FAIL;
1931 2193
1932 if (!table) 2194 if (!table)
1933 return E_INVALIDARG; 2195 return E_INVALIDARG;
1934 2196
1935 2197
1936 int row; 2198 int row;
1937 int column; 2199 int column;
1938 GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row); 2200 GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row);
(...skipping 11 matching lines...) Expand all
1950 ToBrowserAccessibilityWin(find_table)->NewReference()); 2212 ToBrowserAccessibilityWin(find_table)->NewReference());
1951 2213
1952 return S_OK; 2214 return S_OK;
1953 } 2215 }
1954 2216
1955 // 2217 //
1956 // IAccessibleText methods. 2218 // IAccessibleText methods.
1957 // 2219 //
1958 2220
1959 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { 2221 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) {
2222 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_CHARACTERS);
1960 if (!instance_active()) 2223 if (!instance_active())
1961 return E_FAIL; 2224 return E_FAIL;
1962 2225
1963 if (!n_characters) 2226 if (!n_characters)
1964 return E_INVALIDARG; 2227 return E_INVALIDARG;
1965 2228
1966 *n_characters = static_cast<LONG>(GetText().size()); 2229 *n_characters = static_cast<LONG>(GetText().size());
1967 return S_OK; 2230 return S_OK;
1968 } 2231 }
1969 2232
1970 STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) { 2233 STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) {
2234 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CARET_OFFSET);
1971 if (!instance_active()) 2235 if (!instance_active())
1972 return E_FAIL; 2236 return E_FAIL;
1973 2237
1974 if (!offset) 2238 if (!offset)
1975 return E_INVALIDARG; 2239 return E_INVALIDARG;
1976 2240
1977 if (!HasCaret()) 2241 if (!HasCaret())
1978 return S_FALSE; 2242 return S_FALSE;
1979 2243
1980 int selection_start, selection_end; 2244 int selection_start, selection_end;
1981 GetSelectionOffsets(&selection_start, &selection_end); 2245 GetSelectionOffsets(&selection_start, &selection_end);
1982 // The caret is always at the end of the selection. 2246 // The caret is always at the end of the selection.
1983 *offset = selection_end; 2247 *offset = selection_end;
1984 if (*offset < 0) 2248 if (*offset < 0)
1985 return S_FALSE; 2249 return S_FALSE;
1986 2250
1987 return S_OK; 2251 return S_OK;
1988 } 2252 }
1989 2253
1990 STDMETHODIMP BrowserAccessibilityWin::get_characterExtents( 2254 STDMETHODIMP BrowserAccessibilityWin::get_characterExtents(
1991 LONG offset, 2255 LONG offset,
1992 IA2CoordinateType coordinate_type, 2256 IA2CoordinateType coordinate_type,
1993 LONG* out_x, 2257 LONG* out_x,
1994 LONG* out_y, 2258 LONG* out_y,
1995 LONG* out_width, 2259 LONG* out_width,
1996 LONG* out_height) { 2260 LONG* out_height) {
2261 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHARACTER_EXTENTS);
1997 if (!instance_active()) 2262 if (!instance_active())
1998 return E_FAIL; 2263 return E_FAIL;
1999 2264
2000 if (!out_x || !out_y || !out_width || !out_height) 2265 if (!out_x || !out_y || !out_width || !out_height)
2001 return E_INVALIDARG; 2266 return E_INVALIDARG;
2002 2267
2003 const base::string16& text_str = GetText(); 2268 const base::string16& text_str = GetText();
2004 HandleSpecialTextOffset(text_str, &offset); 2269 HandleSpecialTextOffset(text_str, &offset);
2005 2270
2006 if (offset < 0 || offset > static_cast<LONG>(text_str.size())) 2271 if (offset < 0 || offset > static_cast<LONG>(text_str.size()))
(...skipping 12 matching lines...) Expand all
2019 2284
2020 *out_x = character_bounds.x(); 2285 *out_x = character_bounds.x();
2021 *out_y = character_bounds.y(); 2286 *out_y = character_bounds.y();
2022 *out_width = character_bounds.width(); 2287 *out_width = character_bounds.width();
2023 *out_height = character_bounds.height(); 2288 *out_height = character_bounds.height();
2024 2289
2025 return S_OK; 2290 return S_OK;
2026 } 2291 }
2027 2292
2028 STDMETHODIMP BrowserAccessibilityWin::get_nSelections(LONG* n_selections) { 2293 STDMETHODIMP BrowserAccessibilityWin::get_nSelections(LONG* n_selections) {
2294 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTIONS);
2029 if (!instance_active()) 2295 if (!instance_active())
2030 return E_FAIL; 2296 return E_FAIL;
2031 2297
2032 if (!n_selections) 2298 if (!n_selections)
2033 return E_INVALIDARG; 2299 return E_INVALIDARG;
2034 2300
2035 *n_selections = 0; 2301 *n_selections = 0;
2036 int selection_start, selection_end; 2302 int selection_start, selection_end;
2037 GetSelectionOffsets(&selection_start, &selection_end); 2303 GetSelectionOffsets(&selection_start, &selection_end);
2038 if (selection_start >= 0 && selection_end >= 0 && 2304 if (selection_start >= 0 && selection_end >= 0 &&
2039 selection_start != selection_end) { 2305 selection_start != selection_end) {
2040 *n_selections = 1; 2306 *n_selections = 1;
2041 } 2307 }
2042 2308
2043 return S_OK; 2309 return S_OK;
2044 } 2310 }
2045 2311
2046 STDMETHODIMP BrowserAccessibilityWin::get_selection(LONG selection_index, 2312 STDMETHODIMP BrowserAccessibilityWin::get_selection(LONG selection_index,
2047 LONG* start_offset, 2313 LONG* start_offset,
2048 LONG* end_offset) { 2314 LONG* end_offset) {
2315 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTION);
2049 if (!instance_active()) 2316 if (!instance_active())
2050 return E_FAIL; 2317 return E_FAIL;
2051 2318
2052 if (!start_offset || !end_offset || selection_index != 0) 2319 if (!start_offset || !end_offset || selection_index != 0)
2053 return E_INVALIDARG; 2320 return E_INVALIDARG;
2054 2321
2055 LONG n_selections = 0; 2322 LONG n_selections = 0;
2056 if (FAILED(get_nSelections(&n_selections)) || n_selections < 1) 2323 if (FAILED(get_nSelections(&n_selections)) || n_selections < 1)
2057 return E_INVALIDARG; 2324 return E_INVALIDARG;
2058 2325
(...skipping 12 matching lines...) Expand all
2071 *start_offset = selection_start; 2338 *start_offset = selection_start;
2072 *end_offset = selection_end; 2339 *end_offset = selection_end;
2073 } 2340 }
2074 2341
2075 return S_OK; 2342 return S_OK;
2076 } 2343 }
2077 2344
2078 STDMETHODIMP BrowserAccessibilityWin::get_text(LONG start_offset, 2345 STDMETHODIMP BrowserAccessibilityWin::get_text(LONG start_offset,
2079 LONG end_offset, 2346 LONG end_offset,
2080 BSTR* text) { 2347 BSTR* text) {
2348 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT);
2081 if (!instance_active()) 2349 if (!instance_active())
2082 return E_FAIL; 2350 return E_FAIL;
2083 2351
2084 if (!text) 2352 if (!text)
2085 return E_INVALIDARG; 2353 return E_INVALIDARG;
2086 2354
2087 const base::string16& text_str = GetText(); 2355 const base::string16& text_str = GetText();
2088 HandleSpecialTextOffset(text_str, &start_offset); 2356 HandleSpecialTextOffset(text_str, &start_offset);
2089 HandleSpecialTextOffset(text_str, &end_offset); 2357 HandleSpecialTextOffset(text_str, &end_offset);
2090 2358
(...skipping 22 matching lines...) Expand all
2113 DCHECK(*text); 2381 DCHECK(*text);
2114 return S_OK; 2382 return S_OK;
2115 } 2383 }
2116 2384
2117 STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset( 2385 STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset(
2118 LONG offset, 2386 LONG offset,
2119 IA2TextBoundaryType boundary_type, 2387 IA2TextBoundaryType boundary_type,
2120 LONG* start_offset, 2388 LONG* start_offset,
2121 LONG* end_offset, 2389 LONG* end_offset,
2122 BSTR* text) { 2390 BSTR* text) {
2391 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_AT_OFFSET);
2123 if (!instance_active()) 2392 if (!instance_active())
2124 return E_FAIL; 2393 return E_FAIL;
2125 2394
2126 if (!start_offset || !end_offset || !text) 2395 if (!start_offset || !end_offset || !text)
2127 return E_INVALIDARG; 2396 return E_INVALIDARG;
2128 2397
2129 const base::string16& text_str = GetText(); 2398 const base::string16& text_str = GetText();
2130 HandleSpecialTextOffset(text_str, &offset); 2399 HandleSpecialTextOffset(text_str, &offset);
2131 if (offset < 0) 2400 if (offset < 0)
2132 return E_INVALIDARG; 2401 return E_INVALIDARG;
(...skipping 30 matching lines...) Expand all
2163 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); 2432 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION);
2164 return get_text(*start_offset, *end_offset, text); 2433 return get_text(*start_offset, *end_offset, text);
2165 } 2434 }
2166 2435
2167 STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset( 2436 STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset(
2168 LONG offset, 2437 LONG offset,
2169 IA2TextBoundaryType boundary_type, 2438 IA2TextBoundaryType boundary_type,
2170 LONG* start_offset, 2439 LONG* start_offset,
2171 LONG* end_offset, 2440 LONG* end_offset,
2172 BSTR* text) { 2441 BSTR* text) {
2442 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_BEFORE_OFFSET);
2173 if (!instance_active()) 2443 if (!instance_active())
2174 return E_FAIL; 2444 return E_FAIL;
2175 2445
2176 if (!start_offset || !end_offset || !text) 2446 if (!start_offset || !end_offset || !text)
2177 return E_INVALIDARG; 2447 return E_INVALIDARG;
2178 2448
2179 // The IAccessible2 spec says we don't have to implement the "sentence" 2449 // The IAccessible2 spec says we don't have to implement the "sentence"
2180 // boundary type, we can just let the screenreader handle it. 2450 // boundary type, we can just let the screenreader handle it.
2181 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { 2451 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) {
2182 *start_offset = 0; 2452 *start_offset = 0;
2183 *end_offset = 0; 2453 *end_offset = 0;
2184 *text = NULL; 2454 *text = NULL;
2185 return S_FALSE; 2455 return S_FALSE;
2186 } 2456 }
2187 2457
2188 const base::string16& text_str = GetText(); 2458 const base::string16& text_str = GetText();
2189 2459
2190 *start_offset = FindBoundary( 2460 *start_offset = FindBoundary(
2191 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); 2461 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION);
2192 *end_offset = offset; 2462 *end_offset = offset;
2193 return get_text(*start_offset, *end_offset, text); 2463 return get_text(*start_offset, *end_offset, text);
2194 } 2464 }
2195 2465
2196 STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( 2466 STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset(
2197 LONG offset, 2467 LONG offset,
2198 IA2TextBoundaryType boundary_type, 2468 IA2TextBoundaryType boundary_type,
2199 LONG* start_offset, 2469 LONG* start_offset,
2200 LONG* end_offset, 2470 LONG* end_offset,
2201 BSTR* text) { 2471 BSTR* text) {
2472 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_AFTER_OFFSET);
2202 if (!instance_active()) 2473 if (!instance_active())
2203 return E_FAIL; 2474 return E_FAIL;
2204 2475
2205 if (!start_offset || !end_offset || !text) 2476 if (!start_offset || !end_offset || !text)
2206 return E_INVALIDARG; 2477 return E_INVALIDARG;
2207 2478
2208 // The IAccessible2 spec says we don't have to implement the "sentence" 2479 // The IAccessible2 spec says we don't have to implement the "sentence"
2209 // boundary type, we can just let the screenreader handle it. 2480 // boundary type, we can just let the screenreader handle it.
2210 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { 2481 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) {
2211 *start_offset = 0; 2482 *start_offset = 0;
2212 *end_offset = 0; 2483 *end_offset = 0;
2213 *text = NULL; 2484 *text = NULL;
2214 return S_FALSE; 2485 return S_FALSE;
2215 } 2486 }
2216 2487
2217 const base::string16& text_str = GetText(); 2488 const base::string16& text_str = GetText();
2218 2489
2219 *start_offset = offset; 2490 *start_offset = offset;
2220 *end_offset = FindBoundary( 2491 *end_offset = FindBoundary(
2221 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); 2492 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION);
2222 return get_text(*start_offset, *end_offset, text); 2493 return get_text(*start_offset, *end_offset, text);
2223 } 2494 }
2224 2495
2225 STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { 2496 STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) {
2497 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NEW_TEXT);
2226 if (!instance_active()) 2498 if (!instance_active())
2227 return E_FAIL; 2499 return E_FAIL;
2228 2500
2229 if (!new_text) 2501 if (!new_text)
2230 return E_INVALIDARG; 2502 return E_INVALIDARG;
2231 2503
2232 if (!old_win_attributes_) 2504 if (!old_win_attributes_)
2233 return E_FAIL; 2505 return E_FAIL;
2234 2506
2235 int start, old_len, new_len; 2507 int start, old_len, new_len;
2236 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); 2508 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len);
2237 if (new_len == 0) 2509 if (new_len == 0)
2238 return E_FAIL; 2510 return E_FAIL;
2239 2511
2240 base::string16 substr = GetText().substr(start, new_len); 2512 base::string16 substr = GetText().substr(start, new_len);
2241 new_text->text = SysAllocString(substr.c_str()); 2513 new_text->text = SysAllocString(substr.c_str());
2242 new_text->start = static_cast<long>(start); 2514 new_text->start = static_cast<long>(start);
2243 new_text->end = static_cast<long>(start + new_len); 2515 new_text->end = static_cast<long>(start + new_len);
2244 return S_OK; 2516 return S_OK;
2245 } 2517 }
2246 2518
2247 STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) { 2519 STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) {
2520 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OLD_TEXT);
2248 if (!instance_active()) 2521 if (!instance_active())
2249 return E_FAIL; 2522 return E_FAIL;
2250 2523
2251 if (!old_text) 2524 if (!old_text)
2252 return E_INVALIDARG; 2525 return E_INVALIDARG;
2253 2526
2254 if (!old_win_attributes_) 2527 if (!old_win_attributes_)
2255 return E_FAIL; 2528 return E_FAIL;
2256 2529
2257 int start, old_len, new_len; 2530 int start, old_len, new_len;
2258 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); 2531 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len);
2259 if (old_len == 0) 2532 if (old_len == 0)
2260 return E_FAIL; 2533 return E_FAIL;
2261 2534
2262 base::string16 old_hypertext = old_win_attributes_->hypertext; 2535 base::string16 old_hypertext = old_win_attributes_->hypertext;
2263 base::string16 substr = old_hypertext.substr(start, old_len); 2536 base::string16 substr = old_hypertext.substr(start, old_len);
2264 old_text->text = SysAllocString(substr.c_str()); 2537 old_text->text = SysAllocString(substr.c_str());
2265 old_text->start = static_cast<long>(start); 2538 old_text->start = static_cast<long>(start);
2266 old_text->end = static_cast<long>(start + old_len); 2539 old_text->end = static_cast<long>(start + old_len);
2267 return S_OK; 2540 return S_OK;
2268 } 2541 }
2269 2542
2270 STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint( 2543 STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint(
2271 LONG x, 2544 LONG x,
2272 LONG y, 2545 LONG y,
2273 IA2CoordinateType coord_type, 2546 IA2CoordinateType coord_type,
2274 LONG* offset) { 2547 LONG* offset) {
2548 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OFFSET_AT_POINT);
2275 if (!instance_active()) 2549 if (!instance_active())
2276 return E_FAIL; 2550 return E_FAIL;
2277 2551
2278 if (!offset) 2552 if (!offset)
2279 return E_INVALIDARG; 2553 return E_INVALIDARG;
2280 2554
2281 // TODO(dmazzoni): implement this. We're returning S_OK for now so that 2555 // TODO(dmazzoni): implement this. We're returning S_OK for now so that
2282 // screen readers still return partially accurate results rather than 2556 // screen readers still return partially accurate results rather than
2283 // completely failing. 2557 // completely failing.
2284 *offset = 0; 2558 *offset = 0;
2285 return S_OK; 2559 return S_OK;
2286 } 2560 }
2287 2561
2288 STDMETHODIMP BrowserAccessibilityWin::scrollSubstringTo( 2562 STDMETHODIMP BrowserAccessibilityWin::scrollSubstringTo(
2289 LONG start_index, 2563 LONG start_index,
2290 LONG end_index, 2564 LONG end_index,
2291 IA2ScrollType scroll_type) { 2565 IA2ScrollType scroll_type) {
2566 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_SUBSTRING_TO);
2292 // TODO(dmazzoni): adjust this for the start and end index, too. 2567 // TODO(dmazzoni): adjust this for the start and end index, too.
2293 return scrollTo(scroll_type); 2568 return scrollTo(scroll_type);
2294 } 2569 }
2295 2570
2296 STDMETHODIMP BrowserAccessibilityWin::scrollSubstringToPoint( 2571 STDMETHODIMP BrowserAccessibilityWin::scrollSubstringToPoint(
2297 LONG start_index, 2572 LONG start_index,
2298 LONG end_index, 2573 LONG end_index,
2299 IA2CoordinateType coordinate_type, 2574 IA2CoordinateType coordinate_type,
2300 LONG x, 2575 LONG x,
2301 LONG y) { 2576 LONG y) {
2577 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_SUBSTRING_TO_POINT);
2302 // TODO(dmazzoni): adjust this for the start and end index, too. 2578 // TODO(dmazzoni): adjust this for the start and end index, too.
2303 return scrollToPoint(coordinate_type, x, y); 2579 return scrollToPoint(coordinate_type, x, y);
2304 } 2580 }
2305 2581
2306 STDMETHODIMP BrowserAccessibilityWin::addSelection(LONG start_offset, 2582 STDMETHODIMP BrowserAccessibilityWin::addSelection(LONG start_offset,
2307 LONG end_offset) { 2583 LONG end_offset) {
2584 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ADD_SELECTION);
2308 if (!instance_active()) 2585 if (!instance_active())
2309 return E_FAIL; 2586 return E_FAIL;
2310 2587
2311 const base::string16& text_str = GetText(); 2588 const base::string16& text_str = GetText();
2312 HandleSpecialTextOffset(text_str, &start_offset); 2589 HandleSpecialTextOffset(text_str, &start_offset);
2313 HandleSpecialTextOffset(text_str, &end_offset); 2590 HandleSpecialTextOffset(text_str, &end_offset);
2314 2591
2315 manager()->SetTextSelection(*this, start_offset, end_offset); 2592 manager()->SetTextSelection(*this, start_offset, end_offset);
2316 return S_OK; 2593 return S_OK;
2317 } 2594 }
2318 2595
2319 STDMETHODIMP BrowserAccessibilityWin::removeSelection(LONG selection_index) { 2596 STDMETHODIMP BrowserAccessibilityWin::removeSelection(LONG selection_index) {
2597 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_REMOVE_SELECTION);
2320 if (!instance_active()) 2598 if (!instance_active())
2321 return E_FAIL; 2599 return E_FAIL;
2322 2600
2323 if (selection_index != 0) 2601 if (selection_index != 0)
2324 return E_INVALIDARG; 2602 return E_INVALIDARG;
2325 2603
2326 manager()->SetTextSelection(*this, 0, 0); 2604 manager()->SetTextSelection(*this, 0, 0);
2327 return S_OK; 2605 return S_OK;
2328 } 2606 }
2329 2607
2330 STDMETHODIMP BrowserAccessibilityWin::setCaretOffset(LONG offset) { 2608 STDMETHODIMP BrowserAccessibilityWin::setCaretOffset(LONG offset) {
2609 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_CARET_OFFSET);
2331 if (!instance_active()) 2610 if (!instance_active())
2332 return E_FAIL; 2611 return E_FAIL;
2333 2612
2334 const base::string16& text_str = GetText(); 2613 const base::string16& text_str = GetText();
2335 HandleSpecialTextOffset(text_str, &offset); 2614 HandleSpecialTextOffset(text_str, &offset);
2336 manager()->SetTextSelection(*this, offset, offset); 2615 manager()->SetTextSelection(*this, offset, offset);
2337 return S_OK; 2616 return S_OK;
2338 } 2617 }
2339 2618
2340 STDMETHODIMP BrowserAccessibilityWin::setSelection(LONG selection_index, 2619 STDMETHODIMP BrowserAccessibilityWin::setSelection(LONG selection_index,
2341 LONG start_offset, 2620 LONG start_offset,
2342 LONG end_offset) { 2621 LONG end_offset) {
2622 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_SELECTION);
2343 if (!instance_active()) 2623 if (!instance_active())
2344 return E_FAIL; 2624 return E_FAIL;
2345 2625
2346 if (selection_index != 0) 2626 if (selection_index != 0)
2347 return E_INVALIDARG; 2627 return E_INVALIDARG;
2348 2628
2349 const base::string16& text_str = GetText(); 2629 const base::string16& text_str = GetText();
2350 HandleSpecialTextOffset(text_str, &start_offset); 2630 HandleSpecialTextOffset(text_str, &start_offset);
2351 HandleSpecialTextOffset(text_str, &end_offset); 2631 HandleSpecialTextOffset(text_str, &end_offset);
2352 2632
2353 manager()->SetTextSelection(*this, start_offset, end_offset); 2633 manager()->SetTextSelection(*this, start_offset, end_offset);
2354 return S_OK; 2634 return S_OK;
2355 } 2635 }
2356 2636
2357 STDMETHODIMP BrowserAccessibilityWin::get_attributes(LONG offset, 2637 STDMETHODIMP BrowserAccessibilityWin::get_attributes(LONG offset,
2358 LONG* start_offset, 2638 LONG* start_offset,
2359 LONG* end_offset, 2639 LONG* end_offset,
2360 BSTR* text_attributes) { 2640 BSTR* text_attributes) {
2641 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IATEXT_GET_ATTRIBUTES);
2361 if (!start_offset || !end_offset || !text_attributes) 2642 if (!start_offset || !end_offset || !text_attributes)
2362 return E_INVALIDARG; 2643 return E_INVALIDARG;
2363 2644
2364 *start_offset = *end_offset = 0; 2645 *start_offset = *end_offset = 0;
2365 *text_attributes = nullptr; 2646 *text_attributes = nullptr;
2366 if (!instance_active()) 2647 if (!instance_active())
2367 return E_FAIL; 2648 return E_FAIL;
2368 2649
2369 const base::string16& text = GetText(); 2650 const base::string16& text = GetText();
2370 HandleSpecialTextOffset(text, &offset); 2651 HandleSpecialTextOffset(text, &offset);
(...skipping 17 matching lines...) Expand all
2388 *text_attributes = SysAllocString(attributes_str.c_str()); 2669 *text_attributes = SysAllocString(attributes_str.c_str());
2389 DCHECK(*text_attributes); 2670 DCHECK(*text_attributes);
2390 return S_OK; 2671 return S_OK;
2391 } 2672 }
2392 2673
2393 // 2674 //
2394 // IAccessibleHypertext methods. 2675 // IAccessibleHypertext methods.
2395 // 2676 //
2396 2677
2397 STDMETHODIMP BrowserAccessibilityWin::get_nHyperlinks(long* hyperlink_count) { 2678 STDMETHODIMP BrowserAccessibilityWin::get_nHyperlinks(long* hyperlink_count) {
2679 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_HYPERLINKS);
2398 if (!instance_active()) 2680 if (!instance_active())
2399 return E_FAIL; 2681 return E_FAIL;
2400 2682
2401 if (!hyperlink_count) 2683 if (!hyperlink_count)
2402 return E_INVALIDARG; 2684 return E_INVALIDARG;
2403 2685
2404 *hyperlink_count = hyperlink_offset_to_index().size(); 2686 *hyperlink_count = hyperlink_offset_to_index().size();
2405 return S_OK; 2687 return S_OK;
2406 } 2688 }
2407 2689
2408 STDMETHODIMP BrowserAccessibilityWin::get_hyperlink( 2690 STDMETHODIMP BrowserAccessibilityWin::get_hyperlink(
2409 long index, 2691 long index,
2410 IAccessibleHyperlink** hyperlink) { 2692 IAccessibleHyperlink** hyperlink) {
2693 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HYPERLINK);
2411 if (!instance_active()) 2694 if (!instance_active())
2412 return E_FAIL; 2695 return E_FAIL;
2413 2696
2414 if (!hyperlink || 2697 if (!hyperlink ||
2415 index < 0 || 2698 index < 0 ||
2416 index >= static_cast<long>(hyperlinks().size())) { 2699 index >= static_cast<long>(hyperlinks().size())) {
2417 return E_INVALIDARG; 2700 return E_INVALIDARG;
2418 } 2701 }
2419 2702
2420 int32_t id = hyperlinks()[index]; 2703 int32_t id = hyperlinks()[index];
2421 BrowserAccessibilityWin* link = 2704 BrowserAccessibilityWin* link =
2422 ToBrowserAccessibilityWin(GetFromUniqueID(id)); 2705 ToBrowserAccessibilityWin(GetFromUniqueID(id));
2423 if (!link) 2706 if (!link)
2424 return E_FAIL; 2707 return E_FAIL;
2425 2708
2426 *hyperlink = static_cast<IAccessibleHyperlink*>(link->NewReference()); 2709 *hyperlink = static_cast<IAccessibleHyperlink*>(link->NewReference());
2427 return S_OK; 2710 return S_OK;
2428 } 2711 }
2429 2712
2430 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( 2713 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex(
2431 long char_index, 2714 long char_index,
2432 long* hyperlink_index) { 2715 long* hyperlink_index) {
2716 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HYPERLINK_INDEX);
2433 if (!instance_active()) 2717 if (!instance_active())
2434 return E_FAIL; 2718 return E_FAIL;
2435 2719
2436 if (!hyperlink_index) 2720 if (!hyperlink_index)
2437 return E_INVALIDARG; 2721 return E_INVALIDARG;
2438 2722
2439 if (char_index < 0 || char_index >= static_cast<long>(GetText().size())) { 2723 if (char_index < 0 || char_index >= static_cast<long>(GetText().size())) {
2440 return E_INVALIDARG; 2724 return E_INVALIDARG;
2441 } 2725 }
2442 2726
2443 std::map<int32_t, int32_t>::iterator it = 2727 std::map<int32_t, int32_t>::iterator it =
2444 hyperlink_offset_to_index().find(char_index); 2728 hyperlink_offset_to_index().find(char_index);
2445 if (it == hyperlink_offset_to_index().end()) { 2729 if (it == hyperlink_offset_to_index().end()) {
2446 *hyperlink_index = -1; 2730 *hyperlink_index = -1;
2447 return S_FALSE; 2731 return S_FALSE;
2448 } 2732 }
2449 2733
2450 *hyperlink_index = it->second; 2734 *hyperlink_index = it->second;
2451 return S_OK; 2735 return S_OK;
2452 } 2736 }
2453 2737
2454 // 2738 //
2455 // IAccessibleHyperlink methods. 2739 // IAccessibleHyperlink methods.
2456 // 2740 //
2457 2741
2458 // Currently, only text links are supported. 2742 // Currently, only text links are supported.
2459 STDMETHODIMP BrowserAccessibilityWin::get_anchor(long index, VARIANT* anchor) { 2743 STDMETHODIMP BrowserAccessibilityWin::get_anchor(long index, VARIANT* anchor) {
2744 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ANCHOR);
2460 if (!instance_active() || !IsHyperlink()) 2745 if (!instance_active() || !IsHyperlink())
2461 return E_FAIL; 2746 return E_FAIL;
2462 2747
2463 // IA2 text links can have only one anchor, that is the text inside them. 2748 // IA2 text links can have only one anchor, that is the text inside them.
2464 if (index != 0 || !anchor) 2749 if (index != 0 || !anchor)
2465 return E_INVALIDARG; 2750 return E_INVALIDARG;
2466 2751
2467 BSTR ia2_hypertext = SysAllocString(GetText().c_str()); 2752 BSTR ia2_hypertext = SysAllocString(GetText().c_str());
2468 DCHECK(ia2_hypertext); 2753 DCHECK(ia2_hypertext);
2469 anchor->vt = VT_BSTR; 2754 anchor->vt = VT_BSTR;
2470 anchor->bstrVal = ia2_hypertext; 2755 anchor->bstrVal = ia2_hypertext;
2471 2756
2472 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been 2757 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been
2473 // an oversight. 2758 // an oversight.
2474 if (!SysStringLen(ia2_hypertext)) 2759 if (!SysStringLen(ia2_hypertext))
2475 return S_FALSE; 2760 return S_FALSE;
2476 2761
2477 return S_OK; 2762 return S_OK;
2478 } 2763 }
2479 2764
2480 // Currently, only text links are supported. 2765 // Currently, only text links are supported.
2481 STDMETHODIMP BrowserAccessibilityWin::get_anchorTarget(long index, 2766 STDMETHODIMP BrowserAccessibilityWin::get_anchorTarget(long index,
2482 VARIANT* anchor_target) { 2767 VARIANT* anchor_target) {
2768 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ANCHOR_TARGET);
2483 if (!instance_active() || !IsHyperlink()) 2769 if (!instance_active() || !IsHyperlink())
2484 return E_FAIL; 2770 return E_FAIL;
2485 2771
2486 // IA2 text links can have at most one target, that is when they represent an 2772 // IA2 text links can have at most one target, that is when they represent an
2487 // HTML hyperlink, i.e. an <a> element with a "href" attribute. 2773 // HTML hyperlink, i.e. an <a> element with a "href" attribute.
2488 if (index != 0 || !anchor_target) 2774 if (index != 0 || !anchor_target)
2489 return E_INVALIDARG; 2775 return E_INVALIDARG;
2490 2776
2491 BSTR target; 2777 BSTR target;
2492 if (!(ia_state() & STATE_SYSTEM_LINKED) || 2778 if (!(ia_state() & STATE_SYSTEM_LINKED) ||
2493 FAILED(GetStringAttributeAsBstr(ui::AX_ATTR_URL, &target))) { 2779 FAILED(GetStringAttributeAsBstr(ui::AX_ATTR_URL, &target))) {
2494 target = SysAllocString(L""); 2780 target = SysAllocString(L"");
2495 } 2781 }
2496 DCHECK(target); 2782 DCHECK(target);
2497 anchor_target->vt = VT_BSTR; 2783 anchor_target->vt = VT_BSTR;
2498 anchor_target->bstrVal = target; 2784 anchor_target->bstrVal = target;
2499 2785
2500 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been 2786 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been
2501 // an oversight. 2787 // an oversight.
2502 if (!SysStringLen(target)) 2788 if (!SysStringLen(target))
2503 return S_FALSE; 2789 return S_FALSE;
2504 2790
2505 return S_OK; 2791 return S_OK;
2506 } 2792 }
2507 2793
2508 STDMETHODIMP BrowserAccessibilityWin::get_startIndex(long* index) { 2794 STDMETHODIMP BrowserAccessibilityWin::get_startIndex(long* index) {
2795 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_START_INDEX);
2509 if (!instance_active() || !IsHyperlink()) 2796 if (!instance_active() || !IsHyperlink())
2510 return E_FAIL; 2797 return E_FAIL;
2511 2798
2512 if (!index) 2799 if (!index)
2513 return E_INVALIDARG; 2800 return E_INVALIDARG;
2514 2801
2515 int32_t hypertext_offset = 0; 2802 int32_t hypertext_offset = 0;
2516 auto* parent = GetParent(); 2803 auto* parent = GetParent();
2517 if (parent) { 2804 if (parent) {
2518 hypertext_offset = 2805 hypertext_offset =
2519 ToBrowserAccessibilityWin(parent)->GetHypertextOffsetFromChild(*this); 2806 ToBrowserAccessibilityWin(parent)->GetHypertextOffsetFromChild(*this);
2520 } 2807 }
2521 *index = static_cast<LONG>(hypertext_offset); 2808 *index = static_cast<LONG>(hypertext_offset);
2522 return S_OK; 2809 return S_OK;
2523 } 2810 }
2524 2811
2525 STDMETHODIMP BrowserAccessibilityWin::get_endIndex(long* index) { 2812 STDMETHODIMP BrowserAccessibilityWin::get_endIndex(long* index) {
2813 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_END_INDEX);
2526 LONG start_index; 2814 LONG start_index;
2527 HRESULT hr = get_startIndex(&start_index); 2815 HRESULT hr = get_startIndex(&start_index);
2528 if (hr == S_OK) 2816 if (hr == S_OK)
2529 *index = start_index + 1; 2817 *index = start_index + 1;
2530 return hr; 2818 return hr;
2531 } 2819 }
2532 2820
2533 // This method is deprecated in the IA2 Spec. 2821 // This method is deprecated in the IA2 Spec.
2534 STDMETHODIMP BrowserAccessibilityWin::get_valid(boolean* valid) { 2822 STDMETHODIMP BrowserAccessibilityWin::get_valid(boolean* valid) {
2823 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_VALID);
2535 return E_NOTIMPL; 2824 return E_NOTIMPL;
2536 } 2825 }
2537 2826
2538 // 2827 //
2539 // IAccessibleAction partly implemented. 2828 // IAccessibleAction partly implemented.
2540 // 2829 //
2541 2830
2542 STDMETHODIMP BrowserAccessibilityWin::nActions(long* n_actions) { 2831 STDMETHODIMP BrowserAccessibilityWin::nActions(long* n_actions) {
2832 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_N_ACTIONS);
2543 if (!instance_active()) 2833 if (!instance_active())
2544 return E_FAIL; 2834 return E_FAIL;
2545 2835
2546 if (!n_actions) 2836 if (!n_actions)
2547 return E_INVALIDARG; 2837 return E_INVALIDARG;
2548 2838
2549 // |IsHyperlink| is required for |IAccessibleHyperlink::anchor/anchorTarget| 2839 // |IsHyperlink| is required for |IAccessibleHyperlink::anchor/anchorTarget|
2550 // to work properly because the |IAccessibleHyperlink| interface inherits from 2840 // to work properly because the |IAccessibleHyperlink| interface inherits from
2551 // |IAccessibleAction|. 2841 // |IAccessibleAction|.
2552 if (IsHyperlink() || HasStringAttribute(ui::AX_ATTR_ACTION)) { 2842 if (IsHyperlink() || HasStringAttribute(ui::AX_ATTR_ACTION)) {
2553 *n_actions = 1; 2843 *n_actions = 1;
2554 } else { 2844 } else {
2555 *n_actions = 0; 2845 *n_actions = 0;
2556 } 2846 }
2557 2847
2558 return S_OK; 2848 return S_OK;
2559 } 2849 }
2560 2850
2561 STDMETHODIMP BrowserAccessibilityWin::doAction(long action_index) { 2851 STDMETHODIMP BrowserAccessibilityWin::doAction(long action_index) {
2852 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_DO_ACTION);
2562 if (!instance_active()) 2853 if (!instance_active())
2563 return E_FAIL; 2854 return E_FAIL;
2564 2855
2565 if (!HasStringAttribute(ui::AX_ATTR_ACTION) || action_index != 0) 2856 if (!HasStringAttribute(ui::AX_ATTR_ACTION) || action_index != 0)
2566 return E_INVALIDARG; 2857 return E_INVALIDARG;
2567 2858
2568 manager()->DoDefaultAction(*this); 2859 manager()->DoDefaultAction(*this);
2569 return S_OK; 2860 return S_OK;
2570 } 2861 }
2571 2862
2572 STDMETHODIMP 2863 STDMETHODIMP
2573 BrowserAccessibilityWin::get_description(long action_index, BSTR* description) { 2864 BrowserAccessibilityWin::get_description(long action_index, BSTR* description) {
2865 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IAACTION_GET_DESCRIPTION);
2574 return E_NOTIMPL; 2866 return E_NOTIMPL;
2575 } 2867 }
2868
2576 STDMETHODIMP BrowserAccessibilityWin::get_keyBinding(long action_index, 2869 STDMETHODIMP BrowserAccessibilityWin::get_keyBinding(long action_index,
2577 long n_max_bindings, 2870 long n_max_bindings,
2578 BSTR** key_bindings, 2871 BSTR** key_bindings,
2579 long* n_bindings) { 2872 long* n_bindings) {
2873 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_KEY_BINDING);
2580 return E_NOTIMPL; 2874 return E_NOTIMPL;
2581 } 2875 }
2582 2876
2583 STDMETHODIMP BrowserAccessibilityWin::get_name(long action_index, BSTR* name) { 2877 STDMETHODIMP BrowserAccessibilityWin::get_name(long action_index, BSTR* name) {
2878 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAME);
2584 if (!instance_active()) 2879 if (!instance_active())
2585 return E_FAIL; 2880 return E_FAIL;
2586 2881
2587 if (!name) 2882 if (!name)
2588 return E_INVALIDARG; 2883 return E_INVALIDARG;
2589 2884
2590 base::string16 action_verb; 2885 base::string16 action_verb;
2591 if (!GetString16Attribute(ui::AX_ATTR_ACTION, &action_verb) || 2886 if (!GetString16Attribute(ui::AX_ATTR_ACTION, &action_verb) ||
2592 action_index != 0) { 2887 action_index != 0) {
2593 *name = nullptr; 2888 *name = nullptr;
2594 return E_INVALIDARG; 2889 return E_INVALIDARG;
2595 } 2890 }
2596 2891
2597 *name = SysAllocString(action_verb.c_str()); 2892 *name = SysAllocString(action_verb.c_str());
2598 DCHECK(name); 2893 DCHECK(name);
2599 return S_OK; 2894 return S_OK;
2600 } 2895 }
2601 2896
2602 STDMETHODIMP 2897 STDMETHODIMP
2603 BrowserAccessibilityWin::get_localizedName(long action_index, 2898 BrowserAccessibilityWin::get_localizedName(long action_index,
2604 BSTR* localized_name) { 2899 BSTR* localized_name) {
2900 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_NAME);
2605 return E_NOTIMPL; 2901 return E_NOTIMPL;
2606 } 2902 }
2607 2903
2608 // 2904 //
2609 // IAccessibleValue methods. 2905 // IAccessibleValue methods.
2610 // 2906 //
2611 2907
2612 STDMETHODIMP BrowserAccessibilityWin::get_currentValue(VARIANT* value) { 2908 STDMETHODIMP BrowserAccessibilityWin::get_currentValue(VARIANT* value) {
2909 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CURRENT_VALUE);
2613 if (!instance_active()) 2910 if (!instance_active())
2614 return E_FAIL; 2911 return E_FAIL;
2615 2912
2616 if (!value) 2913 if (!value)
2617 return E_INVALIDARG; 2914 return E_INVALIDARG;
2618 2915
2619 float float_val; 2916 float float_val;
2620 if (GetFloatAttribute( 2917 if (GetFloatAttribute(
2621 ui::AX_ATTR_VALUE_FOR_RANGE, &float_val)) { 2918 ui::AX_ATTR_VALUE_FOR_RANGE, &float_val)) {
2622 value->vt = VT_R8; 2919 value->vt = VT_R8;
2623 value->dblVal = float_val; 2920 value->dblVal = float_val;
2624 return S_OK; 2921 return S_OK;
2625 } 2922 }
2626 2923
2627 value->vt = VT_EMPTY; 2924 value->vt = VT_EMPTY;
2628 return S_FALSE; 2925 return S_FALSE;
2629 } 2926 }
2630 2927
2631 STDMETHODIMP BrowserAccessibilityWin::get_minimumValue(VARIANT* value) { 2928 STDMETHODIMP BrowserAccessibilityWin::get_minimumValue(VARIANT* value) {
2929 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MINIMUM_VALUE);
2632 if (!instance_active()) 2930 if (!instance_active())
2633 return E_FAIL; 2931 return E_FAIL;
2634 2932
2635 if (!value) 2933 if (!value)
2636 return E_INVALIDARG; 2934 return E_INVALIDARG;
2637 2935
2638 float float_val; 2936 float float_val;
2639 if (GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, 2937 if (GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE,
2640 &float_val)) { 2938 &float_val)) {
2641 value->vt = VT_R8; 2939 value->vt = VT_R8;
2642 value->dblVal = float_val; 2940 value->dblVal = float_val;
2643 return S_OK; 2941 return S_OK;
2644 } 2942 }
2645 2943
2646 value->vt = VT_EMPTY; 2944 value->vt = VT_EMPTY;
2647 return S_FALSE; 2945 return S_FALSE;
2648 } 2946 }
2649 2947
2650 STDMETHODIMP BrowserAccessibilityWin::get_maximumValue(VARIANT* value) { 2948 STDMETHODIMP BrowserAccessibilityWin::get_maximumValue(VARIANT* value) {
2949 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MAXIMUM_VALUE);
2651 if (!instance_active()) 2950 if (!instance_active())
2652 return E_FAIL; 2951 return E_FAIL;
2653 2952
2654 if (!value) 2953 if (!value)
2655 return E_INVALIDARG; 2954 return E_INVALIDARG;
2656 2955
2657 float float_val; 2956 float float_val;
2658 if (GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, 2957 if (GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE,
2659 &float_val)) { 2958 &float_val)) {
2660 value->vt = VT_R8; 2959 value->vt = VT_R8;
2661 value->dblVal = float_val; 2960 value->dblVal = float_val;
2662 return S_OK; 2961 return S_OK;
2663 } 2962 }
2664 2963
2665 value->vt = VT_EMPTY; 2964 value->vt = VT_EMPTY;
2666 return S_FALSE; 2965 return S_FALSE;
2667 } 2966 }
2668 2967
2669 STDMETHODIMP BrowserAccessibilityWin::setCurrentValue(VARIANT new_value) { 2968 STDMETHODIMP BrowserAccessibilityWin::setCurrentValue(VARIANT new_value) {
2969 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_CURRENT_VALUE);
2670 // TODO(dmazzoni): Implement this. 2970 // TODO(dmazzoni): Implement this.
2671 return E_NOTIMPL; 2971 return E_NOTIMPL;
2672 } 2972 }
2673 2973
2674 // 2974 //
2675 // ISimpleDOMDocument methods. 2975 // ISimpleDOMDocument methods.
2676 // 2976 //
2677 2977
2678 STDMETHODIMP BrowserAccessibilityWin::get_URL(BSTR* url) { 2978 STDMETHODIMP BrowserAccessibilityWin::get_URL(BSTR* url) {
2979 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_URL);
2679 if (!instance_active()) 2980 if (!instance_active())
2680 return E_FAIL; 2981 return E_FAIL;
2681 2982
2682 if (!url) 2983 if (!url)
2683 return E_INVALIDARG; 2984 return E_INVALIDARG;
2684 2985
2685 if (this != manager()->GetRoot()) 2986 if (this != manager()->GetRoot())
2686 return E_FAIL; 2987 return E_FAIL;
2687 2988
2688 std::string str = manager()->GetTreeData().url; 2989 std::string str = manager()->GetTreeData().url;
2689 if (str.empty()) 2990 if (str.empty())
2690 return S_FALSE; 2991 return S_FALSE;
2691 2992
2692 *url = SysAllocString(base::UTF8ToUTF16(str).c_str()); 2993 *url = SysAllocString(base::UTF8ToUTF16(str).c_str());
2693 DCHECK(*url); 2994 DCHECK(*url);
2694 2995
2695 return S_OK; 2996 return S_OK;
2696 } 2997 }
2697 2998
2698 STDMETHODIMP BrowserAccessibilityWin::get_title(BSTR* title) { 2999 STDMETHODIMP BrowserAccessibilityWin::get_title(BSTR* title) {
3000 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TITLE);
2699 if (!instance_active()) 3001 if (!instance_active())
2700 return E_FAIL; 3002 return E_FAIL;
2701 3003
2702 if (!title) 3004 if (!title)
2703 return E_INVALIDARG; 3005 return E_INVALIDARG;
2704 3006
2705 std::string str = manager()->GetTreeData().title; 3007 std::string str = manager()->GetTreeData().title;
2706 if (str.empty()) 3008 if (str.empty())
2707 return S_FALSE; 3009 return S_FALSE;
2708 3010
2709 *title = SysAllocString(base::UTF8ToUTF16(str).c_str()); 3011 *title = SysAllocString(base::UTF8ToUTF16(str).c_str());
2710 DCHECK(*title); 3012 DCHECK(*title);
2711 3013
2712 return S_OK; 3014 return S_OK;
2713 } 3015 }
2714 3016
2715 STDMETHODIMP BrowserAccessibilityWin::get_mimeType(BSTR* mime_type) { 3017 STDMETHODIMP BrowserAccessibilityWin::get_mimeType(BSTR* mime_type) {
3018 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MIME_TYPE);
2716 if (!instance_active()) 3019 if (!instance_active())
2717 return E_FAIL; 3020 return E_FAIL;
2718 3021
2719 if (!mime_type) 3022 if (!mime_type)
2720 return E_INVALIDARG; 3023 return E_INVALIDARG;
2721 3024
2722 std::string str = manager()->GetTreeData().mimetype; 3025 std::string str = manager()->GetTreeData().mimetype;
2723 if (str.empty()) 3026 if (str.empty())
2724 return S_FALSE; 3027 return S_FALSE;
2725 3028
2726 *mime_type = SysAllocString(base::UTF8ToUTF16(str).c_str()); 3029 *mime_type = SysAllocString(base::UTF8ToUTF16(str).c_str());
2727 DCHECK(*mime_type); 3030 DCHECK(*mime_type);
2728 3031
2729 return S_OK; 3032 return S_OK;
2730 } 3033 }
2731 3034
2732 STDMETHODIMP BrowserAccessibilityWin::get_docType(BSTR* doc_type) { 3035 STDMETHODIMP BrowserAccessibilityWin::get_docType(BSTR* doc_type) {
3036 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DOC_TYPE);
2733 if (!instance_active()) 3037 if (!instance_active())
2734 return E_FAIL; 3038 return E_FAIL;
2735 3039
2736 if (!doc_type) 3040 if (!doc_type)
2737 return E_INVALIDARG; 3041 return E_INVALIDARG;
2738 3042
2739 std::string str = manager()->GetTreeData().doctype; 3043 std::string str = manager()->GetTreeData().doctype;
2740 if (str.empty()) 3044 if (str.empty())
2741 return S_FALSE; 3045 return S_FALSE;
2742 3046
2743 *doc_type = SysAllocString(base::UTF8ToUTF16(str).c_str()); 3047 *doc_type = SysAllocString(base::UTF8ToUTF16(str).c_str());
2744 DCHECK(*doc_type); 3048 DCHECK(*doc_type);
2745 3049
2746 return S_OK; 3050 return S_OK;
2747 } 3051 }
2748 3052
2749 STDMETHODIMP 3053 STDMETHODIMP
2750 BrowserAccessibilityWin::get_nameSpaceURIForID(short name_space_id, 3054 BrowserAccessibilityWin::get_nameSpaceURIForID(short name_space_id,
2751 BSTR* name_space_uri) { 3055 BSTR* name_space_uri) {
3056 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAMESPACE_URI_FOR_ID);
2752 return E_NOTIMPL; 3057 return E_NOTIMPL;
2753 } 3058 }
3059
2754 STDMETHODIMP 3060 STDMETHODIMP
2755 BrowserAccessibilityWin::put_alternateViewMediaTypes( 3061 BrowserAccessibilityWin::put_alternateViewMediaTypes(
2756 BSTR* comma_separated_media_types) { 3062 BSTR* comma_separated_media_types) {
3063 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_PUT_ALTERNATE_VIEW_MEDIA_TYPES);
2757 return E_NOTIMPL; 3064 return E_NOTIMPL;
2758 } 3065 }
2759 3066
2760 // 3067 //
2761 // ISimpleDOMNode methods. 3068 // ISimpleDOMNode methods.
2762 // 3069 //
2763 3070
2764 STDMETHODIMP BrowserAccessibilityWin::get_nodeInfo( 3071 STDMETHODIMP BrowserAccessibilityWin::get_nodeInfo(
2765 BSTR* node_name, 3072 BSTR* node_name,
2766 short* name_space_id, 3073 short* name_space_id,
2767 BSTR* node_value, 3074 BSTR* node_value,
2768 unsigned int* num_children, 3075 unsigned int* num_children,
2769 unsigned int* unique_id, 3076 unsigned int* unique_id,
2770 unsigned short* node_type) { 3077 unsigned short* node_type) {
3078 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NODE_INFO);
2771 if (!instance_active()) 3079 if (!instance_active())
2772 return E_FAIL; 3080 return E_FAIL;
2773 3081
2774 if (!node_name || !name_space_id || !node_value || !num_children || 3082 if (!node_name || !name_space_id || !node_value || !num_children ||
2775 !unique_id || !node_type) { 3083 !unique_id || !node_type) {
2776 return E_INVALIDARG; 3084 return E_INVALIDARG;
2777 } 3085 }
2778 3086
2779 base::string16 tag; 3087 base::string16 tag;
2780 if (GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) 3088 if (GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag))
(...skipping 17 matching lines...) Expand all
2798 3106
2799 return S_OK; 3107 return S_OK;
2800 } 3108 }
2801 3109
2802 STDMETHODIMP BrowserAccessibilityWin::get_attributes( 3110 STDMETHODIMP BrowserAccessibilityWin::get_attributes(
2803 unsigned short max_attribs, 3111 unsigned short max_attribs,
2804 BSTR* attrib_names, 3112 BSTR* attrib_names,
2805 short* name_space_id, 3113 short* name_space_id,
2806 BSTR* attrib_values, 3114 BSTR* attrib_values,
2807 unsigned short* num_attribs) { 3115 unsigned short* num_attribs) {
3116 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ISIMPLEDOMNODE_GET_ATTRIBUTES);
2808 if (!instance_active()) 3117 if (!instance_active())
2809 return E_FAIL; 3118 return E_FAIL;
2810 3119
2811 if (!attrib_names || !name_space_id || !attrib_values || !num_attribs) 3120 if (!attrib_names || !name_space_id || !attrib_values || !num_attribs)
2812 return E_INVALIDARG; 3121 return E_INVALIDARG;
2813 3122
2814 *num_attribs = max_attribs; 3123 *num_attribs = max_attribs;
2815 if (*num_attribs > GetHtmlAttributes().size()) 3124 if (*num_attribs > GetHtmlAttributes().size())
2816 *num_attribs = GetHtmlAttributes().size(); 3125 *num_attribs = GetHtmlAttributes().size();
2817 3126
2818 for (unsigned short i = 0; i < *num_attribs; ++i) { 3127 for (unsigned short i = 0; i < *num_attribs; ++i) {
2819 attrib_names[i] = SysAllocString( 3128 attrib_names[i] = SysAllocString(
2820 base::UTF8ToUTF16(GetHtmlAttributes()[i].first).c_str()); 3129 base::UTF8ToUTF16(GetHtmlAttributes()[i].first).c_str());
2821 name_space_id[i] = 0; 3130 name_space_id[i] = 0;
2822 attrib_values[i] = SysAllocString( 3131 attrib_values[i] = SysAllocString(
2823 base::UTF8ToUTF16(GetHtmlAttributes()[i].second).c_str()); 3132 base::UTF8ToUTF16(GetHtmlAttributes()[i].second).c_str());
2824 } 3133 }
2825 return S_OK; 3134 return S_OK;
2826 } 3135 }
2827 3136
2828 STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames( 3137 STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames(
2829 unsigned short num_attribs, 3138 unsigned short num_attribs,
2830 BSTR* attrib_names, 3139 BSTR* attrib_names,
2831 short* name_space_id, 3140 short* name_space_id,
2832 BSTR* attrib_values) { 3141 BSTR* attrib_values) {
3142 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ATTRIBUTES_FOR_NAMES);
2833 if (!instance_active()) 3143 if (!instance_active())
2834 return E_FAIL; 3144 return E_FAIL;
2835 3145
2836 if (!attrib_names || !name_space_id || !attrib_values) 3146 if (!attrib_names || !name_space_id || !attrib_values)
2837 return E_INVALIDARG; 3147 return E_INVALIDARG;
2838 3148
2839 for (unsigned short i = 0; i < num_attribs; ++i) { 3149 for (unsigned short i = 0; i < num_attribs; ++i) {
2840 name_space_id[i] = 0; 3150 name_space_id[i] = 0;
2841 bool found = false; 3151 bool found = false;
2842 std::string name = base::UTF16ToUTF8((LPCWSTR)attrib_names[i]); 3152 std::string name = base::UTF16ToUTF8((LPCWSTR)attrib_names[i]);
(...skipping 11 matching lines...) Expand all
2854 } 3164 }
2855 return S_OK; 3165 return S_OK;
2856 } 3166 }
2857 3167
2858 STDMETHODIMP BrowserAccessibilityWin::get_computedStyle( 3168 STDMETHODIMP BrowserAccessibilityWin::get_computedStyle(
2859 unsigned short max_style_properties, 3169 unsigned short max_style_properties,
2860 boolean use_alternate_view, 3170 boolean use_alternate_view,
2861 BSTR* style_properties, 3171 BSTR* style_properties,
2862 BSTR* style_values, 3172 BSTR* style_values,
2863 unsigned short *num_style_properties) { 3173 unsigned short *num_style_properties) {
3174 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COMPUTED_STYLE);
2864 if (!instance_active()) 3175 if (!instance_active())
2865 return E_FAIL; 3176 return E_FAIL;
2866 3177
2867 if (!style_properties || !style_values) 3178 if (!style_properties || !style_values)
2868 return E_INVALIDARG; 3179 return E_INVALIDARG;
2869 3180
2870 // We only cache a single style property for now: DISPLAY 3181 // We only cache a single style property for now: DISPLAY
2871 3182
2872 base::string16 display; 3183 base::string16 display;
2873 if (max_style_properties == 0 || 3184 if (max_style_properties == 0 ||
2874 !GetString16Attribute(ui::AX_ATTR_DISPLAY, &display)) { 3185 !GetString16Attribute(ui::AX_ATTR_DISPLAY, &display)) {
2875 *num_style_properties = 0; 3186 *num_style_properties = 0;
2876 return S_OK; 3187 return S_OK;
2877 } 3188 }
2878 3189
2879 *num_style_properties = 1; 3190 *num_style_properties = 1;
2880 style_properties[0] = SysAllocString(L"display"); 3191 style_properties[0] = SysAllocString(L"display");
2881 style_values[0] = SysAllocString(display.c_str()); 3192 style_values[0] = SysAllocString(display.c_str());
2882 3193
2883 return S_OK; 3194 return S_OK;
2884 } 3195 }
2885 3196
2886 STDMETHODIMP BrowserAccessibilityWin::get_computedStyleForProperties( 3197 STDMETHODIMP BrowserAccessibilityWin::get_computedStyleForProperties(
2887 unsigned short num_style_properties, 3198 unsigned short num_style_properties,
2888 boolean use_alternate_view, 3199 boolean use_alternate_view,
2889 BSTR* style_properties, 3200 BSTR* style_properties,
2890 BSTR* style_values) { 3201 BSTR* style_values) {
3202 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COMPUTED_STYLE_FOR_PROPERTIES);
2891 if (!instance_active()) 3203 if (!instance_active())
2892 return E_FAIL; 3204 return E_FAIL;
2893 3205
2894 if (!style_properties || !style_values) 3206 if (!style_properties || !style_values)
2895 return E_INVALIDARG; 3207 return E_INVALIDARG;
2896 3208
2897 // We only cache a single style property for now: DISPLAY 3209 // We only cache a single style property for now: DISPLAY
2898 3210
2899 for (unsigned short i = 0; i < num_style_properties; ++i) { 3211 for (unsigned short i = 0; i < num_style_properties; ++i) {
2900 base::string16 name = base::ToLowerASCII( 3212 base::string16 name = base::ToLowerASCII(
2901 reinterpret_cast<const base::char16*>(style_properties[i])); 3213 reinterpret_cast<const base::char16*>(style_properties[i]));
2902 if (name == L"display") { 3214 if (name == L"display") {
2903 base::string16 display = GetString16Attribute( 3215 base::string16 display = GetString16Attribute(
2904 ui::AX_ATTR_DISPLAY); 3216 ui::AX_ATTR_DISPLAY);
2905 style_values[i] = SysAllocString(display.c_str()); 3217 style_values[i] = SysAllocString(display.c_str());
2906 } else { 3218 } else {
2907 style_values[i] = NULL; 3219 style_values[i] = NULL;
2908 } 3220 }
2909 } 3221 }
2910 3222
2911 return S_OK; 3223 return S_OK;
2912 } 3224 }
2913 3225
2914 STDMETHODIMP BrowserAccessibilityWin::scrollTo(boolean placeTopLeft) { 3226 STDMETHODIMP BrowserAccessibilityWin::scrollTo(boolean placeTopLeft) {
3227 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ISIMPLEDOMNODE_SCROLL_TO);
2915 return scrollTo(placeTopLeft ? 3228 return scrollTo(placeTopLeft ?
2916 IA2_SCROLL_TYPE_TOP_LEFT : IA2_SCROLL_TYPE_ANYWHERE); 3229 IA2_SCROLL_TYPE_TOP_LEFT : IA2_SCROLL_TYPE_ANYWHERE);
2917 } 3230 }
2918 3231
2919 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { 3232 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) {
3233 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PARENT_NODE);
2920 if (!instance_active()) 3234 if (!instance_active())
2921 return E_FAIL; 3235 return E_FAIL;
2922 3236
2923 if (!node) 3237 if (!node)
2924 return E_INVALIDARG; 3238 return E_INVALIDARG;
2925 3239
2926 *node = ToBrowserAccessibilityWin(GetParent())->NewReference(); 3240 *node = ToBrowserAccessibilityWin(GetParent())->NewReference();
2927 return S_OK; 3241 return S_OK;
2928 } 3242 }
2929 3243
2930 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) { 3244 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) {
3245 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FIRST_CHILD);
2931 if (!instance_active()) 3246 if (!instance_active())
2932 return E_FAIL; 3247 return E_FAIL;
2933 3248
2934 if (!node) 3249 if (!node)
2935 return E_INVALIDARG; 3250 return E_INVALIDARG;
2936 3251
2937 if (PlatformChildCount() == 0) { 3252 if (PlatformChildCount() == 0) {
2938 *node = NULL; 3253 *node = NULL;
2939 return S_FALSE; 3254 return S_FALSE;
2940 } 3255 }
2941 3256
2942 *node = ToBrowserAccessibilityWin(PlatformGetChild(0))->NewReference(); 3257 *node = ToBrowserAccessibilityWin(PlatformGetChild(0))->NewReference();
2943 return S_OK; 3258 return S_OK;
2944 } 3259 }
2945 3260
2946 STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) { 3261 STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) {
3262 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LAST_CHILD);
2947 if (!instance_active()) 3263 if (!instance_active())
2948 return E_FAIL; 3264 return E_FAIL;
2949 3265
2950 if (!node) 3266 if (!node)
2951 return E_INVALIDARG; 3267 return E_INVALIDARG;
2952 3268
2953 if (PlatformChildCount() == 0) { 3269 if (PlatformChildCount() == 0) {
2954 *node = NULL; 3270 *node = NULL;
2955 return S_FALSE; 3271 return S_FALSE;
2956 } 3272 }
2957 3273
2958 *node = ToBrowserAccessibilityWin( 3274 *node = ToBrowserAccessibilityWin(
2959 PlatformGetChild(PlatformChildCount() - 1))->NewReference(); 3275 PlatformGetChild(PlatformChildCount() - 1))->NewReference();
2960 return S_OK; 3276 return S_OK;
2961 } 3277 }
2962 3278
2963 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( 3279 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling(
2964 ISimpleDOMNode** node) { 3280 ISimpleDOMNode** node) {
3281 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PREVIOUS_SIBLING);
2965 if (!instance_active()) 3282 if (!instance_active())
2966 return E_FAIL; 3283 return E_FAIL;
2967 3284
2968 if (!node) 3285 if (!node)
2969 return E_INVALIDARG; 3286 return E_INVALIDARG;
2970 3287
2971 if (!GetParent() || GetIndexInParent() <= 0) { 3288 if (!GetParent() || GetIndexInParent() <= 0) {
2972 *node = NULL; 3289 *node = NULL;
2973 return S_FALSE; 3290 return S_FALSE;
2974 } 3291 }
2975 3292
2976 *node = ToBrowserAccessibilityWin( 3293 *node = ToBrowserAccessibilityWin(
2977 GetParent()->InternalGetChild(GetIndexInParent() - 1))->NewReference(); 3294 GetParent()->InternalGetChild(GetIndexInParent() - 1))->NewReference();
2978 return S_OK; 3295 return S_OK;
2979 } 3296 }
2980 3297
2981 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { 3298 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) {
3299 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NEXT_SIBLING);
2982 if (!instance_active()) 3300 if (!instance_active())
2983 return E_FAIL; 3301 return E_FAIL;
2984 3302
2985 if (!node) 3303 if (!node)
2986 return E_INVALIDARG; 3304 return E_INVALIDARG;
2987 3305
2988 if (!GetParent() || 3306 if (!GetParent() ||
2989 GetIndexInParent() < 0 || 3307 GetIndexInParent() < 0 ||
2990 GetIndexInParent() >= static_cast<int>( 3308 GetIndexInParent() >= static_cast<int>(
2991 GetParent()->InternalChildCount()) - 1) { 3309 GetParent()->InternalChildCount()) - 1) {
2992 *node = NULL; 3310 *node = NULL;
2993 return S_FALSE; 3311 return S_FALSE;
2994 } 3312 }
2995 3313
2996 *node = ToBrowserAccessibilityWin( 3314 *node = ToBrowserAccessibilityWin(
2997 GetParent()->InternalGetChild(GetIndexInParent() + 1))->NewReference(); 3315 GetParent()->InternalGetChild(GetIndexInParent() + 1))->NewReference();
2998 return S_OK; 3316 return S_OK;
2999 } 3317 }
3000 3318
3001 STDMETHODIMP BrowserAccessibilityWin::get_childAt( 3319 STDMETHODIMP BrowserAccessibilityWin::get_childAt(
3002 unsigned int child_index, 3320 unsigned int child_index,
3003 ISimpleDOMNode** node) { 3321 ISimpleDOMNode** node) {
3322 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_AT);
3004 if (!instance_active()) 3323 if (!instance_active())
3005 return E_FAIL; 3324 return E_FAIL;
3006 3325
3007 if (!node) 3326 if (!node)
3008 return E_INVALIDARG; 3327 return E_INVALIDARG;
3009 3328
3010 if (child_index >= PlatformChildCount()) 3329 if (child_index >= PlatformChildCount())
3011 return E_INVALIDARG; 3330 return E_INVALIDARG;
3012 3331
3013 BrowserAccessibility* child = PlatformGetChild(child_index); 3332 BrowserAccessibility* child = PlatformGetChild(child_index);
3014 if (!child) { 3333 if (!child) {
3015 *node = NULL; 3334 *node = NULL;
3016 return S_FALSE; 3335 return S_FALSE;
3017 } 3336 }
3018 3337
3019 *node = ToBrowserAccessibilityWin(child)->NewReference(); 3338 *node = ToBrowserAccessibilityWin(child)->NewReference();
3020 return S_OK; 3339 return S_OK;
3021 } 3340 }
3022 3341
3023 STDMETHODIMP BrowserAccessibilityWin::get_innerHTML(BSTR* innerHTML) { 3342 STDMETHODIMP BrowserAccessibilityWin::get_innerHTML(BSTR* innerHTML) {
3343 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INNER_HTML);
3024 return E_NOTIMPL; 3344 return E_NOTIMPL;
3025 } 3345 }
3026 3346
3027 STDMETHODIMP 3347 STDMETHODIMP
3028 BrowserAccessibilityWin::get_localInterface(void** local_interface) { 3348 BrowserAccessibilityWin::get_localInterface(void** local_interface) {
3349 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCAL_INTERFACE);
3029 return E_NOTIMPL; 3350 return E_NOTIMPL;
3030 } 3351 }
3031 3352
3032 STDMETHODIMP BrowserAccessibilityWin::get_language(BSTR* language) { 3353 STDMETHODIMP BrowserAccessibilityWin::get_language(BSTR* language) {
3354 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LANGUAGE);
3033 if (!language) 3355 if (!language)
3034 return E_INVALIDARG; 3356 return E_INVALIDARG;
3035 *language = nullptr; 3357 *language = nullptr;
3036 3358
3037 if (!instance_active()) 3359 if (!instance_active())
3038 return E_FAIL; 3360 return E_FAIL;
3039 3361
3040 base::string16 lang = GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE); 3362 base::string16 lang = GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE);
3041 if (lang.empty()) 3363 if (lang.empty())
3042 lang = L"en-US"; 3364 lang = L"en-US";
3043 3365
3044 *language = SysAllocString(lang.c_str()); 3366 *language = SysAllocString(lang.c_str());
3045 DCHECK(*language); 3367 DCHECK(*language);
3046 return S_OK; 3368 return S_OK;
3047 } 3369 }
3048 3370
3049 // 3371 //
3050 // ISimpleDOMText methods. 3372 // ISimpleDOMText methods.
3051 // 3373 //
3052 3374
3053 STDMETHODIMP BrowserAccessibilityWin::get_domText(BSTR* dom_text) { 3375 STDMETHODIMP BrowserAccessibilityWin::get_domText(BSTR* dom_text) {
3376 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DOM_TEXT);
3054 if (!instance_active()) 3377 if (!instance_active())
3055 return E_FAIL; 3378 return E_FAIL;
3056 3379
3057 if (!dom_text) 3380 if (!dom_text)
3058 return E_INVALIDARG; 3381 return E_INVALIDARG;
3059 3382
3060 return GetStringAttributeAsBstr( 3383 return GetStringAttributeAsBstr(
3061 ui::AX_ATTR_NAME, dom_text); 3384 ui::AX_ATTR_NAME, dom_text);
3062 } 3385 }
3063 3386
3064 STDMETHODIMP BrowserAccessibilityWin::get_clippedSubstringBounds( 3387 STDMETHODIMP BrowserAccessibilityWin::get_clippedSubstringBounds(
3065 unsigned int start_index, 3388 unsigned int start_index,
3066 unsigned int end_index, 3389 unsigned int end_index,
3067 int* out_x, 3390 int* out_x,
3068 int* out_y, 3391 int* out_y,
3069 int* out_width, 3392 int* out_width,
3070 int* out_height) { 3393 int* out_height) {
3394 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CLIPPED_SUBSTRING_BOUNDS);
3071 // TODO(dmazzoni): fully support this API by intersecting the 3395 // TODO(dmazzoni): fully support this API by intersecting the
3072 // rect with the container's rect. 3396 // rect with the container's rect.
3073 return get_unclippedSubstringBounds( 3397 return get_unclippedSubstringBounds(
3074 start_index, end_index, out_x, out_y, out_width, out_height); 3398 start_index, end_index, out_x, out_y, out_width, out_height);
3075 } 3399 }
3076 3400
3077 STDMETHODIMP BrowserAccessibilityWin::get_unclippedSubstringBounds( 3401 STDMETHODIMP BrowserAccessibilityWin::get_unclippedSubstringBounds(
3078 unsigned int start_index, 3402 unsigned int start_index,
3079 unsigned int end_index, 3403 unsigned int end_index,
3080 int* out_x, 3404 int* out_x,
3081 int* out_y, 3405 int* out_y,
3082 int* out_width, 3406 int* out_width,
3083 int* out_height) { 3407 int* out_height) {
3408 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNCLIPPED_SUBSTRING_BOUNDS);
3084 if (!instance_active()) 3409 if (!instance_active())
3085 return E_FAIL; 3410 return E_FAIL;
3086 3411
3087 if (!out_x || !out_y || !out_width || !out_height) 3412 if (!out_x || !out_y || !out_width || !out_height)
3088 return E_INVALIDARG; 3413 return E_INVALIDARG;
3089 3414
3090 unsigned int text_length = static_cast<unsigned int>(GetText().size()); 3415 unsigned int text_length = static_cast<unsigned int>(GetText().size());
3091 if (start_index > text_length || end_index > text_length || 3416 if (start_index > text_length || end_index > text_length ||
3092 start_index > end_index) { 3417 start_index > end_index) {
3093 return E_INVALIDARG; 3418 return E_INVALIDARG;
3094 } 3419 }
3095 3420
3096 gfx::Rect bounds = GetScreenBoundsForRange( 3421 gfx::Rect bounds = GetScreenBoundsForRange(
3097 start_index, end_index - start_index); 3422 start_index, end_index - start_index);
3098 *out_x = bounds.x(); 3423 *out_x = bounds.x();
3099 *out_y = bounds.y(); 3424 *out_y = bounds.y();
3100 *out_width = bounds.width(); 3425 *out_width = bounds.width();
3101 *out_height = bounds.height(); 3426 *out_height = bounds.height();
3102 return S_OK; 3427 return S_OK;
3103 } 3428 }
3104 3429
3105 STDMETHODIMP BrowserAccessibilityWin::scrollToSubstring( 3430 STDMETHODIMP BrowserAccessibilityWin::scrollToSubstring(
3106 unsigned int start_index, 3431 unsigned int start_index,
3107 unsigned int end_index) { 3432 unsigned int end_index) {
3433 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_TO_SUBSTRING);
3108 if (!instance_active()) 3434 if (!instance_active())
3109 return E_FAIL; 3435 return E_FAIL;
3110 3436
3111 unsigned int text_length = static_cast<unsigned int>(GetText().size()); 3437 unsigned int text_length = static_cast<unsigned int>(GetText().size());
3112 if (start_index > text_length || end_index > text_length || 3438 if (start_index > text_length || end_index > text_length ||
3113 start_index > end_index) { 3439 start_index > end_index) {
3114 return E_INVALIDARG; 3440 return E_INVALIDARG;
3115 } 3441 }
3116 3442
3117 manager()->ScrollToMakeVisible(*this, GetPageBoundsForRange( 3443 manager()->ScrollToMakeVisible(*this, GetPageBoundsForRange(
3118 start_index, end_index - start_index)); 3444 start_index, end_index - start_index));
3119 manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); 3445 manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this);
3120 3446
3121 return S_OK; 3447 return S_OK;
3122 } 3448 }
3123 3449
3124 STDMETHODIMP BrowserAccessibilityWin::get_fontFamily(BSTR* font_family) { 3450 STDMETHODIMP BrowserAccessibilityWin::get_fontFamily(BSTR* font_family) {
3451 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FONT_FAMILY);
3125 if (!font_family) 3452 if (!font_family)
3126 return E_INVALIDARG; 3453 return E_INVALIDARG;
3127 *font_family = nullptr; 3454 *font_family = nullptr;
3128 3455
3129 if (!instance_active()) 3456 if (!instance_active())
3130 return E_FAIL; 3457 return E_FAIL;
3131 3458
3132 base::string16 family = 3459 base::string16 family =
3133 GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY); 3460 GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY);
3134 if (family.empty()) 3461 if (family.empty())
3135 return S_FALSE; 3462 return S_FALSE;
3136 3463
3137 *font_family = SysAllocString(family.c_str()); 3464 *font_family = SysAllocString(family.c_str());
3138 DCHECK(*font_family); 3465 DCHECK(*font_family);
3139 return S_OK; 3466 return S_OK;
3140 } 3467 }
3141 3468
3142 // 3469 //
3143 // IServiceProvider methods. 3470 // IServiceProvider methods.
3144 // 3471 //
3145 3472
3146 STDMETHODIMP BrowserAccessibilityWin::QueryService(REFGUID guid_service, 3473 STDMETHODIMP BrowserAccessibilityWin::QueryService(REFGUID guid_service,
3147 REFIID riid, 3474 REFIID riid,
3148 void** object) { 3475 void** object) {
3476 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_QUERY_SERVICE);
3149 if (!instance_active()) 3477 if (!instance_active())
3150 return E_FAIL; 3478 return E_FAIL;
3151 3479
3152 // The system uses IAccessible APIs for many purposes, but only 3480 // The system uses IAccessible APIs for many purposes, but only
3153 // assistive technology like screen readers uses IAccessible2. 3481 // assistive technology like screen readers uses IAccessible2.
3154 // Enable full accessibility support when IAccessible2 APIs are queried. 3482 // Enable full accessibility support when IAccessible2 APIs are queried.
3155 if (riid == IID_IAccessible2) 3483 if (riid == IID_IAccessible2)
3156 BrowserAccessibilityStateImpl::GetInstance()->EnableAccessibility(); 3484 BrowserAccessibilityStateImpl::GetInstance()->EnableAccessibility();
3157 3485
3158 if (guid_service == GUID_IAccessibleContentDocument) { 3486 if (guid_service == GUID_IAccessibleContentDocument) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3193 base::win::GetVersion() >= base::win::VERSION_WIN8) { 3521 base::win::GetVersion() >= base::win::VERSION_WIN8) {
3194 return QueryInterface(riid, object); 3522 return QueryInterface(riid, object);
3195 } 3523 }
3196 3524
3197 *object = NULL; 3525 *object = NULL;
3198 return E_FAIL; 3526 return E_FAIL;
3199 } 3527 }
3200 3528
3201 STDMETHODIMP 3529 STDMETHODIMP
3202 BrowserAccessibilityWin::GetObjectForChild(long child_id, IAccessibleEx** ret) { 3530 BrowserAccessibilityWin::GetObjectForChild(long child_id, IAccessibleEx** ret) {
3531 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OBJECT_FOR_CHILD);
3203 return E_NOTIMPL; 3532 return E_NOTIMPL;
3204 } 3533 }
3205 3534
3206 STDMETHODIMP 3535 STDMETHODIMP
3207 BrowserAccessibilityWin::GetIAccessiblePair(IAccessible** acc, long* child_id) { 3536 BrowserAccessibilityWin::GetIAccessiblePair(IAccessible** acc, long* child_id) {
3537 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IACCESSIBLE_PAIR);
3208 return E_NOTIMPL; 3538 return E_NOTIMPL;
3209 } 3539 }
3210 3540
3211 STDMETHODIMP BrowserAccessibilityWin::GetRuntimeId(SAFEARRAY** runtime_id) { 3541 STDMETHODIMP BrowserAccessibilityWin::GetRuntimeId(SAFEARRAY** runtime_id) {
3542 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RUNTIME_ID);
3212 return E_NOTIMPL; 3543 return E_NOTIMPL;
3213 } 3544 }
3214 3545
3215 STDMETHODIMP 3546 STDMETHODIMP
3216 BrowserAccessibilityWin::ConvertReturnedElement( 3547 BrowserAccessibilityWin::ConvertReturnedElement(
3217 IRawElementProviderSimple* element, 3548 IRawElementProviderSimple* element,
3218 IAccessibleEx** acc) { 3549 IAccessibleEx** acc) {
3550 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_CONVERT_RETURNED_ELEMENT);
3219 return E_NOTIMPL; 3551 return E_NOTIMPL;
3220 } 3552 }
3221 3553
3222 STDMETHODIMP BrowserAccessibilityWin::GetPatternProvider(PATTERNID id, 3554 STDMETHODIMP BrowserAccessibilityWin::GetPatternProvider(PATTERNID id,
3223 IUnknown** provider) { 3555 IUnknown** provider) {
3556 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PATTERN_PROVIDER);
3224 DVLOG(1) << "In Function: " << __func__ << " for pattern id: " << id; 3557 DVLOG(1) << "In Function: " << __func__ << " for pattern id: " << id;
3225 if (id == UIA_ValuePatternId || id == UIA_TextPatternId) { 3558 if (id == UIA_ValuePatternId || id == UIA_TextPatternId) {
3226 if (HasState(ui::AX_STATE_EDITABLE)) { 3559 if (HasState(ui::AX_STATE_EDITABLE)) {
3227 DVLOG(1) << "Returning UIA text provider"; 3560 DVLOG(1) << "Returning UIA text provider";
3228 base::win::UIATextProvider::CreateTextProvider( 3561 base::win::UIATextProvider::CreateTextProvider(
3229 GetValueText(), true, provider); 3562 GetValueText(), true, provider);
3230 return S_OK; 3563 return S_OK;
3231 } 3564 }
3232 } 3565 }
3233 return E_NOTIMPL; 3566 return E_NOTIMPL;
3234 } 3567 }
3235 3568
3236 STDMETHODIMP BrowserAccessibilityWin::GetPropertyValue(PROPERTYID id, 3569 STDMETHODIMP BrowserAccessibilityWin::GetPropertyValue(PROPERTYID id,
3237 VARIANT* ret) { 3570 VARIANT* ret) {
3571 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PROPERTY_VALUE);
3238 DVLOG(1) << "In Function: " << __func__ << " for property id: " << id; 3572 DVLOG(1) << "In Function: " << __func__ << " for property id: " << id;
3239 V_VT(ret) = VT_EMPTY; 3573 V_VT(ret) = VT_EMPTY;
3240 if (id == UIA_ControlTypePropertyId) { 3574 if (id == UIA_ControlTypePropertyId) {
3241 if (HasState(ui::AX_STATE_EDITABLE)) { 3575 if (HasState(ui::AX_STATE_EDITABLE)) {
3242 V_VT(ret) = VT_I4; 3576 V_VT(ret) = VT_I4;
3243 ret->lVal = UIA_EditControlTypeId; 3577 ret->lVal = UIA_EditControlTypeId;
3244 DVLOG(1) << "Returning Edit control type"; 3578 DVLOG(1) << "Returning Edit control type";
3245 } else { 3579 } else {
3246 DVLOG(1) << "Returning empty control type"; 3580 DVLOG(1) << "Returning empty control type";
3247 } 3581 }
3248 } 3582 }
3249 return S_OK; 3583 return S_OK;
3250 } 3584 }
3251 3585
3252 STDMETHODIMP BrowserAccessibilityWin::get_ProviderOptions( 3586 STDMETHODIMP BrowserAccessibilityWin::get_ProviderOptions(
3253 ProviderOptions* ret) { 3587 ProviderOptions* ret) {
3588 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PROVIDER_OPTIONS);
3254 return E_NOTIMPL; 3589 return E_NOTIMPL;
3255 } 3590 }
3256 3591
3257 STDMETHODIMP BrowserAccessibilityWin::get_HostRawElementProvider( 3592 STDMETHODIMP BrowserAccessibilityWin::get_HostRawElementProvider(
3258 IRawElementProviderSimple** provider) { 3593 IRawElementProviderSimple** provider) {
3594 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HOST_RAW_ELEMENT_PROVIDER);
3259 return E_NOTIMPL; 3595 return E_NOTIMPL;
3260 } 3596 }
3261 3597
3262 // 3598 //
3263 // CComObjectRootEx methods. 3599 // CComObjectRootEx methods.
3264 // 3600 //
3265 3601
3266 // static 3602 // static
3267 HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( 3603 HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface(
3268 void* this_ptr, 3604 void* this_ptr,
(...skipping 1934 matching lines...) Expand 10 before | Expand all | Expand 10 after
5203 return static_cast<BrowserAccessibilityWin*>(obj); 5539 return static_cast<BrowserAccessibilityWin*>(obj);
5204 } 5540 }
5205 5541
5206 const BrowserAccessibilityWin* 5542 const BrowserAccessibilityWin*
5207 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { 5543 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) {
5208 DCHECK(!obj || obj->IsNative()); 5544 DCHECK(!obj || obj->IsNative());
5209 return static_cast<const BrowserAccessibilityWin*>(obj); 5545 return static_cast<const BrowserAccessibilityWin*>(obj);
5210 } 5546 }
5211 5547
5212 } // namespace content 5548 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698