1 /* 2 * Copyright (C) 2008, 2009, 2010 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 26 #ifndef AccessibleBase_h 27 #define AccessibleBase_h 28 29 #include "WebKit.h" 30 #include <WebCore/AccessibilityObject.h> 31 #include <WebCore/AccessibilityObjectWrapperWin.h> 32 33 class DECLSPEC_UUID("3dbd565b-db22-4d88-8e0e-778bde54524a") AccessibleBase : public IAccessibleComparable, public IServiceProvider, public WebCore::AccessibilityObjectWrapper { 34 public: 35 static AccessibleBase* createInstance(WebCore::AccessibilityObject*); 36 37 // IServiceProvider 38 virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppv); 39 40 // IUnknown 41 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); 42 virtual ULONG STDMETHODCALLTYPE AddRef(void) { return ++m_refCount; } 43 virtual ULONG STDMETHODCALLTYPE Release(void); 44 45 // IAccessible 46 virtual HRESULT STDMETHODCALLTYPE get_accParent(IDispatch**); 47 virtual HRESULT STDMETHODCALLTYPE get_accChildCount(long*); 48 virtual HRESULT STDMETHODCALLTYPE get_accChild(VARIANT vChild, IDispatch** ppChild); 49 virtual HRESULT STDMETHODCALLTYPE get_accName(VARIANT vChild, BSTR*); 50 virtual HRESULT STDMETHODCALLTYPE get_accValue(VARIANT vChild, BSTR*); 51 virtual HRESULT STDMETHODCALLTYPE get_accDescription(VARIANT, BSTR*); 52 virtual HRESULT STDMETHODCALLTYPE get_accRole(VARIANT vChild, VARIANT* pvRole); 53 virtual HRESULT STDMETHODCALLTYPE get_accState(VARIANT vChild, VARIANT* pvState); 54 virtual HRESULT STDMETHODCALLTYPE get_accHelp(VARIANT vChild, BSTR* helpText); 55 virtual HRESULT STDMETHODCALLTYPE get_accKeyboardShortcut(VARIANT vChild, BSTR*); 56 virtual HRESULT STDMETHODCALLTYPE get_accFocus(VARIANT* pvFocusedChild); 57 virtual HRESULT STDMETHODCALLTYPE get_accSelection(VARIANT* pvSelectedChild); 58 virtual HRESULT STDMETHODCALLTYPE get_accDefaultAction(VARIANT vChild, BSTR* actionDescription); 59 virtual HRESULT STDMETHODCALLTYPE accSelect(long selectionFlags, VARIANT vChild); 60 virtual HRESULT STDMETHODCALLTYPE accLocation(long* left, long* top, long* width, long* height, VARIANT vChild); 61 virtual HRESULT STDMETHODCALLTYPE accNavigate(long direction, VARIANT vFromChild, VARIANT* pvNavigatedTo); 62 virtual HRESULT STDMETHODCALLTYPE accHitTest(long x, long y, VARIANT* pvChildAtPoint); 63 virtual HRESULT STDMETHODCALLTYPE accDoDefaultAction(VARIANT vChild); 64 65 // IAccessible - Not to be implemented. 66 virtual HRESULT STDMETHODCALLTYPE put_accName(VARIANT, BSTR) { return E_NOTIMPL; } 67 virtual HRESULT STDMETHODCALLTYPE put_accValue(VARIANT, BSTR) { return E_NOTIMPL; } 68 virtual HRESULT STDMETHODCALLTYPE get_accHelpTopic(BSTR* helpFile, VARIANT, long* topicID) 69 { 70 *helpFile = 0; 71 *topicID = 0; 72 return E_NOTIMPL; 73 } 74 75 // IDispatch - Not to be implemented. 76 virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT* count) 77 { 78 *count = 0; 79 return E_NOTIMPL; 80 } 81 virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT, LCID, ITypeInfo** ppTInfo) 82 { 83 *ppTInfo = 0; 84 return E_NOTIMPL; 85 } 86 virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID, LPOLESTR*, UINT, LCID, DISPID*) { return E_NOTIMPL; } 87 virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*) { return E_NOTIMPL; } 88 89 // WebCore::AccessiblityObjectWrapper 90 virtual void detach() { 91 ASSERT(m_object); 92 m_object = 0; 93 } 94 95 // IAccessibleComparable 96 virtual HRESULT STDMETHODCALLTYPE isSameObject(IAccessibleComparable* other, BOOL* result); 97 98 protected: 99 AccessibleBase(WebCore::AccessibilityObject*); 100 virtual ~AccessibleBase(); 101 102 virtual WTF::String name() const; 103 virtual WTF::String value() const; 104 virtual long role() const; 105 106 HRESULT getAccessibilityObjectForChild(VARIANT vChild, WebCore::AccessibilityObject*&) const; 107 108 static AccessibleBase* wrapper(WebCore::AccessibilityObject*); 109 110 int m_refCount; 111 112 private: 113 AccessibleBase() { } 114 }; 115 116 #endif // AccessibleBase_h 117 118