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 28 matching lines...) Expand all Loading... | |
| 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_hasLoadingFallback(false) | 48 , m_hasLoadingFallback(false) |
| 49 , m_hasCustomFont(false) | |
| 49 { | 50 { |
| 50 } | 51 } |
| 51 | 52 |
| 52 void FontFallbackList::invalidate(PassRefPtrWillBeRawPtr<FontSelector> fontSelec tor) | 53 void FontFallbackList::invalidate(PassRefPtrWillBeRawPtr<FontSelector> fontSelec tor) |
| 53 { | 54 { |
| 54 releaseFontData(); | 55 releaseFontData(); |
| 55 m_fontList.clear(); | 56 m_fontList.clear(); |
| 56 m_pageZero = 0; | 57 m_pageZero = 0; |
| 57 m_pages.clear(); | 58 m_pages.clear(); |
| 58 m_cachedPrimarySimpleFontData = 0; | 59 m_cachedPrimarySimpleFontData = 0; |
| 59 m_familyIndex = 0; | 60 m_familyIndex = 0; |
| 60 m_hasLoadingFallback = false; | 61 m_hasLoadingFallback = false; |
| 62 m_hasCustomFont = false; | |
| 61 if (m_fontSelector != fontSelector) | 63 if (m_fontSelector != fontSelector) |
| 62 m_fontSelector = fontSelector; | 64 m_fontSelector = fontSelector; |
| 63 m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0; | 65 m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0; |
| 64 m_generation = FontCache::fontCache()->generation(); | 66 m_generation = FontCache::fontCache()->generation(); |
| 65 m_cachingWordShaper.clear(); | 67 m_cachingWordShaper.clear(); |
| 66 } | 68 } |
| 67 | 69 |
| 68 void FontFallbackList::releaseFontData() | 70 void FontFallbackList::releaseFontData() |
| 69 { | 71 { |
| 70 unsigned numFonts = m_fontList.size(); | 72 unsigned numFonts = m_fontList.size(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 84 unsigned numFonts = m_fontList.size(); | 86 unsigned numFonts = m_fontList.size(); |
| 85 for (unsigned i = 0; i < numFonts; ++i) { | 87 for (unsigned i = 0; i < numFonts; ++i) { |
| 86 if (m_fontList[i]->isLoading()) | 88 if (m_fontList[i]->isLoading()) |
| 87 return true; | 89 return true; |
| 88 } | 90 } |
| 89 return false; | 91 return false; |
| 90 } | 92 } |
| 91 | 93 |
| 92 bool FontFallbackList::shouldSkipDrawing() const | 94 bool FontFallbackList::shouldSkipDrawing() const |
| 93 { | 95 { |
| 94 if (!m_hasLoadingFallback) | 96 if (m_hasLoadingFallback) { |
| 95 return false; | 97 unsigned numFonts = m_fontList.size(); |
| 96 | 98 for (unsigned i = 0; i < numFonts; ++i) { |
| 97 unsigned numFonts = m_fontList.size(); | 99 if (m_fontList[i]->shouldSkipDrawing()) |
| 98 for (unsigned i = 0; i < numFonts; ++i) { | 100 return true; |
| 99 if (m_fontList[i]->shouldSkipDrawing()) | 101 } |
| 100 return true; | |
| 101 } | 102 } |
| 103 if (m_fontSelector) | |
| 104 m_fontSelector->reportFirstNonBlankText(m_hasCustomFont); | |
|
Bryan McQuade
2015/09/15 17:24:17
I'm still learning this code so I may be misunders
Kunihiko Sakamoto
2015/09/16 05:37:03
Agreed that reporting from shouldXXX is confusing.
| |
| 102 return false; | 105 return false; |
| 103 } | 106 } |
| 104 | 107 |
| 105 const SimpleFontData* FontFallbackList::determinePrimarySimpleFontData(const Fon tDescription& fontDescription) const | 108 const SimpleFontData* FontFallbackList::determinePrimarySimpleFontData(const Fon tDescription& fontDescription) const |
| 106 { | 109 { |
| 107 bool shouldLoadCustomFont = true; | 110 bool shouldLoadCustomFont = true; |
| 108 | 111 |
| 109 for (unsigned fontIndex = 0; ; ++fontIndex) { | 112 for (unsigned fontIndex = 0; ; ++fontIndex) { |
| 110 const FontData* fontData = fontDataAt(fontDescription, fontIndex); | 113 const FontData* fontData = fontDataAt(fontDescription, fontIndex); |
| 111 if (!fontData) { | 114 if (!fontData) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 // Ask the font cache for the font data. | 207 // Ask the font cache for the font data. |
| 205 // We are obtaining this font for the first time. We keep track of the fami lies we've looked at before | 208 // We are obtaining this font for the first time. We keep track of the fami lies we've looked at before |
| 206 // in |m_familyIndex|, so that we never scan the same spot in the list twice . getFontData will adjust our | 209 // in |m_familyIndex|, so that we never scan the same spot in the list twice . getFontData will adjust our |
| 207 // |m_familyIndex| as it scans for the right font to make. | 210 // |m_familyIndex| as it scans for the right font to make. |
| 208 ASSERT(FontCache::fontCache()->generation() == m_generation); | 211 ASSERT(FontCache::fontCache()->generation() == m_generation); |
| 209 RefPtr<FontData> result = getFontData(fontDescription, m_familyIndex); | 212 RefPtr<FontData> result = getFontData(fontDescription, m_familyIndex); |
| 210 if (result) { | 213 if (result) { |
| 211 m_fontList.append(result); | 214 m_fontList.append(result); |
| 212 if (result->isLoadingFallback()) | 215 if (result->isLoadingFallback()) |
| 213 m_hasLoadingFallback = true; | 216 m_hasLoadingFallback = true; |
| 217 if (result->isCustomFont()) | |
| 218 m_hasCustomFont = true; | |
| 214 } | 219 } |
| 215 return result.get(); | 220 return result.get(); |
| 216 } | 221 } |
| 217 | 222 |
| 218 bool FontFallbackList::isValid() const | 223 bool FontFallbackList::isValid() const |
| 219 { | 224 { |
| 220 if (!m_fontSelector) | 225 if (!m_fontSelector) |
| 221 return m_fontSelectorVersion == 0; | 226 return m_fontSelectorVersion == 0; |
| 222 | 227 |
| 223 return m_fontSelector->version() == m_fontSelectorVersion; | 228 return m_fontSelector->version() == m_fontSelectorVersion; |
| 224 } | 229 } |
| 225 | 230 |
| 226 } // namespace blink | 231 } // namespace blink |
| OLD | NEW |