| 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 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 CodePath codePathToUse = codePath(run); | 153 CodePath codePathToUse = codePath(run); |
| 154 if (codePathToUse != ComplexPath) { | 154 if (codePathToUse != ComplexPath) { |
| 155 // The complex path is more restrictive about returning fallback fonts t
han the simple path, so we need an explicit test to make their behaviors match. | 155 // The complex path is more restrictive about returning fallback fonts t
han the simple path, so we need an explicit test to make their behaviors match. |
| 156 if (!FontPlatformFeatures::canReturnFallbackFontsForComplexText()) | 156 if (!FontPlatformFeatures::canReturnFallbackFontsForComplexText()) |
| 157 fallbackFonts = 0; | 157 fallbackFonts = 0; |
| 158 // The simple path can optimize the case where glyph overflow is not obs
ervable. | 158 // The simple path can optimize the case where glyph overflow is not obs
ervable. |
| 159 if (codePathToUse != SimpleWithGlyphOverflowPath && (glyphOverflow && !g
lyphOverflow->computeBounds)) | 159 if (codePathToUse != SimpleWithGlyphOverflowPath && (glyphOverflow && !g
lyphOverflow->computeBounds)) |
| 160 glyphOverflow = 0; | 160 glyphOverflow = 0; |
| 161 } | 161 } |
| 162 | 162 |
| 163 bool hasKerningOrLigatures = fontDescription().typesettingFeatures() & (Kern
ing | Ligatures); | |
| 164 bool hasWordSpacingOrLetterSpacing = fontDescription().wordSpacing() || font
Description().letterSpacing(); | 163 bool hasWordSpacingOrLetterSpacing = fontDescription().wordSpacing() || font
Description().letterSpacing(); |
| 165 bool isCacheable = (codePathToUse == ComplexPath || hasKerningOrLigatures) | 164 bool isCacheable = codePathToUse == ComplexPath |
| 166 && !hasWordSpacingOrLetterSpacing // Word spacing and letter spacing can
change the width of a word. | 165 && !hasWordSpacingOrLetterSpacing // Word spacing and letter spacing can
change the width of a word. |
| 167 && !run.allowTabs(); // If we allow tabs and a tab occurs inside a word,
the width of the word varies based on its position on the line. | 166 && !run.allowTabs(); // If we allow tabs and a tab occurs inside a word,
the width of the word varies based on its position on the line. |
| 168 | 167 |
| 169 WidthCacheEntry* cacheEntry = isCacheable | 168 WidthCacheEntry* cacheEntry = isCacheable |
| 170 ? m_fontFallbackList->widthCache().add(run, WidthCacheEntry()) | 169 ? m_fontFallbackList->widthCache().add(run, WidthCacheEntry()) |
| 171 : 0; | 170 : 0; |
| 172 if (cacheEntry && cacheEntry->isValid()) { | 171 if (cacheEntry && cacheEntry->isValid()) { |
| 173 if (glyphOverflow) | 172 if (glyphOverflow) |
| 174 updateGlyphOverflowFromBounds(cacheEntry->glyphBounds, fontMetrics()
, glyphOverflow); | 173 updateGlyphOverflowFromBounds(cacheEntry->glyphBounds, fontMetrics()
, glyphOverflow); |
| 175 return cacheEntry->width; | 174 return cacheEntry->width; |
| 176 } | 175 } |
| 177 | 176 |
| 178 float result; | 177 float result; |
| 179 IntRectExtent glyphBounds; | 178 IntRectExtent glyphBounds; |
| 180 if (codePathToUse == ComplexPath) { | 179 if (codePathToUse == ComplexPath) { |
| 181 result = floatWidthForComplexText(run, fallbackFonts, &glyphBounds); | 180 result = floatWidthForComplexText(run, fallbackFonts, &glyphBounds); |
| 182 } else { | 181 } else { |
| 183 result = floatWidthForSimpleText(run, fallbackFonts, | 182 ASSERT(!isCacheable); |
| 184 glyphOverflow || isCacheable ? &glyphBounds : 0); | 183 result = floatWidthForSimpleText(run, fallbackFonts, glyphOverflow ? &gl
yphBounds : 0); |
| 185 } | 184 } |
| 186 | 185 |
| 187 if (cacheEntry && (!fallbackFonts || fallbackFonts->isEmpty())) { | 186 if (cacheEntry && (!fallbackFonts || fallbackFonts->isEmpty())) { |
| 188 cacheEntry->glyphBounds = glyphBounds; | 187 cacheEntry->glyphBounds = glyphBounds; |
| 189 cacheEntry->width = result; | 188 cacheEntry->width = result; |
| 190 } | 189 } |
| 191 | 190 |
| 192 if (glyphOverflow) | 191 if (glyphOverflow) |
| 193 updateGlyphOverflowFromBounds(glyphBounds, fontMetrics(), glyphOverflow)
; | 192 updateGlyphOverflowFromBounds(glyphBounds, fontMetrics(), glyphOverflow)
; |
| 194 return result; | 193 return result; |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 if (delta <= 0) | 832 if (delta <= 0) |
| 834 break; | 833 break; |
| 835 } | 834 } |
| 836 } | 835 } |
| 837 } | 836 } |
| 838 | 837 |
| 839 return offset; | 838 return offset; |
| 840 } | 839 } |
| 841 | 840 |
| 842 } | 841 } |
| OLD | NEW |