Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 FontFallbackList::FontFallbackList() | 41 FontFallbackList::FontFallbackList() |
| 42 : m_pageZero(0) | 42 : m_pageZero(0) |
| 43 , m_cachedPrimarySimpleFontData(0) | 43 , m_cachedPrimarySimpleFontData(0) |
| 44 , m_fontSelector(nullptr) | 44 , m_fontSelector(nullptr) |
| 45 , m_fontSelectorVersion(0) | 45 , m_fontSelectorVersion(0) |
| 46 , m_familyIndex(0) | 46 , m_familyIndex(0) |
| 47 , m_generation(FontCache::fontCache()->generation()) | 47 , m_generation(FontCache::fontCache()->generation()) |
| 48 , m_pitch(UnknownPitch) | 48 , m_pitch(UnKnownPitchFont) |
| 49 , m_hasLoadingFallback(false) | 49 , m_hasLoadingFallback(false) |
| 50 { | 50 { |
| 51 } | 51 } |
| 52 | 52 |
| 53 void FontFallbackList::invalidate(PassRefPtrWillBeRawPtr<FontSelector> fontSelec tor) | 53 void FontFallbackList::invalidate(PassRefPtrWillBeRawPtr<FontSelector> fontSelec tor) |
| 54 { | 54 { |
| 55 releaseFontData(); | 55 releaseFontData(); |
| 56 m_fontList.clear(); | 56 m_fontList.clear(); |
| 57 m_pageZero = 0; | 57 m_pageZero = 0; |
| 58 m_pages.clear(); | 58 m_pages.clear(); |
| 59 m_cachedPrimarySimpleFontData = 0; | 59 m_cachedPrimarySimpleFontData = 0; |
| 60 m_familyIndex = 0; | 60 m_familyIndex = 0; |
| 61 m_pitch = UnknownPitch; | 61 m_pitch = UnKnownPitchFont; |
| 62 m_hasLoadingFallback = false; | 62 m_hasLoadingFallback = false; |
| 63 m_fontSelector = fontSelector; | 63 m_fontSelector = fontSelector; |
| 64 m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0; | 64 m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0; |
| 65 m_generation = FontCache::fontCache()->generation(); | 65 m_generation = FontCache::fontCache()->generation(); |
| 66 m_widthCache.clear(); | 66 m_widthCache.clear(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void FontFallbackList::releaseFontData() | 69 void FontFallbackList::releaseFontData() |
| 70 { | 70 { |
| 71 unsigned numFonts = m_fontList.size(); | 71 unsigned numFonts = m_fontList.size(); |
| 72 for (unsigned i = 0; i < numFonts; ++i) { | 72 for (unsigned i = 0; i < numFonts; ++i) { |
| 73 if (!m_fontList[i]->isCustomFont()) { | 73 if (!m_fontList[i]->isCustomFont()) { |
| 74 ASSERT(!m_fontList[i]->isSegmented()); | 74 ASSERT(!m_fontList[i]->isSegmented()); |
| 75 FontCache::fontCache()->releaseFontData(toSimpleFontData(m_fontList[ i])); | 75 FontCache::fontCache()->releaseFontData(toSimpleFontData(m_fontList[ i])); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 void FontFallbackList::determinePitch(const FontDescription& fontDescription) co nst | 80 void FontFallbackList::determinePitch(const FontDescription& fontDescription) co nst |
| 81 { | 81 { |
| 82 for (unsigned fontIndex = 0; ; ++fontIndex) { | 82 for (unsigned fontIndex = 0; ; ++fontIndex) { |
| 83 const FontData* fontData = fontDataAt(fontDescription, fontIndex); | 83 const FontData* fontData = fontDataAt(fontDescription, fontIndex); |
| 84 if (!fontData) { | 84 if (!fontData) { |
| 85 // All fonts are custom fonts and are loading. Fallback should be va riable pitch. | 85 // All fonts are custom fonts and are loading. Fallback should be va riable pitch. |
| 86 m_pitch = VariablePitch; | 86 m_pitch = NonFixedPitchFont; |
|
eae
2015/03/20 15:39:24
VariablePitch is a much better name than NonFixedP
h.joshi
2015/03/23 04:44:05
Done.
| |
| 87 break; | 87 break; |
| 88 } | 88 } |
| 89 | 89 |
| 90 const SimpleFontData* simpleFontData; | 90 const SimpleFontData* simpleFontData; |
| 91 if (fontData->isSegmented()) { | 91 if (fontData->isSegmented()) { |
| 92 const SegmentedFontData* segmentedFontData = toSegmentedFontData(fon tData); | 92 const SegmentedFontData* segmentedFontData = toSegmentedFontData(fon tData); |
| 93 if (segmentedFontData->numRanges() != 1 || !segmentedFontData->range At(0).isEntireRange()) { | 93 if (segmentedFontData->numRanges() != 1 || !segmentedFontData->range At(0).isEntireRange()) { |
| 94 m_pitch = VariablePitch; | 94 m_pitch = NonFixedPitchFont; |
| 95 break; | 95 break; |
| 96 } | 96 } |
| 97 simpleFontData = segmentedFontData->rangeAt(0).fontData().get(); | 97 simpleFontData = segmentedFontData->rangeAt(0).fontData().get(); |
| 98 } else { | 98 } else { |
| 99 simpleFontData = toSimpleFontData(fontData); | 99 simpleFontData = toSimpleFontData(fontData); |
| 100 } | 100 } |
| 101 if (!fontData->isLoadingFallback()) { | 101 if (!fontData->isLoadingFallback()) { |
| 102 m_pitch = simpleFontData->pitch(); | 102 m_pitch = simpleFontData->pitch(); |
| 103 break; | 103 break; |
| 104 } | 104 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 RefPtr<FontData> result = getFontData(fontDescription, m_familyIndex); | 238 RefPtr<FontData> result = getFontData(fontDescription, m_familyIndex); |
| 239 if (result) { | 239 if (result) { |
| 240 m_fontList.append(result); | 240 m_fontList.append(result); |
| 241 if (result->isLoadingFallback()) | 241 if (result->isLoadingFallback()) |
| 242 m_hasLoadingFallback = true; | 242 m_hasLoadingFallback = true; |
| 243 } | 243 } |
| 244 return result.get(); | 244 return result.get(); |
| 245 } | 245 } |
| 246 | 246 |
| 247 } // namespace blink | 247 } // namespace blink |
| OLD | NEW |