| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/browser_accessibility.h" | 5 #include "chrome/browser/browser_accessibility.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/browser_accessibility_manager.h" | 8 #include "chrome/browser/browser_accessibility_manager.h" |
| 9 | 9 |
| 10 using webkit_glue::WebAccessibility; | 10 using webkit_glue::WebAccessibility; |
| 11 | 11 |
| 12 HRESULT BrowserAccessibility::Initialize(int iaccessible_id, int routing_id, | 12 HRESULT BrowserAccessibility::Initialize(int iaccessible_id, int routing_id, |
| 13 int process_id, HWND parent_hwnd) { | 13 int process_id, HWND parent_hwnd) { |
| 14 if (!parent_hwnd || iaccessible_id < 0) | 14 // Check input parameters. Root id is 1000, to avoid conflicts with the ids |
| 15 // used by MSAA. |
| 16 if (!parent_hwnd || iaccessible_id < 1000) |
| 15 return E_INVALIDARG; | 17 return E_INVALIDARG; |
| 16 | 18 |
| 17 iaccessible_id_ = iaccessible_id; | 19 iaccessible_id_ = iaccessible_id; |
| 18 routing_id_ = routing_id; | 20 routing_id_ = routing_id; |
| 19 process_id_ = process_id; | 21 process_id_ = process_id; |
| 20 parent_hwnd_ = parent_hwnd; | 22 parent_hwnd_ = parent_hwnd; |
| 21 | 23 |
| 22 // Mark instance as active. | 24 // Mark instance as active. |
| 23 instance_active_ = true; | 25 instance_active_ = true; |
| 24 | |
| 25 // Treat child ids intitially as referring to direct children of the object. | |
| 26 direct_descendant_ = true; | |
| 27 | |
| 28 return S_OK; | 26 return S_OK; |
| 29 } | 27 } |
| 30 | 28 |
| 31 HRESULT BrowserAccessibility::accDoDefaultAction(VARIANT var_id) { | 29 HRESULT BrowserAccessibility::accDoDefaultAction(VARIANT var_id) { |
| 32 if (!instance_active()) { | 30 if (!instance_active()) { |
| 33 // Instance no longer active, fail gracefully. | 31 // Instance no longer active, fail gracefully. |
| 34 // TODO(klink): Once we have MSAA events, change these fails to having | 32 // TODO(klink): Once we have MSAA events, change these fails to having |
| 35 // BrowserAccessibilityManager firing the right event. | 33 // BrowserAccessibilityManager firing the right event. |
| 36 return E_FAIL; | 34 return E_FAIL; |
| 37 } | 35 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 IDispatch** disp_child) { | 183 IDispatch** disp_child) { |
| 186 if (!instance_active()) { | 184 if (!instance_active()) { |
| 187 // Instance no longer active, fail gracefully. | 185 // Instance no longer active, fail gracefully. |
| 188 return E_FAIL; | 186 return E_FAIL; |
| 189 } | 187 } |
| 190 | 188 |
| 191 if (var_child.vt != VT_I4 || !disp_child) | 189 if (var_child.vt != VT_I4 || !disp_child) |
| 192 return E_INVALIDARG; | 190 return E_INVALIDARG; |
| 193 | 191 |
| 194 // If var_child is the parent, remain with the same IDispatch. | 192 // If var_child is the parent, remain with the same IDispatch. |
| 195 if (var_child.lVal == CHILDID_SELF && iaccessible_id_ != 0) | 193 if (var_child.lVal == CHILDID_SELF && iaccessible_id_ != 1000) |
| 196 return S_OK; | 194 return S_OK; |
| 197 | 195 |
| 198 if (!RequestAccessibilityInfo(WebAccessibility::FUNCTION_GETCHILD, var_child, | 196 if (!RequestAccessibilityInfo(WebAccessibility::FUNCTION_GETCHILD, var_child, |
| 199 NULL, NULL)) { | 197 NULL, NULL)) { |
| 200 return E_FAIL; | 198 return E_FAIL; |
| 201 } | 199 } |
| 202 | 200 |
| 203 if (!response().return_code) { | 201 if (!response().return_code) { |
| 204 // When at a leaf, children are handled by the parent object. | 202 // When at a leaf, children are handled by the parent object. |
| 205 *disp_child = NULL; | 203 *disp_child = NULL; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 STDMETHODIMP BrowserAccessibility::get_accParent(IDispatch** disp_parent) { | 402 STDMETHODIMP BrowserAccessibility::get_accParent(IDispatch** disp_parent) { |
| 405 if (!instance_active()) { | 403 if (!instance_active()) { |
| 406 // Instance no longer active, fail gracefully. | 404 // Instance no longer active, fail gracefully. |
| 407 return E_FAIL; | 405 return E_FAIL; |
| 408 } | 406 } |
| 409 | 407 |
| 410 if (!disp_parent || !parent_hwnd_) | 408 if (!disp_parent || !parent_hwnd_) |
| 411 return E_INVALIDARG; | 409 return E_INVALIDARG; |
| 412 | 410 |
| 413 // Root node's parent is the containing HWND's IAccessible. | 411 // Root node's parent is the containing HWND's IAccessible. |
| 414 if (iaccessible_id_ == 0) { | 412 if (iaccessible_id_ == 1000) { |
| 415 // For an object that has no parent (e.g. root), point the accessible parent | 413 // For an object that has no parent (e.g. root), point the accessible parent |
| 416 // to the default implementation. | 414 // to the default implementation. |
| 417 HRESULT hr = | 415 HRESULT hr = |
| 418 ::CreateStdAccessibleObject(parent_hwnd_, OBJID_WINDOW, | 416 ::CreateStdAccessibleObject(parent_hwnd_, OBJID_WINDOW, |
| 419 IID_IAccessible, | 417 IID_IAccessible, |
| 420 reinterpret_cast<void**>(disp_parent)); | 418 reinterpret_cast<void**>(disp_parent)); |
| 421 | 419 |
| 422 if (!SUCCEEDED(hr)) { | 420 if (!SUCCEEDED(hr)) { |
| 423 *disp_parent = NULL; | 421 *disp_parent = NULL; |
| 424 return S_FALSE; | 422 return S_FALSE; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 | 539 |
| 542 bool BrowserAccessibility::RequestAccessibilityInfo(int iaccessible_func_id, | 540 bool BrowserAccessibility::RequestAccessibilityInfo(int iaccessible_func_id, |
| 543 VARIANT var_id, LONG input1, | 541 VARIANT var_id, LONG input1, |
| 544 LONG input2) { | 542 LONG input2) { |
| 545 // Create and populate IPC message structure, for retrieval of accessibility | 543 // Create and populate IPC message structure, for retrieval of accessibility |
| 546 // information from the renderer. | 544 // information from the renderer. |
| 547 WebAccessibility::InParams in_params; | 545 WebAccessibility::InParams in_params; |
| 548 in_params.object_id = iaccessible_id_; | 546 in_params.object_id = iaccessible_id_; |
| 549 in_params.function_id = iaccessible_func_id; | 547 in_params.function_id = iaccessible_func_id; |
| 550 in_params.child_id = var_id.lVal; | 548 in_params.child_id = var_id.lVal; |
| 551 in_params.direct_descendant = direct_descendant(); | |
| 552 in_params.input_long1 = input1; | 549 in_params.input_long1 = input1; |
| 553 in_params.input_long2 = input2; | 550 in_params.input_long2 = input2; |
| 554 | 551 |
| 555 if (!direct_descendant()) | |
| 556 set_direct_descendant(true); | |
| 557 | |
| 558 return BrowserAccessibilityManager::GetInstance()-> | 552 return BrowserAccessibilityManager::GetInstance()-> |
| 559 RequestAccessibilityInfo(&in_params, routing_id_, process_id_); | 553 RequestAccessibilityInfo(&in_params, routing_id_, process_id_); |
| 560 } | 554 } |
| 561 | 555 |
| 562 const WebAccessibility::OutParams& BrowserAccessibility::response() { | 556 const WebAccessibility::OutParams& BrowserAccessibility::response() { |
| 563 return BrowserAccessibilityManager::GetInstance()->response(); | 557 return BrowserAccessibilityManager::GetInstance()->response(); |
| 564 } | 558 } |
| 565 | 559 |
| 566 long BrowserAccessibility::MSAARole(long browser_accessibility_role) { | 560 long BrowserAccessibility::MSAARole(long browser_accessibility_role) { |
| 567 switch (browser_accessibility_role) { | 561 switch (browser_accessibility_role) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 state |= STATE_SYSTEM_FOCUSED; | 637 state |= STATE_SYSTEM_FOCUSED; |
| 644 | 638 |
| 645 if ((browser_accessibility_state >> WebAccessibility::STATE_TRAVERSED) & 1) | 639 if ((browser_accessibility_state >> WebAccessibility::STATE_TRAVERSED) & 1) |
| 646 state |= STATE_SYSTEM_TRAVERSED; | 640 state |= STATE_SYSTEM_TRAVERSED; |
| 647 | 641 |
| 648 if ((browser_accessibility_state >> WebAccessibility::STATE_FOCUSABLE) & 1) | 642 if ((browser_accessibility_state >> WebAccessibility::STATE_FOCUSABLE) & 1) |
| 649 state |= STATE_SYSTEM_FOCUSABLE; | 643 state |= STATE_SYSTEM_FOCUSABLE; |
| 650 | 644 |
| 651 return state; | 645 return state; |
| 652 } | 646 } |
| OLD | NEW |