| Differences between
and this patch
- a/Source/WebCore/ChangeLog +60 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2018-10-12  Timothy Hatcher  <timothy@apple.com>
2
3
        Add <meta name="supported-color-schemes"> to control what color schemes the page supports
4
        https://bugs.webkit.org/show_bug.cgi?id=190526
5
        rdar://problem/45230140
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        Test: css-dark-mode/supported-color-schemes.html
10
11
        * dom/Document.cpp:
12
        (WebCore::isColorSchemeSeparator): Added.
13
        (WebCore::processColorSchemes): Added.
14
        (WebCore::Document::processSupportedColorSchemes): Added.
15
        (WebCore::Document::useDarkAppearance const): Take system appearance and document's
16
        suppoerted color shcemes into account.
17
        * dom/Document.h:
18
        * editing/cocoa/WebContentReaderCocoa.mm:
19
        (WebCore::createFragment): Update use of LocalDefaultSystemAppearance.
20
        * html/HTMLMetaElement.cpp:
21
        (WebCore::HTMLMetaElement::process): Added supported-color-schemes behind runtime feature check.
22
        * inspector/InspectorOverlay.cpp:
23
        (WebCore::InspectorOverlay::paint): Update use of LocalDefaultSystemAppearance.
24
        * platform/mac/DragImageMac.mm:
25
        (WebCore::createDragImageForLink): Update use of LocalDefaultSystemAppearance.
26
        * platform/mac/LocalDefaultSystemAppearance.h:
27
        * platform/mac/LocalDefaultSystemAppearance.mm:
28
        (WebCore::LocalDefaultSystemAppearance::LocalDefaultSystemAppearance):
29
        Drop the need for useSystemAppearance. This is accounted for in Document::useDarkAppearance.
30
        * platform/mac/ThemeMac.mm:
31
        (WebCore::ThemeMac::paint): Update use of LocalDefaultSystemAppearance.
32
        * rendering/RenderLayerBacking.cpp:
33
        (WebCore::RenderLayerBacking::paintContents): Update use of LocalDefaultSystemAppearance.
34
        * rendering/RenderLayerCompositor.cpp:
35
        (WebCore::RenderLayerCompositor::paintContents): Update use of LocalDefaultSystemAppearance.
36
        * rendering/RenderTheme.cpp:
37
        (WebCore::RenderTheme::paint): Use document instead of page.
38
        * rendering/RenderThemeCocoa.mm:
39
        (WebCore::RenderThemeCocoa::drawLineForDocumentMarker): Update use of LocalDefaultSystemAppearance.
40
        * rendering/RenderThemeMac.mm:
41
        (WebCore::RenderThemeMac::documentViewFor const): Update use of LocalDefaultSystemAppearance.
42
        (WebCore::RenderThemeMac::platformActiveSelectionBackgroundColor const): Ditto.
43
        (WebCore::RenderThemeMac::platformInactiveSelectionBackgroundColor const): Ditto.
44
        (WebCore::RenderThemeMac::transformSelectionBackgroundColor const): Ditto.
45
        (WebCore::RenderThemeMac::supportsSelectionForegroundColors const): Ditto.
46
        (WebCore::RenderThemeMac::platformActiveSelectionForegroundColor const): Ditto.
47
        (WebCore::RenderThemeMac::platformInactiveSelectionForegroundColor const): Ditto.
48
        (WebCore::RenderThemeMac::platformActiveListBoxSelectionBackgroundColor const): Ditto.
49
        (WebCore::RenderThemeMac::platformInactiveListBoxSelectionBackgroundColor const): Ditto.
50
        (WebCore::RenderThemeMac::platformActiveListBoxSelectionForegroundColor const): Ditto.
51
        (WebCore::RenderThemeMac::platformInactiveListBoxSelectionForegroundColor const): Ditto.
52
        (WebCore::RenderThemeMac::platformActiveTextSearchHighlightColor const): Ditto.
53
        (WebCore::RenderThemeMac::colorCache const): Ditto.
54
        (WebCore::RenderThemeMac::systemColor const): Ditto.
55
        (WebCore::RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary): Ditto.
56
        (WebCore::RenderThemeMac::paintSliderThumb): Ditto.
57
        (WebCore::RenderThemeMac::usingDarkAppearance const): No need to limit to macOS here.
58
        * svg/graphics/SVGImage.cpp:
59
        (WebCore::SVGImage::draw): Update use of LocalDefaultSystemAppearance.
60
1
2018-10-11  Timothy Hatcher  <timothy@apple.com>
61
2018-10-11  Timothy Hatcher  <timothy@apple.com>
2
62
3
        Add support for prefers-color-scheme media query
63
        Add support for prefers-color-scheme media query
- a/Source/WebKit/ChangeLog +17 lines
Lines 1-3 a/Source/WebKit/ChangeLog_sec1
1
2018-10-12  Timothy Hatcher  <timothy@apple.com>
2
3
        Add <meta name="supported-color-schemes"> to control what color schemes the page supports
4
        https://bugs.webkit.org/show_bug.cgi?id=190526
5
        rdar://problem/45230140
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        * UIProcess/mac/WKPrintingView.mm:
10
        (-[WKPrintingView drawRect:]): Update use of LocalDefaultSystemAppearance.
11
        * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
12
        (WebKit::InjectedBundleRangeHandle::renderedImage): Ditto.
13
        * WebProcess/Plugins/PDF/PDFPlugin.mm:
14
        (WebKit::PDFPlugin::paintControlForLayerInContext): Ditto.
15
        * WebProcess/WebPage/WebPage.cpp:
16
        (WebKit::WebPage::drawRect): Ditto.
17
1
2018-10-11  Timothy Hatcher  <timothy@apple.com>
18
2018-10-11  Timothy Hatcher  <timothy@apple.com>
2
19
3
        Add support for prefers-color-scheme media query
20
        Add support for prefers-color-scheme media query
- a/Source/WebKitLegacy/mac/ChangeLog +11 lines
Lines 1-3 a/Source/WebKitLegacy/mac/ChangeLog_sec1
1
2018-10-12  Timothy Hatcher  <timothy@apple.com>
2
3
        Add <meta name="supported-color-schemes"> to control what color schemes the page supports
4
        https://bugs.webkit.org/show_bug.cgi?id=190526
5
        rdar://problem/45230140
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        * WebCoreSupport/WebEditorClient.mm:
10
        (_WebCreateFragment): Update use of LocalDefaultSystemAppearance.
11
1
2018-10-11  Timothy Hatcher  <timothy@apple.com>
12
2018-10-11  Timothy Hatcher  <timothy@apple.com>
2
13
3
        Add support for prefers-color-scheme media query
14
        Add support for prefers-color-scheme media query
- a/Source/WebCore/dom/Document.cpp -3 / +67 lines
Lines 3555-3560 void Document::updateViewportArguments() a/Source/WebCore/dom/Document.cpp_sec1
3555
    }
3555
    }
3556
}
3556
}
3557
3557
3558
#if ENABLE(DARK_MODE_CSS)
3559
static bool isColorSchemeSeparator(UChar character)
3560
{
3561
    return isASCIISpace(character) || character == ',';
3562
}
3563
3564
static void processColorSchemes(StringView colorSchemes, const WTF::Function<void(StringView key)>& callback)
3565
{
3566
    unsigned length = colorSchemes.length();
3567
    for (unsigned i = 0; i < length; ) {
3568
        // Skip to first non-separator.
3569
        while (i < length && isColorSchemeSeparator(colorSchemes[i]))
3570
            ++i;
3571
        unsigned keyBegin = i;
3572
3573
        // Skip to first separator.
3574
        while (i < length && !isColorSchemeSeparator(colorSchemes[i]))
3575
            i++;
3576
        unsigned keyEnd = i;
3577
3578
        if (keyBegin == keyEnd)
3579
            continue;
3580
3581
        callback(colorSchemes.substring(keyBegin, keyEnd - keyBegin));
3582
    }
3583
}
3584
3585
void Document::processSupportedColorSchemes(const String& colorSchemes)
3586
{
3587
    OptionSet<ColorSchemes> supportedColorSchemes;
3588
3589
    processColorSchemes(colorSchemes, [&supportedColorSchemes](StringView key) {
3590
        if (equalLettersIgnoringASCIICase(key, "light"))
3591
            supportedColorSchemes.add(ColorSchemes::Light);
3592
        else if (equalLettersIgnoringASCIICase(key, "dark"))
3593
            supportedColorSchemes.add(ColorSchemes::Dark);
3594
    });
3595
3596
    if (supportedColorSchemes.isEmpty())
3597
        supportedColorSchemes.add(ColorSchemes::Light);
3598
3599
    m_supportedColorSchemes = supportedColorSchemes;
3600
3601
    if (auto* page = this->page())
3602
        page->updateStyleAfterChangeInEnvironment();
3603
}
3604
#endif
3605
3558
#if PLATFORM(IOS)
3606
#if PLATFORM(IOS)
3559
3607
3560
void Document::processFormatDetection(const String& features)
3608
void Document::processFormatDetection(const String& features)
Lines 7210-7219 bool Document::useSystemAppearance() const a/Source/WebCore/dom/Document.cpp_sec2
7210
7258
7211
bool Document::useDarkAppearance() const
7259
bool Document::useDarkAppearance() const
7212
{
7260
{
7213
    bool useDarkAppearance = false;
7261
#if ENABLE(DARK_MODE_CSS)
7262
    if (m_supportedColorSchemes.contains(ColorSchemes::Dark) && !m_supportedColorSchemes.contains(ColorSchemes::Light))
7263
        return true;
7264
#endif
7265
7266
    bool pageUsesDarkAppearance = false;
7214
    if (Page* documentPage = page())
7267
    if (Page* documentPage = page())
7215
        useDarkAppearance = documentPage->useDarkAppearance();
7268
        pageUsesDarkAppearance = documentPage->useDarkAppearance();
7216
    return useDarkAppearance;
7269
7270
    if (useSystemAppearance())
7271
        return pageUsesDarkAppearance;
7272
7273
#if ENABLE(DARK_MODE_CSS)
7274
    if (m_supportedColorSchemes.contains(ColorSchemes::Dark))
7275
        return pageUsesDarkAppearance;
7276
7277
    ASSERT(m_supportedColorSchemes.contains(ColorSchemes::Light));
7278
#endif
7279
7280
    return false;
7217
}
7281
}
7218
7282
7219
OptionSet<StyleColor::Options> Document::styleColorOptions() const
7283
OptionSet<StyleColor::Options> Document::styleColorOptions() const
- a/Source/WebCore/dom/Document.h -2 / +15 lines
Lines 571-578 public: a/Source/WebCore/dom/Document.h_sec1
571
571
572
    float deviceScaleFactor() const;
572
    float deviceScaleFactor() const;
573
573
574
    bool useSystemAppearance() const;
574
    WEBCORE_EXPORT bool useSystemAppearance() const;
575
    bool useDarkAppearance() const;
575
    WEBCORE_EXPORT bool useDarkAppearance() const;
576
576
577
    OptionSet<StyleColor::Options> styleColorOptions() const;
577
    OptionSet<StyleColor::Options> styleColorOptions() const;
578
578
Lines 894-899 public: a/Source/WebCore/dom/Document.h_sec2
894
    void updateViewportArguments();
894
    void updateViewportArguments();
895
    void processReferrerPolicy(const String& policy, ReferrerPolicySource);
895
    void processReferrerPolicy(const String& policy, ReferrerPolicySource);
896
896
897
#if ENABLE(DARK_MODE_CSS)
898
    enum class ColorSchemes : uint8_t {
899
        Light = 1 << 0,
900
        Dark = 1 << 1
901
    };
902
903
    void processSupportedColorSchemes(const String& colorSchemes);
904
#endif
905
897
    // Returns the owning element in the parent document.
906
    // Returns the owning element in the parent document.
898
    // Returns 0 if this is the top level document.
907
    // Returns 0 if this is the top level document.
899
    HTMLFrameOwnerElement* ownerElement() const;
908
    HTMLFrameOwnerElement* ownerElement() const;
Lines 1746-1751 private: a/Source/WebCore/dom/Document.h_sec3
1746
    std::unique_ptr<SVGDocumentExtensions> m_svgExtensions;
1755
    std::unique_ptr<SVGDocumentExtensions> m_svgExtensions;
1747
    HashSet<SVGUseElement*> m_svgUseElements;
1756
    HashSet<SVGUseElement*> m_svgUseElements;
1748
1757
1758
#if ENABLE(DARK_MODE_CSS)
1759
    OptionSet<ColorSchemes> m_supportedColorSchemes { ColorSchemes::Light };
1760
#endif
1761
1749
#if ENABLE(DASHBOARD_SUPPORT)
1762
#if ENABLE(DASHBOARD_SUPPORT)
1750
    Vector<AnnotatedRegionValue> m_annotatedRegions;
1763
    Vector<AnnotatedRegionValue> m_annotatedRegions;
1751
    bool m_hasAnnotatedRegions { false };
1764
    bool m_hasAnnotatedRegions { false };
- a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm -2 / +1 lines
Lines 132-139 static FragmentAndResources createFragment(Frame& frame, NSAttributedString *str a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec1
132
    Document& document = *frame.document();
132
    Document& document = *frame.document();
133
133
134
#if PLATFORM(MAC)
134
#if PLATFORM(MAC)
135
    auto* page = frame.page();
135
    LocalDefaultSystemAppearance localAppearance(document.useDarkAppearance());
136
    LocalDefaultSystemAppearance localAppearance(page->useSystemAppearance(), page->useDarkAppearance());
137
#endif
136
#endif
138
137
139
    NSArray *subresources = nil;
138
    NSArray *subresources = nil;
- a/Source/WebCore/html/HTMLMetaElement.cpp +4 lines
Lines 91-96 void HTMLMetaElement::process() a/Source/WebCore/html/HTMLMetaElement.cpp_sec1
91
        document().processViewport(contentValue, ViewportArguments::ViewportMeta);
91
        document().processViewport(contentValue, ViewportArguments::ViewportMeta);
92
    else if (RuntimeEnabledFeatures::sharedFeatures().disabledAdaptationsMetaTagEnabled() && equalLettersIgnoringASCIICase(name(), "disabled-adaptations"))
92
    else if (RuntimeEnabledFeatures::sharedFeatures().disabledAdaptationsMetaTagEnabled() && equalLettersIgnoringASCIICase(name(), "disabled-adaptations"))
93
        document().processDisabledAdaptations(contentValue);
93
        document().processDisabledAdaptations(contentValue);
94
#if ENABLE(DARK_MODE_CSS)
95
    else if (RuntimeEnabledFeatures::sharedFeatures().darkModeCSSEnabled() && equalLettersIgnoringASCIICase(name(), "supported-color-schemes"))
96
        document().processSupportedColorSchemes(contentValue);
97
#endif
94
#if PLATFORM(IOS)
98
#if PLATFORM(IOS)
95
    else if (equalLettersIgnoringASCIICase(name(), "format-detection"))
99
    else if (equalLettersIgnoringASCIICase(name(), "format-detection"))
96
        document().processFormatDetection(contentValue);
100
        document().processFormatDetection(contentValue);
- a/Source/WebCore/inspector/InspectorOverlay.cpp -1 / +1 lines
Lines 181-187 void InspectorOverlay::paint(GraphicsContext& context) a/Source/WebCore/inspector/InspectorOverlay.cpp_sec1
181
        return;
181
        return;
182
182
183
#if PLATFORM(MAC)
183
#if PLATFORM(MAC)
184
    LocalDefaultSystemAppearance localAppearance(m_page.useSystemAppearance(), m_page.useDarkAppearance());
184
    LocalDefaultSystemAppearance localAppearance(m_page.mainFrame().document()->useDarkAppearance());
185
#endif
185
#endif
186
186
187
    GraphicsContextStateSaver stateSaver(context);
187
    GraphicsContextStateSaver stateSaver(context);
- a/Source/WebCore/platform/mac/DragImageMac.mm -3 / +1 lines
Lines 300-308 DragImageRef createDragImageForLink(Element& element, URL& url, const String& ti a/Source/WebCore/platform/mac/DragImageMac.mm_sec1
300
{
300
{
301
    LinkImageLayout layout(url, title);
301
    LinkImageLayout layout(url, title);
302
302
303
    Page* page = element.document().page();
303
    LocalDefaultSystemAppearance localAppearance(element.document().useDarkAppearance());
304
305
    LocalDefaultSystemAppearance localAppearance(true, page ? page->useDarkAppearance() : false);
306
304
307
    auto imageSize = layout.boundingRect.size();
305
    auto imageSize = layout.boundingRect.size();
308
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
306
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
- a/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h -1 / +1 lines
Lines 40-46 class LocalDefaultSystemAppearance { a/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h_sec1
40
    WTF_MAKE_NONCOPYABLE(LocalDefaultSystemAppearance);
40
    WTF_MAKE_NONCOPYABLE(LocalDefaultSystemAppearance);
41
41
42
public:
42
public:
43
    WEBCORE_EXPORT LocalDefaultSystemAppearance(bool useSystemAppearance, bool useDarkAppearance);
43
    WEBCORE_EXPORT LocalDefaultSystemAppearance(bool useDarkAppearance);
44
    WEBCORE_EXPORT ~LocalDefaultSystemAppearance();
44
    WEBCORE_EXPORT ~LocalDefaultSystemAppearance();
45
45
46
    bool usingDarkAppearance() const
46
    bool usingDarkAppearance() const
- a/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm -3 / +2 lines
Lines 31-45 a/Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm_sec1
31
31
32
namespace WebCore {
32
namespace WebCore {
33
33
34
LocalDefaultSystemAppearance::LocalDefaultSystemAppearance(bool useSystemAppearance, bool useDarkAppearance)
34
LocalDefaultSystemAppearance::LocalDefaultSystemAppearance(bool useDarkAppearance)
35
{
35
{
36
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
36
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
37
    m_savedSystemAppearance = [NSAppearance currentAppearance];
37
    m_savedSystemAppearance = [NSAppearance currentAppearance];
38
    m_usingDarkAppearance = useSystemAppearance && useDarkAppearance;
38
    m_usingDarkAppearance = useDarkAppearance;
39
39
40
    [NSAppearance setCurrentAppearance:[NSAppearance appearanceNamed:m_usingDarkAppearance ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]];
40
    [NSAppearance setCurrentAppearance:[NSAppearance appearanceNamed:m_usingDarkAppearance ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]];
41
#else
41
#else
42
    UNUSED_PARAM(useSystemAppearance);
43
    UNUSED_PARAM(useDarkAppearance);
42
    UNUSED_PARAM(useDarkAppearance);
44
#endif
43
#endif
45
}
44
}
- a/Source/WebCore/platform/mac/ThemeMac.mm -1 / +3 lines
Lines 907-913 void ThemeMac::inflateControlPaintRect(ControlPart part, const ControlStates& st a/Source/WebCore/platform/mac/ThemeMac.mm_sec1
907
907
908
void ThemeMac::paint(ControlPart part, ControlStates& states, GraphicsContext& context, const FloatRect& zoomedRect, float zoomFactor, ScrollView* scrollView, float deviceScaleFactor, float pageScaleFactor, bool useSystemAppearance, bool useDarkAppearance)
908
void ThemeMac::paint(ControlPart part, ControlStates& states, GraphicsContext& context, const FloatRect& zoomedRect, float zoomFactor, ScrollView* scrollView, float deviceScaleFactor, float pageScaleFactor, bool useSystemAppearance, bool useDarkAppearance)
909
{
909
{
910
    LocalDefaultSystemAppearance localAppearance(useSystemAppearance, useDarkAppearance);
910
    UNUSED_PARAM(useSystemAppearance);
911
912
    LocalDefaultSystemAppearance localAppearance(useDarkAppearance);
911
913
912
    switch (part) {
914
    switch (part) {
913
        case CheckboxPart:
915
        case CheckboxPart:
- a/Source/WebCore/rendering/RenderLayerBacking.cpp -1 / +1 lines
Lines 2547-2553 void RenderLayerBacking::paintContents(const GraphicsLayer* graphicsLayer, Graph a/Source/WebCore/rendering/RenderLayerBacking.cpp_sec1
2547
#endif
2547
#endif
2548
2548
2549
#if PLATFORM(MAC)
2549
#if PLATFORM(MAC)
2550
    LocalDefaultSystemAppearance localAppearance(renderer().page().useSystemAppearance(), renderer().page().useDarkAppearance());
2550
    LocalDefaultSystemAppearance localAppearance(renderer().document().useDarkAppearance());
2551
#endif
2551
#endif
2552
2552
2553
    // The dirtyRect is in the coords of the painting root.
2553
    // The dirtyRect is in the coords of the painting root.
- a/Source/WebCore/rendering/RenderLayerCompositor.cpp -1 / +1 lines
Lines 2816-2822 void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const IntRec a/Source/WebCore/rendering/RenderLayerCompositor.cpp_sec1
2816
void RenderLayerCompositor::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase, const FloatRect& clip, GraphicsLayerPaintBehavior)
2816
void RenderLayerCompositor::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase, const FloatRect& clip, GraphicsLayerPaintBehavior)
2817
{
2817
{
2818
#if PLATFORM(MAC)
2818
#if PLATFORM(MAC)
2819
    LocalDefaultSystemAppearance localAppearance(page().useSystemAppearance(), page().useDarkAppearance());
2819
    LocalDefaultSystemAppearance localAppearance(m_renderView.document().useDarkAppearance());
2820
#endif
2820
#endif
2821
2821
2822
    IntRect pixelSnappedRectForIntegralPositionedItems = snappedIntRect(LayoutRect(clip));
2822
    IntRect pixelSnappedRectForIntegralPositionedItems = snappedIntRect(LayoutRect(clip));
- a/Source/WebCore/rendering/RenderTheme.cpp -1 / +1 lines
Lines 317-323 bool RenderTheme::paint(const RenderBox& box, ControlStates& controlStates, cons a/Source/WebCore/rendering/RenderTheme.cpp_sec1
317
    case ButtonPart:
317
    case ButtonPart:
318
    case InnerSpinButtonPart:
318
    case InnerSpinButtonPart:
319
        updateControlStatesForRenderer(box, controlStates);
319
        updateControlStatesForRenderer(box, controlStates);
320
        Theme::singleton().paint(part, controlStates, paintInfo.context(), devicePixelSnappedRect, box.style().effectiveZoom(), &box.view().frameView(), deviceScaleFactor, pageScaleFactor, box.page().useSystemAppearance(), box.page().useDarkAppearance());
320
        Theme::singleton().paint(part, controlStates, paintInfo.context(), devicePixelSnappedRect, box.style().effectiveZoom(), &box.view().frameView(), deviceScaleFactor, pageScaleFactor, box.document().useSystemAppearance(), box.document().useDarkAppearance());
321
        return false;
321
        return false;
322
    default:
322
    default:
323
        break;
323
        break;
- a/Source/WebCore/rendering/RenderThemeCocoa.mm -1 / +1 lines
Lines 56-62 void RenderThemeCocoa::drawLineForDocumentMarker(const RenderText& renderer, Gra a/Source/WebCore/rendering/RenderThemeCocoa.mm_sec1
56
    if (context.paintingDisabled())
56
    if (context.paintingDisabled())
57
        return;
57
        return;
58
58
59
    auto circleColor = colorForMarkerLineStyle(style, renderer.page().useSystemAppearance() && renderer.page().useDarkAppearance());
59
    auto circleColor = colorForMarkerLineStyle(style, renderer.document().useDarkAppearance());
60
60
61
    // Center the underline and ensure we only draw entire dots.
61
    // Center the underline and ensure we only draw entire dots.
62
    FloatPoint offsetPoint = origin;
62
    FloatPoint offsetPoint = origin;
- a/Source/WebCore/rendering/RenderThemeMac.mm -24 / +17 lines
Lines 297-303 RenderThemeMac::RenderThemeMac() a/Source/WebCore/rendering/RenderThemeMac.mm_sec1
297
297
298
NSView *RenderThemeMac::documentViewFor(const RenderObject& o) const
298
NSView *RenderThemeMac::documentViewFor(const RenderObject& o) const
299
{
299
{
300
    LocalDefaultSystemAppearance localAppearance(o.page().useSystemAppearance(), o.page().useDarkAppearance());
300
    LocalDefaultSystemAppearance localAppearance(usingDarkAppearance(o));
301
    ControlStates states(extractControlStatesForRenderer(o));
301
    ControlStates states(extractControlStatesForRenderer(o));
302
    return ThemeMac::ensuredView(&o.view().frameView(), states);
302
    return ThemeMac::ensuredView(&o.view().frameView(), states);
303
}
303
}
Lines 392-405 String RenderThemeMac::imageControlsStyleSheet() const a/Source/WebCore/rendering/RenderThemeMac.mm_sec2
392
392
393
Color RenderThemeMac::platformActiveSelectionBackgroundColor(OptionSet<StyleColor::Options> options) const
393
Color RenderThemeMac::platformActiveSelectionBackgroundColor(OptionSet<StyleColor::Options> options) const
394
{
394
{
395
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
395
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
396
    return colorFromNSColor([NSColor selectedTextBackgroundColor]);
396
    return colorFromNSColor([NSColor selectedTextBackgroundColor]);
397
}
397
}
398
398
399
Color RenderThemeMac::platformInactiveSelectionBackgroundColor(OptionSet<StyleColor::Options> options) const
399
Color RenderThemeMac::platformInactiveSelectionBackgroundColor(OptionSet<StyleColor::Options> options) const
400
{
400
{
401
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
401
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
402
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
402
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
403
    return colorFromNSColor([NSColor unemphasizedSelectedTextBackgroundColor]);
403
    return colorFromNSColor([NSColor unemphasizedSelectedTextBackgroundColor]);
404
#else
404
#else
405
    UNUSED_PARAM(options);
405
    UNUSED_PARAM(options);
Lines 409-415 Color RenderThemeMac::platformInactiveSelectionBackgroundColor(OptionSet<StyleCo a/Source/WebCore/rendering/RenderThemeMac.mm_sec3
409
409
410
Color RenderThemeMac::transformSelectionBackgroundColor(const Color& color, OptionSet<StyleColor::Options> options) const
410
Color RenderThemeMac::transformSelectionBackgroundColor(const Color& color, OptionSet<StyleColor::Options> options) const
411
{
411
{
412
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
412
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
413
    if (localAppearance.usingDarkAppearance()) {
413
    if (localAppearance.usingDarkAppearance()) {
414
        // Use an alpha value that is similar to results from blendWithWhite() on light colors.
414
        // Use an alpha value that is similar to results from blendWithWhite() on light colors.
415
        static const float darkAppearanceAlpha = 0.8;
415
        static const float darkAppearanceAlpha = 0.8;
Lines 421-433 Color RenderThemeMac::transformSelectionBackgroundColor(const Color& color, Opti a/Source/WebCore/rendering/RenderThemeMac.mm_sec4
421
421
422
bool RenderThemeMac::supportsSelectionForegroundColors(OptionSet<StyleColor::Options> options) const
422
bool RenderThemeMac::supportsSelectionForegroundColors(OptionSet<StyleColor::Options> options) const
423
{
423
{
424
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
424
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
425
    return localAppearance.usingDarkAppearance();
425
    return localAppearance.usingDarkAppearance();
426
}
426
}
427
427
428
Color RenderThemeMac::platformActiveSelectionForegroundColor(OptionSet<StyleColor::Options> options) const
428
Color RenderThemeMac::platformActiveSelectionForegroundColor(OptionSet<StyleColor::Options> options) const
429
{
429
{
430
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
430
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
431
    if (localAppearance.usingDarkAppearance())
431
    if (localAppearance.usingDarkAppearance())
432
        return colorFromNSColor([NSColor selectedTextColor]);
432
        return colorFromNSColor([NSColor selectedTextColor]);
433
    return { };
433
    return { };
Lines 436-442 Color RenderThemeMac::platformActiveSelectionForegroundColor(OptionSet<StyleColo a/Source/WebCore/rendering/RenderThemeMac.mm_sec5
436
Color RenderThemeMac::platformInactiveSelectionForegroundColor(OptionSet<StyleColor::Options> options) const
436
Color RenderThemeMac::platformInactiveSelectionForegroundColor(OptionSet<StyleColor::Options> options) const
437
{
437
{
438
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
438
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
439
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
439
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
440
    if (localAppearance.usingDarkAppearance())
440
    if (localAppearance.usingDarkAppearance())
441
        return colorFromNSColor([NSColor unemphasizedSelectedTextColor]);
441
        return colorFromNSColor([NSColor unemphasizedSelectedTextColor]);
442
    return { };
442
    return { };
Lines 449-455 Color RenderThemeMac::platformInactiveSelectionForegroundColor(OptionSet<StyleCo a/Source/WebCore/rendering/RenderThemeMac.mm_sec6
449
Color RenderThemeMac::platformActiveListBoxSelectionBackgroundColor(OptionSet<StyleColor::Options> options) const
449
Color RenderThemeMac::platformActiveListBoxSelectionBackgroundColor(OptionSet<StyleColor::Options> options) const
450
{
450
{
451
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
451
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
452
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
452
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
453
    return colorFromNSColor([NSColor selectedContentBackgroundColor]);
453
    return colorFromNSColor([NSColor selectedContentBackgroundColor]);
454
#else
454
#else
455
    UNUSED_PARAM(options);
455
    UNUSED_PARAM(options);
Lines 460-466 Color RenderThemeMac::platformActiveListBoxSelectionBackgroundColor(OptionSet<St a/Source/WebCore/rendering/RenderThemeMac.mm_sec7
460
Color RenderThemeMac::platformInactiveListBoxSelectionBackgroundColor(OptionSet<StyleColor::Options> options) const
460
Color RenderThemeMac::platformInactiveListBoxSelectionBackgroundColor(OptionSet<StyleColor::Options> options) const
461
{
461
{
462
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
462
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
463
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
463
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
464
    return colorFromNSColor([NSColor unemphasizedSelectedContentBackgroundColor]);
464
    return colorFromNSColor([NSColor unemphasizedSelectedContentBackgroundColor]);
465
#else
465
#else
466
    UNUSED_PARAM(options);
466
    UNUSED_PARAM(options);
Lines 470-483 Color RenderThemeMac::platformInactiveListBoxSelectionBackgroundColor(OptionSet< a/Source/WebCore/rendering/RenderThemeMac.mm_sec8
470
470
471
Color RenderThemeMac::platformActiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options> options) const
471
Color RenderThemeMac::platformActiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options> options) const
472
{
472
{
473
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
473
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
474
    return colorFromNSColor([NSColor alternateSelectedControlTextColor]);
474
    return colorFromNSColor([NSColor alternateSelectedControlTextColor]);
475
}
475
}
476
476
477
Color RenderThemeMac::platformInactiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options> options) const
477
Color RenderThemeMac::platformInactiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options> options) const
478
{
478
{
479
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
479
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
480
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
480
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
481
    return colorFromNSColor([NSColor unemphasizedSelectedTextColor]);
481
    return colorFromNSColor([NSColor unemphasizedSelectedTextColor]);
482
#else
482
#else
483
    UNUSED_PARAM(options);
483
    UNUSED_PARAM(options);
Lines 495-501 Color RenderThemeMac::platformFocusRingColor(OptionSet<StyleColor::Options> opti a/Source/WebCore/rendering/RenderThemeMac.mm_sec9
495
Color RenderThemeMac::platformActiveTextSearchHighlightColor(OptionSet<StyleColor::Options> options) const
495
Color RenderThemeMac::platformActiveTextSearchHighlightColor(OptionSet<StyleColor::Options> options) const
496
{
496
{
497
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
497
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
498
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
498
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
499
    return colorFromNSColor([NSColor findHighlightColor]);
499
    return colorFromNSColor([NSColor findHighlightColor]);
500
#else
500
#else
501
    UNUSED_PARAM(options);
501
    UNUSED_PARAM(options);
Lines 612-620 void RenderThemeMac::platformColorsDidChange() a/Source/WebCore/rendering/RenderThemeMac.mm_sec10
612
612
613
auto RenderThemeMac::colorCache(OptionSet<StyleColor::Options> options) const -> ColorCache&
613
auto RenderThemeMac::colorCache(OptionSet<StyleColor::Options> options) const -> ColorCache&
614
{
614
{
615
    const bool useSystemAppearance = options.contains(StyleColor::Options::UseSystemAppearance);
615
    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
616
    const bool useDarkAppearance = options.contains(StyleColor::Options::UseDarkAppearance);
617
    LocalDefaultSystemAppearance localAppearance(useSystemAppearance, useDarkAppearance);
618
    if (localAppearance.usingDarkAppearance())
616
    if (localAppearance.usingDarkAppearance())
619
        return m_darkColorCache;
617
        return m_darkColorCache;
620
    return RenderTheme::colorCache(options);
618
    return RenderTheme::colorCache(options);
Lines 626-632 Color RenderThemeMac::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::O a/Source/WebCore/rendering/RenderThemeMac.mm_sec11
626
    const bool useDarkAppearance = options.contains(StyleColor::Options::UseDarkAppearance);
624
    const bool useDarkAppearance = options.contains(StyleColor::Options::UseDarkAppearance);
627
    const bool forVisitedLink = options.contains(StyleColor::Options::ForVisitedLink);
625
    const bool forVisitedLink = options.contains(StyleColor::Options::ForVisitedLink);
628
626
629
    LocalDefaultSystemAppearance localAppearance(useSystemAppearance, useDarkAppearance);
627
    LocalDefaultSystemAppearance localAppearance(useDarkAppearance);
630
628
631
    auto& cache = colorCache(options);
629
    auto& cache = colorCache(options);
632
630
Lines 1802-1808 void RenderThemeMac::setPopupButtonCellState(const RenderObject& o, const IntSiz a/Source/WebCore/rendering/RenderThemeMac.mm_sec12
1802
1800
1803
void RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary(NSCell* cell, const RenderObject& renderer, const PaintInfo& paintInfo, const FloatRect& rect)
1801
void RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary(NSCell* cell, const RenderObject& renderer, const PaintInfo& paintInfo, const FloatRect& rect)
1804
{
1802
{
1805
    LocalDefaultSystemAppearance localAppearance(renderer.page().useSystemAppearance(), renderer.page().useDarkAppearance());
1803
    LocalDefaultSystemAppearance localAppearance(usingDarkAppearance(renderer));
1806
    bool shouldDrawFocusRing = isFocused(renderer) && renderer.style().outlineStyleIsAuto() == OutlineIsAuto::On;
1804
    bool shouldDrawFocusRing = isFocused(renderer) && renderer.style().outlineStyleIsAuto() == OutlineIsAuto::On;
1807
    bool shouldUseImageBuffer = renderer.style().effectiveZoom() != 1 || renderer.page().pageScaleFactor() != 1;
1805
    bool shouldUseImageBuffer = renderer.style().effectiveZoom() != 1 || renderer.page().pageScaleFactor() != 1;
1808
    bool shouldDrawCell = true;
1806
    bool shouldDrawCell = true;
Lines 1884-1890 bool RenderThemeMac::paintSliderThumb(const RenderObject& o, const PaintInfo& pa a/Source/WebCore/rendering/RenderThemeMac.mm_sec13
1884
        ? sliderThumbVertical()
1882
        ? sliderThumbVertical()
1885
        : sliderThumbHorizontal();
1883
        : sliderThumbHorizontal();
1886
1884
1887
    LocalDefaultSystemAppearance localAppearance(o.page().useSystemAppearance(), o.page().useDarkAppearance());
1885
    LocalDefaultSystemAppearance localAppearance(usingDarkAppearance(o));
1888
1886
1889
    LocalCurrentGraphicsContext localContext(paintInfo.context());
1887
    LocalCurrentGraphicsContext localContext(paintInfo.context());
1890
1888
Lines 2997-3008 bool RenderThemeMac::paintAttachment(const RenderObject& renderer, const PaintIn a/Source/WebCore/rendering/RenderThemeMac.mm_sec14
2997
2995
2998
bool RenderThemeMac::usingDarkAppearance(const RenderObject& o) const
2996
bool RenderThemeMac::usingDarkAppearance(const RenderObject& o) const
2999
{
2997
{
3000
#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
2998
    return o.document().useDarkAppearance();
3001
    return o.page().useSystemAppearance() && o.page().useDarkAppearance();
3002
#else
3003
    UNUSED_PARAM(o);
3004
    return false;
3005
#endif
3006
}
2999
}
3007
3000
3008
CGColorRef RenderThemeMac::colorForMarkerLineStyle(DocumentMarkerLineStyle style, bool useDarkMode)
3001
CGColorRef RenderThemeMac::colorForMarkerLineStyle(DocumentMarkerLineStyle style, bool useDarkMode)
- a/Source/WebCore/svg/graphics/SVGImage.cpp -1 / +2 lines
Lines 324-330 ImageDrawResult SVGImage::draw(GraphicsContext& context, const FloatRect& dstRec a/Source/WebCore/svg/graphics/SVGImage.cpp_sec1
324
    }
324
    }
325
325
326
#if PLATFORM(MAC)
326
#if PLATFORM(MAC)
327
    LocalDefaultSystemAppearance localAppearance(m_page->useSystemAppearance(), m_page->useDarkAppearance());
327
    auto* document = m_page->mainFrame().document();
328
    LocalDefaultSystemAppearance localAppearance(document ? document->useDarkAppearance() : false);
328
#endif
329
#endif
329
330
330
    view->paint(context, intersection(context.clipBounds(), enclosingIntRect(srcRect)));
331
    view->paint(context, intersection(context.clipBounds(), enclosingIntRect(srcRect)));
- a/Source/WebKit/UIProcess/mac/WKPrintingView.mm -5 / +2 lines
Lines 556-566 - (void)drawRect:(NSRect)nsRect a/Source/WebKit/UIProcess/mac/WKPrintingView.mm_sec1
556
556
557
    ASSERT(_printOperation == [NSPrintOperation currentOperation]);
557
    ASSERT(_printOperation == [NSPrintOperation currentOperation]);
558
558
559
    auto* page = _webFrame->page();
559
    // Always use the light appearance when printing.
560
    if (!page)
560
    WebCore::LocalDefaultSystemAppearance localAppearance(false);
561
        return;
562
563
    WebCore::LocalDefaultSystemAppearance localAppearance(page->useSystemAppearance(), page->useDarkAppearance());
564
561
565
    if ([self _isPrintingPreview]) {
562
    if ([self _isPrintingPreview]) {
566
        [self _drawPreview:nsRect];
563
        [self _drawPreview:nsRect];
- a/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp -1 / +1 lines
Lines 124-130 RefPtr<WebImage> InjectedBundleRangeHandle::renderedImage(SnapshotOptions option a/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp_sec1
124
        return nullptr;
124
        return nullptr;
125
125
126
#if PLATFORM(MAC)
126
#if PLATFORM(MAC)
127
    LocalDefaultSystemAppearance localAppearance(frame->page()->useSystemAppearance(), frame->page()->useDarkAppearance());
127
    LocalDefaultSystemAppearance localAppearance(ownerDocument.useDarkAppearance());
128
#endif
128
#endif
129
129
130
    Ref<Frame> protector(*frame);
130
    Ref<Frame> protector(*frame);
- a/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm -1 / +1 lines
Lines 1219-1225 void PDFPlugin::paintControlForLayerInContext(CALayer *layer, CGContextRef conte a/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm_sec1
1219
{
1219
{
1220
#if PLATFORM(MAC)
1220
#if PLATFORM(MAC)
1221
    auto* page = webFrame()->coreFrame()->page();
1221
    auto* page = webFrame()->coreFrame()->page();
1222
    LocalDefaultSystemAppearance localAppearance(page->useSystemAppearance(), page->useDarkAppearance());
1222
    LocalDefaultSystemAppearance localAppearance(page->useDarkAppearance());
1223
#endif
1223
#endif
1224
1224
1225
    GraphicsContext graphicsContext(context);
1225
    GraphicsContext graphicsContext(context);
- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp -1 / +2 lines
Lines 1541-1547 void WebPage::scrollMainFrameIfNotAtMaxScrollPosition(const IntSize& scrollOffse a/Source/WebKit/WebProcess/WebPage/WebPage.cpp_sec1
1541
void WebPage::drawRect(GraphicsContext& graphicsContext, const IntRect& rect)
1541
void WebPage::drawRect(GraphicsContext& graphicsContext, const IntRect& rect)
1542
{
1542
{
1543
#if PLATFORM(MAC)
1543
#if PLATFORM(MAC)
1544
    LocalDefaultSystemAppearance localAppearance(m_page->useSystemAppearance(), m_page->useDarkAppearance());
1544
    auto* document = m_mainFrame->coreFrame()->document();
1545
    LocalDefaultSystemAppearance localAppearance(document ? document->useDarkAppearance() : false);
1545
#endif
1546
#endif
1546
1547
1547
    GraphicsContextStateSaver stateSaver(graphicsContext);
1548
    GraphicsContextStateSaver stateSaver(graphicsContext);
- a/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm -2 / +1 lines
Lines 478-485 static NSDictionary *attributesForAttributedStringConversion() a/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm_sec1
478
void _WebCreateFragment(Document& document, NSAttributedString *string, FragmentAndResources& result)
478
void _WebCreateFragment(Document& document, NSAttributedString *string, FragmentAndResources& result)
479
{
479
{
480
#if PLATFORM(MAC)
480
#if PLATFORM(MAC)
481
    auto* page = document.page();
481
    LocalDefaultSystemAppearance localAppearance(document.useDarkAppearance());
482
    LocalDefaultSystemAppearance localAppearance(page->useSystemAppearance(), page->useDarkAppearance());
483
#endif
482
#endif
484
483
485
    static NSDictionary *documentAttributes = [attributesForAttributedStringConversion() retain];
484
    static NSDictionary *documentAttributes = [attributesForAttributedStringConversion() retain];
- a/LayoutTests/ChangeLog +11 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2018-10-12  Timothy Hatcher  <timothy@apple.com>
2
3
        Add <meta name="supported-color-schemes"> to control what color schemes the page supports
4
        https://bugs.webkit.org/show_bug.cgi?id=190526
5
        rdar://problem/45230140
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        * css-dark-mode/supported-color-schemes-expected.txt: Added.
10
        * css-dark-mode/supported-color-schemes.html: Added.
11
1
2018-10-11  Timothy Hatcher  <timothy@apple.com>
12
2018-10-11  Timothy Hatcher  <timothy@apple.com>
2
13
3
        Add support for prefers-color-scheme media query
14
        Add support for prefers-color-scheme media query
- a/LayoutTests/css-dark-mode/supported-color-schemes-expected.txt +19 lines
Line 0 a/LayoutTests/css-dark-mode/supported-color-schemes-expected.txt_sec1
1
2
PASS Element colors are correct in light color scheme with only light supported color scheme 
3
PASS Dark color scheme enabled 
4
PASS Element colors are correct in dark color scheme with only light supported color scheme 
5
PASS Light color scheme enabled 
6
PASS Supported color schemes changed to light and dark 
7
PASS Element colors are correct in light color scheme with light and dark supported color scheme 
8
PASS Dark color scheme enabled 
9
PASS Element colors are correct in dark color scheme with light and dark supported color scheme 
10
PASS Light color scheme enabled 
11
PASS Supported color schemes changed to dark 
12
PASS Element colors are correct in light color scheme with only dark supported color scheme 
13
PASS Dark color scheme enabled 
14
PASS Element colors are correct in dark color scheme with only dark supported color scheme 
15
PASS Supported color schemes changed to light and a bogus value 
16
PASS Element colors are correct in dark color scheme with only light supported color scheme 
17
PASS Supported color schemes changed to empty value 
18
PASS Element colors are correct in dark color scheme with implicit light supported color scheme 
19
- a/LayoutTests/css-dark-mode/supported-color-schemes.html +103 lines
Line 0 a/LayoutTests/css-dark-mode/supported-color-schemes.html_sec1
1
<!DOCTYPE html>
2
3
<!-- webkit-test-runner [ experimental:DarkModeCSSEnabled=true ] -->
4
5
<script src="../resources/testharness.js"></script>
6
<script src="../resources/testharnessreport.js"></script>
7
8
<style>
9
#test1 {
10
    color: text;
11
}
12
</style>
13
14
<meta id="meta" name="supported-color-schemes" content="light">
15
16
<div id="test1"></div>
17
18
<script>
19
function test_prop(id, prop, expected) {
20
    assert_equals(window.getComputedStyle(document.getElementById(id)).getPropertyValue(prop).trim(), expected);
21
}
22
23
test(function() {
24
    // The semantic text color should be black.
25
    test_prop("test1", "color", "rgb(0, 0, 0)");
26
}, "Element colors are correct in light color scheme with only light supported color scheme");
27
28
test(function() {
29
    if (window.internals)
30
        internals.settings.setUseDarkAppearance(true);
31
}, "Dark color scheme enabled");
32
33
test(function() {
34
    // The semantic text color should be black, and not change.
35
    test_prop("test1", "color", "rgb(0, 0, 0)");
36
}, "Element colors are correct in dark color scheme with only light supported color scheme");
37
38
test(function() {
39
    if (window.internals)
40
        internals.settings.setUseDarkAppearance(false);
41
}, "Light color scheme enabled");
42
43
test(function() {
44
    document.getElementById("meta").content = "light dark";
45
}, "Supported color schemes changed to light and dark");
46
47
test(function() {
48
    // The semantic text color should be black.
49
    test_prop("test1", "color", "rgb(0, 0, 0)");
50
}, "Element colors are correct in light color scheme with light and dark supported color scheme");
51
52
test(function() {
53
    if (window.internals)
54
        internals.settings.setUseDarkAppearance(true);
55
}, "Dark color scheme enabled");
56
57
test(function() {
58
    // The semantic text color should be white.
59
    test_prop("test1", "color", "rgb(255, 255, 255)");
60
}, "Element colors are correct in dark color scheme with light and dark supported color scheme");
61
62
test(function() {
63
    if (window.internals)
64
        internals.settings.setUseDarkAppearance(false);
65
}, "Light color scheme enabled");
66
67
test(function() {
68
    document.getElementById("meta").content = "dark";
69
}, "Supported color schemes changed to dark");
70
71
test(function() {
72
    // The semantic text color should be white.
73
    test_prop("test1", "color", "rgb(255, 255, 255)");
74
}, "Element colors are correct in light color scheme with only dark supported color scheme");
75
76
test(function() {
77
    if (window.internals)
78
        internals.settings.setUseDarkAppearance(true);
79
}, "Dark color scheme enabled");
80
81
test(function() {
82
    // The semantic text color should be white still.
83
    test_prop("test1", "color", "rgb(255, 255, 255)");
84
}, "Element colors are correct in dark color scheme with only dark supported color scheme");
85
86
test(function() {
87
    document.getElementById("meta").content = "light ,foo ";
88
}, "Supported color schemes changed to light and a bogus value");
89
90
test(function() {
91
    // The semantic text color should be black again.
92
    test_prop("test1", "color", "rgb(0, 0, 0)");
93
}, "Element colors are correct in dark color scheme with only light supported color scheme");
94
95
test(function() {
96
    document.getElementById("meta").content = "";
97
}, "Supported color schemes changed to empty value");
98
99
test(function() {
100
    // The semantic text color should be black still.
101
    test_prop("test1", "color", "rgb(0, 0, 0)");
102
}, "Element colors are correct in dark color scheme with implicit light supported color scheme");
103
</script>

Return to Bug 190526