Commit 882f5709 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Remove GetText(), ClientPaddingLeft(), and ClientPaddingRight() of LayoutMenuList

Fold them into their callsites.
This CL has no behavior changes.

Bug: 1040828
Change-Id: Iac6c8c1e061993534e7f7ed45d60139ec9cd63e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2038196Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738490}
parent e02aeb0b
......@@ -181,7 +181,7 @@ TEST_F(ExternalPopupMenuTest, DidAcceptIndex) {
static_cast<ExternalPopupMenu*>(select->Popup());
client->DidAcceptIndex(2);
EXPECT_FALSE(select->PopupIsVisible());
ASSERT_EQ("2", menu_list->GetText().Utf8());
ASSERT_EQ("2", select->InnerElement().innerText().Utf8());
EXPECT_EQ(2, select->selectedIndex());
}
......@@ -203,7 +203,7 @@ TEST_F(ExternalPopupMenuTest, DidAcceptIndices) {
WebVector<int> indices_vector(indices, 1);
client->DidAcceptIndices(indices_vector);
EXPECT_FALSE(select->PopupIsVisible());
EXPECT_EQ("2", menu_list->GetText());
EXPECT_EQ("2", select->InnerElement().innerText());
EXPECT_EQ(2, select->selectedIndex());
}
......
......@@ -2055,14 +2055,20 @@ const ComputedStyle* HTMLSelectElement::ItemComputedStyle(
}
LayoutUnit HTMLSelectElement::ClientPaddingLeft() const {
if (GetLayoutObject() && GetLayoutObject()->IsMenuList())
return ToLayoutMenuList(GetLayoutObject())->ClientPaddingLeft();
DCHECK(UsesMenuList());
auto* this_box = GetLayoutBox();
auto* inner_box = InnerElement().GetLayoutBox();
if (this_box && inner_box)
return this_box->PaddingLeft() + inner_box->PaddingLeft();
return LayoutUnit();
}
LayoutUnit HTMLSelectElement::ClientPaddingRight() const {
if (GetLayoutObject() && GetLayoutObject()->IsMenuList())
return ToLayoutMenuList(GetLayoutObject())->ClientPaddingRight();
DCHECK(UsesMenuList());
auto* this_box = GetLayoutBox();
auto* inner_box = InnerElement().GetLayoutBox();
if (this_box && inner_box)
return this_box->PaddingRight() + inner_box->PaddingRight();
return LayoutUnit();
}
......
......@@ -133,10 +133,6 @@ void LayoutMenuList::UpdateOptionsWidth() const {
options_width_ = static_cast<int>(ceilf(max_option_width));
}
String LayoutMenuList::GetText() const {
return SelectElement()->InnerElement().innerText();
}
PhysicalRect LayoutMenuList::ControlClipRect(
const PhysicalOffset& additional_offset) const {
// Clip to the intersection of the content box and the content box for the
......@@ -186,12 +182,4 @@ void LayoutMenuList::ComputeLogicalHeight(
LayoutBox::ComputeLogicalHeight(logical_height, logical_top, computed_values);
}
LayoutUnit LayoutMenuList::ClientPaddingLeft() const {
return PaddingLeft() + InnerBlock()->PaddingLeft();
}
LayoutUnit LayoutMenuList::ClientPaddingRight() const {
return PaddingRight() + InnerBlock()->PaddingRight();
}
} // namespace blink
......@@ -38,13 +38,9 @@ class CORE_EXPORT LayoutMenuList final : public LayoutFlexibleBox {
~LayoutMenuList() override;
HTMLSelectElement* SelectElement() const;
String GetText() const;
const char* GetName() const override { return "LayoutMenuList"; }
LayoutUnit ClientPaddingLeft() const;
LayoutUnit ClientPaddingRight() const;
private:
bool IsOfType(LayoutObjectType type) const override {
return type == kLayoutObjectMenuList || LayoutFlexibleBox::IsOfType(type);
......
......@@ -111,7 +111,6 @@
#include "third_party/blink/renderer/core/inspector/inspector_issue.h"
#include "third_party/blink/renderer/core/inspector/main_thread_debugger.h"
#include "third_party/blink/renderer/core/intersection_observer/intersection_observer.h"
#include "third_party/blink/renderer/core/layout/layout_menu_list.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/layout_tree_as_text.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
......@@ -2941,12 +2940,9 @@ void Internals::forceImageReload(Element* element,
String Internals::selectMenuListText(HTMLSelectElement* select) {
DCHECK(select);
LayoutObject* layout_object = select->GetLayoutObject();
if (!layout_object || !layout_object->IsMenuList())
if (!select->UsesMenuList())
return String();
LayoutMenuList* menu_list = ToLayoutMenuList(layout_object);
return menu_list->GetText();
return select->InnerElement().innerText();
}
bool Internals::isSelectPopupVisible(Node* node) {
......
......@@ -67,7 +67,6 @@
#include "third_party/blink/renderer/core/layout/layout_inline.h"
#include "third_party/blink/renderer/core/layout/layout_list_item.h"
#include "third_party/blink/renderer/core/layout/layout_list_marker.h"
#include "third_party/blink/renderer/core/layout/layout_menu_list.h"
#include "third_party/blink/renderer/core/layout/layout_replaced.h"
#include "third_party/blink/renderer/core/layout/layout_table.h"
#include "third_party/blink/renderer/core/layout/layout_table_cell.h"
......@@ -1439,11 +1438,12 @@ String AXLayoutObject::StringValue() const {
LayoutBoxModelObject* css_box = GetLayoutBoxModelObject();
if (css_box && css_box->IsMenuList()) {
auto* select_element =
DynamicTo<HTMLSelectElement>(layout_object_->GetNode());
if (css_box && select_element && select_element->UsesMenuList()) {
// LayoutMenuList will go straight to the text() of its selected item.
// This has to be overridden in the case where the selected item has an ARIA
// label.
auto* select_element = To<HTMLSelectElement>(layout_object_->GetNode());
int selected_index = select_element->SelectedListIndex();
const HeapVector<Member<HTMLElement>>& list_items =
select_element->GetListItems();
......@@ -1455,7 +1455,7 @@ String AXLayoutObject::StringValue() const {
if (!overridden_description.IsNull())
return overridden_description;
}
return ToLayoutMenuList(layout_object_)->GetText();
return select_element->InnerElement().innerText();
}
if (IsWebArea()) {
......
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