]> git.saurik.com Git - iphone-api.git/blame - WebCore/AXObjectCache.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / AXObjectCache.h
CommitLineData
a90939db
JF
1/*
2 * Copyright (C) 2003, 2006, 2007, 2008 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 COMPUTER, 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 COMPUTER, 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 AXObjectCache_h
27#define AXObjectCache_h
28
29#include "AccessibilityObject.h"
30#include <limits.h>
31#include <wtf/HashMap.h>
32#include <wtf/HashSet.h>
33#include <wtf/RefPtr.h>
34
35#ifdef __OBJC__
36@class WebCoreTextMarker;
37#else
38class WebCoreTextMarker;
39#endif
40
41namespace WebCore {
42
43 class RenderObject;
44 class String;
45 class VisiblePosition;
46 class AccessibilityObject;
47 class Node;
48
49 typedef unsigned AXID;
50
51 struct TextMarkerData {
52 AXID axID;
53 Node* node;
54 int offset;
55 EAffinity affinity;
56 };
57
58 class AXObjectCache {
59 public:
60 ~AXObjectCache();
61
62 // to be used with render objects
63 AccessibilityObject* get(RenderObject*);
64
65 // used for objects without backing elements
66 AccessibilityObject* get(AccessibilityRole);
67
68 void remove(RenderObject*);
69 void remove(AXID);
70
71 void detachWrapper(AccessibilityObject*);
72 void attachWrapper(AccessibilityObject*);
73 void postNotification(RenderObject*, const String&);
74 void postNotificationToElement(RenderObject*, const String&);
75 void childrenChanged(RenderObject*);
76 void selectedChildrenChanged(RenderObject*);
77 void handleActiveDescendantChanged(RenderObject*);
78 void handleAriaRoleChanged(RenderObject*);
79 static void enableAccessibility() { gAccessibilityEnabled = true; }
80 static void enableEnhancedUserInterfaceAccessibility() { gAccessibilityEnhancedUserInterfaceEnabled = true; }
81
82 static bool accessibilityEnabled() { return gAccessibilityEnabled; }
83 static bool accessibilityEnhancedUserInterfaceEnabled() { return gAccessibilityEnhancedUserInterfaceEnabled; }
84
85 void removeAXID(AccessibilityObject*);
86 bool isIDinUse(AXID id) const { return m_idsInUse.contains(id); }
87
88 private:
89 HashMap<AXID, RefPtr<AccessibilityObject> > m_objects;
90 HashMap<RenderObject*, AXID> m_renderObjectMapping;
91 static bool gAccessibilityEnabled;
92 static bool gAccessibilityEnhancedUserInterfaceEnabled;
93
94 HashSet<AXID> m_idsInUse;
95
96 AXID getAXID(AccessibilityObject*);
97 };
98
99#if !HAVE(ACCESSIBILITY)
100 inline void AXObjectCache::handleActiveDescendantChanged(RenderObject*) { }
101 inline void AXObjectCache::handleAriaRoleChanged(RenderObject*) { }
102 inline void AXObjectCache::detachWrapper(AccessibilityObject*) { }
103 inline void AXObjectCache::attachWrapper(AccessibilityObject*) { }
104 inline void AXObjectCache::selectedChildrenChanged(RenderObject*) { }
105 inline void AXObjectCache::postNotification(RenderObject*, const String&) { }
106 inline void AXObjectCache::postNotificationToElement(RenderObject*, const String&) { }
107#endif
108
109}
110
111#endif