WebKit Bugzilla
Attachment 360276 Details for
Bug 193882
: Make it easier for non-Apple ports to enable dark mode CSS support
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193882-20190127003642.patch (text/plain), 18.47 KB, created by
Timothy Hatcher
on 2019-01-27 00:36:43 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Timothy Hatcher
Created:
2019-01-27 00:36:43 PST
Size:
18.47 KB
patch
obsolete
>Subversion Revision: 240257 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 4f8198260402c9b25ae26204c51775067d13d071..1ed475b5f5f81477220f856aa07a897a90ab2352 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,25 @@ >+2019-01-27 Timothy Hatcher <timothy@apple.com> >+ >+ Make it easier for non-Apple ports to enable dark mode CSS support. >+ https://bugs.webkit.org/show_bug.cgi?id=193882 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * page/FrameView.cpp: >+ (WebCore::FrameView::updateBackgroundRecursively): Limit use of system >+ background color to the Mac platform. >+ * rendering/RenderTheme.cpp: >+ (WebCore::RenderTheme::purgeCaches): Purge m_darkColorCache. >+ (WebCore::RenderTheme::platformColorsDidChange): Reset m_darkColorCache. >+ (WebCore::RenderTheme::colorCache const): Added m_darkColorCache. >+ * rendering/RenderTheme.h: >+ (WebCore::RenderTheme::colorCache const): Deleted. >+ * rendering/RenderThemeMac.h: >+ * rendering/RenderThemeMac.mm: >+ (WebCore::RenderThemeMac::purgeCaches): Removed m_darkColorCache. >+ (WebCore::RenderThemeMac::platformColorsDidChange): Deleted. >+ (WebCore::RenderThemeMac::colorCache const): Deleted. >+ > 2019-01-22 David Kilzer <ddkilzer@apple.com> > > Leak of NSMutableArray (128 bytes) in com.apple.WebKit.WebContent running WebKit layout tests >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index fdfa234e85ee9a26a6dc87473d0e08359405ee36..92b456de4b7cdb32d6a4a7015118b87ed39f4fdd 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,30 @@ >+2019-01-26 Timothy Hatcher <timothy@apple.com> >+ >+ Make it easier for non-Apple ports to enable dark mode CSS support. >+ https://bugs.webkit.org/show_bug.cgi?id=193882 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Make modern WebKit code for dark mode usable by other ports, to match >+ the WebCore parts that have been cross-platform all along. >+ >+ * Shared/WebPageCreationParameters.cpp: >+ (WebKit::WebPageCreationParameters::encode const): >+ (WebKit::WebPageCreationParameters::decode): >+ * Shared/WebPageCreationParameters.h: >+ * UIProcess/PageClient.h: >+ (WebKit::PageClient::effectiveAppearanceIsDark const): >+ * UIProcess/WebPageProxy.cpp: >+ (WebKit::WebPageProxy::creationParameters): >+ (WebKit::WebPageProxy::useDarkAppearance const): >+ (WebKit::WebPageProxy::effectiveAppearanceDidChange): >+ * UIProcess/WebPageProxy.h: >+ * WebProcess/WebPage/WebPage.cpp: >+ (WebKit::m_shouldAttachDrawingAreaOnPageTransition): >+ (WebKit::WebPage::setUseDarkAppearance): >+ * WebProcess/WebPage/WebPage.h: >+ * WebProcess/WebPage/WebPage.messages.in: >+ > 2019-01-22 Oriol Brufau <obrufau@igalia.com> > > [css-logical] Implement flow-relative margin, padding and border shorthands >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index 7faf7328428f26f0fada3933dbe71da62f6ec3c3..b6d6a31458267e0ced9f337319071d96a9e6c9f1 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,14 @@ >+2019-01-26 Timothy Hatcher <timothy@apple.com> >+ >+ Make it easier for non-Apple ports to enable dark mode CSS support. >+ https://bugs.webkit.org/show_bug.cgi?id=193882 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebView/WebView.mm: >+ (-[WebView _commonInitializationWithFrameName:groupName:]): Fix some defines. >+ (-[WebView _effectiveAppearanceIsDark]): Ditto. >+ > 2019-01-22 Oriol Brufau <obrufau@igalia.com> > > [css-logical] Implement flow-relative margin, padding and border shorthands >diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp >index cc931146fab0eee0c2b330791d710677e74b6893..66bad3a53bb1c3cbcdc067b022a98378c9c9c695 100644 >--- a/Source/WebCore/page/FrameView.cpp >+++ b/Source/WebCore/page/FrameView.cpp >@@ -3012,7 +3012,7 @@ void FrameView::setBaseBackgroundColor(const Color& backgroundColor) > > void FrameView::updateBackgroundRecursively(bool transparent) > { >-#if ENABLE(DARK_MODE_CSS) >+#if ENABLE(DARK_MODE_CSS) && PLATFORM(MAC) > Color backgroundColor = transparent ? Color::transparent : RenderTheme::singleton().systemColor(CSSValueAppleSystemControlBackground, styleColorOptions()); > #else > Color backgroundColor = transparent ? Color::transparent : Color::white; >diff --git a/Source/WebCore/rendering/RenderTheme.cpp b/Source/WebCore/rendering/RenderTheme.cpp >index 76c9c5c78d56d3e8d97d421f4dfaa4ab1bd9ecc0..a07b7410302d7f00864501036fa1050bbab2eb6d 100644 >--- a/Source/WebCore/rendering/RenderTheme.cpp >+++ b/Source/WebCore/rendering/RenderTheme.cpp >@@ -1216,15 +1216,24 @@ void RenderTheme::adjustSearchFieldResultsButtonStyle(StyleResolver&, RenderStyl > void RenderTheme::purgeCaches() > { > m_colorCache = ColorCache(); >+ m_darkColorCache = ColorCache(); > } > > void RenderTheme::platformColorsDidChange() > { > m_colorCache = ColorCache(); >+ m_darkColorCache = ColorCache(); > > Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment(); > } > >+auto RenderTheme::colorCache(OptionSet<StyleColor::Options> options) const -> ColorCache& >+{ >+ if (options.contains(StyleColor::Options::UseDarkAppearance)) >+ return m_darkColorCache; >+ return m_colorCache; >+} >+ > FontCascadeDescription& RenderTheme::cachedSystemFontDescription(CSSValueID systemFontID) const > { > static NeverDestroyed<FontCascadeDescription> caption; >diff --git a/Source/WebCore/rendering/RenderTheme.h b/Source/WebCore/rendering/RenderTheme.h >index a6292a437c9f9352dde0b6b25bca8175896a909f..471a9a3a4b53caf929464b8664075a10c19f20d6 100644 >--- a/Source/WebCore/rendering/RenderTheme.h >+++ b/Source/WebCore/rendering/RenderTheme.h >@@ -438,10 +438,11 @@ protected: > Color inactiveTextSearchHighlightColor; > }; > >- virtual ColorCache& colorCache(OptionSet<StyleColor::Options>) const { return m_colorCache; } >+ virtual ColorCache& colorCache(OptionSet<StyleColor::Options>) const; > > private: > mutable ColorCache m_colorCache; >+ mutable ColorCache m_darkColorCache; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/rendering/RenderThemeMac.h b/Source/WebCore/rendering/RenderThemeMac.h >index b74344c57c443b17a4525559e3f5b1cf40a83593..5234fde41cb9b07bee19016484558bc6a445de76 100644 >--- a/Source/WebCore/rendering/RenderThemeMac.h >+++ b/Source/WebCore/rendering/RenderThemeMac.h >@@ -256,8 +256,6 @@ private: > bool m_isSliderThumbHorizontalPressed { false }; > bool m_isSliderThumbVerticalPressed { false }; > >- mutable ColorCache m_darkColorCache; >- > RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver; > > String m_legacyMediaControlsScript; >diff --git a/Source/WebCore/rendering/RenderThemeMac.mm b/Source/WebCore/rendering/RenderThemeMac.mm >index afee9d016910237c2a96c9e11a1fcb0ff54d9e22..ec33906a226c3c51029b070c401374e7a735ebd0 100644 >--- a/Source/WebCore/rendering/RenderThemeMac.mm >+++ b/Source/WebCore/rendering/RenderThemeMac.mm >@@ -335,7 +335,6 @@ void RenderThemeMac::purgeCaches() > m_mediaControlsScript.clearImplIfNotShared(); > m_legacyMediaControlsStyleSheet.clearImplIfNotShared(); > m_mediaControlsStyleSheet.clearImplIfNotShared(); >- m_darkColorCache = ColorCache(); > > RenderTheme::purgeCaches(); > } >@@ -605,21 +604,6 @@ static RGBA32 menuBackgroundColor() > return makeRGBA(pixel[0], pixel[1], pixel[2], pixel[3]); > } > >-void RenderThemeMac::platformColorsDidChange() >-{ >- m_darkColorCache = ColorCache(); >- >- RenderTheme::platformColorsDidChange(); >-} >- >-auto RenderThemeMac::colorCache(OptionSet<StyleColor::Options> options) const -> ColorCache& >-{ >- LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance)); >- if (localAppearance.usingDarkAppearance()) >- return m_darkColorCache; >- return RenderTheme::colorCache(options); >-} >- > Color RenderThemeMac::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::Options> options) const > { > const bool useSystemAppearance = options.contains(StyleColor::Options::UseSystemAppearance); >diff --git a/Source/WebKit/Shared/WebPageCreationParameters.cpp b/Source/WebKit/Shared/WebPageCreationParameters.cpp >index 6d07c03ad8c927e5453c5fda9596709a77261e2b..af75d99771dea4f19f62030d933d8fac6d5dbb38 100644 >--- a/Source/WebKit/Shared/WebPageCreationParameters.cpp >+++ b/Source/WebKit/Shared/WebPageCreationParameters.cpp >@@ -74,11 +74,11 @@ void WebPageCreationParameters::encode(IPC::Encoder& encoder) const > encoder << mimeTypesWithCustomContentProviders; > encoder << controlledByAutomation; > encoder << isProcessSwap; >+ encoder << useDarkAppearance; > > #if PLATFORM(MAC) > encoder << colorSpace; > encoder << useSystemAppearance; >- encoder << useDarkAppearance; > #endif > #if PLATFORM(IOS_FAMILY) > encoder << screenSize; >@@ -229,14 +229,14 @@ Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decod > return WTF::nullopt; > if (!decoder.decode(parameters.isProcessSwap)) > return WTF::nullopt; >+ if (!decoder.decode(parameters.useDarkAppearance)) >+ return WTF::nullopt; > > #if PLATFORM(MAC) > if (!decoder.decode(parameters.colorSpace)) > return WTF::nullopt; > if (!decoder.decode(parameters.useSystemAppearance)) > return WTF::nullopt; >- if (!decoder.decode(parameters.useDarkAppearance)) >- return WTF::nullopt; > #endif > > #if PLATFORM(IOS_FAMILY) >diff --git a/Source/WebKit/Shared/WebPageCreationParameters.h b/Source/WebKit/Shared/WebPageCreationParameters.h >index b382ceedd449a8d9a0f8694735f26c0595ddecd8..fb327e40820dba7223bd02013d2c126273374ece 100644 >--- a/Source/WebKit/Shared/WebPageCreationParameters.h >+++ b/Source/WebKit/Shared/WebPageCreationParameters.h >@@ -131,10 +131,11 @@ struct WebPageCreationParameters { > bool controlledByAutomation; > bool isProcessSwap { false }; > >+ bool useDarkAppearance { false }; >+ > #if PLATFORM(MAC) > ColorSpaceData colorSpace; > bool useSystemAppearance; >- bool useDarkAppearance; > #endif > #if PLATFORM(IOS_FAMILY) > WebCore::FloatSize screenSize; >diff --git a/Source/WebKit/UIProcess/PageClient.h b/Source/WebKit/UIProcess/PageClient.h >index 0795cd8daf4a903d6e0c02b13897a58766b6c6ca..206c84b28a779f56d5f7d41087e31e21eaf47511 100644 >--- a/Source/WebKit/UIProcess/PageClient.h >+++ b/Source/WebKit/UIProcess/PageClient.h >@@ -311,6 +311,8 @@ public: > virtual void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&) = 0; > #endif > >+ virtual bool effectiveAppearanceIsDark() const { return false; } >+ > virtual void enterAcceleratedCompositingMode(const LayerTreeContext&) = 0; > virtual void exitAcceleratedCompositingMode() = 0; > virtual void updateAcceleratedCompositingMode(const LayerTreeContext&) = 0; >@@ -337,8 +339,6 @@ public: > virtual NSWindow *platformWindow() = 0; > virtual void setShouldSuppressFirstResponderChanges(bool) = 0; > >- virtual bool effectiveAppearanceIsDark() const = 0; >- > #if WK_API_ENABLED > virtual NSView *inspectorAttachmentView() = 0; > virtual _WKRemoteObjectRegistry *remoteObjectRegistry() = 0; >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index e74f38dc59b400d4026e2cad3c659e0525b43c9a..6291634e31ebfe89c3e84b8a4be88790381f765a 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -6777,10 +6777,10 @@ WebPageCreationParameters WebPageProxy::creationParameters(WebProcessProxy& proc > parameters.backgroundExtendsBeyondPage = m_backgroundExtendsBeyondPage; > parameters.layerHostingMode = m_layerHostingMode; > parameters.controlledByAutomation = m_controlledByAutomation; >+ parameters.useDarkAppearance = useDarkAppearance(); > #if PLATFORM(MAC) > parameters.colorSpace = pageClient().colorSpace(); > parameters.useSystemAppearance = m_useSystemAppearance; >- parameters.useDarkAppearance = useDarkAppearance(); > #endif > #if PLATFORM(IOS_FAMILY) > parameters.screenSize = screenSize(); >@@ -7393,11 +7393,6 @@ void WebPageProxy::handleAlternativeTextUIResult(const String& result) > m_process->send(Messages::WebPage::HandleAlternativeTextUIResult(result), m_pageID); > } > >-bool WebPageProxy::useDarkAppearance() const >-{ >- return pageClient().effectiveAppearanceIsDark(); >-} >- > #if USE(DICTATION_ALTERNATIVES) > void WebPageProxy::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext) > { >@@ -7904,14 +7899,6 @@ void WebPageProxy::setUseSystemAppearance(bool useSystemAppearance) > m_process->send(Messages::WebPage::SetUseSystemAppearance(useSystemAppearance), m_pageID); > } > >-void WebPageProxy::effectiveAppearanceDidChange() >-{ >- if (!isValid()) >- return; >- >- m_process->send(Messages::WebPage::SetUseDarkAppearance(useDarkAppearance()), m_pageID); >-} >- > void WebPageProxy::setHeaderBannerHeightForTesting(int height) > { > m_process->send(Messages::WebPage::SetHeaderBannerHeightForTesting(height), m_pageID); >@@ -8261,6 +8248,19 @@ void WebPageProxy::requestStorageAccess(String&& subFrameHost, String&& topFrame > } > #endif > >+bool WebPageProxy::useDarkAppearance() const >+{ >+ return pageClient().effectiveAppearanceIsDark(); >+} >+ >+void WebPageProxy::effectiveAppearanceDidChange() >+{ >+ if (!isValid()) >+ return; >+ >+ m_process->send(Messages::WebPage::SetUseDarkAppearance(useDarkAppearance()), m_pageID); >+} >+ > #if PLATFORM(COCOA) > void WebPageProxy::touchBarMenuDataChanged(const TouchBarMenuData& touchBarMenuData) > { >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index ac5600f62acc6a36ed30e02a9fd724301be0bf4c..cbfffac4c898bee953f6f98292874fa4448b0740 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -896,9 +896,10 @@ public: > #if PLATFORM(MAC) > void setUseSystemAppearance(bool); > bool useSystemAppearance() const { return m_useSystemAppearance; } >+#endif >+ > void effectiveAppearanceDidChange(); > bool useDarkAppearance() const; >-#endif > > #if PLATFORM(COCOA) > // Called by the web process through a message. >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >index 5e2d521901e9c49a2b844e3c467958c917864c38..9f9d37483d5860ba7ef66c7243df7104c04d8b64 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -524,10 +524,13 @@ WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters) > setPageLength(parameters.pageLength); > setGapBetweenPages(parameters.gapBetweenPages); > setPaginationLineGridEnabled(parameters.paginationLineGridEnabled); >+ >+ setUseDarkAppearance(parameters.useDarkAppearance); >+ > #if PLATFORM(MAC) > setUseSystemAppearance(parameters.useSystemAppearance); >- setUseDarkAppearance(parameters.useDarkAppearance); > #endif >+ > // If the page is created off-screen, its visibilityState should be prerender. > m_page->setActivityState(m_activityState); > if (!isVisible()) >@@ -4501,12 +4504,13 @@ void WebPage::setUseSystemAppearance(bool useSystemAppearance) > { > corePage()->setUseSystemAppearance(useSystemAppearance); > } >- >+ >+#endif >+ > void WebPage::setUseDarkAppearance(bool useDarkAppearance) > { > corePage()->setUseDarkAppearance(useDarkAppearance); > } >-#endif > > void WebPage::beginPrinting(uint64_t frameID, const PrintInfo& printInfo) > { >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index d4d21d3f33f0747fd3676d76948662d10a7c95f2..3563f79e8e889d951f2777016237d4cacda5d741 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -538,9 +538,10 @@ public: > void setBottomOverhangImage(WebImage*); > > void setUseSystemAppearance(bool); >- void setUseDarkAppearance(bool); > #endif > >+ void setUseDarkAppearance(bool); >+ > bool windowIsFocused() const; > bool windowAndWebPageAreFocused() const; > >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >index 54abbaf8934ccdcf8e4f20f783fcb6b9f03040eb..21ddbfcd906de1b66513a3071fda7b93e0bcb76f 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >@@ -474,12 +474,13 @@ messages -> WebPage LegacyReceiver { > HandleAcceptedCandidate(struct WebCore::TextCheckingResult acceptedCandidate) > > SetUseSystemAppearance(bool useSystemAppearance); >- SetUseDarkAppearance(bool useDarkAppearance); > > SetHeaderBannerHeightForTesting(int height); > SetFooterBannerHeightForTesting(int height); > #endif > >+ SetUseDarkAppearance(bool useDarkAppearance); >+ > #if PLATFORM(COCOA) > RequestActiveNowPlayingSessionInfo(WebKit::CallbackID callbackID) > #endif >diff --git a/Source/WebKitLegacy/mac/WebView/WebView.mm b/Source/WebKitLegacy/mac/WebView/WebView.mm >index ed0e0df79b03da66e8a29bced9ceaa93cd665e8c..0b5dbc41f54f6c150729e3d5f2d7ec715c9af97c 100644 >--- a/Source/WebKitLegacy/mac/WebView/WebView.mm >+++ b/Source/WebKitLegacy/mac/WebView/WebView.mm >@@ -1587,6 +1587,9 @@ - (void)_commonInitializationWithFrameName:(NSString *)frameName groupName:(NSSt > ResourceHandle::forceContentSniffing(); > > _private->page->setDeviceScaleFactor([self _deviceScaleFactor]); >+#endif >+ >+#if HAVE(OS_DARK_MODE_SUPPORT) && PLATFORM(MAC) > _private->page->setUseDarkAppearance(self._effectiveAppearanceIsDark); > #endif > >@@ -5295,15 +5298,13 @@ - (WebEdgeInsets)_unobscuredSafeAreaInsets > return insets; > } > >+#if HAVE(OS_DARK_MODE_SUPPORT) && PLATFORM(MAC) > - (bool)_effectiveAppearanceIsDark > { >-#if HAVE(OS_DARK_MODE_SUPPORT) > NSAppearanceName appearance = [[self effectiveAppearance] bestMatchFromAppearancesWithNames:@[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]]; > return [appearance isEqualToString:NSAppearanceNameDarkAqua]; >-#else >- return false; >-#endif > } >+#endif > > - (void)_setUseSystemAppearance:(BOOL)useSystemAppearance > { >@@ -5319,6 +5320,7 @@ - (BOOL)_useSystemAppearance > return _private->page->useSystemAppearance(); > } > >+#if HAVE(OS_DARK_MODE_SUPPORT) && PLATFORM(MAC) > - (void)viewDidChangeEffectiveAppearance > { > // This can be called during [super initWithCoder:] and [super initWithFrame:]. >@@ -5328,6 +5330,7 @@ - (void)viewDidChangeEffectiveAppearance > > _private->page->setUseDarkAppearance(self._effectiveAppearanceIsDark); > } >+#endif > > - (void)_setSourceApplicationAuditData:(NSData *)sourceApplicationAuditData > {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193882
:
360272
|
360273
|
360276
|
360302
|
360305