| OLD | NEW |
| 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> |
| (...skipping 2504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2515 *index = start_index + 1; | 2515 *index = start_index + 1; |
| 2516 return hr; | 2516 return hr; |
| 2517 } | 2517 } |
| 2518 | 2518 |
| 2519 // This method is deprecated in the IA2 Spec. | 2519 // This method is deprecated in the IA2 Spec. |
| 2520 STDMETHODIMP BrowserAccessibilityWin::get_valid(boolean* valid) { | 2520 STDMETHODIMP BrowserAccessibilityWin::get_valid(boolean* valid) { |
| 2521 return E_NOTIMPL; | 2521 return E_NOTIMPL; |
| 2522 } | 2522 } |
| 2523 | 2523 |
| 2524 // | 2524 // |
| 2525 // IAccessibleAction mostly not implemented. | 2525 // IAccessibleAction partly implemented. |
| 2526 // | 2526 // |
| 2527 | 2527 |
| 2528 STDMETHODIMP BrowserAccessibilityWin::nActions(long* n_actions) { | 2528 STDMETHODIMP BrowserAccessibilityWin::nActions(long* n_actions) { |
| 2529 if (!instance_active()) | 2529 if (!instance_active()) |
| 2530 return E_FAIL; | 2530 return E_FAIL; |
| 2531 | 2531 |
| 2532 if (!n_actions) | 2532 if (!n_actions) |
| 2533 return E_INVALIDARG; | 2533 return E_INVALIDARG; |
| 2534 | 2534 |
| 2535 // Required for IAccessibleHyperlink::anchor/anchorTarget to work properly. | 2535 // |IsHyperlink| is required for |IAccessibleHyperlink::anchor/anchorTarget| |
| 2536 // TODO(nektar): Implement the rest of the logic required by this interface. | 2536 // to work properly because the |IAccessibleHyperlink| interface inherits from |
| 2537 if (IsHyperlink()) | 2537 // |IAccessibleAction|. |
| 2538 if (IsHyperlink() || HasStringAttribute(ui::AX_ATTR_ACTION)) { |
| 2538 *n_actions = 1; | 2539 *n_actions = 1; |
| 2539 else | 2540 } else { |
| 2540 *n_actions = 0; | 2541 *n_actions = 0; |
| 2542 } |
| 2543 |
| 2541 return S_OK; | 2544 return S_OK; |
| 2542 } | 2545 } |
| 2543 | 2546 |
| 2544 STDMETHODIMP BrowserAccessibilityWin::doAction(long action_index) { | 2547 STDMETHODIMP BrowserAccessibilityWin::doAction(long action_index) { |
| 2545 return E_NOTIMPL; | 2548 if (!instance_active()) |
| 2549 return E_FAIL; |
| 2550 |
| 2551 if (!HasStringAttribute(ui::AX_ATTR_ACTION) || action_index != 0) |
| 2552 return E_INVALIDARG; |
| 2553 |
| 2554 manager()->DoDefaultAction(*this); |
| 2555 return S_OK; |
| 2546 } | 2556 } |
| 2557 |
| 2547 STDMETHODIMP | 2558 STDMETHODIMP |
| 2548 BrowserAccessibilityWin::get_description(long action_index, BSTR* description) { | 2559 BrowserAccessibilityWin::get_description(long action_index, BSTR* description) { |
| 2549 return E_NOTIMPL; | 2560 return E_NOTIMPL; |
| 2550 } | 2561 } |
| 2551 STDMETHODIMP BrowserAccessibilityWin::get_keyBinding(long action_index, | 2562 STDMETHODIMP BrowserAccessibilityWin::get_keyBinding(long action_index, |
| 2552 long n_max_bindings, | 2563 long n_max_bindings, |
| 2553 BSTR** key_bindings, | 2564 BSTR** key_bindings, |
| 2554 long* n_bindings) { | 2565 long* n_bindings) { |
| 2555 return E_NOTIMPL; | 2566 return E_NOTIMPL; |
| 2556 } | 2567 } |
| 2568 |
| 2557 STDMETHODIMP BrowserAccessibilityWin::get_name(long action_index, BSTR* name) { | 2569 STDMETHODIMP BrowserAccessibilityWin::get_name(long action_index, BSTR* name) { |
| 2558 return E_NOTIMPL; | 2570 if (!instance_active()) |
| 2571 return E_FAIL; |
| 2572 |
| 2573 if (!name) |
| 2574 return E_INVALIDARG; |
| 2575 |
| 2576 base::string16 action_verb; |
| 2577 if (!GetString16Attribute(ui::AX_ATTR_ACTION, &action_verb) || |
| 2578 action_index != 0) { |
| 2579 *name = nullptr; |
| 2580 return E_INVALIDARG; |
| 2581 } |
| 2582 |
| 2583 *name = SysAllocString(action_verb.c_str()); |
| 2584 DCHECK(name); |
| 2585 return S_OK; |
| 2559 } | 2586 } |
| 2587 |
| 2560 STDMETHODIMP | 2588 STDMETHODIMP |
| 2561 BrowserAccessibilityWin::get_localizedName(long action_index, | 2589 BrowserAccessibilityWin::get_localizedName(long action_index, |
| 2562 BSTR* localized_name) { | 2590 BSTR* localized_name) { |
| 2563 return E_NOTIMPL; | 2591 return E_NOTIMPL; |
| 2564 } | 2592 } |
| 2565 | 2593 |
| 2566 // | 2594 // |
| 2567 // IAccessibleValue methods. | 2595 // IAccessibleValue methods. |
| 2568 // | 2596 // |
| 2569 | 2597 |
| (...skipping 2393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4963 return static_cast<BrowserAccessibilityWin*>(obj); | 4991 return static_cast<BrowserAccessibilityWin*>(obj); |
| 4964 } | 4992 } |
| 4965 | 4993 |
| 4966 const BrowserAccessibilityWin* | 4994 const BrowserAccessibilityWin* |
| 4967 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { | 4995 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { |
| 4968 DCHECK(!obj || obj->IsNative()); | 4996 DCHECK(!obj || obj->IsNative()); |
| 4969 return static_cast<const BrowserAccessibilityWin*>(obj); | 4997 return static_cast<const BrowserAccessibilityWin*>(obj); |
| 4970 } | 4998 } |
| 4971 | 4999 |
| 4972 } // namespace content | 5000 } // namespace content |
| OLD | NEW |