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

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

Issue 2113953002: Merge "Improve performance to remove an OPTION from a SELECT element." to M52 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
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 b8568e0f8846e8e88bb2d9f3d6b339bdd37880d9..21d8caa030c0c2362134f2dda82dd5212ddd0ac7 100644
--- a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
@@ -845,7 +845,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())
@@ -872,6 +872,10 @@ void HTMLSelectElement::resetToDefaultSelection()
if (!firstEnabledOption && !option->isDisabledFormControl()) {
firstEnabledOption = option;
firstEnabledOptionIndex = optionIndex;
+ if (reason == ResetReasonSelectedOptionRemoved) {
+ // There must be no selected OPTIONs.
+ break;
+ }
}
++optionIndex;
}
@@ -989,7 +993,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