Title: [258308] trunk/Source/WebCore
Revision
258308
Author
wenson_hs...@apple.com
Date
2020-03-11 19:48:36 -0700 (Wed, 11 Mar 2020)

Log Message

Large single select elements are incorrectly sized
https://bugs.webkit.org/show_bug.cgi?id=208966

Reviewed by Tim Horton.

Adjusts several size and margin values for menu lists (i.e. the default appearance of non-multiple select
elements) to reflect recent changes in macOS. Additionally, adds a workaround for <rdar://problem/60350699>,
which causes text inside many form controls (including select buttons) to be incorrectly sized.

* platform/mac/ThemeMac.h:
* platform/mac/ThemeMac.mm:
(WebCore::ThemeMac::systemFontSizeFor):
(WebCore::ThemeMac::controlFont const):
* rendering/RenderThemeMac.mm:

Replace calls to +[NSFont systemFontSizeForControlSize:] with `ThemeMac::systemFontSizeFor(NSControlSize size)`
in order to work around <rdar://problem/60350699>.

(WebCore::RenderThemeMac::updateCachedSystemFontDescription const):
(WebCore::RenderThemeMac::setFontFromControlSize const):
(WebCore::RenderThemeMac::controlSizeForSystemFont const):
(WebCore::RenderThemeMac::popupButtonMargins const):
(WebCore::menuListButtonSizes):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (258307 => 258308)


--- trunk/Source/WebCore/ChangeLog	2020-03-12 01:50:54 UTC (rev 258307)
+++ trunk/Source/WebCore/ChangeLog	2020-03-12 02:48:36 UTC (rev 258308)
@@ -1,3 +1,29 @@
+2020-03-11  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Large single select elements are incorrectly sized
+        https://bugs.webkit.org/show_bug.cgi?id=208966
+
+        Reviewed by Tim Horton.
+
+        Adjusts several size and margin values for menu lists (i.e. the default appearance of non-multiple select
+        elements) to reflect recent changes in macOS. Additionally, adds a workaround for <rdar://problem/60350699>,
+        which causes text inside many form controls (including select buttons) to be incorrectly sized.
+
+        * platform/mac/ThemeMac.h:
+        * platform/mac/ThemeMac.mm:
+        (WebCore::ThemeMac::systemFontSizeFor):
+        (WebCore::ThemeMac::controlFont const):
+        * rendering/RenderThemeMac.mm:
+
+        Replace calls to +[NSFont systemFontSizeForControlSize:] with `ThemeMac::systemFontSizeFor(NSControlSize size)`
+        in order to work around <rdar://problem/60350699>.
+
+        (WebCore::RenderThemeMac::updateCachedSystemFontDescription const):
+        (WebCore::RenderThemeMac::setFontFromControlSize const):
+        (WebCore::RenderThemeMac::controlSizeForSystemFont const):
+        (WebCore::RenderThemeMac::popupButtonMargins const):
+        (WebCore::menuListButtonSizes):
+
 2020-03-11  Canhai Chen  <canhai_c...@apple.com>
 
         AX: accessibilityReplaceRange:withText: doesn't post an AXValueChanged notification like when typing with kb

Modified: trunk/Source/WebCore/platform/mac/ThemeMac.h (258307 => 258308)


--- trunk/Source/WebCore/platform/mac/ThemeMac.h	2020-03-12 01:50:54 UTC (rev 258307)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.h	2020-03-12 02:48:36 UTC (rev 258308)
@@ -36,6 +36,8 @@
 #if HAVE(LARGE_CONTROL_SIZE)
     static bool supportsLargeFormControls();
 #endif
+    static double systemFontSizeFor(NSControlSize);
+
     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 (258307 => 258308)


--- trunk/Source/WebCore/platform/mac/ThemeMac.mm	2020-03-12 01:50:54 UTC (rev 258307)
+++ trunk/Source/WebCore/platform/mac/ThemeMac.mm	2020-03-12 02:48:36 UTC (rev 258308)
@@ -803,6 +803,19 @@
     return Theme::baselinePositionAdjustment(part);
 }
 
+double ThemeMac::systemFontSizeFor(NSControlSize size)
+{
+#if HAVE(LARGE_CONTROL_SIZE)
+    if (size == NSControlSizeLarge) {
+        // This is a workaround for <rdar://problem/60350699>. Once this is fixed,
+        // we should remove ThemeMac::systemFontSizeFor as well as this hard-coded
+        // value.
+        return 15;
+    }
+#endif
+    return [NSFont systemFontSizeForControlSize:size];
+}
+
 Optional<FontCascadeDescription> ThemeMac::controlFont(ControlPart part, const FontCascade& font, float zoomFactor) const
 {
     switch (part) {
@@ -810,7 +823,7 @@
         FontCascadeDescription fontDescription;
         fontDescription.setIsAbsoluteSize(true);
 
-        NSFont* nsFont = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:controlSizeForFont(font)]];
+        NSFont* nsFont = [NSFont systemFontOfSize:ThemeMac::systemFontSizeFor(controlSizeForFont(font))];
         fontDescription.setOneFamily(AtomString("-apple-system", AtomString::ConstructFromLiteral));
         fontDescription.setComputedSize([nsFont pointSize] * zoomFactor);
         fontDescription.setSpecifiedSize([nsFont pointSize] * zoomFactor);

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (258307 => 258308)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2020-03-12 01:50:54 UTC (rev 258307)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2020-03-12 02:48:36 UTC (rev 258308)
@@ -553,13 +553,13 @@
             fontName = AtomString("-apple-status-bar", AtomString::ConstructFromLiteral);
             break;
         case CSSValueWebkitMiniControl:
-            font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSControlSizeMini]];
+            font = [NSFont systemFontOfSize:ThemeMac::systemFontSizeFor(NSControlSizeMini)];
             break;
         case CSSValueWebkitSmallControl:
-            font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSControlSizeSmall]];
+            font = [NSFont systemFontOfSize:ThemeMac::systemFontSizeFor(NSControlSizeSmall)];
             break;
         case CSSValueWebkitControl:
-            font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSControlSizeRegular]];
+            font = [NSFont systemFontOfSize:ThemeMac::systemFontSizeFor(NSControlSizeRegular)];
             break;
         default:
             font = [NSFont systemFontOfSize:[NSFont systemFontSize]];
@@ -1101,7 +1101,7 @@
     FontCascadeDescription fontDescription;
     fontDescription.setIsAbsoluteSize(true);
 
-    NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:controlSize]];
+    NSFont* font = [NSFont systemFontOfSize:ThemeMac::systemFontSizeFor(controlSize)];
     fontDescription.setOneFamily(AtomString("-apple-system", AtomString::ConstructFromLiteral));
     fontDescription.setComputedSize([font pointSize] * style.effectiveZoom());
     fontDescription.setSpecifiedSize([font pointSize] * style.effectiveZoom());
@@ -1117,12 +1117,12 @@
 {
     int fontSize = style.computedFontPixelSize();
 #if HAVE(LARGE_CONTROL_SIZE)
-    if (fontSize >= [NSFont systemFontSizeForControlSize:NSControlSizeLarge] && ThemeMac::supportsLargeFormControls())
+    if (fontSize >= ThemeMac::systemFontSizeFor(NSControlSizeLarge) && ThemeMac::supportsLargeFormControls())
         return NSControlSizeLarge;
 #endif
-    if (fontSize >= [NSFont systemFontSizeForControlSize:NSControlSizeRegular])
+    if (fontSize >= ThemeMac::systemFontSizeFor(NSControlSizeRegular))
         return NSControlSizeRegular;
-    if (fontSize >= [NSFont systemFontSizeForControlSize:NSControlSizeSmall])
+    if (fontSize >= ThemeMac::systemFontSizeFor(NSControlSizeSmall))
         return NSControlSizeSmall;
     return NSControlSizeMini;
 }
@@ -1238,7 +1238,7 @@
         { 0, 3, 1, 3 },
         { 0, 3, 2, 3 },
         { 0, 1, 0, 1 },
-        { 0, 3, 1, 3 },
+        { 0, 6, 2, 6 },
     };
     return margins[[popupButton() controlSize]];
 }
@@ -1706,7 +1706,7 @@
 
 static const IntSize* menuListButtonSizes()
 {
-    static const IntSize sizes[4] = { IntSize(0, 21), IntSize(0, 18), IntSize(0, 15), IntSize(0, 24) };
+    static const IntSize sizes[4] = { IntSize(0, 21), IntSize(0, 18), IntSize(0, 15), IntSize(0, 28) };
     return sizes;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to