<?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>258886</bug_id>
          
          <creation_ts>2023-07-05 08:41:08 -0700</creation_ts>
          <short_desc>offsetParent is wrong for a nested element</short_desc>
          <delta_ts>2025-12-25 15:42:05 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Mac (Apple Silicon)</rep_platform>
          <op_sys>macOS 13</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=19923</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=253147</see_also>
          <bug_file_loc>https://jsfiddle.net/xjsm5489/show</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Kanaru Sato">i.am.kanaru.sato</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>mike</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1965124</commentid>
    <comment_count>0</comment_count>
      <attachid>466934</attachid>
    <who name="Kanaru Sato">i.am.kanaru.sato</who>
    <bug_when>2023-07-05 08:41:08 -0700</bug_when>
    <thetext>Created attachment 466934
this html produces the bug

Hi, hope you all are well :)

I found offsetParent is wrong for a bit nested element.

In the attached HTML, the offsetParent of the div element with id, &quot;target&quot;, should be the span with id, &quot;offsetParent&quot;.
But the webkit(265767@main) recognizes the offsetParent is the span with id, &quot;not-offsetParent&quot;.

It affects many libraries which insert elements with consideration of setting position properties correctly.
This kind of library, e.g. floating UI, detects offsetParents of elements and calculates the position related properties of element to be inserted.
(floating UI: https://github.com/floating-ui/floating-ui)

FYI: I found the offsetParent is correctly set when you remove the parent element(div) of the element with id, &quot;target&quot;. But idk this helps debug.

Thank you for checking this report and look forward to your reply :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1965129</commentid>
    <comment_count>1</comment_count>
    <who name="Kanaru Sato">i.am.kanaru.sato</who>
    <bug_when>2023-07-05 08:44:32 -0700</bug_when>
    <thetext>I&apos;ve already checked chrome and firefox correctly recognize the offsetParent...!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1965168</commentid>
    <comment_count>2</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-07-05 11:28:20 -0700</bug_when>
    <thetext>I am able to reproduce this bug on WebKit ToT (265772@main) and Safari 16.5.1, so it might not be recent regression.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1965214</commentid>
    <comment_count>3</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2023-07-05 15:38:30 -0700</bug_when>
    <thetext>This is caused by the continuation tree structure (caused by the inline level element&apos;s block level child &lt;span&gt;&lt;div&gt;) where we fail to follow the continuation chain for our containing block.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1965218</commentid>
    <comment_count>4</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-07-05 16:31:38 -0700</bug_when>
    <thetext>(In reply to zalan from comment #3)
&gt; This is caused by the continuation tree structure (caused by the inline
&gt; level element&apos;s block level child &lt;span&gt;&lt;div&gt;) where we fail to follow the
&gt; continuation chain for our containing block.

By any chance, is this relevant WPT?

http://wpt.live/css/cssom-view/offsetParent-block-in-inline.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1965250</commentid>
    <comment_count>5</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2023-07-05 20:01:05 -0700</bug_when>
    <thetext>yeah(In reply to Ahmad Saleem from comment #4)
&gt; (In reply to zalan from comment #3)
&gt; &gt; This is caused by the continuation tree structure (caused by the inline
&gt; &gt; level element&apos;s block level child &lt;span&gt;&lt;div&gt;) where we fail to follow the
&gt; &gt; continuation chain for our containing block.
&gt; 
&gt; By any chance, is this relevant WPT?
&gt; 
&gt; http://wpt.live/css/cssom-view/offsetParent-block-in-inline.html
yah, it&apos;s all about continuation. :/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1965874</commentid>
    <comment_count>6</comment_count>
    <who name="Kanaru Sato">i.am.kanaru.sato</who>
    <bug_when>2023-07-09 22:03:44 -0700</bug_when>
    <thetext>Thank you for giving replies :)

I&apos;d like to debug and fix it. Could I try that?
According to your guess, I will take a look on the below parts of WebKit.
- `RenderObject::offsetParent()`
- `RenderElement::canContainAbsolutelyPositionedObjects()`

BTW, should I refer to the below page for how to debug webkit?
https://webkit.org/debugging-webkit/
Actually, I&apos;d tried to build and run webkit on local before according to this link, and didn&apos;t succeed...TT

If there was the better or latest document, could you please give me that??</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1966391</commentid>
    <comment_count>7</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-07-12 08:42:17 -0700</bug_when>
    <thetext>&lt;rdar://problem/112140677&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1968747</commentid>
    <comment_count>8</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-07-29 06:30:54 -0700</bug_when>
    <thetext>(In reply to Kanaru Sato from comment #6)
&gt; Thank you for giving replies :)
&gt; 
&gt; I&apos;d like to debug and fix it. Could I try that?
&gt; According to your guess, I will take a look on the below parts of WebKit.
&gt; - `RenderObject::offsetParent()`
&gt; - `RenderElement::canContainAbsolutelyPositionedObjects()`
&gt; 
&gt; BTW, should I refer to the below page for how to debug webkit?
&gt; https://webkit.org/debugging-webkit/
&gt; Actually, I&apos;d tried to build and run webkit on local before according to
&gt; this link, and didn&apos;t succeed...TT
&gt; 
&gt; If there was the better or latest document, could you please give me that??

I think you can try bug 253147, which has more details in where the culprit code is and also potential Blink merge candidate.

Also can you share your steps and what error you faced? Also join WebKit Slack Channel to get more help and support on how to build local WebKit test environment.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2161849</commentid>
    <comment_count>9</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2025-11-28 11:09:32 -0800</bug_when>
    <thetext>Solved with `Block-in-inline` work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2168202</commentid>
    <comment_count>10</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2025-12-25 15:42:05 -0800</bug_when>
    <thetext>Resolved in Safari Technology Preview 234.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>466934</attachid>
            <date>2023-07-05 08:41:08 -0700</date>
            <delta_ts>2023-07-05 08:41:08 -0700</delta_ts>
            <desc>this html produces the bug</desc>
            <filename>file_258886.txt</filename>
            <type>text/plain</type>
            <size>786</size>
            <attacher name="Kanaru Sato">i.am.kanaru.sato</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+DQo8aHRtbCBsYW5nPSJlbiI+DQogIDxoZWFkPg0KICAgIDxtZXRhIGNo
YXJzZXQ9IlVURi04IiAvPg0KICAgIDxtZXRhIG5hbWU9InZpZXdwb3J0IiBjb250ZW50PSJ3aWR0
aD1kZXZpY2Utd2lkdGgsIGluaXRpYWwtc2NhbGU9MS4wIiAvPg0KICAgIDxtZXRhIGh0dHAtZXF1
aXY9IlgtVUEtQ29tcGF0aWJsZSIgY29udGVudD0iaWU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