Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: Source/core/accessibility/AXObjectCacheImpl.h

Issue 713933002: Create Source/modules/accessibility/ and move most of core/accessibility/* into it (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2014, 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
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef AXObjectCacheImpl_h
30 #define AXObjectCacheImpl_h
31
32 #include "core/accessibility/AXObject.h"
33 #include "core/accessibility/AXObjectCache.h"
34 #include "core/rendering/RenderText.h"
35 #include "platform/Timer.h"
36 #include "wtf/Forward.h"
37 #include "wtf/HashMap.h"
38 #include "wtf/HashSet.h"
39 #include "wtf/RefPtr.h"
40
41 namespace blink {
42
43 class AbstractInlineTextBox;
44 class HTMLAreaElement;
45 class FrameView;
46 class Widget;
47
48 struct TextMarkerData {
49 AXID axID;
50 Node* node;
51 int offset;
52 EAffinity affinity;
53 };
54
55 // This class should only be used from inside the accessibility directory.
56 class AXObjectCacheImpl : public AXObjectCache {
57 WTF_MAKE_NONCOPYABLE(AXObjectCacheImpl); WTF_MAKE_FAST_ALLOCATED;
58 public:
59 explicit AXObjectCacheImpl(Document&);
60 ~AXObjectCacheImpl();
61
62 static AXObject* focusedUIElementForPage(const Page*);
63
64 virtual AXObject* objectFromAXID(AXID id) const override { return m_objects. get(id); }
65
66 virtual AXObject* root() override;
67 virtual AXObject* getOrCreateAXObjectFromRenderView(RenderView*) override;
68
69 virtual void selectionChanged(Node*) override;
70 virtual void childrenChanged(Node*) override;
71 virtual void childrenChanged(RenderObject*) override;
72 virtual void childrenChanged(Widget*) override;
73 virtual void checkedStateChanged(Node*) override;
74 virtual void selectedChildrenChanged(Node*) override;
75
76 // will only return the AXObject if it already exists
77 virtual AXObject* get(Node*);
78
79 virtual void remove(RenderObject*) override;
80 virtual void remove(Node*) override;
81 virtual void remove(Widget*) override;
82 virtual void remove(AbstractInlineTextBox*) override;
83
84 virtual const Element* rootAXEditableElement(const Node*) override;
85 virtual bool nodeIsTextControl(const Node*) override;
86
87 // Called by a node when text or a text equivalent (e.g. alt) attribute is c hanged.
88 virtual void textChanged(Node*) override;
89 virtual void textChanged(RenderObject*) override;
90 // Called when a node has just been attached, so we can make sure we have th e right subclass of AXObject.
91 virtual void updateCacheAfterNodeIsAttached(Node*) override;
92
93 virtual void handleAttributeChanged(const QualifiedName& attrName, Element*) override;
94 virtual void handleFocusedUIElementChanged(Node* oldFocusedNode, Node* newFo cusedNode) override;
95 virtual void handleInitialFocus() override;
96 virtual void handleTextFormControlChanged(Node*) override;
97 virtual void handleEditableTextContentChanged(Node*) override;
98 virtual void handleValueChanged(Node*) override;
99 virtual void handleUpdateActiveMenuOption(RenderMenuList*, int optionIndex) override;
100 virtual void handleLoadComplete(Document*) override;
101 virtual void handleLayoutComplete(Document*) override;
102
103 virtual void setCanvasObjectBounds(Element*, const LayoutRect&) override;
104
105 virtual void clearWeakMembers(Visitor*) override;
106
107 virtual void inlineTextBoxesUpdated(RenderObject* renderer) override;
108
109 // Called when the scroll offset changes.
110 virtual void handleScrollPositionChanged(FrameView*) override;
111 virtual void handleScrollPositionChanged(RenderObject*) override;
112
113 // Called when scroll bars are added / removed (as the view resizes).
114 void handleScrollbarUpdate(FrameView*) override;
115 void handleLayoutComplete(RenderObject*) override;
116 void handleScrolledToAnchor(const Node* anchorNode) override;
117
118 // Returns the root object for the entire document.
119 AXObject* rootObject();
120
121 // used for objects without backing elements
122 AXObject* getOrCreate(AccessibilityRole);
123 AXObject* getOrCreate(RenderObject*);
124 AXObject* getOrCreate(Widget*);
125 AXObject* getOrCreate(Node*);
126 AXObject* getOrCreate(AbstractInlineTextBox*);
127
128 // will only return the AXObject if it already exists
129 AXObject* get(RenderObject*);
130 AXObject* get(Widget*);
131 AXObject* get(AbstractInlineTextBox*);
132
133 void remove(AXID);
134
135 void detachWrapper(AXObject*);
136 void attachWrapper(AXObject*);
137 void childrenChanged(AXObject*);
138 void selectedChildrenChanged(RenderObject*);
139
140 void handleActiveDescendantChanged(Node*);
141 void handleAriaRoleChanged(Node*);
142 void handleAriaExpandedChange(Node*);
143
144 void recomputeIsIgnored(RenderObject* renderer);
145
146 bool accessibilityEnabled();
147 bool inlineTextBoxAccessibilityEnabled();
148
149 void removeAXID(AXObject*);
150 bool isIDinUse(AXID id) const { return m_idsInUse.contains(id); }
151
152 AXID platformGenerateAXID() const;
153
154 bool nodeHasRole(Node*, const AtomicString& role);
155
156 // Counts the number of times the document has been modified. Some attribute values are cached
157 // as long as the modification count hasn't changed.
158 int modificationCount() const { return m_modificationCount; }
159
160 void postNotification(RenderObject*, AXNotification, bool postToElement);
161 void postNotification(Node*, AXNotification, bool postToElement);
162 void postNotification(AXObject*, Document*, AXNotification, bool postToEleme nt);
163
164 protected:
165 void postPlatformNotification(AXObject*, AXNotification);
166 void textChanged(AXObject*);
167 void labelChanged(Element*);
168
169 // This is a weak reference cache for knowing if Nodes used by TextMarkers a re valid.
170 void setNodeInUse(Node* n) { m_textMarkerNodes.add(n); }
171 void removeNodeForUse(Node* n) { m_textMarkerNodes.remove(n); }
172 bool isNodeInUse(Node* n) { return m_textMarkerNodes.contains(n); }
173
174 private:
175 Document& m_document;
176 HashMap<AXID, RefPtr<AXObject> > m_objects;
177 HashMap<RenderObject*, AXID> m_renderObjectMapping;
178 HashMap<Widget*, AXID> m_widgetObjectMapping;
179 HashMap<Node*, AXID> m_nodeObjectMapping;
180 HashMap<AbstractInlineTextBox*, AXID> m_inlineTextBoxObjectMapping;
181 HashSet<Node*> m_textMarkerNodes;
182 int m_modificationCount;
183
184 HashSet<AXID> m_idsInUse;
185
186 Timer<AXObjectCacheImpl> m_notificationPostTimer;
187 Vector<pair<RefPtr<AXObject>, AXNotification> > m_notificationsToPost;
188 void notificationPostTimerFired(Timer<AXObjectCacheImpl>*);
189
190 static AXObject* focusedImageMapUIElement(HTMLAreaElement*);
191
192 AXID getAXID(AXObject*);
193
194 Settings* settings();
195 };
196
197 // This is the only subclass of AXObjectCache.
198 DEFINE_TYPE_CASTS(AXObjectCacheImpl, AXObjectCache, cache, true, true);
199
200 bool nodeHasRole(Node*, const String& role);
201 // This will let you know if aria-hidden was explicitly set to false.
202 bool isNodeAriaVisible(Node*);
203
204 }
205
206 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698