Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7ea7016e8f1762c542f93faa186a69debb1b81ea
      
https://github.com/WebKit/WebKit/commit/7ea7016e8f1762c542f93faa186a69debb1b81ea
  Author: Kiet Ho <[email protected]>
  Date:   2024-10-25 (Fri, 25 Oct 2024)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-in-css-min-max-function-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-in-css-min-max-function.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/reference/anchor-in-css-min-max-function-ref.html
    M Source/WebCore/style/AnchorPositionEvaluator.cpp

  Log Message:
  -----------
  [css-anchor-position-1] Restart anchor resolution if a new anchor reference 
is discovered after anchor resolution has concluded
rdar://137628927
https://bugs.webkit.org/show_bug.cgi?id=281169

Reviewed by Antti Koivisto.

It's possible for new anchor name references to be picked up after anchor 
resolution
has completed. Consider this CSS expression:

    top: max(anchor(--a1 top),
             anchor(--a2 top),
             anchor(--a3 top))

min() and max() does short-circuit evaluation: the first argument is always 
evaluated,
and if any arguments from the second one evaluate to NaN, the overall result is 
NaN,
and the remaining arguments are not evaluated.

Dring the first pass of style/layout interleaving, only anchor(--a1 top) and
anchor(--a2 top) are evaluated. We learn that resolving this depends on anchor 
--a1 and
--a2, and we return NaN because there's no layout information to fully resolve. 
HOWEVER,
anchor(--a3 top) is not evaluated, and we don't pick up the dependency on --a3.

On the second pass of style/layout interleaving, anchor(--a1 top) and 
anchor(--a2 top)
evaluate to non-NaN, and only here is anchor(--a3 top) evaluated. BUT, at this 
point,
the anchor resolution process has already finished. If we request evaluation of 
anchor
--a3, it'll assume it's an invalid anchor reference, and not a anchor reference 
that we
have to resolve.

Fix this by setting the anchor resolution stage to the initial stage if we see
a new anchor reference. This forces anchor resolution to rerun and pick up new
references.

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-in-css-min-max-function-expected.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-in-css-min-max-function.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/reference/anchor-in-css-min-max-function-ref.html:
 Added.
* Source/WebCore/style/AnchorPositionEvaluator.cpp:
(WebCore::Style::AnchorPositionEvaluator::evaluate):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to