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

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

Issue 2350303005: Fix a DCHECK failure in PopupMenuImpl::setValueAndClosePopup(). (Closed)
Patch Set: Created 4 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
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 "web/PopupMenuImpl.h" 5 #include "web/PopupMenuImpl.h"
6 6
7 #include "core/HTMLNames.h" 7 #include "core/HTMLNames.h"
8 #include "core/css/CSSFontSelector.h" 8 #include "core/css/CSSFontSelector.h"
9 #include "core/dom/ElementTraversal.h" 9 #include "core/dom/ElementTraversal.h"
10 #include "core/dom/ExecutionContextTask.h" 10 #include "core/dom/ExecutionContextTask.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 void PopupMenuImpl::selectFontsFromOwnerDocument(Document& document) 387 void PopupMenuImpl::selectFontsFromOwnerDocument(Document& document)
388 { 388 {
389 Document& ownerDocument = ownerElement().document(); 389 Document& ownerDocument = ownerElement().document();
390 document.styleEngine().setFontSelector(PopupMenuCSSFontSelector::create(&doc ument, ownerDocument.styleEngine().fontSelector())); 390 document.styleEngine().setFontSelector(PopupMenuCSSFontSelector::create(&doc ument, ownerDocument.styleEngine().fontSelector()));
391 } 391 }
392 392
393 void PopupMenuImpl::setValueAndClosePopup(int numValue, const String& stringValu e) 393 void PopupMenuImpl::setValueAndClosePopup(int numValue, const String& stringValu e)
394 { 394 {
395 DCHECK(m_popup); 395 DCHECK(m_popup);
396 DCHECK(m_ownerElement); 396 DCHECK(m_ownerElement);
397 bool success; 397 if (!stringValue.isEmpty()) {
398 int listIndex = stringValue.toInt(&success); 398 bool success;
399 DCHECK(success); 399 int listIndex = stringValue.toInt(&success);
400 { 400 DCHECK(success);
401
401 EventQueueScope scope; 402 EventQueueScope scope;
402 m_ownerElement->selectOptionByPopup(listIndex); 403 m_ownerElement->selectOptionByPopup(listIndex);
403 if (m_popup) 404 if (m_popup)
404 m_chromeClient->closePagePopup(m_popup); 405 m_chromeClient->closePagePopup(m_popup);
405 // 'change' event is dispatched here. For compatbility with 406 // 'change' event is dispatched here. For compatbility with
406 // Angular 1.2, we need to dispatch a change event before 407 // Angular 1.2, we need to dispatch a change event before
407 // mouseup/click events. 408 // mouseup/click events.
409 } else {
410 if (m_popup)
411 m_chromeClient->closePagePopup(m_popup);
408 } 412 }
409 // We dispatch events on the owner element to match the legacy behavior. 413 // We dispatch events on the owner element to match the legacy behavior.
410 // Other browsers dispatch click events before and after showing the popup. 414 // Other browsers dispatch click events before and after showing the popup.
411 if (m_ownerElement) { 415 if (m_ownerElement) {
412 PlatformMouseEvent event; 416 PlatformMouseEvent event;
413 Element* owner = &ownerElement(); 417 Element* owner = &ownerElement();
414 owner->dispatchMouseEvent(event, EventTypeNames::mouseup); 418 owner->dispatchMouseEvent(event, EventTypeNames::mouseup);
415 owner->dispatchMouseEvent(event, EventTypeNames::click); 419 owner->dispatchMouseEvent(event, EventTypeNames::click);
416 } 420 }
417 } 421 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 525
522 void PopupMenuImpl::disconnectClient() 526 void PopupMenuImpl::disconnectClient()
523 { 527 {
524 m_ownerElement = nullptr; 528 m_ownerElement = nullptr;
525 // Cannot be done during finalization, so instead done when the 529 // Cannot be done during finalization, so instead done when the
526 // layout object is destroyed and disconnected. 530 // layout object is destroyed and disconnected.
527 dispose(); 531 dispose();
528 } 532 }
529 533
530 } // namespace blink 534 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win/fast/forms/select-popup/popup-menu-key-operations-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698