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

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

Issue 2964313002: Converts accNavigate over to the AXPlatformNode code. (Closed)
Patch Set: are -> is 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
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
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/win/enum_variant.h" 16 #include "base/win/enum_variant.h"
17 #include "base/win/scoped_comptr.h" 17 #include "base/win/scoped_comptr.h"
18 #include "base/win/scoped_variant.h" 18 #include "base/win/scoped_variant.h"
19 #include "third_party/iaccessible2/ia2_api_all.h" 19 #include "third_party/iaccessible2/ia2_api_all.h"
20 #include "third_party/skia/include/core/SkColor.h" 20 #include "third_party/skia/include/core/SkColor.h"
21 #include "ui/accessibility/ax_action_data.h" 21 #include "ui/accessibility/ax_action_data.h"
22 #include "ui/accessibility/ax_node_data.h" 22 #include "ui/accessibility/ax_node_data.h"
23 #include "ui/accessibility/ax_role_properties.h"
23 #include "ui/accessibility/ax_text_utils.h" 24 #include "ui/accessibility/ax_text_utils.h"
24 #include "ui/accessibility/ax_tree_data.h" 25 #include "ui/accessibility/ax_tree_data.h"
25 #include "ui/accessibility/platform/ax_platform_node_delegate.h" 26 #include "ui/accessibility/platform/ax_platform_node_delegate.h"
26 #include "ui/accessibility/platform/ax_platform_node_win.h" 27 #include "ui/accessibility/platform/ax_platform_node_win.h"
27 #include "ui/base/win/atl_module.h" 28 #include "ui/base/win/atl_module.h"
28 #include "ui/gfx/geometry/rect_conversions.h" 29 #include "ui/gfx/geometry/rect_conversions.h"
29 30
30 // 31 //
31 // Macros to use at the top of any AXPlatformNodeWin function that implements 32 // Macros to use at the top of any AXPlatformNodeWin function that implements
32 // a COM interface. Because COM objects are reference counted and clients 33 // a COM interface. Because COM objects are reference counted and clients
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(start, end, target); 355 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(start, end, target);
355 end->vt = VT_EMPTY; 356 end->vt = VT_EMPTY;
356 if ((nav_dir == NAVDIR_FIRSTCHILD || nav_dir == NAVDIR_LASTCHILD) && 357 if ((nav_dir == NAVDIR_FIRSTCHILD || nav_dir == NAVDIR_LASTCHILD) &&
357 V_VT(&start) == VT_I4 && V_I4(&start) != CHILDID_SELF) { 358 V_VT(&start) == VT_I4 && V_I4(&start) != CHILDID_SELF) {
358 // MSAA states that navigating to first/last child can only be from self. 359 // MSAA states that navigating to first/last child can only be from self.
359 return E_INVALIDARG; 360 return E_INVALIDARG;
360 } 361 }
361 362
362 IAccessible* result = nullptr; 363 IAccessible* result = nullptr;
363 switch (nav_dir) { 364 switch (nav_dir) {
364 case NAVDIR_DOWN:
365 case NAVDIR_UP:
366 case NAVDIR_LEFT:
367 case NAVDIR_RIGHT:
368 // These directions are not implemented except in tables.
369 return E_NOTIMPL;
370 365
371 case NAVDIR_FIRSTCHILD: 366 case NAVDIR_FIRSTCHILD:
372 if (delegate_->GetChildCount() > 0) 367 if (delegate_->GetChildCount() > 0)
373 result = delegate_->ChildAtIndex(0); 368 result = delegate_->ChildAtIndex(0);
374 break; 369 break;
375 370
376 case NAVDIR_LASTCHILD: 371 case NAVDIR_LASTCHILD:
377 if (delegate_->GetChildCount() > 0) 372 if (delegate_->GetChildCount() > 0)
378 result = delegate_->ChildAtIndex(delegate_->GetChildCount() - 1); 373 result = delegate_->ChildAtIndex(delegate_->GetChildCount() - 1);
379 break; 374 break;
380 375
381 case NAVDIR_NEXT: { 376 case NAVDIR_NEXT: {
382 AXPlatformNodeBase* next = target->GetNextSibling(); 377 AXPlatformNodeBase* next = target->GetNextSibling();
383 if (next) 378 if (next)
384 result = next->GetNativeViewAccessible(); 379 result = next->GetNativeViewAccessible();
385 break; 380 break;
386 } 381 }
387 382
388 case NAVDIR_PREVIOUS: { 383 case NAVDIR_PREVIOUS: {
389 AXPlatformNodeBase* previous = target->GetPreviousSibling(); 384 AXPlatformNodeBase* previous = target->GetPreviousSibling();
390 if (previous) 385 if (previous)
391 result = previous->GetNativeViewAccessible(); 386 result = previous->GetNativeViewAccessible();
392 break; 387 break;
393 } 388 }
389
390 case NAVDIR_DOWN: {
391 // This direction is not implemented except in tables.
392 if (!ui::IsTableLikeRole(GetData().role) &&
393 !ui::IsCellOrTableHeaderRole(GetData().role))
394 return E_NOTIMPL;
395
396 AXPlatformNodeBase* next = target->GetTableCell(
397 GetTableRow() + GetTableRowSpan(), GetTableColumn());
398 if (!next)
399 return S_OK;
400
401 result = next->GetNativeViewAccessible();
402 break;
403 }
404
405 case NAVDIR_UP: {
406 // This direction is not implemented except in tables.
407 if (!ui::IsTableLikeRole(GetData().role) &&
408 !ui::IsCellOrTableHeaderRole(GetData().role))
409 return E_NOTIMPL;
410
411 AXPlatformNodeBase* next =
412 target->GetTableCell(GetTableRow() - 1, GetTableColumn());
413 if (!next)
414 return S_OK;
415
416 result = next->GetNativeViewAccessible();
417 break;
418 }
419
420 case NAVDIR_LEFT: {
421 // This direction is not implemented except in tables.
422 if (!ui::IsTableLikeRole(GetData().role) &&
423 !ui::IsCellOrTableHeaderRole(GetData().role))
424 return E_NOTIMPL;
425
426 AXPlatformNodeBase* next =
427 target->GetTableCell(GetTableRow(), GetTableColumn() - 1);
428 if (!next)
429 return S_OK;
430
431 result = next->GetNativeViewAccessible();
432 break;
433 }
434
435 case NAVDIR_RIGHT: {
436 // This direction is not implemented except in tables.
437
438 if (!ui::IsTableLikeRole(GetData().role) &&
439 !ui::IsCellOrTableHeaderRole(GetData().role))
440 return E_NOTIMPL;
441
442 AXPlatformNodeBase* next = target->GetTableCell(
443 GetTableRow(), GetTableColumn() + GetTableColumnSpan());
444 if (!next)
445 return S_OK;
446
447 result = next->GetNativeViewAccessible();
448 break;
449 }
394 } 450 }
395 451
396 if (!result) 452 if (!result)
397 return S_FALSE; 453 return S_FALSE;
398 454
399 end->vt = VT_DISPATCH; 455 end->vt = VT_DISPATCH;
400 end->pdispVal = result; 456 end->pdispVal = result;
401 // Always increment ref when returning a reference to a COM object. 457 // Always increment ref when returning a reference to a COM object.
402 end->pdispVal->AddRef(); 458 end->pdispVal->AddRef();
403 459
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 1941
1886 AXPlatformNodeBase* base = 1942 AXPlatformNodeBase* base =
1887 FromNativeViewAccessible(node->GetNativeViewAccessible()); 1943 FromNativeViewAccessible(node->GetNativeViewAccessible());
1888 if (base && !IsDescendant(base)) 1944 if (base && !IsDescendant(base))
1889 base = nullptr; 1945 base = nullptr;
1890 1946
1891 return static_cast<AXPlatformNodeWin*>(base); 1947 return static_cast<AXPlatformNodeWin*>(base);
1892 } 1948 }
1893 1949
1894 } // namespace ui 1950 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_delegate.h ('k') | ui/accessibility/platform/ax_system_caret_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698