Commit 2d4812d4 authored by Manuel Rego Casasnovas's avatar Manuel Rego Casasnovas Committed by Commit Bot

[css-contain] Fix <select> dimensions with size containment

Elements with "contain: size" should be treated as having no contents,
that's not happening for <select> elements.
To fix this we add a check for size containment in
LayoutMenuList::UpdateOptionsWidth().

BUG=966673
TEST=external/wpt/css/css-contain/contain-size-select-001.html

Change-Id: Ie71a16e113d7bef4fd5c7b62e1838feba9b15cb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1643872Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Manuel Rego <rego@igalia.com>
Cr-Commit-Position: refs/heads/master@{#666210}
parent 3a207ca2
...@@ -208,6 +208,9 @@ void LayoutMenuList::UpdateInnerBlockHeight() { ...@@ -208,6 +208,9 @@ void LayoutMenuList::UpdateInnerBlockHeight() {
} }
void LayoutMenuList::UpdateOptionsWidth() const { void LayoutMenuList::UpdateOptionsWidth() const {
if (ShouldApplySizeContainment())
return;
float max_option_width = 0; float max_option_width = 0;
for (auto* const option : SelectElement()->GetOptionList()) { for (auto* const option : SelectElement()->GetOptionList()) {
......
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Containment Test: Size containment on select</title>
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-contain-1/#containment-size">
<link rel="match" href="reference/contain-size-select-001-ref.html">
<meta name=assert content="<select> elements with 'contain: size' should be treated as having no contents.">
<style>
select {
color: white;
background: white;
contain: size;
}
</style>
<p>Test passes if it has the same output than the reference.</p>
<select>
<option>AVeryLongOption</option>
<option>Another Option</option>
</select>
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Containment Test: Reference file</title>
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com">
<style>
select {
color: white;
background: white;
}
</style>
<p>Test passes if it has the same output than the reference.</p>
<select></select>
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