Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a7b39ca3653c38e1984af164efaa13475f2b61e6
      
https://github.com/WebKit/WebKit/commit/a7b39ca3653c38e1984af164efaa13475f2b61e6
  Author: Kiet Ho <[email protected]>
  Date:   2026-07-29 (Wed, 29 Jul 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/style-query-registered-custom-rem-change-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/style-query-registered-custom-root-relative-units-change-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/style-query-registered-custom-root-relative-units-change.html
    M Source/WebCore/style/ContainerQueryEvaluator.cpp

  Log Message:
  -----------
  [css-conditional-5] @container style queries not evaluating root-relative 
length correctly
rdar://183094796
https://bugs.webkit.org/show_bug.cgi?id=320160

Reviewed by Tim Nguyen.

During style resolution, new element styles are not immediately committed to the
render tree. Instead, they're stored in a Style::Update, and the render tree 
updater
(which runs after style resolution) commits the new styles. This means 
accessing an
element's render style during style resolution will result in the style of the
previous resolution, not the current one.

This wouldn't work with container style queries, as it queries against the new
style, which hasn't been committed into the render tree. As 
ContainerQueryEvaluator
is run during style resolution, it has has a clever trick: it has access to the
Style::Update of the current resolution. This gives it access to the new styles.

ContainerQueryEvaluator::featureEvaluationContextForQuery uses styleForContainer
to grab the new style for the container and container's parent, but for the root
element style, it uses the current render style instead. This means if the style
queries specifies length using root-relative units (e.g rem, rlh, vb, vi), the
length are relative to the root's old style, not the new one. If the container
queries are re-evaluated because the root style changes (e.g font-size, 
line-height,
or writing-mode), then the queries will incorrectly evaluate the length against
the old root style.

Fix this by also using styleForContainer to get the newest possible root style.

Tests:  
imported/w3c/web-platform-tests/css/css-conditional/container-queries/style-query-registered-custom-rem-change.html
        
imported/w3c/web-platform-tests/css/css-conditional/container-queries/style-query-registered-custom-root-relative-units-change.html

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/style-query-registered-custom-rem-change-expected.txt:
    - Test progression

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/style-query-registered-custom-root-relative-units-change-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/style-query-registered-custom-root-relative-units-change.html:
 Added.
    - Add test that tests whether lengths using root-relative units in 
container style
      queries correctly re-evaluates when the root changes. This test is 
similar to
      style-query-registered-custom-rem-change.html, but it tests more 
root-relative
      units (rem, rlh, vb, vi)

* Source/WebCore/style/ContainerQueryEvaluator.cpp:
(WebCore::Style::ContainerQueryEvaluator::featureEvaluationContextForQuery 
const):

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



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

Reply via email to