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() { ...@@ -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() { void HTMLSelectElement::ScrollToSelection() {
if (!IsFinishedParsingChildren()) if (!IsFinishedParsingChildren())
return; return;
...@@ -1043,8 +1032,7 @@ void HTMLSelectElement::DispatchBlurEvent( ...@@ -1043,8 +1032,7 @@ void HTMLSelectElement::DispatchBlurEvent(
// We only need to fire change events here for menu lists, because we fire // 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 // change events for list boxes whenever the selection change is actually
// made. This matches other browsers' behavior. // made. This matches other browsers' behavior.
if (UsesMenuList()) select_type_->DispatchEventsIfSelectedOptionChanged();
DispatchInputAndChangeEventForMenuList();
last_on_change_selection_.clear(); last_on_change_selection_.clear();
if (PopupIsVisible()) if (PopupIsVisible())
HidePopup(); HidePopup();
......
...@@ -227,8 +227,6 @@ class CORE_EXPORT HTMLSelectElement final ...@@ -227,8 +227,6 @@ class CORE_EXPORT HTMLSelectElement final
void DefaultEventHandler(Event&) override; void DefaultEventHandler(Event&) override;
void DispatchInputAndChangeEventForMenuList();
void SetRecalcListItems(); void SetRecalcListItems();
void RecalcListItems() const; void RecalcListItems() const;
enum ResetReason { kResetReasonSelectedOptionRemoved, kResetReasonOthers }; enum ResetReason { kResetReasonSelectedOptionRemoved, kResetReasonOthers };
......
...@@ -68,6 +68,8 @@ class MenuListSelectType final : public SelectType { ...@@ -68,6 +68,8 @@ class MenuListSelectType final : public SelectType {
void DidSelectOption(HTMLOptionElement* element, void DidSelectOption(HTMLOptionElement* element,
HTMLSelectElement::SelectOptionFlags flags, HTMLSelectElement::SelectOptionFlags flags,
bool should_update_popup) override; bool should_update_popup) override;
void DispatchEventsIfSelectedOptionChanged() override;
void UpdateTextStyle() override { UpdateTextStyleInternal(); } void UpdateTextStyle() override { UpdateTextStyleInternal(); }
void UpdateTextStyleAndContent() override; void UpdateTextStyleAndContent() override;
const ComputedStyle* OptionStyle() const override { const ComputedStyle* OptionStyle() const override {
...@@ -171,7 +173,7 @@ bool MenuListSelectType::DefaultEventHandler(const Event& event) { ...@@ -171,7 +173,7 @@ bool MenuListSelectType::DefaultEventHandler(const Event& event) {
if (!LayoutTheme::GetTheme().PopsMenuByReturnKey() && key_code == '\r') { if (!LayoutTheme::GetTheme().PopsMenuByReturnKey() && key_code == '\r') {
if (HTMLFormElement* form = select_->Form()) if (HTMLFormElement* form = select_->Form())
form->SubmitImplicitly(event, false); form->SubmitImplicitly(event, false);
select_->DispatchInputAndChangeEventForMenuList(); DispatchEventsIfSelectedOptionChanged();
return true; return true;
} }
return false; return false;
...@@ -284,6 +286,15 @@ void MenuListSelectType::DidSelectOption( ...@@ -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() { String MenuListSelectType::UpdateTextStyleInternal() {
HTMLOptionElement* option = select_->OptionToBeShown(); HTMLOptionElement* option = select_->OptionToBeShown();
String text = g_empty_string; String text = g_empty_string;
...@@ -712,6 +723,8 @@ void SelectType::DidSelectOption(HTMLOptionElement*, ...@@ -712,6 +723,8 @@ void SelectType::DidSelectOption(HTMLOptionElement*,
select_->SetNeedsValidityCheck(); select_->SetNeedsValidityCheck();
} }
void SelectType::DispatchEventsIfSelectedOptionChanged() {}
void SelectType::UpdateTextStyle() {} void SelectType::UpdateTextStyle() {}
void SelectType::UpdateTextStyleAndContent() {} void SelectType::UpdateTextStyleAndContent() {}
......
...@@ -28,6 +28,8 @@ class SelectType : public GarbageCollected<SelectType> { ...@@ -28,6 +28,8 @@ class SelectType : public GarbageCollected<SelectType> {
HTMLSelectElement::SelectOptionFlags flags, HTMLSelectElement::SelectOptionFlags flags,
bool should_update_popup); bool should_update_popup);
virtual void DispatchEventsIfSelectedOptionChanged();
// Update style of text in the CSS box on style or selected OPTION change. // Update style of text in the CSS box on style or selected OPTION change.
virtual void UpdateTextStyle(); 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