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

Move HTMLSelectElement::SetActiveSelection*() to ListBoxSelectType

They are used only in ListBoxSelectType.
This CL has no behavior changes.

Bug: 1052232
Change-Id: Ia07346ed04b4cb0a70608dd1eaa10a41ca923cde
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2215544
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Auto-Submit: Kent Tamura <tkent@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772125}
parent 82a2ad6c
......@@ -509,15 +509,6 @@ void HTMLSelectElement::SelectAll() {
select_type_->SelectAll();
}
void HTMLSelectElement::SetActiveSelectionAnchor(HTMLOptionElement* option) {
active_selection_anchor_ = option;
select_type_->SaveListboxActiveSelection();
}
void HTMLSelectElement::SetActiveSelectionEnd(HTMLOptionElement* option) {
active_selection_end_ = option;
}
const HTMLSelectElement::ListItems& HTMLSelectElement::GetListItems() const {
if (should_recalc_list_items_) {
RecalcListItems();
......
......@@ -126,8 +126,6 @@ class CORE_EXPORT HTMLSelectElement final
void SelectAll();
int ActiveSelectionEndListIndex() const;
HTMLOptionElement* ActiveSelectionEnd() const;
void SetActiveSelectionAnchor(HTMLOptionElement*);
void SetActiveSelectionEnd(HTMLOptionElement*);
// For use in the implementation of HTMLOptionElement.
void OptionSelectionStateChanged(HTMLOptionElement*, bool option_is_selected);
......
......@@ -647,6 +647,8 @@ class ListBoxSelectType final : public SelectType {
void UpdateSelectedState(HTMLOptionElement* clicked_option,
SelectionMode mode);
void UpdateListBoxSelection(bool deselect_other_options, bool scroll = true);
void SetActiveSelectionAnchor(HTMLOptionElement*);
void SetActiveSelectionEnd(HTMLOptionElement*);
void ScrollToOptionTask();
Vector<bool> cached_state_for_active_selection_;
......@@ -742,11 +744,11 @@ bool ListBoxSelectType::DefaultEventHandler(const Event& event) {
if (!select_->active_selection_anchor_)
return false;
select_->SetActiveSelectionEnd(option);
SetActiveSelectionEnd(option);
UpdateListBoxSelection(false);
} else {
select_->SetActiveSelectionAnchor(option);
select_->SetActiveSelectionEnd(option);
SetActiveSelectionAnchor(option);
SetActiveSelectionEnd(option);
UpdateListBoxSelection(true);
}
}
......@@ -851,7 +853,7 @@ bool ListBoxSelectType::DefaultEventHandler(const Event& event) {
// selection.
SaveLastSelection();
select_->SetActiveSelectionEnd(end_option);
SetActiveSelectionEnd(end_option);
is_in_non_contiguous_selection_ = select_->is_multiple_ && is_control_key;
bool select_new_item =
......@@ -867,7 +869,7 @@ bool ListBoxSelectType::DefaultEventHandler(const Event& event) {
if (!select_->active_selection_anchor_ || deselect_others) {
if (deselect_others)
select_->DeselectItemsWithoutValidation();
select_->SetActiveSelectionAnchor(select_->active_selection_end_.Get());
SetActiveSelectionAnchor(select_->active_selection_end_.Get());
}
ScrollToOption(end_option);
......@@ -928,9 +930,9 @@ void ListBoxSelectType::DidSelectOption(
// SetActiveSelectionAnchor is O(N).
if (!select_->active_selection_anchor_ || is_single ||
deselect_other_options)
select_->SetActiveSelectionAnchor(element);
SetActiveSelectionAnchor(element);
if (!select_->active_selection_end_ || is_single || deselect_other_options)
select_->SetActiveSelectionEnd(element);
SetActiveSelectionEnd(element);
}
ScrollToSelection();
......@@ -982,6 +984,15 @@ HTMLOptionElement* ListBoxSelectType::SpatialNavigationFocusedOption() {
return FirstSelectableOption();
}
void ListBoxSelectType::SetActiveSelectionAnchor(HTMLOptionElement* option) {
select_->active_selection_anchor_ = option;
SaveListboxActiveSelection();
}
void ListBoxSelectType::SetActiveSelectionEnd(HTMLOptionElement* option) {
select_->active_selection_end_ = option;
}
HTMLOptionElement* ListBoxSelectType::ActiveSelectionEnd() const {
if (select_->active_selection_end_)
return select_->active_selection_end_.Get();
......@@ -1047,8 +1058,8 @@ void ListBoxSelectType::SelectAll() {
SaveLastSelection();
active_selection_state_ = true;
select_->SetActiveSelectionAnchor(NextSelectableOption(nullptr));
select_->SetActiveSelectionEnd(PreviousSelectableOption(nullptr));
SetActiveSelectionAnchor(NextSelectableOption(nullptr));
SetActiveSelectionEnd(PreviousSelectableOption(nullptr));
UpdateListBoxSelection(false, false);
ListBoxOnChange();
......@@ -1112,7 +1123,7 @@ void ListBoxSelectType::UpdateSelectedState(HTMLOptionElement* clicked_option,
// then initialize the anchor to the first selected OPTION.
if (!select_->active_selection_anchor_ &&
mode != SelectionMode::kNotChangeOthers)
select_->SetActiveSelectionAnchor(select_->SelectedOption());
SetActiveSelectionAnchor(select_->SelectedOption());
// Set the selection state of the clicked OPTION.
if (!clicked_option->IsDisabledFormControl()) {
......@@ -1124,9 +1135,9 @@ void ListBoxSelectType::UpdateSelectedState(HTMLOptionElement* clicked_option,
// we're doing kDeselectOthers, or kNotChangeOthers (using cmd or ctrl),
// then initialize the anchor OPTION to the clicked OPTION.
if (!select_->active_selection_anchor_ || mode != SelectionMode::kRange)
select_->SetActiveSelectionAnchor(clicked_option);
SetActiveSelectionAnchor(clicked_option);
select_->SetActiveSelectionEnd(clicked_option);
SetActiveSelectionEnd(clicked_option);
UpdateListBoxSelection(mode != SelectionMode::kNotChangeOthers);
}
......
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