Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 34fc452fa59fe306b3f8bb7fac98a6c51e40cbaa
https://github.com/WebKit/WebKit/commit/34fc452fa59fe306b3f8bb7fac98a6c51e40cbaa
Author: Kiet Ho <[email protected]>
Date: 2026-04-02 (Thu, 02 Apr 2026)
Changed paths:
M LayoutTests/TestExpectations
A
LayoutTests/css-dark-mode/prefers-color-scheme-ignores-document-meta-color-scheme-expected.html
A
LayoutTests/css-dark-mode/prefers-color-scheme-ignores-document-meta-color-scheme.html
A
LayoutTests/css-dark-mode/prefers-color-scheme-in-iframe-consults-owner-element-expected.html
A
LayoutTests/css-dark-mode/prefers-color-scheme-in-iframe-consults-owner-element.html
A LayoutTests/css-dark-mode/resources/prefers-color-scheme-iframe.html
A
LayoutTests/http/tests/css/prefers-color-scheme-in-cross-origin-iframe-consults-owner-element-expected.html
A
LayoutTests/http/tests/css/prefers-color-scheme-in-cross-origin-iframe-consults-owner-element.html
A LayoutTests/http/tests/css/resources/prefers-color-scheme-iframe.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-cross-origin.sub-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-cross-origin.sub.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-page-dark-cross-origin.sub-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-page-dark-cross-origin.sub.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-page-light-cross-origin.sub-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-page-light-cross-origin.sub.html
M Source/WebCore/css/query/MediaQueryFeatures.cpp
M Source/WebCore/page/Page.cpp
Log Message:
-----------
@media (prefers-color-scheme: dark) inside iframe not matching when the
iframe itself has style.colorScheme = 'dark'
rdar://142072593
https://bugs.webkit.org/show_bug.cgi?id=284973
Reviewed by Simon Fraser.
>From CSS Media Queries Level 5 [1]: if the frame is a subframe, its preferred
>color scheme
is the color scheme of its owner element [2]:
> the preferred color scheme must reflect the value of the used color scheme on
> the
> embedding node in the embedding document.
The spec only mentions this for embedded SVG, but this also applies to iframes,
as resolved in [3]:
> RESOLVED: Context-dependent color scheme propagation works for iframes
> (including
> cross-origin) unless specifically restricted
This patch implements this resolution by using
FrameView::ownerElementOfChildFrameUsesDarkAppearance to query for the color
scheme
of the iframe's owner element.
[1]: https://drafts.csswg.org/mediaqueries-5/#prefers-color-scheme
[2]:
https://drafts.csswg.org/mediaqueries-5/#:~:text=the%20preferred%20color%20scheme
[3]: https://github.com/w3c/csswg-drafts/issues/7493#issuecomment-1201691078
Tests:
css-dark-mode/prefers-color-scheme-ignores-document-meta-color-scheme.html
css-dark-mode/prefers-color-scheme-in-iframe-consults-owner-element.html
http/tests/css/prefers-color-scheme-in-cross-origin-iframe-consults-owner-element.html
imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred.html
imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-page-dark.html
imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-page-light.html
imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-cross-origin.sub.html
imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-page-dark-cross-origin.sub.html
imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-page-light-cross-origin.sub.html
* LayoutTests/TestExpectations:
*
LayoutTests/css-dark-mode/prefers-color-scheme-ignores-document-meta-color-scheme-expected.html:
Added.
*
LayoutTests/css-dark-mode/prefers-color-scheme-ignores-document-meta-color-scheme.html:
Added.
*
LayoutTests/css-dark-mode/prefers-color-scheme-in-iframe-consults-owner-element-expected.html:
Added.
*
LayoutTests/css-dark-mode/prefers-color-scheme-in-iframe-consults-owner-element.html:
Added.
* LayoutTests/css-dark-mode/resources/prefers-color-scheme-iframe.html: Added.
*
LayoutTests/http/tests/css/prefers-color-scheme-in-cross-origin-iframe-consults-owner-element-expected.html:
Added.
*
LayoutTests/http/tests/css/prefers-color-scheme-in-cross-origin-iframe-consults-owner-element.html:
Added.
* LayoutTests/http/tests/css/resources/prefers-color-scheme-iframe.html: Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-cross-origin.sub-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-cross-origin.sub.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-page-dark-cross-origin.sub-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-page-dark-cross-origin.sub.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-page-light-cross-origin.sub-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/rendering/dark-color-scheme/color-scheme-iframe-preferred-page-light-cross-origin.sub.html:
Added.
* Source/WebCore/css/query/MediaQueryFeatures.cpp:
(WebCore::MQ::Features::frameUsesDarkAppearanceForPrefersColorScheme):
- Add new function to answer the prefers-color-schema query, taking into
account the color scheme of the owner element.
(WebCore::MQ::Features::prefersColorSchemeFeatureSchema):
- Call frameUsesDarkAppearanceForPrefersColorScheme to answer the query.
* Source/WebCore/page/Page.cpp:
(WebCore::Page::useDarkAppearance const):
- Rewrite the logic to be easier to follow.
Canonical link: https://commits.webkit.org/310465@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications