Diff
Modified: trunk/LayoutTests/ChangeLog (233279 => 233280)
--- trunk/LayoutTests/ChangeLog 2018-06-27 21:43:41 UTC (rev 233279)
+++ trunk/LayoutTests/ChangeLog 2018-06-27 22:14:53 UTC (rev 233280)
@@ -1,3 +1,15 @@
+2018-06-27 Timothy Hatcher <[email protected]>
+
+ Find on page selection color isn't adapted for dark mode.
+ https://bugs.webkit.org/show_bug.cgi?id=187072
+ rdar://problem/40354841
+
+ Reviewed by Tim Horton.
+
+ * fast/css/apple-system-control-colors-expected.txt: Updated.
+ * fast/text/mark-matches-broken-line-rendering-expected.html: Ditto.
+ * fast/text/mark-matches-rendering-expected.html: Ditto.
+
2018-06-27 Youenn Fablet <[email protected]>
Disable content blockers in NetworkLoadChecker except for ping loads
Modified: trunk/LayoutTests/fast/css/apple-system-control-colors-expected.txt (233279 => 233280)
--- trunk/LayoutTests/fast/css/apple-system-control-colors-expected.txt 2018-06-27 21:43:41 UTC (rev 233279)
+++ trunk/LayoutTests/fast/css/apple-system-control-colors-expected.txt 2018-06-27 22:14:53 UTC (rev 233280)
@@ -12,7 +12,7 @@
-apple-system-selected-text-background : rgb(181, 213, 255)
-apple-system-unemphasized-selected-text-background : rgb(212, 212, 212)
-apple-system-placeholder-text : rgba(0, 0, 0, 0.247059)
--apple-system-find-highlight-background : rgb(255, 255, 0)
+-apple-system-find-highlight-background : rgb(255, 204, 0)
-apple-system-label : rgba(0, 0, 0, 0.85098)
-apple-system-secondary-label : rgba(0, 0, 0, 0.498039)
-apple-system-tertiary-label : rgba(0, 0, 0, 0.247059)
Modified: trunk/LayoutTests/fast/text/mark-matches-broken-line-rendering-expected.html (233279 => 233280)
--- trunk/LayoutTests/fast/text/mark-matches-broken-line-rendering-expected.html 2018-06-27 21:43:41 UTC (rev 233279)
+++ trunk/LayoutTests/fast/text/mark-matches-broken-line-rendering-expected.html 2018-06-27 22:14:53 UTC (rev 233280)
@@ -6,7 +6,8 @@
}
span {
- background-color: yellow;
+ background-color: rgb(255, 204, 0);
+ color: -apple-system-label;
}
</style>
<p>
Modified: trunk/LayoutTests/fast/text/mark-matches-rendering-expected.html (233279 => 233280)
--- trunk/LayoutTests/fast/text/mark-matches-rendering-expected.html 2018-06-27 21:43:41 UTC (rev 233279)
+++ trunk/LayoutTests/fast/text/mark-matches-rendering-expected.html 2018-06-27 22:14:53 UTC (rev 233280)
@@ -1,3 +1,3 @@
-<p style="display:inline-block; background-color:yellow">
+<p style="display: inline-block; background-color: rgb(255, 204, 0); color: -apple-system-label">
Quo usque tandem abutere, Catilina, patientia nostra?
</p>
Modified: trunk/Source/WebCore/ChangeLog (233279 => 233280)
--- trunk/Source/WebCore/ChangeLog 2018-06-27 21:43:41 UTC (rev 233279)
+++ trunk/Source/WebCore/ChangeLog 2018-06-27 22:14:53 UTC (rev 233280)
@@ -1,3 +1,40 @@
+2018-06-27 Timothy Hatcher <[email protected]>
+
+ Find on page selection color isn't adapted for dark mode.
+ https://bugs.webkit.org/show_bug.cgi?id=187072
+ rdar://problem/40354841
+
+ Reviewed by Tim Horton.
+
+ * page/mac/TextIndicatorWindow.mm:
+ (-[WebTextIndicatorView initWithFrame:textIndicator:margin:offset:]): Use [NSColor findHighlightColor].
+ * platform/mac/LocalDefaultSystemAppearance.h:
+ (WebCore::LocalDefaultSystemAppearance::usingDarkAppearance const): Added.
+ * platform/mac/LocalDefaultSystemAppearance.mm:
+ (WebCore::LocalDefaultSystemAppearance::LocalDefaultSystemAppearance): Set m_usingDarkAppearance.
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::paintPlatformDocumentMarkers): Use TextPaintPhase::Decoration since this
+ matches step three of InlineTextBox::paint ("Paint fancy decorations"). This allows TextMatch to
+ paint a forground and not end up painting during this "fancy decorations" phase.
+ (WebCore::InlineTextBox::resolveStyleForMarkedText): Set the fillColor for TextMarker to force a
+ dark text color which will draw over the yellow highlight.
+ (WebCore::InlineTextBox::collectMarkedTextsForDocumentMarkers): Added support for TextPaintPhase::Decoration.
+ Seperate DocumentMarker::TelephoneNumber and DocumentMarker::TextMatch. Have DocumentMarker::TextMatch
+ support Forground and Background phases.
+ * rendering/RenderTheme.cpp:
+ (WebCore::RenderTheme::platformColorsDidChange):
+ (WebCore::RenderTheme::activeTextSearchHighlightColor const): Added. Call the platfrom version.
+ (WebCore::RenderTheme::inactiveTextSearchHighlightColor const): Added. Ditto.
+ (WebCore::RenderTheme::platformActiveTextSearchHighlightColor const): Added StyleColor::Options.
+ (WebCore::RenderTheme::platformInactiveTextSearchHighlightColor const): Ditto.
+ * rendering/RenderTheme.h:
+ * rendering/RenderThemeMac.h:
+ * rendering/RenderThemeMac.mm:
+ (WebCore::RenderThemeMac::platformActiveTextSearchHighlightColor const): Added.
+ (WebCore::RenderThemeMac::platformInactiveTextSearchHighlightColor const): Added.
+ (WebCore::RenderThemeMac::platformColorsDidChange): Clear new color caches.
+ (WebCore::RenderThemeMac::systemColor const): Cache system colors by light and dark mode.
+
2018-06-27 Chris Dumez <[email protected]>
Crash under SWServer::unregisterServiceWorkerClient()
Modified: trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm (233279 => 233280)
--- trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm 2018-06-27 21:43:41 UTC (rev 233279)
+++ trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm 2018-06-27 22:14:53 UTC (rev 233280)
@@ -34,6 +34,7 @@
#import "TextIndicator.h"
#import "WebActionDisablingCALayerDelegate.h"
#import <pal/spi/cg/CoreGraphicsSPI.h>
+#import <pal/spi/cocoa/NSColorSPI.h>
#import <pal/spi/cocoa/QuartzCoreSPI.h>
const CFTimeInterval bounceAnimationDuration = 0.12;
@@ -168,7 +169,11 @@
RetainPtr<NSMutableArray> bounceLayers = adoptNS([[NSMutableArray alloc] init]);
- RetainPtr<CGColorRef> highlightColor = [NSColor colorWithDeviceRed:1 green:1 blue:0 alpha:1].CGColor;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
+ RetainPtr<CGColorRef> highlightColor = [NSColor findHighlightColor].CGColor;
+#else
+ RetainPtr<CGColorRef> highlightColor = [NSColor colorWithDeviceRed:1 green:0.8 blue:0 alpha:1].CGColor;
+#endif
RetainPtr<CGColorRef> rimShadowColor = [NSColor colorWithDeviceWhite:0 alpha:0.35].CGColor;
RetainPtr<CGColorRef> dropShadowColor = [NSColor colorWithDeviceWhite:0 alpha:0.2].CGColor;
Modified: trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h (233279 => 233280)
--- trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h 2018-06-27 21:43:41 UTC (rev 233279)
+++ trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h 2018-06-27 22:14:53 UTC (rev 233280)
@@ -38,12 +38,24 @@
// functions which call out into AppKit and rely on the current NSAppearance being set
class LocalDefaultSystemAppearance {
WTF_MAKE_NONCOPYABLE(LocalDefaultSystemAppearance);
+
public:
WEBCORE_EXPORT LocalDefaultSystemAppearance(bool useSystemAppearance, bool useDefaultAppearance);
WEBCORE_EXPORT ~LocalDefaultSystemAppearance();
+
+ bool usingDarkAppearance() const
+ {
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+ return m_usingDarkAppearance;
+#else
+ return false;
+#endif
+ }
+
private:
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
RetainPtr<NSAppearance> m_savedSystemAppearance;
+ bool m_usingDarkAppearance { false };
#endif
};
Modified: trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm (233279 => 233280)
--- trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm 2018-06-27 21:43:41 UTC (rev 233279)
+++ trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm 2018-06-27 22:14:53 UTC (rev 233280)
@@ -42,7 +42,9 @@
return;
m_savedSystemAppearance = [NSAppearance currentAppearance];
- [NSAppearance setCurrentAppearance:[NSAppearance appearanceNamed:(!useSystemAppearance || useDefaultAppearance ? NSAppearanceNameAqua : NSAppearanceNameDarkAqua)]];
+ m_usingDarkAppearance = useSystemAppearance && !useDefaultAppearance;
+
+ [NSAppearance setCurrentAppearance:[NSAppearance appearanceNamed:m_usingDarkAppearance ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]];
#else
UNUSED_PARAM(useSystemAppearance);
UNUSED_PARAM(useDefaultAppearance);
Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (233279 => 233280)
--- trunk/Source/WebCore/rendering/InlineTextBox.cpp 2018-06-27 21:43:41 UTC (rev 233279)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp 2018-06-27 22:14:53 UTC (rev 233280)
@@ -653,7 +653,7 @@
void InlineTextBox::paintPlatformDocumentMarkers(GraphicsContext& context, const FloatPoint& boxOrigin)
{
- for (auto& markedText : subdivide(collectMarkedTextsForDocumentMarkers(TextPaintPhase::Foreground), OverlapStrategy::Frontmost))
+ for (auto& markedText : subdivide(collectMarkedTextsForDocumentMarkers(TextPaintPhase::Decoration), OverlapStrategy::Frontmost))
paintPlatformDocumentMarker(context, boxOrigin, markedText);
}
@@ -763,10 +763,16 @@
style.backgroundColor = { 0xff - selectionBackgroundColor.red(), 0xff - selectionBackgroundColor.green(), 0xff - selectionBackgroundColor.blue() };
break;
}
- case MarkedText::TextMatch:
- style.backgroundColor = markedText.marker->isActiveMatch() ? renderer().theme().platformActiveTextSearchHighlightColor() : renderer().theme().platformInactiveTextSearchHighlightColor();
+ case MarkedText::TextMatch: {
+ // Text matches always use the light system appearance.
+ OptionSet<StyleColor::Options> styleColorOptions = { StyleColor::Options::UseSystemAppearance, StyleColor::Options::UseDefaultAppearance };
+#if PLATFORM(MAC)
+ style.textStyles.fillColor = renderer().theme().systemColor(CSSValueAppleSystemLabel, styleColorOptions);
+#endif
+ style.backgroundColor = markedText.marker->isActiveMatch() ? renderer().theme().activeTextSearchHighlightColor(styleColorOptions) : renderer().theme().inactiveTextSearchHighlightColor(styleColorOptions);
break;
}
+ }
StyledMarkedText styledMarkedText = markedText;
styledMarkedText.style = WTFMove(style);
return styledMarkedText;
@@ -832,7 +838,8 @@
Vector<MarkedText> InlineTextBox::collectMarkedTextsForDocumentMarkers(TextPaintPhase phase)
{
- ASSERT(phase == TextPaintPhase::Background || phase == TextPaintPhase::Foreground);
+ ASSERT_ARG(phase, phase == TextPaintPhase::Background || phase == TextPaintPhase::Foreground || phase == TextPaintPhase::Decoration);
+
if (!renderer().textNode())
return { };
@@ -876,19 +883,23 @@
// FIXME: Remove the PLATFORM(IOS)-guard.
case DocumentMarker::DictationPhraseWithAlternatives:
#endif
- if (phase == TextPaintPhase::Background)
+ if (phase != TextPaintPhase::Decoration)
continue;
break;
case DocumentMarker::TextMatch:
if (!renderer().frame().editor().markedTextMatchesAreHighlighted())
continue;
+ if (phase == TextPaintPhase::Decoration)
+ continue;
+ break;
#if ENABLE(TELEPHONE_NUMBER_DETECTION)
- FALLTHROUGH;
case DocumentMarker::TelephoneNumber:
-#endif
- if (phase == TextPaintPhase::Foreground)
+ if (!renderer().frame().editor().markedTextMatchesAreHighlighted())
continue;
+ if (phase != TextPaintPhase::Background)
+ continue;
break;
+#endif
default:
continue;
}
Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (233279 => 233280)
--- trunk/Source/WebCore/rendering/RenderTheme.cpp 2018-06-27 21:43:41 UTC (rev 233279)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp 2018-06-27 22:14:53 UTC (rev 233280)
@@ -1158,6 +1158,9 @@
m_activeListBoxSelectionBackgroundColor = Color();
m_inactiveListBoxSelectionForegroundColor = Color();
+ m_activeTextSearchHighlightColor = Color();
+ m_inactiveTextSearchHighlightColor = Color();
+
Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment();
}
@@ -1283,12 +1286,26 @@
return Color();
}
-Color RenderTheme::platformActiveTextSearchHighlightColor() const
+Color RenderTheme::activeTextSearchHighlightColor(OptionSet<StyleColor::Options> options) const
{
+ if (!m_activeTextSearchHighlightColor.isValid())
+ m_activeTextSearchHighlightColor = platformActiveTextSearchHighlightColor(options);
+ return m_activeTextSearchHighlightColor;
+}
+
+Color RenderTheme::inactiveTextSearchHighlightColor(OptionSet<StyleColor::Options> options) const
+{
+ if (!m_inactiveTextSearchHighlightColor.isValid())
+ m_inactiveTextSearchHighlightColor = platformInactiveTextSearchHighlightColor(options);
+ return m_inactiveTextSearchHighlightColor;
+}
+
+Color RenderTheme::platformActiveTextSearchHighlightColor(OptionSet<StyleColor::Options>) const
+{
return Color(255, 150, 50); // Orange.
}
-Color RenderTheme::platformInactiveTextSearchHighlightColor() const
+Color RenderTheme::platformInactiveTextSearchHighlightColor(OptionSet<StyleColor::Options>) const
{
return Color(255, 255, 0); // Yellow.
}
Modified: trunk/Source/WebCore/rendering/RenderTheme.h (233279 => 233280)
--- trunk/Source/WebCore/rendering/RenderTheme.h 2018-06-27 21:43:41 UTC (rev 233279)
+++ trunk/Source/WebCore/rendering/RenderTheme.h 2018-06-27 22:14:53 UTC (rev 233280)
@@ -144,9 +144,9 @@
Color inactiveListBoxSelectionBackgroundColor(OptionSet<StyleColor::Options>) const;
Color inactiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options>) const;
- // Highlighting colors for TextMatches.
- virtual Color platformActiveTextSearchHighlightColor() const;
- virtual Color platformInactiveTextSearchHighlightColor() const;
+ // Highlighting colors for search matches.
+ Color activeTextSearchHighlightColor(OptionSet<StyleColor::Options>) const;
+ Color inactiveTextSearchHighlightColor(OptionSet<StyleColor::Options>) const;
virtual Color disabledTextColor(const Color& textColor, const Color& backgroundColor) const;
@@ -265,6 +265,10 @@
virtual Color platformActiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options>) const;
virtual Color platformInactiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options>) const;
+ // The platform highlighting colors for search matches.
+ virtual Color platformActiveTextSearchHighlightColor(OptionSet<StyleColor::Options>) const;
+ virtual Color platformInactiveTextSearchHighlightColor(OptionSet<StyleColor::Options>) const;
+
virtual bool supportsSelectionForegroundColors() const { return true; }
virtual bool supportsListBoxSelectionForegroundColors() const { return true; }
@@ -404,6 +408,9 @@
mutable Color m_inactiveListBoxSelectionBackgroundColor;
mutable Color m_activeListBoxSelectionForegroundColor;
mutable Color m_inactiveListBoxSelectionForegroundColor;
+
+ mutable Color m_activeTextSearchHighlightColor;
+ mutable Color m_inactiveTextSearchHighlightColor;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (233279 => 233280)
--- trunk/Source/WebCore/rendering/RenderThemeMac.h 2018-06-27 21:43:41 UTC (rev 233279)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h 2018-06-27 22:14:53 UTC (rev 233280)
@@ -62,6 +62,8 @@
Color platformInactiveListBoxSelectionBackgroundColor(OptionSet<StyleColor::Options>) const final;
Color platformInactiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options>) const final;
Color platformFocusRingColor(OptionSet<StyleColor::Options>) const final;
+ Color platformActiveTextSearchHighlightColor(OptionSet<StyleColor::Options>) const final;
+ Color platformInactiveTextSearchHighlightColor(OptionSet<StyleColor::Options>) const final;
ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) final { return SmallScrollbar; }
@@ -242,8 +244,10 @@
bool m_isSliderThumbHorizontalPressed { false };
bool m_isSliderThumbVerticalPressed { false };
- mutable HashMap<int, Color> m_systemColorCache;
- mutable Color m_systemVisitedLinkColor;
+ mutable HashMap<int, Color> m_lightSystemColorCache;
+ mutable HashMap<int, Color> m_darkSystemColorCache;
+ mutable Color m_lightSystemVisitedLinkColor;
+ mutable Color m_darkSystemVisitedLinkColor;
RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver;
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (233279 => 233280)
--- trunk/Source/WebCore/rendering/RenderThemeMac.mm 2018-06-27 21:43:41 UTC (rev 233279)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm 2018-06-27 22:14:53 UTC (rev 233280)
@@ -391,6 +391,24 @@
return systemColor(CSSValueWebkitFocusRingColor, options);
}
+Color RenderThemeMac::platformActiveTextSearchHighlightColor(OptionSet<StyleColor::Options> options) const
+{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
+ LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDefaultAppearance));
+ return colorFromNSColor([NSColor findHighlightColor]);
+#else
+ UNUSED_PARAM(options);
+ return Color(255, 204, 0); // Yellow.
+#endif
+}
+
+Color RenderThemeMac::platformInactiveTextSearchHighlightColor(OptionSet<StyleColor::Options> options) const
+{
+ // The inactive color is normally used, since no legacy WebKit client marks a text match as active.
+ // So just return the same color for both states.
+ return platformActiveTextSearchHighlightColor(options);
+}
+
static FontSelectionValue toFontWeight(NSInteger appKitFontWeight)
{
ASSERT(appKitFontWeight > 0 && appKitFontWeight < 15);
@@ -486,8 +504,12 @@
void RenderThemeMac::platformColorsDidChange()
{
- m_systemColorCache.clear();
- m_systemVisitedLinkColor = Color();
+ m_lightSystemColorCache.clear();
+ m_darkSystemColorCache.clear();
+
+ m_lightSystemVisitedLinkColor = Color();
+ m_darkSystemVisitedLinkColor = Color();
+
RenderTheme::platformColorsDidChange();
}
@@ -504,9 +526,15 @@
if (forVisitedLink && cssValueID == CSSValueWebkitLink) {
// Only use NSColor when the system appearance is desired, otherwise use RenderTheme's default.
if (useSystemAppearance) {
- if (!m_systemVisitedLinkColor.isValid())
- m_systemVisitedLinkColor = semanticColorFromNSColor([NSColor systemPurpleColor]);
- return m_systemVisitedLinkColor;
+ if (localAppearance.usingDarkAppearance()) {
+ if (!m_darkSystemVisitedLinkColor.isValid())
+ m_darkSystemVisitedLinkColor = semanticColorFromNSColor([NSColor systemPurpleColor]);
+ return m_darkSystemVisitedLinkColor;
+ }
+
+ if (!m_lightSystemVisitedLinkColor.isValid())
+ m_lightSystemVisitedLinkColor = semanticColorFromNSColor([NSColor systemPurpleColor]);
+ return m_lightSystemVisitedLinkColor;
}
return RenderTheme::systemColor(cssValueID, options);
@@ -514,7 +542,8 @@
ASSERT(!forVisitedLink);
- return m_systemColorCache.ensure(cssValueID, [this, cssValueID, useSystemAppearance, options] () -> Color {
+ auto& systemColorCache = localAppearance.usingDarkAppearance() ? m_darkSystemColorCache : m_lightSystemColorCache;
+ return systemColorCache.ensure(cssValueID, [this, cssValueID, useSystemAppearance, options] () -> Color {
auto selectCocoaColor = [cssValueID, useSystemAppearance] () -> SEL {
switch (cssValueID) {
case CSSValueWebkitLink:
@@ -622,7 +651,8 @@
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
return @selector(findHighlightColor);
#else
- return @selector(systemYellowColor);
+ // Handled below.
+ return nullptr;
#endif
case CSSValueAppleSystemLabel:
return @selector(labelColor);
@@ -688,6 +718,11 @@
case CSSValueMenu:
return menuBackgroundColor();
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
+ case CSSValueAppleSystemFindHighlightBackground:
+ return platformActiveTextSearchHighlightColor(options);
+#endif
+
case CSSValueAppleSystemEvenAlternatingContentBackground: {
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
NSArray<NSColor *> *alternateColors = [NSColor alternatingContentBackgroundColors];