[svg] Fix <use> bounds calculation
Previously we were using fX and fY as the top left of the returned
bounds. We need instead to offset the referenced node's bounds by fX,
fY.
While I was here I updated the attribute parsing to the new form and
changed the type of fHref from SkSVGString to SkSVGIRI.
Change-Id: I4bfb91bca62e47f5dabfbb4aad48cbb301a7ea36
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/354118
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Tyler Denniston <tdenniston@google.com>
diff --git a/modules/svg/include/SkSVGUse.h b/modules/svg/include/SkSVGUse.h
index 6c524e3..93c2d20 100644
--- a/modules/svg/include/SkSVGUse.h
+++ b/modules/svg/include/SkSVGUse.h
@@ -21,13 +21,11 @@
void appendChild(sk_sp<SkSVGNode>) override;
- void setHref(const SkSVGStringType&);
- void setX(const SkSVGLength&);
- void setY(const SkSVGLength&);
+ SVG_ATTR(X , SkSVGLength, SkSVGLength(0))
+ SVG_ATTR(Y , SkSVGLength, SkSVGLength(0))
+ SVG_ATTR(Href, SkSVGIRI , SkSVGIRI())
protected:
- void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
-
bool onPrepareToRender(SkSVGRenderContext*) const override;
void onRender(const SkSVGRenderContext&) const override;
SkPath onAsPath(const SkSVGRenderContext&) const override;
@@ -36,9 +34,7 @@
private:
SkSVGUse();
- SkSVGStringType fHref;
- SkSVGLength fX = SkSVGLength(0);
- SkSVGLength fY = SkSVGLength(0);
+ bool parseAndSetAttribute(const char*, const char*) override;
using INHERITED = SkSVGTransformableNode;
};