Title: [214744] releases/WebKitGTK/webkit-2.16
Revision
214744
Author
carlo...@webkit.org
Date
2017-04-03 00:29:27 -0700 (Mon, 03 Apr 2017)

Log Message

Merge r214010 - Positioned SVG not sized correctly
https://bugs.webkit.org/show_bug.cgi?id=169693
<rdar://problem/30996893>

Reviewed by Zalan Bujtas.

Source/WebCore:

Test: svg/in-html/rect-positioned.html

Change computeReplacedLogicalHeight to take an estimatedUsedWidth. This
value is used instead of the available logical width to resolve replaced
elements without intrinsic sizes but with aspect ratios set.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::computeReplacedLogicalHeight):
* rendering/RenderBox.h:
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::computeConstrainedLogicalWidth):
(WebCore::RenderReplaced::computeReplacedLogicalWidth):
(WebCore::RenderReplaced::computeReplacedLogicalHeight):
* rendering/RenderReplaced.h:
* rendering/RenderVideo.cpp:
(WebCore::RenderVideo::computeReplacedLogicalHeight): Deleted.
* rendering/RenderVideo.h:
* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::computeReplacedLogicalWidth):
(WebCore::RenderSVGRoot::computeReplacedLogicalHeight):
* rendering/svg/RenderSVGRoot.h:

LayoutTests:

* svg/in-html/rect-positioned-expected.html: Added.
* svg/in-html/rect-positioned.html: Added.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog (214743 => 214744)


--- releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog	2017-04-03 07:23:50 UTC (rev 214743)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog	2017-04-03 07:29:27 UTC (rev 214744)
@@ -1,3 +1,14 @@
+2017-03-15  Dave Hyatt  <hy...@apple.com>
+
+        Positioned SVG not sized correctly
+        https://bugs.webkit.org/show_bug.cgi?id=169693
+        <rdar://problem/30996893>
+
+        Reviewed by Zalan Bujtas.
+
+        * svg/in-html/rect-positioned-expected.html: Added.
+        * svg/in-html/rect-positioned.html: Added.
+
 2017-03-14  Wenson Hsieh  <wenson_hs...@apple.com>
 
         RenderElements should unregister for viewport visibility callbacks when they are destroyed

Added: releases/WebKitGTK/webkit-2.16/LayoutTests/svg/in-html/rect-positioned-expected.html (0 => 214744)


--- releases/WebKitGTK/webkit-2.16/LayoutTests/svg/in-html/rect-positioned-expected.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/svg/in-html/rect-positioned-expected.html	2017-04-03 07:29:27 UTC (rev 214744)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+    <body>
+        <p>This blue rectangle is drawn via SVG.</p>
+        
+        <div style="width:600px;height:200px;background-color:lime; position:relative">
+            <svg viewBox="0 0 300 100" preserveAspectRatio="xMidYMid">
+                <<rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" />
+            </svg>
+    </body>

Added: releases/WebKitGTK/webkit-2.16/LayoutTests/svg/in-html/rect-positioned.html (0 => 214744)


--- releases/WebKitGTK/webkit-2.16/LayoutTests/svg/in-html/rect-positioned.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/svg/in-html/rect-positioned.html	2017-04-03 07:29:27 UTC (rev 214744)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+    <body>
+        <p>This blue rectangle is drawn via SVG.</p>
+        
+        <div style="width:600px;height:200px;background-color:lime; position:relative">
+            <svg viewBox="0 0 300 100" preserveAspectRatio="xMidYMid" style="position:absolute;top:0;right:0;bottom:0;left:0">
+                <<rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" />
+            </svg>
+    </body>

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog (214743 => 214744)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog	2017-04-03 07:23:50 UTC (rev 214743)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog	2017-04-03 07:29:27 UTC (rev 214744)
@@ -1,3 +1,33 @@
+2017-03-15  Dave Hyatt  <hy...@apple.com>
+
+        Positioned SVG not sized correctly
+        https://bugs.webkit.org/show_bug.cgi?id=169693
+        <rdar://problem/30996893>
+
+        Reviewed by Zalan Bujtas.
+
+        Test: svg/in-html/rect-positioned.html
+
+        Change computeReplacedLogicalHeight to take an estimatedUsedWidth. This
+        value is used instead of the available logical width to resolve replaced
+        elements without intrinsic sizes but with aspect ratios set.
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::computeReplacedLogicalHeight):
+        * rendering/RenderBox.h:
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::computeConstrainedLogicalWidth):
+        (WebCore::RenderReplaced::computeReplacedLogicalWidth):
+        (WebCore::RenderReplaced::computeReplacedLogicalHeight):
+        * rendering/RenderReplaced.h:
+        * rendering/RenderVideo.cpp:
+        (WebCore::RenderVideo::computeReplacedLogicalHeight): Deleted.
+        * rendering/RenderVideo.h:
+        * rendering/svg/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::computeReplacedLogicalWidth):
+        (WebCore::RenderSVGRoot::computeReplacedLogicalHeight):
+        * rendering/svg/RenderSVGRoot.h:
+
 2017-03-15  Zan Dobersek  <zdober...@igalia.com>
 
         [GTK] Initialize m_button, m_clickCount members in PlatformMouseEvent constructors

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderBox.cpp (214743 => 214744)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderBox.cpp	2017-04-03 07:23:50 UTC (rev 214743)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderBox.cpp	2017-04-03 07:29:27 UTC (rev 214744)
@@ -3114,7 +3114,7 @@
     return 0;
 }
 
-LayoutUnit RenderBox::computeReplacedLogicalHeight() const
+LayoutUnit RenderBox::computeReplacedLogicalHeight(std::optional<LayoutUnit>) const
 {
     return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(MainOrPreferredSize, style().logicalHeight()));
 }

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderBox.h (214743 => 214744)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderBox.h	2017-04-03 07:23:50 UTC (rev 214743)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderBox.h	2017-04-03 07:29:27 UTC (rev 214744)
@@ -416,7 +416,7 @@
     LayoutUnit computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit logicalHeight) const;
 
     virtual LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred  = ComputeActual) const;
-    virtual LayoutUnit computeReplacedLogicalHeight() const;
+    virtual LayoutUnit computeReplacedLogicalHeight(std::optional<LayoutUnit> estimatedUsedWidth = std::nullopt) const;
 
     bool hasDefiniteLogicalWidth() const;
     static bool percentageLogicalHeightIsResolvableFromBlock(const RenderBlock& containingBlock, bool outOfFlowPositioned, bool scrollsOverflowY);

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderReplaced.cpp (214743 => 214744)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderReplaced.cpp	2017-04-03 07:23:50 UTC (rev 214743)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderReplaced.cpp	2017-04-03 07:29:27 UTC (rev 214744)
@@ -405,6 +405,25 @@
     intrinsicRatio = intrinsicSize.width() / intrinsicSize.height();
 }
 
+LayoutUnit RenderReplaced::computeConstrainedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
+{
+    if (shouldComputePreferred == ComputePreferred)
+        return computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit(), ComputePreferred);
+
+    // 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 = containingBlock()->availableLogicalWidth();
+    
+    // This solves above equation for 'width' (== logicalWidth).
+    LayoutUnit marginStart = minimumValueForLength(style().marginStart(), logicalWidth);
+    LayoutUnit marginEnd = minimumValueForLength(style().marginEnd(), logicalWidth);
+    logicalWidth = std::max(LayoutUnit(), (logicalWidth - (marginStart + marginEnd + (size().width() - clientWidth()))));
+    return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth, shouldComputePreferred);
+}
+
 LayoutUnit RenderReplaced::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
 {
     if (style().logicalWidth().isSpecified() || style().logicalWidth().isIntrinsic())
@@ -418,7 +437,7 @@
     computeAspectRatioInformationForRenderBox(contentRenderer, constrainedSize, intrinsicRatio);
 
     if (style().logicalWidth().isAuto()) {
-        bool computedHeightIsAuto = hasAutoHeightOrContainingBlockWithAutoHeight();
+        bool computedHeightIsAuto = style().logicalHeight().isAuto();
         bool hasIntrinsicWidth = constrainedSize.width() > 0;
 
         // If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic width, then that intrinsic width is the used value of 'width'.
@@ -431,30 +450,21 @@
             // or if 'width' has a computed value of 'auto', 'height' has some other computed value, and the element does have an intrinsic ratio; then the used value
             // of 'width' is: (used height) * (intrinsic ratio)
             if (intrinsicRatio && ((computedHeightIsAuto && !hasIntrinsicWidth && hasIntrinsicHeight) || !computedHeightIsAuto)) {
-                LayoutUnit logicalHeight = computeReplacedLogicalHeight();
+                LayoutUnit estimatedUsedWidth = hasIntrinsicWidth ? LayoutUnit(constrainedSize.width()) : computeConstrainedLogicalWidth(shouldComputePreferred);
+                LayoutUnit logicalHeight = computeReplacedLogicalHeight(std::optional<LayoutUnit>(estimatedUsedWidth));
                 return computeReplacedLogicalWidthRespectingMinMaxWidth(roundToInt(round(logicalHeight * intrinsicRatio)), shouldComputePreferred);
             }
 
-            // If 'height' and 'width' both have computed values of 'auto' and the element has an intrinsic ratio but no intrinsic height or width, then the used value of
-            // 'width' is undefined in CSS 2.1. However, it is suggested that, if the containing block's width does not itself depend on the replaced element's width, then
-            // the used value of 'width' is calculated from the constraint equation used for block-level, non-replaced elements in normal flow.
-            if (computedHeightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeight) {
-                // 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 (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).
-                LayoutUnit marginStart = minimumValueForLength(style().marginStart(), logicalWidth);
-                LayoutUnit marginEnd = minimumValueForLength(style().marginEnd(), logicalWidth);
-                logicalWidth = std::max<LayoutUnit>(0, logicalWidth - (marginStart + marginEnd + (width() - clientWidth())));
-                return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth, shouldComputePreferred);
-            }
+            
+            // If 'height' and 'width' both have computed values of 'auto' and the
+            // element has an intrinsic ratio but no intrinsic height or width, then
+            // the used value of 'width' is undefined in CSS 2.1. However, it is
+            // suggested that, if the containing block's width does not itself depend
+            // on the replaced element's width, then the used value of 'width' is
+            // calculated from the constraint equation used for block-level,
+            // non-replaced elements in normal flow.
+            if (computedHeightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeight)
+                return computeConstrainedLogicalWidth(shouldComputePreferred);
         }
 
         // Otherwise, if 'width' has a computed value of 'auto', and the element has an intrinsic width, then that intrinsic width is the used value of 'width'.
@@ -471,7 +481,7 @@
     return computeReplacedLogicalWidthRespectingMinMaxWidth(intrinsicLogicalWidth(), shouldComputePreferred);
 }
 
-LayoutUnit RenderReplaced::computeReplacedLogicalHeight() const
+LayoutUnit RenderReplaced::computeReplacedLogicalHeight(std::optional<LayoutUnit> estimatedUsedWidth) const
 {
     // 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/visudet.html#propdef-height
     if (hasReplacedLogicalHeight())
@@ -493,8 +503,10 @@
 
     // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is:
     // (used width) / (intrinsic ratio)
-    if (intrinsicRatio)
-        return computeReplacedLogicalHeightRespectingMinMaxHeight(roundToInt(round(availableLogicalWidth() / intrinsicRatio)));
+    if (intrinsicRatio) {
+        LayoutUnit usedWidth = estimatedUsedWidth ? estimatedUsedWidth.value() : availableLogicalWidth();
+        return computeReplacedLogicalHeightRespectingMinMaxHeight(roundToInt(round(usedWidth / intrinsicRatio)));
+    }
 
     // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'.
     if (hasIntrinsicHeight)

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderReplaced.h (214743 => 214744)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderReplaced.h	2017-04-03 07:23:50 UTC (rev 214743)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderReplaced.h	2017-04-03 07:29:27 UTC (rev 214744)
@@ -30,7 +30,7 @@
     virtual ~RenderReplaced();
 
     LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred = ComputeActual) const override;
-    LayoutUnit computeReplacedLogicalHeight() const override;
+    LayoutUnit computeReplacedLogicalHeight(std::optional<LayoutUnit> estimatedUsedWidth = std::nullopt) const override;
 
     LayoutRect replacedContentRect(const LayoutSize& intrinsicSize) const;
 
@@ -69,6 +69,8 @@
     void willBeDestroyed() override;
 
 private:
+    LayoutUnit computeConstrainedLogicalWidth(ShouldComputePreferred) const;
+
     virtual RenderBox* embeddedContentBox() const { return 0; }
     const char* renderName() const override { return "RenderReplaced"; }
 

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderVideo.cpp (214743 => 214744)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderVideo.cpp	2017-04-03 07:23:50 UTC (rev 214743)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderVideo.cpp	2017-04-03 07:29:27 UTC (rev 214744)
@@ -245,11 +245,6 @@
     return RenderReplaced::computeReplacedLogicalWidth(shouldComputePreferred);
 }
 
-LayoutUnit RenderVideo::computeReplacedLogicalHeight() const
-{
-    return RenderReplaced::computeReplacedLogicalHeight();
-}
-
 LayoutUnit RenderVideo::minimumReplacedHeight() const 
 {
     return RenderReplaced::minimumReplacedHeight(); 

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderVideo.h (214743 => 214744)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderVideo.h	2017-04-03 07:23:50 UTC (rev 214743)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderVideo.h	2017-04-03 07:29:27 UTC (rev 214744)
@@ -71,7 +71,6 @@
     void layout() final;
 
     LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred  = ComputeActual) const final;
-    LayoutUnit computeReplacedLogicalHeight() const final;
     LayoutUnit minimumReplacedHeight() const final;
 
 #if ENABLE(FULLSCREEN_API)

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/svg/RenderSVGRoot.cpp (214743 => 214744)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/svg/RenderSVGRoot.cpp	2017-04-03 07:23:50 UTC (rev 214743)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/svg/RenderSVGRoot.cpp	2017-04-03 07:29:27 UTC (rev 214744)
@@ -125,17 +125,11 @@
     if (isEmbeddedThroughFrameContainingSVGDocument())
         return containingBlock()->availableLogicalWidth();
 
-    if (style().logicalWidth().isSpecified() || style().logicalMaxWidth().isSpecified())
-        return RenderReplaced::computeReplacedLogicalWidth(shouldComputePreferred);
-
-    if (svgSVGElement().hasIntrinsicWidth())
-        return resolveLengthAttributeForSVG(svgSVGElement().intrinsicWidth(), style().effectiveZoom(), containingBlock()->availableLogicalWidth());
-
     // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SVG.
     return RenderReplaced::computeReplacedLogicalWidth(shouldComputePreferred);
 }
 
-LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight() const
+LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight(std::optional<LayoutUnit> estimatedUsedWidth) const
 {
     // When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
     if (!m_containerSize.isEmpty())
@@ -144,14 +138,8 @@
     if (isEmbeddedThroughFrameContainingSVGDocument())
         return containingBlock()->availableLogicalHeight(IncludeMarginBorderPadding);
 
-    if (style().logicalHeight().isSpecified() || style().logicalMaxHeight().isSpecified())
-        return RenderReplaced::computeReplacedLogicalHeight();
-
-    if (svgSVGElement().hasIntrinsicHeight())
-        return resolveLengthAttributeForSVG(svgSVGElement().intrinsicHeight(), style().effectiveZoom(), containingBlock()->availableLogicalHeight(IncludeMarginBorderPadding).toFloat());
-
     // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SVG.
-    return RenderReplaced::computeReplacedLogicalHeight();
+    return RenderReplaced::computeReplacedLogicalHeight(estimatedUsedWidth);
 }
 
 void RenderSVGRoot::layout()

Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/svg/RenderSVGRoot.h (214743 => 214744)


--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/svg/RenderSVGRoot.h	2017-04-03 07:23:50 UTC (rev 214743)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/svg/RenderSVGRoot.h	2017-04-03 07:29:27 UTC (rev 214744)
@@ -71,7 +71,7 @@
     const char* renderName() const override { return "RenderSVGRoot"; }
 
     LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred  = ComputeActual) const override;
-    LayoutUnit computeReplacedLogicalHeight() const override;
+    LayoutUnit computeReplacedLogicalHeight(std::optional<LayoutUnit> estimatedUsedWidth = std::nullopt) const override;
     void layout() override;
     void paintReplaced(PaintInfo&, const LayoutPoint&) override;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to