OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 float LayoutTextCombine::width(unsigned from, unsigned length, const Font& font,
LayoutUnit xPosition, TextDirection direction, HashSet<const SimpleFontData*>*
fallbackFonts, FloatRect* glyphBounds) const | 54 float LayoutTextCombine::width(unsigned from, unsigned length, const Font& font,
LayoutUnit xPosition, TextDirection direction, HashSet<const SimpleFontData*>*
fallbackFonts, FloatRect* glyphBounds) const |
55 { | 55 { |
56 if (!length) | 56 if (!length) |
57 return 0; | 57 return 0; |
58 | 58 |
59 if (hasEmptyText()) | 59 if (hasEmptyText()) |
60 return 0; | 60 return 0; |
61 | 61 |
62 if (m_isCombined) | 62 if (m_isCombined) |
63 return font.fontDescription().computedSize(); | 63 return font.getFontDescription().computedSize(); |
64 | 64 |
65 return LayoutText::width(from, length, font, xPosition, direction, fallbackF
onts, glyphBounds); | 65 return LayoutText::width(from, length, font, xPosition, direction, fallbackF
onts, glyphBounds); |
66 } | 66 } |
67 | 67 |
68 void scaleHorizontallyAndTranslate(GraphicsContext& context, float scaleX, float
centerX, float offsetX, float offsetY) | 68 void scaleHorizontallyAndTranslate(GraphicsContext& context, float scaleX, float
centerX, float offsetX, float offsetY) |
69 { | 69 { |
70 context.concatCTM(AffineTransform(scaleX, 0, 0, 1, centerX * (1.0f - scaleX)
+ offsetX * scaleX, offsetY)); | 70 context.concatCTM(AffineTransform(scaleX, 0, 0, 1, centerX * (1.0f - scaleX)
+ offsetX * scaleX, offsetY)); |
71 } | 71 } |
72 | 72 |
73 void LayoutTextCombine::transformToInlineCoordinates(GraphicsContext& context, c
onst LayoutRect& boxRect, bool clip) const | 73 void LayoutTextCombine::transformToInlineCoordinates(GraphicsContext& context, c
onst LayoutRect& boxRect, bool clip) const |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 if (!m_needsFontUpdate) | 125 if (!m_needsFontUpdate) |
126 return; | 126 return; |
127 | 127 |
128 m_needsFontUpdate = false; | 128 m_needsFontUpdate = false; |
129 | 129 |
130 if (!m_isCombined) | 130 if (!m_isCombined) |
131 return; | 131 return; |
132 | 132 |
133 unsigned offset = 0; | 133 unsigned offset = 0; |
134 TextRun run = constructTextRun(originalFont(), this, offset, textLength(), s
tyleRef(), style()->direction()); | 134 TextRun run = constructTextRun(originalFont(), this, offset, textLength(), s
tyleRef(), style()->direction()); |
135 FontDescription description = originalFont().fontDescription(); | 135 FontDescription description = originalFont().getFontDescription(); |
136 float emWidth = description.computedSize(); | 136 float emWidth = description.computedSize(); |
137 if (!(style()->textDecorationsInEffect() & (TextDecorationUnderline | TextDe
corationOverline))) | 137 if (!(style()->textDecorationsInEffect() & (TextDecorationUnderline | TextDe
corationOverline))) |
138 emWidth *= textCombineMargin; | 138 emWidth *= textCombineMargin; |
139 | 139 |
140 description.setOrientation(FontOrientation::Horizontal); // We are going to
draw combined text horizontally. | 140 description.setOrientation(FontOrientation::Horizontal); // We are going to
draw combined text horizontally. |
141 m_combinedTextWidth = originalFont().width(run); | 141 m_combinedTextWidth = originalFont().width(run); |
142 | 142 |
143 FontSelector* fontSelector = style()->font().fontSelector(); | 143 FontSelector* fontSelector = style()->font().getFontSelector(); |
144 | 144 |
145 bool shouldUpdateFont = mutableStyleRef().setFontDescription(description); /
/ Need to change font orientation to horizontal. | 145 bool shouldUpdateFont = mutableStyleRef().setFontDescription(description); /
/ Need to change font orientation to horizontal. |
146 | 146 |
147 if (m_combinedTextWidth <= emWidth) { | 147 if (m_combinedTextWidth <= emWidth) { |
148 m_scaleX = 1.0f; | 148 m_scaleX = 1.0f; |
149 } else { | 149 } else { |
150 // Need to try compressed glyphs. | 150 // Need to try compressed glyphs. |
151 static const FontWidthVariant widthVariants[] = { HalfWidth, ThirdWidth,
QuarterWidth }; | 151 static const FontWidthVariant widthVariants[] = { HalfWidth, ThirdWidth,
QuarterWidth }; |
152 for (size_t i = 0 ; i < WTF_ARRAY_LENGTH(widthVariants) ; ++i) { | 152 for (size_t i = 0 ; i < WTF_ARRAY_LENGTH(widthVariants) ; ++i) { |
153 description.setWidthVariant(widthVariants[i]); | 153 description.setWidthVariant(widthVariants[i]); |
(...skipping 17 matching lines...) Expand all Loading... |
171 } else { | 171 } else { |
172 m_scaleX = 1.0f; | 172 m_scaleX = 1.0f; |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 if (shouldUpdateFont) | 176 if (shouldUpdateFont) |
177 style()->font().update(fontSelector); | 177 style()->font().update(fontSelector); |
178 } | 178 } |
179 | 179 |
180 } // namespace blink | 180 } // namespace blink |
OLD | NEW |