| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the internal font implementation. | 2 * This file is part of the internal font implementation. |
| 3 * | 3 * |
| 4 * Copyright (C) 2006, 2008, 2010 Apple Inc. All rights reserved. | 4 * Copyright (C) 2006, 2008, 2010 Apple Inc. All rights reserved. |
| 5 * Copyright (C) 2007-2008 Torch Mobile, Inc. | 5 * Copyright (C) 2007-2008 Torch Mobile, Inc. |
| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 mutable std::unique_ptr<DerivedFontData> m_derivedFontData; | 181 mutable std::unique_ptr<DerivedFontData> m_derivedFontData; |
| 182 | 182 |
| 183 RefPtr<CustomFontData> m_customFontData; | 183 RefPtr<CustomFontData> m_customFontData; |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 | 186 |
| 187 ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const | 187 ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const |
| 188 { | 188 { |
| 189 if (!m_platformData.size()) | |
| 190 return FloatRect(); | |
| 191 | |
| 192 static_assert(sizeof(glyph) == 2, "Glyph id should not be truncated."); | |
| 193 | |
| 194 FloatRect boundsResult; | 189 FloatRect boundsResult; |
| 195 if (m_glyphToBoundsMap) { | 190 if (m_glyphToBoundsMap) { |
| 196 boundsResult = m_glyphToBoundsMap->metricsForGlyph(glyph); | 191 boundsResult = m_glyphToBoundsMap->metricsForGlyph(glyph); |
| 197 if (boundsResult.width() != cGlyphSizeUnknown) | 192 if (boundsResult.width() != cGlyphSizeUnknown) |
| 198 return boundsResult; | 193 return boundsResult; |
| 199 } | 194 } |
| 200 | 195 |
| 201 boundsResult = platformBoundsForGlyph(glyph); | 196 boundsResult = platformBoundsForGlyph(glyph); |
| 202 if (!m_glyphToBoundsMap) | 197 if (!m_glyphToBoundsMap) |
| 203 m_glyphToBoundsMap = wrapUnique(new GlyphMetricsMap<FloatRect>); | 198 m_glyphToBoundsMap = wrapUnique(new GlyphMetricsMap<FloatRect>); |
| 204 m_glyphToBoundsMap->setMetricsForGlyph(glyph, boundsResult); | 199 m_glyphToBoundsMap->setMetricsForGlyph(glyph, boundsResult); |
| 205 | 200 |
| 206 return boundsResult; | 201 return boundsResult; |
| 207 } | 202 } |
| 208 | 203 |
| 209 ALWAYS_INLINE float SimpleFontData::widthForGlyph(Glyph glyph) const | 204 ALWAYS_INLINE float SimpleFontData::widthForGlyph(Glyph glyph) const |
| 210 { | 205 { |
| 211 if (!m_platformData.size()) | |
| 212 return 0; | |
| 213 static_assert(sizeof(glyph) == 2, "Glyph id should not be truncated."); | |
| 214 | |
| 215 float width = m_glyphToWidthMap.metricsForGlyph(glyph); | 206 float width = m_glyphToWidthMap.metricsForGlyph(glyph); |
| 216 if (width != cGlyphSizeUnknown) | 207 if (width != cGlyphSizeUnknown) |
| 217 return width; | 208 return width; |
| 218 | 209 |
| 219 width = platformWidthForGlyph(glyph); | 210 width = platformWidthForGlyph(glyph); |
| 220 | 211 |
| 221 m_glyphToWidthMap.setMetricsForGlyph(glyph, width); | 212 m_glyphToWidthMap.setMetricsForGlyph(glyph, width); |
| 222 return width; | 213 return width; |
| 223 } | 214 } |
| 224 | 215 |
| 225 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false); | 216 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false); |
| 226 | 217 |
| 227 } // namespace blink | 218 } // namespace blink |
| 228 #endif // SimpleFontData_h | 219 #endif // SimpleFontData_h |
| OLD | NEW |