Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 15 matching lines...) Expand all Loading... | |
| 26 // a COM interface. Because COM objects are reference counted and clients | 26 // a COM interface. Because COM objects are reference counted and clients |
| 27 // are completely untrusted, it's important to always first check that our | 27 // are completely untrusted, it's important to always first check that our |
| 28 // object is still valid, and then check that all pointer arguments are | 28 // object is still valid, and then check that all pointer arguments are |
| 29 // not NULL. | 29 // not NULL. |
| 30 // | 30 // |
| 31 | 31 |
| 32 #define COM_OBJECT_VALIDATE() \ | 32 #define COM_OBJECT_VALIDATE() \ |
| 33 if (!delegate_) \ | 33 if (!delegate_) \ |
| 34 return E_FAIL; | 34 return E_FAIL; |
| 35 #define COM_OBJECT_VALIDATE_1_ARG(arg) \ | 35 #define COM_OBJECT_VALIDATE_1_ARG(arg) \ |
| 36 if (!delegate_) return E_FAIL; \ | 36 if (!delegate_) \ |
| 37 if (!arg) return E_INVALIDARG | 37 return E_FAIL; \ |
| 38 if (!arg) \ | |
| 39 return E_INVALIDARG; | |
| 38 #define COM_OBJECT_VALIDATE_2_ARGS(arg1, arg2) \ | 40 #define COM_OBJECT_VALIDATE_2_ARGS(arg1, arg2) \ |
| 39 if (!delegate_) return E_FAIL; \ | 41 if (!delegate_) \ |
| 40 if (!arg1) return E_INVALIDARG; \ | 42 return E_FAIL; \ |
| 41 if (!arg2) return E_INVALIDARG | 43 if (!arg1) \ |
| 44 return E_INVALIDARG; \ | |
| 45 if (!arg2) \ | |
| 46 return E_INVALIDARG; | |
| 42 #define COM_OBJECT_VALIDATE_3_ARGS(arg1, arg2, arg3) \ | 47 #define COM_OBJECT_VALIDATE_3_ARGS(arg1, arg2, arg3) \ |
| 43 if (!delegate_) return E_FAIL; \ | 48 if (!delegate_) \ |
| 44 if (!arg1) return E_INVALIDARG; \ | 49 return E_FAIL; \ |
| 45 if (!arg2) return E_INVALIDARG; \ | 50 if (!arg1) \ |
| 46 if (!arg3) return E_INVALIDARG | 51 return E_INVALIDARG; \ |
| 52 if (!arg2) \ | |
| 53 return E_INVALIDARG; \ | |
| 54 if (!arg3) \ | |
| 55 return E_INVALIDARG; | |
| 47 #define COM_OBJECT_VALIDATE_4_ARGS(arg1, arg2, arg3, arg4) \ | 56 #define COM_OBJECT_VALIDATE_4_ARGS(arg1, arg2, arg3, arg4) \ |
| 48 if (!delegate_) return E_FAIL; \ | 57 if (!delegate_) \ |
| 49 if (!arg1) return E_INVALIDARG; \ | 58 return E_FAIL; \ |
| 50 if (!arg2) return E_INVALIDARG; \ | 59 if (!arg1) \ |
| 51 if (!arg3) return E_INVALIDARG; \ | 60 return E_INVALIDARG; \ |
| 52 if (!arg4) return E_INVALIDARG | 61 if (!arg2) \ |
| 62 return E_INVALIDARG; \ | |
| 63 if (!arg3) \ | |
| 64 return E_INVALIDARG; \ | |
| 65 if (!arg4) \ | |
| 66 return E_INVALIDARG; | |
| 53 #define COM_OBJECT_VALIDATE_VAR_ID(var_id) \ | 67 #define COM_OBJECT_VALIDATE_VAR_ID(var_id) \ |
|
dmazzoni
2017/04/18 04:25:34
I think you can get rid of all of the COM_OBJECT_V
| |
| 54 if (!delegate_) return E_FAIL; \ | 68 if (!delegate_) \ |
| 55 if (!IsValidId(var_id)) return E_INVALIDARG | 69 return E_FAIL; \ |
| 70 if (!IsValidId(var_id)) \ | |
| 71 return E_INVALIDARG; | |
| 72 | |
| 56 #define COM_OBJECT_VALIDATE_VAR_ID_1_ARG(var_id, arg) \ | 73 #define COM_OBJECT_VALIDATE_VAR_ID_1_ARG(var_id, arg) \ |
| 57 if (!delegate_) return E_FAIL; \ | 74 if (!delegate_) \ |
| 58 if (!IsValidId(var_id)) return E_INVALIDARG; \ | 75 return E_FAIL; \ |
| 59 if (!arg) return E_INVALIDARG | 76 if (!IsValidId(var_id)) \ |
| 77 return E_INVALIDARG; \ | |
| 78 if (!arg) \ | |
| 79 return E_INVALIDARG; | |
| 60 #define COM_OBJECT_VALIDATE_VAR_ID_2_ARGS(var_id, arg1, arg2) \ | 80 #define COM_OBJECT_VALIDATE_VAR_ID_2_ARGS(var_id, arg1, arg2) \ |
| 61 if (!delegate_) return E_FAIL; \ | 81 if (!delegate_) \ |
| 62 if (!IsValidId(var_id)) return E_INVALIDARG; \ | 82 return E_FAIL; \ |
| 63 if (!arg1) return E_INVALIDARG; \ | 83 if (!IsValidId(var_id)) \ |
| 64 if (!arg2) return E_INVALIDARG | 84 return E_INVALIDARG; \ |
| 85 if (!arg1) \ | |
| 86 return E_INVALIDARG; \ | |
| 87 if (!arg2) \ | |
| 88 return E_INVALIDARG; | |
| 65 #define COM_OBJECT_VALIDATE_VAR_ID_3_ARGS(var_id, arg1, arg2, arg3) \ | 89 #define COM_OBJECT_VALIDATE_VAR_ID_3_ARGS(var_id, arg1, arg2, arg3) \ |
| 66 if (!delegate_) return E_FAIL; \ | 90 if (!delegate_) \ |
| 67 if (!IsValidId(var_id)) return E_INVALIDARG; \ | 91 return E_FAIL; \ |
| 68 if (!arg1) return E_INVALIDARG; \ | 92 if (!IsValidId(var_id)) \ |
| 69 if (!arg2) return E_INVALIDARG; \ | 93 return E_INVALIDARG; \ |
| 70 if (!arg3) return E_INVALIDARG | 94 if (!arg1) \ |
| 95 return E_INVALIDARG; \ | |
| 96 if (!arg2) \ | |
| 97 return E_INVALIDARG; \ | |
| 98 if (!arg3) \ | |
| 99 return E_INVALIDARG; | |
| 71 #define COM_OBJECT_VALIDATE_VAR_ID_4_ARGS(var_id, arg1, arg2, arg3, arg4) \ | 100 #define COM_OBJECT_VALIDATE_VAR_ID_4_ARGS(var_id, arg1, arg2, arg3, arg4) \ |
| 72 if (!delegate_) return E_FAIL; \ | 101 if (!delegate_) \ |
| 73 if (!IsValidId(var_id)) return E_INVALIDARG; \ | 102 return E_FAIL; \ |
| 74 if (!arg1) return E_INVALIDARG; \ | 103 if (!IsValidId(var_id)) \ |
| 75 if (!arg2) return E_INVALIDARG; \ | 104 return E_INVALIDARG; \ |
| 76 if (!arg3) return E_INVALIDARG; \ | 105 if (!arg1) \ |
| 77 if (!arg4) return E_INVALIDARG | 106 return E_INVALIDARG; \ |
| 107 if (!arg2) \ | |
| 108 return E_INVALIDARG; \ | |
| 109 if (!arg3) \ | |
| 110 return E_INVALIDARG; \ | |
| 111 if (!arg4) \ | |
| 112 return E_INVALIDARG; | |
| 113 #define COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_id, target) \ | |
| 114 if (!delegate_) \ | |
| 115 return E_FAIL; \ | |
| 116 target = GetTargetFromChildID(var_id); \ | |
| 117 if (!target) \ | |
| 118 return E_INVALIDARG; \ | |
| 119 if (!target->delegate_) \ | |
| 120 return E_INVALIDARG; | |
| 121 #define COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, arg, target) \ | |
| 122 if (!delegate_) \ | |
| 123 return E_FAIL; \ | |
| 124 if (!arg) \ | |
| 125 return E_INVALIDARG; \ | |
| 126 target = GetTargetFromChildID(var_id); \ | |
| 127 if (!target) \ | |
| 128 return E_INVALIDARG; \ | |
| 129 if (!target->delegate_) \ | |
| 130 return E_INVALIDARG; | |
| 131 #define COM_OBJECT_VALIDATE_VAR_ID_2_ARGS_AND_GET_TARGET(var_id, arg1, arg2, \ | |
| 132 target) \ | |
| 133 if (!delegate_) \ | |
| 134 return E_FAIL; \ | |
| 135 if (!arg1) \ | |
| 136 return E_INVALIDARG; \ | |
| 137 if (!arg2) \ | |
| 138 return E_INVALIDARG; \ | |
| 139 target = GetTargetFromChildID(var_id); \ | |
| 140 if (!target) \ | |
| 141 return E_INVALIDARG; \ | |
| 142 if (!target->delegate_) \ | |
| 143 return E_INVALIDARG; | |
| 144 #define COM_OBJECT_VALIDATE_VAR_ID_3_ARGS_AND_GET_TARGET(var_id, arg1, arg2, \ | |
| 145 arg3, target) \ | |
| 146 if (!delegate_) \ | |
| 147 return E_FAIL; \ | |
| 148 if (!arg1) \ | |
| 149 return E_INVALIDARG; \ | |
| 150 if (!arg2) \ | |
| 151 return E_INVALIDARG; \ | |
| 152 if (!arg3) \ | |
| 153 return E_INVALIDARG; \ | |
| 154 target = GetTargetFromChildID(var_id); \ | |
| 155 if (!target) \ | |
| 156 return E_INVALIDARG; \ | |
| 157 if (!target->delegate_) \ | |
| 158 return E_INVALIDARG; | |
| 159 #define COM_OBJECT_VALIDATE_VAR_ID_4_ARGS_AND_GET_TARGET(var_id, arg1, arg2, \ | |
| 160 arg3, arg4, target) \ | |
| 161 if (!delegate_) \ | |
| 162 return E_FAIL; \ | |
| 163 if (!arg1) \ | |
| 164 return E_INVALIDARG; \ | |
| 165 if (!arg2) \ | |
| 166 return E_INVALIDARG; \ | |
| 167 if (!arg3) \ | |
| 168 return E_INVALIDARG; \ | |
| 169 if (!arg4) \ | |
| 170 return E_INVALIDARG; \ | |
| 171 target = GetTargetFromChildID(var_id); \ | |
| 172 if (!target) \ | |
| 173 return E_INVALIDARG; \ | |
| 174 if (!target->delegate_) \ | |
| 175 return E_INVALIDARG; | |
| 78 | 176 |
| 79 namespace ui { | 177 namespace ui { |
| 80 | 178 |
| 81 namespace { | 179 namespace { |
| 82 | 180 |
| 83 typedef base::hash_set<AXPlatformNodeWin*> AXPlatformNodeWinSet; | 181 typedef base::hash_set<AXPlatformNodeWin*> AXPlatformNodeWinSet; |
| 84 // Set of all AXPlatformNodeWin objects that were the target of an | 182 // Set of all AXPlatformNodeWin objects that were the target of an |
| 85 // alert event. | 183 // alert event. |
| 86 base::LazyInstance<AXPlatformNodeWinSet>::DestructorAtExit g_alert_targets = | 184 base::LazyInstance<AXPlatformNodeWinSet>::DestructorAtExit g_alert_targets = |
| 87 LAZY_INSTANCE_INITIALIZER; | 185 LAZY_INSTANCE_INITIALIZER; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 HRESULT hr = CComObject<AXPlatformNodeWin>::CreateInstance(&instance); | 219 HRESULT hr = CComObject<AXPlatformNodeWin>::CreateInstance(&instance); |
| 122 DCHECK(SUCCEEDED(hr)); | 220 DCHECK(SUCCEEDED(hr)); |
| 123 instance->Init(delegate); | 221 instance->Init(delegate); |
| 124 instance->AddRef(); | 222 instance->AddRef(); |
| 125 return instance; | 223 return instance; |
| 126 } | 224 } |
| 127 | 225 |
| 128 // static | 226 // static |
| 129 AXPlatformNode* AXPlatformNode::FromNativeViewAccessible( | 227 AXPlatformNode* AXPlatformNode::FromNativeViewAccessible( |
| 130 gfx::NativeViewAccessible accessible) { | 228 gfx::NativeViewAccessible accessible) { |
| 229 if (!accessible) | |
| 230 return nullptr; | |
| 131 base::win::ScopedComPtr<AXPlatformNodeWin> ax_platform_node; | 231 base::win::ScopedComPtr<AXPlatformNodeWin> ax_platform_node; |
| 132 accessible->QueryInterface(ax_platform_node.Receive()); | 232 accessible->QueryInterface(ax_platform_node.Receive()); |
| 133 return ax_platform_node.get(); | 233 return ax_platform_node.get(); |
| 134 } | 234 } |
| 135 | 235 |
| 136 // | 236 // |
| 137 // AXPlatformNodeWin | 237 // AXPlatformNodeWin |
| 138 // | 238 // |
| 139 | 239 |
| 140 AXPlatformNodeWin::AXPlatformNodeWin() { | 240 AXPlatformNodeWin::AXPlatformNodeWin() { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 if (S_OK == result && child->vt == VT_I4 && child->lVal == CHILDID_SELF) { | 345 if (S_OK == result && child->vt == VT_I4 && child->lVal == CHILDID_SELF) { |
| 246 child->vt = VT_DISPATCH; | 346 child->vt = VT_DISPATCH; |
| 247 child->pdispVal = hit_child; | 347 child->pdispVal = hit_child; |
| 248 // Always increment ref when returning a reference to a COM object. | 348 // Always increment ref when returning a reference to a COM object. |
| 249 child->pdispVal->AddRef(); | 349 child->pdispVal->AddRef(); |
| 250 } | 350 } |
| 251 return result; | 351 return result; |
| 252 } | 352 } |
| 253 | 353 |
| 254 HRESULT AXPlatformNodeWin::accDoDefaultAction(VARIANT var_id) { | 354 HRESULT AXPlatformNodeWin::accDoDefaultAction(VARIANT var_id) { |
| 255 COM_OBJECT_VALIDATE_VAR_ID(var_id); | 355 AXPlatformNodeWin* target; |
| 356 COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_id, target); | |
| 256 AXActionData data; | 357 AXActionData data; |
| 257 data.action = ui::AX_ACTION_DO_DEFAULT; | 358 data.action = ui::AX_ACTION_DO_DEFAULT; |
| 258 if (delegate_->AccessibilityPerformAction(data)) | 359 |
| 360 if (target->delegate_->AccessibilityPerformAction(data)) | |
| 259 return S_OK; | 361 return S_OK; |
| 260 return E_FAIL; | 362 return E_FAIL; |
| 261 } | 363 } |
| 262 | 364 |
| 263 STDMETHODIMP AXPlatformNodeWin::accLocation( | 365 STDMETHODIMP AXPlatformNodeWin::accLocation( |
| 264 LONG* x_left, LONG* y_top, LONG* width, LONG* height, VARIANT var_id) { | 366 LONG* x_left, LONG* y_top, LONG* width, LONG* height, VARIANT var_id) { |
| 265 COM_OBJECT_VALIDATE_VAR_ID_4_ARGS(var_id, x_left, y_top, width, height); | 367 AXPlatformNodeWin* target; |
| 266 gfx::Rect bounds = delegate_->GetScreenBoundsRect(); | 368 COM_OBJECT_VALIDATE_VAR_ID_4_ARGS_AND_GET_TARGET(var_id, x_left, y_top, width, |
| 369 height, target); | |
| 370 | |
| 371 gfx::Rect bounds = target->delegate_->GetScreenBoundsRect(); | |
| 267 *x_left = bounds.x(); | 372 *x_left = bounds.x(); |
| 268 *y_top = bounds.y(); | 373 *y_top = bounds.y(); |
| 269 *width = bounds.width(); | 374 *width = bounds.width(); |
| 270 *height = bounds.height(); | 375 *height = bounds.height(); |
| 271 | 376 |
| 272 if (bounds.IsEmpty()) | 377 if (bounds.IsEmpty()) |
| 273 return S_FALSE; | 378 return S_FALSE; |
| 274 | 379 |
| 275 return S_OK; | 380 return S_OK; |
| 276 } | 381 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 end->vt = VT_DISPATCH; | 435 end->vt = VT_DISPATCH; |
| 331 end->pdispVal = result; | 436 end->pdispVal = result; |
| 332 // Always increment ref when returning a reference to a COM object. | 437 // Always increment ref when returning a reference to a COM object. |
| 333 end->pdispVal->AddRef(); | 438 end->pdispVal->AddRef(); |
| 334 | 439 |
| 335 return S_OK; | 440 return S_OK; |
| 336 } | 441 } |
| 337 | 442 |
| 338 STDMETHODIMP AXPlatformNodeWin::get_accChild(VARIANT var_child, | 443 STDMETHODIMP AXPlatformNodeWin::get_accChild(VARIANT var_child, |
| 339 IDispatch** disp_child) { | 444 IDispatch** disp_child) { |
| 340 COM_OBJECT_VALIDATE_1_ARG(disp_child); | 445 *disp_child = nullptr; |
| 341 LONG child_id = V_I4(&var_child); | 446 AXPlatformNodeWin* target; |
| 342 if (child_id == CHILDID_SELF) { | 447 COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_child, target); |
| 343 *disp_child = this; | |
| 344 (*disp_child)->AddRef(); | |
| 345 return S_OK; | |
| 346 } | |
| 347 | 448 |
| 348 if (child_id >= 1 && child_id <= delegate_->GetChildCount()) { | 449 *disp_child = target; |
| 349 // Positive child ids are a 1-based child index, used by clients | 450 (*disp_child)->AddRef(); |
| 350 // that want to enumerate all immediate children. | 451 return S_OK; |
| 351 *disp_child = delegate_->ChildAtIndex(child_id - 1); | |
| 352 if (!(*disp_child)) | |
| 353 return E_INVALIDARG; | |
| 354 (*disp_child)->AddRef(); | |
| 355 return S_OK; | |
| 356 } | |
| 357 | |
| 358 if (child_id >= 0) | |
| 359 return E_INVALIDARG; | |
| 360 | |
| 361 // Negative child ids can be used to map to any descendant. | |
| 362 AXPlatformNodeWin* child = static_cast<AXPlatformNodeWin*>( | |
| 363 GetFromUniqueId(-child_id)); | |
| 364 if (child && !IsDescendant(child)) | |
| 365 child = nullptr; | |
| 366 | |
| 367 if (child) { | |
| 368 *disp_child = child; | |
| 369 (*disp_child)->AddRef(); | |
| 370 return S_OK; | |
| 371 } | |
| 372 | |
| 373 *disp_child = nullptr; | |
| 374 return E_INVALIDARG; | |
| 375 } | 452 } |
| 376 | 453 |
| 377 STDMETHODIMP AXPlatformNodeWin::get_accChildCount(LONG* child_count) { | 454 STDMETHODIMP AXPlatformNodeWin::get_accChildCount(LONG* child_count) { |
| 378 COM_OBJECT_VALIDATE_1_ARG(child_count); | 455 COM_OBJECT_VALIDATE_1_ARG(child_count); |
| 379 *child_count = delegate_->GetChildCount(); | 456 *child_count = delegate_->GetChildCount(); |
| 380 return S_OK; | 457 return S_OK; |
| 381 } | 458 } |
| 382 | 459 |
| 383 STDMETHODIMP AXPlatformNodeWin::get_accDefaultAction( | 460 STDMETHODIMP AXPlatformNodeWin::get_accDefaultAction( |
| 384 VARIANT var_id, BSTR* def_action) { | 461 VARIANT var_id, BSTR* def_action) { |
| 385 COM_OBJECT_VALIDATE_VAR_ID_1_ARG(var_id, def_action); | 462 AXPlatformNodeWin* target; |
| 463 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, def_action, target); | |
| 464 | |
| 386 int action; | 465 int action; |
| 387 if (!GetIntAttribute(AX_ATTR_ACTION, &action)) { | 466 if (!target->GetIntAttribute(AX_ATTR_ACTION, &action)) { |
| 388 *def_action = nullptr; | 467 *def_action = nullptr; |
| 389 return S_FALSE; | 468 return S_FALSE; |
| 390 } | 469 } |
| 391 | 470 |
| 392 base::string16 action_verb = | 471 base::string16 action_verb = |
| 393 ActionToString(static_cast<AXSupportedAction>(action)); | 472 ActionToString(static_cast<AXSupportedAction>(action)); |
| 394 if (action_verb.empty()) { | 473 if (action_verb.empty()) { |
| 395 *def_action = nullptr; | 474 *def_action = nullptr; |
| 396 return S_FALSE; | 475 return S_FALSE; |
| 397 } | 476 } |
| 398 | 477 |
| 399 *def_action = SysAllocString(action_verb.c_str()); | 478 *def_action = SysAllocString(action_verb.c_str()); |
| 400 DCHECK(def_action); | 479 DCHECK(def_action); |
| 401 return S_OK; | 480 return S_OK; |
| 402 } | 481 } |
| 403 | 482 |
| 404 STDMETHODIMP AXPlatformNodeWin::get_accDescription( | 483 STDMETHODIMP AXPlatformNodeWin::get_accDescription( |
| 405 VARIANT var_id, BSTR* desc) { | 484 VARIANT var_id, BSTR* desc) { |
| 406 COM_OBJECT_VALIDATE_VAR_ID_1_ARG(var_id, desc); | 485 AXPlatformNodeWin* target; |
| 407 return GetStringAttributeAsBstr(ui::AX_ATTR_DESCRIPTION, desc); | 486 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, desc, target); |
| 487 | |
| 488 return target->GetStringAttributeAsBstr(ui::AX_ATTR_DESCRIPTION, desc); | |
| 408 } | 489 } |
| 409 | 490 |
| 410 STDMETHODIMP AXPlatformNodeWin::get_accFocus(VARIANT* focus_child) { | 491 STDMETHODIMP AXPlatformNodeWin::get_accFocus(VARIANT* focus_child) { |
| 411 COM_OBJECT_VALIDATE_1_ARG(focus_child); | 492 COM_OBJECT_VALIDATE_1_ARG(focus_child); |
| 412 gfx::NativeViewAccessible focus_accessible = delegate_->GetFocus(); | 493 gfx::NativeViewAccessible focus_accessible = delegate_->GetFocus(); |
| 413 if (focus_accessible == this) { | 494 if (focus_accessible == this) { |
| 414 focus_child->vt = VT_I4; | 495 focus_child->vt = VT_I4; |
| 415 focus_child->lVal = CHILDID_SELF; | 496 focus_child->lVal = CHILDID_SELF; |
| 416 } else if (focus_accessible) { | 497 } else if (focus_accessible) { |
| 417 focus_child->vt = VT_DISPATCH; | 498 focus_child->vt = VT_DISPATCH; |
| 418 focus_child->pdispVal = focus_accessible; | 499 focus_child->pdispVal = focus_accessible; |
| 419 focus_child->pdispVal->AddRef(); | 500 focus_child->pdispVal->AddRef(); |
| 420 return S_OK; | 501 return S_OK; |
| 421 } else { | 502 } else { |
| 422 focus_child->vt = VT_EMPTY; | 503 focus_child->vt = VT_EMPTY; |
| 423 } | 504 } |
| 424 | 505 |
| 425 return S_OK; | 506 return S_OK; |
| 426 } | 507 } |
| 427 | 508 |
| 428 STDMETHODIMP AXPlatformNodeWin::get_accKeyboardShortcut( | 509 STDMETHODIMP AXPlatformNodeWin::get_accKeyboardShortcut( |
| 429 VARIANT var_id, BSTR* acc_key) { | 510 VARIANT var_id, BSTR* acc_key) { |
| 430 COM_OBJECT_VALIDATE_VAR_ID_1_ARG(var_id, acc_key); | 511 AXPlatformNodeWin* target; |
| 431 return GetStringAttributeAsBstr(ui::AX_ATTR_SHORTCUT, acc_key); | 512 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, acc_key, target); |
| 513 | |
| 514 return target->GetStringAttributeAsBstr(ui::AX_ATTR_SHORTCUT, acc_key); | |
| 432 } | 515 } |
| 433 | 516 |
| 434 STDMETHODIMP AXPlatformNodeWin::get_accName( | 517 STDMETHODIMP AXPlatformNodeWin::get_accName( |
| 435 VARIANT var_id, BSTR* name) { | 518 VARIANT var_id, BSTR* name) { |
| 436 COM_OBJECT_VALIDATE_VAR_ID_1_ARG(var_id, name); | 519 AXPlatformNodeWin* target; |
| 437 return GetStringAttributeAsBstr(ui::AX_ATTR_NAME, name); | 520 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, name, target); |
| 521 | |
| 522 return target->GetStringAttributeAsBstr(ui::AX_ATTR_NAME, name); | |
| 438 } | 523 } |
| 439 | 524 |
| 440 STDMETHODIMP AXPlatformNodeWin::get_accParent( | 525 STDMETHODIMP AXPlatformNodeWin::get_accParent( |
| 441 IDispatch** disp_parent) { | 526 IDispatch** disp_parent) { |
| 442 COM_OBJECT_VALIDATE_1_ARG(disp_parent); | 527 COM_OBJECT_VALIDATE_1_ARG(disp_parent); |
| 443 *disp_parent = GetParent(); | 528 *disp_parent = GetParent(); |
| 444 if (*disp_parent) { | 529 if (*disp_parent) { |
| 445 (*disp_parent)->AddRef(); | 530 (*disp_parent)->AddRef(); |
| 446 return S_OK; | 531 return S_OK; |
| 447 } | 532 } |
| 448 | 533 |
| 449 return S_FALSE; | 534 return S_FALSE; |
| 450 } | 535 } |
| 451 | 536 |
| 452 STDMETHODIMP AXPlatformNodeWin::get_accRole( | 537 STDMETHODIMP AXPlatformNodeWin::get_accRole( |
| 453 VARIANT var_id, VARIANT* role) { | 538 VARIANT var_id, VARIANT* role) { |
| 454 COM_OBJECT_VALIDATE_VAR_ID_1_ARG(var_id, role); | 539 AXPlatformNodeWin* target; |
| 540 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, role, target); | |
| 455 role->vt = VT_I4; | 541 role->vt = VT_I4; |
| 456 role->lVal = MSAARole(); | 542 role->lVal = target->MSAARole(); |
| 457 return S_OK; | 543 return S_OK; |
| 458 } | 544 } |
| 459 | 545 |
| 460 STDMETHODIMP AXPlatformNodeWin::get_accState( | 546 STDMETHODIMP AXPlatformNodeWin::get_accState( |
| 461 VARIANT var_id, VARIANT* state) { | 547 VARIANT var_id, VARIANT* state) { |
| 462 COM_OBJECT_VALIDATE_VAR_ID_1_ARG(var_id, state); | 548 AXPlatformNodeWin* target; |
| 549 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, state, target); | |
| 463 state->vt = VT_I4; | 550 state->vt = VT_I4; |
| 464 state->lVal = MSAAState(); | 551 state->lVal = target->MSAAState(); |
| 465 return S_OK; | 552 return S_OK; |
| 466 } | 553 } |
| 467 | 554 |
| 468 STDMETHODIMP AXPlatformNodeWin::get_accHelp( | 555 STDMETHODIMP AXPlatformNodeWin::get_accHelp( |
| 469 VARIANT var_id, BSTR* help) { | 556 VARIANT var_id, BSTR* help) { |
| 470 COM_OBJECT_VALIDATE_VAR_ID_1_ARG(var_id, help); | 557 COM_OBJECT_VALIDATE_VAR_ID_1_ARG(var_id, help); |
| 471 return S_FALSE; | 558 return S_FALSE; |
| 472 } | 559 } |
| 473 | 560 |
| 474 STDMETHODIMP AXPlatformNodeWin::get_accValue(VARIANT var_id, BSTR* value) { | 561 STDMETHODIMP AXPlatformNodeWin::get_accValue(VARIANT var_id, BSTR* value) { |
| 475 COM_OBJECT_VALIDATE_VAR_ID_1_ARG(var_id, value); | 562 AXPlatformNodeWin* target; |
| 476 return GetStringAttributeAsBstr(ui::AX_ATTR_VALUE, value); | 563 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, value, target); |
| 564 return target->GetStringAttributeAsBstr(ui::AX_ATTR_VALUE, value); | |
| 477 } | 565 } |
| 478 | 566 |
| 479 STDMETHODIMP AXPlatformNodeWin::put_accValue(VARIANT var_id, | 567 STDMETHODIMP AXPlatformNodeWin::put_accValue(VARIANT var_id, |
| 480 BSTR new_value) { | 568 BSTR new_value) { |
| 569 AXPlatformNodeWin* target; | |
| 570 COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_id, target); | |
| 571 | |
| 481 AXActionData data; | 572 AXActionData data; |
| 482 data.action = ui::AX_ACTION_SET_VALUE; | 573 data.action = ui::AX_ACTION_SET_VALUE; |
| 483 data.value = new_value; | 574 data.value = new_value; |
| 484 COM_OBJECT_VALIDATE_VAR_ID(var_id); | 575 if (target->delegate_->AccessibilityPerformAction(data)) |
| 485 if (delegate_->AccessibilityPerformAction(data)) | |
| 486 return S_OK; | 576 return S_OK; |
| 487 return E_FAIL; | 577 return E_FAIL; |
| 488 } | 578 } |
| 489 | 579 |
| 490 // IAccessible functions not supported. | 580 // IAccessible functions not supported. |
| 491 | 581 |
| 492 STDMETHODIMP AXPlatformNodeWin::get_accSelection(VARIANT* selected) { | 582 STDMETHODIMP AXPlatformNodeWin::get_accSelection(VARIANT* selected) { |
| 493 COM_OBJECT_VALIDATE_1_ARG(selected); | 583 COM_OBJECT_VALIDATE_1_ARG(selected); |
| 494 if (selected) | 584 if (selected) |
| 495 selected->vt = VT_EMPTY; | 585 selected->vt = VT_EMPTY; |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 969 | 1059 |
| 970 *object = nullptr; | 1060 *object = nullptr; |
| 971 return E_FAIL; | 1061 return E_FAIL; |
| 972 } | 1062 } |
| 973 | 1063 |
| 974 // | 1064 // |
| 975 // Private member functions. | 1065 // Private member functions. |
| 976 // | 1066 // |
| 977 | 1067 |
| 978 bool AXPlatformNodeWin::IsValidId(const VARIANT& child) const { | 1068 bool AXPlatformNodeWin::IsValidId(const VARIANT& child) const { |
| 979 // Since we have a separate IAccessible COM object for each node, we only | |
| 980 // support the CHILDID_SELF id. | |
| 981 return (VT_I4 == child.vt) && (CHILDID_SELF == child.lVal); | 1069 return (VT_I4 == child.vt) && (CHILDID_SELF == child.lVal); |
| 982 } | 1070 } |
| 983 | 1071 |
| 984 int AXPlatformNodeWin::MSAARole() { | 1072 int AXPlatformNodeWin::MSAARole() { |
| 985 switch (GetData().role) { | 1073 switch (GetData().role) { |
| 986 case ui::AX_ROLE_ALERT: | 1074 case ui::AX_ROLE_ALERT: |
| 987 return ROLE_SYSTEM_ALERT; | 1075 return ROLE_SYSTEM_ALERT; |
| 988 case ui::AX_ROLE_APPLICATION: | 1076 case ui::AX_ROLE_APPLICATION: |
| 989 return ROLE_SYSTEM_APPLICATION; | 1077 return ROLE_SYSTEM_APPLICATION; |
| 990 case ui::AX_ROLE_BUTTON_DROP_DOWN: | 1078 case ui::AX_ROLE_BUTTON_DROP_DOWN: |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1199 LONG start_offset, | 1287 LONG start_offset, |
| 1200 ui::TextBoundaryDirection direction) { | 1288 ui::TextBoundaryDirection direction) { |
| 1201 HandleSpecialTextOffset(&start_offset); | 1289 HandleSpecialTextOffset(&start_offset); |
| 1202 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); | 1290 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); |
| 1203 std::vector<int32_t> line_breaks; | 1291 std::vector<int32_t> line_breaks; |
| 1204 return static_cast<LONG>(ui::FindAccessibleTextBoundary( | 1292 return static_cast<LONG>(ui::FindAccessibleTextBoundary( |
| 1205 text, line_breaks, boundary, start_offset, direction, | 1293 text, line_breaks, boundary, start_offset, direction, |
| 1206 AX_TEXT_AFFINITY_DOWNSTREAM)); | 1294 AX_TEXT_AFFINITY_DOWNSTREAM)); |
| 1207 } | 1295 } |
| 1208 | 1296 |
| 1297 AXPlatformNodeWin* AXPlatformNodeWin::GetTargetFromChildID( | |
| 1298 const VARIANT& var_id) { | |
| 1299 LONG child_id = V_I4(&var_id); | |
| 1300 if (child_id == CHILDID_SELF) { | |
| 1301 return this; | |
| 1302 } | |
| 1303 | |
| 1304 if (child_id >= 1 && child_id <= delegate_->GetChildCount()) { | |
| 1305 // Positive child ids are a 1-based child index, used by clients | |
| 1306 // that want to enumerate all immediate children. | |
| 1307 AXPlatformNodeBase* base = | |
| 1308 FromNativeViewAccessible(delegate_->ChildAtIndex(child_id - 1)); | |
| 1309 return static_cast<AXPlatformNodeWin*>(base); | |
| 1310 } | |
| 1311 | |
| 1312 if (child_id >= 0) | |
| 1313 return nullptr; | |
| 1314 | |
| 1315 // Negative child ids can be used to map to any descendant. | |
| 1316 AXPlatformNode* node = GetFromUniqueId(-child_id); | |
| 1317 if (!node) | |
| 1318 return nullptr; | |
| 1319 | |
| 1320 AXPlatformNodeBase* base = | |
| 1321 FromNativeViewAccessible(node->GetNativeViewAccessible()); | |
| 1322 if (base && !IsDescendant(base)) | |
| 1323 base = nullptr; | |
| 1324 | |
| 1325 return static_cast<AXPlatformNodeWin*>(base); | |
| 1326 } | |
| 1327 | |
| 1209 } // namespace ui | 1328 } // namespace ui |
| OLD | NEW |