OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |