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

Unified Diff: third_party/WebKit/Source/core/html/HTMLSelectElement.cpp

Issue 2108883003: Improve performance to remove an OPTION from a SELECT element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSelectElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
index bafe8c6c7bc0c6610adc5141060677d0811e793d..6451c393d720e84232f08ad098fe46c2d32925e0 100644
--- a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
@@ -842,7 +842,7 @@ void HTMLSelectElement::recalcListItems() const
}
}
-void HTMLSelectElement::resetToDefaultSelection()
+void HTMLSelectElement::resetToDefaultSelection(ResetReason reason)
{
// https://html.spec.whatwg.org/multipage/forms.html#ask-for-a-reset
if (multiple())
@@ -869,6 +869,10 @@ void HTMLSelectElement::resetToDefaultSelection()
if (!firstEnabledOption && !option->isDisabledFormControl()) {
firstEnabledOption = option;
firstEnabledOptionIndex = optionIndex;
+ if (reason == ResetReasonSelectedOptionRemoved) {
+ // There must be no selected OPTIONs.
+ break;
+ }
}
++optionIndex;
}
@@ -986,7 +990,9 @@ void HTMLSelectElement::optionInserted(HTMLOptionElement& option, bool optionIsS
void HTMLSelectElement::optionRemoved(const HTMLOptionElement& option)
{
setRecalcListItems();
- if (option.selected() || !m_lastOnChangeOption)
+ if (option.selected())
+ resetToDefaultSelection(ResetReasonSelectedOptionRemoved);
+ else if (!m_lastOnChangeOption)
resetToDefaultSelection();
if (m_lastOnChangeOption == &option)
m_lastOnChangeOption.clear();
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSelectElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698