| 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 18 matching lines...) Expand all Loading... |
| 29 #include "core/css/CSSFontSelector.h" | 29 #include "core/css/CSSFontSelector.h" |
| 30 #include "platform/RuntimeEnabledFeatures.h" | 30 #include "platform/RuntimeEnabledFeatures.h" |
| 31 #include "platform/fonts/FontCache.h" | 31 #include "platform/fonts/FontCache.h" |
| 32 #include "platform/fonts/FontDescription.h" | 32 #include "platform/fonts/FontDescription.h" |
| 33 #include "platform/fonts/FontFaceCreationParams.h" | 33 #include "platform/fonts/FontFaceCreationParams.h" |
| 34 #include "platform/fonts/SegmentedFontData.h" | 34 #include "platform/fonts/SegmentedFontData.h" |
| 35 #include "platform/fonts/SimpleFontData.h" | 35 #include "platform/fonts/SimpleFontData.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 CSSSegmentedFontFace::CSSSegmentedFontFace(CSSFontSelector* fontSelector, | 39 CSSSegmentedFontFace::CSSSegmentedFontFace(FontTraits traits) |
| 40 FontTraits traits) | 40 : m_traits(traits), |
| 41 : m_fontSelector(fontSelector), | |
| 42 m_traits(traits), | |
| 43 m_firstNonCssConnectedFace(m_fontFaces.end()), | 41 m_firstNonCssConnectedFace(m_fontFaces.end()), |
| 44 m_approximateCharacterCount(0) {} | 42 m_approximateCharacterCount(0) {} |
| 45 | 43 |
| 46 CSSSegmentedFontFace::~CSSSegmentedFontFace() {} | 44 CSSSegmentedFontFace::~CSSSegmentedFontFace() {} |
| 47 | 45 |
| 48 void CSSSegmentedFontFace::pruneTable() { | 46 void CSSSegmentedFontFace::pruneTable() { |
| 49 // Make sure the glyph page tree prunes out all uses of this custom font. | 47 // Make sure the glyph page tree prunes out all uses of this custom font. |
| 50 if (m_fontDataTable.isEmpty()) | 48 if (m_fontDataTable.isEmpty()) |
| 51 return; | 49 return; |
| 52 | 50 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 if (fontData->numFaces()) { | 138 if (fontData->numFaces()) { |
| 141 // No release, we have a reference to an object in the cache which should | 139 // No release, we have a reference to an object in the cache which should |
| 142 // retain the ref count it has. | 140 // retain the ref count it has. |
| 143 return fontData; | 141 return fontData; |
| 144 } | 142 } |
| 145 | 143 |
| 146 return nullptr; | 144 return nullptr; |
| 147 } | 145 } |
| 148 | 146 |
| 149 void CSSSegmentedFontFace::willUseFontData( | 147 void CSSSegmentedFontFace::willUseFontData( |
| 148 Document* document, |
| 150 const FontDescription& fontDescription, | 149 const FontDescription& fontDescription, |
| 151 const String& text) { | 150 const String& text) { |
| 152 m_approximateCharacterCount += text.length(); | 151 m_approximateCharacterCount += text.length(); |
| 153 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); | 152 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); |
| 154 it != m_fontFaces.rend(); ++it) { | 153 it != m_fontFaces.rend(); ++it) { |
| 155 if ((*it)->loadStatus() != FontFace::Unloaded) | 154 if ((*it)->loadStatus() != FontFace::Unloaded) |
| 156 break; | 155 break; |
| 157 if ((*it)->cssFontFace()->maybeLoadFont(fontDescription, text)) | 156 if ((*it)->cssFontFace()->maybeLoadFont(document, fontDescription, text)) |
| 158 break; | 157 break; |
| 159 } | 158 } |
| 160 } | 159 } |
| 161 | 160 |
| 162 void CSSSegmentedFontFace::willUseRange( | 161 void CSSSegmentedFontFace::willUseRange( |
| 162 Document* document, |
| 163 const blink::FontDescription& fontDescription, | 163 const blink::FontDescription& fontDescription, |
| 164 const blink::FontDataForRangeSet& rangeSet) { | 164 const blink::FontDataForRangeSet& rangeSet) { |
| 165 // Iterating backwards since later defined unicode-range faces override | 165 // Iterating backwards since later defined unicode-range faces override |
| 166 // previously defined ones, according to the CSS3 fonts module. | 166 // previously defined ones, according to the CSS3 fonts module. |
| 167 // https://drafts.csswg.org/css-fonts/#composite-fonts | 167 // https://drafts.csswg.org/css-fonts/#composite-fonts |
| 168 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); | 168 for (FontFaceList::reverse_iterator it = m_fontFaces.rbegin(); |
| 169 it != m_fontFaces.rend(); ++it) { | 169 it != m_fontFaces.rend(); ++it) { |
| 170 CSSFontFace* cssFontFace = (*it)->cssFontFace(); | 170 CSSFontFace* cssFontFace = (*it)->cssFontFace(); |
| 171 if (cssFontFace->maybeLoadFont(fontDescription, rangeSet)) | 171 if (cssFontFace->maybeLoadFont(document, fontDescription, rangeSet)) |
| 172 break; | 172 break; |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool CSSSegmentedFontFace::checkFont(const String& text) const { | 176 bool CSSSegmentedFontFace::checkFont(const String& text) const { |
| 177 for (const auto& fontFace : m_fontFaces) { | 177 for (const auto& fontFace : m_fontFaces) { |
| 178 if (fontFace->loadStatus() != FontFace::Loaded && | 178 if (fontFace->loadStatus() != FontFace::Loaded && |
| 179 fontFace->cssFontFace()->ranges()->intersectsWith(text)) | 179 fontFace->cssFontFace()->ranges()->intersectsWith(text)) |
| 180 return false; | 180 return false; |
| 181 } | 181 } |
| 182 return true; | 182 return true; |
| 183 } | 183 } |
| 184 | 184 |
| 185 void CSSSegmentedFontFace::match(const String& text, | 185 void CSSSegmentedFontFace::match(const String& text, |
| 186 HeapVector<Member<FontFace>>& faces) const { | 186 HeapVector<Member<FontFace>>& faces) const { |
| 187 for (const auto& fontFace : m_fontFaces) { | 187 for (const auto& fontFace : m_fontFaces) { |
| 188 if (fontFace->cssFontFace()->ranges()->intersectsWith(text)) | 188 if (fontFace->cssFontFace()->ranges()->intersectsWith(text)) |
| 189 faces.push_back(fontFace); | 189 faces.push_back(fontFace); |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 DEFINE_TRACE(CSSSegmentedFontFace) { | 193 DEFINE_TRACE(CSSSegmentedFontFace) { |
| 194 visitor->trace(m_fontSelector); | |
| 195 visitor->trace(m_firstNonCssConnectedFace); | 194 visitor->trace(m_firstNonCssConnectedFace); |
| 196 visitor->trace(m_fontFaces); | 195 visitor->trace(m_fontFaces); |
| 197 } | 196 } |
| 198 | 197 |
| 199 } // namespace blink | 198 } // namespace blink |
| OLD | NEW |