Diff
Modified: trunk/LayoutTests/ChangeLog (214009 => 214010)
--- trunk/LayoutTests/ChangeLog 2017-03-15 22:04:50 UTC (rev 214009)
+++ trunk/LayoutTests/ChangeLog 2017-03-15 22:09:59 UTC (rev 214010)
@@ -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-15 Ryan Haddad <ryanhad...@apple.com>
Clean up TestExpectations for some WPT LayoutTests.
Added: trunk/LayoutTests/svg/in-html/rect-positioned-expected.html (0 => 214010)
--- trunk/LayoutTests/svg/in-html/rect-positioned-expected.html (rev 0)
+++ trunk/LayoutTests/svg/in-html/rect-positioned-expected.html 2017-03-15 22:09:59 UTC (rev 214010)
@@ -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: trunk/LayoutTests/svg/in-html/rect-positioned.html (0 => 214010)
--- trunk/LayoutTests/svg/in-html/rect-positioned.html (rev 0)
+++ trunk/LayoutTests/svg/in-html/rect-positioned.html 2017-03-15 22:09:59 UTC (rev 214010)
@@ -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: trunk/Source/WebCore/ChangeLog (214009 => 214010)
--- trunk/Source/WebCore/ChangeLog 2017-03-15 22:04:50 UTC (rev 214009)
+++ trunk/Source/WebCore/ChangeLog 2017-03-15 22:09:59 UTC (rev 214010)
@@ -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 Antoine Quint <grao...@apple.com>
[Modern Media Controls] Using the arrow keys to navigate in the tracks menu also scrolls the page
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (214009 => 214010)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2017-03-15 22:04:50 UTC (rev 214009)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2017-03-15 22:09:59 UTC (rev 214010)
@@ -3149,7 +3149,7 @@
return 0;
}
-LayoutUnit RenderBox::computeReplacedLogicalHeight() const
+LayoutUnit RenderBox::computeReplacedLogicalHeight(std::optional<LayoutUnit>) const
{
return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(MainOrPreferredSize, style().logicalHeight()));
}
Modified: trunk/Source/WebCore/rendering/RenderBox.h (214009 => 214010)
--- trunk/Source/WebCore/rendering/RenderBox.h 2017-03-15 22:04:50 UTC (rev 214009)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2017-03-15 22:09:59 UTC (rev 214010)
@@ -430,7 +430,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;
std::optional<LayoutUnit> computePercentageLogicalHeight(const Length& height) const;
Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (214009 => 214010)
--- trunk/Source/WebCore/rendering/RenderReplaced.cpp 2017-03-15 22:04:50 UTC (rev 214009)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp 2017-03-15 22:09:59 UTC (rev 214010)
@@ -408,6 +408,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())
@@ -421,7 +440,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'.
@@ -434,30 +453,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'.
@@ -474,7 +484,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())
@@ -496,8 +506,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: trunk/Source/WebCore/rendering/RenderReplaced.h (214009 => 214010)
--- trunk/Source/WebCore/rendering/RenderReplaced.h 2017-03-15 22:04:50 UTC (rev 214009)
+++ trunk/Source/WebCore/rendering/RenderReplaced.h 2017-03-15 22:09:59 UTC (rev 214010)
@@ -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: trunk/Source/WebCore/rendering/RenderVideo.cpp (214009 => 214010)
--- trunk/Source/WebCore/rendering/RenderVideo.cpp 2017-03-15 22:04:50 UTC (rev 214009)
+++ trunk/Source/WebCore/rendering/RenderVideo.cpp 2017-03-15 22:09:59 UTC (rev 214010)
@@ -245,11 +245,6 @@
return RenderReplaced::computeReplacedLogicalWidth(shouldComputePreferred);
}
-LayoutUnit RenderVideo::computeReplacedLogicalHeight() const
-{
- return RenderReplaced::computeReplacedLogicalHeight();
-}
-
LayoutUnit RenderVideo::minimumReplacedHeight() const
{
return RenderReplaced::minimumReplacedHeight();
Modified: trunk/Source/WebCore/rendering/RenderVideo.h (214009 => 214010)
--- trunk/Source/WebCore/rendering/RenderVideo.h 2017-03-15 22:04:50 UTC (rev 214009)
+++ trunk/Source/WebCore/rendering/RenderVideo.h 2017-03-15 22:09:59 UTC (rev 214010)
@@ -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: trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp (214009 => 214010)
--- trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp 2017-03-15 22:04:50 UTC (rev 214009)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp 2017-03-15 22:09:59 UTC (rev 214010)
@@ -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: trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h (214009 => 214010)
--- trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h 2017-03-15 22:04:50 UTC (rev 214009)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h 2017-03-15 22:09:59 UTC (rev 214010)
@@ -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;