diff options
author | fmalita <fmalita@chromium.org> | 2016-09-14 12:04:30 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-14 12:04:30 -0700 |
commit | e1baa7c105dad0f301ce34e5d6d1aa329334ef8c (patch) | |
tree | c79b25d4ed835bffccd2cbac9a6da433f1e51245 /experimental/svg/model/SkSVGSVG.cpp | |
parent | be362774f9b9e8964544a579281603ed995e6e5a (diff) |
[SVGDom] Expose intrinsic size info
* expose intrinsic size info on <svg> nodes.
* tweak the SkSVGDOM constructor to no longer take an container size
param, but instead default to intrinsic size
* update clients to call SkSVGDOM::setContainerSize() explicitly, when
needed
R=robertphillips@google.com,stephana@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2345533002
Review-Url: https://codereview.chromium.org/2345533002
Diffstat (limited to 'experimental/svg/model/SkSVGSVG.cpp')
-rw-r--r-- | experimental/svg/model/SkSVGSVG.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/experimental/svg/model/SkSVGSVG.cpp b/experimental/svg/model/SkSVGSVG.cpp index 13f18043c0..592992760a 100644 --- a/experimental/svg/model/SkSVGSVG.cpp +++ b/experimental/svg/model/SkSVGSVG.cpp @@ -95,3 +95,15 @@ void SkSVGSVG::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) { this->INHERITED::onSetAttribute(attr, v); } } + +// https://www.w3.org/TR/SVG/coords.html#IntrinsicSizing +SkSize SkSVGSVG::intrinsicSize(const SkSVGLengthContext& lctx) const { + // Percentage values do not provide an intrinsic size. + if (fWidth.unit() == SkSVGLength::Unit::kPercentage || + fHeight.unit() == SkSVGLength::Unit::kPercentage) { + return SkSize::Make(0, 0); + } + + return SkSize::Make(lctx.resolve(fWidth, SkSVGLengthContext::LengthType::kHorizontal), + lctx.resolve(fHeight, SkSVGLengthContext::LengthType::kVertical)); +} |