Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(664)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutReplaced.cpp

Issue 1587023002: SVG with zero intrinsic size should be respected always (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Align with review comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutReplaced.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutReplaced.cpp b/third_party/WebKit/Source/core/layout/LayoutReplaced.cpp
index 3e42a90b09d1e94d92945c587cc63ba4d5902a08..edd5d412b6903d11c1588b0462c6a6cbe349a89c 100644
--- a/third_party/WebKit/Source/core/layout/LayoutReplaced.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutReplaced.cpp
@@ -32,6 +32,7 @@
#include "core/paint/PaintInfo.h"
#include "core/paint/PaintLayer.h"
#include "core/paint/ReplacedPainter.h"
+#include "core/svg/SVGSVGElement.h"
#include "platform/LengthFunctions.h"
namespace blink {
@@ -266,6 +267,28 @@ void LayoutReplaced::computeIntrinsicRatioInformation(FloatSize& intrinsicSize,
intrinsicRatio = intrinsicSize.width() / intrinsicSize.height();
}
+static bool hasIntrinsicWidthForLayoutBox(LayoutBox* layoutObject)
+{
+ if (layoutObject && layoutObject->isSVGRoot()) {
+ SVGSVGElement* svg = toSVGSVGElement(layoutObject->node());
+ ASSERT(svg);
+ return svg->hasIntrinsicWidth();
+ }
+
+ return false;
+}
+
+static bool hasIntrinsicHeightForLayoutBox(LayoutBox* layoutObject)
+{
+ if (layoutObject && layoutObject->isSVGRoot()) {
+ SVGSVGElement* svg = toSVGSVGElement(layoutObject->node());
+ ASSERT(svg);
+ return svg->hasIntrinsicHeight();
+ }
+
+ return false;
+}
+
LayoutUnit LayoutReplaced::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
{
if (style()->logicalWidth().isSpecified() || style()->logicalWidth().isIntrinsic())
@@ -280,7 +303,7 @@ LayoutUnit LayoutReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh
if (style()->logicalWidth().isAuto()) {
bool computedHeightIsAuto = hasAutoHeightOrContainingBlockWithAutoHeight();
- bool hasIntrinsicWidth = constrainedSize.width() > 0;
+ bool hasIntrinsicWidth = constrainedSize.width() > 0 || hasIntrinsicWidthForLayoutBox(contentLayoutObject);
davve 2016/01/20 07:54:22 While I think this is safer than the previous fix,
// 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'.
if (computedHeightIsAuto && hasIntrinsicWidth)
@@ -342,7 +365,7 @@ LayoutUnit LayoutReplaced::computeReplacedLogicalHeight() const
computeAspectRatioInformationForLayoutBox(contentLayoutObject, constrainedSize, intrinsicRatio);
bool widthIsAuto = style()->logicalWidth().isAuto();
- bool hasIntrinsicHeight = constrainedSize.height() > 0;
+ bool hasIntrinsicHeight = constrainedSize.height() > 0 || hasIntrinsicHeightForLayoutBox(contentLayoutObject);
// If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic height, then that intrinsic height is the used value of 'height'.
if (widthIsAuto && hasIntrinsicHeight)

Powered by Google App Engine
This is Rietveld 408576698