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

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

Issue 670093002: Get rid of AXComputedObjectAttributeCache (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix comment Created 6 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/accessibility/AXObject.cpp ('k') | Source/core/accessibility/AXObjectCacheImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014, Google Inc. All rights reserved. 2 * Copyright (C) 2014, Google 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 class FrameView; 45 class FrameView;
46 class Widget; 46 class Widget;
47 47
48 struct TextMarkerData { 48 struct TextMarkerData {
49 AXID axID; 49 AXID axID;
50 Node* node; 50 Node* node;
51 int offset; 51 int offset;
52 EAffinity affinity; 52 EAffinity affinity;
53 }; 53 };
54 54
55 class AXComputedObjectAttributeCache {
56 public:
57 static PassOwnPtr<AXComputedObjectAttributeCache> create() { return adoptPtr (new AXComputedObjectAttributeCache()); }
58
59 AXObjectInclusion getIgnored(AXID) const;
60 void setIgnored(AXID, AXObjectInclusion);
61
62 void clear();
63
64 private:
65 AXComputedObjectAttributeCache() { }
66
67 struct CachedAXObjectAttributes {
68 CachedAXObjectAttributes() : ignored(DefaultBehavior) { }
69
70 AXObjectInclusion ignored;
71 };
72
73 HashMap<AXID, CachedAXObjectAttributes> m_idMapping;
74 };
75
76 enum PostType { PostSynchronously, PostAsynchronously }; 55 enum PostType { PostSynchronously, PostAsynchronously };
77 56
78 // This class should only be used from inside the accessibility directory. 57 // This class should only be used from inside the accessibility directory.
79 class AXObjectCacheImpl : public AXObjectCache { 58 class AXObjectCacheImpl : public AXObjectCache {
80 WTF_MAKE_NONCOPYABLE(AXObjectCacheImpl); WTF_MAKE_FAST_ALLOCATED; 59 WTF_MAKE_NONCOPYABLE(AXObjectCacheImpl); WTF_MAKE_FAST_ALLOCATED;
81 public: 60 public:
82 explicit AXObjectCacheImpl(Document&); 61 explicit AXObjectCacheImpl(Document&);
83 ~AXObjectCacheImpl(); 62 ~AXObjectCacheImpl();
84 63
85 static AXObject* focusedUIElementForPage(const Page*); 64 static AXObject* focusedUIElementForPage(const Page*);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 bool accessibilityEnabled(); 146 bool accessibilityEnabled();
168 bool inlineTextBoxAccessibilityEnabled(); 147 bool inlineTextBoxAccessibilityEnabled();
169 148
170 void removeAXID(AXObject*); 149 void removeAXID(AXObject*);
171 bool isIDinUse(AXID id) const { return m_idsInUse.contains(id); } 150 bool isIDinUse(AXID id) const { return m_idsInUse.contains(id); }
172 151
173 AXID platformGenerateAXID() const; 152 AXID platformGenerateAXID() const;
174 153
175 bool nodeHasRole(Node*, const AtomicString& role); 154 bool nodeHasRole(Node*, const AtomicString& role);
176 155
177 AXComputedObjectAttributeCache* computedObjectAttributeCache() { return m_co mputedObjectAttributeCache.get(); } 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; }
178 159
179 void postNotification(RenderObject*, AXNotification, bool postToElement, Pos tType = PostAsynchronously); 160 void postNotification(RenderObject*, AXNotification, bool postToElement, Pos tType = PostAsynchronously);
180 void postNotification(Node*, AXNotification, bool postToElement, PostType = PostAsynchronously); 161 void postNotification(Node*, AXNotification, bool postToElement, PostType = PostAsynchronously);
181 void postNotification(AXObject*, Document*, AXNotification, bool postToEleme nt, PostType = PostAsynchronously); 162 void postNotification(AXObject*, Document*, AXNotification, bool postToEleme nt, PostType = PostAsynchronously);
182 163
183 protected: 164 protected:
184 void postPlatformNotification(AXObject*, AXNotification); 165 void postPlatformNotification(AXObject*, AXNotification);
185 void textChanged(AXObject*); 166 void textChanged(AXObject*);
186 void labelChanged(Element*); 167 void labelChanged(Element*);
187 168
188 // This is a weak reference cache for knowing if Nodes used by TextMarkers a re valid. 169 // This is a weak reference cache for knowing if Nodes used by TextMarkers a re valid.
189 void setNodeInUse(Node* n) { m_textMarkerNodes.add(n); } 170 void setNodeInUse(Node* n) { m_textMarkerNodes.add(n); }
190 void removeNodeForUse(Node* n) { m_textMarkerNodes.remove(n); } 171 void removeNodeForUse(Node* n) { m_textMarkerNodes.remove(n); }
191 bool isNodeInUse(Node* n) { return m_textMarkerNodes.contains(n); } 172 bool isNodeInUse(Node* n) { return m_textMarkerNodes.contains(n); }
192 173
193 private: 174 private:
194 Document& m_document; 175 Document& m_document;
195 HashMap<AXID, RefPtr<AXObject> > m_objects; 176 HashMap<AXID, RefPtr<AXObject> > m_objects;
196 HashMap<RenderObject*, AXID> m_renderObjectMapping; 177 HashMap<RenderObject*, AXID> m_renderObjectMapping;
197 HashMap<Widget*, AXID> m_widgetObjectMapping; 178 HashMap<Widget*, AXID> m_widgetObjectMapping;
198 HashMap<Node*, AXID> m_nodeObjectMapping; 179 HashMap<Node*, AXID> m_nodeObjectMapping;
199 HashMap<AbstractInlineTextBox*, AXID> m_inlineTextBoxObjectMapping; 180 HashMap<AbstractInlineTextBox*, AXID> m_inlineTextBoxObjectMapping;
200 HashSet<Node*> m_textMarkerNodes; 181 HashSet<Node*> m_textMarkerNodes;
201 OwnPtr<AXComputedObjectAttributeCache> m_computedObjectAttributeCache; 182 int m_modificationCount;
202 183
203 HashSet<AXID> m_idsInUse; 184 HashSet<AXID> m_idsInUse;
204 185
205 Timer<AXObjectCacheImpl> m_notificationPostTimer; 186 Timer<AXObjectCacheImpl> m_notificationPostTimer;
206 Vector<pair<RefPtr<AXObject>, AXNotification> > m_notificationsToPost; 187 Vector<pair<RefPtr<AXObject>, AXNotification> > m_notificationsToPost;
207 void notificationPostTimerFired(Timer<AXObjectCacheImpl>*); 188 void notificationPostTimerFired(Timer<AXObjectCacheImpl>*);
208 189
209 static AXObject* focusedImageMapUIElement(HTMLAreaElement*); 190 static AXObject* focusedImageMapUIElement(HTMLAreaElement*);
210 191
211 AXID getAXID(AXObject*); 192 AXID getAXID(AXObject*);
212 193
213 Settings* settings(); 194 Settings* settings();
214 }; 195 };
215 196
216 // This is the only subclass of AXObjectCache. 197 // This is the only subclass of AXObjectCache.
217 DEFINE_TYPE_CASTS(AXObjectCacheImpl, AXObjectCache, cache, true, true); 198 DEFINE_TYPE_CASTS(AXObjectCacheImpl, AXObjectCache, cache, true, true);
218 199
219 bool nodeHasRole(Node*, const String& role); 200 bool nodeHasRole(Node*, const String& role);
220 // This will let you know if aria-hidden was explicitly set to false. 201 // This will let you know if aria-hidden was explicitly set to false.
221 bool isNodeAriaVisible(Node*); 202 bool isNodeAriaVisible(Node*);
222 203
223 } 204 }
224 205
225 #endif 206 #endif
OLDNEW
« no previous file with comments | « Source/core/accessibility/AXObject.cpp ('k') | Source/core/accessibility/AXObjectCacheImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698