Use the system's link color when system appearance is desired for a WebView.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Apr 2018 08:35:00 +0000 (08:35 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Apr 2018 08:35:00 +0000 (08:35 +0000)
commite758cfabe8072b58d3613914b2c743e863f93dc5
tree1d2891bd8c4ffe77df3aa44cbc83f654e2e9fe60
parent3988ea5e1913a5b89f1f32b1cc9a009245ef191b
Use the system's link color when system appearance is desired for a WebView.

https://bugs.webkit.org/show_bug.cgi?id=184353
rdar://problem/9420053

Reviewed by Wenson Hsieh.

Source/WebCore:

Have Document consult RenderTheme via StyleColor for the various link colors.
This allows the system to have different colors than the standard hardcoded ones.
This adds StyleColor::Options, to avoid multiple booleans being passed around,
since the "for visited link" state is now needed in RenderTheme.

* WebCore.xcodeproj/project.pbxproj: Made StyleColor.h private, since RenderTheme.h includes it.
* css/StyleColor.cpp:
(WebCore::StyleColor::colorFromKeyword): Use options instead of a bool.
(WebCore::StyleColor::isSystemColor): Consider CSSValueWebkitLink the start of system colors.
* css/StyleColor.h:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::colorFromPrimitiveValue const): Use StyleColor::Options.
* css/parser/CSSParser.cpp:
(WebCore::CSSParser::parseSystemColor): Use StyleColor::Options.
* dom/Document.cpp:
(WebCore::Document::resetLinkColor): Ask StyleColor for the link color instead of hardcoding it.
(WebCore::Document::resetVisitedLinkColor): Ditto.
(WebCore::Document::resetActiveLinkColor): Ditto.
(WebCore::Document::styleColorOptions const): Added. Helper to get the options used.
* dom/Document.h:
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::drawFocusIfNeededInternal): Use StyleColor::Options.
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::systemColor const): Add default values here, moved from Document.
(WebCore::RenderTheme::focusRingColor): Use StyleColor::Options.
* rendering/RenderTheme.h:
(WebCore::RenderTheme::platformFocusRingColor const): Use StyleColor::Options.
* rendering/RenderThemeGtk.cpp:
(WebCore::RenderThemeGtk::systemColor const): Use StyleColor::Options.
* rendering/RenderThemeGtk.h:
* rendering/RenderThemeIOS.h:
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::systemColor const): Use StyleColor::Options.
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::platformFocusRingColor const): Use StyleColor::Options.
(WebCore::RenderThemeMac::platformColorsDidChange): Clear m_systemVisitedLinkColor.
(WebCore::RenderThemeMac::systemColor const): Use StyleColor::Options.
(WebCore::RenderThemeMac::adjustMenuListStyle const): Ditto.
* rendering/RenderThemeWin.cpp:
(WebCore::RenderThemeWin::systemColor const): Use StyleColor::Options.
* rendering/RenderThemeWin.h:
* rendering/TextPaintStyle.cpp:
(WebCore::computeTextPaintStyle): Use StyleColor::Options.

Source/WebCore/PAL:

* pal/spi/cocoa/NSColorSPI.h: Added linkColor.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm: Added.
(TestWebKitAPI::WebKit::LinkColor):
(TestWebKitAPI::WebKit::LinkColorWithSystemAppearance):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230368 268f45cc-cd09-0410-ab3c-d52691b4dbfc
25 files changed:
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/cocoa/NSColorSPI.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/StyleColor.cpp
Source/WebCore/css/StyleColor.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/parser/CSSParser.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeGtk.cpp
Source/WebCore/rendering/RenderThemeGtk.h
Source/WebCore/rendering/RenderThemeIOS.h
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebCore/rendering/RenderThemeMac.h
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebCore/rendering/RenderThemeWin.cpp
Source/WebCore/rendering/RenderThemeWin.h
Source/WebCore/rendering/TextPaintStyle.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm [new file with mode: 0644]