AccessibleBase.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Copyright (C) 2008, 2009, 2010, 2013 Apple Inc. All Rights Reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
  14. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
  17. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  18. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  20. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  21. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef AccessibleBase_h
  26. #define AccessibleBase_h
  27. #include "WebKit.h"
  28. #include <WebCore/AccessibilityObject.h>
  29. #include <WebCore/AccessibilityObjectWrapperWin.h>
  30. class DECLSPEC_UUID("3dbd565b-db22-4d88-8e0e-778bde54524a") AccessibleBase : public IAccessibleComparable, public IServiceProvider, public WebCore::AccessibilityObjectWrapper {
  31. public:
  32. static AccessibleBase* createInstance(WebCore::AccessibilityObject*, HWND);
  33. // IServiceProvider
  34. virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppv);
  35. // IUnknown
  36. virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
  37. virtual ULONG STDMETHODCALLTYPE AddRef(void) { return ++m_refCount; }
  38. virtual ULONG STDMETHODCALLTYPE Release(void);
  39. // IAccessible2_2
  40. virtual HRESULT STDMETHODCALLTYPE get_attribute(BSTR name, VARIANT* attribute);
  41. virtual HRESULT STDMETHODCALLTYPE get_accessibleWithCaret(IUnknown** accessible, long* caretOffset);
  42. virtual HRESULT STDMETHODCALLTYPE get_relationTargetsOfType(BSTR type, long maxTargets, IUnknown*** targets, long* nTargets);
  43. // IAccessible2
  44. virtual HRESULT STDMETHODCALLTYPE get_nRelations(long*);
  45. virtual HRESULT STDMETHODCALLTYPE get_relation(long relationIndex, IAccessibleRelation**);
  46. virtual HRESULT STDMETHODCALLTYPE get_relations(long maxRelations, IAccessibleRelation** relations, long* nRelations);
  47. virtual HRESULT STDMETHODCALLTYPE role(long*);
  48. virtual HRESULT STDMETHODCALLTYPE scrollTo(IA2ScrollType);
  49. virtual HRESULT STDMETHODCALLTYPE scrollToPoint(IA2CoordinateType, long x, long y);
  50. virtual HRESULT STDMETHODCALLTYPE get_groupPosition(long* groupLevel, long* similarItemsInGroup, long* positionInGroup);
  51. virtual HRESULT STDMETHODCALLTYPE get_states(AccessibleStates*);
  52. virtual HRESULT STDMETHODCALLTYPE get_extendedRole(BSTR*);
  53. virtual HRESULT STDMETHODCALLTYPE get_localizedExtendedRole(BSTR*);
  54. virtual HRESULT STDMETHODCALLTYPE get_nExtendedStates(long*);
  55. virtual HRESULT STDMETHODCALLTYPE get_extendedStates(long maxExtendedStates, BSTR** extendedStates, long* nExtendedStates);
  56. virtual HRESULT STDMETHODCALLTYPE get_localizedExtendedStates(long maxLocalizedExtendedStates, BSTR** localizedExtendedStates, long* nLocalizedExtendedStates);
  57. virtual HRESULT STDMETHODCALLTYPE get_uniqueID(long*);
  58. virtual HRESULT STDMETHODCALLTYPE get_windowHandle(HWND*);
  59. virtual HRESULT STDMETHODCALLTYPE get_indexInParent(long*);
  60. virtual HRESULT STDMETHODCALLTYPE get_locale(IA2Locale*);
  61. virtual HRESULT STDMETHODCALLTYPE get_attributes(BSTR*);
  62. // IAccessible
  63. virtual HRESULT STDMETHODCALLTYPE get_accParent(IDispatch**);
  64. virtual HRESULT STDMETHODCALLTYPE get_accChildCount(long*);
  65. virtual HRESULT STDMETHODCALLTYPE get_accChild(VARIANT vChild, IDispatch** ppChild);
  66. virtual HRESULT STDMETHODCALLTYPE get_accName(VARIANT vChild, BSTR*);
  67. virtual HRESULT STDMETHODCALLTYPE get_accValue(VARIANT vChild, BSTR*);
  68. virtual HRESULT STDMETHODCALLTYPE get_accDescription(VARIANT, BSTR*);
  69. virtual HRESULT STDMETHODCALLTYPE get_accRole(VARIANT vChild, VARIANT* pvRole);
  70. virtual HRESULT STDMETHODCALLTYPE get_accState(VARIANT vChild, VARIANT* pvState);
  71. virtual HRESULT STDMETHODCALLTYPE get_accHelp(VARIANT vChild, BSTR* helpText);
  72. virtual HRESULT STDMETHODCALLTYPE get_accKeyboardShortcut(VARIANT vChild, BSTR*);
  73. virtual HRESULT STDMETHODCALLTYPE get_accFocus(VARIANT* pvFocusedChild);
  74. virtual HRESULT STDMETHODCALLTYPE get_accSelection(VARIANT* pvSelectedChild);
  75. virtual HRESULT STDMETHODCALLTYPE get_accDefaultAction(VARIANT vChild, BSTR* actionDescription);
  76. virtual HRESULT STDMETHODCALLTYPE accSelect(long selectionFlags, VARIANT vChild);
  77. virtual HRESULT STDMETHODCALLTYPE accLocation(long* left, long* top, long* width, long* height, VARIANT vChild);
  78. virtual HRESULT STDMETHODCALLTYPE accNavigate(long direction, VARIANT vFromChild, VARIANT* pvNavigatedTo);
  79. virtual HRESULT STDMETHODCALLTYPE accHitTest(long x, long y, VARIANT* pvChildAtPoint);
  80. virtual HRESULT STDMETHODCALLTYPE accDoDefaultAction(VARIANT vChild);
  81. // IAccessible - Not to be implemented.
  82. virtual HRESULT STDMETHODCALLTYPE put_accName(VARIANT, BSTR) { return E_NOTIMPL; }
  83. virtual HRESULT STDMETHODCALLTYPE put_accValue(VARIANT, BSTR) { return E_NOTIMPL; }
  84. virtual HRESULT STDMETHODCALLTYPE get_accHelpTopic(BSTR* helpFile, VARIANT, long* topicID)
  85. {
  86. *helpFile = 0;
  87. *topicID = 0;
  88. return E_NOTIMPL;
  89. }
  90. // IDispatch - Not to be implemented.
  91. virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT* count)
  92. {
  93. *count = 0;
  94. return E_NOTIMPL;
  95. }
  96. virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT, LCID, ITypeInfo** ppTInfo)
  97. {
  98. *ppTInfo = 0;
  99. return E_NOTIMPL;
  100. }
  101. virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID, LPOLESTR*, UINT, LCID, DISPID*) { return E_NOTIMPL; }
  102. virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*) { return E_NOTIMPL; }
  103. // WebCore::AccessiblityObjectWrapper
  104. virtual void detach() {
  105. ASSERT(m_object);
  106. m_object = 0;
  107. }
  108. // IAccessibleComparable
  109. virtual HRESULT STDMETHODCALLTYPE isSameObject(IAccessibleComparable* other, BOOL* result);
  110. protected:
  111. AccessibleBase(WebCore::AccessibilityObject*, HWND);
  112. virtual ~AccessibleBase();
  113. virtual WTF::String name() const;
  114. virtual WTF::String value() const;
  115. virtual long role() const;
  116. virtual long state() const;
  117. HRESULT getAccessibilityObjectForChild(VARIANT vChild, WebCore::AccessibilityObject*&) const;
  118. AccessibleBase* wrapper(WebCore::AccessibilityObject*) const;
  119. HWND m_window;
  120. int m_refCount;
  121. private:
  122. AccessibleBase() { }
  123. };
  124. #endif // AccessibleBase_h