| 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 19 matching lines...) Expand all Loading... |
| 30 #include "core/css/CSSSegmentedFontFace.h" | 30 #include "core/css/CSSSegmentedFontFace.h" |
| 31 #include "core/css/FontFaceSet.h" | 31 #include "core/css/FontFaceSet.h" |
| 32 #include "core/css/RemoteFontFaceSource.h" | 32 #include "core/css/RemoteFontFaceSource.h" |
| 33 #include "core/frame/UseCounter.h" | 33 #include "core/frame/UseCounter.h" |
| 34 #include "platform/fonts/FontDescription.h" | 34 #include "platform/fonts/FontDescription.h" |
| 35 #include "platform/fonts/SimpleFontData.h" | 35 #include "platform/fonts/SimpleFontData.h" |
| 36 #include <algorithm> | 36 #include <algorithm> |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 void CSSFontFace::addSource(PassOwnPtrWillBeRawPtr<CSSFontFaceSource> source) | 40 void CSSFontFace::addSource(RawPtr<CSSFontFaceSource> source) |
| 41 { | 41 { |
| 42 source->setFontFace(this); | 42 source->setFontFace(this); |
| 43 m_sources.append(source); | 43 m_sources.append(source); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void CSSFontFace::setSegmentedFontFace(CSSSegmentedFontFace* segmentedFontFace) | 46 void CSSFontFace::setSegmentedFontFace(CSSSegmentedFontFace* segmentedFontFace) |
| 47 { | 47 { |
| 48 ASSERT(!m_segmentedFontFace); | 48 ASSERT(!m_segmentedFontFace); |
| 49 m_segmentedFontFace = segmentedFontFace; | 49 m_segmentedFontFace = segmentedFontFace; |
| 50 } | 50 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 if (m_segmentedFontFace) | 83 if (m_segmentedFontFace) |
| 84 m_segmentedFontFace->fontFaceInvalidated(); | 84 m_segmentedFontFace->fontFaceInvalidated(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 PassRefPtr<SimpleFontData> CSSFontFace::getFontData(const FontDescription& fontD
escription) | 87 PassRefPtr<SimpleFontData> CSSFontFace::getFontData(const FontDescription& fontD
escription) |
| 88 { | 88 { |
| 89 if (!isValid()) | 89 if (!isValid()) |
| 90 return nullptr; | 90 return nullptr; |
| 91 | 91 |
| 92 while (!m_sources.isEmpty()) { | 92 while (!m_sources.isEmpty()) { |
| 93 OwnPtrWillBeMember<CSSFontFaceSource>& source = m_sources.first(); | 93 Member<CSSFontFaceSource>& source = m_sources.first(); |
| 94 if (RefPtr<SimpleFontData> result = source->getFontData(fontDescription)
) { | 94 if (RefPtr<SimpleFontData> result = source->getFontData(fontDescription)
) { |
| 95 if (loadStatus() == FontFace::Unloaded && (source->isLoading() || so
urce->isLoaded())) | 95 if (loadStatus() == FontFace::Unloaded && (source->isLoading() || so
urce->isLoaded())) |
| 96 setLoadStatus(FontFace::Loading); | 96 setLoadStatus(FontFace::Loading); |
| 97 if (loadStatus() == FontFace::Loading && source->isLoaded()) | 97 if (loadStatus() == FontFace::Loading && source->isLoaded()) |
| 98 setLoadStatus(FontFace::Loaded); | 98 setLoadStatus(FontFace::Loaded); |
| 99 return result.release(); | 99 return result.release(); |
| 100 } | 100 } |
| 101 m_sources.removeFirst(); | 101 m_sources.removeFirst(); |
| 102 } | 102 } |
| 103 | 103 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 load(fontDescription); | 139 load(fontDescription); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void CSSFontFace::load(const FontDescription& fontDescription) | 142 void CSSFontFace::load(const FontDescription& fontDescription) |
| 143 { | 143 { |
| 144 if (loadStatus() == FontFace::Unloaded) | 144 if (loadStatus() == FontFace::Unloaded) |
| 145 setLoadStatus(FontFace::Loading); | 145 setLoadStatus(FontFace::Loading); |
| 146 ASSERT(loadStatus() == FontFace::Loading); | 146 ASSERT(loadStatus() == FontFace::Loading); |
| 147 | 147 |
| 148 while (!m_sources.isEmpty()) { | 148 while (!m_sources.isEmpty()) { |
| 149 OwnPtrWillBeMember<CSSFontFaceSource>& source = m_sources.first(); | 149 Member<CSSFontFaceSource>& source = m_sources.first(); |
| 150 if (source->isValid()) { | 150 if (source->isValid()) { |
| 151 if (source->isLocal()) { | 151 if (source->isLocal()) { |
| 152 if (source->isLocalFontAvailable(fontDescription)) { | 152 if (source->isLocalFontAvailable(fontDescription)) { |
| 153 setLoadStatus(FontFace::Loaded); | 153 setLoadStatus(FontFace::Loaded); |
| 154 return; | 154 return; |
| 155 } | 155 } |
| 156 } else { | 156 } else { |
| 157 if (!source->isLoaded()) | 157 if (!source->isLoaded()) |
| 158 source->beginLoadIfNeeded(); | 158 source->beginLoadIfNeeded(); |
| 159 else | 159 else |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 } | 257 } |
| 258 | 258 |
| 259 DEFINE_TRACE(CSSFontFace) | 259 DEFINE_TRACE(CSSFontFace) |
| 260 { | 260 { |
| 261 visitor->trace(m_segmentedFontFace); | 261 visitor->trace(m_segmentedFontFace); |
| 262 visitor->trace(m_sources); | 262 visitor->trace(m_sources); |
| 263 visitor->trace(m_fontFace); | 263 visitor->trace(m_fontFace); |
| 264 } | 264 } |
| 265 | 265 |
| 266 } // namespace blink | 266 } // namespace blink |
| OLD | NEW |