<?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>226765</bug_id>
          
          <creation_ts>2021-06-08 04:48:41 -0700</creation_ts>
          <short_desc>Dynamically inserted inline-level element causes the adjacent float to shift down</short_desc>
          <delta_ts>2022-12-16 07:59:28 -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>Layout and Rendering</component>
          <version>Safari 14</version>
          <rep_platform>Mac (Intel)</rep_platform>
          <op_sys>macOS 10.15</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <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 name="Sarkis">kzakiss</reporter>
          <assigned_to name="alan">zalan</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>bfulgham</cc>
    
    <cc>koivisto</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>1767740</commentid>
    <comment_count>0</comment_count>
      <attachid>430831</attachid>
    <who name="Sarkis">kzakiss</who>
    <bug_when>2021-06-08 04:48:41 -0700</bug_when>
    <thetext>Created attachment 430831
Demonstration

The problem seems to happen only when there&apos;s a block-level element present next to the float. Removing the block-level element from the document (either dynamically or from source) resolves the problem.

The case is not only confined to dynamically inserted inline elements, but also includes out-of-flow inline elements that appear in-flow later (e.g., by changing their &apos;position&apos; from &apos;absolute&apos; to &apos;static&apos;).

Everything works just fine in case the inline element is already in flow on page load. The problem also disappears once I manually set the &apos;display&apos; property of the containing element to &apos;none&apos; and then revert it to its initial value.

The bug also affects Safari on iOS, thus affecting other mobile browsers as well.

Find the demonstration attached.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1769750</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-06-15 04:49:15 -0700</bug_when>
    <thetext>&lt;rdar://problem/79335914&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1919864</commentid>
    <comment_count>2</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-12-16 02:34:37 -0800</bug_when>
    <thetext>I am able to reproduce this with Safari Technology Preview 160 as well where &quot;span&quot; and &quot;float&quot; are not on same line, while Chrome Canary 110 and Firefox Nightly 110 match each other. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1919911</commentid>
    <comment_count>3</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2022-12-16 06:32:27 -0800</bug_when>
    <thetext>It looks like this breaks when the content is dynamically inserted. The same content works fine when no DOM mutation happens.

&lt;style&gt;
  #container {
  width: 500px;
  border: 1px solid black;
}

#container::after {
  content: &apos;after content&apos;;
  display: block;
}

#floating {
  float: right;
  background-color: blue;
}
&lt;/style&gt;
&lt;div id=&quot;container&quot;&gt;&lt;div id=&quot;floating&quot;&gt;Float&lt;/div&gt;&lt;/div&gt;
&lt;script&gt;
document.body.offsetHeight;
container.prepend(document.createTextNode(&quot;PASS if same line as float&quot;));
&lt;/script&gt;

produces the following render tree:

B---YGLS- --* RenderView at (0,0) size 1111x663
B-----LS- --    HTML RenderBlock at (0,0) size 1111x663
B-------- --      BODY RenderBody at (8,8) size 1095x647
B-------- --        DIV RenderBlock at (0,0) size 502x38
B---YG--- --          RenderBlock at (1,1) size 500x18
I-------- --            #text RenderText &quot;PASS if same line as float&quot;
B-F------ --          DIV RenderBlock at (468.11,19) size 32.89x18
I-------- --            #text RenderText &quot;Float&quot;
B----G--- --          &lt;pseudo&gt; RenderBlock at (1,19) size 500x18)
I---YG--- --            RenderText &quot;after content&quot;

while 
&lt;div id=&quot;container&quot;&gt;PASS if same line as float&lt;div id=&quot;floating&quot;&gt;Float&lt;/div&gt;&lt;/div&gt;

B---YGLS- --* RenderView at (0,0) size 1111x663)
B-----LS- --    HTML RenderBlock at (0,0) size 1111x663
B-------- --      BODY RenderBody at (8,8) size 1095x647
B-------- --        DIV RenderBlock at (0,0) size 502x38
B---YG--- --          RenderBlock at (1,1) size 500x18
I-------- --            #text RenderText &quot;PASS if same line as float&quot;
B-F------ --            DIV RenderBlock at (467.11,0) size 32.89x18
I-------- --              #text RenderText &quot;Float&quot;
B----G--- --          &lt;pseudo&gt; RenderBlock at (1,19) size 500x18
I---YG--- --            RenderText &quot;after content&quot;

Note that in the first case, the &quot;PASS if same line as float&quot; is wrapped in an anon block container.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>430831</attachid>
            <date>2021-06-08 04:48:41 -0700</date>
            <delta_ts>2021-06-08 04:48:41 -0700</delta_ts>
            <desc>Demonstration</desc>
            <filename>shifting-float.html</filename>
            <type>text/html</type>
            <size>888</size>
            <attacher name="Sarkis">kzakiss</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KPGhlYWQ+CiAgPG1ldGEgY2hhcnNldD0i
VVRGLTgiPgogIDxtZXRhIG5hbWU9InZpZXdwb3J0IiBjb250ZW50PSJ3aWR0aD1kZXZpY2Utd2lk
dGgsIGluaXRpYWwtc2NhbGU9MS4wIj4KICA8dGl0bGU+RHluYW1pY2FsbHkgaW5zZXJ0ZWQgaW5s
aW5lLWxldmVsIGVsZW1lbnQgY2F1c2VzIHRoZSBhZGphY2VudCBmbG9hdCB0byBzaGlmdCBkb3du
PC90aXRsZT4K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