<?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>273268</bug_id>
          
          <creation_ts>2024-04-25 13:01:37 -0700</creation_ts>
          <short_desc>[Regression: STP193] document.body.getBoundingClientRect() returns incorrect results.</short_desc>
          <delta_ts>2024-04-26 16:12:52 -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>Layout and Rendering</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=271934</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>ikilpatrick</reporter>
          <assigned_to name="alan">zalan</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>bfulgham</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>2031261</commentid>
    <comment_count>0</comment_count>
    <who name="">ikilpatrick</who>
    <bug_when>2024-04-25 13:01:37 -0700</bug_when>
    <thetext>After https://github.com/WebKit/WebKit/commit/08da24e33a25275b870ce9d3a2604c02c42495e5 landed document.body.getBoundingClientRect() returns incorrect results in a bunch of different situations.
This is present in Safari Tech Preview 193.

I&apos;ve created 6 examples here, but basically got bored after this point :P . (There are more I can think of off the top of my head).

Let me know if you have any questions!

&lt;!DOCTYPE html&gt;
&lt;style&gt;
body { width: 100%; height: 100%; }
&lt;/style&gt;
&lt;body&gt; 
  &lt;div id=target&gt;hi&lt;/div&gt;
&lt;/body&gt;
&lt;script&gt;
document.body.offsetTop;
target.style.marginTop = &apos;40px&apos;
console.log(document.body.getBoundingClientRect().top);
document.body.offsetTop;
console.log(document.body.getBoundingClientRect().top);
&lt;/script&gt;

&lt;!DOCTYPE html&gt;
&lt;style&gt;
body { width: 80%; height: 100px; overflow: hidden; clear: left;}
div { height: 20px; }
html.fail &gt; div { height: 100px; }
&lt;/style&gt;
&lt;body&gt;&lt;/body&gt;
&lt;script&gt;
document.documentElement.insertBefore(document.createElement(&apos;div&apos;), document.body);
document.body.offsetTop;
document.documentElement.className = &apos;fail&apos;;
console.log(document.body.getBoundingClientRect().top);
document.body.offsetTop;
console.log(document.body.getBoundingClientRect().top);
&lt;/script&gt;

&lt;!DOCTYPE html&gt;
&lt;style&gt;
body { width: 200px; height: 200px; display: table; }
&lt;/style&gt;
&lt;body&gt;
  &lt;div id=&quot;target&quot; style=&quot;height: 20px;&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;script&gt;
document.body.offsetTop;
target.style.height = &apos;300px&apos;;
console.log(document.body.getBoundingClientRect().height);
document.body.offsetTop;
console.log(document.body.getBoundingClientRect().height);
&lt;/script&gt;

&lt;!DOCTYPE html&gt;
&lt;style&gt;
/* force a conventional scrollbar */
html::-webkit-scrollbar {
  width: 20px;
  height: 20px;
  background-color: lime;
}
body { width: 100%; height: 200px; margin: 0; }
&lt;/style&gt;
&lt;body&gt;
  &lt;div id=&quot;target&quot; style=&quot;height: 80vh;&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;script&gt;
document.body.offsetTop;
target.style.height = &apos;200vh&apos;;
console.log(document.body.getBoundingClientRect().width);
document.body.offsetTop;
console.log(document.body.getBoundingClientRect().width);
&lt;/script&gt;

&lt;!DOCTYPE html&gt;
&lt;style&gt;
html { display: flex; flex-direction: column; }
body { width: 200px; height: 50%; }
&lt;/style&gt;
&lt;body&gt;
  &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;script&gt;
document.body.offsetTop;
target.style.height = &apos;80vh&apos;;
console.log(document.body.getBoundingClientRect().height);
document.body.offsetTop;
console.log(document.body.getBoundingClientRect().height);
&lt;/script&gt;

&lt;!DOCTYPE html&gt;
&lt;style&gt;
body { width: 200px; height: 50%; min-height: min-content; }
&lt;/style&gt;
&lt;body&gt;
  &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;script&gt;
document.body.offsetTop;
target.style.height = &apos;80vh&apos;;
console.log(document.body.getBoundingClientRect().height);
document.body.offsetTop;
console.log(document.body.getBoundingClientRect().height);
&lt;/script&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2031266</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-04-25 13:27:19 -0700</bug_when>
    <thetext>&lt;rdar://problem/127070600&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2031411</commentid>
    <comment_count>2</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2024-04-25 20:33:49 -0700</bug_when>
    <thetext>Thank you, yeah this is clearly incomplete. will just revert this change for now (I didn&apos;t feel particularly happy about it the first place).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2031620</commentid>
    <comment_count>3</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2024-04-26 16:12:52 -0700</bug_when>
    <thetext>reverted at 278063@main</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>