<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>292754</bug_id>
          
          <creation_ts>2025-05-08 18:40:08 -0700</creation_ts>
          <short_desc>[css-anchor-position-1] Wrong assumption that if an anchor doesn&apos;t exist, it will not exist again in the future</short_desc>
          <delta_ts>2025-07-23 13:18:22 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://github.com/web-platform-tests/wpt/pull/53936</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>291856</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Kiet Ho">kiet.ho</reporter>
          <assigned_to name="Kiet Ho">kiet.ho</assigned_to>
          <cc>fantasai.bugs</cc>
    
    <cc>kiet.ho</cc>
    
    <cc>koivisto</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2116014</commentid>
    <comment_count>0</comment_count>
      <attachid>475172</attachid>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2025-05-08 18:40:08 -0700</bug_when>
    <thetext>Created attachment 475172
Test case

Consider this pseudo-HTML (see attached HTML for a fully working test case)

&lt;div anchor-name: --a /&gt; // A
&lt;div position-anchor: --a position-area: top left&gt; // B
  &lt;div anchor-name: --c &gt;&lt;/div&gt; // C
&lt;/div&gt;

&lt;div position-anchor: --c position-area: top right /&gt; // D

A is an anchor. B is anchor-positioned, and its child, C, is an anchor. D is anchor-positioned.

Style/layout interleaving timeline:

* First style resolution: A is discovered as an anchor. B is discovered as anchor-positioned to A. D is discovered as anchor-positioned to C. Crucially, there&apos;s an optimization where if an anchor-positioned element hasn&apos;t been resolved yet, we skip descending into its children until the next style resolution, when the anchor-positioned element has been resolved. So here, we don&apos;t discover C as an anchor (because its parent, B, is anchor-positioned and not resolved yet)
* First layout: A is laid out. Post processing task links B to A, but doesn&apos;t link D to anything (because D depends on C, but the code hasn&apos;t seen C yet)
* Second style resolution: B, D are marked as resolved. Since B is resolved, the code descends into B and discovers C as an anchor. BUT, since D are already marked as resolved, we don&apos;t go back and fix that C actually exists.
* Second layout: B is laid out

Result: the code treats C as if it doesn&apos;t exist.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2116015</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-05-08 18:40:17 -0700</bug_when>
    <thetext>&lt;rdar://problem/150975368&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2131316</commentid>
    <comment_count>2</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2025-07-18 19:09:05 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/48282</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2132124</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-07-23 11:25:40 -0700</bug_when>
    <thetext>Committed 297797@main (1996b78d76bf): &lt;https://commits.webkit.org/297797@main&gt;

Reviewed commits have been landed. Closing PR #48282 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2132126</commentid>
    <comment_count>4</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2025-07-23 11:48:08 -0700</bug_when>
    <thetext>Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/53936</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2132147</commentid>
    <comment_count>5</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2025-07-23 13:18:22 -0700</bug_when>
    <thetext>*** Bug 294642 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>475172</attachid>
            <date>2025-05-08 18:40:08 -0700</date>
            <delta_ts>2025-05-08 18:40:08 -0700</delta_ts>
            <desc>Test case</desc>
            <filename>position-area-display-change-anchor-positioned-in-anchor.html</filename>
            <type>text/html</type>
            <size>1980</size>
            <attacher name="Kiet Ho">kiet.ho</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+Cgo8dGl0bGU+VGVzdHMgdGhhdCBYWFg8L3RpdGxlPgoKPGxpbmsgcmVs
PSJoZWxwIiBocmVmPSJodHRwczovL2RyYWZ0cy5jc3N3Zy5vcmcvY3NzLWFuY2hvci1wb3NpdGlv
bi0xLyNwb3NpdGlvbi1hcmVhIj4KPGxpbmsgcmVsPSJhdXRob3IiIGhyZWY9Im1haWx0bzpraWV0
LmhvQGFwcGxlLmNvbSI+CjxsaW5rIHJlbD0ibWF0Y2giIGhyZWY9InJlZmVyZW5jZS9wb3NpdGlv
bi1hcmVhLWRpc3BsYXktY2hhbmdlLXJlZi5odG1sIj4KCjxzY3JpcHQgc3JjPSIvY29tbW9uL3Jl
ZnRlc3Qtd2FpdC5qcyI+PC9zY3JpcHQ+CjxzY3JpcHQgc3JjPSIvY29tbW9uL3JlbmRlcmluZy11
dGlscy5qcyI+PC9zY3JpcHQ+Cgo8c3R5bGU+CiAgLmNvbnRhaW5pbmctYmxvY2sgewogICAgcG9z
aXRpb246IHJlbGF0aXZlOwogICAgd2lkdGg6IDE1MHB4OwogICAgaGVpZ2h0OiAxNTBweDsKICB9
Cg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