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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLSelectElement.cpp

Issue 2208483003: Delay DOM mutation events in HTMLSelectElement::setOption(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/forms/select/select-add-assertion.html ('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 /* 1 /*
2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * (C) 1999 Antti Koivisto (koivisto@kde.org)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
10 * 10 *
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 element.setHTMLOptionElement(option); 422 element.setHTMLOptionElement(option);
423 HTMLElementOrLong before; 423 HTMLElementOrLong before;
424 // Out of array bounds? First insert empty dummies. 424 // Out of array bounds? First insert empty dummies.
425 if (diff > 0) { 425 if (diff > 0) {
426 setLength(index, exceptionState); 426 setLength(index, exceptionState);
427 // Replace an existing entry? 427 // Replace an existing entry?
428 } else if (diff < 0) { 428 } else if (diff < 0) {
429 before.setHTMLElement(options()->item(index + 1)); 429 before.setHTMLElement(options()->item(index + 1));
430 remove(index); 430 remove(index);
431 } 431 }
432 if (exceptionState.hadException())
433 return;
432 // Finally add the new element. 434 // Finally add the new element.
433 if (!exceptionState.hadException()) { 435 EventQueueScope scope;
434 add(element, before, exceptionState); 436 add(element, before, exceptionState);
435 if (diff >= 0 && option->selected()) 437 if (diff >= 0 && option->selected())
436 optionSelectionStateChanged(option, true); 438 optionSelectionStateChanged(option, true);
437 }
438 } 439 }
439 440
440 void HTMLSelectElement::setLength(unsigned newLen, ExceptionState& exceptionStat e) 441 void HTMLSelectElement::setLength(unsigned newLen, ExceptionState& exceptionStat e)
441 { 442 {
442 // We should check |newLen > maxListItems| first to avoid integer overflow. 443 // We should check |newLen > maxListItems| first to avoid integer overflow.
443 if (newLen > maxListItems || listItems().size() + newLen - length() > maxLis tItems) { 444 if (newLen > maxListItems || listItems().size() + newLen - length() > maxLis tItems) {
444 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, War ningMessageLevel, 445 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, War ningMessageLevel,
445 String::format("Blocked to expand the option list to %u items. The maximum list length is %u.", newLen, maxListItems))); 446 String::format("Blocked to expand the option list to %u items. The maximum list length is %u.", newLen, maxListItems)));
446 return; 447 return;
447 } 448 }
(...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 } 2039 }
2039 2040
2040 void HTMLSelectElement::didMutateSubtree() 2041 void HTMLSelectElement::didMutateSubtree()
2041 { 2042 {
2042 DCHECK(popupIsVisible()); 2043 DCHECK(popupIsVisible());
2043 DCHECK(m_popup); 2044 DCHECK(m_popup);
2044 m_popup->updateFromElement(PopupMenu::ByDOMChange); 2045 m_popup->updateFromElement(PopupMenu::ByDOMChange);
2045 } 2046 }
2046 2047
2047 } // namespace blink 2048 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/forms/select/select-add-assertion.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698