Title: [270713] trunk
Revision
270713
Author
[email protected]
Date
2020-12-11 15:27:35 -0800 (Fri, 11 Dec 2020)

Log Message

[iOS][FCR] Add new look for select elements
https://bugs.webkit.org/show_bug.cgi?id=219507
<rdar://problem/71951874>

Reviewed by Wenson Hsieh.

Source/WebCore:

Implement the new in-page appearance for <select> and <select multiple>.
The new appearance/behavior of the select popup will be added separately.

Tests: fast/forms/ios/form-control-refresh/select/background-color.html
       fast/forms/ios/form-control-refresh/select/border-radius.html
       fast/forms/ios/form-control-refresh/select/border.html
       fast/forms/ios/form-control-refresh/select/multiple-appearance.html
       fast/forms/ios/form-control-refresh/select/rtl-appearance.html
       fast/forms/ios/form-control-refresh/select/text-color.html
       fast/forms/ios/form-control-refresh/select/width-height.html

* css/formControlsIOS.css:
(select):
* rendering/RenderMenuList.cpp:
(WebCore::RenderMenuList::adjustInnerStyle):
(RenderMenuList::layout):

Override the layout method so that the border radius can be adjusted to
enforce the pill-shaped appearance. Ideally, we should not be adjusting
styles during layout. However, for a pill-shaped appearance, the
horizontal border radius is dependent on the computed height of the box.
This means that the border radius cannot be declared prior to layout,
since CSS only allows the horizontal border radius to be dependent on the
computed width of the box.

Ignoring the style's border radius and forcing a pill-shaped appearance at
paint time is not an option, since focus rings and tap highlights will not
use the correct border radius. Consequently, we need to adjust the border
radius after layout.

Note that similar adjustments to style after layout are made in RenderSliderThumb,
RenderButton, and RenderTextControlSingleLine.

* rendering/RenderMenuList.h:
* rendering/RenderTheme.h:
(WebCore::RenderTheme::popupInternalPaddingBox const):

Added a new parameter, so that the padding can be controlled at runtime.

* rendering/RenderThemeAdwaita.cpp:
(WebCore::RenderThemeAdwaita::popupInternalPaddingBox const):
* rendering/RenderThemeAdwaita.h:
* rendering/RenderThemeIOS.h:
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::popupInternalPaddingBox const):

Use a 1em padding, so that the button scales with the font size.

(WebCore::canAdjustBorderRadiusForAppearance):

Enforce a pill-like shape, only if the author has not specified a
custom border radius.

(WebCore::RenderThemeIOS::paintMenuListButtonDecorations):
(WebCore::RenderThemeIOS::paintMenuListButtonDecorationsWithFormControlRefresh):

Paint the appropriate glyph for <select> (a two-headed arrow) and
<select multiple> (ellipses). Both glyphs were obtained from
SF Symbols. The glyph is painted on the right by default, and on
the left if the element's direction is RTL.

* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::popupInternalPaddingBox const):

LayoutTests:

Added tests to verify the stylability of select elements with the new appearance.

* fast/forms/ios/form-control-refresh/select/background-color-expected-mismatch.html: Added.
* fast/forms/ios/form-control-refresh/select/background-color.html: Added.
* fast/forms/ios/form-control-refresh/select/border-expected-mismatch.html: Added.
* fast/forms/ios/form-control-refresh/select/border-radius-expected-mismatch.html: Added.
* fast/forms/ios/form-control-refresh/select/border-radius.html: Added.
* fast/forms/ios/form-control-refresh/select/border.html: Added.
* fast/forms/ios/form-control-refresh/select/multiple-appearance-expected-mismatch.html: Added.
* fast/forms/ios/form-control-refresh/select/multiple-appearance.html: Added.
* fast/forms/ios/form-control-refresh/select/rtl-appearance-expected-mismatch.html: Added.
* fast/forms/ios/form-control-refresh/select/rtl-appearance.html: Added.
* fast/forms/ios/form-control-refresh/select/text-color-expected-mismatch.html: Added.
* fast/forms/ios/form-control-refresh/select/text-color.html: Added.
* fast/forms/ios/form-control-refresh/select/width-height-expected-mismatch.html: Added.
* fast/forms/ios/form-control-refresh/select/width-height.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (270712 => 270713)


--- trunk/LayoutTests/ChangeLog	2020-12-11 22:59:22 UTC (rev 270712)
+++ trunk/LayoutTests/ChangeLog	2020-12-11 23:27:35 UTC (rev 270713)
@@ -1,3 +1,28 @@
+2020-12-11  Aditya Keerthi  <[email protected]>
+
+        [iOS][FCR] Add new look for select elements
+        https://bugs.webkit.org/show_bug.cgi?id=219507
+        <rdar://problem/71951874>
+
+        Reviewed by Wenson Hsieh.
+
+        Added tests to verify the stylability of select elements with the new appearance.
+
+        * fast/forms/ios/form-control-refresh/select/background-color-expected-mismatch.html: Added.
+        * fast/forms/ios/form-control-refresh/select/background-color.html: Added.
+        * fast/forms/ios/form-control-refresh/select/border-expected-mismatch.html: Added.
+        * fast/forms/ios/form-control-refresh/select/border-radius-expected-mismatch.html: Added.
+        * fast/forms/ios/form-control-refresh/select/border-radius.html: Added.
+        * fast/forms/ios/form-control-refresh/select/border.html: Added.
+        * fast/forms/ios/form-control-refresh/select/multiple-appearance-expected-mismatch.html: Added.
+        * fast/forms/ios/form-control-refresh/select/multiple-appearance.html: Added.
+        * fast/forms/ios/form-control-refresh/select/rtl-appearance-expected-mismatch.html: Added.
+        * fast/forms/ios/form-control-refresh/select/rtl-appearance.html: Added.
+        * fast/forms/ios/form-control-refresh/select/text-color-expected-mismatch.html: Added.
+        * fast/forms/ios/form-control-refresh/select/text-color.html: Added.
+        * fast/forms/ios/form-control-refresh/select/width-height-expected-mismatch.html: Added.
+        * fast/forms/ios/form-control-refresh/select/width-height.html: Added.
+
 2020-12-11  Truitt Savell  <[email protected]>
 
         Remove LayoutTests/platform/big-sur

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/background-color-expected-mismatch.html (0 => 270713)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/background-color-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/background-color-expected-mismatch.html	2020-12-11 23:27:35 UTC (rev 270713)
@@ -0,0 +1,21 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ IOSFormControlRefreshEnabled=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+</head>
+<body>
+<select>
+    <option label="Apple"></option>
+    <option label="Apricot"></option>
+    <option label="Banana"></option>
+    <option label="Cantaloupe"></option>
+    <option label="Durian"></option>
+    <option label="Grape"></option>
+    <option label="Guava"></option>
+    <option label="Orange"></option>
+    <option label="Mango"></option>
+    <option label="Pear"></option>
+    <option label="Watermelon"></option>
+</select>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/background-color.html (0 => 270713)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/background-color.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/background-color.html	2020-12-11 23:27:35 UTC (rev 270713)
@@ -0,0 +1,28 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ IOSFormControlRefreshEnabled=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+
+select {
+    background-color: red;
+}
+
+</style>
+</head>
+<body>
+<select>
+    <option label="Apple"></option>
+    <option label="Apricot"></option>
+    <option label="Banana"></option>
+    <option label="Cantaloupe"></option>
+    <option label="Durian"></option>
+    <option label="Grape"></option>
+    <option label="Guava"></option>
+    <option label="Orange"></option>
+    <option label="Mango"></option>
+    <option label="Pear"></option>
+    <option label="Watermelon"></option>
+</select>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/border-expected-mismatch.html (0 => 270713)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/border-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/border-expected-mismatch.html	2020-12-11 23:27:35 UTC (rev 270713)
@@ -0,0 +1,21 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ IOSFormControlRefreshEnabled=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+</head>
+<body>
+<select>
+    <option label="Apple"></option>
+    <option label="Apricot"></option>
+    <option label="Banana"></option>
+    <option label="Cantaloupe"></option>
+    <option label="Durian"></option>
+    <option label="Grape"></option>
+    <option label="Guava"></option>
+    <option label="Orange"></option>
+    <option label="Mango"></option>
+    <option label="Pear"></option>
+    <option label="Watermelon"></option>
+</select>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/border-radius-expected-mismatch.html (0 => 270713)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/border-radius-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/border-radius-expected-mismatch.html	2020-12-11 23:27:35 UTC (rev 270713)
@@ -0,0 +1,28 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ IOSFormControlRefreshEnabled=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+
+select {
+    border-radius: 2px;
+}
+
+</style>
+</head>
+<body>
+<select>
+    <option label="Apple"></option>
+    <option label="Apricot"></option>
+    <option label="Banana"></option>
+    <option label="Cantaloupe"></option>
+    <option label="Durian"></option>
+    <option label="Grape"></option>
+    <option label="Guava"></option>
+    <option label="Orange"></option>
+    <option label="Mango"></option>
+    <option label="Pear"></option>
+    <option label="Watermelon"></option>
+</select>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/border-radius.html (0 => 270713)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/border-radius.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/border-radius.html	2020-12-11 23:27:35 UTC (rev 270713)
@@ -0,0 +1,28 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ IOSFormControlRefreshEnabled=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+
+select {
+    border-radius: 5px;
+}
+
+</style>
+</head>
+<body>
+<select>
+    <option label="Apple"></option>
+    <option label="Apricot"></option>
+    <option label="Banana"></option>
+    <option label="Cantaloupe"></option>
+    <option label="Durian"></option>
+    <option label="Grape"></option>
+    <option label="Guava"></option>
+    <option label="Orange"></option>
+    <option label="Mango"></option>
+    <option label="Pear"></option>
+    <option label="Watermelon"></option>
+</select>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/border.html (0 => 270713)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/border.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/border.html	2020-12-11 23:27:35 UTC (rev 270713)
@@ -0,0 +1,28 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ IOSFormControlRefreshEnabled=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+
+select {
+    border: 5px solid red;
+}
+
+</style>
+</head>
+<body>
+<select>
+    <option label="Apple"></option>
+    <option label="Apricot"></option>
+    <option label="Banana"></option>
+    <option label="Cantaloupe"></option>
+    <option label="Durian"></option>
+    <option label="Grape"></option>
+    <option label="Guava"></option>
+    <option label="Orange"></option>
+    <option label="Mango"></option>
+    <option label="Pear"></option>
+    <option label="Watermelon"></option>
+</select>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/multiple-appearance-expected-mismatch.html (0 => 270713)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/multiple-appearance-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/multiple-appearance-expected-mismatch.html	2020-12-11 23:27:35 UTC (rev 270713)
@@ -0,0 +1,21 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ IOSFormControlRefreshEnabled=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+</head>
+<body>
+<select>
+    <option label="Apple"></option>
+    <option label="Apricot"></option>
+    <option label="Banana"></option>
+    <option label="Cantaloupe"></option>
+    <option label="Durian"></option>
+    <option label="Grape"></option>
+    <option label="Guava"></option>
+    <option label="Orange"></option>
+    <option label="Mango"></option>
+    <option label="Pear"></option>
+    <option label="Watermelon"></option>
+</select>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/multiple-appearance.html (0 => 270713)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/multiple-appearance.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/multiple-appearance.html	2020-12-11 23:27:35 UTC (rev 270713)
@@ -0,0 +1,21 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ IOSFormControlRefreshEnabled=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+</head>
+<body>
+<select multiple>
+    <option label="Apple"></option>
+    <option label="Apricot"></option>
+    <option label="Banana"></option>
+    <option label="Cantaloupe"></option>
+    <option label="Durian"></option>
+    <option label="Grape"></option>
+    <option label="Guava"></option>
+    <option label="Orange"></option>
+    <option label="Mango"></option>
+    <option label="Pear"></option>
+    <option label="Watermelon"></option>
+</select>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/rtl-appearance-expected-mismatch.html (0 => 270713)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/rtl-appearance-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/rtl-appearance-expected-mismatch.html	2020-12-11 23:27:35 UTC (rev 270713)
@@ -0,0 +1,21 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ IOSFormControlRefreshEnabled=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+</head>
+<body>
+<select>
+    <option label="Apple"></option>
+    <option label="Apricot"></option>
+    <option label="Banana"></option>
+    <option label="Cantaloupe"></option>
+    <option label="Durian"></option>
+    <option label="Grape"></option>
+    <option label="Guava"></option>
+    <option label="Orange"></option>
+    <option label="Mango"></option>
+    <option label="Pear"></option>
+    <option label="Watermelon"></option>
+</select>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/rtl-appearance.html (0 => 270713)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/rtl-appearance.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/rtl-appearance.html	2020-12-11 23:27:35 UTC (rev 270713)
@@ -0,0 +1,21 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ IOSFormControlRefreshEnabled=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+</head>
+<body>
+<select dir="rtl">
+    <option label="Apple"></option>
+    <option label="Apricot"></option>
+    <option label="Banana"></option>
+    <option label="Cantaloupe"></option>
+    <option label="Durian"></option>
+    <option label="Grape"></option>
+    <option label="Guava"></option>
+    <option label="Orange"></option>
+    <option label="Mango"></option>
+    <option label="Pear"></option>
+    <option label="Watermelon"></option>
+</select>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/text-color-expected-mismatch.html (0 => 270713)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/text-color-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/text-color-expected-mismatch.html	2020-12-11 23:27:35 UTC (rev 270713)
@@ -0,0 +1,21 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ IOSFormControlRefreshEnabled=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+</head>
+<body>
+<select>
+    <option label="Apple"></option>
+    <option label="Apricot"></option>
+    <option label="Banana"></option>
+    <option label="Cantaloupe"></option>
+    <option label="Durian"></option>
+    <option label="Grape"></option>
+    <option label="Guava"></option>
+    <option label="Orange"></option>
+    <option label="Mango"></option>
+    <option label="Pear"></option>
+    <option label="Watermelon"></option>
+</select>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/text-color.html (0 => 270713)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/text-color.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/text-color.html	2020-12-11 23:27:35 UTC (rev 270713)
@@ -0,0 +1,28 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ IOSFormControlRefreshEnabled=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+
+select {
+    color: red;
+}
+
+</style>
+</head>
+<body>
+<select>
+    <option label="Apple"></option>
+    <option label="Apricot"></option>
+    <option label="Banana"></option>
+    <option label="Cantaloupe"></option>
+    <option label="Durian"></option>
+    <option label="Grape"></option>
+    <option label="Guava"></option>
+    <option label="Orange"></option>
+    <option label="Mango"></option>
+    <option label="Pear"></option>
+    <option label="Watermelon"></option>
+</select>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/width-height-expected-mismatch.html (0 => 270713)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/width-height-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/width-height-expected-mismatch.html	2020-12-11 23:27:35 UTC (rev 270713)
@@ -0,0 +1,21 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ IOSFormControlRefreshEnabled=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+</head>
+<body>
+<select>
+    <option label="Apple"></option>
+    <option label="Apricot"></option>
+    <option label="Banana"></option>
+    <option label="Cantaloupe"></option>
+    <option label="Durian"></option>
+    <option label="Grape"></option>
+    <option label="Guava"></option>
+    <option label="Orange"></option>
+    <option label="Mango"></option>
+    <option label="Pear"></option>
+    <option label="Watermelon"></option>
+</select>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/width-height.html (0 => 270713)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/width-height.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/select/width-height.html	2020-12-11 23:27:35 UTC (rev 270713)
@@ -0,0 +1,29 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ IOSFormControlRefreshEnabled=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+
+select {
+    width: 300px;
+    height: 100px;
+}
+
+</style>
+</head>
+<body>
+<select>
+    <option label="Apple"></option>
+    <option label="Apricot"></option>
+    <option label="Banana"></option>
+    <option label="Cantaloupe"></option>
+    <option label="Durian"></option>
+    <option label="Grape"></option>
+    <option label="Guava"></option>
+    <option label="Orange"></option>
+    <option label="Mango"></option>
+    <option label="Pear"></option>
+    <option label="Watermelon"></option>
+</select>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (270712 => 270713)


--- trunk/Source/WebCore/ChangeLog	2020-12-11 22:59:22 UTC (rev 270712)
+++ trunk/Source/WebCore/ChangeLog	2020-12-11 23:27:35 UTC (rev 270713)
@@ -1,3 +1,76 @@
+2020-12-11  Aditya Keerthi  <[email protected]>
+
+        [iOS][FCR] Add new look for select elements
+        https://bugs.webkit.org/show_bug.cgi?id=219507
+        <rdar://problem/71951874>
+
+        Reviewed by Wenson Hsieh.
+
+        Implement the new in-page appearance for <select> and <select multiple>.
+        The new appearance/behavior of the select popup will be added separately.
+
+        Tests: fast/forms/ios/form-control-refresh/select/background-color.html
+               fast/forms/ios/form-control-refresh/select/border-radius.html
+               fast/forms/ios/form-control-refresh/select/border.html
+               fast/forms/ios/form-control-refresh/select/multiple-appearance.html
+               fast/forms/ios/form-control-refresh/select/rtl-appearance.html
+               fast/forms/ios/form-control-refresh/select/text-color.html
+               fast/forms/ios/form-control-refresh/select/width-height.html
+
+        * css/formControlsIOS.css:
+        (select):
+        * rendering/RenderMenuList.cpp:
+        (WebCore::RenderMenuList::adjustInnerStyle):
+        (RenderMenuList::layout):
+
+        Override the layout method so that the border radius can be adjusted to
+        enforce the pill-shaped appearance. Ideally, we should not be adjusting
+        styles during layout. However, for a pill-shaped appearance, the
+        horizontal border radius is dependent on the computed height of the box.
+        This means that the border radius cannot be declared prior to layout,
+        since CSS only allows the horizontal border radius to be dependent on the
+        computed width of the box.
+
+        Ignoring the style's border radius and forcing a pill-shaped appearance at
+        paint time is not an option, since focus rings and tap highlights will not
+        use the correct border radius. Consequently, we need to adjust the border
+        radius after layout.
+
+        Note that similar adjustments to style after layout are made in RenderSliderThumb,
+        RenderButton, and RenderTextControlSingleLine.
+
+        * rendering/RenderMenuList.h:
+        * rendering/RenderTheme.h:
+        (WebCore::RenderTheme::popupInternalPaddingBox const):
+
+        Added a new parameter, so that the padding can be controlled at runtime.
+
+        * rendering/RenderThemeAdwaita.cpp:
+        (WebCore::RenderThemeAdwaita::popupInternalPaddingBox const):
+        * rendering/RenderThemeAdwaita.h:
+        * rendering/RenderThemeIOS.h:
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::popupInternalPaddingBox const):
+
+        Use a 1em padding, so that the button scales with the font size.
+
+        (WebCore::canAdjustBorderRadiusForAppearance):
+
+        Enforce a pill-like shape, only if the author has not specified a
+        custom border radius.
+
+        (WebCore::RenderThemeIOS::paintMenuListButtonDecorations):
+        (WebCore::RenderThemeIOS::paintMenuListButtonDecorationsWithFormControlRefresh):
+
+        Paint the appropriate glyph for <select> (a two-headed arrow) and
+        <select multiple> (ellipses). Both glyphs were obtained from
+        SF Symbols. The glyph is painted on the right by default, and on
+        the left if the element's direction is RTL.
+
+        * rendering/RenderThemeMac.h:
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::popupInternalPaddingBox const):
+
 2020-12-11  Tim Horton  <[email protected]>
 
         Trackpad and Mouse scroll events on iPad only fire "pointermove" -- not "wheel"

Modified: trunk/Source/WebCore/css/formControlsIOS.css (270712 => 270713)


--- trunk/Source/WebCore/css/formControlsIOS.css	2020-12-11 22:59:22 UTC (rev 270712)
+++ trunk/Source/WebCore/css/formControlsIOS.css	2020-12-11 23:27:35 UTC (rev 270713)
@@ -88,4 +88,13 @@
     border-radius: inherit;
 }
 
+select {
+    color: rgb(0, 122, 255);
+    font-weight: bold;
+    font-family: system-ui;
+    border: initial;
+    border-radius: initial;
+    background-color: rgb(235, 245, 255);
+}
+
 #endif

Modified: trunk/Source/WebCore/rendering/RenderMenuList.cpp (270712 => 270713)


--- trunk/Source/WebCore/rendering/RenderMenuList.cpp	2020-12-11 22:59:22 UTC (rev 270712)
+++ trunk/Source/WebCore/rendering/RenderMenuList.cpp	2020-12-11 23:27:35 UTC (rev 270713)
@@ -51,6 +51,7 @@
 
 #if PLATFORM(IOS_FAMILY)
 #include "LocalizedStrings.h"
+#include "RenderThemeIOS.h"
 #endif
 
 namespace WebCore {
@@ -123,7 +124,7 @@
         innerStyle.setAlignSelfPosition(ItemPosition::FlexStart);
     }
 
-    innerStyle.setPaddingBox(theme().popupInternalPaddingBox(style()));
+    innerStyle.setPaddingBox(theme().popupInternalPaddingBox(style(), document().settings()));
 
     if (document().page()->chrome().selectItemWritingDirectionIsNatural()) {
         // Items in the popup will not respect the CSS text-align and direction properties,
@@ -651,4 +652,26 @@
     return &document().fontSelector();
 }
 
+#if PLATFORM(IOS_FAMILY)
+void RenderMenuList::layout()
+{
+    RenderFlexibleBox::layout();
+
+    // Ideally, we should not be adjusting styles during layout. However, for a
+    // pill-shaped appearance, the horizontal border radius is dependent on the
+    // computed height of the box. This means that the appearance cannot be declared
+    // prior to layout, since CSS only allows the horizontal border radius to be
+    // dependent on the computed width of the box.
+    //
+    // Ignoring the style's border radius and forcing a pill-shaped appearance at
+    // paint time is not an option, since focus rings and tap highlights will not
+    // use the correct border radius. Consequently, we need to adjust the border
+    // radius here.
+    //
+    // Note that similar adjustments are made in RenderSliderThumb, RenderButton
+    // and RenderTextControlSingleLine.
+    RenderThemeIOS::adjustRoundBorderRadius(mutableStyle(), *this);
 }
+#endif
+
+}

Modified: trunk/Source/WebCore/rendering/RenderMenuList.h (270712 => 270713)


--- trunk/Source/WebCore/rendering/RenderMenuList.h	2020-12-11 22:59:22 UTC (rev 270712)
+++ trunk/Source/WebCore/rendering/RenderMenuList.h	2020-12-11 23:27:35 UTC (rev 270713)
@@ -59,6 +59,10 @@
 
     String text() const;
 
+#if PLATFORM(IOS_FAMILY)
+    void layout() override;
+#endif
+
     RenderBlock* innerRenderer() const { return m_innerBlock.get(); }
     void setInnerRenderer(RenderBlock&);
 

Modified: trunk/Source/WebCore/rendering/RenderTheme.h (270712 => 270713)


--- trunk/Source/WebCore/rendering/RenderTheme.h	2020-12-11 22:59:22 UTC (rev 270712)
+++ trunk/Source/WebCore/rendering/RenderTheme.h	2020-12-11 23:27:35 UTC (rev 270713)
@@ -187,7 +187,7 @@
 
     virtual void adjustSliderThumbSize(RenderStyle&, const Element*) const;
 
-    virtual LengthBox popupInternalPaddingBox(const RenderStyle&) const { return { 0, 0, 0, 0 }; }
+    virtual LengthBox popupInternalPaddingBox(const RenderStyle&, const Settings&) const { return { 0, 0, 0, 0 }; }
     virtual bool popupOptionSupportsTextIndent() const { return false; }
     virtual PopupMenuStyle::PopupMenuSize popupMenuSize(const RenderStyle&, IntRect&) const { return PopupMenuStyle::PopupMenuSizeNormal; }
 

Modified: trunk/Source/WebCore/rendering/RenderThemeAdwaita.cpp (270712 => 270713)


--- trunk/Source/WebCore/rendering/RenderThemeAdwaita.cpp	2020-12-11 22:59:22 UTC (rev 270712)
+++ trunk/Source/WebCore/rendering/RenderThemeAdwaita.cpp	2020-12-11 23:27:35 UTC (rev 270713)
@@ -251,7 +251,7 @@
     adjustMenuListStyle(style, element);
 }
 
-LengthBox RenderThemeAdwaita::popupInternalPaddingBox(const RenderStyle& style) const
+LengthBox RenderThemeAdwaita::popupInternalPaddingBox(const RenderStyle& style, const Settings&) const
 {
     if (style.appearance() == NoControlPart)
         return { };

Modified: trunk/Source/WebCore/rendering/RenderThemeAdwaita.h (270712 => 270713)


--- trunk/Source/WebCore/rendering/RenderThemeAdwaita.h	2020-12-11 22:59:22 UTC (rev 270712)
+++ trunk/Source/WebCore/rendering/RenderThemeAdwaita.h	2020-12-11 23:27:35 UTC (rev 270713)
@@ -64,7 +64,7 @@
     bool popsMenuBySpaceOrReturn() const final { return true; }
     void adjustMenuListStyle(RenderStyle&, const Element*) const override;
     void adjustMenuListButtonStyle(RenderStyle&, const Element*) const override;
-    LengthBox popupInternalPaddingBox(const RenderStyle&) const final;
+    LengthBox popupInternalPaddingBox(const RenderStyle&, const Settings&) const final;
     bool paintMenuList(const RenderObject&, const PaintInfo&, const FloatRect&) final;
     void paintMenuListButtonDecorations(const RenderBox&, const PaintInfo&, const FloatRect&) final;
 

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.h (270712 => 270713)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.h	2020-12-11 22:59:22 UTC (rev 270712)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.h	2020-12-11 23:27:35 UTC (rev 270713)
@@ -70,7 +70,7 @@
 private:
     bool canPaint(const PaintInfo&, const Settings&) const final;
 
-    LengthBox popupInternalPaddingBox(const RenderStyle&) const override;
+    LengthBox popupInternalPaddingBox(const RenderStyle&, const Settings&) const override;
 
     int baselinePosition(const RenderBox&) const override;
 
@@ -177,6 +177,7 @@
 #if ENABLE(IOS_FORM_CONTROL_REFRESH)
     bool paintProgressBarWithFormControlRefresh(const RenderObject&, const PaintInfo&, const IntRect&);
     bool paintSliderTrackWithFormControlRefresh(const RenderObject&, const PaintInfo&, const IntRect&);
+    void paintMenuListButtonDecorationsWithFormControlRefresh(const RenderBox&, const PaintInfo&, const FloatRect&);
 #endif
 
     FloatRect addRoundedBorderClip(const RenderObject& box, GraphicsContext&, const IntRect&);

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (270712 => 270713)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2020-12-11 22:59:22 UTC (rev 270712)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2020-12-11 23:27:35 UTC (rev 270713)
@@ -562,12 +562,18 @@
 const float MenuListArrowHeight = 6;
 const float MenuListButtonPaddingAfter = 19;
 
-LengthBox RenderThemeIOS::popupInternalPaddingBox(const RenderStyle& style) const
+LengthBox RenderThemeIOS::popupInternalPaddingBox(const RenderStyle& style, const Settings& settings) const
 {
+    float padding = MenuListButtonPaddingAfter;
+    if (settings.iOSFormControlRefreshEnabled()) {
+        auto emSize = CSSPrimitiveValue::create(1.0, CSSUnitType::CSS_EMS);
+        padding = emSize->computeLength<float>(CSSToLengthConversionData(&style, nullptr, nullptr, nullptr, 1.0, WTF::nullopt));
+    }
+
     if (style.appearance() == MenulistButtonPart) {
         if (style.direction() == TextDirection::RTL)
-            return { 0, 0, 0, static_cast<int>(MenuListButtonPaddingAfter + style.borderTopWidth()) };
-        return { 0, static_cast<int>(MenuListButtonPaddingAfter + style.borderTopWidth()), 0, 0 };
+            return { 0, 0, 0, static_cast<int>(padding + style.borderTopWidth()) };
+        return { 0, static_cast<int>(padding + style.borderTopWidth()), 0, 0 };
     }
     return { 0, 0, 0, 0 };
 }
@@ -583,6 +589,8 @@
 #if ENABLE(IOS_FORM_CONTROL_REFRESH)
     case SearchFieldPart:
         return !box.settings().iOSFormControlRefreshEnabled();
+    case MenulistButtonPart:
+        return !box.style().hasExplicitlySetBorderRadius() && box.settings().iOSFormControlRefreshEnabled();
 #endif
     default:
         return true;
@@ -683,6 +691,13 @@
 
 void RenderThemeIOS::paintMenuListButtonDecorations(const RenderBox& box, const PaintInfo& paintInfo, const FloatRect& rect)
 {
+#if ENABLE(IOS_FORM_CONTROL_REFRESH)
+    if (box.settings().iOSFormControlRefreshEnabled()) {
+        paintMenuListButtonDecorationsWithFormControlRefresh(box, paintInfo, rect);
+        return;
+    }
+#endif
+
     auto& style = box.style();
     bool isRTL = style.direction() == TextDirection::RTL;
     float borderTopWidth = style.borderTopWidth();
@@ -2032,6 +2047,8 @@
 constexpr auto meterSuboptimalColor = SRGBA<uint8_t> { 247, 206, 70 };
 constexpr auto meterEvenLessGoodColor = SRGBA<uint8_t> { 255, 59, 48 };
 
+constexpr auto menulistButtonColor = SRGBA<uint8_t> { 97, 172, 255 };
+
 bool RenderThemeIOS::paintCheckbox(const RenderObject& box, const PaintInfo& paintInfo, const IntRect& rect)
 {
     if (!box.settings().iOSFormControlRefreshEnabled())
@@ -2357,6 +2374,79 @@
 
 #endif // ENABLE(INPUT_TYPE_COLOR)
 
+void RenderThemeIOS::paintMenuListButtonDecorationsWithFormControlRefresh(const RenderBox& box, const PaintInfo& paintInfo, const FloatRect& rect)
+{
+    auto& context = paintInfo.context();
+    GraphicsContextStateSaver stateSaver(context);
+
+    auto& style = box.style();
+
+    Path glyphPath;
+    FloatSize glyphSize;
+
+    if (box.isMenuList() && downcast<HTMLSelectElement>(box.element())->multiple()) {
+        constexpr int length = 18;
+        constexpr int count = 3;
+        constexpr int padding = 12;
+
+        FloatRect ellipse(0, 0, length, length);
+
+        for (int i = 0; i < count; ++i) {
+            glyphPath.addEllipse(ellipse);
+            ellipse.move(length + padding, 0);
+        }
+
+        glyphSize = { length * count + padding * (count - 1), length };
+    } else {
+        constexpr int glyphWidth = 63;
+        constexpr int glyphHeight = 73;
+        glyphSize = { glyphWidth, glyphHeight };
+
+        glyphPath.moveTo({ 31.8593f, 1.0f });
+        glyphPath.addBezierCurveTo({ 30.541f, 1.0f }, { 29.418f, 1.586f }, { 28.0507f, 2.66f });
+        glyphPath.addLineTo({ 2.5625f, 23.168f });
+        glyphPath.addBezierCurveTo({ 1.5859f, 23.998f }, { 1.0f, 25.2188f }, { 1.0f, 26.7325f });
+        glyphPath.addBezierCurveTo({ 1.0f, 29.6133f }, { 3.246f, 31.7129f }, { 5.9316f, 31.7129f });
+        glyphPath.addBezierCurveTo({ 7.1523f, 31.7129f }, { 8.3242f, 31.2246f }, { 9.5449f, 30.248f });
+        glyphPath.addLineTo({ 31.8593f, 12.377f });
+        glyphPath.addLineTo({ 54.2226f, 30.248f });
+        glyphPath.addBezierCurveTo({ 55.3945f, 31.2246f }, { 56.6152f, 31.7129f }, { 57.7871f, 31.7129 });
+        glyphPath.addBezierCurveTo({ 60.4726f, 31.7129f }, { 62.7187f, 29.6133f }, { 62.7187f, 26.7325 });
+        glyphPath.addBezierCurveTo({ 62.7187f, 25.2188f }, { 62.1327f, 23.9981f }, { 61.1562f, 23.168 });
+        glyphPath.addLineTo({ 35.6679f, 2.6602f });
+        glyphPath.addBezierCurveTo({ 34.3496f, 1.586f }, { 33.1777f, 1.0f }, { 31.8593f, 1.0f });
+        glyphPath.moveTo({ 31.8593f, 72.3867f });
+        glyphPath.addBezierCurveTo({ 33.1777f, 72.3867f }, { 34.3496f, 71.8007f }, { 35.6679f, 70.7266f });
+        glyphPath.addLineTo({ 61.1562f, 50.2188f });
+        glyphPath.addBezierCurveTo({ 62.1328f, 49.3888f }, { 62.7187f, 48.168f }, { 62.7187f, 46.6543f });
+        glyphPath.addBezierCurveTo({ 62.7187f, 43.7735f }, { 60.4726f, 41.6739f }, { 57.7871f, 41.6739f });
+        glyphPath.addBezierCurveTo({ 56.6151f, 41.6739f }, { 55.3945f, 42.162f }, { 54.2226f, 43.09f });
+        glyphPath.addLineTo({ 31.8593f, 61.01f });
+        glyphPath.addLineTo({ 9.545f, 43.0898f });
+        glyphPath.addBezierCurveTo({ 8.3243f, 42.1619f }, { 7.1524f, 41.6738f }, { 5.9317f, 41.6738f });
+        glyphPath.addBezierCurveTo({ 3.246f, 41.6739f }, { 1.0f, 43.7735f }, { 1.0f, 46.6543f });
+        glyphPath.addBezierCurveTo({ 1.0f, 48.168f }, { 1.5859, 49.3887 }, { 2.5625, 50.2188f });
+        glyphPath.addLineTo({ 28.0507f, 70.7266f });
+        glyphPath.addBezierCurveTo({ 29.4179f, 71.8f }, { 30.541f, 72.3867f }, { 31.8593f, 72.3867 });
+    }
+
+    auto emSize = CSSPrimitiveValue::create(1.0, CSSUnitType::CSS_EMS);
+    auto emPixels = emSize->computeLength<float>(CSSToLengthConversionData(&style, nullptr, nullptr, nullptr, 1.0, WTF::nullopt));
+    auto glyphScale = 0.65f * emPixels / glyphSize.width();
+    glyphSize = glyphScale * glyphSize;
+
+    AffineTransform transform;
+    if (style.isLeftToRightDirection())
+        transform.translate(rect.maxX() - glyphSize.width() - box.style().borderEndWidth() - valueForLength(box.style().paddingEnd(), rect.width()), rect.center().y() - glyphSize.height() / 2.0f);
+    else
+        transform.translate(rect.x() + box.style().borderEndWidth() + valueForLength(box.style().paddingEnd(), rect.width()), rect.center().y() - glyphSize.height() / 2.0f);
+    transform.scale(glyphScale);
+    glyphPath.transform(transform);
+
+    context.setFillColor(menulistButtonColor);
+    context.fillPath(glyphPath);
+}
+
 #endif // ENABLE(IOS_FORM_CONTROL_REFRESH)
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (270712 => 270713)


--- trunk/Source/WebCore/rendering/RenderThemeMac.h	2020-12-11 22:59:22 UTC (rev 270712)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h	2020-12-11 23:27:35 UTC (rev 270713)
@@ -81,7 +81,7 @@
     int sliderTickOffsetFromTrackCenter() const final;
 #endif
 
-    LengthBox popupInternalPaddingBox(const RenderStyle&) const final;
+    LengthBox popupInternalPaddingBox(const RenderStyle&, const Settings&) const final;
     PopupMenuStyle::PopupMenuSize popupMenuSize(const RenderStyle&, IntRect&) const final;
 
     bool popsMenuByArrowKeys() const final { return true; }

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (270712 => 270713)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2020-12-11 22:59:22 UTC (rev 270712)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2020-12-11 23:27:35 UTC (rev 270713)
@@ -1646,7 +1646,7 @@
     style.setBoxShadow(nullptr);
 }
 
-LengthBox RenderThemeMac::popupInternalPaddingBox(const RenderStyle& style) const
+LengthBox RenderThemeMac::popupInternalPaddingBox(const RenderStyle& style, const Settings&) const
 {
     if (style.appearance() == MenulistPart) {
         const int* padding = popupButtonPadding(controlSizeForFont(style), style.direction() == TextDirection::RTL);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to