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

Side by Side Diff: Source/modules/accessibility/AXMenuListPopup.cpp

Issue 1175533004: Refactor: Clear m_axObjectCache when AXObject detaches (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added ASSERT Created 5 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2010 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
(...skipping 16 matching lines...) Expand all
27 #include "modules/accessibility/AXMenuListPopup.h" 27 #include "modules/accessibility/AXMenuListPopup.h"
28 28
29 #include "core/html/HTMLSelectElement.h" 29 #include "core/html/HTMLSelectElement.h"
30 #include "modules/accessibility/AXMenuListOption.h" 30 #include "modules/accessibility/AXMenuListOption.h"
31 #include "modules/accessibility/AXObjectCacheImpl.h" 31 #include "modules/accessibility/AXObjectCacheImpl.h"
32 32
33 namespace blink { 33 namespace blink {
34 34
35 using namespace HTMLNames; 35 using namespace HTMLNames;
36 36
37 AXMenuListPopup::AXMenuListPopup(AXObjectCacheImpl* axObjectCache) 37 AXMenuListPopup::AXMenuListPopup(AXObjectCacheImpl& axObjectCache)
38 : AXMockObject(axObjectCache), m_activeIndex(-1) 38 : AXMockObject(axObjectCache), m_activeIndex(-1)
39 { 39 {
40 } 40 }
41 41
42 bool AXMenuListPopup::isVisible() const 42 bool AXMenuListPopup::isVisible() const
43 { 43 {
44 return !isOffScreen(); 44 return !isOffScreen();
45 } 45 }
46 46
47 bool AXMenuListPopup::isOffScreen() const 47 bool AXMenuListPopup::isOffScreen() const
(...skipping 16 matching lines...) Expand all
64 { 64 {
65 return accessibilityIsIgnoredByDefault(ignoredReasons); 65 return accessibilityIsIgnoredByDefault(ignoredReasons);
66 } 66 }
67 67
68 AXMenuListOption* AXMenuListPopup::menuListOptionAXObject(HTMLElement* element) const 68 AXMenuListOption* AXMenuListPopup::menuListOptionAXObject(HTMLElement* element) const
69 { 69 {
70 ASSERT(element); 70 ASSERT(element);
71 if (!isHTMLOptionElement(*element)) 71 if (!isHTMLOptionElement(*element))
72 return 0; 72 return 0;
73 73
74 AXObject* object = axObjectCache()->getOrCreate(element); 74 AXObject* object = axObjectCache().getOrCreate(element);
75 if (!object || !object->isMenuListOption()) 75 if (!object || !object->isMenuListOption())
76 return 0; 76 return 0;
77 77
78 return toAXMenuListOption(object); 78 return toAXMenuListOption(object);
79 } 79 }
80 80
81 int AXMenuListPopup::getSelectedIndex() const 81 int AXMenuListPopup::getSelectedIndex() const
82 { 82 {
83 if (!m_parent) 83 if (!m_parent)
84 return -1; 84 return -1;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 clearChildren(); 132 clearChildren();
133 133
134 if (!m_haveChildren) 134 if (!m_haveChildren)
135 addChildren(); 135 addChildren();
136 } 136 }
137 137
138 void AXMenuListPopup::didUpdateActiveOption(int optionIndex) 138 void AXMenuListPopup::didUpdateActiveOption(int optionIndex)
139 { 139 {
140 updateChildrenIfNecessary(); 140 updateChildrenIfNecessary();
141 141
142 AXObjectCacheImpl* cache = axObjectCache(); 142 AXObjectCacheImpl& cache = axObjectCache();
143 if (m_activeIndex != optionIndex && m_activeIndex >= 0 && m_activeIndex < st atic_cast<int>(m_children.size())) { 143 if (m_activeIndex != optionIndex && m_activeIndex >= 0 && m_activeIndex < st atic_cast<int>(m_children.size())) {
144 RefPtr<AXObject> previousChild = m_children[m_activeIndex].get(); 144 RefPtr<AXObject> previousChild = m_children[m_activeIndex].get();
145 cache->postNotification(previousChild.get(), AXObjectCacheImpl::AXMenuLi stItemUnselected); 145 cache.postNotification(previousChild.get(), AXObjectCacheImpl::AXMenuLis tItemUnselected);
146 } 146 }
147 147
148 if (optionIndex >= 0 && optionIndex < static_cast<int>(m_children.size())) { 148 if (optionIndex >= 0 && optionIndex < static_cast<int>(m_children.size())) {
149 RefPtr<AXObject> child = m_children[optionIndex].get(); 149 RefPtr<AXObject> child = m_children[optionIndex].get();
150 cache->postNotification(child.get(), AXObjectCacheImpl::AXFocusedUIEleme ntChanged); 150 cache.postNotification(child.get(), AXObjectCacheImpl::AXFocusedUIElemen tChanged);
151 cache->postNotification(child.get(), AXObjectCacheImpl::AXMenuListItemSe lected); 151 cache.postNotification(child.get(), AXObjectCacheImpl::AXMenuListItemSel ected);
152 } 152 }
153 153
154 m_activeIndex = optionIndex; 154 m_activeIndex = optionIndex;
155 } 155 }
156 156
157 void AXMenuListPopup::didHide() 157 void AXMenuListPopup::didHide()
158 { 158 {
159 AXObjectCacheImpl* cache = axObjectCache(); 159 AXObjectCacheImpl& cache = axObjectCache();
160 cache->postNotification(this, AXObjectCacheImpl::AXHide); 160 cache.postNotification(this, AXObjectCacheImpl::AXHide);
161 if (activeChild()) 161 if (activeChild())
162 cache->postNotification(activeChild(), AXObjectCacheImpl::AXMenuListItem Unselected); 162 cache.postNotification(activeChild(), AXObjectCacheImpl::AXMenuListItemU nselected);
163 } 163 }
164 164
165 void AXMenuListPopup::didShow() 165 void AXMenuListPopup::didShow()
166 { 166 {
167 if (!m_haveChildren) 167 if (!m_haveChildren)
168 addChildren(); 168 addChildren();
169 169
170 AXObjectCacheImpl* cache = axObjectCache(); 170 AXObjectCacheImpl& cache = axObjectCache();
171 cache->postNotification(this, AXObjectCacheImpl::AXShow); 171 cache.postNotification(this, AXObjectCacheImpl::AXShow);
172 int selectedIndex = getSelectedIndex(); 172 int selectedIndex = getSelectedIndex();
173 if (selectedIndex >= 0 && selectedIndex < static_cast<int>(m_children.size() )) 173 if (selectedIndex >= 0 && selectedIndex < static_cast<int>(m_children.size() ))
174 didUpdateActiveOption(selectedIndex); 174 didUpdateActiveOption(selectedIndex);
175 else 175 else
176 cache->postNotification(m_parent, AXObjectCacheImpl::AXFocusedUIElementC hanged); 176 cache.postNotification(m_parent, AXObjectCacheImpl::AXFocusedUIElementCh anged);
177 } 177 }
178 178
179 AXObject* AXMenuListPopup::activeChild() 179 AXObject* AXMenuListPopup::activeChild()
180 { 180 {
181 if (m_activeIndex < 0 || m_activeIndex >= static_cast<int>(children().size() )) 181 if (m_activeIndex < 0 || m_activeIndex >= static_cast<int>(children().size() ))
182 return nullptr; 182 return nullptr;
183 183
184 return m_children[m_activeIndex].get(); 184 return m_children[m_activeIndex].get();
185 } 185 }
186 186
187 } // namespace blink 187 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/accessibility/AXMenuListPopup.h ('k') | Source/modules/accessibility/AXMockObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698