Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: Source/core/css/CSSFontFace.cpp

Issue 23446007: Use unicode-range to prevent unnecessary @font-face donwnloads (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase and add toSegmentedFontData() Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSFontFace.h ('k') | Source/core/css/CSSFontFaceSource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 source->setFontFace(this); 60 source->setFontFace(this);
61 m_sources.append(source); 61 m_sources.append(source);
62 } 62 }
63 63
64 void CSSFontFace::setSegmentedFontFace(CSSSegmentedFontFace* segmentedFontFace) 64 void CSSFontFace::setSegmentedFontFace(CSSSegmentedFontFace* segmentedFontFace)
65 { 65 {
66 ASSERT(!m_segmentedFontFace); 66 ASSERT(!m_segmentedFontFace);
67 m_segmentedFontFace = segmentedFontFace; 67 m_segmentedFontFace = segmentedFontFace;
68 } 68 }
69 69
70 void CSSFontFace::beginLoadingFontSoon(FontResource* resource)
71 {
72 if (!m_segmentedFontFace)
73 return;
74
75 CSSFontSelector* fontSelector = m_segmentedFontFace->fontSelector();
76 fontSelector->beginLoadingFontSoon(resource);
77
78 if (loadStatus() == FontFace::Unloaded)
79 setLoadStatus(FontFace::Loading);
80 }
81
70 void CSSFontFace::fontLoaded(CSSFontFaceSource* source) 82 void CSSFontFace::fontLoaded(CSSFontFaceSource* source)
71 { 83 {
72 if (source != m_activeSource) 84 if (source != m_activeSource)
73 return; 85 return;
74 86
75 // FIXME: Can we assert that m_segmentedFontFace is non-null? That may 87 // FIXME: Can we assert that m_segmentedFontFace is non-null? That may
76 // require stopping in-progress font loading when the last 88 // require stopping in-progress font loading when the last
77 // CSSSegmentedFontFace is removed. 89 // CSSSegmentedFontFace is removed.
78 if (!m_segmentedFontFace) 90 if (!m_segmentedFontFace)
79 return; 91 return;
(...skipping 13 matching lines...) Expand all
93 105
94 PassRefPtr<SimpleFontData> CSSFontFace::getFontData(const FontDescription& fontD escription, bool syntheticBold, bool syntheticItalic) 106 PassRefPtr<SimpleFontData> CSSFontFace::getFontData(const FontDescription& fontD escription, bool syntheticBold, bool syntheticItalic)
95 { 107 {
96 m_activeSource = 0; 108 m_activeSource = 0;
97 if (!isValid()) 109 if (!isValid())
98 return 0; 110 return 0;
99 111
100 ASSERT(m_segmentedFontFace); 112 ASSERT(m_segmentedFontFace);
101 CSSFontSelector* fontSelector = m_segmentedFontFace->fontSelector(); 113 CSSFontSelector* fontSelector = m_segmentedFontFace->fontSelector();
102 114
103 if (loadStatus() == FontFace::Unloaded)
104 setLoadStatus(FontFace::Loading);
105
106 size_t size = m_sources.size(); 115 size_t size = m_sources.size();
107 for (size_t i = 0; i < size; ++i) { 116 for (size_t i = 0; i < size; ++i) {
108 if (RefPtr<SimpleFontData> result = m_sources[i]->getFontData(fontDescri ption, syntheticBold, syntheticItalic, fontSelector)) { 117 if (RefPtr<SimpleFontData> result = m_sources[i]->getFontData(fontDescri ption, syntheticBold, syntheticItalic, fontSelector)) {
109 m_activeSource = m_sources[i].get(); 118 m_activeSource = m_sources[i].get();
119 if (loadStatus() == FontFace::Unloaded && (m_sources[i]->isLoading() || m_sources[i]->isLoaded()))
120 setLoadStatus(FontFace::Loading);
110 if (loadStatus() == FontFace::Loading && m_sources[i]->isLoaded()) 121 if (loadStatus() == FontFace::Loading && m_sources[i]->isLoaded())
111 setLoadStatus(FontFace::Loaded); 122 setLoadStatus(FontFace::Loaded);
112 return result.release(); 123 return result.release();
113 } 124 }
114 } 125 }
115 126
127 if (loadStatus() == FontFace::Unloaded)
128 setLoadStatus(FontFace::Loading);
116 if (loadStatus() == FontFace::Loading) 129 if (loadStatus() == FontFace::Loading)
117 setLoadStatus(FontFace::Error); 130 setLoadStatus(FontFace::Error);
118 return 0; 131 return 0;
119 } 132 }
120 133
121 void CSSFontFace::willUseFontData(const FontDescription& fontDescription) 134 void CSSFontFace::willUseFontData(const FontDescription& fontDescription)
122 { 135 {
123 if (loadStatus() != FontFace::Unloaded) 136 if (loadStatus() != FontFace::Unloaded)
124 return; 137 return;
125 138
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 size_t size = m_sources.size(); 179 size_t size = m_sources.size();
167 for (size_t i = 0; i < size; i++) { 180 for (size_t i = 0; i < size; i++) {
168 if (m_sources[i]->isSVGFontFaceSource()) 181 if (m_sources[i]->isSVGFontFaceSource())
169 return true; 182 return true;
170 } 183 }
171 return false; 184 return false;
172 } 185 }
173 #endif 186 #endif
174 187
175 } 188 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSFontFace.h ('k') | Source/core/css/CSSFontFaceSource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698