Title: [287753] trunk
Revision
287753
Author
akeer...@apple.com
Date
2022-01-07 09:32:52 -0800 (Fri, 07 Jan 2022)

Log Message

Checkboxes on PurpleAir map controls are much smaller in Safari than other browsers
https://bugs.webkit.org/show_bug.cgi?id=234897
rdar://83367191

Reviewed by Darin Adler.

Source/WebCore:

Unlike other browser engines, WebKit adjusts the size of checkboxes and
radio buttons based on the font-size of the element, when the size is
unspecified. The checkboxes on PurpleAir have a font-size of 9px, which
results in WebKit painting a checkbox using NSControlSizeMini (with a
length of 10px). In constrast, Chrome and Firefox simply use their
default sizes (13px and 12.6px respectively).

To fix, remove the font-size adjustments for checkboxes and radio
buttons with an unspecified size, and use the current effective
default of NSControlSizeSmall (with a length of 12px) to paint the
controls.

This ensures our unspecified sizing behavior matches other browsers.
There may be some risk for other WebKit clients that currently rely
on font-size getting them their desired size. However, this risk is
believed to be minimal given the sizes of these controls are already
restricted to a 10 - 16px range.

Test: fast/forms/checkbox-radio-font-size.html

* platform/mac/ThemeMac.mm:
(WebCore::checkboxSize):
(WebCore::radioSize):
(WebCore::ThemeMac::controlSize const):

LayoutTests:

* fast/forms/checkbox-radio-font-size-expected.html: Added.
* fast/forms/checkbox-radio-font-size.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (287752 => 287753)


--- trunk/LayoutTests/ChangeLog	2022-01-07 17:27:19 UTC (rev 287752)
+++ trunk/LayoutTests/ChangeLog	2022-01-07 17:32:52 UTC (rev 287753)
@@ -1,3 +1,14 @@
+2022-01-07  Aditya Keerthi  <akeer...@apple.com>
+
+        Checkboxes on PurpleAir map controls are much smaller in Safari than other browsers
+        https://bugs.webkit.org/show_bug.cgi?id=234897
+        rdar://83367191
+
+        Reviewed by Darin Adler.
+
+        * fast/forms/checkbox-radio-font-size-expected.html: Added.
+        * fast/forms/checkbox-radio-font-size.html: Added.
+
 2022-01-07  Diego Pino Garcia  <dp...@igalia.com>
 
         [GTK] Regression in inspector/audit/run-resources.html

Added: trunk/LayoutTests/fast/forms/checkbox-radio-font-size-expected.html (0 => 287753)


--- trunk/LayoutTests/fast/forms/checkbox-radio-font-size-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/checkbox-radio-font-size-expected.html	2022-01-07 17:32:52 UTC (rev 287753)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that checkboxes and radio buttons do not change size based on font-size.</title>
+</head>
+<body>
+    <div>
+        <input type="checkbox" checked>
+        <input type="checkbox">
+        <input type="checkbox">
+        <input type="checkbox">
+    </div>
+    <div>
+        <input type="radio" checked>
+        <input type="radio">
+        <input type="radio">
+        <input type="radio">
+    </div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/checkbox-radio-font-size.html (0 => 287753)


--- trunk/LayoutTests/fast/forms/checkbox-radio-font-size.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/checkbox-radio-font-size.html	2022-01-07 17:32:52 UTC (rev 287753)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that checkboxes and radio buttons do not change size based on font-size.</title>
+</head>
+<body>
+    <div>
+        <input style="font-size: 9px" type="checkbox" checked>
+        <input style="font-size: 12px" type="checkbox">
+        <input style="font-size: 16px" type="checkbox">
+        <input style="font-size: 30px" type="checkbox">
+    </div>
+    <div>
+        <input style="font-size: 9px" type="radio" checked>
+        <input style="font-size: 12px" type="radio">
+        <input style="font-size: 16px" type="radio">
+        <input style="font-size: 30px" type="radio">
+    </div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (287752 => 287753)


--- trunk/Source/WebCore/ChangeLog	2022-01-07 17:27:19 UTC (rev 287752)
+++ trunk/Source/WebCore/ChangeLog	2022-01-07 17:32:52 UTC (rev 287753)
@@ -1,3 +1,36 @@
+2022-01-07  Aditya Keerthi  <akeer...@apple.com>
+
+        Checkboxes on PurpleAir map controls are much smaller in Safari than other browsers
+        https://bugs.webkit.org/show_bug.cgi?id=234897
+        rdar://83367191
+
+        Reviewed by Darin Adler.
+
+        Unlike other browser engines, WebKit adjusts the size of checkboxes and
+        radio buttons based on the font-size of the element, when the size is
+        unspecified. The checkboxes on PurpleAir have a font-size of 9px, which
+        results in WebKit painting a checkbox using NSControlSizeMini (with a
+        length of 10px). In constrast, Chrome and Firefox simply use their
+        default sizes (13px and 12.6px respectively).
+
+        To fix, remove the font-size adjustments for checkboxes and radio
+        buttons with an unspecified size, and use the current effective
+        default of NSControlSizeSmall (with a length of 12px) to paint the
+        controls.
+
+        This ensures our unspecified sizing behavior matches other browsers.
+        There may be some risk for other WebKit clients that currently rely
+        on font-size getting them their desired size. However, this risk is
+        believed to be minimal given the sizes of these controls are already
+        restricted to a 10 - 16px range.
+
+        Test: fast/forms/checkbox-radio-font-size.html
+
+        * platform/mac/ThemeMac.mm:
+        (WebCore::checkboxSize):
+        (WebCore::radioSize):
+        (WebCore::ThemeMac::controlSize const):
+
 2022-01-07  Alan Bujtas  <za...@apple.com>
 
         [Cleanup] RenderElement::containingBlockFor*(fixed/absolute/inflow)Position is slightly confusing

Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (287752 => 287753)


--- trunk/Source/WebCore/platform/mac/ThemeMac.mm	2022-01-07 17:27:19 UTC (rev 287752)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm	2022-01-07 17:32:52 UTC (rev 287753)
@@ -281,14 +281,13 @@
     return margins[controlSize];
 }
 
-static LengthSize checkboxSize(const FontCascade& font, const LengthSize& zoomedSize, float zoomFactor)
+static LengthSize checkboxSize(const LengthSize& zoomedSize, float zoomFactor)
 {
     // If the width and height are both specified, then we have nothing to do.
     if (!zoomedSize.width.isIntrinsicOrAuto() && !zoomedSize.height.isIntrinsicOrAuto())
         return zoomedSize;
 
-    // Use the font size to determine the intrinsic width of the control.
-    return sizeFromFont(font, zoomedSize, zoomFactor, checkboxSizes());
+    return sizeFromNSControlSize(NSControlSizeSmall, zoomedSize, zoomFactor, checkboxSizes());
 }
 
 // Radio Buttons
@@ -322,14 +321,13 @@
     return margins[controlSize];
 }
 
-static LengthSize radioSize(const FontCascade& font, const LengthSize& zoomedSize, float zoomFactor)
+static LengthSize radioSize(const LengthSize& zoomedSize, float zoomFactor)
 {
     // If the width and height are both specified, then we have nothing to do.
     if (!zoomedSize.width.isIntrinsicOrAuto() && !zoomedSize.height.isIntrinsicOrAuto())
         return zoomedSize;
 
-    // Use the font size to determine the intrinsic width of the control.
-    return sizeFromFont(font, zoomedSize, zoomFactor, radioSizes());
+    return sizeFromNSControlSize(NSControlSizeSmall, zoomedSize, zoomFactor, radioSizes());
 }
     
 static void configureToggleButton(NSCell* cell, ControlPart buttonType, const ControlStates& states, const IntSize& zoomedSize, float zoomFactor, bool isStateChange)
@@ -822,9 +820,9 @@
 {
     switch (part) {
     case CheckboxPart:
-        return checkboxSize(font, zoomedSize, zoomFactor);
+        return checkboxSize(zoomedSize, zoomFactor);
     case RadioPart:
-        return radioSize(font, zoomedSize, zoomFactor);
+        return radioSize(zoomedSize, zoomFactor);
     case PushButtonPart:
         // Height is reset to auto so that specified heights can be ignored.
         return sizeFromFont(font, { zoomedSize.width, { } }, zoomFactor, buttonSizes());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to