WebKit Bugzilla
Attachment 362477 Details for
Bug 194822
: RenderThemeIOS should use RenderTheme's color cache instead of its own
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194822-20190219203409.patch (text/plain), 17.51 KB, created by
Timothy Hatcher
on 2019-02-19 20:34:10 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Timothy Hatcher
Created:
2019-02-19 20:34:10 PST
Size:
17.51 KB
patch
obsolete
>Subversion Revision: 241761 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index a6da53fe8e04ad79dd06c117c410a040b2b97e76..ffd64bd94a7fe31edc94d5151da9d17cd95e2ecb 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,26 @@ >+2019-02-19 Timothy Hatcher <timothy@apple.com> >+ >+ RenderThemeIOS should use RenderTheme's color cache instead of its own. >+ https://bugs.webkit.org/show_bug.cgi?id=194822 >+ rdar://problem/48208296 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Tested by fast/css/apple-system-colors.html. >+ >+ * css/CSSValueKeywords.in: >+ * css/parser/CSSPropertyParser.cpp: >+ (WebCore::isAppleLegacyCssValueKeyword): >+ * platform/graphics/Color.h: >+ * platform/graphics/cg/ColorCG.cpp: >+ (WebCore::makeRGBAFromCGColor): >+ (WebCore::Color::Color): >+ * rendering/RenderThemeIOS.h: >+ * rendering/RenderThemeIOS.mm: >+ (WebCore::RenderThemeIOS::systemColor const): >+ * rendering/RenderThemeMac.mm: >+ (WebCore::RenderThemeMac::systemColor const): >+ > 2019-02-19 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r241722. >diff --git a/Source/WebCore/PAL/ChangeLog b/Source/WebCore/PAL/ChangeLog >index 7e5c531eee9d9cfa3cf747d62d6759dc7f96742b..3c911923b2727f187c05da3fbb4ae1e130be4efa 100644 >--- a/Source/WebCore/PAL/ChangeLog >+++ b/Source/WebCore/PAL/ChangeLog >@@ -1,3 +1,15 @@ >+2019-02-19 Timothy Hatcher <timothy@apple.com> >+ >+ RenderThemeIOS should use RenderTheme's color cache instead of its own. >+ https://bugs.webkit.org/show_bug.cgi?id=194822 >+ rdar://problem/48208296 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * pal/ios/UIKitSoftLink.h: >+ * pal/ios/UIKitSoftLink.mm: >+ * pal/spi/ios/UIKitSPI.h: >+ > 2019-02-16 Darin Adler <darin@apple.com> > > Continue reducing use of String::format, now focusing on hex: "%p", "%x", etc. >diff --git a/Source/WebCore/PAL/pal/ios/UIKitSoftLink.h b/Source/WebCore/PAL/pal/ios/UIKitSoftLink.h >index f933959e62b8cce53cf13309b8496dea7eb0c482..90529f368b19176f00748de98865ba9638264e74 100644 >--- a/Source/WebCore/PAL/pal/ios/UIKitSoftLink.h >+++ b/Source/WebCore/PAL/pal/ios/UIKitSoftLink.h >@@ -56,6 +56,7 @@ SOFT_LINK_CLASS_FOR_HEADER(PAL, UILabel) > SOFT_LINK_CLASS_FOR_HEADER(PAL, UIPasteboard) > SOFT_LINK_CLASS_FOR_HEADER(PAL, UIScreen) > SOFT_LINK_CLASS_FOR_HEADER(PAL, UITapGestureRecognizer) >+SOFT_LINK_CLASS_FOR_HEADER(PAL, UITraitCollection) > SOFT_LINK_CLASS_FOR_HEADER(PAL, UIView) > SOFT_LINK_CLASS_FOR_HEADER(PAL, UIViewController) > SOFT_LINK_CLASS_FOR_HEADER(PAL, UIWindow) >diff --git a/Source/WebCore/PAL/pal/ios/UIKitSoftLink.mm b/Source/WebCore/PAL/pal/ios/UIKitSoftLink.mm >index 33715ccc9bcd55dde959e2871d8b956eebb7516a..c2ed364c68d424a24cd987137aac33802679f949 100644 >--- a/Source/WebCore/PAL/pal/ios/UIKitSoftLink.mm >+++ b/Source/WebCore/PAL/pal/ios/UIKitSoftLink.mm >@@ -56,6 +56,7 @@ SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, UILabel) > SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, UIPasteboard) > SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, UIScreen) > SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, UITapGestureRecognizer) >+SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, UITraitCollection) > SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, UIView) > SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, UIViewController) > SOFT_LINK_CLASS_FOR_SOURCE(PAL, UIKit, UIWindow) >diff --git a/Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h b/Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h >index e1d46ac955352a4037784cc12c871e61a0737cb7..dad351495a6b83ffecb8643ebd6c88f630f443f7 100644 >--- a/Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h >+++ b/Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h >@@ -109,6 +109,7 @@ typedef enum { > + (UIColor *)systemGreenColor; > + (UIColor *)systemOrangeColor; > + (UIColor *)systemPinkColor; >++ (UIColor *)systemPurpleColor; > + (UIColor *)systemRedColor; > + (UIColor *)systemYellowColor; > >diff --git a/Source/WebCore/css/CSSValueKeywords.in b/Source/WebCore/css/CSSValueKeywords.in >index d8d3d2d544b787fc97c426073a62b9ca678ef4de..7e0e1706eebcf1ebfd24fdbdb43fa5a560c4935c 100644 >--- a/Source/WebCore/css/CSSValueKeywords.in >+++ b/Source/WebCore/css/CSSValueKeywords.in >@@ -222,22 +222,11 @@ threedshadow > window > windowframe > windowtext >-#if defined(WTF_PLATFORM_MAC) && WTF_PLATFORM_MAC >+#if (defined(WTF_PLATFORM_MAC) && WTF_PLATFORM_MAC) || (defined(WTF_PLATFORM_IOS_FAMILY) && WTF_PLATFORM_IOS_FAMILY) > -apple-system-header-text > -apple-system-text-background > -apple-system-control-background >--apple-system-alternate-selected-text >--apple-system-control-accent >--apple-system-even-alternating-content-background >--apple-system-odd-alternating-content-background >--apple-system-selected-content-background >--apple-system-unemphasized-selected-content-background >--apple-system-selected-text >--apple-system-unemphasized-selected-text >--apple-system-selected-text-background >--apple-system-unemphasized-selected-text-background > -apple-system-placeholder-text >--apple-system-find-highlight-background > -apple-system-label > -apple-system-secondary-label > -apple-system-tertiary-label >@@ -245,7 +234,14 @@ windowtext > -apple-system-grid > -apple-system-separator > -apple-system-container-border >-#endif >+-apple-system-background >+-apple-system-secondary-background >+-apple-system-tertiary-background >+-apple-system-grouped-background >+-apple-system-secondary-grouped-background >+-apple-system-tertiary-grouped-background >+-apple-system-selected-content-background >+-apple-system-unemphasized-selected-content-background > -apple-wireless-playback-target-active > -apple-system-blue > -apple-system-brown >@@ -256,6 +252,22 @@ windowtext > -apple-system-purple > -apple-system-red > -apple-system-yellow >+#endif >+#if defined(WTF_PLATFORM_MAC) && WTF_PLATFORM_MAC >+-apple-system-alternate-selected-text >+-apple-system-control-accent >+-apple-system-even-alternating-content-background >+-apple-system-odd-alternating-content-background >+-apple-system-selected-text >+-apple-system-unemphasized-selected-text >+-apple-system-selected-text-background >+-apple-system-unemphasized-selected-text-background >+-apple-system-find-highlight-background >+#endif >+#if defined(WTF_PLATFORM_IOS_FAMILY) && WTF_PLATFORM_IOS_FAMILY >+-apple-system-indigo >+-apple-system-teal >+#endif > -webkit-focus-ring-color > currentcolor > // >diff --git a/Source/WebCore/css/parser/CSSPropertyParser.cpp b/Source/WebCore/css/parser/CSSPropertyParser.cpp >index b6f117c5e4e60defc71c9f23b1ba2595ac748142..34a2d63d0d3aa0c747536c37c1002a46f1130aef 100644 >--- a/Source/WebCore/css/parser/CSSPropertyParser.cpp >+++ b/Source/WebCore/css/parser/CSSPropertyParser.cpp >@@ -156,12 +156,18 @@ static bool isAppleLegacyCssValueKeyword(const char* valueKeyword, unsigned leng > static const char applePrefix[] = "-apple-"; > static const char appleSystemPrefix[] = "-apple-system"; > static const char applePayPrefix[] = "-apple-pay"; >+ >+#if PLATFORM(MAC) || PLATFORM(IOS_FAMILY) > static const char* appleWirelessPlaybackTargetActive = getValueName(CSSValueAppleWirelessPlaybackTargetActive); >- >+#endif >+ > return hasPrefix(valueKeyword, length, applePrefix) > && !hasPrefix(valueKeyword, length, appleSystemPrefix) > && !hasPrefix(valueKeyword, length, applePayPrefix) >- && !WTF::equal(reinterpret_cast<const LChar*>(valueKeyword), reinterpret_cast<const LChar*>(appleWirelessPlaybackTargetActive), length); >+#if PLATFORM(MAC) || PLATFORM(IOS_FAMILY) >+ && !WTF::equal(reinterpret_cast<const LChar*>(valueKeyword), reinterpret_cast<const LChar*>(appleWirelessPlaybackTargetActive), length) >+#endif >+ ; > } > > template <typename CharacterType> >diff --git a/Source/WebCore/platform/graphics/Color.h b/Source/WebCore/platform/graphics/Color.h >index 5d039bbc20e6794f230e6140b409f338e59c71b1..d6915c0cc7a6ddcc64be2a7c79e2cda6c46d416e 100644 >--- a/Source/WebCore/platform/graphics/Color.h >+++ b/Source/WebCore/platform/graphics/Color.h >@@ -262,6 +262,7 @@ public: > > #if USE(CG) > WEBCORE_EXPORT Color(CGColorRef); >+ WEBCORE_EXPORT Color(CGColorRef, SemanticTag); > #endif > > #if PLATFORM(WIN) >diff --git a/Source/WebCore/platform/graphics/cg/ColorCG.cpp b/Source/WebCore/platform/graphics/cg/ColorCG.cpp >index f6e655a7553671bfd0241609b284327a69ea4cf5..109c640c52661a187ed510ad2f27000de53b7839 100644 >--- a/Source/WebCore/platform/graphics/cg/ColorCG.cpp >+++ b/Source/WebCore/platform/graphics/cg/ColorCG.cpp >@@ -51,13 +51,8 @@ RetainPtr<CGColorRef> TinyLRUCachePolicy<WebCore::Color, RetainPtr<CGColorRef>>: > > namespace WebCore { > >-Color::Color(CGColorRef color) >+static RGBA32 makeRGBAFromCGColor(CGColorRef color) > { >- if (!color) { >- m_colorData.rgbaAndFlags = invalidRGBAColor; >- return; >- } >- > size_t numComponents = CGColorGetNumberOfComponents(color); > const CGFloat* components = CGColorGetComponents(color); > >@@ -81,7 +76,29 @@ Color::Color(CGColorRef color) > ASSERT_NOT_REACHED(); > } > >- setRGB(makeRGBA(r * 255, g * 255, b * 255, a * 255)); >+ static const double scaleFactor = nextafter(256.0, 0.0); >+ return makeRGBA(r * scaleFactor, g * scaleFactor, b * scaleFactor, a * scaleFactor); >+} >+ >+Color::Color(CGColorRef color) >+{ >+ if (!color) { >+ m_colorData.rgbaAndFlags = invalidRGBAColor; >+ return; >+ } >+ >+ setRGB(makeRGBAFromCGColor(color)); >+} >+ >+Color::Color(CGColorRef color, SemanticTag) >+{ >+ if (!color) { >+ m_colorData.rgbaAndFlags = invalidRGBAColor; >+ return; >+ } >+ >+ setRGB(makeRGBAFromCGColor(color)); >+ setIsSemantic(); > } > > static CGColorRef leakCGColor(const Color& color) >diff --git a/Source/WebCore/rendering/RenderThemeIOS.h b/Source/WebCore/rendering/RenderThemeIOS.h >index ed8927fc4bdca0f53a8ccf49cf4466797c03adef..738591035efa74e165b0c957272ab7f6199ece01 100644 >--- a/Source/WebCore/rendering/RenderThemeIOS.h >+++ b/Source/WebCore/rendering/RenderThemeIOS.h >@@ -159,8 +159,6 @@ private: > String m_legacyMediaControlsStyleSheet; > String m_mediaControlsStyleSheet; > >- mutable HashMap<int, Color> m_systemColorCache; >- > #if USE(SYSTEM_PREVIEW) > RetainPtr<CIContext> m_ciContext; > #if HAVE(IOSURFACE) >diff --git a/Source/WebCore/rendering/RenderThemeIOS.mm b/Source/WebCore/rendering/RenderThemeIOS.mm >index a28a4adc272f71c2b483f3094f9417cf71b67f0f..113743f4e290feb60354748a8b54c5963d66af1a 100644 >--- a/Source/WebCore/rendering/RenderThemeIOS.mm >+++ b/Source/WebCore/rendering/RenderThemeIOS.mm >@@ -75,9 +75,14 @@ > #import <pal/spi/cocoa/CoreTextSPI.h> > #import <pal/spi/ios/UIKitSPI.h> > #import <wtf/NeverDestroyed.h> >+#import <wtf/ObjCRuntimeExtras.h> > #import <wtf/RefPtr.h> > #import <wtf/StdLibExtras.h> > >+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/RenderThemeIOSAdditions.mm>) >+#include <WebKitAdditions/RenderThemeIOSAdditions.mm> >+#endif >+ > @interface WebCoreRenderThemeBundle : NSObject > @end > >@@ -1413,56 +1418,60 @@ String RenderThemeIOS::mediaControlsBase64StringForIconNameAndType(const String& > > Color RenderThemeIOS::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::Options> options) const > { >+ const bool useSystemAppearance = options.contains(StyleColor::Options::UseSystemAppearance); > const bool forVisitedLink = options.contains(StyleColor::Options::ForVisitedLink); > >+ auto& cache = colorCache(options); >+ >+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/RenderThemeIOSSystemColorAdditions.mm>) >+#include <WebKitAdditions/RenderThemeIOSSystemColorAdditions.mm> >+#endif >+ > // The system color cache below can't handle visited links. The only color value > // that cares about visited links is CSSValueWebkitLink, so handle it here by > // calling through to RenderTheme's base implementation. > if (forVisitedLink && cssValueID == CSSValueWebkitLink) > return RenderTheme::systemColor(cssValueID, options); > >+ ASSERT_UNUSED(useSystemAppearance, !useSystemAppearance); > ASSERT(!forVisitedLink); > >- auto addResult = m_systemColorCache.add(cssValueID, Color()); >- if (!addResult.isNewEntry) >- return addResult.iterator->value; >- >- Color color; >- switch (cssValueID) { >- case CSSValueAppleWirelessPlaybackTargetActive: >- color = [PAL::getUIColorClass() systemBlueColor].CGColor; >- break; >- case CSSValueAppleSystemBlue: >- color = [PAL::getUIColorClass() systemBlueColor].CGColor; >- break; >- case CSSValueAppleSystemGray: >- color = [PAL::getUIColorClass() systemGrayColor].CGColor; >- break; >- case CSSValueAppleSystemGreen: >- color = [PAL::getUIColorClass() systemGreenColor].CGColor; >- break; >- case CSSValueAppleSystemOrange: >- color = [PAL::getUIColorClass() systemOrangeColor].CGColor; >- break; >- case CSSValueAppleSystemPink: >- color = [PAL::getUIColorClass() systemPinkColor].CGColor; >- break; >- case CSSValueAppleSystemRed: >- color = [PAL::getUIColorClass() systemRedColor].CGColor; >- break; >- case CSSValueAppleSystemYellow: >- color = [PAL::getUIColorClass() systemYellowColor].CGColor; >- break; >- default: >- break; >- } >+ return cache.systemStyleColors.ensure(cssValueID, [this, cssValueID, options] () -> Color { >+ auto cssColorToSelector = [cssValueID] () -> SEL { >+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/RenderThemeIOSColorToSelectorAdditions.mm>) >+#include <WebKitAdditions/RenderThemeIOSColorToSelectorAdditions.mm> >+#endif > >- if (!color.isValid()) >- color = RenderTheme::systemColor(cssValueID, options); >+ switch (cssValueID) { >+ case CSSValueAppleWirelessPlaybackTargetActive: >+ case CSSValueAppleSystemBlue: >+ return @selector(systemBlueColor); >+ case CSSValueAppleSystemGray: >+ return @selector(systemGrayColor); >+ case CSSValueAppleSystemGreen: >+ return @selector(systemGreenColor); >+ case CSSValueAppleSystemOrange: >+ return @selector(systemOrangeColor); >+ case CSSValueAppleSystemPink: >+ return @selector(systemPinkColor); >+ case CSSValueAppleSystemPurple: >+ return @selector(systemPurpleColor); >+ case CSSValueAppleSystemRed: >+ return @selector(systemRedColor); >+ case CSSValueAppleSystemYellow: >+ return @selector(systemYellowColor); >+ default: >+ return nullptr; >+ } >+ }; > >- addResult.iterator->value = color; >+ if (auto selector = cssColorToSelector()) { >+ if (auto color = wtfObjCMsgSend<UIColor *>(PAL::getUIColorClass(), selector)) >+ return Color(color.CGColor, Color::Semantic); >+ } > >- return addResult.iterator->value; >+ return RenderTheme::systemColor(cssValueID, options); >+ }).iterator->value; > } > > #if ENABLE(ATTACHMENT_ELEMENT) >diff --git a/Source/WebCore/rendering/RenderThemeMac.mm b/Source/WebCore/rendering/RenderThemeMac.mm >index ec33906a226c3c51029b070c401374e7a735ebd0..5dc10a0a7583fcd89a56faa9990b6d1059a86aa5 100644 >--- a/Source/WebCore/rendering/RenderThemeMac.mm >+++ b/Source/WebCore/rendering/RenderThemeMac.mm >@@ -776,7 +776,6 @@ Color RenderThemeMac::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::O > return @selector(gridColor); > #endif > case CSSValueAppleWirelessPlaybackTargetActive: >- return @selector(systemBlueColor); > case CSSValueAppleSystemBlue: > return @selector(systemBlueColor); > case CSSValueAppleSystemBrown: >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index e26eaf6e984904ac4398e158332c2c689e209500..d40fbf231fc672e21baa5af439c9d07ceda36876 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,15 @@ >+2019-02-19 Timothy Hatcher <timothy@apple.com> >+ >+ RenderThemeIOS should use RenderTheme's color cache instead of its own. >+ https://bugs.webkit.org/show_bug.cgi?id=194822 >+ rdar://problem/48208296 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * platform/ios/fast/css/apple-system-colors-expected.txt: Rebased for -apple-system-purple. >+ * platform/win/fast/css/apple-system-colors-expected.txt: Rebased for invalid color now >+ that -apple-system colors are macOS and iOS only. >+ > 2019-02-19 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r241722. >diff --git a/LayoutTests/platform/ios/fast/css/apple-system-colors-expected.txt b/LayoutTests/platform/ios/fast/css/apple-system-colors-expected.txt >index eeb728b6a7dcc3d6b0d0736cfd8d2f773df902e4..83a93327079ecb07703ae54957891cb75aab173c 100644 >--- a/LayoutTests/platform/ios/fast/css/apple-system-colors-expected.txt >+++ b/LayoutTests/platform/ios/fast/css/apple-system-colors-expected.txt >@@ -4,7 +4,7 @@ > -apple-system-green : rgb(76, 217, 100) > -apple-system-orange : rgb(255, 149, 0) > -apple-system-pink : rgb(255, 45, 85) >--apple-system-purple : rgba(0, 0, 0, 0) >+-apple-system-purple : rgb(88, 86, 214) > -apple-system-red : rgb(255, 59, 48) > -apple-system-yellow : rgb(255, 204, 0) > -apple-wireless-playback-target-active : rgb(0, 122, 255) >diff --git a/LayoutTests/platform/win/fast/css/apple-system-colors-expected.txt b/LayoutTests/platform/win/fast/css/apple-system-colors-expected.txt >index 339072853d6b75e37fbaede6b84083efcb34cb63..420cef414a9faa7231a3ba76d015c09c9b2c33d0 100644 >--- a/LayoutTests/platform/win/fast/css/apple-system-colors-expected.txt >+++ b/LayoutTests/platform/win/fast/css/apple-system-colors-expected.txt >@@ -8,4 +8,4 @@ > -apple-system-red : rgba(0, 0, 0, 0) > -apple-system-yellow : rgba(0, 0, 0, 0) > -apple-wireless-playback-target-active : rgba(0, 0, 0, 0) >-current-color with inherited -apple-system-blue : rgba(0, 0, 0, 0) >+current-color with inherited -apple-system-blue : rgb(0, 0, 0)
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 194822
:
362405
|
362407
|
362426
|
362433
|
362458
| 362477