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

Side by Side Diff: ui/accessibility/platform/ax_platform_node_win.cc

Issue 2981023002: Move Win32 API Histogram code to AXPlatformNode so that it can be shared. (Closed)
Patch Set: Created 3 years, 5 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 | « ui/accessibility/platform/ax_platform_node_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <atlbase.h> 5 #include <atlbase.h>
6 #include <atlcom.h> 6 #include <atlcom.h>
7 #include <limits.h> 7 #include <limits.h>
8 #include <oleacc.h> 8 #include <oleacc.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 272
273 return -1; 273 return -1;
274 } 274 }
275 275
276 // 276 //
277 // IAccessible implementation. 277 // IAccessible implementation.
278 // 278 //
279 279
280 STDMETHODIMP AXPlatformNodeWin::accHitTest( 280 STDMETHODIMP AXPlatformNodeWin::accHitTest(
281 LONG x_left, LONG y_top, VARIANT* child) { 281 LONG x_left, LONG y_top, VARIANT* child) {
282 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_HIT_TEST);
282 COM_OBJECT_VALIDATE_1_ARG(child); 283 COM_OBJECT_VALIDATE_1_ARG(child);
283 284
284 gfx::Point point(x_left, y_top); 285 gfx::Point point(x_left, y_top);
285 if (!delegate_->GetScreenBoundsRect().Contains(point)) { 286 if (!delegate_->GetScreenBoundsRect().Contains(point)) {
286 // Return S_FALSE and VT_EMPTY when outside the object's boundaries. 287 // Return S_FALSE and VT_EMPTY when outside the object's boundaries.
287 child->vt = VT_EMPTY; 288 child->vt = VT_EMPTY;
288 return S_FALSE; 289 return S_FALSE;
289 } 290 }
290 291
291 gfx::NativeViewAccessible hit_child = delegate_->HitTestSync(x_left, y_top); 292 gfx::NativeViewAccessible hit_child = delegate_->HitTestSync(x_left, y_top);
(...skipping 22 matching lines...) Expand all
314 if (S_OK == result && child->vt == VT_I4 && child->lVal == CHILDID_SELF) { 315 if (S_OK == result && child->vt == VT_I4 && child->lVal == CHILDID_SELF) {
315 child->vt = VT_DISPATCH; 316 child->vt = VT_DISPATCH;
316 child->pdispVal = hit_child; 317 child->pdispVal = hit_child;
317 // Always increment ref when returning a reference to a COM object. 318 // Always increment ref when returning a reference to a COM object.
318 child->pdispVal->AddRef(); 319 child->pdispVal->AddRef();
319 } 320 }
320 return result; 321 return result;
321 } 322 }
322 323
323 HRESULT AXPlatformNodeWin::accDoDefaultAction(VARIANT var_id) { 324 HRESULT AXPlatformNodeWin::accDoDefaultAction(VARIANT var_id) {
325 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_DO_DEFAULT_ACTION);
324 AXPlatformNodeWin* target; 326 AXPlatformNodeWin* target;
325 COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_id, target); 327 COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_id, target);
326 AXActionData data; 328 AXActionData data;
327 data.action = ui::AX_ACTION_DO_DEFAULT; 329 data.action = ui::AX_ACTION_DO_DEFAULT;
328 330
329 if (target->delegate_->AccessibilityPerformAction(data)) 331 if (target->delegate_->AccessibilityPerformAction(data))
330 return S_OK; 332 return S_OK;
331 return E_FAIL; 333 return E_FAIL;
332 } 334 }
333 335
334 STDMETHODIMP AXPlatformNodeWin::accLocation( 336 STDMETHODIMP AXPlatformNodeWin::accLocation(
335 LONG* x_left, LONG* y_top, LONG* width, LONG* height, VARIANT var_id) { 337 LONG* x_left, LONG* y_top, LONG* width, LONG* height, VARIANT var_id) {
338 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_LOCATION);
336 AXPlatformNodeWin* target; 339 AXPlatformNodeWin* target;
337 COM_OBJECT_VALIDATE_VAR_ID_4_ARGS_AND_GET_TARGET(var_id, x_left, y_top, width, 340 COM_OBJECT_VALIDATE_VAR_ID_4_ARGS_AND_GET_TARGET(var_id, x_left, y_top, width,
338 height, target); 341 height, target);
339 342
340 gfx::Rect bounds = target->delegate_->GetScreenBoundsRect(); 343 gfx::Rect bounds = target->delegate_->GetScreenBoundsRect();
341 *x_left = bounds.x(); 344 *x_left = bounds.x();
342 *y_top = bounds.y(); 345 *y_top = bounds.y();
343 *width = bounds.width(); 346 *width = bounds.width();
344 *height = bounds.height(); 347 *height = bounds.height();
345 348
346 if (bounds.IsEmpty()) 349 if (bounds.IsEmpty())
347 return S_FALSE; 350 return S_FALSE;
348 351
349 return S_OK; 352 return S_OK;
350 } 353 }
351 354
352 STDMETHODIMP AXPlatformNodeWin::accNavigate( 355 STDMETHODIMP AXPlatformNodeWin::accNavigate(
353 LONG nav_dir, VARIANT start, VARIANT* end) { 356 LONG nav_dir, VARIANT start, VARIANT* end) {
357 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_NAVIGATE);
354 AXPlatformNodeWin* target; 358 AXPlatformNodeWin* target;
355 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(start, end, target); 359 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(start, end, target);
356 end->vt = VT_EMPTY; 360 end->vt = VT_EMPTY;
357 if ((nav_dir == NAVDIR_FIRSTCHILD || nav_dir == NAVDIR_LASTCHILD) && 361 if ((nav_dir == NAVDIR_FIRSTCHILD || nav_dir == NAVDIR_LASTCHILD) &&
358 V_VT(&start) == VT_I4 && V_I4(&start) != CHILDID_SELF) { 362 V_VT(&start) == VT_I4 && V_I4(&start) != CHILDID_SELF) {
359 // MSAA states that navigating to first/last child can only be from self. 363 // MSAA states that navigating to first/last child can only be from self.
360 return E_INVALIDARG; 364 return E_INVALIDARG;
361 } 365 }
362 366
363 IAccessible* result = nullptr; 367 IAccessible* result = nullptr;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 end->vt = VT_DISPATCH; 459 end->vt = VT_DISPATCH;
456 end->pdispVal = result; 460 end->pdispVal = result;
457 // Always increment ref when returning a reference to a COM object. 461 // Always increment ref when returning a reference to a COM object.
458 end->pdispVal->AddRef(); 462 end->pdispVal->AddRef();
459 463
460 return S_OK; 464 return S_OK;
461 } 465 }
462 466
463 STDMETHODIMP AXPlatformNodeWin::get_accChild(VARIANT var_child, 467 STDMETHODIMP AXPlatformNodeWin::get_accChild(VARIANT var_child,
464 IDispatch** disp_child) { 468 IDispatch** disp_child) {
469 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_CHILD);
470
465 *disp_child = nullptr; 471 *disp_child = nullptr;
466 AXPlatformNodeWin* target; 472 AXPlatformNodeWin* target;
467 COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_child, target); 473 COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_child, target);
468 474
469 *disp_child = target; 475 *disp_child = target;
470 (*disp_child)->AddRef(); 476 (*disp_child)->AddRef();
471 return S_OK; 477 return S_OK;
472 } 478 }
473 479
474 STDMETHODIMP AXPlatformNodeWin::get_accChildCount(LONG* child_count) { 480 STDMETHODIMP AXPlatformNodeWin::get_accChildCount(LONG* child_count) {
481 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_CHILD_COUNT);
482
475 COM_OBJECT_VALIDATE_1_ARG(child_count); 483 COM_OBJECT_VALIDATE_1_ARG(child_count);
476 *child_count = delegate_->GetChildCount(); 484 *child_count = delegate_->GetChildCount();
477 return S_OK; 485 return S_OK;
478 } 486 }
479 487
480 STDMETHODIMP AXPlatformNodeWin::get_accDefaultAction( 488 STDMETHODIMP AXPlatformNodeWin::get_accDefaultAction(
481 VARIANT var_id, BSTR* def_action) { 489 VARIANT var_id, BSTR* def_action) {
490 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DEFAULT_ACTION);
482 AXPlatformNodeWin* target; 491 AXPlatformNodeWin* target;
483 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, def_action, target); 492 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, def_action, target);
484 493
485 int action; 494 int action;
486 if (!target->GetIntAttribute(AX_ATTR_DEFAULT_ACTION_VERB, &action)) { 495 if (!target->GetIntAttribute(AX_ATTR_DEFAULT_ACTION_VERB, &action)) {
487 *def_action = nullptr; 496 *def_action = nullptr;
488 return S_FALSE; 497 return S_FALSE;
489 } 498 }
490 499
491 base::string16 action_verb = 500 base::string16 action_verb =
492 ActionVerbToLocalizedString(static_cast<AXDefaultActionVerb>(action)); 501 ActionVerbToLocalizedString(static_cast<AXDefaultActionVerb>(action));
493 if (action_verb.empty()) { 502 if (action_verb.empty()) {
494 *def_action = nullptr; 503 *def_action = nullptr;
495 return S_FALSE; 504 return S_FALSE;
496 } 505 }
497 506
498 *def_action = SysAllocString(action_verb.c_str()); 507 *def_action = SysAllocString(action_verb.c_str());
499 DCHECK(def_action); 508 DCHECK(def_action);
500 return S_OK; 509 return S_OK;
501 } 510 }
502 511
503 STDMETHODIMP AXPlatformNodeWin::get_accDescription( 512 STDMETHODIMP AXPlatformNodeWin::get_accDescription(
504 VARIANT var_id, BSTR* desc) { 513 VARIANT var_id, BSTR* desc) {
514 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DESCRIPTION);
505 AXPlatformNodeWin* target; 515 AXPlatformNodeWin* target;
506 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, desc, target); 516 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, desc, target);
507 517
508 return target->GetStringAttributeAsBstr(ui::AX_ATTR_DESCRIPTION, desc); 518 return target->GetStringAttributeAsBstr(ui::AX_ATTR_DESCRIPTION, desc);
509 } 519 }
510 520
511 STDMETHODIMP AXPlatformNodeWin::get_accFocus(VARIANT* focus_child) { 521 STDMETHODIMP AXPlatformNodeWin::get_accFocus(VARIANT* focus_child) {
522 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_FOCUS);
512 COM_OBJECT_VALIDATE_1_ARG(focus_child); 523 COM_OBJECT_VALIDATE_1_ARG(focus_child);
513 gfx::NativeViewAccessible focus_accessible = delegate_->GetFocus(); 524 gfx::NativeViewAccessible focus_accessible = delegate_->GetFocus();
514 if (focus_accessible == this) { 525 if (focus_accessible == this) {
515 focus_child->vt = VT_I4; 526 focus_child->vt = VT_I4;
516 focus_child->lVal = CHILDID_SELF; 527 focus_child->lVal = CHILDID_SELF;
517 } else if (focus_accessible) { 528 } else if (focus_accessible) {
518 focus_child->vt = VT_DISPATCH; 529 focus_child->vt = VT_DISPATCH;
519 focus_child->pdispVal = focus_accessible; 530 focus_child->pdispVal = focus_accessible;
520 focus_child->pdispVal->AddRef(); 531 focus_child->pdispVal->AddRef();
521 return S_OK; 532 return S_OK;
522 } else { 533 } else {
523 focus_child->vt = VT_EMPTY; 534 focus_child->vt = VT_EMPTY;
524 } 535 }
525 536
526 return S_OK; 537 return S_OK;
527 } 538 }
528 539
529 STDMETHODIMP AXPlatformNodeWin::get_accKeyboardShortcut( 540 STDMETHODIMP AXPlatformNodeWin::get_accKeyboardShortcut(
530 VARIANT var_id, BSTR* acc_key) { 541 VARIANT var_id, BSTR* acc_key) {
542 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_KEYBOARD_SHORTCUT);
531 AXPlatformNodeWin* target; 543 AXPlatformNodeWin* target;
532 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, acc_key, target); 544 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, acc_key, target);
533 545
534 return target->GetStringAttributeAsBstr(ui::AX_ATTR_KEY_SHORTCUTS, acc_key); 546 return target->GetStringAttributeAsBstr(ui::AX_ATTR_KEY_SHORTCUTS, acc_key);
535 } 547 }
536 548
537 STDMETHODIMP AXPlatformNodeWin::get_accName( 549 STDMETHODIMP AXPlatformNodeWin::get_accName(
538 VARIANT var_id, BSTR* name) { 550 VARIANT var_id, BSTR* name) {
551 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_NAME);
539 AXPlatformNodeWin* target; 552 AXPlatformNodeWin* target;
540 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, name, target); 553 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, name, target);
541 554
542 HRESULT result = target->GetStringAttributeAsBstr(ui::AX_ATTR_NAME, name); 555 HRESULT result = target->GetStringAttributeAsBstr(ui::AX_ATTR_NAME, name);
543 if (FAILED(result) && MSAARole() == ROLE_SYSTEM_DOCUMENT && GetParent()) { 556 if (FAILED(result) && MSAARole() == ROLE_SYSTEM_DOCUMENT && GetParent()) {
544 // Hack: Some versions of JAWS crash if they get an empty name on 557 // Hack: Some versions of JAWS crash if they get an empty name on
545 // a document that's the child of an iframe, so always return a 558 // a document that's the child of an iframe, so always return a
546 // nonempty string for this role. https://crbug.com/583057 559 // nonempty string for this role. https://crbug.com/583057
547 base::string16 str = L" "; 560 base::string16 str = L" ";
548 561
549 *name = SysAllocString(str.c_str()); 562 *name = SysAllocString(str.c_str());
550 DCHECK(*name); 563 DCHECK(*name);
551 } 564 }
552 565
553 return result; 566 return result;
554 } 567 }
555 568
556 STDMETHODIMP AXPlatformNodeWin::get_accParent( 569 STDMETHODIMP AXPlatformNodeWin::get_accParent(
557 IDispatch** disp_parent) { 570 IDispatch** disp_parent) {
571 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_PARENT);
558 COM_OBJECT_VALIDATE_1_ARG(disp_parent); 572 COM_OBJECT_VALIDATE_1_ARG(disp_parent);
559 *disp_parent = GetParent(); 573 *disp_parent = GetParent();
560 if (*disp_parent) { 574 if (*disp_parent) {
561 (*disp_parent)->AddRef(); 575 (*disp_parent)->AddRef();
562 return S_OK; 576 return S_OK;
563 } 577 }
564 578
565 return S_FALSE; 579 return S_FALSE;
566 } 580 }
567 581
568 STDMETHODIMP AXPlatformNodeWin::get_accRole( 582 STDMETHODIMP AXPlatformNodeWin::get_accRole(
569 VARIANT var_id, VARIANT* role) { 583 VARIANT var_id, VARIANT* role) {
584 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_ROLE);
570 AXPlatformNodeWin* target; 585 AXPlatformNodeWin* target;
571 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, role, target); 586 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, role, target);
572 587
573 // For historical reasons, we return a string (typically 588 // For historical reasons, we return a string (typically
574 // containing the HTML tag name) as the MSAA role, rather 589 // containing the HTML tag name) as the MSAA role, rather
575 // than a int. 590 // than a int.
576 std::string role_string = 591 std::string role_string =
577 base::ToUpperASCII(target->StringOverrideForMSAARole()); 592 base::ToUpperASCII(target->StringOverrideForMSAARole());
578 if (!role_string.empty()) { 593 if (!role_string.empty()) {
579 role->vt = VT_BSTR; 594 role->vt = VT_BSTR;
580 std::wstring wsTmp(role_string.begin(), role_string.end()); 595 std::wstring wsTmp(role_string.begin(), role_string.end());
581 role->bstrVal = SysAllocString(wsTmp.c_str()); 596 role->bstrVal = SysAllocString(wsTmp.c_str());
582 return S_OK; 597 return S_OK;
583 } 598 }
584 599
585 role->vt = VT_I4; 600 role->vt = VT_I4;
586 role->lVal = target->MSAARole(); 601 role->lVal = target->MSAARole();
587 return S_OK; 602 return S_OK;
588 } 603 }
589 604
590 STDMETHODIMP AXPlatformNodeWin::get_accState( 605 STDMETHODIMP AXPlatformNodeWin::get_accState(
591 VARIANT var_id, VARIANT* state) { 606 VARIANT var_id, VARIANT* state) {
607 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_STATE);
592 AXPlatformNodeWin* target; 608 AXPlatformNodeWin* target;
593 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, state, target); 609 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, state, target);
594 state->vt = VT_I4; 610 state->vt = VT_I4;
595 state->lVal = target->MSAAState(); 611 state->lVal = target->MSAAState();
596 return S_OK; 612 return S_OK;
597 } 613 }
598 614
599 STDMETHODIMP AXPlatformNodeWin::get_accHelp( 615 STDMETHODIMP AXPlatformNodeWin::get_accHelp(
600 VARIANT var_id, BSTR* help) { 616 VARIANT var_id, BSTR* help) {
617 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP);
601 COM_OBJECT_VALIDATE_1_ARG(help); 618 COM_OBJECT_VALIDATE_1_ARG(help);
602 return S_FALSE; 619 return S_FALSE;
603 } 620 }
604 621
605 STDMETHODIMP AXPlatformNodeWin::get_accValue(VARIANT var_id, BSTR* value) { 622 STDMETHODIMP AXPlatformNodeWin::get_accValue(VARIANT var_id, BSTR* value) {
623 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_VALUE);
606 AXPlatformNodeWin* target; 624 AXPlatformNodeWin* target;
607 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, value, target); 625 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, value, target);
608 626
609 // get_accValue() has two sets of special cases depending on the node's role. 627 // get_accValue() has two sets of special cases depending on the node's role.
610 // The first set apply without regard for the nodes |value| attribute. That is 628 // The first set apply without regard for the nodes |value| attribute. That is
611 // the nodes value attribute isn't consider for the first set of special 629 // the nodes value attribute isn't consider for the first set of special
612 // cases. For example, if the node role is AX_ROLE_COLOR_WELL, we do not care 630 // cases. For example, if the node role is AX_ROLE_COLOR_WELL, we do not care
613 // at all about the node's AX_ATTR_VALUE attribute. The second set of special 631 // at all about the node's AX_ATTR_VALUE attribute. The second set of special
614 // cases only apply if the value attribute for the node is empty. That is, if 632 // cases only apply if the value attribute for the node is empty. That is, if
615 // AX_ATTR_VALUE is empty, we do something special. 633 // AX_ATTR_VALUE is empty, we do something special.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 712
695 AXActionData data; 713 AXActionData data;
696 data.action = ui::AX_ACTION_SET_VALUE; 714 data.action = ui::AX_ACTION_SET_VALUE;
697 data.value = new_value; 715 data.value = new_value;
698 if (target->delegate_->AccessibilityPerformAction(data)) 716 if (target->delegate_->AccessibilityPerformAction(data))
699 return S_OK; 717 return S_OK;
700 return E_FAIL; 718 return E_FAIL;
701 } 719 }
702 720
703 STDMETHODIMP AXPlatformNodeWin::get_accSelection(VARIANT* selected) { 721 STDMETHODIMP AXPlatformNodeWin::get_accSelection(VARIANT* selected) {
722 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_SELECTION);
704 COM_OBJECT_VALIDATE_1_ARG(selected); 723 COM_OBJECT_VALIDATE_1_ARG(selected);
705 724
706 if (GetData().role != ui::AX_ROLE_LIST_BOX) 725 if (GetData().role != ui::AX_ROLE_LIST_BOX)
707 return E_NOTIMPL; 726 return E_NOTIMPL;
708 727
709 unsigned long selected_count = 0; 728 unsigned long selected_count = 0;
710 for (auto i = 0; i < delegate_->GetChildCount(); ++i) { 729 for (auto i = 0; i < delegate_->GetChildCount(); ++i) {
711 AXPlatformNodeWin* node = static_cast<AXPlatformNodeWin*>( 730 AXPlatformNodeWin* node = static_cast<AXPlatformNodeWin*>(
712 FromNativeViewAccessible(delegate_->ChildAtIndex(i))); 731 FromNativeViewAccessible(delegate_->ChildAtIndex(i)));
713 732
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 } 770 }
752 } 771 }
753 selected->vt = VT_UNKNOWN; 772 selected->vt = VT_UNKNOWN;
754 selected->punkVal = static_cast<IUnknown*>( 773 selected->punkVal = static_cast<IUnknown*>(
755 static_cast<base::win::IUnknownImpl*>(enum_variant)); 774 static_cast<base::win::IUnknownImpl*>(enum_variant));
756 return S_OK; 775 return S_OK;
757 } 776 }
758 777
759 STDMETHODIMP AXPlatformNodeWin::accSelect( 778 STDMETHODIMP AXPlatformNodeWin::accSelect(
760 LONG flagsSelect, VARIANT var_id) { 779 LONG flagsSelect, VARIANT var_id) {
780 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_SELECT);
761 AXPlatformNodeWin* target; 781 AXPlatformNodeWin* target;
762 COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_id, target); 782 COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_id, target);
763 783
764 if (flagsSelect & SELFLAG_TAKEFOCUS) { 784 if (flagsSelect & SELFLAG_TAKEFOCUS) {
765 ui::AXActionData action_data; 785 ui::AXActionData action_data;
766 action_data.action = ui::AX_ACTION_FOCUS; 786 action_data.action = ui::AX_ACTION_FOCUS;
767 target->delegate_->AccessibilityPerformAction(action_data); 787 target->delegate_->AccessibilityPerformAction(action_data);
768 return S_OK; 788 return S_OK;
769 } 789 }
770 790
771 return S_FALSE; 791 return S_FALSE;
772 } 792 }
773 793
774 STDMETHODIMP AXPlatformNodeWin::get_accHelpTopic( 794 STDMETHODIMP AXPlatformNodeWin::get_accHelpTopic(
775 BSTR* help_file, VARIANT var_id, LONG* topic_id) { 795 BSTR* help_file, VARIANT var_id, LONG* topic_id) {
796 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP_TOPIC);
776 AXPlatformNodeWin* target; 797 AXPlatformNodeWin* target;
777 COM_OBJECT_VALIDATE_VAR_ID_2_ARGS_AND_GET_TARGET(var_id, help_file, topic_id, 798 COM_OBJECT_VALIDATE_VAR_ID_2_ARGS_AND_GET_TARGET(var_id, help_file, topic_id,
778 target); 799 target);
779 if (help_file) { 800 if (help_file) {
780 *help_file = nullptr; 801 *help_file = nullptr;
781 } 802 }
782 if (topic_id) { 803 if (topic_id) {
783 *topic_id = static_cast<LONG>(-1); 804 *topic_id = static_cast<LONG>(-1);
784 } 805 }
785 return E_NOTIMPL; 806 return E_NOTIMPL;
786 } 807 }
787 808
788 STDMETHODIMP AXPlatformNodeWin::put_accName( 809 STDMETHODIMP AXPlatformNodeWin::put_accName(
789 VARIANT var_id, BSTR put_name) { 810 VARIANT var_id, BSTR put_name) {
811 // TODO(dougt): We may want to collect an API histogram here.
790 // Deprecated. 812 // Deprecated.
791 return E_NOTIMPL; 813 return E_NOTIMPL;
792 } 814 }
793 815
794 // 816 //
795 // IAccessible2 implementation. 817 // IAccessible2 implementation.
796 // 818 //
797 819
798 STDMETHODIMP AXPlatformNodeWin::role(LONG* role) { 820 STDMETHODIMP AXPlatformNodeWin::role(LONG* role) {
821 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ROLE);
799 COM_OBJECT_VALIDATE_1_ARG(role); 822 COM_OBJECT_VALIDATE_1_ARG(role);
800 823
801 *role = IA2Role(); 824 *role = IA2Role();
802 // If we didn't explicitly set the IAccessible2 role, make it the same 825 // If we didn't explicitly set the IAccessible2 role, make it the same
803 // as the MSAA role. 826 // as the MSAA role.
804 if (!*role) 827 if (!*role)
805 *role = MSAARole(); 828 *role = MSAARole();
806 return S_OK; 829 return S_OK;
807 } 830 }
808 831
809 STDMETHODIMP AXPlatformNodeWin::get_states(AccessibleStates* states) { 832 STDMETHODIMP AXPlatformNodeWin::get_states(AccessibleStates* states) {
833 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_STATES);
810 COM_OBJECT_VALIDATE_1_ARG(states); 834 COM_OBJECT_VALIDATE_1_ARG(states);
811 *states = IA2State(); 835 *states = IA2State();
812 return S_OK; 836 return S_OK;
813 } 837 }
814 838
815 STDMETHODIMP AXPlatformNodeWin::get_uniqueID(LONG* unique_id) { 839 STDMETHODIMP AXPlatformNodeWin::get_uniqueID(LONG* unique_id) {
816 COM_OBJECT_VALIDATE_1_ARG(unique_id); 840 COM_OBJECT_VALIDATE_1_ARG(unique_id);
817 *unique_id = -unique_id_; 841 *unique_id = -unique_id_;
818 return S_OK; 842 return S_OK;
819 } 843 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 return E_NOTIMPL; 985 return E_NOTIMPL;
962 } 986 }
963 987
964 // 988 //
965 // IAccessibleTable methods. 989 // IAccessibleTable methods.
966 // 990 //
967 991
968 STDMETHODIMP AXPlatformNodeWin::get_accessibleAt(long row, 992 STDMETHODIMP AXPlatformNodeWin::get_accessibleAt(long row,
969 long column, 993 long column,
970 IUnknown** accessible) { 994 IUnknown** accessible) {
995 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACCESSIBLE_AT);
971 if (!accessible) 996 if (!accessible)
972 return E_INVALIDARG; 997 return E_INVALIDARG;
973 998
974 AXPlatformNodeBase* cell = 999 AXPlatformNodeBase* cell =
975 GetTableCell(static_cast<int>(row), static_cast<int>(column)); 1000 GetTableCell(static_cast<int>(row), static_cast<int>(column));
976 if (cell) { 1001 if (cell) {
977 auto* node_win = static_cast<AXPlatformNodeWin*>(cell); 1002 auto* node_win = static_cast<AXPlatformNodeWin*>(cell);
978 node_win->AddRef(); 1003 node_win->AddRef();
979 1004
980 *accessible = static_cast<IAccessible*>(node_win); 1005 *accessible = static_cast<IAccessible*>(node_win);
981 return S_OK; 1006 return S_OK;
982 } 1007 }
983 1008
984 *accessible = nullptr; 1009 *accessible = nullptr;
985 return E_INVALIDARG; 1010 return E_INVALIDARG;
986 } 1011 }
987 1012
988 STDMETHODIMP AXPlatformNodeWin::get_caption(IUnknown** accessible) { 1013 STDMETHODIMP AXPlatformNodeWin::get_caption(IUnknown** accessible) {
1014 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CAPTION);
989 if (!accessible) 1015 if (!accessible)
990 return E_INVALIDARG; 1016 return E_INVALIDARG;
991 1017
992 // TODO(dmazzoni): implement 1018 // TODO(dmazzoni): implement
993 *accessible = nullptr; 1019 *accessible = nullptr;
994 return S_FALSE; 1020 return S_FALSE;
995 } 1021 }
996 1022
997 STDMETHODIMP AXPlatformNodeWin::get_childIndex(long row, 1023 STDMETHODIMP AXPlatformNodeWin::get_childIndex(long row,
998 long column, 1024 long column,
999 long* cell_index) { 1025 long* cell_index) {
1026 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_INDEX);
1000 if (!cell_index) 1027 if (!cell_index)
1001 return E_INVALIDARG; 1028 return E_INVALIDARG;
1002 1029
1003 auto* cell = GetTableCell(static_cast<int>(row), static_cast<int>(column)); 1030 auto* cell = GetTableCell(static_cast<int>(row), static_cast<int>(column));
1004 if (cell) { 1031 if (cell) {
1005 *cell_index = static_cast<LONG>(cell->GetTableCellIndex()); 1032 *cell_index = static_cast<LONG>(cell->GetTableCellIndex());
1006 return S_OK; 1033 return S_OK;
1007 } 1034 }
1008 1035
1009 *cell_index = 0; 1036 *cell_index = 0;
1010 return E_INVALIDARG; 1037 return E_INVALIDARG;
1011 } 1038 }
1012 1039
1013 STDMETHODIMP AXPlatformNodeWin::get_columnDescription(long column, 1040 STDMETHODIMP AXPlatformNodeWin::get_columnDescription(long column,
1014 BSTR* description) { 1041 BSTR* description) {
1042 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_DESCRIPTION);
1015 if (!description) 1043 if (!description)
1016 return E_INVALIDARG; 1044 return E_INVALIDARG;
1017 1045
1018 int columns = GetTableColumnCount(); 1046 int columns = GetTableColumnCount();
1019 if (column < 0 || column >= columns) 1047 if (column < 0 || column >= columns)
1020 return E_INVALIDARG; 1048 return E_INVALIDARG;
1021 1049
1022 int rows = GetTableRowCount(); 1050 int rows = GetTableRowCount();
1023 if (rows <= 0) { 1051 if (rows <= 0) {
1024 *description = nullptr; 1052 *description = nullptr;
(...skipping 17 matching lines...) Expand all
1042 } 1070 }
1043 } 1071 }
1044 1072
1045 *description = nullptr; 1073 *description = nullptr;
1046 return S_FALSE; 1074 return S_FALSE;
1047 } 1075 }
1048 1076
1049 STDMETHODIMP AXPlatformNodeWin::get_columnExtentAt(long row, 1077 STDMETHODIMP AXPlatformNodeWin::get_columnExtentAt(long row,
1050 long column, 1078 long column,
1051 long* n_columns_spanned) { 1079 long* n_columns_spanned) {
1080 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_EXTENT_AT);
1052 if (!n_columns_spanned) 1081 if (!n_columns_spanned)
1053 return E_INVALIDARG; 1082 return E_INVALIDARG;
1054 1083
1055 auto* cell = GetTableCell(static_cast<int>(row), static_cast<int>(column)); 1084 auto* cell = GetTableCell(static_cast<int>(row), static_cast<int>(column));
1056 if (!cell) 1085 if (!cell)
1057 return E_INVALIDARG; 1086 return E_INVALIDARG;
1058 1087
1059 *n_columns_spanned = cell->GetTableColumnSpan(); 1088 *n_columns_spanned = cell->GetTableColumnSpan();
1060 return S_OK; 1089 return S_OK;
1061 } 1090 }
1062 1091
1063 STDMETHODIMP AXPlatformNodeWin::get_columnHeader( 1092 STDMETHODIMP AXPlatformNodeWin::get_columnHeader(
1064 IAccessibleTable** accessible_table, 1093 IAccessibleTable** accessible_table,
1065 long* starting_row_index) { 1094 long* starting_row_index) {
1095 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_HEADER);
1066 // TODO(dmazzoni): implement 1096 // TODO(dmazzoni): implement
1067 return E_NOTIMPL; 1097 return E_NOTIMPL;
1068 } 1098 }
1069 1099
1070 STDMETHODIMP AXPlatformNodeWin::get_columnIndex(long cell_index, 1100 STDMETHODIMP AXPlatformNodeWin::get_columnIndex(long cell_index,
1071 long* column_index) { 1101 long* column_index) {
1102 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_INDEX);
1072 if (!column_index) 1103 if (!column_index)
1073 return E_INVALIDARG; 1104 return E_INVALIDARG;
1074 1105
1075 auto* cell = GetTableCell(cell_index); 1106 auto* cell = GetTableCell(cell_index);
1076 if (!cell) 1107 if (!cell)
1077 return E_INVALIDARG; 1108 return E_INVALIDARG;
1078 *column_index = cell->GetTableColumn(); 1109 *column_index = cell->GetTableColumn();
1079 return S_OK; 1110 return S_OK;
1080 } 1111 }
1081 1112
1082 STDMETHODIMP AXPlatformNodeWin::get_nColumns(long* column_count) { 1113 STDMETHODIMP AXPlatformNodeWin::get_nColumns(long* column_count) {
1114 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_COLUMNS);
1083 if (!column_count) 1115 if (!column_count)
1084 return E_INVALIDARG; 1116 return E_INVALIDARG;
1085 1117
1086 *column_count = GetTableColumnCount(); 1118 *column_count = GetTableColumnCount();
1087 return S_OK; 1119 return S_OK;
1088 } 1120 }
1089 1121
1090 STDMETHODIMP AXPlatformNodeWin::get_nRows(long* row_count) { 1122 STDMETHODIMP AXPlatformNodeWin::get_nRows(long* row_count) {
1123 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_ROWS);
1091 if (!row_count) 1124 if (!row_count)
1092 return E_INVALIDARG; 1125 return E_INVALIDARG;
1093 1126
1094 *row_count = GetTableRowCount(); 1127 *row_count = GetTableRowCount();
1095 return S_OK; 1128 return S_OK;
1096 } 1129 }
1097 1130
1098 STDMETHODIMP AXPlatformNodeWin::get_nSelectedChildren(long* cell_count) { 1131 STDMETHODIMP AXPlatformNodeWin::get_nSelectedChildren(long* cell_count) {
1132 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_CHILDREN);
1099 if (!cell_count) 1133 if (!cell_count)
1100 return E_INVALIDARG; 1134 return E_INVALIDARG;
1101 1135
1102 // TODO(dmazzoni): add support for selected cells/rows/columns in tables. 1136 // TODO(dmazzoni): add support for selected cells/rows/columns in tables.
1103 *cell_count = 0; 1137 *cell_count = 0;
1104 return S_FALSE; 1138 return S_FALSE;
1105 } 1139 }
1106 1140
1107 STDMETHODIMP AXPlatformNodeWin::get_nSelectedColumns(long* column_count) { 1141 STDMETHODIMP AXPlatformNodeWin::get_nSelectedColumns(long* column_count) {
1142 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_COLUMNS);
1108 if (!column_count) 1143 if (!column_count)
1109 return E_INVALIDARG; 1144 return E_INVALIDARG;
1110 1145
1111 *column_count = 0; 1146 *column_count = 0;
1112 return S_FALSE; 1147 return S_FALSE;
1113 } 1148 }
1114 1149
1115 STDMETHODIMP AXPlatformNodeWin::get_nSelectedRows(long* row_count) { 1150 STDMETHODIMP AXPlatformNodeWin::get_nSelectedRows(long* row_count) {
1151 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_ROWS);
1116 if (!row_count) 1152 if (!row_count)
1117 return E_INVALIDARG; 1153 return E_INVALIDARG;
1118 1154
1119 *row_count = 0; 1155 *row_count = 0;
1120 return S_FALSE; 1156 return S_FALSE;
1121 } 1157 }
1122 1158
1123 STDMETHODIMP AXPlatformNodeWin::get_rowDescription(long row, 1159 STDMETHODIMP AXPlatformNodeWin::get_rowDescription(long row,
1124 BSTR* description) { 1160 BSTR* description) {
1161 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_DESCRIPTION);
1125 if (!description) 1162 if (!description)
1126 return E_INVALIDARG; 1163 return E_INVALIDARG;
1127 1164
1128 if (row < 0 || row >= GetTableRowCount()) 1165 if (row < 0 || row >= GetTableRowCount())
1129 return E_INVALIDARG; 1166 return E_INVALIDARG;
1130 1167
1131 int columns = GetTableColumnCount(); 1168 int columns = GetTableColumnCount();
1132 if (columns <= 0) { 1169 if (columns <= 0) {
1133 *description = nullptr; 1170 *description = nullptr;
1134 return S_FALSE; 1171 return S_FALSE;
(...skipping 15 matching lines...) Expand all
1150 } 1187 }
1151 } 1188 }
1152 1189
1153 *description = nullptr; 1190 *description = nullptr;
1154 return S_FALSE; 1191 return S_FALSE;
1155 } 1192 }
1156 1193
1157 STDMETHODIMP AXPlatformNodeWin::get_rowExtentAt(long row, 1194 STDMETHODIMP AXPlatformNodeWin::get_rowExtentAt(long row,
1158 long column, 1195 long column,
1159 long* n_rows_spanned) { 1196 long* n_rows_spanned) {
1197 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_EXTENT_AT);
1160 if (!n_rows_spanned) 1198 if (!n_rows_spanned)
1161 return E_INVALIDARG; 1199 return E_INVALIDARG;
1162 1200
1163 auto* cell = GetTableCell(row, column); 1201 auto* cell = GetTableCell(row, column);
1164 if (!cell) 1202 if (!cell)
1165 return E_INVALIDARG; 1203 return E_INVALIDARG;
1166 1204
1167 *n_rows_spanned = GetTableRowSpan(); 1205 *n_rows_spanned = GetTableRowSpan();
1168 return S_OK; 1206 return S_OK;
1169 } 1207 }
1170 1208
1171 STDMETHODIMP AXPlatformNodeWin::get_rowHeader( 1209 STDMETHODIMP AXPlatformNodeWin::get_rowHeader(
1172 IAccessibleTable** accessible_table, 1210 IAccessibleTable** accessible_table,
1173 long* starting_column_index) { 1211 long* starting_column_index) {
1212 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_HEADER);
1174 // TODO(dmazzoni): implement 1213 // TODO(dmazzoni): implement
1175 return E_NOTIMPL; 1214 return E_NOTIMPL;
1176 } 1215 }
1177 1216
1178 STDMETHODIMP AXPlatformNodeWin::get_rowIndex(long cell_index, long* row_index) { 1217 STDMETHODIMP AXPlatformNodeWin::get_rowIndex(long cell_index, long* row_index) {
1179 if (!row_index) 1218 if (!row_index)
1180 return E_INVALIDARG; 1219 return E_INVALIDARG;
1181 1220
1182 auto* cell = GetTableCell(cell_index); 1221 auto* cell = GetTableCell(cell_index);
1183 if (!cell) 1222 if (!cell)
(...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 if (container && container->GetData().role == ui::AX_ROLE_GROUP) 2799 if (container && container->GetData().role == ui::AX_ROLE_GROUP)
2761 container = FromNativeViewAccessible(container->GetParent()); 2800 container = FromNativeViewAccessible(container->GetParent());
2762 2801
2763 if (!container) 2802 if (!container)
2764 return false; 2803 return false;
2765 2804
2766 return container->GetData().role == ui::AX_ROLE_TREE_GRID; 2805 return container->GetData().role == ui::AX_ROLE_TREE_GRID;
2767 } 2806 }
2768 2807
2769 } // namespace ui 2808 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698