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

Side by Side Diff: third_party/WebKit/Source/core/css/FontFace.cpp

Issue 2640753002: CSS font-display: expose display property on FontFace (Closed)
Patch Set: Fix webexposed Created 3 years, 11 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "core/dom/DOMException.h" 53 #include "core/dom/DOMException.h"
54 #include "core/dom/Document.h" 54 #include "core/dom/Document.h"
55 #include "core/dom/ExceptionCode.h" 55 #include "core/dom/ExceptionCode.h"
56 #include "core/dom/StyleEngine.h" 56 #include "core/dom/StyleEngine.h"
57 #include "core/dom/TaskRunnerHelper.h" 57 #include "core/dom/TaskRunnerHelper.h"
58 #include "core/frame/LocalFrame.h" 58 #include "core/frame/LocalFrame.h"
59 #include "core/frame/Settings.h" 59 #include "core/frame/Settings.h"
60 #include "core/frame/UseCounter.h" 60 #include "core/frame/UseCounter.h"
61 #include "platform/FontFamilyNames.h" 61 #include "platform/FontFamilyNames.h"
62 #include "platform/Histogram.h" 62 #include "platform/Histogram.h"
63 #include "platform/RuntimeEnabledFeatures.h"
63 #include "platform/SharedBuffer.h" 64 #include "platform/SharedBuffer.h"
64 #include "platform/WebTaskRunner.h" 65 #include "platform/WebTaskRunner.h"
65 66
66 namespace blink { 67 namespace blink {
67 68
68 static const CSSValue* parseCSSValue(const Document* document, 69 static const CSSValue* parseCSSValue(const Document* document,
69 const String& value, 70 const String& value,
70 CSSPropertyID propertyID) { 71 CSSPropertyID propertyID) {
71 CSSParserContext* context = 72 CSSParserContext* context =
72 CSSParserContext::create(*document, UseCounter::getFrom(document)); 73 CSSParserContext::create(*document, UseCounter::getFrom(document));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 setPropertyFromString(document, descriptors.style(), CSSPropertyFontStyle); 168 setPropertyFromString(document, descriptors.style(), CSSPropertyFontStyle);
168 setPropertyFromString(document, descriptors.weight(), CSSPropertyFontWeight); 169 setPropertyFromString(document, descriptors.weight(), CSSPropertyFontWeight);
169 setPropertyFromString(document, descriptors.stretch(), 170 setPropertyFromString(document, descriptors.stretch(),
170 CSSPropertyFontStretch); 171 CSSPropertyFontStretch);
171 setPropertyFromString(document, descriptors.unicodeRange(), 172 setPropertyFromString(document, descriptors.unicodeRange(),
172 CSSPropertyUnicodeRange); 173 CSSPropertyUnicodeRange);
173 setPropertyFromString(document, descriptors.variant(), 174 setPropertyFromString(document, descriptors.variant(),
174 CSSPropertyFontVariant); 175 CSSPropertyFontVariant);
175 setPropertyFromString(document, descriptors.featureSettings(), 176 setPropertyFromString(document, descriptors.featureSettings(),
176 CSSPropertyFontFeatureSettings); 177 CSSPropertyFontFeatureSettings);
178 if (RuntimeEnabledFeatures::cssFontDisplayEnabled()) {
179 setPropertyFromString(document, descriptors.display(),
180 CSSPropertyFontDisplay);
181 }
177 } 182 }
178 183
179 FontFace::~FontFace() {} 184 FontFace::~FontFace() {}
180 185
181 String FontFace::style() const { 186 String FontFace::style() const {
182 return m_style ? m_style->cssText() : "normal"; 187 return m_style ? m_style->cssText() : "normal";
183 } 188 }
184 189
185 String FontFace::weight() const { 190 String FontFace::weight() const {
186 return m_weight ? m_weight->cssText() : "normal"; 191 return m_weight ? m_weight->cssText() : "normal";
187 } 192 }
188 193
189 String FontFace::stretch() const { 194 String FontFace::stretch() const {
190 return m_stretch ? m_stretch->cssText() : "normal"; 195 return m_stretch ? m_stretch->cssText() : "normal";
191 } 196 }
192 197
193 String FontFace::unicodeRange() const { 198 String FontFace::unicodeRange() const {
194 return m_unicodeRange ? m_unicodeRange->cssText() : "U+0-10FFFF"; 199 return m_unicodeRange ? m_unicodeRange->cssText() : "U+0-10FFFF";
195 } 200 }
196 201
197 String FontFace::variant() const { 202 String FontFace::variant() const {
198 return m_variant ? m_variant->cssText() : "normal"; 203 return m_variant ? m_variant->cssText() : "normal";
199 } 204 }
200 205
201 String FontFace::featureSettings() const { 206 String FontFace::featureSettings() const {
202 return m_featureSettings ? m_featureSettings->cssText() : "normal"; 207 return m_featureSettings ? m_featureSettings->cssText() : "normal";
203 } 208 }
204 209
210 String FontFace::display() const {
211 return m_display ? m_display->cssText() : "auto";
212 }
213
205 void FontFace::setStyle(ExecutionContext* context, 214 void FontFace::setStyle(ExecutionContext* context,
206 const String& s, 215 const String& s,
207 ExceptionState& exceptionState) { 216 ExceptionState& exceptionState) {
208 setPropertyFromString(toDocument(context), s, CSSPropertyFontStyle, 217 setPropertyFromString(toDocument(context), s, CSSPropertyFontStyle,
209 &exceptionState); 218 &exceptionState);
210 } 219 }
211 220
212 void FontFace::setWeight(ExecutionContext* context, 221 void FontFace::setWeight(ExecutionContext* context,
213 const String& s, 222 const String& s,
214 ExceptionState& exceptionState) { 223 ExceptionState& exceptionState) {
(...skipping 22 matching lines...) Expand all
237 &exceptionState); 246 &exceptionState);
238 } 247 }
239 248
240 void FontFace::setFeatureSettings(ExecutionContext* context, 249 void FontFace::setFeatureSettings(ExecutionContext* context,
241 const String& s, 250 const String& s,
242 ExceptionState& exceptionState) { 251 ExceptionState& exceptionState) {
243 setPropertyFromString(toDocument(context), s, CSSPropertyFontFeatureSettings, 252 setPropertyFromString(toDocument(context), s, CSSPropertyFontFeatureSettings,
244 &exceptionState); 253 &exceptionState);
245 } 254 }
246 255
256 void FontFace::setDisplay(ExecutionContext* context,
257 const String& s,
258 ExceptionState& exceptionState) {
259 setPropertyFromString(toDocument(context), s, CSSPropertyFontDisplay,
260 &exceptionState);
261 }
262
247 void FontFace::setPropertyFromString(const Document* document, 263 void FontFace::setPropertyFromString(const Document* document,
248 const String& s, 264 const String& s,
249 CSSPropertyID propertyID, 265 CSSPropertyID propertyID,
250 ExceptionState* exceptionState) { 266 ExceptionState* exceptionState) {
251 const CSSValue* value = parseCSSValue(document, s, propertyID); 267 const CSSValue* value = parseCSSValue(document, s, propertyID);
252 if (value && setPropertyValue(value, propertyID)) 268 if (value && setPropertyValue(value, propertyID))
253 return; 269 return;
254 270
255 String message = "Failed to set '" + s + "' as a property value."; 271 String message = "Failed to set '" + s + "' as a property value.";
256 if (exceptionState) 272 if (exceptionState)
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 672
657 bool FontFace::hadBlankText() const { 673 bool FontFace::hadBlankText() const {
658 return m_cssFontFace->hadBlankText(); 674 return m_cssFontFace->hadBlankText();
659 } 675 }
660 676
661 bool FontFace::hasPendingActivity() const { 677 bool FontFace::hasPendingActivity() const {
662 return m_status == Loading && getExecutionContext(); 678 return m_status == Loading && getExecutionContext();
663 } 679 }
664 680
665 } // namespace blink 681 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/FontFace.h ('k') | third_party/WebKit/Source/core/css/FontFace.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698