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

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

Issue 1687503002: Introduce IntrinsicSizingInfo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make passed reference const 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2007, 2008, 2009 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2007, 2008, 2009 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. 5 * Copyright (C) 2009 Google, Inc.
6 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 62
63 FloatSize LayoutSVGRoot::calculateIntrinsicSize() const 63 FloatSize LayoutSVGRoot::calculateIntrinsicSize() const
64 { 64 {
65 SVGSVGElement* svg = toSVGSVGElement(node()); 65 SVGSVGElement* svg = toSVGSVGElement(node());
66 ASSERT(svg); 66 ASSERT(svg);
67 67
68 return FloatSize(floatValueForLength(svg->intrinsicWidth(), 0), floatValueFo rLength(svg->intrinsicHeight(), 0)); 68 return FloatSize(floatValueForLength(svg->intrinsicWidth(), 0), floatValueFo rLength(svg->intrinsicHeight(), 0));
69 } 69 }
70 70
71 void LayoutSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, d ouble& intrinsicRatio) const 71 void LayoutSVGRoot::computeIntrinsicSizingInfo(IntrinsicSizingInfo& intrinsicSiz ingInfo) const
72 { 72 {
73 // https://www.w3.org/TR/SVG/coords.html#IntrinsicSizing 73 // https://www.w3.org/TR/SVG/coords.html#IntrinsicSizing
74 intrinsicSize = calculateIntrinsicSize(); 74 intrinsicSizingInfo.size = calculateIntrinsicSize();
75 75
76 if (!isHorizontalWritingMode()) 76 if (!isHorizontalWritingMode())
77 intrinsicSize = intrinsicSize.transposedSize(); 77 intrinsicSizingInfo.size = intrinsicSizingInfo.size.transposedSize();
78 78
79 if (!intrinsicSize.isEmpty()) { 79 if (!intrinsicSizingInfo.size.isEmpty()) {
80 intrinsicRatio = intrinsicSize.width() / static_cast<double>(intrinsicSi ze.height()); 80 intrinsicSizingInfo.aspectRatio = intrinsicSizingInfo.size.width() / sta tic_cast<double>(intrinsicSizingInfo.size.height());
81 } else { 81 } else {
82 SVGSVGElement* svg = toSVGSVGElement(node()); 82 SVGSVGElement* svg = toSVGSVGElement(node());
83 ASSERT(svg); 83 ASSERT(svg);
84 84
85 FloatSize viewBoxSize = svg->viewBox()->currentValue()->value().size(); 85 FloatSize viewBoxSize = svg->viewBox()->currentValue()->value().size();
86 if (!viewBoxSize.isEmpty()) { 86 if (!viewBoxSize.isEmpty()) {
87 // The viewBox can only yield an intrinsic ratio, not an intrinsic s ize. 87 // The viewBox can only yield an intrinsic ratio, not an intrinsic s ize.
88 intrinsicRatio = viewBoxSize.width() / static_cast<double>(viewBoxSi ze.height()); 88 intrinsicSizingInfo.aspectRatio = viewBoxSize.width() / static_cast< double>(viewBoxSize.height());
89 if (!isHorizontalWritingMode()) 89 if (!isHorizontalWritingMode())
90 intrinsicRatio = 1 / intrinsicRatio; 90 intrinsicSizingInfo.aspectRatio = 1 / intrinsicSizingInfo.aspect Ratio;
91 } 91 }
92 } 92 }
93 } 93 }
94 94
95 bool LayoutSVGRoot::isEmbeddedThroughSVGImage() const 95 bool LayoutSVGRoot::isEmbeddedThroughSVGImage() const
96 { 96 {
97 return SVGImage::isInSVGImage(toSVGSVGElement(node())); 97 return SVGImage::isInSVGImage(toSVGSVGElement(node()));
98 } 98 }
99 99
100 bool LayoutSVGRoot::isEmbeddedThroughFrameContainingSVGDocument() const 100 bool LayoutSVGRoot::isEmbeddedThroughFrameContainingSVGDocument() const
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 updateHitTestResult(result, pointInBorderBox); 399 updateHitTestResult(result, pointInBorderBox);
400 if (result.addNodeToListBasedTestResult(node(), locationInContainer, boundsRect) == StopHitTesting) 400 if (result.addNodeToListBasedTestResult(node(), locationInContainer, boundsRect) == StopHitTesting)
401 return true; 401 return true;
402 } 402 }
403 } 403 }
404 404
405 return false; 405 return false;
406 } 406 }
407 407
408 } // namespace blink 408 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.h ('k') | third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698