Commit 14c03783 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Move HTMLSelectElement::SelectAll() to SelectType

This CL has no behavior changes.

Bug: 1052232
Change-Id: I9b583888cea7708a69eb35ac89c2dca2938f74b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2066405Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743420}
parent 0f2af34b
...@@ -567,21 +567,7 @@ HTMLOptionElement* HTMLSelectElement::NextSelectableOptionPageAway( ...@@ -567,21 +567,7 @@ HTMLOptionElement* HTMLSelectElement::NextSelectableOptionPageAway(
} }
void HTMLSelectElement::SelectAll() { void HTMLSelectElement::SelectAll() {
DCHECK(!UsesMenuList()); select_type_->SelectAll();
if (!GetLayoutObject() || !is_multiple_)
return;
// Save the selection so it can be compared to the new selectAll selection
// when dispatching change events.
SaveLastSelection();
active_selection_state_ = true;
SetActiveSelectionAnchor(NextSelectableOption(nullptr));
SetActiveSelectionEnd(PreviousSelectableOption(nullptr));
UpdateListBoxSelection(false, false);
ListBoxOnChange();
SetNeedsValidityCheck();
} }
void HTMLSelectElement::SaveLastSelection() { void HTMLSelectElement::SaveLastSelection() {
......
...@@ -383,6 +383,7 @@ class ListBoxSelectType final : public SelectType { ...@@ -383,6 +383,7 @@ class ListBoxSelectType final : public SelectType {
explicit ListBoxSelectType(HTMLSelectElement& select) : SelectType(select) {} explicit ListBoxSelectType(HTMLSelectElement& select) : SelectType(select) {}
bool DefaultEventHandler(const Event& event) override; bool DefaultEventHandler(const Event& event) override;
void UpdateMultiSelectFocus() override; void UpdateMultiSelectFocus() override;
void SelectAll() override;
private: private:
bool is_in_non_contiguous_selection_ = false; bool is_in_non_contiguous_selection_ = false;
...@@ -654,6 +655,23 @@ void ListBoxSelectType::UpdateMultiSelectFocus() { ...@@ -654,6 +655,23 @@ void ListBoxSelectType::UpdateMultiSelectFocus() {
select_->ScrollToSelection(); select_->ScrollToSelection();
} }
void ListBoxSelectType::SelectAll() {
if (!select_->GetLayoutObject() || !select_->is_multiple_)
return;
// Save the selection so it can be compared to the new selectAll selection
// when dispatching change events.
select_->SaveLastSelection();
select_->active_selection_state_ = true;
select_->SetActiveSelectionAnchor(select_->NextSelectableOption(nullptr));
select_->SetActiveSelectionEnd(select_->PreviousSelectableOption(nullptr));
select_->UpdateListBoxSelection(false, false);
select_->ListBoxOnChange();
select_->SetNeedsValidityCheck();
}
// ============================================================================ // ============================================================================
SelectType::SelectType(HTMLSelectElement& select) : select_(select) {} SelectType::SelectType(HTMLSelectElement& select) : select_(select) {}
...@@ -691,4 +709,8 @@ const ComputedStyle* SelectType::OptionStyle() const { ...@@ -691,4 +709,8 @@ const ComputedStyle* SelectType::OptionStyle() const {
void SelectType::UpdateMultiSelectFocus() {} void SelectType::UpdateMultiSelectFocus() {}
void SelectType::SelectAll() {
NOTREACHED();
}
} // namespace blink } // namespace blink
...@@ -39,6 +39,8 @@ class SelectType : public GarbageCollected<SelectType> { ...@@ -39,6 +39,8 @@ class SelectType : public GarbageCollected<SelectType> {
// Update :-internal-multi-select-focus state of selected OPTIONs. // Update :-internal-multi-select-focus state of selected OPTIONs.
virtual void UpdateMultiSelectFocus(); virtual void UpdateMultiSelectFocus();
virtual void SelectAll();
// TODO(crbug.com/1052232): Add more virtual functions. // TODO(crbug.com/1052232): Add more virtual functions.
protected: protected:
......
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