Commit 9ded1de0 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Move HTMLSelectElement::ToggleSelection() to ListBoxSelectType

This CL has no behavior changes.

Bug: 1052232
Change-Id: I8ea8e3480edce7a34e06883c14692788c7868ce5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2094490
Commit-Queue: Kent Tamura <tkent@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Auto-Submit: Kent Tamura <tkent@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748586}
parent e22aaa9a
...@@ -1255,12 +1255,6 @@ void HTMLSelectElement::HandleMouseRelease() { ...@@ -1255,12 +1255,6 @@ void HTMLSelectElement::HandleMouseRelease() {
ListBoxOnChange(); ListBoxOnChange();
} }
void HTMLSelectElement::ToggleSelection(HTMLOptionElement& option) {
active_selection_state_ = !active_selection_state_;
UpdateSelectedState(&option, true /*multi*/, false /*shift*/);
ListBoxOnChange();
}
void HTMLSelectElement::DefaultEventHandler(Event& event) { void HTMLSelectElement::DefaultEventHandler(Event& event) {
if (!GetLayoutObject()) if (!GetLayoutObject())
return; return;
......
...@@ -261,7 +261,6 @@ class CORE_EXPORT HTMLSelectElement final ...@@ -261,7 +261,6 @@ class CORE_EXPORT HTMLSelectElement final
void UpdateListBoxSelection(bool deselect_other_options, bool scroll = true); void UpdateListBoxSelection(bool deselect_other_options, bool scroll = true);
void SetIndexToSelectOnCancel(int list_index); void SetIndexToSelectOnCancel(int list_index);
void SetSuggestedOption(HTMLOptionElement*); void SetSuggestedOption(HTMLOptionElement*);
void ToggleSelection(HTMLOptionElement&);
// Returns nullptr if listIndex is out of bounds, or it doesn't point an // Returns nullptr if listIndex is out of bounds, or it doesn't point an
// HTMLOptionElement. // HTMLOptionElement.
......
...@@ -614,6 +614,7 @@ class ListBoxSelectType final : public SelectType { ...@@ -614,6 +614,7 @@ class ListBoxSelectType final : public SelectType {
private: private:
HTMLOptionElement* NextSelectableOptionPageAway(HTMLOptionElement*, HTMLOptionElement* NextSelectableOptionPageAway(HTMLOptionElement*,
SkipDirection) const; SkipDirection) const;
void ToggleSelection(HTMLOptionElement& option);
bool is_in_non_contiguous_selection_ = false; bool is_in_non_contiguous_selection_ = false;
}; };
...@@ -793,7 +794,7 @@ bool ListBoxSelectType::DefaultEventHandler(const Event& event) { ...@@ -793,7 +794,7 @@ bool ListBoxSelectType::DefaultEventHandler(const Event& event) {
if (select_->is_multiple_ && keyboard_event->keyCode() == ' ' && if (select_->is_multiple_ && keyboard_event->keyCode() == ' ' &&
is_control_key && select_->active_selection_end_) { is_control_key && select_->active_selection_end_) {
// Use ctrl+space to toggle selection change. // Use ctrl+space to toggle selection change.
select_->ToggleSelection(*select_->active_selection_end_); ToggleSelection(*select_->active_selection_end_);
return true; return true;
} }
...@@ -858,7 +859,7 @@ bool ListBoxSelectType::DefaultEventHandler(const Event& event) { ...@@ -858,7 +859,7 @@ bool ListBoxSelectType::DefaultEventHandler(const Event& event) {
option = NextSelectableOption(select_->LastSelectedOption()); option = NextSelectableOption(select_->LastSelectedOption());
if (option) { if (option) {
// Use space to toggle selection change. // Use space to toggle selection change.
select_->ToggleSelection(*option); ToggleSelection(*option);
return true; return true;
} }
} }
...@@ -924,6 +925,12 @@ HTMLOptionElement* ListBoxSelectType::NextSelectableOptionPageAway( ...@@ -924,6 +925,12 @@ HTMLOptionElement* ListBoxSelectType::NextSelectableOptionPageAway(
return NextValidOption(edge_index, direction, skip_amount); return NextValidOption(edge_index, direction, skip_amount);
} }
void ListBoxSelectType::ToggleSelection(HTMLOptionElement& option) {
select_->active_selection_state_ = !select_->active_selection_state_;
select_->UpdateSelectedState(&option, true /*multi*/, false /*shift*/);
select_->ListBoxOnChange();
}
// ============================================================================ // ============================================================================
SelectType::SelectType(HTMLSelectElement& select) : select_(select) {} SelectType::SelectType(HTMLSelectElement& select) : select_(select) {}
......
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