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() { ...@@ -509,15 +509,6 @@ void HTMLSelectElement::SelectAll() {
select_type_->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 { const HTMLSelectElement::ListItems& HTMLSelectElement::GetListItems() const {
if (should_recalc_list_items_) { if (should_recalc_list_items_) {
RecalcListItems(); RecalcListItems();
......
...@@ -126,8 +126,6 @@ class CORE_EXPORT HTMLSelectElement final ...@@ -126,8 +126,6 @@ class CORE_EXPORT HTMLSelectElement final
void SelectAll(); void SelectAll();
int ActiveSelectionEndListIndex() const; int ActiveSelectionEndListIndex() const;
HTMLOptionElement* ActiveSelectionEnd() const; HTMLOptionElement* ActiveSelectionEnd() const;
void SetActiveSelectionAnchor(HTMLOptionElement*);
void SetActiveSelectionEnd(HTMLOptionElement*);
// For use in the implementation of HTMLOptionElement. // For use in the implementation of HTMLOptionElement.
void OptionSelectionStateChanged(HTMLOptionElement*, bool option_is_selected); void OptionSelectionStateChanged(HTMLOptionElement*, bool option_is_selected);
......
...@@ -647,6 +647,8 @@ class ListBoxSelectType final : public SelectType { ...@@ -647,6 +647,8 @@ class ListBoxSelectType final : public SelectType {
void UpdateSelectedState(HTMLOptionElement* clicked_option, void UpdateSelectedState(HTMLOptionElement* clicked_option,
SelectionMode mode); SelectionMode mode);
void UpdateListBoxSelection(bool deselect_other_options, bool scroll = true); void UpdateListBoxSelection(bool deselect_other_options, bool scroll = true);
void SetActiveSelectionAnchor(HTMLOptionElement*);
void SetActiveSelectionEnd(HTMLOptionElement*);
void ScrollToOptionTask(); void ScrollToOptionTask();
Vector<bool> cached_state_for_active_selection_; Vector<bool> cached_state_for_active_selection_;
...@@ -742,11 +744,11 @@ bool ListBoxSelectType::DefaultEventHandler(const Event& event) { ...@@ -742,11 +744,11 @@ bool ListBoxSelectType::DefaultEventHandler(const Event& event) {
if (!select_->active_selection_anchor_) if (!select_->active_selection_anchor_)
return false; return false;
select_->SetActiveSelectionEnd(option); SetActiveSelectionEnd(option);
UpdateListBoxSelection(false); UpdateListBoxSelection(false);
} else { } else {
select_->SetActiveSelectionAnchor(option); SetActiveSelectionAnchor(option);
select_->SetActiveSelectionEnd(option); SetActiveSelectionEnd(option);
UpdateListBoxSelection(true); UpdateListBoxSelection(true);
} }
} }
...@@ -851,7 +853,7 @@ bool ListBoxSelectType::DefaultEventHandler(const Event& event) { ...@@ -851,7 +853,7 @@ bool ListBoxSelectType::DefaultEventHandler(const Event& event) {
// selection. // selection.
SaveLastSelection(); SaveLastSelection();
select_->SetActiveSelectionEnd(end_option); SetActiveSelectionEnd(end_option);
is_in_non_contiguous_selection_ = select_->is_multiple_ && is_control_key; is_in_non_contiguous_selection_ = select_->is_multiple_ && is_control_key;
bool select_new_item = bool select_new_item =
...@@ -867,7 +869,7 @@ bool ListBoxSelectType::DefaultEventHandler(const Event& event) { ...@@ -867,7 +869,7 @@ bool ListBoxSelectType::DefaultEventHandler(const Event& event) {
if (!select_->active_selection_anchor_ || deselect_others) { if (!select_->active_selection_anchor_ || deselect_others) {
if (deselect_others) if (deselect_others)
select_->DeselectItemsWithoutValidation(); select_->DeselectItemsWithoutValidation();
select_->SetActiveSelectionAnchor(select_->active_selection_end_.Get()); SetActiveSelectionAnchor(select_->active_selection_end_.Get());
} }
ScrollToOption(end_option); ScrollToOption(end_option);
...@@ -928,9 +930,9 @@ void ListBoxSelectType::DidSelectOption( ...@@ -928,9 +930,9 @@ void ListBoxSelectType::DidSelectOption(
// SetActiveSelectionAnchor is O(N). // SetActiveSelectionAnchor is O(N).
if (!select_->active_selection_anchor_ || is_single || if (!select_->active_selection_anchor_ || is_single ||
deselect_other_options) deselect_other_options)
select_->SetActiveSelectionAnchor(element); SetActiveSelectionAnchor(element);
if (!select_->active_selection_end_ || is_single || deselect_other_options) if (!select_->active_selection_end_ || is_single || deselect_other_options)
select_->SetActiveSelectionEnd(element); SetActiveSelectionEnd(element);
} }
ScrollToSelection(); ScrollToSelection();
...@@ -982,6 +984,15 @@ HTMLOptionElement* ListBoxSelectType::SpatialNavigationFocusedOption() { ...@@ -982,6 +984,15 @@ HTMLOptionElement* ListBoxSelectType::SpatialNavigationFocusedOption() {
return FirstSelectableOption(); 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 { HTMLOptionElement* ListBoxSelectType::ActiveSelectionEnd() const {
if (select_->active_selection_end_) if (select_->active_selection_end_)
return select_->active_selection_end_.Get(); return select_->active_selection_end_.Get();
...@@ -1047,8 +1058,8 @@ void ListBoxSelectType::SelectAll() { ...@@ -1047,8 +1058,8 @@ void ListBoxSelectType::SelectAll() {
SaveLastSelection(); SaveLastSelection();
active_selection_state_ = true; active_selection_state_ = true;
select_->SetActiveSelectionAnchor(NextSelectableOption(nullptr)); SetActiveSelectionAnchor(NextSelectableOption(nullptr));
select_->SetActiveSelectionEnd(PreviousSelectableOption(nullptr)); SetActiveSelectionEnd(PreviousSelectableOption(nullptr));
UpdateListBoxSelection(false, false); UpdateListBoxSelection(false, false);
ListBoxOnChange(); ListBoxOnChange();
...@@ -1112,7 +1123,7 @@ void ListBoxSelectType::UpdateSelectedState(HTMLOptionElement* clicked_option, ...@@ -1112,7 +1123,7 @@ void ListBoxSelectType::UpdateSelectedState(HTMLOptionElement* clicked_option,
// then initialize the anchor to the first selected OPTION. // then initialize the anchor to the first selected OPTION.
if (!select_->active_selection_anchor_ && if (!select_->active_selection_anchor_ &&
mode != SelectionMode::kNotChangeOthers) mode != SelectionMode::kNotChangeOthers)
select_->SetActiveSelectionAnchor(select_->SelectedOption()); SetActiveSelectionAnchor(select_->SelectedOption());
// Set the selection state of the clicked OPTION. // Set the selection state of the clicked OPTION.
if (!clicked_option->IsDisabledFormControl()) { if (!clicked_option->IsDisabledFormControl()) {
...@@ -1124,9 +1135,9 @@ void ListBoxSelectType::UpdateSelectedState(HTMLOptionElement* clicked_option, ...@@ -1124,9 +1135,9 @@ void ListBoxSelectType::UpdateSelectedState(HTMLOptionElement* clicked_option,
// we're doing kDeselectOthers, or kNotChangeOthers (using cmd or ctrl), // we're doing kDeselectOthers, or kNotChangeOthers (using cmd or ctrl),
// then initialize the anchor OPTION to the clicked OPTION. // then initialize the anchor OPTION to the clicked OPTION.
if (!select_->active_selection_anchor_ || mode != SelectionMode::kRange) 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); 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