Commit 3bf300c7 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Move DispatchInputAndChangeEventForMenuList() from HTMLSelectElement to SelectType

This CL has no behavior changes.

Bug: 1052232
Change-Id: I67007e9f988a803277f9299b7c055f55a9344a41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079722
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745407}
parent 13d585cd
......@@ -611,17 +611,6 @@ void HTMLSelectElement::ListBoxOnChange() {
}
}
void HTMLSelectElement::DispatchInputAndChangeEventForMenuList() {
DCHECK(UsesMenuList());
HTMLOptionElement* selected_option = SelectedOption();
if (last_on_change_option_.Get() != selected_option) {
last_on_change_option_ = selected_option;
DispatchInputEvent();
DispatchChangeEvent();
}
}
void HTMLSelectElement::ScrollToSelection() {
if (!IsFinishedParsingChildren())
return;
......@@ -1043,8 +1032,7 @@ void HTMLSelectElement::DispatchBlurEvent(
// We only need to fire change events here for menu lists, because we fire
// change events for list boxes whenever the selection change is actually
// made. This matches other browsers' behavior.
if (UsesMenuList())
DispatchInputAndChangeEventForMenuList();
select_type_->DispatchEventsIfSelectedOptionChanged();
last_on_change_selection_.clear();
if (PopupIsVisible())
HidePopup();
......
......@@ -227,8 +227,6 @@ class CORE_EXPORT HTMLSelectElement final
void DefaultEventHandler(Event&) override;
void DispatchInputAndChangeEventForMenuList();
void SetRecalcListItems();
void RecalcListItems() const;
enum ResetReason { kResetReasonSelectedOptionRemoved, kResetReasonOthers };
......
......@@ -68,6 +68,8 @@ class MenuListSelectType final : public SelectType {
void DidSelectOption(HTMLOptionElement* element,
HTMLSelectElement::SelectOptionFlags flags,
bool should_update_popup) override;
void DispatchEventsIfSelectedOptionChanged() override;
void UpdateTextStyle() override { UpdateTextStyleInternal(); }
void UpdateTextStyleAndContent() override;
const ComputedStyle* OptionStyle() const override {
......@@ -171,7 +173,7 @@ bool MenuListSelectType::DefaultEventHandler(const Event& event) {
if (!LayoutTheme::GetTheme().PopsMenuByReturnKey() && key_code == '\r') {
if (HTMLFormElement* form = select_->Form())
form->SubmitImplicitly(event, false);
select_->DispatchInputAndChangeEventForMenuList();
DispatchEventsIfSelectedOptionChanged();
return true;
}
return false;
......@@ -284,6 +286,15 @@ void MenuListSelectType::DidSelectOption(
}
}
void MenuListSelectType::DispatchEventsIfSelectedOptionChanged() {
HTMLOptionElement* selected_option = select_->SelectedOption();
if (select_->last_on_change_option_.Get() != selected_option) {
select_->last_on_change_option_ = selected_option;
select_->DispatchInputEvent();
select_->DispatchChangeEvent();
}
}
String MenuListSelectType::UpdateTextStyleInternal() {
HTMLOptionElement* option = select_->OptionToBeShown();
String text = g_empty_string;
......@@ -712,6 +723,8 @@ void SelectType::DidSelectOption(HTMLOptionElement*,
select_->SetNeedsValidityCheck();
}
void SelectType::DispatchEventsIfSelectedOptionChanged() {}
void SelectType::UpdateTextStyle() {}
void SelectType::UpdateTextStyleAndContent() {}
......
......@@ -28,6 +28,8 @@ class SelectType : public GarbageCollected<SelectType> {
HTMLSelectElement::SelectOptionFlags flags,
bool should_update_popup);
virtual void DispatchEventsIfSelectedOptionChanged();
// Update style of text in the CSS box on style or selected OPTION change.
virtual void UpdateTextStyle();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment