| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2011 Apple 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 ASSERT(!m_segmentedFontFace); | 47 ASSERT(!m_segmentedFontFace); |
| 48 m_segmentedFontFace = segmentedFontFace; | 48 m_segmentedFontFace = segmentedFontFace; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void CSSFontFace::didBeginLoad() { | 51 void CSSFontFace::didBeginLoad() { |
| 52 if (loadStatus() == FontFace::Unloaded) | 52 if (loadStatus() == FontFace::Unloaded) |
| 53 setLoadStatus(FontFace::Loading); | 53 setLoadStatus(FontFace::Loading); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void CSSFontFace::fontLoaded(RemoteFontFaceSource* source) { | 56 void CSSFontFace::fontLoaded(RemoteFontFaceSource* source) { |
| 57 if (!isValid() || source != m_sources.first()) | 57 if (!isValid() || source != m_sources.front()) |
| 58 return; | 58 return; |
| 59 | 59 |
| 60 if (loadStatus() == FontFace::Loading) { | 60 if (loadStatus() == FontFace::Loading) { |
| 61 if (source->isValid()) { | 61 if (source->isValid()) { |
| 62 setLoadStatus(FontFace::Loaded); | 62 setLoadStatus(FontFace::Loaded); |
| 63 } else if (source->getDisplayPeriod() == | 63 } else if (source->getDisplayPeriod() == |
| 64 RemoteFontFaceSource::FailurePeriod) { | 64 RemoteFontFaceSource::FailurePeriod) { |
| 65 m_sources.clear(); | 65 m_sources.clear(); |
| 66 setLoadStatus(FontFace::Error); | 66 setLoadStatus(FontFace::Error); |
| 67 } else { | 67 } else { |
| 68 m_sources.pop_front(); | 68 m_sources.pop_front(); |
| 69 load(); | 69 load(); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 if (m_segmentedFontFace) | 73 if (m_segmentedFontFace) |
| 74 m_segmentedFontFace->fontFaceInvalidated(); | 74 m_segmentedFontFace->fontFaceInvalidated(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 size_t CSSFontFace::approximateBlankCharacterCount() const { | 77 size_t CSSFontFace::approximateBlankCharacterCount() const { |
| 78 if (!m_sources.isEmpty() && m_sources.first()->isBlank() && | 78 if (!m_sources.isEmpty() && m_sources.front()->isBlank() && |
| 79 m_segmentedFontFace) | 79 m_segmentedFontFace) |
| 80 return m_segmentedFontFace->approximateCharacterCount(); | 80 return m_segmentedFontFace->approximateCharacterCount(); |
| 81 return 0; | 81 return 0; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void CSSFontFace::didBecomeVisibleFallback(RemoteFontFaceSource* source) { | 84 void CSSFontFace::didBecomeVisibleFallback(RemoteFontFaceSource* source) { |
| 85 if (!isValid() || source != m_sources.first()) | 85 if (!isValid() || source != m_sources.front()) |
| 86 return; | 86 return; |
| 87 if (m_segmentedFontFace) | 87 if (m_segmentedFontFace) |
| 88 m_segmentedFontFace->fontFaceInvalidated(); | 88 m_segmentedFontFace->fontFaceInvalidated(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 PassRefPtr<SimpleFontData> CSSFontFace::getFontData( | 91 PassRefPtr<SimpleFontData> CSSFontFace::getFontData( |
| 92 const FontDescription& fontDescription) { | 92 const FontDescription& fontDescription) { |
| 93 if (!isValid()) | 93 if (!isValid()) |
| 94 return nullptr; | 94 return nullptr; |
| 95 | 95 |
| 96 while (!m_sources.isEmpty()) { | 96 while (!m_sources.isEmpty()) { |
| 97 Member<CSSFontFaceSource>& source = m_sources.first(); | 97 Member<CSSFontFaceSource>& source = m_sources.front(); |
| 98 if (RefPtr<SimpleFontData> result = source->getFontData(fontDescription)) { | 98 if (RefPtr<SimpleFontData> result = source->getFontData(fontDescription)) { |
| 99 if (loadStatus() == FontFace::Unloaded && | 99 if (loadStatus() == FontFace::Unloaded && |
| 100 (source->isLoading() || source->isLoaded())) | 100 (source->isLoading() || source->isLoaded())) |
| 101 setLoadStatus(FontFace::Loading); | 101 setLoadStatus(FontFace::Loading); |
| 102 if (loadStatus() == FontFace::Loading && source->isLoaded()) | 102 if (loadStatus() == FontFace::Loading && source->isLoaded()) |
| 103 setLoadStatus(FontFace::Loaded); | 103 setLoadStatus(FontFace::Loaded); |
| 104 return result.release(); | 104 return result.release(); |
| 105 } | 105 } |
| 106 m_sources.pop_front(); | 106 m_sources.pop_front(); |
| 107 } | 107 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 fontDescription.setTraits(m_fontFace->traits()); | 147 fontDescription.setTraits(m_fontFace->traits()); |
| 148 load(fontDescription); | 148 load(fontDescription); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void CSSFontFace::load(const FontDescription& fontDescription) { | 151 void CSSFontFace::load(const FontDescription& fontDescription) { |
| 152 if (loadStatus() == FontFace::Unloaded) | 152 if (loadStatus() == FontFace::Unloaded) |
| 153 setLoadStatus(FontFace::Loading); | 153 setLoadStatus(FontFace::Loading); |
| 154 ASSERT(loadStatus() == FontFace::Loading); | 154 ASSERT(loadStatus() == FontFace::Loading); |
| 155 | 155 |
| 156 while (!m_sources.isEmpty()) { | 156 while (!m_sources.isEmpty()) { |
| 157 Member<CSSFontFaceSource>& source = m_sources.first(); | 157 Member<CSSFontFaceSource>& source = m_sources.front(); |
| 158 if (source->isValid()) { | 158 if (source->isValid()) { |
| 159 if (source->isLocal()) { | 159 if (source->isLocal()) { |
| 160 if (source->isLocalFontAvailable(fontDescription)) { | 160 if (source->isLocalFontAvailable(fontDescription)) { |
| 161 setLoadStatus(FontFace::Loaded); | 161 setLoadStatus(FontFace::Loaded); |
| 162 return; | 162 return; |
| 163 } | 163 } |
| 164 } else { | 164 } else { |
| 165 if (!source->isLoaded()) | 165 if (!source->isLoaded()) |
| 166 source->beginLoadIfNeeded(); | 166 source->beginLoadIfNeeded(); |
| 167 else | 167 else |
| (...skipping 20 matching lines...) Expand all Loading... |
| 188 FontFaceSet::from(*document)->beginFontLoading(m_fontFace); | 188 FontFaceSet::from(*document)->beginFontLoading(m_fontFace); |
| 189 } | 189 } |
| 190 | 190 |
| 191 DEFINE_TRACE(CSSFontFace) { | 191 DEFINE_TRACE(CSSFontFace) { |
| 192 visitor->trace(m_segmentedFontFace); | 192 visitor->trace(m_segmentedFontFace); |
| 193 visitor->trace(m_sources); | 193 visitor->trace(m_sources); |
| 194 visitor->trace(m_fontFace); | 194 visitor->trace(m_fontFace); |
| 195 } | 195 } |
| 196 | 196 |
| 197 } // namespace blink | 197 } // namespace blink |
| OLD | NEW |