Modified: trunk/Source/WebCore/ChangeLog (263308 => 263309)
--- trunk/Source/WebCore/ChangeLog 2020-06-20 01:22:52 UTC (rev 263308)
+++ trunk/Source/WebCore/ChangeLog 2020-06-20 02:26:14 UTC (rev 263309)
@@ -1,3 +1,23 @@
+2020-06-19 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [macOS] Move progress bar painting code off of Carbon API
+ https://bugs.webkit.org/show_bug.cgi?id=213405
+ <rdar://problem/63958537>
+
+ Reviewed by Tim Horton.
+
+ Adopts CoreUI constants and AppKit SPI (`-[NSAppearance _drawInRect:context:options:]`) when painting progress
+ elements. This is being done in light of recent changes around how `HIThemeDrawTrack` draws progress bars on
+ recent versions of macOS; it has been recommended to us that we move away from using Carbon, and instead use
+ AppKit.
+
+ * rendering/RenderThemeMac.mm:
+ (WebCore::RenderThemeMac::paintProgressBar):
+
+ The `NSControlSize` to `CUISize` mapping here looks counterintuitive, but matches our current behavior. This is
+ because `kThemeLargeProgressBar` and `kThemeLargeIndeterminateBar` both map to `kCUISizeRegular`, while
+ `kThemeMediumIndeterminateBar` and `kThemeMediumProgressBar` map to `kCUISizeSmall`.
+
2020-06-19 Clark Wang <clark_w...@apple.com>
Remove setVelocity() from PannerNode
Modified: trunk/Source/WebCore/PAL/ChangeLog (263308 => 263309)
--- trunk/Source/WebCore/PAL/ChangeLog 2020-06-20 01:22:52 UTC (rev 263308)
+++ trunk/Source/WebCore/PAL/ChangeLog 2020-06-20 02:26:14 UTC (rev 263309)
@@ -1,3 +1,15 @@
+2020-06-19 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [macOS] Move progress bar painting code off of Carbon API
+ https://bugs.webkit.org/show_bug.cgi?id=213405
+ <rdar://problem/63958537>
+
+ Reviewed by Tim Horton.
+
+ Add forward declarations for CoreUI SPI on non-internal SDKs.
+
+ * pal/spi/mac/CoreUISPI.h:
+
2020-06-19 Per Arne Vollan <pvol...@apple.com>
[macOS] Connections to the preference daemon are established before entering the sandbox
Modified: trunk/Source/WebCore/PAL/pal/spi/mac/CoreUISPI.h (263308 => 263309)
--- trunk/Source/WebCore/PAL/pal/spi/mac/CoreUISPI.h 2020-06-20 01:22:52 UTC (rev 263308)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/CoreUISPI.h 2020-06-20 02:26:14 UTC (rev 263309)
@@ -35,5 +35,21 @@
extern const CFStringRef kCUIIsFlippedKey;
extern const CFStringRef kCUIWidgetScrollBarTrackCorner;
+extern const CFStringRef kCUIWidgetProgressIndeterminateBar;
+extern const CFStringRef kCUIWidgetProgressBar;
+extern const CFStringRef kCUIUserInterfaceLayoutDirectionLeftToRight;
+extern const CFStringRef kCUIPresentationStateActiveKey;
+extern const CFStringRef kCUIPresentationStateInactive;
+extern const CFStringRef kCUIOrientHorizontal;
+extern const CFStringRef kCUISizeSmall;
+extern const CFStringRef kCUISizeRegular;
+extern const CFStringRef kCUIValueKey;
+extern const CFStringRef kCUISizeKey;
+extern const CFStringRef kCUIUserInterfaceLayoutDirectionKey;
+extern const CFStringRef kCUIScaleKey;
+extern const CFStringRef kCUIPresentationStateKey;
+extern const CFStringRef kCUIOrientationKey;
+extern const CFStringRef kCUIAnimationFrameKey;
+
#endif
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (263308 => 263309)
--- trunk/Source/WebCore/rendering/RenderThemeMac.mm 2020-06-20 01:22:52 UTC (rev 263308)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm 2020-06-20 02:26:14 UTC (rev 263309)
@@ -72,6 +72,8 @@
#import <math.h>
#import <pal/spi/cg/CoreGraphicsSPI.h>
#import <pal/spi/cocoa/NSColorSPI.h>
+#import <pal/spi/mac/CoreUISPI.h>
+#import <pal/spi/mac/NSAppearanceSPI.h>
#import <pal/spi/mac/NSCellSPI.h>
#import <pal/spi/mac/NSImageSPI.h>
#import <pal/spi/mac/NSSharingServicePickerSPI.h>
@@ -1384,40 +1386,42 @@
IntRect inflatedRect = progressBarRectForBounds(renderObject, rect);
NSControlSize controlSize = controlSizeForFont(renderObject.style());
-
const auto& renderProgress = downcast<RenderProgress>(renderObject);
- HIThemeTrackDrawInfo trackInfo;
- trackInfo.version = 0;
-
- 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;
-
float deviceScaleFactor = renderObject.document().deviceScaleFactor();
- trackInfo.bounds = IntRect(IntPoint(), inflatedRect.size());
- trackInfo.min = 0;
- trackInfo.max = std::numeric_limits<SInt32>::max();
- trackInfo.value = lround(renderProgress.position() * nextafter(trackInfo.max, 0));
- trackInfo.trackInfo.progress.phase = lround(renderProgress.animationProgress() * nextafter(progressAnimationNumFrames, 0) * deviceScaleFactor);
- trackInfo.attributes = kThemeTrackHorizontal;
- trackInfo.enableState = isActive(renderObject) ? kThemeTrackActive : kThemeTrackInactive;
- trackInfo.reserved = 0;
- trackInfo.filler1 = 0;
-
- std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::createCompatibleBuffer(inflatedRect.size(), deviceScaleFactor, ColorSpace::SRGB, paintInfo.context());
+ bool isIndeterminate = renderProgress.position() < 0;
+ auto animationFrame = lround(renderProgress.animationProgress() * nextafter(progressAnimationNumFrames, 0) * deviceScaleFactor);
+ auto imageBuffer = ImageBuffer::createCompatibleBuffer(inflatedRect.size(), deviceScaleFactor, ColorSpace::SRGB, paintInfo.context());
if (!imageBuffer)
return true;
ContextContainer cgContextContainer(imageBuffer->context());
CGContextRef cgContext = cgContextContainer.context();
- HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal);
+ auto coreUISizeForProgressBarSize = [](NSControlSize size) -> CFStringRef {
+ switch (size) {
+ case NSControlSizeMini:
+ case NSControlSizeSmall:
+ return kCUISizeSmall;
+ case NSControlSizeRegular:
+#if HAVE(LARGE_CONTROL_SIZE)
+ case NSControlSizeLarge:
+#endif
+ return kCUISizeRegular;
+ }
+ ASSERT_NOT_REACHED();
+ return nullptr;
+ };
+ [[NSAppearance currentAppearance] _drawInRect:NSMakeRect(0, 0, inflatedRect.width(), inflatedRect.height()) context:cgContext options:@{
+ (__bridge NSString *)kCUIWidgetKey: (__bridge NSString *)(isIndeterminate ? kCUIWidgetProgressIndeterminateBar : kCUIWidgetProgressBar),
+ (__bridge NSString *)kCUIValueKey: @(isIndeterminate ? 1 : std::min(nextafter(1.0, -1), renderProgress.position())),
+ (__bridge NSString *)kCUISizeKey: (__bridge NSString *)coreUISizeForProgressBarSize(controlSize),
+ (__bridge NSString *)kCUIUserInterfaceLayoutDirectionKey: (__bridge NSString *)kCUIUserInterfaceLayoutDirectionLeftToRight,
+ (__bridge NSString *)kCUIScaleKey: @(deviceScaleFactor),
+ (__bridge NSString *)kCUIPresentationStateKey: (__bridge NSString *)(isActive(renderObject) ? kCUIPresentationStateActiveKey : kCUIPresentationStateInactive),
+ (__bridge NSString *)kCUIOrientationKey: (__bridge NSString *)kCUIOrientHorizontal,
+ (__bridge NSString *)kCUIAnimationFrameKey: @(isIndeterminate ? animationFrame : 0)
+ }];
+
GraphicsContextStateSaver stateSaver(paintInfo.context());
if (!renderProgress.style().isLeftToRightDirection()) {