| 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();
|
|
|