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

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

Issue 1548913002: Store a <scale, bias> tuple for textLength scale adjustment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Baseline. 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 b3ff267d7fbcac3914b9707fba8effaeca5362f6..ebd5fd2f68e693743f7af8638240b49b6318d702 100644
--- a/third_party/WebKit/Source/core/layout/svg/SVGTextFragment.h
+++ b/third_party/WebKit/Source/core/layout/svg/SVGTextFragment.h
@@ -33,10 +33,13 @@ struct SVGTextFragment {
, metricsListOffset(0)
, length(0)
, isTextOnPath(false)
+ , isVertical(false)
, x(0)
, y(0)
, width(0)
, height(0)
+ , lengthAdjustScale(1)
+ , lengthAdjustBias(0)
{
}
@@ -88,8 +91,9 @@ struct SVGTextFragment {
// The first laid out character starts at LayoutSVGInlineText::characters() + characterOffset.
unsigned characterOffset;
unsigned metricsListOffset;
- unsigned length : 31;
+ unsigned length : 30;
unsigned isTextOnPath : 1;
+ unsigned isVertical : 1;
float x;
float y;
@@ -108,7 +112,8 @@ struct SVGTextFragment {
AffineTransform transform;
// Contains lengthAdjust related transformations, which are not allowd to influence the SVGTextQuery code.
- AffineTransform lengthAdjustTransform;
+ float lengthAdjustScale;
+ float lengthAdjustBias;
private:
AffineTransform buildNormalFragmentTransform() const
@@ -118,7 +123,7 @@ private:
return buildTransformForTextOnLine();
}
- bool affectedByTextLength() const { return lengthAdjustTransform.a() != 1 || lengthAdjustTransform.d() != 1; }
+ bool affectedByTextLength() const { return lengthAdjustScale != 1; }
void transformAroundOrigin(AffineTransform& result) const
{
@@ -130,22 +135,42 @@ private:
AffineTransform buildTransformForTextOnPath() const
{
- // For text-on-path layout, multiply the transform with the lengthAdjustTransform before orienting the resulting transform.
- AffineTransform result = !affectedByTextLength() ? transform : transform * lengthAdjustTransform;
+ // For text-on-path layout, multiply the transform with the
+ // lengthAdjustTransform before orienting the resulting transform.
+ // T(x,y) * M(transform) [ * M(lengthAdjust) ] * T(-x,-y)
pdr. 2016/01/04 21:54:13 Supernit: The brackets around * M(lengthAdjust) ]
fs 2016/01/07 10:24:51 Removed [].
+ AffineTransform result = !affectedByTextLength() ? transform : transform * lengthAdjustTransform();
if (!result.isIdentity())
transformAroundOrigin(result);
return result;
}
+ AffineTransform lengthAdjustTransform() const
+ {
+ AffineTransform result;
+ if (!affectedByTextLength())
+ return result;
+ // Load a transform assuming horizontal direction, then swap if vertical.
+ result.setMatrix(lengthAdjustScale, 0, 0, 1, lengthAdjustBias, 0);
+ if (isVertical) {
+ result.setD(result.a());
+ result.setA(1);
+ result.setF(result.e());
+ result.setE(0);
+ }
+ return result;
+ }
+
AffineTransform buildTransformForTextOnLine() const
{
- // For text-on-line layout, orient the transform first, then multiply the lengthAdjustTransform with the oriented transform.
+ // For text-on-line layout, orient the transform first, then multiply
+ // the lengthAdjustTransform with the oriented transform.
+ // [ M(lengthAdjust) * ] T(x,y) * M(transform) * T(-x,-y)
if (transform.isIdentity())
- return lengthAdjustTransform;
+ return lengthAdjustTransform();
AffineTransform result = transform;
transformAroundOrigin(result);
- result.preMultiply(lengthAdjustTransform);
+ result.preMultiply(lengthAdjustTransform());
return result;
}
};

Powered by Google App Engine
This is Rietveld 408576698