Title: [200854] releases/WebKitGTK/webkit-2.12
Revision
200854
Author
[email protected]
Date
2016-05-13 06:35:08 -0700 (Fri, 13 May 2016)

Log Message

Merge r200486 - Do not attempt to compute min/max width.
https://bugs.webkit.org/show_bug.cgi?id=157320

Reviewed by David Hyatt.

Replaced elements with no intrinsic size (only with ratio) should not call the containing
block to compute the min/max width when the containing block's min/max width
depends on the children's intrinsic size. It could lead to infinite recursion.

Source/WebCore:

Test: fast/replaced/before-content-intrinsic-crash.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth): Unrelated code change.
* rendering/RenderImage.cpp: Unrelated code change.
(WebCore::RenderImage::RenderImage): Deleted.
* rendering/RenderImage.h:
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::computeReplacedLogicalWidth):

LayoutTests:

* fast/replaced/before-content-intrinsic-crash-expected.txt: Added.
* fast/replaced/before-content-intrinsic-crash.html: Added.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog (200853 => 200854)


--- releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog	2016-05-13 13:31:20 UTC (rev 200853)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog	2016-05-13 13:35:08 UTC (rev 200854)
@@ -1,3 +1,17 @@
+2016-05-05  Zalan Bujtas  <[email protected]>
+
+        Do not attempt to compute min/max width.
+        https://bugs.webkit.org/show_bug.cgi?id=157320
+
+        Reviewed by David Hyatt.
+
+        Replaced elements with no intrinsic size (only with ratio) should not call the containing
+        block to compute the min/max width when the containing block's min/max width
+        depends on the children's intrinsic size. It could lead to infinite recursion.
+
+        * fast/replaced/before-content-intrinsic-crash-expected.txt: Added.
+        * fast/replaced/before-content-intrinsic-crash.html: Added.
+
 2016-05-04  Daniel Bates  <[email protected]>
 
         CSP: Perform case sensitive match against path portion of source _expression_ URL that ends in '/'

Added: releases/WebKitGTK/webkit-2.12/LayoutTests/fast/replaced/before-content-intrinsic-crash-expected.txt (0 => 200854)


--- releases/WebKitGTK/webkit-2.12/LayoutTests/fast/replaced/before-content-intrinsic-crash-expected.txt	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/fast/replaced/before-content-intrinsic-crash-expected.txt	2016-05-13 13:35:08 UTC (rev 200854)
@@ -0,0 +1,2 @@
+PASS if no crash or ASSERT.
+

Added: releases/WebKitGTK/webkit-2.12/LayoutTests/fast/replaced/before-content-intrinsic-crash.html (0 => 200854)


--- releases/WebKitGTK/webkit-2.12/LayoutTests/fast/replaced/before-content-intrinsic-crash.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/fast/replaced/before-content-intrinsic-crash.html	2016-05-13 13:35:08 UTC (rev 200854)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that we don't crash when replaced element's (with no intrinsic width/height) parent has min-width/max-width.</title>
+<style>
+.minWidth { 
+    width: 0px; 
+	min-width: -webkit-min-content;
+}
+
+.minWidth::before { 
+    content: url(data:text/plain,broken); 
+}
+
+.maxWidth { 
+    width: 0px; 
+	max-width: -webkit-max-content;
+}
+
+.maxWidth::before { 
+    content: url(data:text/plain,broken); 
+}
+</style>
+</head>
+<body>
+PASS if no crash or ASSERT.
+<div class=minWidth></div>
+<div class=maxWidth></div>
+<div id=foo></div>
+<div id=bar></div>
+<script>
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+}
+
+setTimeout(function() {
+    document.getElementById("foo").className = "minWidth";
+    document.getElementById("bar").className = "maxWidth";
+    if (window.testRunner)
+        testRunner.notifyDone();
+}, 5);
+</script>
+</body>
+</html>

Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog (200853 => 200854)


--- releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog	2016-05-13 13:31:20 UTC (rev 200853)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog	2016-05-13 13:35:08 UTC (rev 200854)
@@ -1,3 +1,24 @@
+2016-05-05  Zalan Bujtas  <[email protected]>
+
+        Do not attempt to compute min/max width.
+        https://bugs.webkit.org/show_bug.cgi?id=157320
+
+        Reviewed by David Hyatt.
+
+        Replaced elements with no intrinsic size (only with ratio) should not call the containing
+        block to compute the min/max width when the containing block's min/max width
+        depends on the children's intrinsic size. It could lead to infinite recursion.
+
+        Test: fast/replaced/before-content-intrinsic-crash.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth): Unrelated code change.
+        * rendering/RenderImage.cpp: Unrelated code change.
+        (WebCore::RenderImage::RenderImage): Deleted.
+        * rendering/RenderImage.h:
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::computeReplacedLogicalWidth):
+
 2016-05-05  Carlos Garcia Campos  <[email protected]>
 
         [GStreamer] Adaptive streaming issues

Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderBox.cpp (200853 => 200854)


--- releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderBox.cpp	2016-05-13 13:31:20 UTC (rev 200853)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderBox.cpp	2016-05-13 13:35:08 UTC (rev 200854)
@@ -3032,8 +3032,12 @@
 
 LayoutUnit RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit logicalWidth, ShouldComputePreferred shouldComputePreferred) const
 {
-    LayoutUnit minLogicalWidth = (shouldComputePreferred == ComputePreferred && style().logicalMinWidth().isPercentOrCalculated()) || style().logicalMinWidth().isUndefined() ? logicalWidth : computeReplacedLogicalWidthUsing(MinSize, style().logicalMinWidth());
-    LayoutUnit maxLogicalWidth = (shouldComputePreferred == ComputePreferred && style().logicalMaxWidth().isPercentOrCalculated()) || style().logicalMaxWidth().isUndefined() ? logicalWidth : computeReplacedLogicalWidthUsing(MaxSize, style().logicalMaxWidth());
+    auto& logicalMinWidth = style().logicalMinWidth();
+    auto& logicalMaxWidth = style().logicalMaxWidth();
+    bool useLogicalWidthForMinWidth = (shouldComputePreferred == ComputePreferred && logicalMinWidth.isPercentOrCalculated()) || logicalMinWidth.isUndefined();
+    bool useLogicalWidthForMaxWidth = (shouldComputePreferred == ComputePreferred && logicalMaxWidth.isPercentOrCalculated()) || logicalMaxWidth.isUndefined();
+    auto minLogicalWidth =  useLogicalWidthForMinWidth ? logicalWidth : computeReplacedLogicalWidthUsing(MinSize, logicalMinWidth);
+    auto maxLogicalWidth =  useLogicalWidthForMaxWidth ? logicalWidth : computeReplacedLogicalWidthUsing(MaxSize, logicalMaxWidth);
     return std::max(minLogicalWidth, std::min(logicalWidth, maxLogicalWidth));
 }
 

Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderImage.cpp (200853 => 200854)


--- releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderImage.cpp	2016-05-13 13:31:20 UTC (rev 200853)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderImage.cpp	2016-05-13 13:35:08 UTC (rev 200854)
@@ -121,15 +121,10 @@
 RenderImage::RenderImage(Element& element, Ref<RenderStyle>&& style, StyleImage* styleImage, const float imageDevicePixelRatio)
     : RenderReplaced(element, WTFMove(style), IntSize())
     , m_imageResource(styleImage ? std::make_unique<RenderImageResourceStyleImage>(*styleImage) : std::make_unique<RenderImageResource>())
-    , m_needsToSetSizeForAltText(false)
-    , m_didIncrementVisuallyNonEmptyPixelCount(false)
-    , m_isGeneratedContent(false)
-    , m_hasShadowControls(false)
     , m_imageDevicePixelRatio(imageDevicePixelRatio)
 {
     updateAltText();
     imageResource().initialize(this);
-
     if (is<HTMLImageElement>(element))
         m_hasShadowControls = downcast<HTMLImageElement>(element).hasShadowControls();
 }
@@ -137,11 +132,6 @@
 RenderImage::RenderImage(Document& document, Ref<RenderStyle>&& style, StyleImage* styleImage)
     : RenderReplaced(document, WTFMove(style), IntSize())
     , m_imageResource(styleImage ? std::make_unique<RenderImageResourceStyleImage>(*styleImage) : std::make_unique<RenderImageResource>())
-    , m_needsToSetSizeForAltText(false)
-    , m_didIncrementVisuallyNonEmptyPixelCount(false)
-    , m_isGeneratedContent(false)
-    , m_hasShadowControls(false)
-    , m_imageDevicePixelRatio(1.0f)
 {
     imageResource().initialize(this);
 }

Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderImage.h (200853 => 200854)


--- releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderImage.h	2016-05-13 13:31:20 UTC (rev 200853)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderImage.h	2016-05-13 13:35:08 UTC (rev 200854)
@@ -124,11 +124,11 @@
     // Text to display as long as the image isn't available.
     String m_altText;
     std::unique_ptr<RenderImageResource> m_imageResource;
-    bool m_needsToSetSizeForAltText;
-    bool m_didIncrementVisuallyNonEmptyPixelCount;
-    bool m_isGeneratedContent;
-    bool m_hasShadowControls;
-    float m_imageDevicePixelRatio;
+    bool m_needsToSetSizeForAltText { false };
+    bool m_didIncrementVisuallyNonEmptyPixelCount { false };
+    bool m_isGeneratedContent { false };
+    bool m_hasShadowControls { false };
+    float m_imageDevicePixelRatio { 1 };
 
     friend class RenderImageScaleObserver;
 };

Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderReplaced.cpp (200853 => 200854)


--- releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderReplaced.cpp	2016-05-13 13:31:20 UTC (rev 200853)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/rendering/RenderReplaced.cpp	2016-05-13 13:35:08 UTC (rev 200854)
@@ -416,9 +416,11 @@
                 // The aforementioned 'constraint equation' used for block-level, non-replaced elements in normal flow:
                 // 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containing block
                 LayoutUnit logicalWidth;
-                if (RenderBlock* blockWithWidth = firstContainingBlockWithLogicalWidth(this))
-                    logicalWidth = blockWithWidth->computeReplacedLogicalWidthRespectingMinMaxWidth(blockWithWidth->computeReplacedLogicalWidthUsing(MainOrPreferredSize, blockWithWidth->style().logicalWidth()), shouldComputePreferred);
-                else
+                if (auto* blockWithWidth = firstContainingBlockWithLogicalWidth(this)) {
+                    logicalWidth = blockWithWidth->computeReplacedLogicalWidthUsing(MainOrPreferredSize, blockWithWidth->style().logicalWidth());
+                    if (!blockWithWidth->style().logicalMaxWidth().isMaxContent() && !blockWithWidth->style().logicalMinWidth().isMinContent())
+                        logicalWidth = blockWithWidth->computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth, shouldComputePreferred);
+                } else
                     logicalWidth = containingBlock()->availableLogicalWidth();
 
                 // This solves above equation for 'width' (== logicalWidth).
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to