OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef AXObjectCache_h | 26 #ifndef AXObjectCache_h |
27 #define AXObjectCache_h | 27 #define AXObjectCache_h |
28 | 28 |
29 #include "core/accessibility/AXObject.h" | 29 #include "core/accessibility/AXObject.h" |
| 30 #include "core/rendering/RenderText.h" |
30 #include "platform/Timer.h" | 31 #include "platform/Timer.h" |
31 #include "wtf/Forward.h" | 32 #include "wtf/Forward.h" |
32 #include "wtf/HashMap.h" | 33 #include "wtf/HashMap.h" |
33 #include "wtf/HashSet.h" | 34 #include "wtf/HashSet.h" |
34 #include "wtf/RefPtr.h" | 35 #include "wtf/RefPtr.h" |
35 | 36 |
36 namespace WebCore { | 37 namespace WebCore { |
37 | 38 |
| 39 class AbstractInlineTextBox; |
38 class Document; | 40 class Document; |
39 class HTMLAreaElement; | 41 class HTMLAreaElement; |
40 class Node; | 42 class Node; |
41 class Page; | 43 class Page; |
42 class RenderObject; | 44 class RenderObject; |
43 class ScrollView; | 45 class ScrollView; |
44 class VisiblePosition; | 46 class VisiblePosition; |
45 class Widget; | 47 class Widget; |
46 | 48 |
47 struct TextMarkerData { | 49 struct TextMarkerData { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 84 |
83 static AXObject* focusedUIElementForPage(const Page*); | 85 static AXObject* focusedUIElementForPage(const Page*); |
84 | 86 |
85 // Returns the root object for the entire document. | 87 // Returns the root object for the entire document. |
86 AXObject* rootObject(); | 88 AXObject* rootObject(); |
87 | 89 |
88 // For AX objects with elements that back them. | 90 // For AX objects with elements that back them. |
89 AXObject* getOrCreate(RenderObject*); | 91 AXObject* getOrCreate(RenderObject*); |
90 AXObject* getOrCreate(Widget*); | 92 AXObject* getOrCreate(Widget*); |
91 AXObject* getOrCreate(Node*); | 93 AXObject* getOrCreate(Node*); |
| 94 AXObject* getOrCreate(AbstractInlineTextBox*); |
92 | 95 |
93 // used for objects without backing elements | 96 // used for objects without backing elements |
94 AXObject* getOrCreate(AccessibilityRole); | 97 AXObject* getOrCreate(AccessibilityRole); |
95 | 98 |
96 // will only return the AXObject if it already exists | 99 // will only return the AXObject if it already exists |
97 AXObject* get(RenderObject*); | 100 AXObject* get(RenderObject*); |
98 AXObject* get(Widget*); | 101 AXObject* get(Widget*); |
99 AXObject* get(Node*); | 102 AXObject* get(Node*); |
| 103 AXObject* get(AbstractInlineTextBox*); |
100 | 104 |
101 void remove(RenderObject*); | 105 void remove(RenderObject*); |
102 void remove(Node*); | 106 void remove(Node*); |
103 void remove(Widget*); | 107 void remove(Widget*); |
| 108 void remove(AbstractInlineTextBox*); |
104 void remove(AXID); | 109 void remove(AXID); |
105 | 110 |
106 void detachWrapper(AXObject*); | 111 void detachWrapper(AXObject*); |
107 void attachWrapper(AXObject*); | 112 void attachWrapper(AXObject*); |
108 void childrenChanged(Node*); | 113 void childrenChanged(Node*); |
109 void childrenChanged(RenderObject*); | 114 void childrenChanged(RenderObject*); |
110 void childrenChanged(AXObject*); | 115 void childrenChanged(AXObject*); |
111 void checkedStateChanged(Node*); | 116 void checkedStateChanged(Node*); |
112 void selectedChildrenChanged(Node*); | 117 void selectedChildrenChanged(Node*); |
113 void selectedChildrenChanged(RenderObject*); | 118 void selectedChildrenChanged(RenderObject*); |
(...skipping 10 matching lines...) Expand all Loading... |
124 void handleScrolledToAnchor(const Node* anchorNode); | 129 void handleScrolledToAnchor(const Node* anchorNode); |
125 void handleAriaExpandedChange(Node*); | 130 void handleAriaExpandedChange(Node*); |
126 void handleScrollbarUpdate(ScrollView*); | 131 void handleScrollbarUpdate(ScrollView*); |
127 | 132 |
128 void handleAttributeChanged(const QualifiedName& attrName, Element*); | 133 void handleAttributeChanged(const QualifiedName& attrName, Element*); |
129 void recomputeIsIgnored(RenderObject* renderer); | 134 void recomputeIsIgnored(RenderObject* renderer); |
130 | 135 |
131 #if HAVE(ACCESSIBILITY) | 136 #if HAVE(ACCESSIBILITY) |
132 static void enableAccessibility() { gAccessibilityEnabled = true; } | 137 static void enableAccessibility() { gAccessibilityEnabled = true; } |
133 static bool accessibilityEnabled() { return gAccessibilityEnabled; } | 138 static bool accessibilityEnabled() { return gAccessibilityEnabled; } |
| 139 static void setInlineTextBoxAccessibility(bool flag) { gInlineTextBoxAccessi
bility = flag; } |
| 140 static bool inlineTextBoxAccessibility() { return gInlineTextBoxAccessibilit
y; } |
134 #else | 141 #else |
135 static void enableAccessibility() { } | 142 static void enableAccessibility() { } |
| 143 static void setInlineTextBoxAccessibility(bool) { } |
136 static bool accessibilityEnabled() { return false; } | 144 static bool accessibilityEnabled() { return false; } |
| 145 static bool inlineTextBoxAccessibility() { return false; } |
137 #endif | 146 #endif |
138 | 147 |
139 void removeAXID(AXObject*); | 148 void removeAXID(AXObject*); |
140 bool isIDinUse(AXID id) const { return m_idsInUse.contains(id); } | 149 bool isIDinUse(AXID id) const { return m_idsInUse.contains(id); } |
141 | 150 |
142 Element* rootAXEditableElement(Node*); | 151 Element* rootAXEditableElement(Node*); |
143 const Element* rootAXEditableElement(const Node*); | 152 const Element* rootAXEditableElement(const Node*); |
144 bool nodeIsTextControl(const Node*); | 153 bool nodeIsTextControl(const Node*); |
145 | 154 |
146 AXID platformGenerateAXID() const; | 155 AXID platformGenerateAXID() const; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 void setNodeInUse(Node* n) { m_textMarkerNodes.add(n); } | 209 void setNodeInUse(Node* n) { m_textMarkerNodes.add(n); } |
201 void removeNodeForUse(Node* n) { m_textMarkerNodes.remove(n); } | 210 void removeNodeForUse(Node* n) { m_textMarkerNodes.remove(n); } |
202 bool isNodeInUse(Node* n) { return m_textMarkerNodes.contains(n); } | 211 bool isNodeInUse(Node* n) { return m_textMarkerNodes.contains(n); } |
203 | 212 |
204 private: | 213 private: |
205 Document* m_document; | 214 Document* m_document; |
206 HashMap<AXID, RefPtr<AXObject> > m_objects; | 215 HashMap<AXID, RefPtr<AXObject> > m_objects; |
207 HashMap<RenderObject*, AXID> m_renderObjectMapping; | 216 HashMap<RenderObject*, AXID> m_renderObjectMapping; |
208 HashMap<Widget*, AXID> m_widgetObjectMapping; | 217 HashMap<Widget*, AXID> m_widgetObjectMapping; |
209 HashMap<Node*, AXID> m_nodeObjectMapping; | 218 HashMap<Node*, AXID> m_nodeObjectMapping; |
| 219 HashMap<AbstractInlineTextBox*, AXID> m_inlineTextBoxObjectMapping; |
210 HashSet<Node*> m_textMarkerNodes; | 220 HashSet<Node*> m_textMarkerNodes; |
211 OwnPtr<AXComputedObjectAttributeCache> m_computedObjectAttributeCache; | 221 OwnPtr<AXComputedObjectAttributeCache> m_computedObjectAttributeCache; |
212 static bool gAccessibilityEnabled; | 222 static bool gAccessibilityEnabled; |
| 223 static bool gInlineTextBoxAccessibility; |
213 | 224 |
214 HashSet<AXID> m_idsInUse; | 225 HashSet<AXID> m_idsInUse; |
215 | 226 |
216 Timer<AXObjectCache> m_notificationPostTimer; | 227 Timer<AXObjectCache> m_notificationPostTimer; |
217 Vector<pair<RefPtr<AXObject>, AXNotification> > m_notificationsToPost; | 228 Vector<pair<RefPtr<AXObject>, AXNotification> > m_notificationsToPost; |
218 void notificationPostTimerFired(Timer<AXObjectCache>*); | 229 void notificationPostTimerFired(Timer<AXObjectCache>*); |
219 | 230 |
220 static AXObject* focusedImageMapUIElement(HTMLAreaElement*); | 231 static AXObject* focusedImageMapUIElement(HTMLAreaElement*); |
221 | 232 |
222 AXID getAXID(AXObject*); | 233 AXID getAXID(AXObject*); |
223 }; | 234 }; |
224 | 235 |
225 bool nodeHasRole(Node*, const String& role); | 236 bool nodeHasRole(Node*, const String& role); |
226 // This will let you know if aria-hidden was explicitly set to false. | 237 // This will let you know if aria-hidden was explicitly set to false. |
227 bool isNodeAriaVisible(Node*); | 238 bool isNodeAriaVisible(Node*); |
228 | 239 |
229 #if !HAVE(ACCESSIBILITY) | 240 #if !HAVE(ACCESSIBILITY) |
230 inline AXObjectInclusion AXComputedObjectAttributeCache::getIgnored(AXID) const
{ return DefaultBehavior; } | 241 inline AXObjectInclusion AXComputedObjectAttributeCache::getIgnored(AXID) const
{ return DefaultBehavior; } |
231 inline void AXComputedObjectAttributeCache::setIgnored(AXID, AXObjectInclusion)
{ } | 242 inline void AXComputedObjectAttributeCache::setIgnored(AXID, AXObjectInclusion)
{ } |
232 inline AXObjectCache::AXObjectCache(const Document* doc) : m_document(const_cast
<Document*>(doc)), m_notificationPostTimer(this, 0) { } | 243 inline AXObjectCache::AXObjectCache(const Document* doc) : m_document(const_cast
<Document*>(doc)), m_notificationPostTimer(this, 0) { } |
233 inline AXObjectCache::~AXObjectCache() { } | 244 inline AXObjectCache::~AXObjectCache() { } |
234 inline AXObject* AXObjectCache::focusedUIElementForPage(const Page*) { return 0;
} | 245 inline AXObject* AXObjectCache::focusedUIElementForPage(const Page*) { return 0;
} |
235 inline AXObject* AXObjectCache::get(RenderObject*) { return 0; } | 246 inline AXObject* AXObjectCache::get(RenderObject*) { return 0; } |
236 inline AXObject* AXObjectCache::get(Node*) { return 0; } | 247 inline AXObject* AXObjectCache::get(Node*) { return 0; } |
237 inline AXObject* AXObjectCache::get(Widget*) { return 0; } | 248 inline AXObject* AXObjectCache::get(Widget*) { return 0; } |
| 249 inline AXObject* AXObjectCache::get(AbstractInlineTextBox*) { return 0; } |
238 inline AXObject* AXObjectCache::getOrCreate(AccessibilityRole) { return 0; } | 250 inline AXObject* AXObjectCache::getOrCreate(AccessibilityRole) { return 0; } |
239 inline AXObject* AXObjectCache::getOrCreate(RenderObject*) { return 0; } | 251 inline AXObject* AXObjectCache::getOrCreate(RenderObject*) { return 0; } |
240 inline AXObject* AXObjectCache::getOrCreate(Node*) { return 0; } | 252 inline AXObject* AXObjectCache::getOrCreate(Node*) { return 0; } |
241 inline AXObject* AXObjectCache::getOrCreate(Widget*) { return 0; } | 253 inline AXObject* AXObjectCache::getOrCreate(Widget*) { return 0; } |
| 254 inline AXObject* AXObjectCache::getOrCreate(AbstractInlineTextBox*) { return 0;
} |
242 inline AXObject* AXObjectCache::rootObject() { return 0; } | 255 inline AXObject* AXObjectCache::rootObject() { return 0; } |
243 inline Element* AXObjectCache::rootAXEditableElement(Node*) { return 0; } | 256 inline Element* AXObjectCache::rootAXEditableElement(Node*) { return 0; } |
244 inline bool nodeHasRole(Node*, const String&) { return false; } | 257 inline bool nodeHasRole(Node*, const String&) { return false; } |
245 inline void AXObjectCache::startCachingComputedObjectAttributesUntilTreeMutates(
) { } | 258 inline void AXObjectCache::startCachingComputedObjectAttributesUntilTreeMutates(
) { } |
246 inline void AXObjectCache::stopCachingComputedObjectAttributes() { } | 259 inline void AXObjectCache::stopCachingComputedObjectAttributes() { } |
247 inline bool isNodeAriaVisible(Node*) { return true; } | 260 inline bool isNodeAriaVisible(Node*) { return true; } |
248 inline const Element* AXObjectCache::rootAXEditableElement(const Node*) { return
0; } | 261 inline const Element* AXObjectCache::rootAXEditableElement(const Node*) { return
0; } |
249 inline void AXObjectCache::attachWrapper(AXObject*) { } | 262 inline void AXObjectCache::attachWrapper(AXObject*) { } |
250 inline void AXObjectCache::checkedStateChanged(Node*) { } | 263 inline void AXObjectCache::checkedStateChanged(Node*) { } |
251 inline void AXObjectCache::childrenChanged(RenderObject*) { } | 264 inline void AXObjectCache::childrenChanged(RenderObject*) { } |
(...skipping 15 matching lines...) Expand all Loading... |
267 inline void AXObjectCache::nodeTextChangeNotification(Node*, AXTextChange, unsig
ned, const String&) { } | 280 inline void AXObjectCache::nodeTextChangeNotification(Node*, AXTextChange, unsig
ned, const String&) { } |
268 inline void AXObjectCache::nodeTextChangePlatformNotification(AXObject*, AXTextC
hange, unsigned, const String&) { } | 281 inline void AXObjectCache::nodeTextChangePlatformNotification(AXObject*, AXTextC
hange, unsigned, const String&) { } |
269 inline void AXObjectCache::postNotification(AXObject*, Document*, AXNotification
, bool, PostType) { } | 282 inline void AXObjectCache::postNotification(AXObject*, Document*, AXNotification
, bool, PostType) { } |
270 inline void AXObjectCache::postNotification(RenderObject*, AXNotification, bool,
PostType) { } | 283 inline void AXObjectCache::postNotification(RenderObject*, AXNotification, bool,
PostType) { } |
271 inline void AXObjectCache::postNotification(Node*, AXNotification, bool, PostTyp
e) { } | 284 inline void AXObjectCache::postNotification(Node*, AXNotification, bool, PostTyp
e) { } |
272 inline void AXObjectCache::postPlatformNotification(AXObject*, AXNotification) {
} | 285 inline void AXObjectCache::postPlatformNotification(AXObject*, AXNotification) {
} |
273 inline void AXObjectCache::remove(AXID) { } | 286 inline void AXObjectCache::remove(AXID) { } |
274 inline void AXObjectCache::remove(RenderObject*) { } | 287 inline void AXObjectCache::remove(RenderObject*) { } |
275 inline void AXObjectCache::remove(Node*) { } | 288 inline void AXObjectCache::remove(Node*) { } |
276 inline void AXObjectCache::remove(Widget*) { } | 289 inline void AXObjectCache::remove(Widget*) { } |
| 290 inline void AXObjectCache::remove(AbstractInlineTextBox*) { } |
277 inline void AXObjectCache::selectedChildrenChanged(RenderObject*) { } | 291 inline void AXObjectCache::selectedChildrenChanged(RenderObject*) { } |
278 inline void AXObjectCache::selectedChildrenChanged(Node*) { } | 292 inline void AXObjectCache::selectedChildrenChanged(Node*) { } |
279 #endif | 293 #endif |
280 | 294 |
281 } | 295 } |
282 | 296 |
283 #endif | 297 #endif |
OLD | NEW |