diff options
Diffstat (limited to 'Source/WebCore/rendering/svg/SVGTextFragment.h')
-rw-r--r-- | Source/WebCore/rendering/svg/SVGTextFragment.h | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/Source/WebCore/rendering/svg/SVGTextFragment.h b/Source/WebCore/rendering/svg/SVGTextFragment.h index b5b3c57..a44d0fa 100644 --- a/Source/WebCore/rendering/svg/SVGTextFragment.h +++ b/Source/WebCore/rendering/svg/SVGTextFragment.h @@ -31,6 +31,7 @@ struct SVGTextFragment { : characterOffset(0) , metricsListOffset(0) , length(0) + , isTextOnPath(false) , x(0) , y(0) , width(0) @@ -38,19 +39,74 @@ struct SVGTextFragment { { } + enum TransformType { + TransformRespectingTextLength, + TransformIgnoringTextLength + }; + + void buildFragmentTransform(AffineTransform& result, TransformType type = TransformRespectingTextLength) const + { + if (type == TransformIgnoringTextLength) { + result = transform; + transformAroundOrigin(result); + return; + } + + if (isTextOnPath) + buildTransformForTextOnPath(result); + else + buildTransformForTextOnLine(result); + } + // The first rendered character starts at RenderSVGInlineText::characters() + characterOffset. unsigned characterOffset; unsigned metricsListOffset; - unsigned length; + unsigned length : 31; + bool isTextOnPath : 1; float x; float y; float width; float height; - // Includes rotation/glyph-orientation-(horizontal|vertical) transforms, lengthAdjust="spacingAndGlyphs" (for textPath only), - // as well as orientation related shifts (see SVGTextLayoutEngine, which builds this transformation). + // Includes rotation/glyph-orientation-(horizontal|vertical) transforms, as well as orientation related shifts + // (see SVGTextLayoutEngine, which builds this transformation). AffineTransform transform; + + // Contains lengthAdjust related transformations, which are not allowd to influence the SVGTextQuery code. + AffineTransform lengthAdjustTransform; + +private: + void transformAroundOrigin(AffineTransform& result) const + { + // Returns (translate(x, y) * result) * translate(-x, -y). + result.setE(result.e() + x); + result.setF(result.f() + y); + result.translate(-x, -y); + } + + void buildTransformForTextOnPath(AffineTransform& result) const + { + // For text-on-path layout, multiply the transform with the lengthAdjustTransform before orienting the resulting transform. + result = lengthAdjustTransform.isIdentity() ? transform : transform * lengthAdjustTransform; + if (!result.isIdentity()) + transformAroundOrigin(result); + } + + void buildTransformForTextOnLine(AffineTransform& result) const + { + // For text-on-line layout, orient the transform first, then multiply the lengthAdjustTransform with the oriented transform. + if (transform.isIdentity()) { + result = lengthAdjustTransform; + return; + } + + result = transform; + transformAroundOrigin(result); + + if (!lengthAdjustTransform.isIdentity()) + result = lengthAdjustTransform * result; + } }; } // namespace WebCore |