Changeset 230368 in webkit
- Timestamp:
- Apr 7, 2018 1:35:00 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 24 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r230365 r230368 1 2018-04-07 Timothy Hatcher <timothy@apple.com> 2 3 Use the system's link color when system appearance is desired for a WebView. 4 5 https://bugs.webkit.org/show_bug.cgi?id=184353 6 rdar://problem/9420053 7 8 Reviewed by Wenson Hsieh. 9 10 Have Document consult RenderTheme via StyleColor for the various link colors. 11 This allows the system to have different colors than the standard hardcoded ones. 12 This adds StyleColor::Options, to avoid multiple booleans being passed around, 13 since the "for visited link" state is now needed in RenderTheme. 14 15 * WebCore.xcodeproj/project.pbxproj: Made StyleColor.h private, since RenderTheme.h includes it. 16 * css/StyleColor.cpp: 17 (WebCore::StyleColor::colorFromKeyword): Use options instead of a bool. 18 (WebCore::StyleColor::isSystemColor): Consider CSSValueWebkitLink the start of system colors. 19 * css/StyleColor.h: 20 * css/StyleResolver.cpp: 21 (WebCore::StyleResolver::colorFromPrimitiveValue const): Use StyleColor::Options. 22 * css/parser/CSSParser.cpp: 23 (WebCore::CSSParser::parseSystemColor): Use StyleColor::Options. 24 * dom/Document.cpp: 25 (WebCore::Document::resetLinkColor): Ask StyleColor for the link color instead of hardcoding it. 26 (WebCore::Document::resetVisitedLinkColor): Ditto. 27 (WebCore::Document::resetActiveLinkColor): Ditto. 28 (WebCore::Document::styleColorOptions const): Added. Helper to get the options used. 29 * dom/Document.h: 30 * html/canvas/CanvasRenderingContext2D.cpp: 31 (WebCore::CanvasRenderingContext2D::drawFocusIfNeededInternal): Use StyleColor::Options. 32 * rendering/RenderTheme.cpp: 33 (WebCore::RenderTheme::systemColor const): Add default values here, moved from Document. 34 (WebCore::RenderTheme::focusRingColor): Use StyleColor::Options. 35 * rendering/RenderTheme.h: 36 (WebCore::RenderTheme::platformFocusRingColor const): Use StyleColor::Options. 37 * rendering/RenderThemeGtk.cpp: 38 (WebCore::RenderThemeGtk::systemColor const): Use StyleColor::Options. 39 * rendering/RenderThemeGtk.h: 40 * rendering/RenderThemeIOS.h: 41 * rendering/RenderThemeIOS.mm: 42 (WebCore::RenderThemeIOS::systemColor const): Use StyleColor::Options. 43 * rendering/RenderThemeMac.h: 44 * rendering/RenderThemeMac.mm: 45 (WebCore::RenderThemeMac::platformFocusRingColor const): Use StyleColor::Options. 46 (WebCore::RenderThemeMac::platformColorsDidChange): Clear m_systemVisitedLinkColor. 47 (WebCore::RenderThemeMac::systemColor const): Use StyleColor::Options. 48 (WebCore::RenderThemeMac::adjustMenuListStyle const): Ditto. 49 * rendering/RenderThemeWin.cpp: 50 (WebCore::RenderThemeWin::systemColor const): Use StyleColor::Options. 51 * rendering/RenderThemeWin.h: 52 * rendering/TextPaintStyle.cpp: 53 (WebCore::computeTextPaintStyle): Use StyleColor::Options. 54 1 55 2018-04-06 Youenn Fablet <youenn@apple.com> 2 56 -
trunk/Source/WebCore/PAL/ChangeLog
r230311 r230368 1 2018-04-07 Timothy Hatcher <timothy@apple.com> 2 3 Use the system's link color when system appearance is desired for a WebView. 4 5 https://bugs.webkit.org/show_bug.cgi?id=184353 6 rdar://problem/9420053 7 8 Reviewed by Wenson Hsieh. 9 10 * pal/spi/cocoa/NSColorSPI.h: Added linkColor. 11 1 12 2018-04-05 John Wilander <wilander@apple.com> 2 13 -
trunk/Source/WebCore/PAL/pal/spi/cocoa/NSColorSPI.h
r220506 r230368 42 42 + (NSColor *)systemPurpleColor; 43 43 + (NSColor *)systemGrayColor; 44 + (NSColor *)linkColor; 44 45 @end 45 46 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r230279 r230368 2607 2607 93F9B7A10BA6032600854064 /* JSCDATASection.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F9B79F0BA6032600854064 /* JSCDATASection.h */; }; 2608 2608 93FDAFCA0B11307400E2746F /* EditorInsertAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 93FDAFC90B11307400E2746F /* EditorInsertAction.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2609 9418278B1D8B244000492764 /* StyleColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 941827891D8B242200492764 /* StyleColor.h */; };2609 9418278B1D8B244000492764 /* StyleColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 941827891D8B242200492764 /* StyleColor.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2610 2610 9418278F1D8CAF9200492764 /* CSSPendingSubstitutionValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9418278D1D8CAE9500492764 /* CSSPendingSubstitutionValue.h */; }; 2611 2611 9444CBD41D860C8B0073A074 /* SizesCalcParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 9444CBCF1D860C740073A074 /* SizesCalcParser.h */; }; -
trunk/Source/WebCore/css/StyleColor.cpp
r230056 r230368 38 38 namespace WebCore { 39 39 40 Color StyleColor::colorFromKeyword(CSSValueID keyword, bool useSystemAppearance)40 Color StyleColor::colorFromKeyword(CSSValueID keyword, OptionSet<Options> options) 41 41 { 42 42 if (const char* valueName = getValueName(keyword)) { … … 44 44 return Color(namedColor->ARGBValue); 45 45 } 46 return RenderTheme::singleton().systemColor(keyword, useSystemAppearance); 46 47 return RenderTheme::singleton().systemColor(keyword, options); 47 48 } 48 49 … … 54 55 bool StyleColor::isSystemColor(CSSValueID id) 55 56 { 56 return (id >= CSSValue Activeborder&& id <= CSSValueWebkitFocusRingColor) || id == CSSValueMenu || id == CSSValueText;57 return (id >= CSSValueWebkitLink && id <= CSSValueWebkitFocusRingColor) || id == CSSValueMenu || id == CSSValueText; 57 58 } 58 59 -
trunk/Source/WebCore/css/StyleColor.h
r229448 r230368 34 34 #include "CSSValueKeywords.h" 35 35 #include "Color.h" 36 #include <wtf/OptionSet.h> 36 37 37 38 namespace WebCore { … … 51 52 const Color& resolve(const Color& currentColor) const { return m_currentColor ? currentColor : m_color; } 52 53 53 static Color colorFromKeyword(CSSValueID, bool useSystemAppearance); 54 enum class Options : uint8_t { 55 ForVisitedLink = 1 << 0, 56 UseSystemAppearance = 1 << 1 57 }; 58 59 static Color colorFromKeyword(CSSValueID, OptionSet<Options>); 54 60 static bool isColorKeyword(CSSValueID); 55 61 static bool isSystemColor(CSSValueID); -
trunk/Source/WebCore/css/StyleResolver.cpp
r230100 r230368 1830 1830 return document().activeLinkColor(); 1831 1831 case CSSValueWebkitFocusRingColor: 1832 return RenderTheme::focusRingColor(document(). useSystemAppearance());1832 return RenderTheme::focusRingColor(document().styleColorOptions()); 1833 1833 case CSSValueCurrentcolor: 1834 1834 // Color is an inherited property so depending on it effectively makes the property inherited. … … 1837 1837 return m_state.style()->color(); 1838 1838 default: 1839 return StyleColor::colorFromKeyword(identifier, document(). useSystemAppearance());1839 return StyleColor::colorFromKeyword(identifier, document().styleColorOptions()); 1840 1840 } 1841 1841 } -
trunk/Source/WebCore/css/parser/CSSParser.cpp
r229654 r230368 182 182 if (!StyleColor::isSystemColor(id)) 183 183 return Color(); 184 if (context) 185 return RenderTheme::singleton().systemColor(id, context.value().useSystemAppearance); 186 return RenderTheme::singleton().systemColor(id, false); 184 185 OptionSet<StyleColor::Options> options; 186 if (context && context.value().useSystemAppearance) 187 options |= StyleColor::Options::UseSystemAppearance; 188 return RenderTheme::singleton().systemColor(id, options); 187 189 } 188 190 -
trunk/Source/WebCore/dom/Document.cpp
r230290 r230368 190 190 #include "StorageEvent.h" 191 191 #include "StringCallback.h" 192 #include "StyleColor.h" 192 193 #include "StyleProperties.h" 193 194 #include "StyleResolveForDocument.h" … … 802 803 void Document::resetLinkColor() 803 804 { 804 m_linkColor = Color(0, 0, 238);805 m_linkColor = StyleColor::colorFromKeyword(CSSValueWebkitLink, styleColorOptions()); 805 806 } 806 807 807 808 void Document::resetVisitedLinkColor() 808 809 { 809 m_visitedLinkColor = Color(85, 26, 139);810 m_visitedLinkColor = StyleColor::colorFromKeyword(CSSValueWebkitLink, styleColorOptions() | StyleColor::Options::ForVisitedLink); 810 811 } 811 812 812 813 void Document::resetActiveLinkColor() 813 814 { 814 m_activeLinkColor = Color(255, 0, 0);815 m_activeLinkColor = StyleColor::colorFromKeyword(CSSValueWebkitActivelink, styleColorOptions()); 815 816 } 816 817 … … 7028 7029 return deviceScaleFactor; 7029 7030 } 7030 7031 7031 7032 bool Document::useSystemAppearance() const 7032 7033 { … … 7036 7037 return useSystemAppearance; 7037 7038 } 7038 7039 7040 OptionSet<StyleColor::Options> Document::styleColorOptions() const 7041 { 7042 OptionSet<StyleColor::Options> options; 7043 if (useSystemAppearance()) 7044 options |= StyleColor::Options::UseSystemAppearance; 7045 return options; 7046 } 7047 7039 7048 void Document::didAssociateFormControl(Element* element) 7040 7049 { -
trunk/Source/WebCore/dom/Document.h
r230226 r230368 46 46 #include "ScriptExecutionContext.h" 47 47 #include "StringWithDirection.h" 48 #include "StyleColor.h" 48 49 #include "Supplementable.h" 49 50 #include "TextResourceDecoder.h" … … 544 545 545 546 float deviceScaleFactor() const; 546 547 547 548 bool useSystemAppearance() const; 549 OptionSet<StyleColor::Options> styleColorOptions() const; 548 550 549 551 WEBCORE_EXPORT Ref<Range> createRange(); -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r229448 r230368 85 85 if (!element.focused() || !state().hasInvertibleTransform || path.isEmpty() || !element.isDescendantOf(canvas()) || !context) 86 86 return; 87 context->drawFocusRing(path, 1, 1, RenderTheme::focusRingColor(element.document(). useSystemAppearance()));87 context->drawFocusRing(path, 1, 1, RenderTheme::focusRingColor(element.document().styleColorOptions())); 88 88 } 89 89 -
trunk/Source/WebCore/rendering/RenderTheme.cpp
r229448 r230368 1209 1209 } 1210 1210 1211 Color RenderTheme::systemColor(CSSValueID cssValueId, bool useSystemAppearance) const 1212 { 1213 UNUSED_PARAM(useSystemAppearance); 1214 1211 Color RenderTheme::systemColor(CSSValueID cssValueId, OptionSet<StyleColor::Options> options) const 1212 { 1215 1213 switch (cssValueId) { 1214 case CSSValueWebkitLink: 1215 return options.contains(StyleColor::Options::ForVisitedLink) ? 0xFF551A8B : 0xFF0000EE; 1216 case CSSValueWebkitActivelink: 1217 return 0xFFFF0000; 1216 1218 case CSSValueActiveborder: 1217 1219 return 0xFFFFFFFF; … … 1328 1330 } 1329 1331 1330 Color RenderTheme::focusRingColor( bool useSystemAppearance)1331 { 1332 return customFocusRingColor().isValid() ? customFocusRingColor() : RenderTheme::singleton().platformFocusRingColor( useSystemAppearance);1332 Color RenderTheme::focusRingColor(OptionSet<StyleColor::Options> options) 1333 { 1334 return customFocusRingColor().isValid() ? customFocusRingColor() : RenderTheme::singleton().platformFocusRingColor(options); 1333 1335 } 1334 1336 -
trunk/Source/WebCore/rendering/RenderTheme.h
r229448 r230368 25 25 #include "PopupMenuStyle.h" 26 26 #include "ScrollTypes.h" 27 #include "StyleColor.h" 27 28 #include "ThemeTypes.h" 28 29 … … 150 151 virtual Color disabledTextColor(const Color& textColor, const Color& backgroundColor) const; 151 152 152 static Color focusRingColor( bool useSystemAppearance);153 virtual Color platformFocusRingColor( bool) const { return Color(0, 0, 0); }153 static Color focusRingColor(OptionSet<StyleColor::Options>); 154 virtual Color platformFocusRingColor(OptionSet<StyleColor::Options>) const { return Color(0, 0, 0); } 154 155 static void setCustomFocusRingColor(const Color&); 155 156 static float platformFocusRingWidth() { return 3; } … … 165 166 // System fonts and colors for CSS. 166 167 void systemFont(CSSValueID, FontCascadeDescription&) const; 167 virtual Color systemColor(CSSValueID, bool useSystemAppearance) const;168 virtual Color systemColor(CSSValueID, OptionSet<StyleColor::Options>) const; 168 169 169 170 virtual int minimumMenuListSize(const RenderStyle&) const { return 0; } -
trunk/Source/WebCore/rendering/RenderThemeGtk.cpp
r229448 r230368 1757 1757 } 1758 1758 1759 Color RenderThemeGtk::systemColor(CSSValueID cssValueId, bool) const1759 Color RenderThemeGtk::systemColor(CSSValueID cssValueId, OptionSet<StyleColor::Options> options) const 1760 1760 { 1761 1761 switch (cssValueId) { … … 1765 1765 return styleColor(Entry, GTK_STATE_FLAG_ACTIVE, StyleColorForeground); 1766 1766 default: 1767 return RenderTheme::systemColor(cssValueId, false);1767 return RenderTheme::systemColor(cssValueId, options); 1768 1768 } 1769 1769 } -
trunk/Source/WebCore/rendering/RenderThemeGtk.h
r229448 r230368 87 87 88 88 // System colors. 89 Color systemColor(CSSValueID, bool) const override;89 Color systemColor(CSSValueID, OptionSet<StyleColor::Options>) const override; 90 90 91 91 bool popsMenuBySpaceOrReturn() const override { return true; } -
trunk/Source/WebCore/rendering/RenderThemeIOS.h
r229448 r230368 136 136 FloatRect addRoundedBorderClip(const RenderObject& box, GraphicsContext&, const IntRect&); 137 137 138 Color systemColor(CSSValueID, bool) const override;138 Color systemColor(CSSValueID, OptionSet<StyleColor::Options>) const override; 139 139 140 140 String m_legacyMediaControlsScript; -
trunk/Source/WebCore/rendering/RenderThemeIOS.mm
r230039 r230368 1398 1398 #endif // ENABLE(VIDEO) 1399 1399 1400 Color RenderThemeIOS::systemColor(CSSValueID cssValueID, bool) const 1401 { 1400 Color RenderThemeIOS::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::Options> options) const 1401 { 1402 const bool forVisitedLink = options.contains(StyleColor::Options::ForVisitedLink); 1403 1404 // The system color cache below can't handle visited links. The only color value 1405 // that cares about visited links is CSSValueWebkitLink, so handle it here by 1406 // calling through to RenderTheme's base implementation. 1407 if (forVisitedLink && cssValueID == CSSValueWebkitLink) 1408 return RenderTheme::systemColor(cssValueID, options); 1409 1410 ASSERT(!forVisitedLink); 1411 1402 1412 auto addResult = m_systemColorCache.add(cssValueID, Color()); 1403 1413 if (!addResult.isNewEntry) … … 1435 1445 1436 1446 if (!color.isValid()) 1437 color = RenderTheme::systemColor(cssValueID, false);1447 color = RenderTheme::systemColor(cssValueID, options); 1438 1448 1439 1449 addResult.iterator->value = color; -
trunk/Source/WebCore/rendering/RenderThemeMac.h
r229448 r230368 60 60 Color platformInactiveListBoxSelectionBackgroundColor(bool) const final; 61 61 Color platformInactiveListBoxSelectionForegroundColor() const final; 62 Color platformFocusRingColor( bool useSystemAppearance) const final;62 Color platformFocusRingColor(OptionSet<StyleColor::Options>) const final; 63 63 64 64 ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) final { return SmallScrollbar; } … … 170 170 String fileListNameForWidth(const FileList*, const FontCascade&, int width, bool multipleFilesAllowed) const final; 171 171 172 Color systemColor(CSSValueID, bool useSystemAppearance) const final;172 Color systemColor(CSSValueID, OptionSet<StyleColor::Options>) const final; 173 173 174 174 void purgeCaches() final; … … 244 244 245 245 mutable HashMap<int, Color> m_systemColorCache; 246 mutable Color m_systemVisitedLinkColor; 246 247 247 248 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver; -
trunk/Source/WebCore/rendering/RenderThemeMac.mm
r230064 r230368 316 316 } 317 317 318 Color RenderThemeMac::platformFocusRingColor( bool useSystemAppearance) const318 Color RenderThemeMac::platformFocusRingColor(OptionSet<StyleColor::Options> options) const 319 319 { 320 320 if (usesTestModeFocusRingColor()) 321 321 return oldAquaFocusRingColor(); 322 323 return systemColor(CSSValueWebkitFocusRingColor, useSystemAppearance); 322 return systemColor(CSSValueWebkitFocusRingColor, options); 324 323 } 325 324 … … 426 425 { 427 426 m_systemColorCache.clear(); 427 m_systemVisitedLinkColor = Color(); 428 428 RenderTheme::platformColorsDidChange(); 429 429 } 430 430 431 Color RenderThemeMac::systemColor(CSSValueID cssValueID, bool useSystemAppearance) const 432 { 431 Color RenderThemeMac::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::Options> options) const 432 { 433 const bool useSystemAppearance = options.contains(StyleColor::Options::UseSystemAppearance); 434 const bool forVisitedLink = options.contains(StyleColor::Options::ForVisitedLink); 435 433 436 LocalDefaultSystemAppearance localAppearance(useSystemAppearance); 434 return m_systemColorCache.ensure(cssValueID, [this, cssValueID, useSystemAppearance] () -> Color { 435 auto selectCocoaColor = [cssValueID] () -> SEL { 437 438 // The system color cache below can't handle visited links. The only color value 439 // that cares about visited links is CSSValueWebkitLink, so handle it here. 440 if (forVisitedLink && cssValueID == CSSValueWebkitLink) { 441 // Only use NSColor when the system appearance is desired, otherwise use RenderTheme's default. 442 if (useSystemAppearance) { 443 if (!m_systemVisitedLinkColor.isValid()) 444 m_systemVisitedLinkColor = colorFromNSColor([NSColor systemPurpleColor]); 445 return m_systemVisitedLinkColor; 446 } 447 448 return RenderTheme::systemColor(cssValueID, options); 449 } 450 451 ASSERT(!forVisitedLink); 452 453 return m_systemColorCache.ensure(cssValueID, [this, cssValueID, useSystemAppearance, options] () -> Color { 454 auto selectCocoaColor = [cssValueID, useSystemAppearance] () -> SEL { 436 455 switch (cssValueID) { 456 case CSSValueWebkitLink: 457 // Only use NSColor when the system appearance is desired, otherwise use RenderTheme's default. 458 return useSystemAppearance ? @selector(linkColor) : nullptr; 459 case CSSValueWebkitActivelink: 460 // Only use NSColor when the system appearance is desired, otherwise use RenderTheme's default. 461 // FIXME: Use a semantic system color for this, instead of systemRedColor. <rdar://problem/39256684> 462 return useSystemAppearance ? @selector(systemRedColor) : nullptr; 437 463 case CSSValueActiveborder: 438 464 return @selector(keyboardFocusIndicatorColor); … … 525 551 } 526 552 }; 553 527 554 if (auto selector = selectCocoaColor()) { 528 555 if (auto color = wtfObjcMsgSend<NSColor *>([NSColor class], selector)) 529 556 return colorFromNSColor(color); 530 557 } 558 531 559 switch (cssValueID) { 532 560 case CSSValueActivebuttontext: … … 547 575 FALLTHROUGH; 548 576 default: 549 return RenderTheme::systemColor(cssValueID, useSystemAppearance);577 return RenderTheme::systemColor(cssValueID, options); 550 578 } 551 579 }).iterator->value; … … 1298 1326 Color c = Color::darkGray; 1299 1327 if (e) { 1300 bool useSystemAppearance = e->document().page()->useSystemAppearance();1301 c = !e->isDisabledFormControl() ? systemColor(CSSValueButtontext, useSystemAppearance) : systemColor(CSSValueGraytext, useSystemAppearance);1328 OptionSet<StyleColor::Options> options = e->document().styleColorOptions(); 1329 c = !e->isDisabledFormControl() ? systemColor(CSSValueButtontext, options) : systemColor(CSSValueGraytext, options); 1302 1330 } 1303 1331 style.setColor(c); -
trunk/Source/WebCore/rendering/RenderThemeWin.cpp
r229448 r230368 1013 1013 } 1014 1014 1015 Color RenderThemeWin::systemColor(CSSValueID cssValueId, bool) const1015 Color RenderThemeWin::systemColor(CSSValueID cssValueId, OptionSet<StyleColor::Options> options) const 1016 1016 { 1017 1017 int sysColorIndex = cssValueIdToSysColorIndex(cssValueId); 1018 1018 if (sysColorIndex == -1) 1019 return RenderTheme::systemColor(cssValueId, false);1019 return RenderTheme::systemColor(cssValueId, options); 1020 1020 1021 1021 COLORREF color = GetSysColor(sysColorIndex); -
trunk/Source/WebCore/rendering/RenderThemeWin.h
r229448 r230368 60 60 Color platformInactiveSelectionForegroundColor() const override; 61 61 62 Color systemColor(CSSValueID, bool) const override;62 Color systemColor(CSSValueID, OptionSet<StyleColor::Options>) const override; 63 63 64 64 bool paintCheckbox(const RenderObject& o, const PaintInfo& i, const IntRect& r) override -
trunk/Source/WebCore/rendering/TextPaintStyle.cpp
r229510 r230368 99 99 Page* page = frame.page(); 100 100 if (page && page->focusController().isActive()) { 101 paintStyle.fillColor = RenderTheme::singleton().systemColor(CSSValueActivebuttontext, page->useSystemAppearance()); 101 OptionSet<StyleColor::Options> options; 102 if (page->useSystemAppearance()) 103 options |= StyleColor::Options::UseSystemAppearance; 104 paintStyle.fillColor = RenderTheme::singleton().systemColor(CSSValueActivebuttontext, options); 102 105 return paintStyle; 103 106 } -
trunk/Tools/ChangeLog
r230366 r230368 1 2018-04-07 Timothy Hatcher <timothy@apple.com> 2 3 Use the system's link color when system appearance is desired for a WebView. 4 5 https://bugs.webkit.org/show_bug.cgi?id=184353 6 rdar://problem/9420053 7 8 Reviewed by Wenson Hsieh. 9 10 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 11 * TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm: Added. 12 (TestWebKitAPI::WebKit::LinkColor): 13 (TestWebKitAPI::WebKit::LinkColorWithSystemAppearance): 14 1 15 2018-04-06 Zalan Bujtas <zalan@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r230099 r230368 63 63 1C2B81861C89259D00A5529F /* webfont.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C2B81841C8924A200A5529F /* webfont.html */; }; 64 64 1C2B81871C8925A000A5529F /* Ahem.ttf in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C2B81851C89252300A5529F /* Ahem.ttf */; }; 65 1C734B5320788C4800F430EA /* SystemColors.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C734B5220788C4800F430EA /* SystemColors.mm */; }; 65 66 1C9EB8411E380DA1005C6442 /* ComplexTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */; }; 66 67 1CAD1F861E5CE7DA00AF2C2C /* FontCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD1F851E5CE7DA00AF2C2C /* FontCache.cpp */; }; … … 1185 1186 1C2B81841C8924A200A5529F /* webfont.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = webfont.html; sourceTree = "<group>"; }; 1186 1187 1C2B81851C89252300A5529F /* Ahem.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = Ahem.ttf; sourceTree = "<group>"; }; 1188 1C734B5220788C4800F430EA /* SystemColors.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemColors.mm; sourceTree = "<group>"; }; 1187 1189 1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextController.cpp; sourceTree = "<group>"; }; 1188 1190 1CAD1F851E5CE7DA00AF2C2C /* FontCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontCache.cpp; sourceTree = "<group>"; }; … … 2218 2220 2DFF7B6C1DA487AF00814614 /* SnapshotStore.mm */, 2219 2221 515BE1701D428BD100DD7C68 /* StoreBlobThenDelete.mm */, 2222 1C734B5220788C4800F430EA /* SystemColors.mm */, 2220 2223 5CB40B4D1F4B98BE007DC7B9 /* UIDelegate.mm */, 2221 2224 7CC3E1FA197E234100BE6252 /* UserContentController.mm */, … … 3711 3714 7CCE7ED21A411A7E00447C4C /* SubresourceErrorCrash.mm in Sources */, 3712 3715 7CCE7EA81A411A1900447C4C /* SyntheticBackingScaleFactorWindow.m in Sources */, 3716 1C734B5320788C4800F430EA /* SystemColors.mm in Sources */, 3713 3717 7CCE7F161A411AE600447C4C /* TerminateTwice.cpp in Sources */, 3714 3718 7CCE7EA91A411A1D00447C4C /* TestBrowsingContextLoadDelegate.mm in Sources */, -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SystemColors.mm
r230367 r230368 1 1 /* 2 * Copyright (C) 201 5Apple Inc. All rights reserved.2 * Copyright (C) 2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #i mport <AppKit/NSColor.h>26 #include "config.h" 27 27 28 #if PLATFORM(MAC) && USE(APPLE_INTERNAL_SDK)28 #if WK_API_ENABLED 29 29 30 #import <AppKit/NSColor_Private.h> 30 #import "PlatformUtilities.h" 31 #import "TestWKWebView.h" 32 #import <WebKit/WKWebViewPrivate.h> 33 #import <wtf/RetainPtr.h> 31 34 32 #else 35 namespace TestWebKitAPI { 33 36 34 @interface NSColor () 35 + (NSColor *)systemRedColor; 36 + (NSColor *)systemGreenColor; 37 + (NSColor *)systemBlueColor; 38 + (NSColor *)systemOrangeColor; 39 + (NSColor *)systemYellowColor; 40 + (NSColor *)systemBrownColor; 41 + (NSColor *)systemPinkColor; 42 + (NSColor *)systemPurpleColor; 43 + (NSColor *)systemGrayColor; 44 @end 37 TEST(WebKit, LinkColor) 38 { 39 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]); 40 41 [webView synchronouslyLoadHTMLString:@"<a href>Test</a>"]; 42 43 NSString *linkColor = [webView stringByEvaluatingJavaScript:@"getComputedStyle(document.links[0]).color"]; 44 EXPECT_WK_STREQ("rgb(0, 0, 238)", linkColor); 45 } 46 47 #if PLATFORM(MAC) 48 TEST(WebKit, LinkColorWithSystemAppearance) 49 { 50 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]); 51 [webView _setUseSystemAppearance:YES]; 52 53 [webView synchronouslyLoadHTMLString:@"<a href>Test</a>"]; 54 55 NSString *linkColor = [webView stringByEvaluatingJavaScript:@"getComputedStyle(document.links[0]).color"]; 56 EXPECT_WK_STREQ("rgb(0, 105, 217)", linkColor); 57 } 58 #endif 59 60 } // namespace TestWebKitAPI 45 61 46 62 #endif
Note: See TracChangeset
for help on using the changeset viewer.