Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1174)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutListBox.cpp

Issue 2060493002: Set LayoutListBox's height as 'size' attribute * (height of the tallest option). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2nd merge conflict Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutListBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutListBox.cpp b/third_party/WebKit/Source/core/layout/LayoutListBox.cpp
index 2a845529173207526f7e0f30b9fe2232b4345ff3..0854713e223d6358b97a0efa1d6147058fb5f4e9 100644
--- a/third_party/WebKit/Source/core/layout/LayoutListBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutListBox.cpp
@@ -79,17 +79,24 @@ LayoutUnit LayoutListBox::itemHeight() const
HTMLSelectElement* select = selectElement();
if (!select)
return LayoutUnit();
- Element* baseItem = ElementTraversal::firstChild(*select);
- if (!baseItem)
- return defaultItemHeight();
- if (isHTMLOptGroupElement(baseItem))
- baseItem = &toHTMLOptGroupElement(baseItem)->optGroupLabelElement();
- else if (!isHTMLOptionElement(baseItem))
- return defaultItemHeight();
- LayoutObject* baseItemLayoutObject = baseItem->layoutObject();
- if (!baseItemLayoutObject || !baseItemLayoutObject->isBox())
+
+ const auto& items = select->listItems();
+ if (items.isEmpty())
return defaultItemHeight();
- return toLayoutBox(baseItemLayoutObject)->size().height();
+
+ LayoutUnit maxHeight;
+ for (Element* element : items) {
+ if (isHTMLOptGroupElement(element))
+ element = &toHTMLOptGroupElement(element)->optGroupLabelElement();
+ LayoutObject* layoutObject = element->layoutObject();
+ LayoutUnit itemHeight;
+ if (layoutObject && layoutObject->isBox())
+ itemHeight = toLayoutBox(layoutObject)->size().height();
+ else
+ itemHeight = defaultItemHeight();
+ maxHeight = std::max(maxHeight, itemHeight);
+ }
+ return maxHeight;
}
void LayoutListBox::computeLogicalHeight(LayoutUnit, LayoutUnit logicalTop, LogicalExtentComputedValues& computedValues) const
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698