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

Side by Side Diff: experimental/svg/model/SkSVGSVG.cpp

Issue 2345533002: [SVGDom] Expose intrinsic size info (Closed)
Patch Set: private intrinsicSize() Created 4 years, 3 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
« no previous file with comments | « experimental/svg/model/SkSVGSVG.h ('k') | samplecode/SampleSVGFile.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkSVGRenderContext.h" 9 #include "SkSVGRenderContext.h"
10 #include "SkSVGSVG.h" 10 #include "SkSVGSVG.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 break; 88 break;
89 case SkSVGAttribute::kViewBox: 89 case SkSVGAttribute::kViewBox:
90 if (const auto* vb = v.as<SkSVGViewBoxValue>()) { 90 if (const auto* vb = v.as<SkSVGViewBoxValue>()) {
91 this->setViewBox(*vb); 91 this->setViewBox(*vb);
92 } 92 }
93 break; 93 break;
94 default: 94 default:
95 this->INHERITED::onSetAttribute(attr, v); 95 this->INHERITED::onSetAttribute(attr, v);
96 } 96 }
97 } 97 }
98
99 // https://www.w3.org/TR/SVG/coords.html#IntrinsicSizing
100 SkSize SkSVGSVG::intrinsicSize(const SkSVGLengthContext& lctx) const {
101 // Percentage values do not provide an intrinsic size.
102 if (fWidth.unit() == SkSVGLength::Unit::kPercentage ||
103 fHeight.unit() == SkSVGLength::Unit::kPercentage) {
104 return SkSize::Make(0, 0);
105 }
106
107 return SkSize::Make(lctx.resolve(fWidth, SkSVGLengthContext::LengthType::kHo rizontal),
108 lctx.resolve(fHeight, SkSVGLengthContext::LengthType::kV ertical));
109 }
OLDNEW
« no previous file with comments | « experimental/svg/model/SkSVGSVG.h ('k') | samplecode/SampleSVGFile.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698