Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 93785137d0d1b8d929ae16aaec342101a9ca4eea
      
https://github.com/WebKit/WebKit/commit/93785137d0d1b8d929ae16aaec342101a9ca4eea
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-05-21 (Thu, 21 May 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/display-contents-style-query-descendant-restyle-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/display-contents-style-query-descendant-restyle.html
    M Source/WebCore/style/StyleUpdate.cpp

  Log Message:
  -----------
  CSS Container Style Queries: fails when container has display: contents
https://bugs.webkit.org/show_bug.cgi?id=301871
rdar://164414720

Reviewed by Antti Koivisto.

This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.

When a descendant of a `display: contents` ancestor is re-resolved
(e.g. on :hover), `Style::Update::elementStyle()` returned nullptr for
that ancestor: it had no pending update entry this pass and no renderer
to read a style from. `styleForContainer()` then bailed and
`@container style(...)` silently stopped matching, dropping any
properties the rule was applying.

Fix this at the source: `Update::elementStyle()` now reads from
`Element::renderOrDisplayContentsStyle()` whenever there is no pending
update entry. That helper already returns the `displayContentsOrNoneStyle`
for `display: contents` elements and the renderer's style otherwise (or
nullptr when there is no renderer), so a single call covers all cases.
Behavior is unchanged for elements with a renderer, and `display: none`
elements still resolve to nullptr.

This makes the fix benefit every caller of `Update::elementStyle()`
rather than only the container query evaluator.

Test: 
imported/w3c/web-platform-tests/css/css-conditional/container-queries/display-contents-style-query-descendant-restyle.html

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/display-contents-style-query-descendant-restyle-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/display-contents-style-query-descendant-restyle.html:
 Added.
* Source/WebCore/style/StyleUpdate.cpp:
(WebCore::Style::Update::elementStyle const):
(WebCore::Style::Update::elementStyle):

Canonical link: https://commits.webkit.org/313677@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to