OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef HarfBuzzShaper_h | 31 #ifndef HarfBuzzShaper_h |
32 #define HarfBuzzShaper_h | 32 #define HarfBuzzShaper_h |
33 | 33 |
34 #include "hb.h" | 34 #include "hb.h" |
35 #include "platform/fonts/GlyphBuffer.h" | 35 #include "platform/fonts/GlyphBuffer.h" |
| 36 #include "platform/geometry/FloatBoxExtent.h" |
36 #include "platform/geometry/FloatPoint.h" | 37 #include "platform/geometry/FloatPoint.h" |
37 #include "platform/text/TextRun.h" | 38 #include "platform/text/TextRun.h" |
38 #include "wtf/HashSet.h" | 39 #include "wtf/HashSet.h" |
39 #include "wtf/OwnPtr.h" | 40 #include "wtf/OwnPtr.h" |
40 #include "wtf/PassOwnPtr.h" | 41 #include "wtf/PassOwnPtr.h" |
41 #include "wtf/unicode/CharacterNames.h" | 42 #include "wtf/unicode/CharacterNames.h" |
42 #include "wtf/Vector.h" | 43 #include "wtf/Vector.h" |
43 | 44 |
44 namespace WebCore { | 45 namespace WebCore { |
45 | 46 |
46 class Font; | 47 class Font; |
47 class SimpleFontData; | 48 class SimpleFontData; |
48 class HarfBuzzShaper FINAL { | 49 class HarfBuzzShaper FINAL { |
49 public: | 50 public: |
50 enum ForTextEmphasisOrNot { | 51 enum ForTextEmphasisOrNot { |
51 NotForTextEmphasis, | 52 NotForTextEmphasis, |
52 ForTextEmphasis | 53 ForTextEmphasis |
53 }; | 54 }; |
54 | 55 |
55 HarfBuzzShaper(const Font*, const TextRun&, ForTextEmphasisOrNot = NotForTex
tEmphasis); | 56 HarfBuzzShaper(const Font*, const TextRun&, ForTextEmphasisOrNot = NotForTex
tEmphasis); |
56 | 57 |
57 void setDrawRange(int from, int to); | 58 void setDrawRange(int from, int to); |
58 bool shape(GlyphBuffer* = 0); | 59 bool shape(GlyphBuffer* = 0); |
59 FloatPoint adjustStartPoint(const FloatPoint&); | 60 FloatPoint adjustStartPoint(const FloatPoint&); |
60 float totalWidth() { return m_totalWidth; } | 61 float totalWidth() { return m_totalWidth; } |
61 int offsetForPosition(float targetX); | 62 int offsetForPosition(float targetX); |
62 FloatRect selectionRect(const FloatPoint&, int height, int from, int to); | 63 FloatRect selectionRect(const FloatPoint&, int height, int from, int to); |
63 | 64 FloatBoxExtent glyphBoundingBox() const { return m_glyphBoundingBox; } |
64 float minGlyphBoundingBoxX() const { return m_minGlyphBoundingBoxX; } | |
65 float maxGlyphBoundingBoxX() const { return m_maxGlyphBoundingBoxX; } | |
66 float minGlyphBoundingBoxY() const { return m_minGlyphBoundingBoxY; } | |
67 float maxGlyphBoundingBoxY() const { return m_maxGlyphBoundingBoxY; } | |
68 | 65 |
69 private: | 66 private: |
70 class HarfBuzzRun { | 67 class HarfBuzzRun { |
71 public: | 68 public: |
72 HarfBuzzRun(const HarfBuzzRun&); | 69 HarfBuzzRun(const HarfBuzzRun&); |
73 ~HarfBuzzRun(); | 70 ~HarfBuzzRun(); |
74 | 71 |
75 static PassOwnPtr<HarfBuzzRun> create(const SimpleFontData* fontData, un
signed startIndex, unsigned numCharacters, TextDirection direction, hb_script_t
script) | 72 static PassOwnPtr<HarfBuzzRun> create(const SimpleFontData* fontData, un
signed startIndex, unsigned numCharacters, TextDirection direction, hb_script_t
script) |
76 { | 73 { |
77 return adoptPtr(new HarfBuzzRun(fontData, startIndex, numCharacters,
direction, script)); | 74 return adoptPtr(new HarfBuzzRun(fontData, startIndex, numCharacters,
direction, script)); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 Vector<OwnPtr<HarfBuzzRun>, 16> m_harfBuzzRuns; | 153 Vector<OwnPtr<HarfBuzzRun>, 16> m_harfBuzzRuns; |
157 | 154 |
158 FloatPoint m_startOffset; | 155 FloatPoint m_startOffset; |
159 | 156 |
160 int m_fromIndex; | 157 int m_fromIndex; |
161 int m_toIndex; | 158 int m_toIndex; |
162 | 159 |
163 ForTextEmphasisOrNot m_forTextEmphasis; | 160 ForTextEmphasisOrNot m_forTextEmphasis; |
164 | 161 |
165 float m_totalWidth; | 162 float m_totalWidth; |
166 float m_minGlyphBoundingBoxX; | 163 FloatBoxExtent m_glyphBoundingBox; |
167 float m_maxGlyphBoundingBoxX; | |
168 float m_minGlyphBoundingBoxY; | |
169 float m_maxGlyphBoundingBoxY; | |
170 | 164 |
171 friend struct CachedShapingResults; | 165 friend struct CachedShapingResults; |
172 }; | 166 }; |
173 | 167 |
174 } // namespace WebCore | 168 } // namespace WebCore |
175 | 169 |
176 #endif // HarfBuzzShaper_h | 170 #endif // HarfBuzzShaper_h |
OLD | NEW |