[svg] Fix text object bounding box resolution
Two issues:
1) we are currently computing object bounding boxes using the
RenderContext of the client resource, which can override presentation
attributes
-> introduce an OBBScope to capture not just the current OBB node but
also its original RenderContext
2) text fragments must use the root <text> bounding box for OBB-relative
units [1]
-> update SkSVGTextFragment::renderText to not override the current
OBBScope; this ensures we're using the root element scope for the
whole text subtree
[1] https://www.w3.org/TR/SVG11/text.html#ObjectBoundingBoxUnitsTextObjects
Bug: skia:11936
Change-Id: Ib48ccd3dc22639de42ea150b881a26dda72fa4bf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/403037
Commit-Queue: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Tyler Denniston <tdenniston@google.com>
diff --git a/modules/svg/tests/Text.cpp b/modules/svg/tests/Text.cpp
index 7308ac8..bcfd034 100644
--- a/modules/svg/tests/Text.cpp
+++ b/modules/svg/tests/Text.cpp
@@ -163,7 +163,7 @@
SkNoDrawCanvas canvas(0, 0);
sk_sp<SkFontMgr> fmgr;
sk_sp<skresources::ResourceProvider> rp;
- const SkSVGRenderContext ctx(&canvas, fmgr, rp, mapper, lctx, pctx, nullptr);
+ const SkSVGRenderContext ctx(&canvas, fmgr, rp, mapper, lctx, pctx, {nullptr, nullptr});
SkSVGTextContext tctx(ctx, mock_cb);
SkSVGTextContext::ScopedPosResolver pa(*a, lctx, &tctx, tst.offseta);