Commit 29eff3ab authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

[Mac] Set a minimum size on checkboxes and radio buttons

Followup to https://chromium-review.googlesource.com/c/581753

Bug: 719737
Change-Id: Ibfe553c23884d04450223b17974214658ec6f763
Reviewed-on: https://chromium-review.googlesource.com/596474
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@opera.com>
Cr-Commit-Position: refs/heads/master@{#491914}
parent 113e2d41
......@@ -3034,9 +3034,6 @@ crbug.com/626703 [ Win7 Debug ] external/wpt/encoding/legacy-mb-tchinese/big5/bi
crbug.com/626703 [ Win7 Debug ] external/wpt/encoding/legacy-mb-tchinese/big5/big5-encode-form-errors-extBb.html [ Timeout Pass ]
crbug.com/626703 [ Win7 Debug ] external/wpt/encoding/legacy-mb-korean/euc-kr/euckr-encode-href-errors-han.html [ Timeout Pass ]
# Needs a mac person to fix the bug
crbug.com/719737 [ Mac ] css3/flexbox/radiobutton-min-size.html [ Failure ]
# module script lacks XHTML support
crbug.com/717643 external/wpt/html/semantics/scripting-1/the-script-element/module/module-in-xhtml.xhtml [ Failure ]
......
......@@ -184,19 +184,21 @@ void LayoutTheme::AdjustStyle(ComputedStyle& style, Element* e) {
LengthSize control_size = platform_theme_->GetControlSize(
part, style.GetFont().GetFontDescription(),
LengthSize(style.Width(), style.Height()), style.EffectiveZoom());
LengthSize min_control_size = platform_theme_->MinimumControlSize(
part, style.GetFont().GetFontDescription(), style.EffectiveZoom());
// Only potentially set min-size to |control_size| for these parts.
if (part == kCheckboxPart || part == kRadioPart)
SetMinimumSize(style, &control_size, &min_control_size);
else
SetMinimumSize(style, nullptr, &min_control_size);
if (control_size.Width() != style.Width())
style.SetWidth(control_size.Width());
if (control_size.Height() != style.Height())
style.SetHeight(control_size.Height());
// Min-Width / Min-Height
LengthSize min_control_size = platform_theme_->MinimumControlSize(
part, style.GetFont().GetFontDescription(), style.EffectiveZoom());
if (min_control_size.Width() != style.MinWidth())
style.SetMinWidth(min_control_size.Width());
if (min_control_size.Height() != style.MinHeight())
style.SetMinHeight(min_control_size.Height());
// Font
FontDescription control_font = platform_theme_->ControlFont(
part, style.GetFont().GetFontDescription(), style.EffectiveZoom());
......@@ -905,15 +907,30 @@ void LayoutTheme::SetSizeIfAuto(ComputedStyle& style, const IntSize& size) {
}
// static
void LayoutTheme::SetMinimumSizeIfAuto(ComputedStyle& style,
const IntSize& size) {
void LayoutTheme::SetMinimumSize(ComputedStyle& style,
const LengthSize* part_size,
const LengthSize* min_part_size) {
DCHECK(part_size || min_part_size);
// We only want to set a minimum size if no explicit size is specified, to
// avoid overriding author intentions.
if (style.MinWidth().IsIntrinsicOrAuto() && style.Width().IsIntrinsicOrAuto())
style.SetMinWidth(Length(size.Width(), kFixed));
if (style.MinHeight().IsIntrinsicOrAuto() &&
if (part_size && style.MinWidth().IsIntrinsicOrAuto() &&
style.Width().IsIntrinsicOrAuto())
style.SetMinWidth(part_size->Width());
else if (min_part_size && min_part_size->Width() != style.MinWidth())
style.SetMinWidth(min_part_size->Width());
if (part_size && style.MinHeight().IsIntrinsicOrAuto() &&
style.Height().IsIntrinsicOrAuto())
style.SetMinHeight(Length(size.Height(), kFixed));
style.SetMinHeight(part_size->Height());
else if (min_part_size && min_part_size->Height() != style.MinHeight())
style.SetMinHeight(min_part_size->Height());
}
// static
void LayoutTheme::SetMinimumSizeIfAuto(ComputedStyle& style,
const IntSize& size) {
LengthSize length_size(Length(size.Width(), kFixed),
Length(size.Height(), kFixed));
SetMinimumSize(style, &length_size);
}
void LayoutTheme::AdjustCheckboxStyleUsingFallbackTheme(
......
......@@ -42,6 +42,7 @@ class Font;
class FontDescription;
class HTMLInputElement;
class LayoutObject;
class LengthSize;
class Locale;
class PlatformChromeClient;
class Theme;
......@@ -63,6 +64,11 @@ class CORE_EXPORT LayoutTheme : public RefCounted<LayoutTheme> {
virtual void DidChangeThemeEngine() {}
static void SetSizeIfAuto(ComputedStyle&, const IntSize&);
// Sets the minimum size to |part_size| or |min_part_size| as appropriate
// according to the given style, if they are specified.
static void SetMinimumSize(ComputedStyle&,
const LengthSize* part_size,
const LengthSize* min_part_size = nullptr);
// SetMinimumSizeIfAuto must be called before SetSizeIfAuto, because we
// will not set a minimum size if an explicit size is set, and SetSizeIfAuto
// sets an explicit size.
......
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