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

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: Created 5 years, 9 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
« Source/web/PopupListBox.cpp ('K') | « Source/web/PopupMenuImpl.h ('k') | no next file » | 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/NodeLayoutStyle.h" 10 #include "core/dom/NodeLayoutStyle.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 PassRefPtrWillBeRawPtr<PopupMenuImpl> PopupMenuImpl::create(ChromeClientImpl* ch romeClient, PopupMenuClient* client) 61 PassRefPtrWillBeRawPtr<PopupMenuImpl> PopupMenuImpl::create(ChromeClientImpl* ch romeClient, PopupMenuClient* client)
62 { 62 {
63 return adoptRefWillBeNoop(new PopupMenuImpl(chromeClient, client)); 63 return adoptRefWillBeNoop(new PopupMenuImpl(chromeClient, client));
64 } 64 }
65 65
66 PopupMenuImpl::PopupMenuImpl(ChromeClientImpl* chromeClient, PopupMenuClient* cl ient) 66 PopupMenuImpl::PopupMenuImpl(ChromeClientImpl* chromeClient, PopupMenuClient* cl ient)
67 : m_chromeClient(chromeClient) 67 : m_chromeClient(chromeClient)
68 , m_client(client) 68 , m_client(client)
69 , m_popup(nullptr) 69 , m_popup(nullptr)
70 , m_indexToSetOnClose(-1)
71 { 70 {
72 } 71 }
73 72
74 PopupMenuImpl::~PopupMenuImpl() 73 PopupMenuImpl::~PopupMenuImpl()
75 { 74 {
76 ASSERT(!m_popup); 75 ASSERT(!m_popup);
77 } 76 }
78 77
79 IntSize PopupMenuImpl::contentSize() 78 IntSize PopupMenuImpl::contentSize()
80 { 79 {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 void PopupMenuImpl::setValueAndClosePopup(int numValue, const String& stringValu e) 229 void PopupMenuImpl::setValueAndClosePopup(int numValue, const String& stringValu e)
231 { 230 {
232 ASSERT(m_popup); 231 ASSERT(m_popup);
233 ASSERT(m_client); 232 ASSERT(m_client);
234 RefPtrWillBeRawPtr<PopupMenuImpl> protector(this); 233 RefPtrWillBeRawPtr<PopupMenuImpl> protector(this);
235 bool success; 234 bool success;
236 int listIndex = stringValue.toInt(&success); 235 int listIndex = stringValue.toInt(&success);
237 ASSERT(success); 236 ASSERT(success);
238 m_client->selectionChanged(listIndex); 237 m_client->selectionChanged(listIndex);
239 m_client->valueChanged(listIndex); 238 m_client->valueChanged(listIndex);
240 m_indexToSetOnClose = -1;
241 closePopup(); 239 closePopup();
242 } 240 }
243 241
244 void PopupMenuImpl::setValue(const String& value) 242 void PopupMenuImpl::setValue(const String& value)
245 { 243 {
246 ASSERT(m_client); 244 ASSERT(m_client);
247 bool success; 245 bool success;
248 int listIndex = value.toInt(&success); 246 int listIndex = value.toInt(&success);
249 ASSERT(success); 247 ASSERT(success);
250 m_client->setTextFromItem(listIndex); 248 m_client->setProvisionallySelectedListIndex(listIndex);
251 m_indexToSetOnClose = listIndex;
252 } 249 }
253 250
254 void PopupMenuImpl::didClosePopup() 251 void PopupMenuImpl::didClosePopup()
255 { 252 {
256 // Clearing m_popup first to prevent from trying to close the popup again. 253 // Clearing m_popup first to prevent from trying to close the popup again.
257 m_popup = nullptr; 254 m_popup = nullptr;
258 RefPtrWillBeRawPtr<PopupMenuImpl> protector(this); 255 RefPtrWillBeRawPtr<PopupMenuImpl> protector(this);
259 if (m_client && m_indexToSetOnClose >= 0) {
260 // valueChanged() will dispatch a 'change' event.
261 m_client->valueChanged(m_indexToSetOnClose);
262 }
263 m_indexToSetOnClose = -1;
264 if (m_client) 256 if (m_client)
265 m_client->popupDidHide(); 257 m_client->popupDidHide();
266 } 258 }
267 259
268 Element& PopupMenuImpl::ownerElement() 260 Element& PopupMenuImpl::ownerElement()
269 { 261 {
270 return m_client->ownerElement(); 262 return m_client->ownerElement();
271 } 263 }
272 264
273 Locale& PopupMenuImpl::locale() 265 Locale& PopupMenuImpl::locale()
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 314
323 void PopupMenuImpl::disconnectClient() 315 void PopupMenuImpl::disconnectClient()
324 { 316 {
325 m_client = nullptr; 317 m_client = nullptr;
326 // Cannot be done during finalization, so instead done when the 318 // Cannot be done during finalization, so instead done when the
327 // render object is destroyed and disconnected. 319 // render object is destroyed and disconnected.
328 dispose(); 320 dispose();
329 } 321 }
330 322
331 } // namespace blink 323 } // namespace blink
OLDNEW
« Source/web/PopupListBox.cpp ('K') | « Source/web/PopupMenuImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698