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

Unified Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp

Issue 1679743006: Expand IntrinsicSizingInfo for SVG (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@propagate-whether-svg-has
Patch Set: Zero means zero Created 4 years, 10 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/Source/core/layout/svg/LayoutSVGRoot.h ('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/svg/LayoutSVGRoot.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp
index 840ffc71caabd6fc42427e2c0249692b45269f0f..6a16ef6e0c526312cb58eb02bede00019b3fea8b 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp
@@ -39,6 +39,15 @@
namespace blink {
+namespace {
+
+FloatSize calculateIntrinsicSize(const SVGSVGElement& svg)
+{
+ return FloatSize(floatValueForLength(svg.intrinsicWidth(), 0), floatValueForLength(svg.intrinsicHeight(), 0));
+}
+
+} // namespace
+
LayoutSVGRoot::LayoutSVGRoot(SVGElement* node)
: LayoutReplaced(node)
, m_objectBoundingBoxValid(false)
@@ -48,10 +57,13 @@ LayoutSVGRoot::LayoutSVGRoot(SVGElement* node)
, m_hasNonIsolatedBlendingDescendants(false)
, m_hasNonIsolatedBlendingDescendantsDirty(false)
{
- LayoutSize intrinsicSize(calculateIntrinsicSize());
- if (!intrinsicSize.width())
+ SVGSVGElement* svg = toSVGSVGElement(node);
+ ASSERT(svg);
+
+ LayoutSize intrinsicSize(calculateIntrinsicSize(*svg));
+ if (!svg->hasIntrinsicWidth())
intrinsicSize.setWidth(LayoutUnit(defaultWidth));
- if (!intrinsicSize.height())
+ if (!svg->hasIntrinsicHeight())
intrinsicSize.setHeight(LayoutUnit(defaultHeight));
setIntrinsicSize(intrinsicSize);
}
@@ -60,36 +72,29 @@ LayoutSVGRoot::~LayoutSVGRoot()
{
}
-FloatSize LayoutSVGRoot::calculateIntrinsicSize() const
-{
- SVGSVGElement* svg = toSVGSVGElement(node());
- ASSERT(svg);
-
- return FloatSize(floatValueForLength(svg->intrinsicWidth(), 0), floatValueForLength(svg->intrinsicHeight(), 0));
-}
-
void LayoutSVGRoot::computeIntrinsicSizingInfo(IntrinsicSizingInfo& intrinsicSizingInfo) const
{
// https://www.w3.org/TR/SVG/coords.html#IntrinsicSizing
- intrinsicSizingInfo.size = calculateIntrinsicSize();
- if (!isHorizontalWritingMode())
- intrinsicSizingInfo.size = intrinsicSizingInfo.size.transposedSize();
+ SVGSVGElement* svg = toSVGSVGElement(node());
+ ASSERT(svg);
+
+ intrinsicSizingInfo.size = calculateIntrinsicSize(*svg);
+ intrinsicSizingInfo.hasWidth = svg->hasIntrinsicWidth();
+ intrinsicSizingInfo.hasHeight = svg->hasIntrinsicHeight();
if (!intrinsicSizingInfo.size.isEmpty()) {
intrinsicSizingInfo.aspectRatio = intrinsicSizingInfo.size.width() / static_cast<double>(intrinsicSizingInfo.size.height());
} else {
- SVGSVGElement* svg = toSVGSVGElement(node());
- ASSERT(svg);
-
FloatSize viewBoxSize = svg->viewBox()->currentValue()->value().size();
if (!viewBoxSize.isEmpty()) {
// The viewBox can only yield an intrinsic ratio, not an intrinsic size.
intrinsicSizingInfo.aspectRatio = viewBoxSize.width() / static_cast<double>(viewBoxSize.height());
- if (!isHorizontalWritingMode())
- intrinsicSizingInfo.aspectRatio = 1 / intrinsicSizingInfo.aspectRatio;
}
}
+
+ if (!isHorizontalWritingMode())
+ intrinsicSizingInfo.transpose();
}
bool LayoutSVGRoot::isEmbeddedThroughSVGImage() const
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698