Upstream application accent color support
https://bugs.webkit.org/show_bug.cgi?id=213859
Reviewed by Wenson Hsieh.
Source/WebCore/PAL:
* pal/spi/mac/NSApplicationSPI.h:
Source/WebKit:
* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/Cocoa/PageClientImplCocoa.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
* UIProcess/mac/PageClientImplMac.h:
* UIProcess/mac/PageClientImplMac.mm:
(WebKit::PageClientImpl::accentColor):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_limitsNavigationsToAppBoundDomains):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::setAccentColor):
Plumb accent color to the Web Content process so that it is used when
deciding the colors of selection and form controls.
Source/WTF:
* wtf/PlatformHave.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@263819 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog
index 13ddb98..faca1e68 100644
--- a/Source/WTF/ChangeLog
+++ b/Source/WTF/ChangeLog
@@ -1,3 +1,12 @@
+2020-07-01 Tim Horton <timothy_horton@apple.com>
+
+ Upstream application accent color support
+ https://bugs.webkit.org/show_bug.cgi?id=213859
+
+ Reviewed by Wenson Hsieh.
+
+ * wtf/PlatformHave.h:
+
2020-07-01 Alexey Shvayka <shvaikalesh@gmail.com>
Use more efficient makeString() instead of StringBuilder
diff --git a/Source/WTF/wtf/PlatformHave.h b/Source/WTF/wtf/PlatformHave.h
index 48c0df3..3e4f20e 100644
--- a/Source/WTF/wtf/PlatformHave.h
+++ b/Source/WTF/wtf/PlatformHave.h
@@ -660,3 +660,7 @@
|| (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 110000))
#define HAVE_PTHREAD_JIT_PERMISSIONS_API 1
#endif
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600
+#define HAVE_APP_ACCENT_COLORS 1
+#endif
diff --git a/Source/WebCore/PAL/ChangeLog b/Source/WebCore/PAL/ChangeLog
index c3580e2..4c33e2a 100644
--- a/Source/WebCore/PAL/ChangeLog
+++ b/Source/WebCore/PAL/ChangeLog
@@ -1,3 +1,12 @@
+2020-07-01 Tim Horton <timothy_horton@apple.com>
+
+ Upstream application accent color support
+ https://bugs.webkit.org/show_bug.cgi?id=213859
+
+ Reviewed by Wenson Hsieh.
+
+ * pal/spi/mac/NSApplicationSPI.h:
+
2020-06-30 Per Arne Vollan <pvollan@apple.com>
[macOS] Connections to the preference daemon are established before entering the sandbox
diff --git a/Source/WebCore/PAL/pal/spi/mac/NSApplicationSPI.h b/Source/WebCore/PAL/pal/spi/mac/NSApplicationSPI.h
index cf1c1b4..262a19b 100644
--- a/Source/WebCore/PAL/pal/spi/mac/NSApplicationSPI.h
+++ b/Source/WebCore/PAL/pal/spi/mac/NSApplicationSPI.h
@@ -26,10 +26,15 @@
#if USE(APPKIT)
@interface NSApplication ()
+
- (void)speakString:(NSString *)string;
- (void)_setCurrentEvent:(NSEvent *)event;
+ (void)_accessibilityInitialize;
+ (void)_preventDockConnections;
+
+// Conditionally define this only for !USE_APPLE_INTERNAL_SDK when <rdar://problem/63864711> is fixed.
+@property (copy, setter=_setAccentColor:) NSColor *_accentColor;
+
@end
#endif // USE(APPKIT)
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index 688a24e..d4de840 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,29 @@
+2020-07-01 Tim Horton <timothy_horton@apple.com>
+
+ Upstream application accent color support
+ https://bugs.webkit.org/show_bug.cgi?id=213859
+
+ Reviewed by Wenson Hsieh.
+
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::encode const):
+ (WebKit::WebPageCreationParameters::decode):
+ * Shared/WebPageCreationParameters.h:
+ * UIProcess/Cocoa/PageClientImplCocoa.h:
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::creationParameters):
+ * UIProcess/mac/PageClientImplMac.h:
+ * UIProcess/mac/PageClientImplMac.mm:
+ (WebKit::PageClientImpl::accentColor):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::m_limitsNavigationsToAppBoundDomains):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::setAccentColor):
+ Plumb accent color to the Web Content process so that it is used when
+ deciding the colors of selection and form controls.
+
2020-07-01 Keith Miller <keith_miller@apple.com>
Add WebXR to WebKit.plist preferences, off by default
diff --git a/Source/WebKit/Shared/WebPageCreationParameters.cpp b/Source/WebKit/Shared/WebPageCreationParameters.cpp
index e18736f..ce2738e 100644
--- a/Source/WebKit/Shared/WebPageCreationParameters.cpp
+++ b/Source/WebKit/Shared/WebPageCreationParameters.cpp
@@ -113,8 +113,8 @@
encoder << smartInsertDeleteEnabled;
encoder << additionalSupportedImageTypes;
#endif
-#if ENABLE(TINT_COLOR_SUPPORT)
- encoder << tintColor;
+#if HAVE(APP_ACCENT_COLORS)
+ encoder << accentColor;
#endif
#if USE(WPE_RENDERER)
encoder << hostFileDescriptor;
@@ -359,8 +359,8 @@
return WTF::nullopt;
#endif
-#if ENABLE(TINT_COLOR_SUPPORT)
- if (!decoder.decode(parameters.tintColor))
+#if HAVE(APP_ACCENT_COLORS)
+ if (!decoder.decode(parameters.accentColor))
return WTF::nullopt;
#endif
diff --git a/Source/WebKit/Shared/WebPageCreationParameters.h b/Source/WebKit/Shared/WebPageCreationParameters.h
index 992baf4..bd4160a 100644
--- a/Source/WebKit/Shared/WebPageCreationParameters.h
+++ b/Source/WebKit/Shared/WebPageCreationParameters.h
@@ -174,8 +174,8 @@
bool smartInsertDeleteEnabled;
Vector<String> additionalSupportedImageTypes;
#endif
-#if ENABLE(TINT_COLOR_SUPPORT)
- WebCore::Color tintColor;
+#if HAVE(APP_ACCENT_COLORS)
+ WebCore::Color accentColor;
#endif
#if USE(WPE_RENDERER)
IPC::Attachment hostFileDescriptor;
diff --git a/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h b/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h
index 7f2c2fc..0f1c3dc 100644
--- a/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h
+++ b/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h
@@ -54,10 +54,6 @@
bool scrollingUpdatesDisabledForTesting() final;
-#if ENABLE(TINT_COLOR_SUPPORT)
- WebCore::Color tintColor() final;
-#endif
-
#if ENABLE(ATTACHMENT_ELEMENT)
void didInsertAttachment(API::Attachment&, const String& source) final;
void didRemoveAttachment(API::Attachment&) final;
diff --git a/Source/WebKit/UIProcess/PageClient.h b/Source/WebKit/UIProcess/PageClient.h
index 2e66628..392a9df 100644
--- a/Source/WebKit/UIProcess/PageClient.h
+++ b/Source/WebKit/UIProcess/PageClient.h
@@ -350,8 +350,8 @@
virtual void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&) = 0;
#endif
-#if ENABLE(TINT_COLOR_SUPPORT)
- virtual WebCore::Color tintColor() = 0;
+#if HAVE(APP_ACCENT_COLORS)
+ virtual WebCore::Color accentColor() = 0;
#endif
virtual bool effectiveAppearanceIsDark() const { return false; }
diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp
index 6b400dc..a990186 100644
--- a/Source/WebKit/UIProcess/WebPageProxy.cpp
+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp
@@ -7800,8 +7800,8 @@
parameters.smartInsertDeleteEnabled = m_isSmartInsertDeleteEnabled;
parameters.additionalSupportedImageTypes = m_configuration->additionalSupportedImageTypes();
#endif
-#if ENABLE(TINT_COLOR_SUPPORT)
- parameters.tintColor = pageClient().tintColor();
+#if HAVE(APP_ACCENT_COLORS)
+ parameters.accentColor = pageClient().accentColor();
#endif
parameters.shouldScaleViewToFitDocument = m_shouldScaleViewToFitDocument;
parameters.userInterfaceLayoutDirection = pageClient().userInterfaceLayoutDirection();
diff --git a/Source/WebKit/UIProcess/mac/PageClientImplMac.h b/Source/WebKit/UIProcess/mac/PageClientImplMac.h
index 53203c0..7a1c5b3 100644
--- a/Source/WebKit/UIProcess/mac/PageClientImplMac.h
+++ b/Source/WebKit/UIProcess/mac/PageClientImplMac.h
@@ -257,6 +257,10 @@
void takeFocus(WebCore::FocusDirection) override;
+#if HAVE(APP_ACCENT_COLORS)
+ WebCore::Color accentColor() override;
+#endif
+
NSView *m_view;
WeakPtr<WebViewImpl> m_impl;
#if USE(AUTOCORRECTION_PANEL)
diff --git a/Source/WebKit/UIProcess/mac/PageClientImplMac.mm b/Source/WebKit/UIProcess/mac/PageClientImplMac.mm
index 7b7e66c..5f4c68d 100644
--- a/Source/WebKit/UIProcess/mac/PageClientImplMac.mm
+++ b/Source/WebKit/UIProcess/mac/PageClientImplMac.mm
@@ -62,6 +62,7 @@
#import "_WKThumbnailView.h"
#import <WebCore/AlternativeTextUIController.h>
#import <WebCore/BitmapImage.h>
+#import <WebCore/ColorMac.h>
#import <WebCore/Cursor.h>
#import <WebCore/DictionaryLookup.h>
#import <WebCore/DragItem.h>
@@ -78,6 +79,7 @@
#import <WebCore/TextUndoInsertionMarkupMac.h>
#import <WebCore/ValidationBubble.h>
#import <WebCore/WebCoreCALayerExtras.h>
+#import <pal/spi/mac/NSApplicationSPI.h>
#import <wtf/ProcessPrivilege.h>
#import <wtf/RetainPtr.h>
#import <wtf/text/CString.h>
@@ -936,6 +938,13 @@
m_impl->requestDOMPasteAccess(elementRect, originIdentifier, WTFMove(completion));
}
+#if HAVE(APP_ACCENT_COLORS)
+WebCore::Color PageClientImpl::accentColor()
+{
+ return WebCore::colorFromNSColor([NSApp _accentColor]);
+}
+#endif
+
} // namespace WebKit
#endif // PLATFORM(MAC)
diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp
index 488006f..7d90118 100644
--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp
+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp
@@ -726,8 +726,8 @@
WebCore::setAdditionalSupportedImageTypes(parameters.additionalSupportedImageTypes);
#endif
-#if ENABLE(TINT_COLOR_SUPPORT)
- setTintColor(parameters.tintColor);
+#if HAVE(APP_ACCENT_COLORS)
+ setAccentColor(parameters.accentColor);
#endif
m_needsFontAttributes = parameters.needsFontAttributes;
diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h
index 9204186..2004649 100644
--- a/Source/WebKit/WebProcess/WebPage/WebPage.h
+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h
@@ -1572,8 +1572,8 @@
void drawPagesToPDFFromPDFDocument(CGContextRef, PDFDocument *, const PrintInfo&, uint32_t first, uint32_t count);
#endif
-#if ENABLE(TINT_COLOR_SUPPORT)
- void setTintColor(WebCore::Color);
+#if HAVE(APP_ACCENT_COLORS)
+ void setAccentColor(WebCore::Color);
#endif
void setMainFrameIsScrollable(bool);
diff --git a/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm b/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
index b6a1629..650fc2f 100644
--- a/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
+++ b/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
@@ -57,6 +57,7 @@
#import <QuartzCore/QuartzCore.h>
#import <WebCore/AXObjectCache.h>
#import <WebCore/BackForwardController.h>
+#import <WebCore/ColorMac.h>
#import <WebCore/DataDetection.h>
#import <WebCore/DictionaryLookup.h>
#import <WebCore/Editing.h>
@@ -91,6 +92,7 @@
#import <WebCore/VisibleUnits.h>
#import <WebCore/WindowsKeyboardCodes.h>
#import <pal/spi/cocoa/NSAccessibilitySPI.h>
+#import <pal/spi/mac/NSApplicationSPI.h>
#import <wtf/SetForScope.h>
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
@@ -1046,6 +1048,15 @@
#endif
}
+#if HAVE(APP_ACCENT_COLORS)
+
+void WebPage::setAccentColor(WebCore::Color color)
+{
+ [NSApp _setAccentColor:color.isValid() ? WebCore::nsColor(color) : nil];
+}
+
+#endif
+
} // namespace WebKit
#endif // PLATFORM(MAC)