Skip to content

Commit

Permalink
Move HTMLSelectElement::SetOptionsChangedOnLayoutObject() to MenuList…
Browse files Browse the repository at this point in the history
…SelectType

and rename it to MaximumOptionWidthMightBeChanged().
This CL has no behavior changes.

Bug: 1052232
Change-Id: Ifb891a8c0bfb916075f44460ef85be301982932c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2094475
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748104}
  • Loading branch information
tkent-google authored and Commit Bot committed Mar 9, 2020
1 parent 8dda15b commit 5c8f724
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -616,15 +616,6 @@ void HTMLSelectElement::ScrollToSelection() {
cache->ListboxActiveIndexChanged(this);
}

void HTMLSelectElement::SetOptionsChangedOnLayoutObject() {
if (LayoutObject* layout_object = GetLayoutObject()) {
if (!UsesMenuList())
return;
layout_object->SetNeedsLayoutAndPrefWidthsRecalc(
layout_invalidation_reason::kMenuOptionsChanged);
}
}

const HTMLSelectElement::ListItems& HTMLSelectElement::GetListItems() const {
if (should_recalc_list_items_) {
RecalcListItems();
Expand All @@ -651,7 +642,7 @@ void HTMLSelectElement::SetRecalcListItems() {

should_recalc_list_items_ = true;

SetOptionsChangedOnLayoutObject();
select_type_->MaximumOptionWidthMightBeChanged();
if (!isConnected()) {
if (HTMLOptionsCollection* collection =
CachedCollection<HTMLOptionsCollection>(kSelectOptions))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ class CORE_EXPORT HTMLSelectElement final
void ParseMultipleAttribute(const AtomicString&);
HTMLOptionElement* LastSelectedOption() const;
void UpdateSelectedState(HTMLOptionElement*, bool multi, bool shift);
void SetOptionsChangedOnLayoutObject();
wtf_size_t SearchOptionsForValue(const String&,
wtf_size_t list_index_start,
wtf_size_t list_index_end) const;
Expand Down
10 changes: 10 additions & 0 deletions third_party/blink/renderer/core/html/forms/select_type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class MenuListSelectType final : public SelectType {
const ComputedStyle* OptionStyle() const override {
return option_style_.get();
}
void MaximumOptionWidthMightBeChanged() const override;

void ShowPopup() override;
void HidePopup() override;
Expand Down Expand Up @@ -501,6 +502,13 @@ void MenuListSelectType::DidUpdateActiveOption(HTMLOptionElement* option) {
select_->GetLayoutObject(), option_index);
}

void MenuListSelectType::MaximumOptionWidthMightBeChanged() const {
if (LayoutObject* layout_object = select_->GetLayoutObject()) {
layout_object->SetNeedsLayoutAndPrefWidthsRecalc(
layout_invalidation_reason::kMenuOptionsChanged);
}
}

// PopupUpdater notifies updates of the specified SELECT element subtree to
// a PopupMenu object.
class PopupUpdater : public MutationObserver::Delegate {
Expand Down Expand Up @@ -945,6 +953,8 @@ const ComputedStyle* SelectType::OptionStyle() const {
return nullptr;
}

void SelectType::MaximumOptionWidthMightBeChanged() const {}

void SelectType::UpdateMultiSelectFocus() {}

void SelectType::SelectAll() {
Expand Down
1 change: 1 addition & 0 deletions third_party/blink/renderer/core/html/forms/select_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class SelectType : public GarbageCollected<SelectType> {
virtual void UpdateTextStyleAndContent();

virtual const ComputedStyle* OptionStyle() const;
virtual void MaximumOptionWidthMightBeChanged() const;

// Update :-internal-multi-select-focus state of selected OPTIONs.
virtual void UpdateMultiSelectFocus();
Expand Down

0 comments on commit 5c8f724

Please sign in to comment.