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

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

Issue 1545443002: Helper for checking if an SVGTextFragment is transformed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/svg/SVGTextQuery.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 transformAroundOrigin(result); 52 transformAroundOrigin(result);
53 return; 53 return;
54 } 54 }
55 55
56 if (isTextOnPath) 56 if (isTextOnPath)
57 buildTransformForTextOnPath(result); 57 buildTransformForTextOnPath(result);
58 else 58 else
59 buildTransformForTextOnLine(result); 59 buildTransformForTextOnLine(result);
60 } 60 }
61 61
62 bool isTransformed() const { return affectedByTextLength() || !transform.isI dentity(); }
63
62 // The first laid out character starts at LayoutSVGInlineText::characters() + characterOffset. 64 // The first laid out character starts at LayoutSVGInlineText::characters() + characterOffset.
63 unsigned characterOffset; 65 unsigned characterOffset;
64 unsigned metricsListOffset; 66 unsigned metricsListOffset;
65 unsigned length : 31; 67 unsigned length : 31;
66 unsigned isTextOnPath : 1; 68 unsigned isTextOnPath : 1;
67 69
68 float x; 70 float x;
69 float y; 71 float y;
70 float width; 72 float width;
71 float height; 73 float height;
72 74
73 // Top and bottom are the amounts of glyph overflows exceeding the font metr ics' ascent and descent, respectively. 75 // Top and bottom are the amounts of glyph overflows exceeding the font metr ics' ascent and descent, respectively.
74 float glyphOverflowTop; 76 float glyphOverflowTop;
75 float glyphOverflowBottom; 77 float glyphOverflowBottom;
76 // Left and right are the amounts of glyph overflows exceeding the left and right edge of normal layout boundary, respectively. 78 // Left and right are the amounts of glyph overflows exceeding the left and right edge of normal layout boundary, respectively.
77 float glyphOverflowLeft; 79 float glyphOverflowLeft;
78 float glyphOverflowRight; 80 float glyphOverflowRight;
79 81
80 // Includes rotation/glyph-orientation-(horizontal|vertical) transforms, as well as orientation related shifts 82 // Includes rotation/glyph-orientation-(horizontal|vertical) transforms, as well as orientation related shifts
81 // (see SVGTextLayoutEngine, which builds this transformation). 83 // (see SVGTextLayoutEngine, which builds this transformation).
82 AffineTransform transform; 84 AffineTransform transform;
83 85
84 // Contains lengthAdjust related transformations, which are not allowd to in fluence the SVGTextQuery code. 86 // Contains lengthAdjust related transformations, which are not allowd to in fluence the SVGTextQuery code.
85 AffineTransform lengthAdjustTransform; 87 AffineTransform lengthAdjustTransform;
86 88
87 private: 89 private:
90 bool affectedByTextLength() const { return lengthAdjustTransform.a() != 1 || lengthAdjustTransform.d() != 1; }
91
88 void transformAroundOrigin(AffineTransform& result) const 92 void transformAroundOrigin(AffineTransform& result) const
89 { 93 {
90 // Returns (translate(x, y) * result) * translate(-x, -y). 94 // Returns (translate(x, y) * result) * translate(-x, -y).
91 result.setE(result.e() + x); 95 result.setE(result.e() + x);
92 result.setF(result.f() + y); 96 result.setF(result.f() + y);
93 result.translate(-x, -y); 97 result.translate(-x, -y);
94 } 98 }
95 99
96 void buildTransformForTextOnPath(AffineTransform& result) const 100 void buildTransformForTextOnPath(AffineTransform& result) const
97 { 101 {
98 // For text-on-path layout, multiply the transform with the lengthAdjust Transform before orienting the resulting transform. 102 // For text-on-path layout, multiply the transform with the lengthAdjust Transform before orienting the resulting transform.
99 result = lengthAdjustTransform.isIdentity() ? transform : transform * le ngthAdjustTransform; 103 result = !affectedByTextLength() ? transform : transform * lengthAdjustT ransform;
100 if (!result.isIdentity()) 104 if (!result.isIdentity())
101 transformAroundOrigin(result); 105 transformAroundOrigin(result);
102 } 106 }
103 107
104 void buildTransformForTextOnLine(AffineTransform& result) const 108 void buildTransformForTextOnLine(AffineTransform& result) const
105 { 109 {
106 // For text-on-line layout, orient the transform first, then multiply th e lengthAdjustTransform with the oriented transform. 110 // For text-on-line layout, orient the transform first, then multiply th e lengthAdjustTransform with the oriented transform.
107 if (transform.isIdentity()) { 111 if (transform.isIdentity()) {
108 result = lengthAdjustTransform; 112 result = lengthAdjustTransform;
109 return; 113 return;
110 } 114 }
111 115
112 result = transform; 116 result = transform;
113 transformAroundOrigin(result); 117 transformAroundOrigin(result);
114 result.preMultiply(lengthAdjustTransform); 118 result.preMultiply(lengthAdjustTransform);
115 } 119 }
116 }; 120 };
117 121
118 } // namespace blink 122 } // namespace blink
119 123
120 #endif 124 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/svg/SVGTextQuery.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698