OLD | NEW |
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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/frame/LocalFrame.h" | 57 #include "core/frame/LocalFrame.h" |
58 #include "core/frame/Settings.h" | 58 #include "core/frame/Settings.h" |
59 #include "core/frame/UseCounter.h" | 59 #include "core/frame/UseCounter.h" |
60 #include "platform/FontFamilyNames.h" | 60 #include "platform/FontFamilyNames.h" |
61 #include "platform/SharedBuffer.h" | 61 #include "platform/SharedBuffer.h" |
62 | 62 |
63 namespace blink { | 63 namespace blink { |
64 | 64 |
65 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document,
const String& value, CSSPropertyID propertyID) | 65 static NullableCSSValue parseCSSValue(const Document* document, const String& va
lue, CSSPropertyID propertyID) |
66 { | 66 { |
67 CSSParserContext context(*document, UseCounter::getFrom(document)); | 67 CSSParserContext context(*document, UseCounter::getFrom(document)); |
68 return CSSParser::parseFontFaceDescriptor(propertyID, value, context); | 68 return CSSParser::parseFontFaceDescriptor(propertyID, value, context); |
69 } | 69 } |
70 | 70 |
71 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
st AtomicString& family, StringOrArrayBufferOrArrayBufferView& source, const Fon
tFaceDescriptors& descriptors) | 71 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
st AtomicString& family, StringOrArrayBufferOrArrayBufferView& source, const Fon
tFaceDescriptors& descriptors) |
72 { | 72 { |
73 if (source.isString()) | 73 if (source.isString()) |
74 return create(context, family, source.getAsString(), descriptors); | 74 return create(context, family, source.getAsString(), descriptors); |
75 if (source.isArrayBuffer()) | 75 if (source.isArrayBuffer()) |
76 return create(context, family, source.getAsArrayBuffer(), descriptors); | 76 return create(context, family, source.getAsArrayBuffer(), descriptors); |
77 if (source.isArrayBufferView()) | 77 if (source.isArrayBufferView()) |
78 return create(context, family, source.getAsArrayBufferView(), descriptor
s); | 78 return create(context, family, source.getAsArrayBufferView(), descriptor
s); |
79 ASSERT_NOT_REACHED(); | 79 ASSERT_NOT_REACHED(); |
80 return nullptr; | 80 return nullptr; |
81 } | 81 } |
82 | 82 |
83 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
st AtomicString& family, const String& source, const FontFaceDescriptors& descri
ptors) | 83 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
st AtomicString& family, const String& source, const FontFaceDescriptors& descri
ptors) |
84 { | 84 { |
85 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont
ext, family, descriptors)); | 85 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont
ext, family, descriptors)); |
86 | 86 |
87 RefPtrWillBeRawPtr<CSSValue> src = parseCSSValue(toDocument(context), source
, CSSPropertySrc); | 87 NullableCSSValue src = parseCSSValue(toDocument(context), source, CSSPropert
ySrc); |
88 if (!src || !src->isValueList()) | 88 if (!src || !src->isValueList()) { |
89 fontFace->setError(DOMException::create(SyntaxError, "The source provide
d ('" + source + "') could not be parsed as a value list.")); | 89 fontFace->setError(DOMException::create(SyntaxError, "The source provide
d ('" + source + "') could not be parsed as a value list.")); |
| 90 return fontFace; |
| 91 } |
90 | 92 |
91 fontFace->initCSSFontFace(toDocument(context), src); | 93 fontFace->initCSSFontFace(toDocument(context), *src); |
92 return fontFace.release(); | 94 return fontFace.release(); |
93 } | 95 } |
94 | 96 |
95 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
st AtomicString& family, PassRefPtr<DOMArrayBuffer> source, const FontFaceDescri
ptors& descriptors) | 97 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
st AtomicString& family, PassRefPtr<DOMArrayBuffer> source, const FontFaceDescri
ptors& descriptors) |
96 { | 98 { |
97 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont
ext, family, descriptors)); | 99 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont
ext, family, descriptors)); |
98 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->data()),
source->byteLength()); | 100 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->data()),
source->byteLength()); |
99 return fontFace.release(); | 101 return fontFace.release(); |
100 } | 102 } |
101 | 103 |
102 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
st AtomicString& family, PassRefPtr<DOMArrayBufferView> source, const FontFaceDe
scriptors& descriptors) | 104 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
st AtomicString& family, PassRefPtr<DOMArrayBufferView> source, const FontFaceDe
scriptors& descriptors) |
103 { | 105 { |
104 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont
ext, family, descriptors)); | 106 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont
ext, family, descriptors)); |
105 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->baseAddr
ess()), source->byteLength()); | 107 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->baseAddr
ess()), source->byteLength()); |
106 return fontFace.release(); | 108 return fontFace.release(); |
107 } | 109 } |
108 | 110 |
109 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(Document* document, const Styl
eRuleFontFace* fontFaceRule) | 111 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(Document* document, const Styl
eRuleFontFace* fontFaceRule) |
110 { | 112 { |
111 const StylePropertySet& properties = fontFaceRule->properties(); | 113 const StylePropertySet& properties = fontFaceRule->properties(); |
112 | 114 |
113 // Obtain the font-family property and the src property. Both must be define
d. | 115 // Obtain the font-family property and the src property. Both must be define
d. |
114 RefPtrWillBeRawPtr<CSSValue> family = properties.getPropertyCSSValue(CSSProp
ertyFontFamily); | 116 NullableCSSValue family = properties.getPropertyCSSValue(CSSPropertyFontFami
ly); |
115 if (!family || !family->isValueList()) | 117 if (!family || !family->isValueList()) |
116 return nullptr; | 118 return nullptr; |
117 RefPtrWillBeRawPtr<CSSValue> src = properties.getPropertyCSSValue(CSSPropert
ySrc); | 119 NullableCSSValue src = properties.getPropertyCSSValue(CSSPropertySrc); |
118 if (!src || !src->isValueList()) | 120 if (!src || !src->isValueList()) |
119 return nullptr; | 121 return nullptr; |
120 | 122 |
121 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(docu
ment)); | 123 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(docu
ment)); |
122 | 124 |
123 if (fontFace->setFamilyValue(toCSSValueList(family.get())) | 125 if (fontFace->setFamilyValue(toCSSValueList(family)) |
124 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStyle) | 126 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStyle) |
125 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontWeight) | 127 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontWeight) |
126 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStretch) | 128 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStretch) |
127 && fontFace->setPropertyFromStyle(properties, CSSPropertyUnicodeRange) | 129 && fontFace->setPropertyFromStyle(properties, CSSPropertyUnicodeRange) |
128 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontVariant) | 130 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontVariant) |
129 && fontFace->setPropertyFromStyle(properties, CSSPropertyWebkitFontFeatu
reSettings) | 131 && fontFace->setPropertyFromStyle(properties, CSSPropertyWebkitFontFeatu
reSettings) |
130 && !fontFace->family().isEmpty() | 132 && !fontFace->family().isEmpty() |
131 && fontFace->traits().bitfield()) { | 133 && fontFace->traits().bitfield()) { |
132 fontFace->initCSSFontFace(document, src); | 134 fontFace->initCSSFontFace(document, *src); |
133 return fontFace.release(); | 135 return fontFace.release(); |
134 } | 136 } |
135 return nullptr; | 137 return nullptr; |
136 } | 138 } |
137 | 139 |
138 FontFace::FontFace(ExecutionContext* context) | 140 FontFace::FontFace(ExecutionContext* context) |
139 : ActiveDOMObject(context) | 141 : ActiveDOMObject(context) |
140 , m_status(Unloaded) | 142 , m_status(Unloaded) |
141 { | 143 { |
142 suspendIfNeeded(); | 144 suspendIfNeeded(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 setPropertyFromString(toDocument(context), s, CSSPropertyFontVariant, &excep
tionState); | 219 setPropertyFromString(toDocument(context), s, CSSPropertyFontVariant, &excep
tionState); |
218 } | 220 } |
219 | 221 |
220 void FontFace::setFeatureSettings(ExecutionContext* context, const String& s, Ex
ceptionState& exceptionState) | 222 void FontFace::setFeatureSettings(ExecutionContext* context, const String& s, Ex
ceptionState& exceptionState) |
221 { | 223 { |
222 setPropertyFromString(toDocument(context), s, CSSPropertyWebkitFontFeatureSe
ttings, &exceptionState); | 224 setPropertyFromString(toDocument(context), s, CSSPropertyWebkitFontFeatureSe
ttings, &exceptionState); |
223 } | 225 } |
224 | 226 |
225 void FontFace::setPropertyFromString(const Document* document, const String& s,
CSSPropertyID propertyID, ExceptionState* exceptionState) | 227 void FontFace::setPropertyFromString(const Document* document, const String& s,
CSSPropertyID propertyID, ExceptionState* exceptionState) |
226 { | 228 { |
227 RefPtrWillBeRawPtr<CSSValue> value = parseCSSValue(document, s, propertyID); | 229 NullableCSSValue value = parseCSSValue(document, s, propertyID); |
228 if (value && setPropertyValue(value, propertyID)) | 230 if (value && setPropertyValue(value, propertyID)) |
229 return; | 231 return; |
230 | 232 |
231 String message = "Failed to set '" + s + "' as a property value."; | 233 String message = "Failed to set '" + s + "' as a property value."; |
232 if (exceptionState) | 234 if (exceptionState) |
233 exceptionState->throwDOMException(SyntaxError, message); | 235 exceptionState->throwDOMException(SyntaxError, message); |
234 else | 236 else |
235 setError(DOMException::create(SyntaxError, message)); | 237 setError(DOMException::create(SyntaxError, message)); |
236 } | 238 } |
237 | 239 |
238 bool FontFace::setPropertyFromStyle(const StylePropertySet& properties, CSSPrope
rtyID propertyID) | 240 bool FontFace::setPropertyFromStyle(const StylePropertySet& properties, CSSPrope
rtyID propertyID) |
239 { | 241 { |
240 return setPropertyValue(properties.getPropertyCSSValue(propertyID), property
ID); | 242 return setPropertyValue(properties.getPropertyCSSValue(propertyID), property
ID); |
241 } | 243 } |
242 | 244 |
243 bool FontFace::setPropertyValue(PassRefPtrWillBeRawPtr<CSSValue> value, CSSPrope
rtyID propertyID) | 245 bool FontFace::setPropertyValue(NullableCSSValue value, CSSPropertyID propertyID
) |
244 { | 246 { |
245 switch (propertyID) { | 247 switch (propertyID) { |
246 case CSSPropertyFontStyle: | 248 case CSSPropertyFontStyle: |
247 m_style = value; | 249 m_style = value; |
248 break; | 250 break; |
249 case CSSPropertyFontWeight: | 251 case CSSPropertyFontWeight: |
250 m_weight = value; | 252 m_weight = value; |
251 break; | 253 break; |
252 case CSSPropertyFontStretch: | 254 case CSSPropertyFontStretch: |
253 m_stretch = value; | 255 m_stretch = value; |
(...skipping 15 matching lines...) Expand all Loading... |
269 } | 271 } |
270 return true; | 272 return true; |
271 } | 273 } |
272 | 274 |
273 bool FontFace::setFamilyValue(CSSValueList* familyList) | 275 bool FontFace::setFamilyValue(CSSValueList* familyList) |
274 { | 276 { |
275 // The font-family descriptor has to have exactly one family name. | 277 // The font-family descriptor has to have exactly one family name. |
276 if (familyList->length() != 1) | 278 if (familyList->length() != 1) |
277 return false; | 279 return false; |
278 | 280 |
279 CSSPrimitiveValue* familyValue = toCSSPrimitiveValue(familyList->item(0)); | 281 CSSPrimitiveValue& familyValue = toCSSPrimitiveValue(familyList->item(0)); |
280 AtomicString family; | 282 AtomicString family; |
281 if (familyValue->isCustomIdent()) { | 283 if (familyValue.isCustomIdent()) { |
282 family = AtomicString(familyValue->getStringValue()); | 284 family = AtomicString(familyValue.getStringValue()); |
283 } else if (familyValue->isValueID()) { | 285 } else if (familyValue.isValueID()) { |
284 // We need to use the raw text for all the generic family types, since @
font-face is a way of actually | 286 // We need to use the raw text for all the generic family types, since @
font-face is a way of actually |
285 // defining what font to use for those types. | 287 // defining what font to use for those types. |
286 switch (familyValue->getValueID()) { | 288 switch (familyValue.getValueID()) { |
287 case CSSValueSerif: | 289 case CSSValueSerif: |
288 family = FontFamilyNames::webkit_serif; | 290 family = FontFamilyNames::webkit_serif; |
289 break; | 291 break; |
290 case CSSValueSansSerif: | 292 case CSSValueSansSerif: |
291 family = FontFamilyNames::webkit_sans_serif; | 293 family = FontFamilyNames::webkit_sans_serif; |
292 break; | 294 break; |
293 case CSSValueCursive: | 295 case CSSValueCursive: |
294 family = FontFamilyNames::webkit_cursive; | 296 family = FontFamilyNames::webkit_cursive; |
295 break; | 297 break; |
296 case CSSValueFantasy: | 298 case CSSValueFantasy: |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 toDocument(context)->styleEngine().fontSelector()->fontLoader()->loadPending
Fonts(); | 398 toDocument(context)->styleEngine().fontSelector()->fontLoader()->loadPending
Fonts(); |
397 } | 399 } |
398 | 400 |
399 FontTraits FontFace::traits() const | 401 FontTraits FontFace::traits() const |
400 { | 402 { |
401 FontStyle style = FontStyleNormal; | 403 FontStyle style = FontStyleNormal; |
402 if (m_style) { | 404 if (m_style) { |
403 if (!m_style->isPrimitiveValue()) | 405 if (!m_style->isPrimitiveValue()) |
404 return 0; | 406 return 0; |
405 | 407 |
406 switch (toCSSPrimitiveValue(m_style.get())->getValueID()) { | 408 switch (toCSSPrimitiveValue(m_style)->getValueID()) { |
407 case CSSValueNormal: | 409 case CSSValueNormal: |
408 style = FontStyleNormal; | 410 style = FontStyleNormal; |
409 break; | 411 break; |
410 case CSSValueItalic: | 412 case CSSValueItalic: |
411 case CSSValueOblique: | 413 case CSSValueOblique: |
412 style = FontStyleItalic; | 414 style = FontStyleItalic; |
413 break; | 415 break; |
414 default: | 416 default: |
415 break; | 417 break; |
416 } | 418 } |
417 } | 419 } |
418 | 420 |
419 FontWeight weight = FontWeight400; | 421 FontWeight weight = FontWeight400; |
420 if (m_weight) { | 422 if (m_weight) { |
421 if (!m_weight->isPrimitiveValue()) | 423 if (!m_weight->isPrimitiveValue()) |
422 return 0; | 424 return 0; |
423 | 425 |
424 switch (toCSSPrimitiveValue(m_weight.get())->getValueID()) { | 426 switch (toCSSPrimitiveValue(m_weight)->getValueID()) { |
425 case CSSValueBold: | 427 case CSSValueBold: |
426 case CSSValue700: | 428 case CSSValue700: |
427 weight = FontWeight700; | 429 weight = FontWeight700; |
428 break; | 430 break; |
429 case CSSValueNormal: | 431 case CSSValueNormal: |
430 case CSSValue400: | 432 case CSSValue400: |
431 weight = FontWeight400; | 433 weight = FontWeight400; |
432 break; | 434 break; |
433 case CSSValue900: | 435 case CSSValue900: |
434 weight = FontWeight900; | 436 weight = FontWeight900; |
(...skipping 21 matching lines...) Expand all Loading... |
456 case CSSValueLighter: | 458 case CSSValueLighter: |
457 case CSSValueBolder: | 459 case CSSValueBolder: |
458 break; | 460 break; |
459 default: | 461 default: |
460 ASSERT_NOT_REACHED(); | 462 ASSERT_NOT_REACHED(); |
461 break; | 463 break; |
462 } | 464 } |
463 } | 465 } |
464 | 466 |
465 FontVariant variant = FontVariantNormal; | 467 FontVariant variant = FontVariantNormal; |
466 if (RefPtrWillBeRawPtr<CSSValue> fontVariant = m_variant) { | 468 if (NullableCSSValue fontVariant = m_variant) { |
467 // font-variant descriptor can be a value list. | 469 // font-variant descriptor can be a value list. |
468 if (fontVariant->isPrimitiveValue()) { | 470 if (fontVariant->isPrimitiveValue()) { |
469 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSep
arated(); | 471 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSep
arated(); |
470 list->append(fontVariant); | 472 list->append(*fontVariant); |
471 fontVariant = list; | 473 fontVariant = list; |
472 } else if (!fontVariant->isValueList()) { | 474 } else if (!fontVariant->isValueList()) { |
473 return 0; | 475 return 0; |
474 } | 476 } |
475 | 477 |
476 CSSValueList* variantList = toCSSValueList(fontVariant.get()); | 478 CSSValueList* variantList = toCSSValueList(fontVariant); |
477 unsigned numVariants = variantList->length(); | 479 unsigned numVariants = variantList->length(); |
478 if (!numVariants) | 480 if (!numVariants) |
479 return 0; | 481 return 0; |
480 | 482 |
481 for (unsigned i = 0; i < numVariants; ++i) { | 483 for (unsigned i = 0; i < numVariants; ++i) { |
482 switch (toCSSPrimitiveValue(variantList->item(i))->getValueID()) { | 484 switch (toCSSPrimitiveValue(variantList->item(i)).getValueID()) { |
483 case CSSValueNormal: | 485 case CSSValueNormal: |
484 variant = FontVariantNormal; | 486 variant = FontVariantNormal; |
485 break; | 487 break; |
486 case CSSValueSmallCaps: | 488 case CSSValueSmallCaps: |
487 variant = FontVariantSmallCaps; | 489 variant = FontVariantSmallCaps; |
488 break; | 490 break; |
489 default: | 491 default: |
490 break; | 492 break; |
491 } | 493 } |
492 } | 494 } |
493 } | 495 } |
494 | 496 |
495 return FontTraits(style, variant, weight, FontStretchNormal); | 497 return FontTraits(style, variant, weight, FontStretchNormal); |
496 } | 498 } |
497 | 499 |
498 static PassOwnPtrWillBeRawPtr<CSSFontFace> createCSSFontFace(FontFace* fontFace,
CSSValue* unicodeRange) | 500 static PassOwnPtrWillBeRawPtr<CSSFontFace> createCSSFontFace(FontFace* fontFace,
NullableCSSValue unicodeRange) |
499 { | 501 { |
500 Vector<CSSFontFace::UnicodeRange> ranges; | 502 Vector<CSSFontFace::UnicodeRange> ranges; |
501 if (CSSValueList* rangeList = toCSSValueList(unicodeRange)) { | 503 if (CSSValueList* rangeList = toCSSValueList(unicodeRange)) { |
502 unsigned numRanges = rangeList->length(); | 504 unsigned numRanges = rangeList->length(); |
503 for (unsigned i = 0; i < numRanges; i++) { | 505 for (unsigned i = 0; i < numRanges; i++) { |
504 CSSUnicodeRangeValue* range = toCSSUnicodeRangeValue(rangeList->item
(i)); | 506 CSSUnicodeRangeValue& range = toCSSUnicodeRangeValue(rangeList->item
(i)); |
505 ranges.append(CSSFontFace::UnicodeRange(range->from(), range->to()))
; | 507 ranges.append(CSSFontFace::UnicodeRange(range.from(), range.to())); |
506 } | 508 } |
507 } | 509 } |
508 | 510 |
509 return adoptPtrWillBeNoop(new CSSFontFace(fontFace, ranges)); | 511 return adoptPtrWillBeNoop(new CSSFontFace(fontFace, ranges)); |
510 } | 512 } |
511 | 513 |
512 void FontFace::initCSSFontFace(Document* document, PassRefPtrWillBeRawPtr<CSSVal
ue> src) | 514 void FontFace::initCSSFontFace(Document* document, CSSValue src) |
513 { | 515 { |
514 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); | 516 m_cssFontFace = createCSSFontFace(this, m_unicodeRange); |
515 if (m_error) | 517 if (m_error) |
516 return; | 518 return; |
517 | 519 |
518 // Each item in the src property's list is a single CSSFontFaceSource. Put t
hem all into a CSSFontFace. | 520 // Each item in the src property's list is a single CSSFontFaceSource. Put t
hem all into a CSSFontFace. |
519 ASSERT(src); | 521 ASSERT(src.isValueList()); |
520 ASSERT(src->isValueList()); | 522 CSSValueList& srcList = toCSSValueList(src); |
521 CSSValueList* srcList = toCSSValueList(src.get()); | 523 int srcLength = srcList.length(); |
522 int srcLength = srcList->length(); | |
523 | 524 |
524 for (int i = 0; i < srcLength; i++) { | 525 for (int i = 0; i < srcLength; i++) { |
525 // An item in the list either specifies a string (local font name) or a
URL (remote font to download). | 526 // An item in the list either specifies a string (local font name) or a
URL (remote font to download). |
526 CSSFontFaceSrcValue* item = toCSSFontFaceSrcValue(srcList->item(i)); | 527 CSSFontFaceSrcValue& item = toCSSFontFaceSrcValue(srcList.item(i)); |
527 OwnPtrWillBeRawPtr<CSSFontFaceSource> source = nullptr; | 528 OwnPtrWillBeRawPtr<CSSFontFaceSource> source = nullptr; |
528 | 529 |
529 if (!item->isLocal()) { | 530 if (!item.isLocal()) { |
530 Settings* settings = document ? document->frame() ? document->frame(
)->settings() : 0 : 0; | 531 Settings* settings = document ? document->frame() ? document->frame(
)->settings() : 0 : 0; |
531 bool allowDownloading = settings && settings->downloadableBinaryFont
sEnabled(); | 532 bool allowDownloading = settings && settings->downloadableBinaryFont
sEnabled(); |
532 if (allowDownloading && item->isSupportedFormat() && document) { | 533 if (allowDownloading && item.isSupportedFormat() && document) { |
533 FontResource* fetched = item->fetch(document); | 534 FontResource* fetched = item.fetch(document); |
534 if (fetched) { | 535 if (fetched) { |
535 FontLoader* fontLoader = document->styleEngine().fontSelecto
r()->fontLoader(); | 536 FontLoader* fontLoader = document->styleEngine().fontSelecto
r()->fontLoader(); |
536 source = adoptPtrWillBeNoop(new RemoteFontFaceSource(fetched
, fontLoader)); | 537 source = adoptPtrWillBeNoop(new RemoteFontFaceSource(fetched
, fontLoader)); |
537 } | 538 } |
538 } | 539 } |
539 } else { | 540 } else { |
540 source = adoptPtrWillBeNoop(new LocalFontFaceSource(item->resource()
)); | 541 source = adoptPtrWillBeNoop(new LocalFontFaceSource(item.resource())
); |
541 } | 542 } |
542 | 543 |
543 if (source) | 544 if (source) |
544 m_cssFontFace->addSource(source.release()); | 545 m_cssFontFace->addSource(source.release()); |
545 } | 546 } |
546 } | 547 } |
547 | 548 |
548 void FontFace::initCSSFontFace(const unsigned char* data, unsigned size) | 549 void FontFace::initCSSFontFace(const unsigned char* data, unsigned size) |
549 { | 550 { |
550 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); | 551 m_cssFontFace = createCSSFontFace(this, m_unicodeRange); |
551 if (m_error) | 552 if (m_error) |
552 return; | 553 return; |
553 | 554 |
554 RefPtr<SharedBuffer> buffer = SharedBuffer::create(data, size); | 555 RefPtr<SharedBuffer> buffer = SharedBuffer::create(data, size); |
555 OwnPtrWillBeRawPtr<BinaryDataFontFaceSource> source = adoptPtrWillBeNoop(new
BinaryDataFontFaceSource(buffer.get(), m_otsParseMessage)); | 556 OwnPtrWillBeRawPtr<BinaryDataFontFaceSource> source = adoptPtrWillBeNoop(new
BinaryDataFontFaceSource(buffer.get(), m_otsParseMessage)); |
556 if (source->isValid()) | 557 if (source->isValid()) |
557 setLoadStatus(Loaded); | 558 setLoadStatus(Loaded); |
558 else | 559 else |
559 setError(DOMException::create(SyntaxError, "Invalid font data in ArrayBu
ffer.")); | 560 setError(DOMException::create(SyntaxError, "Invalid font data in ArrayBu
ffer.")); |
560 m_cssFontFace->addSource(source.release()); | 561 m_cssFontFace->addSource(source.release()); |
(...skipping 19 matching lines...) Expand all Loading... |
580 { | 581 { |
581 return m_cssFontFace->hadBlankText(); | 582 return m_cssFontFace->hadBlankText(); |
582 } | 583 } |
583 | 584 |
584 bool FontFace::hasPendingActivity() const | 585 bool FontFace::hasPendingActivity() const |
585 { | 586 { |
586 return m_status == Loading && executionContext() && !executionContext()->act
iveDOMObjectsAreStopped(); | 587 return m_status == Loading && executionContext() && !executionContext()->act
iveDOMObjectsAreStopped(); |
587 } | 588 } |
588 | 589 |
589 } // namespace blink | 590 } // namespace blink |
OLD | NEW |