Changeset 233280 in webkit
- Timestamp:
- Jun 27, 2018 3:14:53 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r233269 r233280 1 2018-06-27 Timothy Hatcher <timothy@apple.com> 2 3 Find on page selection color isn't adapted for dark mode. 4 https://bugs.webkit.org/show_bug.cgi?id=187072 5 rdar://problem/40354841 6 7 Reviewed by Tim Horton. 8 9 * fast/css/apple-system-control-colors-expected.txt: Updated. 10 * fast/text/mark-matches-broken-line-rendering-expected.html: Ditto. 11 * fast/text/mark-matches-rendering-expected.html: Ditto. 12 1 13 2018-06-27 Youenn Fablet <youenn@apple.com> 2 14 -
trunk/LayoutTests/fast/css/apple-system-control-colors-expected.txt
r232878 r233280 13 13 -apple-system-unemphasized-selected-text-background : rgb(212, 212, 212) 14 14 -apple-system-placeholder-text : rgba(0, 0, 0, 0.247059) 15 -apple-system-find-highlight-background : rgb(255, 2 55, 0)15 -apple-system-find-highlight-background : rgb(255, 204, 0) 16 16 -apple-system-label : rgba(0, 0, 0, 0.85098) 17 17 -apple-system-secondary-label : rgba(0, 0, 0, 0.498039) -
trunk/LayoutTests/fast/text/mark-matches-broken-line-rendering-expected.html
r188527 r233280 7 7 8 8 span { 9 background-color: yellow; 9 background-color: rgb(255, 204, 0); 10 color: -apple-system-label; 10 11 } 11 12 </style> -
trunk/LayoutTests/fast/text/mark-matches-rendering-expected.html
r169199 r233280 1 <p style="display: inline-block; background-color:yellow">1 <p style="display: inline-block; background-color: rgb(255, 204, 0); color: -apple-system-label"> 2 2 Quo usque tandem abutere, Catilina, patientia nostra? 3 3 </p> -
trunk/Source/WebCore/ChangeLog
r233279 r233280 1 2018-06-27 Timothy Hatcher <timothy@apple.com> 2 3 Find on page selection color isn't adapted for dark mode. 4 https://bugs.webkit.org/show_bug.cgi?id=187072 5 rdar://problem/40354841 6 7 Reviewed by Tim Horton. 8 9 * page/mac/TextIndicatorWindow.mm: 10 (-[WebTextIndicatorView initWithFrame:textIndicator:margin:offset:]): Use [NSColor findHighlightColor]. 11 * platform/mac/LocalDefaultSystemAppearance.h: 12 (WebCore::LocalDefaultSystemAppearance::usingDarkAppearance const): Added. 13 * platform/mac/LocalDefaultSystemAppearance.mm: 14 (WebCore::LocalDefaultSystemAppearance::LocalDefaultSystemAppearance): Set m_usingDarkAppearance. 15 * rendering/InlineTextBox.cpp: 16 (WebCore::InlineTextBox::paintPlatformDocumentMarkers): Use TextPaintPhase::Decoration since this 17 matches step three of InlineTextBox::paint ("Paint fancy decorations"). This allows TextMatch to 18 paint a forground and not end up painting during this "fancy decorations" phase. 19 (WebCore::InlineTextBox::resolveStyleForMarkedText): Set the fillColor for TextMarker to force a 20 dark text color which will draw over the yellow highlight. 21 (WebCore::InlineTextBox::collectMarkedTextsForDocumentMarkers): Added support for TextPaintPhase::Decoration. 22 Seperate DocumentMarker::TelephoneNumber and DocumentMarker::TextMatch. Have DocumentMarker::TextMatch 23 support Forground and Background phases. 24 * rendering/RenderTheme.cpp: 25 (WebCore::RenderTheme::platformColorsDidChange): 26 (WebCore::RenderTheme::activeTextSearchHighlightColor const): Added. Call the platfrom version. 27 (WebCore::RenderTheme::inactiveTextSearchHighlightColor const): Added. Ditto. 28 (WebCore::RenderTheme::platformActiveTextSearchHighlightColor const): Added StyleColor::Options. 29 (WebCore::RenderTheme::platformInactiveTextSearchHighlightColor const): Ditto. 30 * rendering/RenderTheme.h: 31 * rendering/RenderThemeMac.h: 32 * rendering/RenderThemeMac.mm: 33 (WebCore::RenderThemeMac::platformActiveTextSearchHighlightColor const): Added. 34 (WebCore::RenderThemeMac::platformInactiveTextSearchHighlightColor const): Added. 35 (WebCore::RenderThemeMac::platformColorsDidChange): Clear new color caches. 36 (WebCore::RenderThemeMac::systemColor const): Cache system colors by light and dark mode. 37 1 38 2018-06-27 Chris Dumez <cdumez@apple.com> 2 39 -
trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm
r232501 r233280 35 35 #import "WebActionDisablingCALayerDelegate.h" 36 36 #import <pal/spi/cg/CoreGraphicsSPI.h> 37 #import <pal/spi/cocoa/NSColorSPI.h> 37 38 #import <pal/spi/cocoa/QuartzCoreSPI.h> 38 39 … … 169 170 RetainPtr<NSMutableArray> bounceLayers = adoptNS([[NSMutableArray alloc] init]); 170 171 171 RetainPtr<CGColorRef> highlightColor = [NSColor colorWithDeviceRed:1 green:1 blue:0 alpha:1].CGColor; 172 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 173 RetainPtr<CGColorRef> highlightColor = [NSColor findHighlightColor].CGColor; 174 #else 175 RetainPtr<CGColorRef> highlightColor = [NSColor colorWithDeviceRed:1 green:0.8 blue:0 alpha:1].CGColor; 176 #endif 172 177 RetainPtr<CGColorRef> rimShadowColor = [NSColor colorWithDeviceWhite:0 alpha:0.35].CGColor; 173 178 RetainPtr<CGColorRef> dropShadowColor = [NSColor colorWithDeviceWhite:0 alpha:0.2].CGColor; -
trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h
r233116 r233280 39 39 class LocalDefaultSystemAppearance { 40 40 WTF_MAKE_NONCOPYABLE(LocalDefaultSystemAppearance); 41 41 42 public: 42 43 WEBCORE_EXPORT LocalDefaultSystemAppearance(bool useSystemAppearance, bool useDefaultAppearance); 43 44 WEBCORE_EXPORT ~LocalDefaultSystemAppearance(); 45 46 bool usingDarkAppearance() const 47 { 48 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 49 return m_usingDarkAppearance; 50 #else 51 return false; 52 #endif 53 } 54 44 55 private: 45 56 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 46 57 RetainPtr<NSAppearance> m_savedSystemAppearance; 58 bool m_usingDarkAppearance { false }; 47 59 #endif 48 60 }; -
trunk/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm
r233116 r233280 43 43 44 44 m_savedSystemAppearance = [NSAppearance currentAppearance]; 45 [NSAppearance setCurrentAppearance:[NSAppearance appearanceNamed:(!useSystemAppearance || useDefaultAppearance ? NSAppearanceNameAqua : NSAppearanceNameDarkAqua)]]; 45 m_usingDarkAppearance = useSystemAppearance && !useDefaultAppearance; 46 47 [NSAppearance setCurrentAppearance:[NSAppearance appearanceNamed:m_usingDarkAppearance ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]]; 46 48 #else 47 49 UNUSED_PARAM(useSystemAppearance); -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r233267 r233280 654 654 void InlineTextBox::paintPlatformDocumentMarkers(GraphicsContext& context, const FloatPoint& boxOrigin) 655 655 { 656 for (auto& markedText : subdivide(collectMarkedTextsForDocumentMarkers(TextPaintPhase:: Foreground), OverlapStrategy::Frontmost))656 for (auto& markedText : subdivide(collectMarkedTextsForDocumentMarkers(TextPaintPhase::Decoration), OverlapStrategy::Frontmost)) 657 657 paintPlatformDocumentMarker(context, boxOrigin, markedText); 658 658 } … … 764 764 break; 765 765 } 766 case MarkedText::TextMatch: 767 style.backgroundColor = markedText.marker->isActiveMatch() ? renderer().theme().platformActiveTextSearchHighlightColor() : renderer().theme().platformInactiveTextSearchHighlightColor(); 766 case MarkedText::TextMatch: { 767 // Text matches always use the light system appearance. 768 OptionSet<StyleColor::Options> styleColorOptions = { StyleColor::Options::UseSystemAppearance, StyleColor::Options::UseDefaultAppearance }; 769 #if PLATFORM(MAC) 770 style.textStyles.fillColor = renderer().theme().systemColor(CSSValueAppleSystemLabel, styleColorOptions); 771 #endif 772 style.backgroundColor = markedText.marker->isActiveMatch() ? renderer().theme().activeTextSearchHighlightColor(styleColorOptions) : renderer().theme().inactiveTextSearchHighlightColor(styleColorOptions); 768 773 break; 774 } 769 775 } 770 776 StyledMarkedText styledMarkedText = markedText; … … 833 839 Vector<MarkedText> InlineTextBox::collectMarkedTextsForDocumentMarkers(TextPaintPhase phase) 834 840 { 835 ASSERT(phase == TextPaintPhase::Background || phase == TextPaintPhase::Foreground); 841 ASSERT_ARG(phase, phase == TextPaintPhase::Background || phase == TextPaintPhase::Foreground || phase == TextPaintPhase::Decoration); 842 836 843 if (!renderer().textNode()) 837 844 return { }; … … 877 884 case DocumentMarker::DictationPhraseWithAlternatives: 878 885 #endif 879 if (phase == TextPaintPhase::Background)886 if (phase != TextPaintPhase::Decoration) 880 887 continue; 881 888 break; … … 883 890 if (!renderer().frame().editor().markedTextMatchesAreHighlighted()) 884 891 continue; 885 #if ENABLE(TELEPHONE_NUMBER_DETECTION) 886 FALLTHROUGH; 887 case DocumentMarker::TelephoneNumber: 888 #endif 889 if (phase == TextPaintPhase::Foreground) 892 if (phase == TextPaintPhase::Decoration) 890 893 continue; 891 894 break; 895 #if ENABLE(TELEPHONE_NUMBER_DETECTION) 896 case DocumentMarker::TelephoneNumber: 897 if (!renderer().frame().editor().markedTextMatchesAreHighlighted()) 898 continue; 899 if (phase != TextPaintPhase::Background) 900 continue; 901 break; 902 #endif 892 903 default: 893 904 continue; -
trunk/Source/WebCore/rendering/RenderTheme.cpp
r232486 r233280 1159 1159 m_inactiveListBoxSelectionForegroundColor = Color(); 1160 1160 1161 m_activeTextSearchHighlightColor = Color(); 1162 m_inactiveTextSearchHighlightColor = Color(); 1163 1161 1164 Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment(); 1162 1165 } … … 1284 1287 } 1285 1288 1286 Color RenderTheme::platformActiveTextSearchHighlightColor() const 1289 Color RenderTheme::activeTextSearchHighlightColor(OptionSet<StyleColor::Options> options) const 1290 { 1291 if (!m_activeTextSearchHighlightColor.isValid()) 1292 m_activeTextSearchHighlightColor = platformActiveTextSearchHighlightColor(options); 1293 return m_activeTextSearchHighlightColor; 1294 } 1295 1296 Color RenderTheme::inactiveTextSearchHighlightColor(OptionSet<StyleColor::Options> options) const 1297 { 1298 if (!m_inactiveTextSearchHighlightColor.isValid()) 1299 m_inactiveTextSearchHighlightColor = platformInactiveTextSearchHighlightColor(options); 1300 return m_inactiveTextSearchHighlightColor; 1301 } 1302 1303 Color RenderTheme::platformActiveTextSearchHighlightColor(OptionSet<StyleColor::Options>) const 1287 1304 { 1288 1305 return Color(255, 150, 50); // Orange. 1289 1306 } 1290 1307 1291 Color RenderTheme::platformInactiveTextSearchHighlightColor( ) const1308 Color RenderTheme::platformInactiveTextSearchHighlightColor(OptionSet<StyleColor::Options>) const 1292 1309 { 1293 1310 return Color(255, 255, 0); // Yellow. -
trunk/Source/WebCore/rendering/RenderTheme.h
r232486 r233280 145 145 Color inactiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options>) const; 146 146 147 // Highlighting colors for TextMatches.148 virtual Color platformActiveTextSearchHighlightColor() const;149 virtual Color platformInactiveTextSearchHighlightColor() const;147 // Highlighting colors for search matches. 148 Color activeTextSearchHighlightColor(OptionSet<StyleColor::Options>) const; 149 Color inactiveTextSearchHighlightColor(OptionSet<StyleColor::Options>) const; 150 150 151 151 virtual Color disabledTextColor(const Color& textColor, const Color& backgroundColor) const; … … 265 265 virtual Color platformActiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options>) const; 266 266 virtual Color platformInactiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options>) const; 267 268 // The platform highlighting colors for search matches. 269 virtual Color platformActiveTextSearchHighlightColor(OptionSet<StyleColor::Options>) const; 270 virtual Color platformInactiveTextSearchHighlightColor(OptionSet<StyleColor::Options>) const; 267 271 268 272 virtual bool supportsSelectionForegroundColors() const { return true; } … … 405 409 mutable Color m_activeListBoxSelectionForegroundColor; 406 410 mutable Color m_inactiveListBoxSelectionForegroundColor; 411 412 mutable Color m_activeTextSearchHighlightColor; 413 mutable Color m_inactiveTextSearchHighlightColor; 407 414 }; 408 415 -
trunk/Source/WebCore/rendering/RenderThemeMac.h
r232486 r233280 63 63 Color platformInactiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options>) const final; 64 64 Color platformFocusRingColor(OptionSet<StyleColor::Options>) const final; 65 Color platformActiveTextSearchHighlightColor(OptionSet<StyleColor::Options>) const final; 66 Color platformInactiveTextSearchHighlightColor(OptionSet<StyleColor::Options>) const final; 65 67 66 68 ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) final { return SmallScrollbar; } … … 243 245 bool m_isSliderThumbVerticalPressed { false }; 244 246 245 mutable HashMap<int, Color> m_systemColorCache; 246 mutable Color m_systemVisitedLinkColor; 247 mutable HashMap<int, Color> m_lightSystemColorCache; 248 mutable HashMap<int, Color> m_darkSystemColorCache; 249 mutable Color m_lightSystemVisitedLinkColor; 250 mutable Color m_darkSystemVisitedLinkColor; 247 251 248 252 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver; -
trunk/Source/WebCore/rendering/RenderThemeMac.mm
r232892 r233280 392 392 } 393 393 394 Color RenderThemeMac::platformActiveTextSearchHighlightColor(OptionSet<StyleColor::Options> options) const 395 { 396 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 397 LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDefaultAppearance)); 398 return colorFromNSColor([NSColor findHighlightColor]); 399 #else 400 UNUSED_PARAM(options); 401 return Color(255, 204, 0); // Yellow. 402 #endif 403 } 404 405 Color RenderThemeMac::platformInactiveTextSearchHighlightColor(OptionSet<StyleColor::Options> options) const 406 { 407 // The inactive color is normally used, since no legacy WebKit client marks a text match as active. 408 // So just return the same color for both states. 409 return platformActiveTextSearchHighlightColor(options); 410 } 411 394 412 static FontSelectionValue toFontWeight(NSInteger appKitFontWeight) 395 413 { … … 487 505 void RenderThemeMac::platformColorsDidChange() 488 506 { 489 m_systemColorCache.clear(); 490 m_systemVisitedLinkColor = Color(); 507 m_lightSystemColorCache.clear(); 508 m_darkSystemColorCache.clear(); 509 510 m_lightSystemVisitedLinkColor = Color(); 511 m_darkSystemVisitedLinkColor = Color(); 512 491 513 RenderTheme::platformColorsDidChange(); 492 514 } … … 505 527 // Only use NSColor when the system appearance is desired, otherwise use RenderTheme's default. 506 528 if (useSystemAppearance) { 507 if (!m_systemVisitedLinkColor.isValid()) 508 m_systemVisitedLinkColor = semanticColorFromNSColor([NSColor systemPurpleColor]); 509 return m_systemVisitedLinkColor; 529 if (localAppearance.usingDarkAppearance()) { 530 if (!m_darkSystemVisitedLinkColor.isValid()) 531 m_darkSystemVisitedLinkColor = semanticColorFromNSColor([NSColor systemPurpleColor]); 532 return m_darkSystemVisitedLinkColor; 533 } 534 535 if (!m_lightSystemVisitedLinkColor.isValid()) 536 m_lightSystemVisitedLinkColor = semanticColorFromNSColor([NSColor systemPurpleColor]); 537 return m_lightSystemVisitedLinkColor; 510 538 } 511 539 … … 515 543 ASSERT(!forVisitedLink); 516 544 517 return m_systemColorCache.ensure(cssValueID, [this, cssValueID, useSystemAppearance, options] () -> Color { 545 auto& systemColorCache = localAppearance.usingDarkAppearance() ? m_darkSystemColorCache : m_lightSystemColorCache; 546 return systemColorCache.ensure(cssValueID, [this, cssValueID, useSystemAppearance, options] () -> Color { 518 547 auto selectCocoaColor = [cssValueID, useSystemAppearance] () -> SEL { 519 548 switch (cssValueID) { … … 623 652 return @selector(findHighlightColor); 624 653 #else 625 return @selector(systemYellowColor); 654 // Handled below. 655 return nullptr; 626 656 #endif 627 657 case CSSValueAppleSystemLabel: … … 689 719 return menuBackgroundColor(); 690 720 721 #if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300 722 case CSSValueAppleSystemFindHighlightBackground: 723 return platformActiveTextSearchHighlightColor(options); 724 #endif 725 691 726 case CSSValueAppleSystemEvenAlternatingContentBackground: { 692 727 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
Note: See TracChangeset
for help on using the changeset viewer.