| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2010, 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 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/css/CSSFontFaceSource.h" | 27 #include "core/css/CSSFontFaceSource.h" |
| 28 | 28 |
| 29 #include "RuntimeEnabledFeatures.h" | 29 #include "RuntimeEnabledFeatures.h" |
| 30 #include "core/css/CSSCustomFontData.h" | 30 #include "core/css/CSSCustomFontData.h" |
| 31 #include "core/css/CSSFontFace.h" | 31 #include "core/css/CSSFontFace.h" |
| 32 #include "core/dom/ElementTraversal.h" |
| 32 #include "platform/fonts/FontCache.h" | 33 #include "platform/fonts/FontCache.h" |
| 33 #include "platform/fonts/FontDescription.h" | 34 #include "platform/fonts/FontDescription.h" |
| 34 #include "platform/fonts/SimpleFontData.h" | 35 #include "platform/fonts/SimpleFontData.h" |
| 35 #include "public/platform/Platform.h" | 36 #include "public/platform/Platform.h" |
| 36 #include "wtf/CurrentTime.h" | 37 #include "wtf/CurrentTime.h" |
| 37 | 38 |
| 38 #if ENABLE(SVG_FONTS) | 39 #if ENABLE(SVG_FONTS) |
| 39 #include "SVGNames.h" | 40 #include "SVGNames.h" |
| 40 #include "core/svg/SVGFontData.h" | 41 #include "core/svg/SVGFontData.h" |
| 41 #include "core/svg/SVGFontElement.h" | 42 #include "core/svg/SVGFontElement.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 String fragmentIdentifier; | 169 String fragmentIdentifier; |
| 169 size_t start = m_string.find('#'); | 170 size_t start = m_string.find('#'); |
| 170 if (start != kNotFound) | 171 if (start != kNotFound) |
| 171 fragmentIdentifier = m_string.string().substring(start +
1); | 172 fragmentIdentifier = m_string.string().substring(start +
1); |
| 172 m_externalSVGFontElement = m_font->getSVGFontById(fragmentId
entifier); | 173 m_externalSVGFontElement = m_font->getSVGFontById(fragmentId
entifier); |
| 173 } | 174 } |
| 174 | 175 |
| 175 if (!m_externalSVGFontElement) | 176 if (!m_externalSVGFontElement) |
| 176 return nullptr; | 177 return nullptr; |
| 177 | 178 |
| 178 SVGFontFaceElement* fontFaceElement = 0; | |
| 179 | |
| 180 // Select first <font-face> child | 179 // Select first <font-face> child |
| 181 for (Node* fontChild = m_externalSVGFontElement->firstChild(); f
ontChild; fontChild = fontChild->nextSibling()) { | 180 if (SVGFontFaceElement* fontFaceElement = Traversal<SVGFontFaceE
lement>::firstChild(*m_externalSVGFontElement)) { |
| 182 if (fontChild->hasTagName(SVGNames::font_faceTag)) { | |
| 183 fontFaceElement = toSVGFontFaceElement(fontChild); | |
| 184 break; | |
| 185 } | |
| 186 } | |
| 187 | |
| 188 if (fontFaceElement) { | |
| 189 if (!m_svgFontFaceElement) { | 181 if (!m_svgFontFaceElement) { |
| 190 // We're created using a CSS @font-face rule, that means
we're not associated with a SVGFontFaceElement. | 182 // We're created using a CSS @font-face rule, that means
we're not associated with a SVGFontFaceElement. |
| 191 // Use the imported <font-face> tag as referencing font-
face element for these cases. | 183 // Use the imported <font-face> tag as referencing font-
face element for these cases. |
| 192 m_svgFontFaceElement = fontFaceElement; | 184 m_svgFontFaceElement = fontFaceElement; |
| 193 } | 185 } |
| 194 | 186 |
| 195 fontData = SimpleFontData::create( | 187 fontData = SimpleFontData::create( |
| 196 SVGFontData::create(fontFaceElement), | 188 SVGFontData::create(fontFaceElement), |
| 197 fontDescription.effectiveFontSize(), | 189 fontDescription.effectiveFontSize(), |
| 198 fontDescription.isSyntheticBold(), | 190 fontDescription.isSyntheticBold(), |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 if (size < 50 * 1024) | 327 if (size < 50 * 1024) |
| 336 return "WebFont.DownloadTime.1.10KBTo50KB"; | 328 return "WebFont.DownloadTime.1.10KBTo50KB"; |
| 337 if (size < 100 * 1024) | 329 if (size < 100 * 1024) |
| 338 return "WebFont.DownloadTime.2.50KBTo100KB"; | 330 return "WebFont.DownloadTime.2.50KBTo100KB"; |
| 339 if (size < 1024 * 1024) | 331 if (size < 1024 * 1024) |
| 340 return "WebFont.DownloadTime.3.100KBTo1MB"; | 332 return "WebFont.DownloadTime.3.100KBTo1MB"; |
| 341 return "WebFont.DownloadTime.4.Over1MB"; | 333 return "WebFont.DownloadTime.4.Over1MB"; |
| 342 } | 334 } |
| 343 | 335 |
| 344 } | 336 } |
| OLD | NEW |