Title: [257150] trunk/Source
Revision
257150
Author
[email protected]
Date
2020-02-21 11:03:29 -0800 (Fri, 21 Feb 2020)

Log Message

[macOS] Large form controls are rendered at the wrong NSControlSize
https://bugs.webkit.org/show_bug.cgi?id=208043
<rdar://problem/59659134>

Reviewed by Tim Horton.

Source/WebCore:

When painting form controls that are larger than a certain threshold (for the most part, 21px), use
NSControlSizeLarge instead of NSControlSizeRegular. This makes us choose a more appropriate appearance when
painting native large form controls, as long as the system supports it. Note that not all the metrics for
NSControlSizeLarge form controls are finalized, as noted in the per-method comments below.

With this patch alone, there is no change in behavior yet; in the near future, these changes will be covered by
new platform-specific baselines.

* platform/PopupMenuStyle.h: Add a new PopupMenuSizeLarge that corresponds to a popup that has NSControlSizeLarge.
* platform/mac/ThemeMac.h: Add a helper to check (at runtime) whether the new large form control size is enabled.
* platform/mac/ThemeMac.mm:
(WebCore::controlSizeForFont): Add a new font size breakpoint, for which we use NSControlSizeLarge instead of
NSControlSizeRegular.

(WebCore::sizeFromNSControlSize):
(WebCore::sizeFromFont):
(WebCore::controlSizeFromPixelSize):
(WebCore::setControlSize):
(WebCore::checkboxSizes): Reflect the fact that checkboxes with NSControlSizeLarge are 16 by 16.
(WebCore::checkboxMargins): Just match NSControlSizeRegular margins for now. These seem incorrect already, even
for NSControlSizeRegular in macOS 10.15.

(WebCore::radioSizes): Reflect the fact that radio buttons with NSControlSizeLarge are 16 by 16, and
NSControlSizeRegular radio buttons are 14 by 14.

(WebCore::radioMargins): Just match NSControlSizeRegular margins for now. These seem incorrect already, even for
NSControlSizeRegular in macOS 10.15.

(WebCore::buttonSizes): Reflect the fact that buttons with NSControlSizeLarge are 28px tall.
(WebCore::buttonMargins): Just match NSControlSizeRegular margins for now, and add a FIXME about updating them.
(WebCore::setUpButtonCell):
(WebCore::stepperSizes): NSControlSizeLarge matches NSControlSizeRegular at the moment.
(WebCore::stepperControlSizeForFont): Add a new font size breakpoint for using NSControlSizeLarge.
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::controlSizeForFont const):
(WebCore::RenderThemeMac::controlSizeForCell const):
(WebCore::RenderThemeMac::controlSizeForSystemFont const):
(WebCore::RenderThemeMac::popupButtonMargins const):
(WebCore::RenderThemeMac::popupButtonSizes const):
(WebCore::RenderThemeMac::popupButtonPadding const):

NSControlSizeLarge metrics for popup buttons cannot be determined yet.

(WebCore::RenderThemeMac::progressBarSizes const):
(WebCore::RenderThemeMac::progressBarMargins const):
(WebCore::RenderThemeMac::paintProgressBar):

NSControlSizeLarge matches NSControlSizeRegular at the moment.

(WebCore::menuListButtonSizes):
(WebCore::RenderThemeMac::popupMenuSize const):
(WebCore::RenderThemeMac::menuListSizes const):
(WebCore::RenderThemeMac::searchFieldSizes const):
(WebCore::RenderThemeMac::cancelButtonSizes const):
(WebCore::RenderThemeMac::resultsButtonSizes const):

Search field results and cancel buttons have the same size in NSControlSizeLarge as in NSControlSizeRegular.

Source/WebCore/PAL:

Import NSAppearance_Private.h in this SPI header. See WebCore ChangeLog for more details.

* pal/spi/mac/NSAppearanceSPI.h:

Source/WebKit:

See WebCore ChangeLog for more details.

* UIProcess/mac/WebPopupMenuProxyMac.mm:
(WebKit::WebPopupMenuProxyMac::showPopupMenu):

Source/WebKitLegacy/mac:

See WebCore ChangeLog for more details.

* WebCoreSupport/PopupMenuMac.mm:
(PopupMenuMac::show):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (257149 => 257150)


--- trunk/Source/WebCore/ChangeLog	2020-02-21 18:52:24 UTC (rev 257149)
+++ trunk/Source/WebCore/ChangeLog	2020-02-21 19:03:29 UTC (rev 257150)
@@ -1,3 +1,69 @@
+2020-02-21  Wenson Hsieh  <[email protected]>
+
+        [macOS] Large form controls are rendered at the wrong NSControlSize
+        https://bugs.webkit.org/show_bug.cgi?id=208043
+        <rdar://problem/59659134>
+
+        Reviewed by Tim Horton.
+
+        When painting form controls that are larger than a certain threshold (for the most part, 21px), use
+        NSControlSizeLarge instead of NSControlSizeRegular. This makes us choose a more appropriate appearance when
+        painting native large form controls, as long as the system supports it. Note that not all the metrics for
+        NSControlSizeLarge form controls are finalized, as noted in the per-method comments below.
+
+        With this patch alone, there is no change in behavior yet; in the near future, these changes will be covered by
+        new platform-specific baselines.
+
+        * platform/PopupMenuStyle.h: Add a new PopupMenuSizeLarge that corresponds to a popup that has NSControlSizeLarge.
+        * platform/mac/ThemeMac.h: Add a helper to check (at runtime) whether the new large form control size is enabled.
+        * platform/mac/ThemeMac.mm:
+        (WebCore::controlSizeForFont): Add a new font size breakpoint, for which we use NSControlSizeLarge instead of
+        NSControlSizeRegular.
+
+        (WebCore::sizeFromNSControlSize):
+        (WebCore::sizeFromFont):
+        (WebCore::controlSizeFromPixelSize):
+        (WebCore::setControlSize):
+        (WebCore::checkboxSizes): Reflect the fact that checkboxes with NSControlSizeLarge are 16 by 16.
+        (WebCore::checkboxMargins): Just match NSControlSizeRegular margins for now. These seem incorrect already, even
+        for NSControlSizeRegular in macOS 10.15.
+
+        (WebCore::radioSizes): Reflect the fact that radio buttons with NSControlSizeLarge are 16 by 16, and
+        NSControlSizeRegular radio buttons are 14 by 14.
+
+        (WebCore::radioMargins): Just match NSControlSizeRegular margins for now. These seem incorrect already, even for
+        NSControlSizeRegular in macOS 10.15.
+
+        (WebCore::buttonSizes): Reflect the fact that buttons with NSControlSizeLarge are 28px tall.
+        (WebCore::buttonMargins): Just match NSControlSizeRegular margins for now, and add a FIXME about updating them.
+        (WebCore::setUpButtonCell):
+        (WebCore::stepperSizes): NSControlSizeLarge matches NSControlSizeRegular at the moment.
+        (WebCore::stepperControlSizeForFont): Add a new font size breakpoint for using NSControlSizeLarge.
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::controlSizeForFont const):
+        (WebCore::RenderThemeMac::controlSizeForCell const):
+        (WebCore::RenderThemeMac::controlSizeForSystemFont const):
+        (WebCore::RenderThemeMac::popupButtonMargins const):
+        (WebCore::RenderThemeMac::popupButtonSizes const):
+        (WebCore::RenderThemeMac::popupButtonPadding const):
+
+        NSControlSizeLarge metrics for popup buttons cannot be determined yet.
+
+        (WebCore::RenderThemeMac::progressBarSizes const):
+        (WebCore::RenderThemeMac::progressBarMargins const):
+        (WebCore::RenderThemeMac::paintProgressBar):
+
+        NSControlSizeLarge matches NSControlSizeRegular at the moment.
+
+        (WebCore::menuListButtonSizes):
+        (WebCore::RenderThemeMac::popupMenuSize const):
+        (WebCore::RenderThemeMac::menuListSizes const):
+        (WebCore::RenderThemeMac::searchFieldSizes const):
+        (WebCore::RenderThemeMac::cancelButtonSizes const):
+        (WebCore::RenderThemeMac::resultsButtonSizes const):
+
+        Search field results and cancel buttons have the same size in NSControlSizeLarge as in NSControlSizeRegular.
+
 2020-02-21  Michael Catanzaro  <[email protected]>
 
         [WPE][GTK] googleapis.com is a public suffix, defeating isGoogle() check in UserAgentQuirks.cpp

Modified: trunk/Source/WebCore/PAL/ChangeLog (257149 => 257150)


--- trunk/Source/WebCore/PAL/ChangeLog	2020-02-21 18:52:24 UTC (rev 257149)
+++ trunk/Source/WebCore/PAL/ChangeLog	2020-02-21 19:03:29 UTC (rev 257150)
@@ -1,3 +1,15 @@
+2020-02-21  Wenson Hsieh  <[email protected]>
+
+        [macOS] Large form controls are rendered at the wrong NSControlSize
+        https://bugs.webkit.org/show_bug.cgi?id=208043
+        <rdar://problem/59659134>
+
+        Reviewed by Tim Horton.
+
+        Import NSAppearance_Private.h in this SPI header. See WebCore ChangeLog for more details.
+
+        * pal/spi/mac/NSAppearanceSPI.h:
+
 2020-02-20  Peng Liu  <[email protected]>
 
         [Media in GPU process] Synchronize the properties of video layers in the GPU process with the hosting layer in the web process

Modified: trunk/Source/WebCore/PAL/pal/spi/mac/NSAppearanceSPI.h (257149 => 257150)


--- trunk/Source/WebCore/PAL/pal/spi/mac/NSAppearanceSPI.h	2020-02-21 18:52:24 UTC (rev 257149)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/NSAppearanceSPI.h	2020-02-21 19:03:29 UTC (rev 257150)
@@ -25,6 +25,12 @@
 
 #if USE(APPKIT)
 
+#import <AppKit/AppKit.h>
+
+#if USE(APPLE_INTERNAL_SDK)
+#import <AppKit/NSAppearance_Private.h>
+#endif
+
 @interface NSAppearance ()
 
 - (void)_drawInRect:(NSRect)rect context:(CGContextRef)context options:(NSDictionary *)options;

Modified: trunk/Source/WebCore/platform/PopupMenuStyle.h (257149 => 257150)


--- trunk/Source/WebCore/platform/PopupMenuStyle.h	2020-02-21 18:52:24 UTC (rev 257149)
+++ trunk/Source/WebCore/platform/PopupMenuStyle.h	2020-02-21 19:03:29 UTC (rev 257150)
@@ -39,7 +39,10 @@
     enum PopupMenuSize {
         PopupMenuSizeNormal,
         PopupMenuSizeSmall,
-        PopupMenuSizeMini
+        PopupMenuSizeMini,
+#if HAVE(LARGE_CONTROL_SIZE)
+        PopupMenuSizeLarge,
+#endif
     };
 
     PopupMenuStyle(const Color& foreground, const Color& background, const FontCascade& font, bool visible, bool isDisplayNone, bool hasDefaultAppearance, Length textIndent, TextDirection textDirection, bool hasTextDirectionOverride, BackgroundColorType backgroundColorType = DefaultBackgroundColor, PopupMenuType menuType = SelectPopup, PopupMenuSize menuSize = PopupMenuSizeNormal)

Modified: trunk/Source/WebCore/platform/mac/ThemeMac.h (257149 => 257150)


--- trunk/Source/WebCore/platform/mac/ThemeMac.h	2020-02-21 18:52:24 UTC (rev 257149)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.h	2020-02-21 19:03:29 UTC (rev 257150)
@@ -33,6 +33,9 @@
 
 class ThemeMac final : public ThemeCocoa {
 public:
+#if HAVE(LARGE_CONTROL_SIZE)
+    static bool supportsLargeFormControls();
+#endif
     static NSView *ensuredView(ScrollView*, const ControlStates&, bool useUnparentedView = false);
     static void setFocusRingClipRect(const FloatRect&);
     static bool drawCellOrFocusRingWithViewIntoContext(NSCell *, GraphicsContext&, const FloatRect&, NSView *, bool drawButtonCell, bool drawFocusRing, bool useImageBuffer, float deviceScaleFactor);

Modified: trunk/Source/WebCore/platform/mac/ThemeMac.mm (257149 => 257150)


--- trunk/Source/WebCore/platform/mac/ThemeMac.mm	2020-02-21 18:52:24 UTC (rev 257149)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm	2020-02-21 19:03:29 UTC (rev 257150)
@@ -40,6 +40,7 @@
 #import "ScrollView.h"
 #import <Carbon/Carbon.h>
 #import <pal/spi/cocoa/NSButtonCellSPI.h>
+#import <pal/spi/mac/NSAppearanceSPI.h>
 #import <pal/spi/mac/NSGraphicsSPI.h>
 #import <wtf/BlockObjCExceptions.h>
 #import <wtf/NeverDestroyed.h>
@@ -119,6 +120,10 @@
 
 namespace WebCore {
 
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/ThemeMacAdditions.mm>
+#endif
+
 enum {
     topMargin,
     rightMargin,
@@ -137,6 +142,10 @@
 static NSControlSize controlSizeForFont(const FontCascade& font)
 {
     int fontSize = font.pixelSize();
+#if HAVE(LARGE_CONTROL_SIZE)
+    if (fontSize >= 21 && ThemeMac::supportsLargeFormControls())
+        return NSControlSizeLarge;
+#endif
     if (fontSize >= 16)
         return NSControlSizeRegular;
     if (fontSize >= 11)
@@ -144,7 +153,7 @@
     return NSControlSizeMini;
 }
 
-static LengthSize sizeFromNSControlSize(NSControlSize nsControlSize, const LengthSize& zoomedSize, float zoomFactor, const std::array<IntSize, 3>& sizes)
+static LengthSize sizeFromNSControlSize(NSControlSize nsControlSize, const LengthSize& zoomedSize, float zoomFactor, const std::array<IntSize, 4>& sizes)
 {
     IntSize controlSize = sizes[nsControlSize];
     if (zoomFactor != 1.0f)
@@ -157,13 +166,19 @@
     return result;
 }
 
-static LengthSize sizeFromFont(const FontCascade& font, const LengthSize& zoomedSize, float zoomFactor, const std::array<IntSize, 3>& sizes)
+static LengthSize sizeFromFont(const FontCascade& font, const LengthSize& zoomedSize, float zoomFactor, const std::array<IntSize, 4>& sizes)
 {
     return sizeFromNSControlSize(controlSizeForFont(font), zoomedSize, zoomFactor, sizes);
 }
 
-static ControlSize controlSizeFromPixelSize(const std::array<IntSize, 3>& sizes, const IntSize& minZoomedSize, float zoomFactor)
+static ControlSize controlSizeFromPixelSize(const std::array<IntSize, 4>& sizes, const IntSize& minZoomedSize, float zoomFactor)
 {
+#if HAVE(LARGE_CONTROL_SIZE)
+    if (ThemeMac::supportsLargeFormControls()
+        && minZoomedSize.width() >= static_cast<int>(sizes[NSControlSizeLarge].width() * zoomFactor)
+        && minZoomedSize.height() >= static_cast<int>(sizes[NSControlSizeLarge].height() * zoomFactor))
+        return NSControlSizeLarge;
+#endif
     if (minZoomedSize.width() >= static_cast<int>(sizes[NSControlSizeRegular].width() * zoomFactor)
         && minZoomedSize.height() >= static_cast<int>(sizes[NSControlSizeRegular].height() * zoomFactor))
         return NSControlSizeRegular;
@@ -173,7 +188,7 @@
     return NSControlSizeMini;
 }
 
-static void setControlSize(NSCell* cell, const std::array<IntSize, 3>& sizes, const IntSize& minZoomedSize, float zoomFactor)
+static void setControlSize(NSCell* cell, const std::array<IntSize, 4>& sizes, const IntSize& minZoomedSize, float zoomFactor)
 {
     ControlSize size = controlSizeFromPixelSize(sizes, minZoomedSize, zoomFactor);
     if (size != [cell controlSize]) // Only update if we have to, since AppKit does work even if the size is the same.
@@ -258,20 +273,21 @@
 
 // Checkboxes and radio buttons
 
-static const std::array<IntSize, 3>& checkboxSizes()
+static const std::array<IntSize, 4>& checkboxSizes()
 {
-    static const std::array<IntSize, 3> sizes = { { IntSize(14, 14), IntSize(12, 12), IntSize(10, 10) } };
+    static const std::array<IntSize, 4> sizes = { { IntSize(14, 14), IntSize(12, 12), IntSize(10, 10), IntSize(16, 16) } };
     return sizes;
 }
 
 static const int* checkboxMargins(NSControlSize controlSize)
 {
-    static const int margins[3][4] =
+    static const int margins[4][4] =
     {
         // top right bottom left
         { 2, 2, 2, 2 },
         { 2, 1, 2, 1 },
         { 0, 0, 1, 0 },
+        { 2, 2, 2, 2 },
     };
     return margins[controlSize];
 }
@@ -288,20 +304,31 @@
 
 // Radio Buttons
 
-static const std::array<IntSize, 3>& radioSizes()
+static const std::array<IntSize, 4>& radioSizes()
 {
-    static const std::array<IntSize, 3> sizes = { { IntSize(16, 16), IntSize(12, 12), IntSize(10, 10) } };
+    static std::array<IntSize, 4> sizes;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+#if HAVE(LARGE_CONTROL_SIZE)
+        if (ThemeMac::supportsLargeFormControls()) {
+            sizes = { { IntSize(14, 14), IntSize(12, 12), IntSize(10, 10), IntSize(16, 16) } };
+            return;
+        }
+#endif
+        sizes = { { IntSize(16, 16), IntSize(12, 12), IntSize(10, 10), IntSize(0, 0) } };
+    });
     return sizes;
 }
 
 static const int* radioMargins(NSControlSize controlSize)
 {
-    static const int margins[3][4] =
+    static const int margins[4][4] =
     {
         // top right bottom left
         { 1, 0, 1, 2 },
         { 1, 1, 2, 1 },
         { 0, 0, 1, 1 },
+        { 1, 0, 1, 2 },
     };
     return margins[controlSize];
 }
@@ -466,19 +493,23 @@
 // Buttons
 
 // Buttons really only constrain height. They respect width.
-static const std::array<IntSize, 3>& buttonSizes()
+static const std::array<IntSize, 4>& buttonSizes()
 {
-    static const std::array<IntSize, 3> sizes = { { IntSize(0, 21), IntSize(0, 18), IntSize(0, 15) } };
+    static const std::array<IntSize, 4> sizes = { { IntSize(0, 21), IntSize(0, 18), IntSize(0, 15), IntSize(0, 28) } };
     return sizes;
 }
 
 static const int* buttonMargins(NSControlSize controlSize)
 {
-    static const int margins[3][4] =
+    // FIXME: These values may need to be reevaluated. They appear to have been originally chosen
+    // to reflect the size of shadows around native form controls on macOS, but as of macOS 10.15,
+    // these margins extend well past the boundaries of a native button cell's shadows.
+    static const int margins[4][4] =
     {
         { 4, 6, 7, 6 },
         { 4, 5, 6, 5 },
         { 0, 1, 1, 1 },
+        { 4, 6, 7, 6 },
     };
     return margins[controlSize];
 }
@@ -498,7 +529,7 @@
 static void setUpButtonCell(NSButtonCell *cell, ControlPart part, const ControlStates& states, const IntSize& zoomedSize, float zoomFactor)
 {
     // Set the control size based off the rectangle we're painting into.
-    const std::array<IntSize, 3>& sizes = buttonSizes();
+    const std::array<IntSize, 4>& sizes = buttonSizes();
     switch (part) {
     case SquareButtonPart:
         [cell setBezelStyle:NSBezelStyleShadowlessSquare];
@@ -509,7 +540,12 @@
         break;
 #endif
     default:
-        NSBezelStyle style = (zoomedSize.height() > buttonSizes()[NSControlSizeRegular].height() * zoomFactor) ? NSBezelStyleShadowlessSquare : NSBezelStyleRounded;
+#if HAVE(LARGE_CONTROL_SIZE)
+        auto largestControlSize = ThemeMac::supportsLargeFormControls() ? NSControlSizeLarge : NSControlSizeRegular;
+#else
+        auto largestControlSize = NSControlSizeRegular;
+#endif
+        NSBezelStyle style = (zoomedSize.height() > buttonSizes()[largestControlSize].height() * zoomFactor) ? NSBezelStyleShadowlessSquare : NSBezelStyleRounded;
         [cell setBezelStyle:style];
         break;
     }
@@ -593,9 +629,9 @@
 
 // Stepper
 
-static const std::array<IntSize, 3>& stepperSizes()
+static const std::array<IntSize, 4>& stepperSizes()
 {
-    static const std::array<IntSize, 3> sizes = { { IntSize(19, 27), IntSize(15, 22), IntSize(13, 15) } };
+    static const std::array<IntSize, 4> sizes = { { IntSize(19, 27), IntSize(15, 22), IntSize(13, 15), IntSize(19, 27) } };
     return sizes;
 }
 
@@ -604,6 +640,10 @@
 static NSControlSize stepperControlSizeForFont(const FontCascade& font)
 {
     int fontSize = font.pixelSize();
+#if HAVE(LARGE_CONTROL_SIZE)
+    if (fontSize >= 23 && ThemeMac::supportsLargeFormControls())
+        return NSControlSizeLarge;
+#endif
     if (fontSize >= 18)
         return NSControlSizeRegular;
     if (fontSize >= 13)

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (257149 => 257150)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2020-02-21 18:52:24 UTC (rev 257149)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2020-02-21 19:03:29 UTC (rev 257150)
@@ -1030,6 +1030,10 @@
 NSControlSize RenderThemeMac::controlSizeForFont(const RenderStyle& style) const
 {
     int fontSize = style.computedFontPixelSize();
+#if HAVE(LARGE_CONTROL_SIZE)
+    if (fontSize >= 21 && ThemeMac::supportsLargeFormControls())
+        return NSControlSizeLarge;
+#endif
     if (fontSize >= 16)
         return NSControlSizeRegular;
     if (fontSize >= 11)
@@ -1039,6 +1043,13 @@
 
 NSControlSize RenderThemeMac::controlSizeForCell(NSCell*, const IntSize* sizes, const IntSize& minSize, float zoomLevel) const
 {
+#if HAVE(LARGE_CONTROL_SIZE)
+    if (ThemeMac::supportsLargeFormControls()
+        && minSize.width() >= static_cast<int>(sizes[NSControlSizeLarge].width() * zoomLevel)
+        && minSize.height() >= static_cast<int>(sizes[NSControlSizeLarge].height() * zoomLevel))
+        return NSControlSizeLarge;
+#endif
+
     if (minSize.width() >= static_cast<int>(sizes[NSControlSizeRegular].width() * zoomLevel)
         && minSize.height() >= static_cast<int>(sizes[NSControlSizeRegular].height() * zoomLevel))
         return NSControlSizeRegular;
@@ -1105,6 +1116,10 @@
 NSControlSize RenderThemeMac::controlSizeForSystemFont(const RenderStyle& style) const
 {
     int fontSize = style.computedFontPixelSize();
+#if HAVE(LARGE_CONTROL_SIZE)
+    if (fontSize >= [NSFont systemFontSizeForControlSize:NSControlSizeLarge] && ThemeMac::supportsLargeFormControls())
+        return NSControlSizeLarge;
+#endif
     if (fontSize >= [NSFont systemFontSizeForControlSize:NSControlSizeRegular])
         return NSControlSizeRegular;
     if (fontSize >= [NSFont systemFontSizeForControlSize:NSControlSizeSmall])
@@ -1218,11 +1233,12 @@
 
 const int* RenderThemeMac::popupButtonMargins() const
 {
-    static const int margins[3][4] =
+    static const int margins[4][4] =
     {
         { 0, 3, 1, 3 },
         { 0, 3, 2, 3 },
-        { 0, 1, 0, 1 }
+        { 0, 1, 0, 1 },
+        { 0, 3, 1, 3 },
     };
     return margins[[popupButton() controlSize]];
 }
@@ -1229,23 +1245,25 @@
 
 const IntSize* RenderThemeMac::popupButtonSizes() const
 {
-    static const IntSize sizes[3] = { IntSize(0, 21), IntSize(0, 18), IntSize(0, 15) };
+    static const IntSize sizes[4] = { IntSize(0, 21), IntSize(0, 18), IntSize(0, 15), IntSize(0, 24) };
     return sizes;
 }
 
 const int* RenderThemeMac::popupButtonPadding(NSControlSize size, bool isRTL) const
 {
-    static const int paddingLTR[3][4] =
+    static const int paddingLTR[4][4] =
     {
         { 2, 26, 3, 8 },
         { 2, 23, 3, 8 },
-        { 2, 22, 3, 10 }
+        { 2, 22, 3, 10 },
+        { 2, 26, 3, 8 },
     };
-    static const int paddingRTL[3][4] =
+    static const int paddingRTL[4][4] =
     {
         { 2, 8, 3, 26 },
         { 2, 8, 3, 23 },
-        { 2, 8, 3, 22 }
+        { 2, 8, 3, 22 },
+        { 2, 8, 3, 26 },
     };
     return isRTL ? paddingRTL[size] : paddingLTR[size];
 }
@@ -1388,17 +1406,18 @@
 
 const IntSize* RenderThemeMac::progressBarSizes() const
 {
-    static const IntSize sizes[3] = { IntSize(0, 20), IntSize(0, 12), IntSize(0, 12) };
+    static const IntSize sizes[4] = { IntSize(0, 20), IntSize(0, 12), IntSize(0, 12), IntSize(0, 20) };
     return sizes;
 }
 
 const int* RenderThemeMac::progressBarMargins(NSControlSize controlSize) const
 {
-    static const int margins[3][4] =
+    static const int margins[4][4] =
     {
         { 0, 0, 1, 0 },
         { 0, 0, 1, 0 },
         { 0, 0, 1, 0 },
+        { 0, 0, 1, 0 },
     };
     return margins[controlSize];
 }
@@ -1455,7 +1474,13 @@
     const auto& renderProgress = downcast<RenderProgress>(renderObject);
     HIThemeTrackDrawInfo trackInfo;
     trackInfo.version = 0;
-    if (controlSize == NSControlSizeRegular)
+
+    bool shouldUseLargeProgressBarIfPossible = controlSize == NSControlSizeRegular;
+#if HAVE(LARGE_CONTROL_SIZE)
+    if (ThemeMac::supportsLargeFormControls())
+        shouldUseLargeProgressBarIfPossible |= controlSize == NSControlSizeLarge;
+#endif
+    if (shouldUseLargeProgressBarIfPossible)
         trackInfo.kind = renderProgress.position() < 0 ? kThemeLargeIndeterminateBar : kThemeLargeProgressBar;
     else
         trackInfo.kind = renderProgress.position() < 0 ? kThemeMediumIndeterminateBar : kThemeMediumProgressBar;
@@ -1681,7 +1706,7 @@
 
 static const IntSize* menuListButtonSizes()
 {
-    static const IntSize sizes[3] = { IntSize(0, 21), IntSize(0, 18), IntSize(0, 15) };
+    static const IntSize sizes[4] = { IntSize(0, 21), IntSize(0, 18), IntSize(0, 15), IntSize(0, 24) };
     return sizes;
 }
 
@@ -1753,6 +1778,10 @@
         return PopupMenuStyle::PopupMenuSizeSmall;
     case NSControlSizeMini:
         return PopupMenuStyle::PopupMenuSizeMini;
+#if HAVE(LARGE_CONTROL_SIZE)
+    case NSControlSizeLarge:
+        return ThemeMac::supportsLargeFormControls() ? PopupMenuStyle::PopupMenuSizeLarge : PopupMenuStyle::PopupMenuSizeNormal;
+#endif
     default:
         return PopupMenuStyle::PopupMenuSizeNormal;
     }
@@ -1798,7 +1827,7 @@
 
 const IntSize* RenderThemeMac::menuListSizes() const
 {
-    static const IntSize sizes[3] = { IntSize(9, 0), IntSize(5, 0), IntSize(0, 0) };
+    static const IntSize sizes[4] = { IntSize(9, 0), IntSize(5, 0), IntSize(0, 0), IntSize(13, 0) };
     return sizes;
 }
 
@@ -1981,7 +2010,7 @@
 
 const IntSize* RenderThemeMac::searchFieldSizes() const
 {
-    static const IntSize sizes[3] = { IntSize(0, 22), IntSize(0, 19), IntSize(0, 17) };
+    static const IntSize sizes[4] = { IntSize(0, 22), IntSize(0, 19), IntSize(0, 17), IntSize(0, 22) };
     return sizes;
 }
 
@@ -2082,7 +2111,7 @@
 
 const IntSize* RenderThemeMac::cancelButtonSizes() const
 {
-    static const IntSize sizes[3] = { IntSize(22, 22), IntSize(19, 19), IntSize(15, 15) };
+    static const IntSize sizes[4] = { IntSize(22, 22), IntSize(19, 19), IntSize(15, 15), IntSize(22, 22) };
     return sizes;
 }
 
@@ -2097,7 +2126,7 @@
 const int resultsArrowWidth = 5;
 const IntSize* RenderThemeMac::resultsButtonSizes() const
 {
-    static const IntSize sizes[3] = { IntSize(19, 22), IntSize(17, 19), IntSize(17, 15) };
+    static const IntSize sizes[4] = { IntSize(19, 22), IntSize(17, 19), IntSize(17, 15), IntSize(19, 22) };
     return sizes;
 }
 

Modified: trunk/Source/WebKit/ChangeLog (257149 => 257150)


--- trunk/Source/WebKit/ChangeLog	2020-02-21 18:52:24 UTC (rev 257149)
+++ trunk/Source/WebKit/ChangeLog	2020-02-21 19:03:29 UTC (rev 257150)
@@ -1,3 +1,16 @@
+2020-02-21  Wenson Hsieh  <[email protected]>
+
+        [macOS] Large form controls are rendered at the wrong NSControlSize
+        https://bugs.webkit.org/show_bug.cgi?id=208043
+        <rdar://problem/59659134>
+
+        Reviewed by Tim Horton.
+
+        See WebCore ChangeLog for more details.
+
+        * UIProcess/mac/WebPopupMenuProxyMac.mm:
+        (WebKit::WebPopupMenuProxyMac::showPopupMenu):
+
 2020-02-21  Chris Dumez  <[email protected]>
 
         Remove WebPageProxy::machSendRightCallback as it is dead code

Modified: trunk/Source/WebKit/UIProcess/mac/WebPopupMenuProxyMac.mm (257149 => 257150)


--- trunk/Source/WebKit/UIProcess/mac/WebPopupMenuProxyMac.mm	2020-02-21 18:52:24 UTC (rev 257149)
+++ trunk/Source/WebKit/UIProcess/mac/WebPopupMenuProxyMac.mm	2020-02-21 19:03:29 UTC (rev 257150)
@@ -34,6 +34,7 @@
 #import "PlatformPopupMenuData.h"
 #import "StringUtilities.h"
 #import "WebPopupItem.h"
+#import <pal/spi/mac/NSCellSPI.h>
 #import <pal/system/mac/PopupMenu.h>
 #import <wtf/BlockObjCExceptions.h>
 #import <wtf/ProcessPrivilege.h>
@@ -161,6 +162,11 @@
     case WebCore::PopupMenuStyle::PopupMenuSizeMini:
         controlSize = NSControlSizeMini;
         break;
+#if HAVE(LARGE_CONTROL_SIZE)
+    case PopupMenuStyle::PopupMenuSizeLarge:
+        controlSize = NSControlSizeLarge;
+        break;
+#endif
     }
 
     Ref<WebPopupMenuProxyMac> protect(*this);

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (257149 => 257150)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2020-02-21 18:52:24 UTC (rev 257149)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2020-02-21 19:03:29 UTC (rev 257150)
@@ -1,3 +1,16 @@
+2020-02-21  Wenson Hsieh  <[email protected]>
+
+        [macOS] Large form controls are rendered at the wrong NSControlSize
+        https://bugs.webkit.org/show_bug.cgi?id=208043
+        <rdar://problem/59659134>
+
+        Reviewed by Tim Horton.
+
+        See WebCore ChangeLog for more details.
+
+        * WebCoreSupport/PopupMenuMac.mm:
+        (PopupMenuMac::show):
+
 2020-02-21  Daniel Bates  <[email protected]>
 
         [iOS][Legacy WebKit] Expose SPI for Page::revealCurrentSelection()

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/PopupMenuMac.mm (257149 => 257150)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/PopupMenuMac.mm	2020-02-21 18:52:24 UTC (rev 257149)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/PopupMenuMac.mm	2020-02-21 19:03:29 UTC (rev 257150)
@@ -33,6 +33,7 @@
 #import <WebCore/FrameView.h>
 #import <WebCore/Page.h>
 #import <WebCore/PopupMenuClient.h>
+#import <pal/spi/mac/NSCellSPI.h>
 #import <pal/system/mac/PopupMenu.h>
 #import <wtf/BlockObjCExceptions.h>
 
@@ -207,6 +208,11 @@
     case PopupMenuStyle::PopupMenuSizeMini:
         controlSize = NSControlSizeMini;
         break;
+#if HAVE(LARGE_CONTROL_SIZE)
+    case PopupMenuStyle::PopupMenuSizeLarge:
+        controlSize = NSControlSizeLarge;
+        break;
+#endif
     }
 
     PAL::popUpMenu(menu, location, roundf(NSWidth(r)), dummyView.get(), selectedIndex, toNSFont(font), controlSize, !m_client->menuStyle().hasDefaultAppearance());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to