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

Side by Side Diff: Source/web/PopupMenuImpl.cpp

Issue 1013303004: Fix issue on <select> style change when popup is visible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed test expectation Created 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/PopupMenuImpl.h ('k') | Source/web/PopupMenuTest.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 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "web/PopupMenuImpl.h" 6 #include "web/PopupMenuImpl.h"
7 7
8 #include "core/HTMLNames.h" 8 #include "core/HTMLNames.h"
9 #include "core/css/CSSFontSelector.h" 9 #include "core/css/CSSFontSelector.h"
10 #include "core/dom/ElementTraversal.h" 10 #include "core/dom/ElementTraversal.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 PassRefPtrWillBeRawPtr<PopupMenuImpl> PopupMenuImpl::create(ChromeClientImpl* ch romeClient, PopupMenuClient* client) 63 PassRefPtrWillBeRawPtr<PopupMenuImpl> PopupMenuImpl::create(ChromeClientImpl* ch romeClient, PopupMenuClient* client)
64 { 64 {
65 return adoptRefWillBeNoop(new PopupMenuImpl(chromeClient, client)); 65 return adoptRefWillBeNoop(new PopupMenuImpl(chromeClient, client));
66 } 66 }
67 67
68 PopupMenuImpl::PopupMenuImpl(ChromeClientImpl* chromeClient, PopupMenuClient* cl ient) 68 PopupMenuImpl::PopupMenuImpl(ChromeClientImpl* chromeClient, PopupMenuClient* cl ient)
69 : m_chromeClient(chromeClient) 69 : m_chromeClient(chromeClient)
70 , m_client(client) 70 , m_client(client)
71 , m_popup(nullptr) 71 , m_popup(nullptr)
72 , m_indexToSetOnClose(-1)
73 , m_needsUpdate(false) 72 , m_needsUpdate(false)
74 { 73 {
75 } 74 }
76 75
77 PopupMenuImpl::~PopupMenuImpl() 76 PopupMenuImpl::~PopupMenuImpl()
78 { 77 {
79 ASSERT(!m_popup); 78 ASSERT(!m_popup);
80 } 79 }
81 80
82 IntSize PopupMenuImpl::contentSize() 81 IntSize PopupMenuImpl::contentSize()
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 void PopupMenuImpl::setValueAndClosePopup(int numValue, const String& stringValu e) 232 void PopupMenuImpl::setValueAndClosePopup(int numValue, const String& stringValu e)
234 { 233 {
235 ASSERT(m_popup); 234 ASSERT(m_popup);
236 ASSERT(m_client); 235 ASSERT(m_client);
237 RefPtrWillBeRawPtr<PopupMenuImpl> protector(this); 236 RefPtrWillBeRawPtr<PopupMenuImpl> protector(this);
238 bool success; 237 bool success;
239 int listIndex = stringValue.toInt(&success); 238 int listIndex = stringValue.toInt(&success);
240 ASSERT(success); 239 ASSERT(success);
241 m_client->selectionChanged(listIndex); 240 m_client->selectionChanged(listIndex);
242 m_client->valueChanged(listIndex); 241 m_client->valueChanged(listIndex);
243 m_indexToSetOnClose = -1; 242 if (m_popup)
244 closePopup(); 243 m_chromeClient->closePagePopup(m_popup);
245 } 244 }
246 245
247 void PopupMenuImpl::setValue(const String& value) 246 void PopupMenuImpl::setValue(const String& value)
248 { 247 {
249 ASSERT(m_client); 248 ASSERT(m_client);
250 bool success; 249 bool success;
251 int listIndex = value.toInt(&success); 250 int listIndex = value.toInt(&success);
252 ASSERT(success); 251 ASSERT(success);
253 m_client->setTextFromItem(listIndex); 252 m_client->provisionalSelectionChanged(listIndex);
254 m_indexToSetOnClose = listIndex;
255 } 253 }
256 254
257 void PopupMenuImpl::didClosePopup() 255 void PopupMenuImpl::didClosePopup()
258 { 256 {
259 // Clearing m_popup first to prevent from trying to close the popup again. 257 // Clearing m_popup first to prevent from trying to close the popup again.
260 m_popup = nullptr; 258 m_popup = nullptr;
261 RefPtrWillBeRawPtr<PopupMenuImpl> protector(this); 259 RefPtrWillBeRawPtr<PopupMenuImpl> protector(this);
262 if (m_client && m_indexToSetOnClose >= 0) {
263 // valueChanged() will dispatch a 'change' event.
264 m_client->valueChanged(m_indexToSetOnClose);
265 }
266 m_indexToSetOnClose = -1;
267 if (m_client) 260 if (m_client)
268 m_client->popupDidHide(); 261 m_client->popupDidHide();
269 } 262 }
270 263
271 Element& PopupMenuImpl::ownerElement() 264 Element& PopupMenuImpl::ownerElement()
272 { 265 {
273 return m_client->ownerElement(); 266 return m_client->ownerElement();
274 } 267 }
275 268
276 Locale& PopupMenuImpl::locale() 269 Locale& PopupMenuImpl::locale()
277 { 270 {
278 return Locale::defaultLocale(); 271 return Locale::defaultLocale();
279 } 272 }
280 273
281 void PopupMenuImpl::closePopup() 274 void PopupMenuImpl::closePopup()
282 { 275 {
283 if (m_popup) 276 if (m_popup)
284 m_chromeClient->closePagePopup(m_popup); 277 m_chromeClient->closePagePopup(m_popup);
278 if (m_client)
279 m_client->popupDidCancel();
280 }
281
282 void PopupMenuImpl::dispose()
283 {
284 if (m_popup)
285 m_chromeClient->closePagePopup(m_popup);
285 } 286 }
286 287
287 void PopupMenuImpl::dispose()
288 {
289 closePopup();
290 }
291
292 void PopupMenuImpl::show(const FloatQuad& /*controlPosition*/, const IntSize& /* controlSize*/, int /*index*/) 288 void PopupMenuImpl::show(const FloatQuad& /*controlPosition*/, const IntSize& /* controlSize*/, int /*index*/)
293 { 289 {
294 ASSERT(!m_popup); 290 ASSERT(!m_popup);
295 m_popup = m_chromeClient->openPagePopup(this); 291 m_popup = m_chromeClient->openPagePopup(this);
296 } 292 }
297 293
298 void PopupMenuImpl::hide() 294 void PopupMenuImpl::hide()
299 { 295 {
300 if (m_popup) 296 if (m_popup)
301 m_chromeClient->closePagePopup(m_popup); 297 m_chromeClient->closePagePopup(m_popup);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 333
338 void PopupMenuImpl::disconnectClient() 334 void PopupMenuImpl::disconnectClient()
339 { 335 {
340 m_client = nullptr; 336 m_client = nullptr;
341 // Cannot be done during finalization, so instead done when the 337 // Cannot be done during finalization, so instead done when the
342 // render object is destroyed and disconnected. 338 // render object is destroyed and disconnected.
343 dispose(); 339 dispose();
344 } 340 }
345 341
346 } // namespace blink 342 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/PopupMenuImpl.h ('k') | Source/web/PopupMenuTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698