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

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: Added TODO 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
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/custom/object-sizing-zero-intrinsic-width-height-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..764746a08c87ad457e25978de08406838d0c2202 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,13 +303,16 @@ LayoutUnit LayoutReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh
if (style()->logicalWidth().isAuto()) {
bool computedHeightIsAuto = hasAutoHeightOrContainingBlockWithAutoHeight();
- bool hasIntrinsicWidth = constrainedSize.width() > 0;
+ // TODO(shanmuga.m@samsung.com): hasIntrinsicWidth/Height information should be obtained
+ // from LayoutBox::computeIntrinsicRatioInformation().
+ bool hasIntrinsicWidth = constrainedSize.width() > 0 || hasIntrinsicWidthForLayoutBox(contentLayoutObject);
// 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)
return computeReplacedLogicalWidthRespectingMinMaxWidth(constrainedSize.width(), shouldComputePreferred);
- bool hasIntrinsicHeight = constrainedSize.height() > 0;
+ bool hasIntrinsicHeight = constrainedSize.height() > 0 || hasIntrinsicHeightForLayoutBox(contentLayoutObject);
+
if (intrinsicRatio) {
// If 'height' and 'width' both have computed values of 'auto' and the element has no intrinsic width, but does have an intrinsic height and intrinsic ratio;
// 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
@@ -342,7 +368,9 @@ LayoutUnit LayoutReplaced::computeReplacedLogicalHeight() const
computeAspectRatioInformationForLayoutBox(contentLayoutObject, constrainedSize, intrinsicRatio);
bool widthIsAuto = style()->logicalWidth().isAuto();
- bool hasIntrinsicHeight = constrainedSize.height() > 0;
+ // TODO(shanmuga.m@samsung.com): hasIntrinsicWidth/Height information should be obtained
+ // from LayoutBox::computeIntrinsicRatioInformation().
+ 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)
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/custom/object-sizing-zero-intrinsic-width-height-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698