Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Unified Diff: third_party/WebKit/Source/core/layout/svg/SVGTextFragment.h

Issue 1549503002: Return AffineTransform from SVGTextFragment::buildFragmentTransform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/svg/SVGTextFragment.h
diff --git a/third_party/WebKit/Source/core/layout/svg/SVGTextFragment.h b/third_party/WebKit/Source/core/layout/svg/SVGTextFragment.h
index d03e43b242f85fd2f5aadace4405bb6cf458242a..b3ff267d7fbcac3914b9707fba8effaeca5362f6 100644
--- a/third_party/WebKit/Source/core/layout/svg/SVGTextFragment.h
+++ b/third_party/WebKit/Source/core/layout/svg/SVGTextFragment.h
@@ -45,18 +45,42 @@ struct SVGTextFragment {
TransformIgnoringTextLength
};
- void buildFragmentTransform(AffineTransform& result, TransformType type = TransformRespectingTextLength) const
+ FloatRect boundingBox(float baseline) const
+ {
+ FloatRect fragmentRect(x, y - baseline, width, height);
+ if (!isTransformed())
+ return fragmentRect;
+ return buildNormalFragmentTransform().mapRect(fragmentRect);
+ }
+
+ FloatRect overflowBoundingBox(float baseline) const
+ {
+ FloatRect fragmentRect(
+ x - glyphOverflowLeft,
+ y - baseline - glyphOverflowTop,
+ width + glyphOverflowLeft + glyphOverflowRight,
+ height + glyphOverflowTop + glyphOverflowBottom);
+ if (!isTransformed())
+ return fragmentRect;
+ return buildNormalFragmentTransform().mapRect(fragmentRect);
+ }
+
+ FloatQuad boundingQuad(float baseline) const
+ {
+ FloatQuad fragmentQuad(FloatRect(x, y - baseline, width, height));
+ if (!isTransformed())
+ return fragmentQuad;
+ return buildNormalFragmentTransform().mapQuad(fragmentQuad);
+ }
+
+ AffineTransform buildFragmentTransform(TransformType type = TransformRespectingTextLength) const
{
if (type == TransformIgnoringTextLength) {
- result = transform;
+ AffineTransform result = transform;
transformAroundOrigin(result);
- return;
+ return result;
}
-
- if (isTextOnPath)
- buildTransformForTextOnPath(result);
- else
- buildTransformForTextOnLine(result);
+ return buildNormalFragmentTransform();
}
bool isTransformed() const { return affectedByTextLength() || !transform.isIdentity(); }
@@ -87,6 +111,13 @@ struct SVGTextFragment {
AffineTransform lengthAdjustTransform;
private:
+ AffineTransform buildNormalFragmentTransform() const
+ {
+ if (isTextOnPath)
+ return buildTransformForTextOnPath();
+ return buildTransformForTextOnLine();
+ }
+
bool affectedByTextLength() const { return lengthAdjustTransform.a() != 1 || lengthAdjustTransform.d() != 1; }
void transformAroundOrigin(AffineTransform& result) const
@@ -97,25 +128,25 @@ private:
result.translate(-x, -y);
}
- void buildTransformForTextOnPath(AffineTransform& result) const
+ AffineTransform buildTransformForTextOnPath() const
{
// For text-on-path layout, multiply the transform with the lengthAdjustTransform before orienting the resulting transform.
- result = !affectedByTextLength() ? transform : transform * lengthAdjustTransform;
+ AffineTransform result = !affectedByTextLength() ? transform : transform * lengthAdjustTransform;
if (!result.isIdentity())
transformAroundOrigin(result);
+ return result;
}
- void buildTransformForTextOnLine(AffineTransform& result) const
+ AffineTransform buildTransformForTextOnLine() const
{
// For text-on-line layout, orient the transform first, then multiply the lengthAdjustTransform with the oriented transform.
- if (transform.isIdentity()) {
- result = lengthAdjustTransform;
- return;
- }
+ if (transform.isIdentity())
+ return lengthAdjustTransform;
- result = transform;
+ AffineTransform result = transform;
transformAroundOrigin(result);
result.preMultiply(lengthAdjustTransform);
+ return result;
}
};

Powered by Google App Engine
This is Rietveld 408576698