| 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 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #include "core/platform/graphics/FontFallbackList.h" | 30 #include "core/platform/graphics/FontFallbackList.h" |
| 31 | 31 |
| 32 #include "core/platform/graphics/Font.h" |
| 32 #include "core/platform/graphics/FontCache.h" | 33 #include "core/platform/graphics/FontCache.h" |
| 33 #include "core/platform/graphics/SegmentedFontData.h" | 34 #include "core/platform/graphics/SegmentedFontData.h" |
| 34 | 35 |
| 35 namespace WebCore { | 36 namespace WebCore { |
| 36 | 37 |
| 37 FontFallbackList::FontFallbackList() | 38 FontFallbackList::FontFallbackList() |
| 38 : m_pageZero(0) | 39 : m_pageZero(0) |
| 39 , m_cachedPrimarySimpleFontData(0) | 40 , m_cachedPrimarySimpleFontData(0) |
| 40 , m_fontSelector(0) | 41 , m_fontSelector(0) |
| 41 , m_fontSelectorVersion(0) | 42 , m_fontSelectorVersion(0) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 130 |
| 130 const FontData* FontFallbackList::fontDataAt(const Font* font, unsigned realized
FontIndex) const | 131 const FontData* FontFallbackList::fontDataAt(const Font* font, unsigned realized
FontIndex) const |
| 131 { | 132 { |
| 132 if (realizedFontIndex < m_fontList.size()) | 133 if (realizedFontIndex < m_fontList.size()) |
| 133 return m_fontList[realizedFontIndex].get(); // This fallback font is alr
eady in our list. | 134 return m_fontList[realizedFontIndex].get(); // This fallback font is alr
eady in our list. |
| 134 | 135 |
| 135 // Make sure we're not passing in some crazy value here. | 136 // Make sure we're not passing in some crazy value here. |
| 136 ASSERT(realizedFontIndex == m_fontList.size()); | 137 ASSERT(realizedFontIndex == m_fontList.size()); |
| 137 | 138 |
| 138 if (m_familyIndex == cAllFamiliesScanned) | 139 if (m_familyIndex == cAllFamiliesScanned) |
| 139 return 0; | 140 return fontCache()->getNonRetainedLastResortFallbackFont(font->fontDescr
iption()); |
| 140 | 141 |
| 141 // Ask the font cache for the font data. | 142 // Ask the font cache for the font data. |
| 142 // We are obtaining this font for the first time. We keep track of the fami
lies we've looked at before | 143 // We are obtaining this font for the first time. We keep track of the fami
lies we've looked at before |
| 143 // in |m_familyIndex|, so that we never scan the same spot in the list twice
. getFontData will adjust our | 144 // in |m_familyIndex|, so that we never scan the same spot in the list twice
. getFontData will adjust our |
| 144 // |m_familyIndex| as it scans for the right font to make. | 145 // |m_familyIndex| as it scans for the right font to make. |
| 145 ASSERT(fontCache()->generation() == m_generation); | 146 ASSERT(fontCache()->generation() == m_generation); |
| 146 RefPtr<FontData> result = fontCache()->getFontData(*font, m_familyIndex, m_f
ontSelector.get()); | 147 RefPtr<FontData> result = fontCache()->getFontData(*font, m_familyIndex, m_f
ontSelector.get()); |
| 147 if (result) { | 148 if (result) { |
| 148 m_fontList.append(result); | 149 m_fontList.append(result); |
| 149 if (result->isLoading()) | 150 if (result->isLoading()) |
| 150 m_loadingCustomFonts = true; | 151 m_loadingCustomFonts = true; |
| 151 } | 152 } |
| 152 return result.get(); | 153 return result.get(); |
| 153 } | 154 } |
| 154 | 155 |
| 155 void FontFallbackList::setPlatformFont(const FontPlatformData& platformData) | 156 void FontFallbackList::setPlatformFont(const FontPlatformData& platformData) |
| 156 { | 157 { |
| 157 m_familyIndex = cAllFamiliesScanned; | 158 m_familyIndex = cAllFamiliesScanned; |
| 158 ASSERT(fontCache()->generation() == m_generation); | 159 ASSERT(fontCache()->generation() == m_generation); |
| 159 RefPtr<FontData> fontData = fontCache()->getFontResourceData(&platformData); | 160 RefPtr<FontData> fontData = fontCache()->getFontResourceData(&platformData); |
| 160 m_fontList.append(fontData); | 161 m_fontList.append(fontData); |
| 161 } | 162 } |
| 162 | 163 |
| 163 } | 164 } |
| OLD | NEW |