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

Move some parts of HTMLSelectElement::DispatchBlurEvent() to SelectType

... as SelectType::DidBlur().

DispatchEventsIfSelectedOptionChanged() is now used only by
MenuListSelectType. This CL removes |SelectType::
DispatchEventsIfSelectedOptionChanged()|, and makes |MenuListSelectType
::DispatchEventsIfSelectedOptionChanged()| private.

This CL has no behavior changes.

Bug: 1052232
Change-Id: I791b4377719cc629d26d96f5c79a4ccd91ac9bbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2081721Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746183}
parent 50b8c93b
...@@ -998,13 +998,7 @@ void HTMLSelectElement::DispatchBlurEvent( ...@@ -998,13 +998,7 @@ void HTMLSelectElement::DispatchBlurEvent(
mojom::blink::FocusType type, mojom::blink::FocusType type,
InputDeviceCapabilities* source_capabilities) { InputDeviceCapabilities* source_capabilities) {
type_ahead_.ResetSession(); type_ahead_.ResetSession();
// We only need to fire change events here for menu lists, because we fire select_type_->DidBlur();
// change events for list boxes whenever the selection change is actually
// made. This matches other browsers' behavior.
select_type_->DispatchEventsIfSelectedOptionChanged();
last_on_change_selection_.clear();
if (PopupIsVisible())
HidePopup();
HTMLFormControlElementWithState::DispatchBlurEvent(new_focused_element, type, HTMLFormControlElementWithState::DispatchBlurEvent(new_focused_element, type,
source_capabilities); source_capabilities);
} }
......
...@@ -68,7 +68,7 @@ class MenuListSelectType final : public SelectType { ...@@ -68,7 +68,7 @@ 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 DidBlur() override;
void UpdateTextStyle() override { UpdateTextStyleInternal(); } void UpdateTextStyle() override { UpdateTextStyleInternal(); }
void UpdateTextStyleAndContent() override; void UpdateTextStyleAndContent() override;
...@@ -81,7 +81,7 @@ class MenuListSelectType final : public SelectType { ...@@ -81,7 +81,7 @@ class MenuListSelectType final : public SelectType {
bool ShouldOpenPopupForKeyPressEvent(const KeyboardEvent& event); bool ShouldOpenPopupForKeyPressEvent(const KeyboardEvent& event);
// Returns true if this function handled the event. // Returns true if this function handled the event.
bool HandlePopupOpenKeyboardEvent(); bool HandlePopupOpenKeyboardEvent();
void DispatchEventsIfSelectedOptionChanged();
String UpdateTextStyleInternal(); String UpdateTextStyleInternal();
void DidUpdateActiveOption(HTMLOptionElement* option); void DidUpdateActiveOption(HTMLOptionElement* option);
...@@ -295,6 +295,16 @@ void MenuListSelectType::DispatchEventsIfSelectedOptionChanged() { ...@@ -295,6 +295,16 @@ void MenuListSelectType::DispatchEventsIfSelectedOptionChanged() {
} }
} }
void MenuListSelectType::DidBlur() {
// 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.
DispatchEventsIfSelectedOptionChanged();
if (select_->PopupIsVisible())
select_->HidePopup();
SelectType::DidBlur();
}
String MenuListSelectType::UpdateTextStyleInternal() { String MenuListSelectType::UpdateTextStyleInternal() {
HTMLOptionElement* option = select_->OptionToBeShown(); HTMLOptionElement* option = select_->OptionToBeShown();
String text = g_empty_string; String text = g_empty_string;
...@@ -723,7 +733,9 @@ void SelectType::DidSelectOption(HTMLOptionElement*, ...@@ -723,7 +733,9 @@ void SelectType::DidSelectOption(HTMLOptionElement*,
select_->SetNeedsValidityCheck(); select_->SetNeedsValidityCheck();
} }
void SelectType::DispatchEventsIfSelectedOptionChanged() {} void SelectType::DidBlur() {
select_->last_on_change_selection_.clear();
}
void SelectType::UpdateTextStyle() {} void SelectType::UpdateTextStyle() {}
......
...@@ -28,7 +28,7 @@ class SelectType : public GarbageCollected<SelectType> { ...@@ -28,7 +28,7 @@ class SelectType : public GarbageCollected<SelectType> {
HTMLSelectElement::SelectOptionFlags flags, HTMLSelectElement::SelectOptionFlags flags,
bool should_update_popup); bool should_update_popup);
virtual void DispatchEventsIfSelectedOptionChanged(); virtual void DidBlur();
// 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