OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. |
6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. | 6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 } | 103 } |
104 | 104 |
105 float Font::drawText(GraphicsContext* context, const TextRunPaintInfo& runInfo, const FloatPoint& point, CustomFontNotReadyAction customFontNotReadyAction) cons t | 105 float Font::drawText(GraphicsContext* context, const TextRunPaintInfo& runInfo, const FloatPoint& point, CustomFontNotReadyAction customFontNotReadyAction) cons t |
106 { | 106 { |
107 // Don't draw anything while we are using custom fonts that are in the proce ss of loading, | 107 // Don't draw anything while we are using custom fonts that are in the proce ss of loading, |
108 // except if the 'force' argument is set to true (in which case it will use a fallback | 108 // except if the 'force' argument is set to true (in which case it will use a fallback |
109 // font). | 109 // font). |
110 if (shouldSkipDrawing() && customFontNotReadyAction == DoNotPaintIfFontNotRe ady) | 110 if (shouldSkipDrawing() && customFontNotReadyAction == DoNotPaintIfFontNotRe ady) |
111 return 0; | 111 return 0; |
112 | 112 |
113 CodePath codePathToUse = codePath(runInfo.run); | 113 if (codePath(runInfo.run, runInfo.from, runInfo.to) != ComplexPath) |
114 // FIXME: Use the fast code path once it handles partial runs with kerning a nd ligatures. See http://webkit.org/b/100050 | |
115 if (codePathToUse != ComplexPath && fontDescription().typesettingFeatures() && (runInfo.from || runInfo.to != runInfo.run.length())) | |
116 codePathToUse = ComplexPath; | |
117 | |
118 if (codePathToUse != ComplexPath) | |
119 return drawSimpleText(context, runInfo, point); | 114 return drawSimpleText(context, runInfo, point); |
120 | 115 |
121 return drawComplexText(context, runInfo, point); | 116 return drawComplexText(context, runInfo, point); |
122 } | 117 } |
123 | 118 |
124 void Font::drawEmphasisMarks(GraphicsContext* context, const TextRunPaintInfo& r unInfo, const AtomicString& mark, const FloatPoint& point) const | 119 void Font::drawEmphasisMarks(GraphicsContext* context, const TextRunPaintInfo& r unInfo, const AtomicString& mark, const FloatPoint& point) const |
125 { | 120 { |
126 if (shouldSkipDrawing()) | 121 if (shouldSkipDrawing()) |
127 return; | 122 return; |
128 | 123 |
129 CodePath codePathToUse = codePath(runInfo.run); | 124 if (codePath(runInfo.run, runInfo.from, runInfo.to) != ComplexPath) |
130 // FIXME: Use the fast code path once it handles partial runs with kerning a nd ligatures. See http://webkit.org/b/100050 | |
131 if (codePathToUse != ComplexPath && fontDescription().typesettingFeatures() && (runInfo.from || runInfo.to != runInfo.run.length())) | |
132 codePathToUse = ComplexPath; | |
133 | |
134 if (codePathToUse != ComplexPath) | |
135 drawEmphasisMarksForSimpleText(context, runInfo, mark, point); | 125 drawEmphasisMarksForSimpleText(context, runInfo, mark, point); |
136 else | 126 else |
137 drawEmphasisMarksForComplexText(context, runInfo, mark, point); | 127 drawEmphasisMarksForComplexText(context, runInfo, mark, point); |
138 } | 128 } |
139 | 129 |
140 static inline void updateGlyphOverflowFromBounds(const IntRectExtent& glyphBound s, | 130 static inline void updateGlyphOverflowFromBounds(const IntRectExtent& glyphBound s, |
141 const FontMetrics& fontMetrics, GlyphOverflow* glyphOverflow) | 131 const FontMetrics& fontMetrics, GlyphOverflow* glyphOverflow) |
142 { | 132 { |
143 glyphOverflow->top = std::max<int>(glyphOverflow->top, | 133 glyphOverflow->top = std::max<int>(glyphOverflow->top, |
144 glyphBounds.top() - (glyphOverflow->computeBounds ? 0 : fontMetrics.asce nt())); | 134 glyphBounds.top() - (glyphOverflow->computeBounds ? 0 : fontMetrics.asce nt())); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 | 194 |
205 PassTextBlobPtr Font::buildTextBlob(const TextRunPaintInfo& runInfo, const Float Point& textOrigin, bool couldUseLCDRenderedText, CustomFontNotReadyAction custom FontNotReadyAction) const | 195 PassTextBlobPtr Font::buildTextBlob(const TextRunPaintInfo& runInfo, const Float Point& textOrigin, bool couldUseLCDRenderedText, CustomFontNotReadyAction custom FontNotReadyAction) const |
206 { | 196 { |
207 ASSERT(RuntimeEnabledFeatures::textBlobEnabled()); | 197 ASSERT(RuntimeEnabledFeatures::textBlobEnabled()); |
208 | 198 |
209 // FIXME: Some logic in common with Font::drawText. Would be nice to | 199 // FIXME: Some logic in common with Font::drawText. Would be nice to |
210 // deduplicate. | 200 // deduplicate. |
211 if (shouldSkipDrawing() && customFontNotReadyAction == DoNotPaintIfFontNotRe ady) | 201 if (shouldSkipDrawing() && customFontNotReadyAction == DoNotPaintIfFontNotRe ady) |
212 return nullptr; | 202 return nullptr; |
213 | 203 |
214 CodePath codePathToUse = codePath(runInfo.run); | 204 if (codePath(runInfo.run, runInfo.from, runInfo.to) != ComplexPath) |
215 // FIXME: Use the fast code path once it handles partial runs with kerning a nd ligatures. See http://webkit.org/b/100050 | |
216 if (codePathToUse != ComplexPath && fontDescription().typesettingFeatures() && (runInfo.from || runInfo.to != runInfo.run.length())) | |
217 codePathToUse = ComplexPath; | |
218 | |
219 if (codePathToUse != ComplexPath) | |
220 return buildTextBlobForSimpleText(runInfo, textOrigin, couldUseLCDRender edText); | 205 return buildTextBlobForSimpleText(runInfo, textOrigin, couldUseLCDRender edText); |
221 | 206 |
222 return nullptr; | 207 return nullptr; |
223 } | 208 } |
224 | 209 |
225 PassTextBlobPtr Font::buildTextBlobForSimpleText(const TextRunPaintInfo& runInfo , const FloatPoint& textOrigin, bool couldUseLCDRenderedText) const | 210 PassTextBlobPtr Font::buildTextBlobForSimpleText(const TextRunPaintInfo& runInfo , const FloatPoint& textOrigin, bool couldUseLCDRenderedText) const |
226 { | 211 { |
227 GlyphBuffer glyphBuffer; | 212 GlyphBuffer glyphBuffer; |
228 float initialAdvance = getGlyphsAndAdvancesForSimpleText(runInfo, glyphBuffe r); | 213 float initialAdvance = getGlyphsAndAdvancesForSimpleText(runInfo, glyphBuffe r); |
229 | 214 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
290 | 275 |
291 advance = x; | 276 advance = x; |
292 return adoptRef(builder.build()); | 277 return adoptRef(builder.build()); |
293 } | 278 } |
294 | 279 |
295 | 280 |
296 FloatRect Font::selectionRectForText(const TextRun& run, const FloatPoint& point , int h, int from, int to, bool accountForGlyphBounds) const | 281 FloatRect Font::selectionRectForText(const TextRun& run, const FloatPoint& point , int h, int from, int to, bool accountForGlyphBounds) const |
297 { | 282 { |
298 to = (to == -1 ? run.length() : to); | 283 to = (to == -1 ? run.length() : to); |
299 | 284 |
300 CodePath codePathToUse = codePath(run); | 285 if (codePath(run, from, to) != ComplexPath) |
301 // FIXME: Use the fast code path once it handles partial runs with kerning a nd ligatures. See http://webkit.org/b/100050 | |
302 if (codePathToUse != ComplexPath && fontDescription().typesettingFeatures() && (from || to != run.length())) | |
303 codePathToUse = ComplexPath; | |
304 | |
305 if (codePathToUse != ComplexPath) | |
306 return selectionRectForSimpleText(run, point, h, from, to, accountForGly phBounds); | 286 return selectionRectForSimpleText(run, point, h, from, to, accountForGly phBounds); |
307 | 287 |
308 return selectionRectForComplexText(run, point, h, from, to); | 288 return selectionRectForComplexText(run, point, h, from, to); |
309 } | 289 } |
310 | 290 |
311 int Font::offsetForPosition(const TextRun& run, float x, bool includePartialGlyp hs) const | 291 int Font::offsetForPosition(const TextRun& run, float x, bool includePartialGlyp hs) const |
312 { | 292 { |
313 // FIXME: Use the fast code path once it handles partial runs with kerning a nd ligatures. See http://webkit.org/b/100050 | 293 // FIXME: Use the fast code path once it handles partial runs with kerning a nd ligatures. See http://webkit.org/b/100050 |
314 if (codePath(run) != ComplexPath && !fontDescription().typesettingFeatures() ) | 294 if (codePath(run) != ComplexPath && !fontDescription().typesettingFeatures() ) |
315 return offsetForPositionForSimpleText(run, x, includePartialGlyphs); | 295 return offsetForPositionForSimpleText(run, x, includePartialGlyphs); |
316 | 296 |
317 return offsetForPositionForComplexText(run, x, includePartialGlyphs); | 297 return offsetForPositionForComplexText(run, x, includePartialGlyphs); |
318 } | 298 } |
319 | 299 |
320 void Font::setCodePath(CodePath p) | 300 void Font::setCodePath(CodePath p) |
321 { | 301 { |
322 s_codePath = p; | 302 s_codePath = p; |
323 } | 303 } |
324 | 304 |
325 CodePath Font::codePath() | 305 CodePath Font::codePath(const TextRun& run, int from, int to) const |
Dominik Röttsches
2014/10/10 13:37:53
I would make the argument a TextRunPaintInfo - whi
f(malita)
2014/10/10 14:09:12
Done.
| |
326 { | 306 { |
327 return s_codePath; | 307 // FIXME: Do we really want to override s_codePath? |
Dominik Röttsches
2014/10/10 13:37:54
Can you elaborate on the question? What do we need
f(malita)
2014/10/10 14:09:12
Per comments, I assumed it is a way to force a par
| |
328 } | 308 // FIXME: Use the fast code path once it handles partial runs with kerning a nd ligatures. |
Dominik Röttsches
2014/10/10 13:37:54
The second FIXME is obsolete. We plan to remove th
f(malita)
2014/10/10 14:09:12
Do you mean SimpleShaper & friends are going away?
| |
309 // See http://webkit.org/b/100050 | |
310 // (Is that still feasible?) | |
311 if (fontDescription().typesettingFeatures() && (from || to != run.length())) | |
312 return ComplexPath; | |
329 | 313 |
330 CodePath Font::codePath(const TextRun& run) const | |
331 { | |
332 if (s_codePath != AutoPath) | 314 if (s_codePath != AutoPath) |
333 return s_codePath; | 315 return s_codePath; |
334 | 316 |
335 #if ENABLE(SVG_FONTS) | 317 #if ENABLE(SVG_FONTS) |
336 if (run.renderingContext()) | 318 if (run.renderingContext()) |
337 return SimplePath; | 319 return SimplePath; |
338 #endif | 320 #endif |
339 | 321 |
340 if (m_fontDescription.featureSettings() && m_fontDescription.featureSettings ()->size() > 0 && m_fontDescription.letterSpacing() == 0) | 322 if (m_fontDescription.featureSettings() && m_fontDescription.featureSettings ()->size() > 0 && m_fontDescription.letterSpacing() == 0) |
341 return ComplexPath; | 323 return ComplexPath; |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1182 if (delta <= 0) | 1164 if (delta <= 0) |
1183 break; | 1165 break; |
1184 } | 1166 } |
1185 } | 1167 } |
1186 } | 1168 } |
1187 | 1169 |
1188 return offset; | 1170 return offset; |
1189 } | 1171 } |
1190 | 1172 |
1191 } // namespace blink | 1173 } // namespace blink |
OLD | NEW |