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

Side by Side Diff: third_party/WebKit/Source/web/ExternalPopupMenu.cpp

Issue 1865813002: Remove RawPtr from Source/web/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 8 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 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 void ExternalPopupMenu::didChangeSelection(int index) 180 void ExternalPopupMenu::didChangeSelection(int index)
181 { 181 {
182 } 182 }
183 183
184 void ExternalPopupMenu::didAcceptIndex(int index) 184 void ExternalPopupMenu::didAcceptIndex(int index)
185 { 185 {
186 // Calling methods on the HTMLSelectElement might lead to this object being 186 // Calling methods on the HTMLSelectElement might lead to this object being
187 // derefed. This ensures it does not get deleted while we are running this 187 // derefed. This ensures it does not get deleted while we are running this
188 // method. 188 // method.
189 int popupMenuItemIndex = toPopupMenuItemIndex(index, *m_ownerElement); 189 int popupMenuItemIndex = toPopupMenuItemIndex(index, *m_ownerElement);
190 RawPtr<ExternalPopupMenu> guard(this);
191 190
192 if (m_ownerElement) { 191 if (m_ownerElement) {
193 m_ownerElement->popupDidHide(); 192 m_ownerElement->popupDidHide();
194 m_ownerElement->valueChanged(popupMenuItemIndex); 193 m_ownerElement->valueChanged(popupMenuItemIndex);
195 } 194 }
196 m_webExternalPopupMenu = 0; 195 m_webExternalPopupMenu = 0;
197 } 196 }
198 197
199 void ExternalPopupMenu::didAcceptIndices(const WebVector<int>& indices) 198 void ExternalPopupMenu::didAcceptIndices(const WebVector<int>& indices)
200 { 199 {
201 if (!m_ownerElement) { 200 if (!m_ownerElement) {
202 m_webExternalPopupMenu = 0; 201 m_webExternalPopupMenu = 0;
203 return; 202 return;
204 } 203 }
205 204
206 // Calling methods on the HTMLSelectElement might lead to this object being
207 // derefed. This ensures it does not get deleted while we are running this
208 // method.
209 RawPtr<ExternalPopupMenu> protect(this);
210 RawPtr<HTMLSelectElement> ownerElement(m_ownerElement.get()); 205 RawPtr<HTMLSelectElement> ownerElement(m_ownerElement.get());
211 ownerElement->popupDidHide(); 206 ownerElement->popupDidHide();
212 207
213 if (indices.size() == 0) { 208 if (indices.size() == 0) {
214 ownerElement->valueChanged(static_cast<unsigned>(-1)); 209 ownerElement->valueChanged(static_cast<unsigned>(-1));
215 } else { 210 } else {
216 for (size_t i = 0; i < indices.size(); ++i) 211 for (size_t i = 0; i < indices.size(); ++i)
217 ownerElement->listBoxSelectItem(toPopupMenuItemIndex(indices[i], *ow nerElement), (i > 0), false, (i == indices.size() - 1)); 212 ownerElement->listBoxSelectItem(toPopupMenuItemIndex(indices[i], *ow nerElement), (i > 0), false, (i == indices.size() - 1));
218 } 213 }
219 214
220 m_webExternalPopupMenu = 0; 215 m_webExternalPopupMenu = 0;
221 } 216 }
222 217
223 void ExternalPopupMenu::didCancel() 218 void ExternalPopupMenu::didCancel()
224 { 219 {
225 // See comment in didAcceptIndex on why we need this.
226 RawPtr<ExternalPopupMenu> guard(this);
227
228 if (m_ownerElement) 220 if (m_ownerElement)
229 m_ownerElement->popupDidHide(); 221 m_ownerElement->popupDidHide();
230 m_webExternalPopupMenu = 0; 222 m_webExternalPopupMenu = 0;
231 } 223 }
232 224
233 void ExternalPopupMenu::getPopupMenuInfo(WebPopupMenuInfo& info, HTMLSelectEleme nt& ownerElement) 225 void ExternalPopupMenu::getPopupMenuInfo(WebPopupMenuInfo& info, HTMLSelectEleme nt& ownerElement)
234 { 226 {
235 const HeapVector<Member<HTMLElement>>& listItems = ownerElement.listItems(); 227 const HeapVector<Member<HTMLElement>>& listItems = ownerElement.listItems();
236 size_t itemCount = listItems.size(); 228 size_t itemCount = listItems.size();
237 size_t count = 0; 229 size_t count = 0;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 if (ownerElement.itemIsDisplayNone(*items[i])) 290 if (ownerElement.itemIsDisplayNone(*items[i]))
299 continue; 291 continue;
300 if (popupMenuItemIndex == i) 292 if (popupMenuItemIndex == i)
301 return indexTracker; 293 return indexTracker;
302 ++indexTracker; 294 ++indexTracker;
303 } 295 }
304 return -1; 296 return -1;
305 } 297 }
306 298
307 } // namespace blink 299 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/ExternalDateTimeChooser.cpp ('k') | third_party/WebKit/Source/web/ExternalPopupMenuTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698