diff options
author | Florin Malita <fmalita@chromium.org> | 2017-10-12 11:33:28 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-10-12 17:06:34 +0000 |
commit | ffe6ae49e48a8c5cb53cec93643a2ad054faf74a (patch) | |
tree | a05f09ad8de93641de8abdcb4a878443d40d8ae4 /experimental/svg/model/SkSVGNode.cpp | |
parent | 177e695589edb1f776cc5c28b9d3eee244d48284 (diff) |
[SVGDom] Add 'visibility' support
https://www.w3.org/TR/SVG/painting.html#VisibilityProperty
Change-Id: I8b872af26150d93cf39cf8eeba23c91e1decace3
Reviewed-on: https://skia-review.googlesource.com/58863
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental/svg/model/SkSVGNode.cpp')
-rw-r--r-- | experimental/svg/model/SkSVGNode.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/experimental/svg/model/SkSVGNode.cpp b/experimental/svg/model/SkSVGNode.cpp index dfd25bafbb..ddde838f8e 100644 --- a/experimental/svg/model/SkSVGNode.cpp +++ b/experimental/svg/model/SkSVGNode.cpp @@ -50,7 +50,10 @@ SkPath SkSVGNode::asPath(const SkSVGRenderContext& ctx) const { bool SkSVGNode::onPrepareToRender(SkSVGRenderContext* ctx) const { ctx->applyPresentationAttributes(fPresentationAttributes, this->hasChildren() ? 0 : SkSVGRenderContext::kLeaf); - return true; + + // visibility:hidden disables rendering + const auto visibility = ctx->presentationContext().fInherited.fVisibility.get()->type(); + return visibility != SkSVGVisibility::Type::kHidden; } void SkSVGNode::setAttribute(SkSVGAttribute attr, const SkSVGValue& v) { @@ -96,6 +99,10 @@ void SkSVGNode::setStrokeWidth(const SkSVGLength& strokeWidth) { fPresentationAttributes.fStrokeWidth.set(strokeWidth); } +void SkSVGNode::setVisibility(const SkSVGVisibility& visibility) { + fPresentationAttributes.fVisibility.set(visibility); +} + void SkSVGNode::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) { switch (attr) { case SkSVGAttribute::kClipPath: @@ -158,6 +165,11 @@ void SkSVGNode::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) { this->setStrokeWidth(*strokeWidth); } break; + case SkSVGAttribute::kVisibility: + if (const SkSVGVisibilityValue* visibility = v.as<SkSVGVisibilityValue>()) { + this->setVisibility(*visibility); + } + break; default: SkDebugf("attribute ID <%d> ignored for node <%d>\n", attr, fTag); break; |