skia2/experimental/svg/model
Florin Malita 27aeb12d47 [svg] Reference cycle avoidance
Several SVG constructs reference other elements based on their ID (e.g.
<use>).  This can yield arbitrary reference chains and cycles.

Since all ID-based lookups are funneled through
SkSVGRenderContext::findNodeById(), a straightforward method to break
cycles is to temporarily clear the id->node association following a
lookup -- where "temporarily" refers to the local execution scope.

This approach works for all recursive traversals, as scopes are
nested/released in a natural manner.

  - introduce a scoped node reference wrapper (BorrowedNode), which
    clears the id mapping for its lifetime and restores it upon
    destruction
  - update findNodeById() return BorrowedNode values
  - update call sites as needed

Change-Id: I2ec5539b24e23b4fbbaff01a44460c41190028e0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282271
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Tyler Denniston <tdenniston@google.com>
2020-04-08 20:04:17 +00:00
..
SkPEG.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGAttribute.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGAttribute.h Add experimental support for svg text tag. 2020-03-27 13:56:49 +00:00
SkSVGAttributeParser.cpp [SVG] Fix application of skewX/skewY attributes 2020-04-08 19:51:47 +00:00
SkSVGAttributeParser.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGCircle.cpp Revert "Revert "switch to new filltype for SkPath"" 2019-11-26 17:43:14 +00:00
SkSVGCircle.h Revert "Revert "switch to new filltype for SkPath"" 2019-11-26 17:43:14 +00:00
SkSVGClipPath.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGClipPath.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGContainer.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGContainer.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGDefs.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGDOM.cpp Add experimental support for svg text tag. 2020-03-27 13:56:49 +00:00
SkSVGDOM.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGEllipse.cpp Revert "Revert "switch to new filltype for SkPath"" 2019-11-26 17:43:14 +00:00
SkSVGEllipse.h Revert "Revert "switch to new filltype for SkPath"" 2019-11-26 17:43:14 +00:00
SkSVGG.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGGradient.cpp [svg] Reference cycle avoidance 2020-04-08 20:04:17 +00:00
SkSVGGradient.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGHiddenContainer.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGIDMapper.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGLine.cpp Revert "Revert "switch to new filltype for SkPath"" 2019-11-26 17:43:14 +00:00
SkSVGLine.h Revert "Revert "switch to new filltype for SkPath"" 2019-11-26 17:43:14 +00:00
SkSVGLinearGradient.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGLinearGradient.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGNode.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGNode.h Add experimental support for svg text tag. 2020-03-27 13:56:49 +00:00
SkSVGPath.cpp Revert "Revert "switch to new filltype for SkPath"" 2019-11-26 17:43:14 +00:00
SkSVGPath.h Revert "Revert "switch to new filltype for SkPath"" 2019-11-26 17:43:14 +00:00
SkSVGPattern.cpp [svg] Reference cycle avoidance 2020-04-08 20:04:17 +00:00
SkSVGPattern.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGPoly.cpp Revert "Revert "switch to new filltype for SkPath"" 2019-11-26 17:43:14 +00:00
SkSVGPoly.h Revert "Revert "switch to new filltype for SkPath"" 2019-11-26 17:43:14 +00:00
SkSVGRadialGradient.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGRadialGradient.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGRect.cpp Revert "Revert "switch to new filltype for SkPath"" 2019-11-26 17:43:14 +00:00
SkSVGRect.h Revert "Revert "switch to new filltype for SkPath"" 2019-11-26 17:43:14 +00:00
SkSVGRenderContext.cpp [svg] Reference cycle avoidance 2020-04-08 20:04:17 +00:00
SkSVGRenderContext.h [svg] Reference cycle avoidance 2020-04-08 20:04:17 +00:00
SkSVGShape.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGShape.h Revert "Revert "switch to new filltype for SkPath"" 2019-11-26 17:43:14 +00:00
SkSVGStop.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGStop.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGSVG.cpp [SVG] Fix spec links 2020-04-08 15:48:08 +00:00
SkSVGSVG.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGText.cpp Add experimental support for svg text tag. 2020-03-27 13:56:49 +00:00
SkSVGText.h Add experimental support for svg text tag. 2020-03-27 13:56:49 +00:00
SkSVGTransformableNode.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGTransformableNode.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGTypes.h Revert "Revert "switch to new filltype for SkPath"" 2019-11-26 17:43:14 +00:00
SkSVGUse.cpp [svg] Reference cycle avoidance 2020-04-08 20:04:17 +00:00
SkSVGUse.h [SVG] Fix spec links 2020-04-08 15:48:08 +00:00
SkSVGValue.cpp rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
SkSVGValue.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00