| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return; | 126 return; |
| 127 } | 127 } |
| 128 | 128 |
| 129 for (unsigned j = 0; j < numRanges; ++j) | 129 for (unsigned j = 0; j < numRanges; ++j) |
| 130 newFontData->appendRange(FontDataRange(ranges.rangeAt(j).from(), ranges.
rangeAt(j).to(), faceFontData)); | 130 newFontData->appendRange(FontDataRange(ranges.rangeAt(j).from(), ranges.
rangeAt(j).to(), faceFontData)); |
| 131 } | 131 } |
| 132 | 132 |
| 133 PassRefPtr<FontData> CSSSegmentedFontFace::getFontData(const FontDescription& fo
ntDescription) | 133 PassRefPtr<FontData> CSSSegmentedFontFace::getFontData(const FontDescription& fo
ntDescription) |
| 134 { | 134 { |
| 135 if (!isValid()) | 135 if (!isValid()) |
| 136 return 0; | 136 return nullptr; |
| 137 | 137 |
| 138 FontTraitsMask desiredTraitsMask = fontDescription.traitsMask(); | 138 FontTraitsMask desiredTraitsMask = fontDescription.traitsMask(); |
| 139 AtomicString emptyFontFamily = ""; | 139 AtomicString emptyFontFamily = ""; |
| 140 FontCacheKey key = fontDescription.cacheKey(emptyFontFamily, desiredTraitsMa
sk); | 140 FontCacheKey key = fontDescription.cacheKey(emptyFontFamily, desiredTraitsMa
sk); |
| 141 | 141 |
| 142 RefPtr<SegmentedFontData>& fontData = m_fontDataTable.add(key.hash(), 0).sto
redValue->value; | 142 RefPtr<SegmentedFontData>& fontData = m_fontDataTable.add(key.hash(), nullpt
r).storedValue->value; |
| 143 if (fontData && fontData->numRanges()) | 143 if (fontData && fontData->numRanges()) |
| 144 return fontData; // No release, we have a reference to an object in the
cache which should retain the ref count it has. | 144 return fontData; // No release, we have a reference to an object in the
cache which should retain the ref count it has. |
| 145 | 145 |
| 146 if (!fontData) | 146 if (!fontData) |
| 147 fontData = SegmentedFontData::create(); | 147 fontData = SegmentedFontData::create(); |
| 148 | 148 |
| 149 FontDescription requestedFontDescription(fontDescription); | 149 FontDescription requestedFontDescription(fontDescription); |
| 150 requestedFontDescription.setTraitsMask(m_traitsMask); | 150 requestedFontDescription.setTraitsMask(m_traitsMask); |
| 151 requestedFontDescription.setSyntheticBold(!(m_traitsMask & (FontWeight600Mas
k | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask)) && (desiredTrait
sMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight9
00Mask))); | 151 requestedFontDescription.setSyntheticBold(!(m_traitsMask & (FontWeight600Mas
k | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask)) && (desiredTrait
sMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight9
00Mask))); |
| 152 requestedFontDescription.setSyntheticItalic(!(m_traitsMask & FontStyleItalic
Mask) && (desiredTraitsMask & FontStyleItalicMask)); | 152 requestedFontDescription.setSyntheticItalic(!(m_traitsMask & FontStyleItalic
Mask) && (desiredTraitsMask & FontStyleItalicMask)); |
| 153 | 153 |
| 154 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); it != m_fontF
aces.rend(); ++it) { | 154 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); it != m_fontF
aces.rend(); ++it) { |
| 155 if (!(*it)->cssFontFace()->isValid()) | 155 if (!(*it)->cssFontFace()->isValid()) |
| 156 continue; | 156 continue; |
| 157 if (RefPtr<SimpleFontData> faceFontData = (*it)->cssFontFace()->getFontD
ata(requestedFontDescription)) { | 157 if (RefPtr<SimpleFontData> faceFontData = (*it)->cssFontFace()->getFontD
ata(requestedFontDescription)) { |
| 158 ASSERT(!faceFontData->isSegmented()); | 158 ASSERT(!faceFontData->isSegmented()); |
| 159 #if ENABLE(SVG_FONTS) | 159 #if ENABLE(SVG_FONTS) |
| 160 // For SVG Fonts that specify that they only support the "normal" va
riant, we will assume they are incapable | 160 // For SVG Fonts that specify that they only support the "normal" va
riant, we will assume they are incapable |
| 161 // of small-caps synthesis and just ignore the font face. | 161 // of small-caps synthesis and just ignore the font face. |
| 162 if (faceFontData->isSVGFont() && (desiredTraitsMask & FontVariantSma
llCapsMask) && !(m_traitsMask & FontVariantSmallCapsMask)) | 162 if (faceFontData->isSVGFont() && (desiredTraitsMask & FontVariantSma
llCapsMask) && !(m_traitsMask & FontVariantSmallCapsMask)) |
| 163 continue; | 163 continue; |
| 164 #endif | 164 #endif |
| 165 appendFontData(fontData.get(), faceFontData.release(), (*it)->cssFon
tFace()->ranges()); | 165 appendFontData(fontData.get(), faceFontData.release(), (*it)->cssFon
tFace()->ranges()); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 if (fontData->numRanges()) | 168 if (fontData->numRanges()) |
| 169 return fontData; // No release, we have a reference to an object in the
cache which should retain the ref count it has. | 169 return fontData; // No release, we have a reference to an object in the
cache which should retain the ref count it has. |
| 170 | 170 |
| 171 return 0; | 171 return nullptr; |
| 172 } | 172 } |
| 173 | 173 |
| 174 bool CSSSegmentedFontFace::isLoading() const | 174 bool CSSSegmentedFontFace::isLoading() const |
| 175 { | 175 { |
| 176 for (FontFaceList::const_iterator it = m_fontFaces.begin(); it != m_fontFace
s.end(); ++it) { | 176 for (FontFaceList::const_iterator it = m_fontFaces.begin(); it != m_fontFace
s.end(); ++it) { |
| 177 if ((*it)->loadStatus() == FontFace::Loading) | 177 if ((*it)->loadStatus() == FontFace::Loading) |
| 178 return true; | 178 return true; |
| 179 } | 179 } |
| 180 return false; | 180 return false; |
| 181 } | 181 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 if (isLoading()) | 215 if (isLoading()) |
| 216 m_callbacks.append(callback); | 216 m_callbacks.append(callback); |
| 217 else if (isLoaded()) | 217 else if (isLoaded()) |
| 218 callback->notifyLoaded(this); | 218 callback->notifyLoaded(this); |
| 219 else | 219 else |
| 220 callback->notifyError(this); | 220 callback->notifyError(this); |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 } | 224 } |
| OLD | NEW |