Title: [213748] trunk
Revision
213748
Author
hy...@apple.com
Date
2017-03-10 19:30:05 -0800 (Fri, 10 Mar 2017)

Log Message

Percentage constrained images shrinking inside blocks inside nested flex boxes
https://bugs.webkit.org/show_bug.cgi?id=169438

Reviewed by Dean Jackson.

Source/WebCore:

Added new test in fast/hidpi.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::computeChildPreferredLogicalWidths):
Make sure to clear out flexbox override sizes when computing preferred logical widths,
since they should not ever influence the preferred size.

LayoutTests:

* fast/hidpi/percent-height-image-nested-expected.html: Added.
* fast/hidpi/percent-height-image-nested.html: Added.
* fast/hidpi/resources/pic.jpg: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (213747 => 213748)


--- trunk/LayoutTests/ChangeLog	2017-03-11 03:24:30 UTC (rev 213747)
+++ trunk/LayoutTests/ChangeLog	2017-03-11 03:30:05 UTC (rev 213748)
@@ -1,3 +1,14 @@
+2017-03-10  Dave Hyatt  <hy...@apple.com>
+
+        Percentage constrained images shrinking inside blocks inside nested flex boxes
+        https://bugs.webkit.org/show_bug.cgi?id=169438
+
+        Reviewed by Dean Jackson.
+
+        * fast/hidpi/percent-height-image-nested-expected.html: Added.
+        * fast/hidpi/percent-height-image-nested.html: Added.
+        * fast/hidpi/resources/pic.jpg: Added.
+
 2017-03-10  Youenn Fablet  <you...@apple.com>
 
         Move libwebrtc backend to using tracks

Added: trunk/LayoutTests/fast/hidpi/percent-height-image-nested-expected.html (0 => 213748)


--- trunk/LayoutTests/fast/hidpi/percent-height-image-nested-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/hidpi/percent-height-image-nested-expected.html	2017-03-11 03:30:05 UTC (rev 213748)
@@ -0,0 +1,15 @@
+<!doctype html>
+<head>
+    <style>
+        .flex { display: flex }
+        img {  max-width:100%; }
+        body, html { height:100% }
+        html { overflow:hidden }
+        div { width:16.6% }
+        </style>
+</head>
+<body>
+    <div>
+    <img src=""
+   </div>
+ 

Added: trunk/LayoutTests/fast/hidpi/percent-height-image-nested.html (0 => 213748)


--- trunk/LayoutTests/fast/hidpi/percent-height-image-nested.html	                        (rev 0)
+++ trunk/LayoutTests/fast/hidpi/percent-height-image-nested.html	2017-03-11 03:30:05 UTC (rev 213748)
@@ -0,0 +1,24 @@
+<!doctype html>
+<head>
+<style>
+.flex { display: flex }
+img { max-height:80%; max-width:100%; }
+body, html { height:100% }
+html { overflow:hidden }
+</style>
+</head>
+<body>
+<div class="flex">
+    <div class="flex">
+        <div>
+             <img src=""
+        </div>
+    </div>
+</div>
+</div>
+<script>
+document.body.offsetWidth
+document.body.style.width = '20%'
+document.body.offsetHeight
+</script>
+

Added: trunk/LayoutTests/fast/hidpi/resources/blue-1500-2000-px.png


(Binary files differ)
Index: trunk/LayoutTests/fast/hidpi/resources/blue-1500-2000-px.png =================================================================== --- trunk/LayoutTests/fast/hidpi/resources/blue-1500-2000-px.png 2017-03-11 03:24:30 UTC (rev 213747) +++ trunk/LayoutTests/fast/hidpi/resources/blue-1500-2000-px.png 2017-03-11 03:30:05 UTC (rev 213748) Property changes on: trunk/LayoutTests/fast/hidpi/resources/blue-1500-2000-px.png ___________________________________________________________________

Added: svn:mime-type

+application/octet-stream \ No newline at end of property

Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (213747 => 213748)


--- trunk/LayoutTests/platform/ios-simulator/TestExpectations	2017-03-11 03:24:30 UTC (rev 213747)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations	2017-03-11 03:30:05 UTC (rev 213748)
@@ -2901,3 +2901,7 @@
 # Bundle upload is not supported on iOS
 fast/files/filereader-zip-bundle-using-open-panel.html [ Skip ]
 http/tests/local/fileapi/upload-zip-bundle-as-blob-using-open-panel.html [ Skip ]
+
+# Results differ from desktop
+fast/hidpi/percent-height-image-nested.html [ Skip ]
+

Modified: trunk/Source/WebCore/ChangeLog (213747 => 213748)


--- trunk/Source/WebCore/ChangeLog	2017-03-11 03:24:30 UTC (rev 213747)
+++ trunk/Source/WebCore/ChangeLog	2017-03-11 03:30:05 UTC (rev 213748)
@@ -1,3 +1,17 @@
+2017-03-10  Dave Hyatt  <hy...@apple.com>
+
+        Percentage constrained images shrinking inside blocks inside nested flex boxes
+        https://bugs.webkit.org/show_bug.cgi?id=169438
+
+        Reviewed by Dean Jackson.
+
+        Added new test in fast/hidpi.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::computeChildPreferredLogicalWidths):
+        Make sure to clear out flexbox override sizes when computing preferred logical widths,
+        since they should not ever influence the preferred size.
+
 2017-03-10  Youenn Fablet  <you...@apple.com>
 
         Move libwebrtc backend to using tracks

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (213747 => 213748)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2017-03-11 03:24:30 UTC (rev 213747)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2017-03-11 03:30:05 UTC (rev 213748)
@@ -2878,9 +2878,34 @@
         minPreferredLogicalWidth = maxPreferredLogicalWidth = downcast<RenderBox>(child).computeLogicalHeightWithoutLayout();
         return;
     }
+    
+    // The preferred widths of flexbox children should never depend on override sizes. They should
+    // always be computed without regard for any overrides that are present.
+    std::optional<LayoutUnit> overrideHeight;
+    std::optional<LayoutUnit> overrideWidth;
+    
+    if (child.isBox()) {
+        auto& box = downcast<RenderBox>(child);
+        if (box.isFlexItem()) {
+            if (box.hasOverrideLogicalContentHeight())
+                overrideHeight = std::optional<LayoutUnit>(box.overrideLogicalContentHeight());
+            if (box.hasOverrideLogicalContentWidth())
+                overrideWidth = std::optional<LayoutUnit>(box.overrideLogicalContentWidth());
+            box.clearOverrideSize();
+        }
+    }
+    
     minPreferredLogicalWidth = child.minPreferredLogicalWidth();
     maxPreferredLogicalWidth = child.maxPreferredLogicalWidth();
     
+    if (child.isBox()) {
+        auto& box = downcast<RenderBox>(child);
+        if (overrideHeight)
+            box.setOverrideLogicalContentHeight(overrideHeight.value());
+        if (overrideWidth)
+            box.setOverrideLogicalContentWidth(overrideWidth.value());
+    }
+
     // For non-replaced blocks if the inline size is min|max-content or a definite
     // size the min|max-content contribution is that size plus border, padding and
     // margin https://drafts.csswg.org/css-sizing/#block-intrinsic

Modified: trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp (213747 => 213748)


--- trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2017-03-11 03:24:30 UTC (rev 213747)
+++ trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2017-03-11 03:30:05 UTC (rev 213748)
@@ -309,8 +309,6 @@
 
     ChildFrameRects oldChildRects;
     appendChildFrameRects(this, oldChildRects);
-    
-    dirtyForLayoutFromPercentageHeightDescendants();
 
     if (isHorizontal())
         layoutHorizontalBox(relayoutChildren);

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (213747 => 213748)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2017-03-11 03:24:30 UTC (rev 213747)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2017-03-11 03:30:05 UTC (rev 213748)
@@ -263,8 +263,6 @@
 
     beginUpdateScrollInfoAfterLayoutTransaction();
 
-    dirtyForLayoutFromPercentageHeightDescendants();
-
     prepareOrderIteratorAndMargins();
 
     // Fieldsets need to find their legend and position it inside the border of the object.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to