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 19 matching lines...) Expand all Loading... | |
| 30 #include "platform/fonts/FontFallbackList.h" | 30 #include "platform/fonts/FontFallbackList.h" |
| 31 | 31 |
| 32 #include "platform/FontFamilyNames.h" | 32 #include "platform/FontFamilyNames.h" |
| 33 #include "platform/fonts/FontCache.h" | 33 #include "platform/fonts/FontCache.h" |
| 34 #include "platform/fonts/FontDescription.h" | 34 #include "platform/fonts/FontDescription.h" |
| 35 #include "platform/fonts/FontFamily.h" | 35 #include "platform/fonts/FontFamily.h" |
| 36 #include "platform/fonts/SegmentedFontData.h" | 36 #include "platform/fonts/SegmentedFontData.h" |
| 37 #include "wtf/unicode/CharacterNames.h" | 37 #include "wtf/unicode/CharacterNames.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 using namespace WTF; | |
|
jsbell
2015/05/11 16:28:02
Are these using declarations necessary?
h.joshi
2015/05/12 04:20:14
Sorry for this, removed now. Was checking somethin
| |
| 41 using namespace Unicode; | |
| 40 | 42 |
| 41 FontFallbackList::FontFallbackList() | 43 FontFallbackList::FontFallbackList() |
| 42 : m_pageZero(0) | 44 : m_pageZero(0) |
| 43 , m_cachedPrimarySimpleFontData(0) | 45 , m_cachedPrimarySimpleFontData(0) |
| 44 , m_fontSelector(nullptr) | 46 , m_fontSelector(nullptr) |
| 45 , m_fontSelectorVersion(0) | 47 , m_fontSelectorVersion(0) |
| 46 , m_familyIndex(0) | 48 , m_familyIndex(0) |
| 47 , m_generation(FontCache::fontCache()->generation()) | 49 , m_generation(FontCache::fontCache()->generation()) |
| 48 , m_hasLoadingFallback(false) | 50 , m_hasLoadingFallback(false) |
| 49 { | 51 { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 const SimpleFontData* FontFallbackList::determinePrimarySimpleFontData(const Fon tDescription& fontDescription) const | 106 const SimpleFontData* FontFallbackList::determinePrimarySimpleFontData(const Fon tDescription& fontDescription) const |
| 105 { | 107 { |
| 106 bool shouldLoadCustomFont = true; | 108 bool shouldLoadCustomFont = true; |
| 107 | 109 |
| 108 for (unsigned fontIndex = 0; ; ++fontIndex) { | 110 for (unsigned fontIndex = 0; ; ++fontIndex) { |
| 109 const FontData* fontData = fontDataAt(fontDescription, fontIndex); | 111 const FontData* fontData = fontDataAt(fontDescription, fontIndex); |
| 110 if (!fontData) { | 112 if (!fontData) { |
| 111 // All fonts are custom fonts and are loading. Return the first Font Data. | 113 // All fonts are custom fonts and are loading. Return the first Font Data. |
| 112 fontData = fontDataAt(fontDescription, 0); | 114 fontData = fontDataAt(fontDescription, 0); |
| 113 if (fontData) | 115 if (fontData) |
| 114 return fontData->fontDataForCharacter(space); | 116 return fontData->fontDataForCharacter(spaceCharacter); |
| 115 | 117 |
| 116 SimpleFontData* lastResortFallback = FontCache::fontCache()->getLast ResortFallbackFont(fontDescription).get(); | 118 SimpleFontData* lastResortFallback = FontCache::fontCache()->getLast ResortFallbackFont(fontDescription).get(); |
| 117 ASSERT(lastResortFallback); | 119 ASSERT(lastResortFallback); |
| 118 return lastResortFallback; | 120 return lastResortFallback; |
| 119 } | 121 } |
| 120 | 122 |
| 121 if (fontData->isSegmented() && !toSegmentedFontData(fontData)->containsC haracter(space)) | 123 if (fontData->isSegmented() && !toSegmentedFontData(fontData)->containsC haracter(spaceCharacter)) |
| 122 continue; | 124 continue; |
| 123 | 125 |
| 124 const SimpleFontData* fontDataForSpace = fontData->fontDataForCharacter( space); | 126 const SimpleFontData* fontDataForSpace = fontData->fontDataForCharacter( spaceCharacter); |
| 125 ASSERT(fontDataForSpace); | 127 ASSERT(fontDataForSpace); |
| 126 | 128 |
| 127 // When a custom font is loading, we should use the correct fallback fon t to layout the text. | 129 // When a custom font is loading, we should use the correct fallback fon t to layout the text. |
| 128 // Here skip the temporary font for the loading custom font which may no t act as the correct fallback font. | 130 // Here skip the temporary font for the loading custom font which may no t act as the correct fallback font. |
| 129 if (!fontDataForSpace->isLoadingFallback()) | 131 if (!fontDataForSpace->isLoadingFallback()) |
| 130 return fontDataForSpace; | 132 return fontDataForSpace; |
| 131 | 133 |
| 132 if (fontData->isSegmented()) { | 134 if (fontData->isSegmented()) { |
| 133 const SegmentedFontData* segmented = toSegmentedFontData(fontData); | 135 const SegmentedFontData* segmented = toSegmentedFontData(fontData); |
| 134 for (unsigned i = 0; i < segmented->numRanges(); i++) { | 136 for (unsigned i = 0; i < segmented->numRanges(); i++) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 | 218 |
| 217 bool FontFallbackList::isValid() const | 219 bool FontFallbackList::isValid() const |
| 218 { | 220 { |
| 219 if (!m_fontSelector) | 221 if (!m_fontSelector) |
| 220 return m_fontSelectorVersion == 0; | 222 return m_fontSelectorVersion == 0; |
| 221 | 223 |
| 222 return m_fontSelector->version() == m_fontSelectorVersion; | 224 return m_fontSelector->version() == m_fontSelectorVersion; |
| 223 } | 225 } |
| 224 | 226 |
| 225 } // namespace blink | 227 } // namespace blink |
| OLD | NEW |