<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - float with media query positioned incorrectly after window resize"
   href="https://bugs.webkit.org/show_bug.cgi?id=152558#c7">Comment # 7</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - float with media query positioned incorrectly after window resize"
   href="https://bugs.webkit.org/show_bug.cgi?id=152558">bug 152558</a>
              from <span class="vcard"><a class="email" href="mailto:zalan&#64;apple.com" title="zalan &lt;zalan&#64;apple.com&gt;"> <span class="fn">zalan</span></a>
</span></b>
        <pre>RenderBlock::addChildIgnoringContinuation says:
&quot;// If we're inserting an inline (or floated) child but all of our children are blocks, then we have to make sure
// it is put into an anomyous block box. We try to use an existing anonymous box if possible, otherwise
// a new one is created and inserted into our list of children in the appropriate position.&quot;
However when we are transforming an existing block renderer to floated, we don't follow this rule and the floated renderer ends up with the wrong parent.
The fix is to apply the same logic when this style change happens.
Something like this (but probably with a bit more limited scope)
+    // This renderer might need a new parent.
+    if (m_style-&gt;isFloating() &amp;&amp; previousSibling() &amp;&amp; previousSibling()-&gt;isAnonymousBlock())
+        downcast&lt;RenderBoxModelObject&gt;(*parent()).moveChildTo(&amp;downcast&lt;RenderBoxModelObject&gt;(*previousSibling()), this);
right after calling RenderElement::removeAnonymousWrappersForInlinesIfNecessary() in RenderElement::styleDidChange() when s_noLongerAffectsParentBlock is true. 
This puts the floated renderer on the correct line (other &quot;out of flow&quot; style changes should probably trigger the same logic, though they don't impact rendering the same way float does).</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>