• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 Google 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 are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef AccessibilityUIElement_h
32 #define AccessibilityUIElement_h
33 
34 #include "CppBoundClass.h"
35 #include "WebAccessibilityObject.h"
36 #include <wtf/Vector.h>
37 
38 class AccessibilityUIElement : public CppBoundClass {
39 public:
40     class Factory {
41     public:
~Factory()42         virtual ~Factory() { }
43         virtual AccessibilityUIElement* create(const WebKit::WebAccessibilityObject&) = 0;
44     };
45 
46     AccessibilityUIElement(const WebKit::WebAccessibilityObject&, Factory*);
47 
48     virtual AccessibilityUIElement* getChildAtIndex(unsigned);
isRoot()49     virtual bool isRoot() const { return false; }
50 
51 protected:
accessibilityObject()52     const WebKit::WebAccessibilityObject& accessibilityObject() const { return m_accessibilityObject; }
factory()53     Factory* factory() const { return m_factory; }
54 
55 private:
56     // Bound methods and properties.
57     void allAttributesCallback(const CppArgumentList&, CppVariant*);
58     void attributesOfLinkedUIElementsCallback(const CppArgumentList&, CppVariant*);
59     void attributesOfDocumentLinksCallback(const CppArgumentList&, CppVariant*);
60     void attributesOfChildrenCallback(const CppArgumentList&, CppVariant*);
61     void parametrizedAttributeNamesCallback(const CppArgumentList&, CppVariant*);
62     void lineForIndexCallback(const CppArgumentList&, CppVariant*);
63     void boundsForRangeCallback(const CppArgumentList&, CppVariant*);
64     void stringForRangeCallback(const CppArgumentList&, CppVariant*);
65     void childAtIndexCallback(const CppArgumentList&, CppVariant*);
66     void elementAtPointCallback(const CppArgumentList&, CppVariant*);
67     void attributesOfColumnHeadersCallback(const CppArgumentList&, CppVariant*);
68     void attributesOfRowHeadersCallback(const CppArgumentList&, CppVariant*);
69     void attributesOfColumnsCallback(const CppArgumentList&, CppVariant*);
70     void attributesOfRowsCallback(const CppArgumentList&, CppVariant*);
71     void attributesOfVisibleCellsCallback(const CppArgumentList&, CppVariant*);
72     void attributesOfHeaderCallback(const CppArgumentList&, CppVariant*);
73     void indexInTableCallback(const CppArgumentList&, CppVariant*);
74     void rowIndexRangeCallback(const CppArgumentList&, CppVariant*);
75     void columnIndexRangeCallback(const CppArgumentList&, CppVariant*);
76     void cellForColumnAndRowCallback(const CppArgumentList&, CppVariant*);
77     void titleUIElementCallback(const CppArgumentList&, CppVariant*);
78     void setSelectedTextRangeCallback(const CppArgumentList&, CppVariant*);
79     void attributeValueCallback(const CppArgumentList&, CppVariant*);
80     void isAttributeSettableCallback(const CppArgumentList&, CppVariant*);
81     void isActionSupportedCallback(const CppArgumentList&, CppVariant*);
82     void parentElementCallback(const CppArgumentList&, CppVariant*);
83     void incrementCallback(const CppArgumentList&, CppVariant*);
84     void decrementCallback(const CppArgumentList&, CppVariant*);
85     void fallbackCallback(const CppArgumentList&, CppVariant*);
86 
87     void childrenCountGetterCallback(CppVariant*);
88     void descriptionGetterCallback(CppVariant*);
89     void isEnabledGetterCallback(CppVariant*);
90     void isSelectedGetterCallback(CppVariant*);
91     void roleGetterCallback(CppVariant*);
92     void titleGetterCallback(CppVariant*);
93 
94     CppVariant m_subrole;
95     CppVariant m_language;
96     CppVariant m_x;
97     CppVariant m_y;
98     CppVariant m_width;
99     CppVariant m_height;
100     CppVariant m_clickPointX;
101     CppVariant m_clickPointY;
102     CppVariant m_intValue;
103     CppVariant m_minValue;
104     CppVariant m_maxValue;
105     CppVariant m_childrenCount;
106     CppVariant m_insertionPointLineNumber;
107     CppVariant m_selectedTextRange;
108     CppVariant m_isRequired;
109     CppVariant m_valueDescription;
110 
111     WebKit::WebAccessibilityObject m_accessibilityObject;
112     Factory* m_factory;
113 };
114 
115 
116 class RootAccessibilityUIElement : public AccessibilityUIElement {
117 public:
118     RootAccessibilityUIElement(const WebKit::WebAccessibilityObject&, Factory*);
119 
120     virtual AccessibilityUIElement* getChildAtIndex(unsigned);
isRoot()121     virtual bool isRoot() const { return true; }
122 };
123 
124 
125 // Provides simple lifetime management of the AccessibilityUIElement instances:
126 // all AccessibilityUIElements ever created from the controller are stored in
127 // a list and cleared explicitly.
128 class AccessibilityUIElementList : public AccessibilityUIElement::Factory {
129 public:
AccessibilityUIElementList()130     AccessibilityUIElementList() { }
131     virtual ~AccessibilityUIElementList();
132 
133     void clear();
134     virtual AccessibilityUIElement* create(const WebKit::WebAccessibilityObject&);
135     AccessibilityUIElement* createRoot(const WebKit::WebAccessibilityObject&);
136 
137 private:
138     typedef Vector<AccessibilityUIElement*> ElementList;
139     ElementList m_elements;
140 };
141 
142 #endif // AccessibilityUIElement_h
143