| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 if (font_selector_ != font_selector) | 56 if (font_selector_ != font_selector) |
| 57 font_selector_ = font_selector; | 57 font_selector_ = font_selector; |
| 58 font_selector_version_ = font_selector_ ? font_selector_->Version() : 0; | 58 font_selector_version_ = font_selector_ ? font_selector_->Version() : 0; |
| 59 generation_ = FontCache::GetFontCache()->Generation(); | 59 generation_ = FontCache::GetFontCache()->Generation(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void FontFallbackList::ReleaseFontData() { | 62 void FontFallbackList::ReleaseFontData() { |
| 63 unsigned num_fonts = font_list_.size(); | 63 unsigned num_fonts = font_list_.size(); |
| 64 for (unsigned i = 0; i < num_fonts; ++i) { | 64 for (unsigned i = 0; i < num_fonts; ++i) { |
| 65 if (!font_list_[i]->IsCustomFont()) { | 65 if (!font_list_[i]->IsCustomFont()) { |
| 66 ASSERT(!font_list_[i]->IsSegmented()); | 66 DCHECK(!font_list_[i]->IsSegmented()); |
| 67 FontCache::GetFontCache()->ReleaseFontData( | 67 FontCache::GetFontCache()->ReleaseFontData( |
| 68 ToSimpleFontData(font_list_[i])); | 68 ToSimpleFontData(font_list_[i])); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 shape_cache_.reset(); // Clear the weak pointer to the cache instance. | 71 shape_cache_.reset(); // Clear the weak pointer to the cache instance. |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool FontFallbackList::LoadingCustomFonts() const { | 74 bool FontFallbackList::LoadingCustomFonts() const { |
| 75 if (!has_loading_fallback_) | 75 if (!has_loading_fallback_) |
| 76 return false; | 76 return false; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 104 if (!font_data) { | 104 if (!font_data) { |
| 105 // All fonts are custom fonts and are loading. Return the first FontData. | 105 // All fonts are custom fonts and are loading. Return the first FontData. |
| 106 font_data = FontDataAt(font_description, 0); | 106 font_data = FontDataAt(font_description, 0); |
| 107 if (font_data) | 107 if (font_data) |
| 108 return font_data->FontDataForCharacter(kSpaceCharacter); | 108 return font_data->FontDataForCharacter(kSpaceCharacter); |
| 109 | 109 |
| 110 SimpleFontData* last_resort_fallback = | 110 SimpleFontData* last_resort_fallback = |
| 111 FontCache::GetFontCache() | 111 FontCache::GetFontCache() |
| 112 ->GetLastResortFallbackFont(font_description) | 112 ->GetLastResortFallbackFont(font_description) |
| 113 .Get(); | 113 .Get(); |
| 114 ASSERT(last_resort_fallback); | 114 DCHECK(last_resort_fallback); |
| 115 return last_resort_fallback; | 115 return last_resort_fallback; |
| 116 } | 116 } |
| 117 | 117 |
| 118 if (font_data->IsSegmented() && | 118 if (font_data->IsSegmented() && |
| 119 !ToSegmentedFontData(font_data)->ContainsCharacter(kSpaceCharacter)) | 119 !ToSegmentedFontData(font_data)->ContainsCharacter(kSpaceCharacter)) |
| 120 continue; | 120 continue; |
| 121 | 121 |
| 122 const SimpleFontData* font_data_for_space = | 122 const SimpleFontData* font_data_for_space = |
| 123 font_data->FontDataForCharacter(kSpaceCharacter); | 123 font_data->FontDataForCharacter(kSpaceCharacter); |
| 124 ASSERT(font_data_for_space); | 124 DCHECK(font_data_for_space); |
| 125 | 125 |
| 126 // When a custom font is loading, we should use the correct fallback font to | 126 // When a custom font is loading, we should use the correct fallback font to |
| 127 // layout the text. Here skip the temporary font for the loading custom | 127 // layout the text. Here skip the temporary font for the loading custom |
| 128 // font which may not act as the correct fallback font. | 128 // font which may not act as the correct fallback font. |
| 129 if (!font_data_for_space->IsLoadingFallback()) | 129 if (!font_data_for_space->IsLoadingFallback()) |
| 130 return font_data_for_space; | 130 return font_data_for_space; |
| 131 | 131 |
| 132 if (font_data->IsSegmented()) { | 132 if (font_data->IsSegmented()) { |
| 133 const SegmentedFontData* segmented = ToSegmentedFontData(font_data); | 133 const SegmentedFontData* segmented = ToSegmentedFontData(font_data); |
| 134 for (unsigned i = 0; i < segmented->NumFaces(); i++) { | 134 for (unsigned i = 0; i < segmented->NumFaces(); i++) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } | 215 } |
| 216 | 216 |
| 217 const FontData* FontFallbackList::FontDataAt( | 217 const FontData* FontFallbackList::FontDataAt( |
| 218 const FontDescription& font_description, | 218 const FontDescription& font_description, |
| 219 unsigned realized_font_index) const { | 219 unsigned realized_font_index) const { |
| 220 if (realized_font_index < font_list_.size()) | 220 if (realized_font_index < font_list_.size()) |
| 221 return font_list_[realized_font_index] | 221 return font_list_[realized_font_index] |
| 222 .Get(); // This fallback font is already in our list. | 222 .Get(); // This fallback font is already in our list. |
| 223 | 223 |
| 224 // Make sure we're not passing in some crazy value here. | 224 // Make sure we're not passing in some crazy value here. |
| 225 ASSERT(realized_font_index == font_list_.size()); | 225 DCHECK_EQ(realized_font_index, font_list_.size()); |
| 226 | 226 |
| 227 if (family_index_ == kCAllFamiliesScanned) | 227 if (family_index_ == kCAllFamiliesScanned) |
| 228 return 0; | 228 return 0; |
| 229 | 229 |
| 230 // Ask the font cache for the font data. | 230 // Ask the font cache for the font data. |
| 231 // We are obtaining this font for the first time. We keep track of the | 231 // We are obtaining this font for the first time. We keep track of the |
| 232 // families we've looked at before in |m_familyIndex|, so that we never scan | 232 // families we've looked at before in |m_familyIndex|, so that we never scan |
| 233 // the same spot in the list twice. getFontData will adjust our | 233 // the same spot in the list twice. getFontData will adjust our |
| 234 // |m_familyIndex| as it scans for the right font to make. | 234 // |m_familyIndex| as it scans for the right font to make. |
| 235 ASSERT(FontCache::GetFontCache()->Generation() == generation_); | 235 DCHECK_EQ(FontCache::GetFontCache()->Generation(), generation_); |
| 236 RefPtr<FontData> result = GetFontData(font_description, family_index_); | 236 RefPtr<FontData> result = GetFontData(font_description, family_index_); |
| 237 if (result) { | 237 if (result) { |
| 238 font_list_.push_back(result); | 238 font_list_.push_back(result); |
| 239 if (result->IsLoadingFallback()) | 239 if (result->IsLoadingFallback()) |
| 240 has_loading_fallback_ = true; | 240 has_loading_fallback_ = true; |
| 241 } | 241 } |
| 242 return result.Get(); | 242 return result.Get(); |
| 243 } | 243 } |
| 244 | 244 |
| 245 bool FontFallbackList::IsValid() const { | 245 bool FontFallbackList::IsValid() const { |
| 246 if (!font_selector_) | 246 if (!font_selector_) |
| 247 return font_selector_version_ == 0; | 247 return font_selector_version_ == 0; |
| 248 | 248 |
| 249 return font_selector_->Version() == font_selector_version_; | 249 return font_selector_->Version() == font_selector_version_; |
| 250 } | 250 } |
| 251 | 251 |
| 252 } // namespace blink | 252 } // namespace blink |
| OLD | NEW |