<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Webkit not recalculating width when changing height of absolute-positioned div with image"
   href="https://bugs.webkit.org/show_bug.cgi?id=152588#c4">Comment # 4</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Webkit not recalculating width when changing height of absolute-positioned div with image"
   href="https://bugs.webkit.org/show_bug.cgi?id=152588">bug 152588</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>diff --git a/Source/WebCore/rendering/RenderBlockFlow.cpp b/Source/WebCore/rendering/RenderBlockFlow.cpp
index 286649c..96ed8c2 100644
--- a/Source/WebCore/rendering/RenderBlockFlow.cpp
+++ b/Source/WebCore/rendering/RenderBlockFlow.cpp
&#64;&#64; -479,6 +479,7 &#64;&#64; void RenderBlockFlow::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalH
     LayoutUnit maxFloatLogicalBottom = 0;
     if (!firstChild() &amp;&amp; !isAnonymousBlock())
         setChildrenInline(true);
+    dirtyForLayoutFromPercentageHeightDescendants();
     if (childrenInline())
         layoutInlineChildren(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
     else
&#64;&#64; -584,8 +585,6 &#64;&#64; void RenderBlockFlow::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalH

 void RenderBlockFlow::layoutBlockChildren(bool relayoutChildren, LayoutUnit&amp; maxFloatLogicalBottom)
 {
-    dirtyForLayoutFromPercentageHeightDescendants();
-
     LayoutUnit beforeEdge = borderAndPaddingBefore();
     LayoutUnit afterEdge = borderAndPaddingAfter() + scrollbarLogicalHeight();

^^It fixes the issue of not dirtying the replaced renderer's preferred width when the (non-direct)ancestor height changes.

The failing test case has 
(A)RenderBlock with fixed height.
  (B)RenderBlock with percentage height
    (C)RenderImage with percentage height

When (A)'s height is changed, we recalculate (C)'s height but we keep the original width (so we might lose the original aspect ratio)

In this case, gPercentHeightDescendantsMap has the (B)-&gt;(C) pair -since (A) has non-auto, non-percentage height. By changing (A)'s height, all the renderers (A)(B) and (C) are correctly marked dirty. However the preferred width bit does not get dirty (C) because the RenderBlock only calls dirtyForLayoutFromPercentageHeightDescendants() on its block children only -while here, (B) only has an inline child (C) 
Dave, do you know why it was originally added only to the block children path?</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>