| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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/Histogram.h" | 61 #include "platform/Histogram.h" |
| 62 #include "platform/SharedBuffer.h" | 62 #include "platform/SharedBuffer.h" |
| 63 | 63 |
| 64 namespace blink { | 64 namespace blink { |
| 65 | 65 |
| 66 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document,
const String& value, CSSPropertyID propertyID) | 66 static RawPtr<CSSValue> parseCSSValue(const Document* document, const String& va
lue, CSSPropertyID propertyID) |
| 67 { | 67 { |
| 68 CSSParserContext context(*document, UseCounter::getFrom(document)); | 68 CSSParserContext context(*document, UseCounter::getFrom(document)); |
| 69 return CSSParser::parseFontFaceDescriptor(propertyID, value, context); | 69 return CSSParser::parseFontFaceDescriptor(propertyID, value, context); |
| 70 } | 70 } |
| 71 | 71 |
| 72 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
st AtomicString& family, StringOrArrayBufferOrArrayBufferView& source, const Fon
tFaceDescriptors& descriptors) | 72 RawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString&
family, StringOrArrayBufferOrArrayBufferView& source, const FontFaceDescriptors
& descriptors) |
| 73 { | 73 { |
| 74 if (source.isString()) | 74 if (source.isString()) |
| 75 return create(context, family, source.getAsString(), descriptors); | 75 return create(context, family, source.getAsString(), descriptors); |
| 76 if (source.isArrayBuffer()) | 76 if (source.isArrayBuffer()) |
| 77 return create(context, family, source.getAsArrayBuffer(), descriptors); | 77 return create(context, family, source.getAsArrayBuffer(), descriptors); |
| 78 if (source.isArrayBufferView()) | 78 if (source.isArrayBufferView()) |
| 79 return create(context, family, source.getAsArrayBufferView(), descriptor
s); | 79 return create(context, family, source.getAsArrayBufferView(), descriptor
s); |
| 80 ASSERT_NOT_REACHED(); | 80 ASSERT_NOT_REACHED(); |
| 81 return nullptr; | 81 return nullptr; |
| 82 } | 82 } |
| 83 | 83 |
| 84 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
st AtomicString& family, const String& source, const FontFaceDescriptors& descri
ptors) | 84 RawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString&
family, const String& source, const FontFaceDescriptors& descriptors) |
| 85 { | 85 { |
| 86 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont
ext, family, descriptors)); | 86 RawPtr<FontFace> fontFace = (new FontFace(context, family, descriptors)); |
| 87 | 87 |
| 88 RefPtrWillBeRawPtr<CSSValue> src = parseCSSValue(toDocument(context), source
, CSSPropertySrc); | 88 RawPtr<CSSValue> src = parseCSSValue(toDocument(context), source, CSSPropert
ySrc); |
| 89 if (!src || !src->isValueList()) | 89 if (!src || !src->isValueList()) |
| 90 fontFace->setError(DOMException::create(SyntaxError, "The source provide
d ('" + source + "') could not be parsed as a value list.")); | 90 fontFace->setError(DOMException::create(SyntaxError, "The source provide
d ('" + source + "') could not be parsed as a value list.")); |
| 91 | 91 |
| 92 fontFace->initCSSFontFace(toDocument(context), src); | 92 fontFace->initCSSFontFace(toDocument(context), src); |
| 93 return fontFace.release(); | 93 return fontFace.release(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
st AtomicString& family, PassRefPtr<DOMArrayBuffer> source, const FontFaceDescri
ptors& descriptors) | 96 RawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString&
family, PassRefPtr<DOMArrayBuffer> source, const FontFaceDescriptors& descripto
rs) |
| 97 { | 97 { |
| 98 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont
ext, family, descriptors)); | 98 RawPtr<FontFace> fontFace = (new FontFace(context, family, descriptors)); |
| 99 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->data()),
source->byteLength()); | 99 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->data()),
source->byteLength()); |
| 100 return fontFace.release(); | 100 return fontFace.release(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con
st AtomicString& family, PassRefPtr<DOMArrayBufferView> source, const FontFaceDe
scriptors& descriptors) | 103 RawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString&
family, PassRefPtr<DOMArrayBufferView> source, const FontFaceDescriptors& descr
iptors) |
| 104 { | 104 { |
| 105 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(cont
ext, family, descriptors)); | 105 RawPtr<FontFace> fontFace = (new FontFace(context, family, descriptors)); |
| 106 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->baseAddr
ess()), source->byteLength()); | 106 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->baseAddr
ess()), source->byteLength()); |
| 107 return fontFace.release(); | 107 return fontFace.release(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(Document* document, const Styl
eRuleFontFace* fontFaceRule) | 110 RawPtr<FontFace> FontFace::create(Document* document, const StyleRuleFontFace* f
ontFaceRule) |
| 111 { | 111 { |
| 112 const StylePropertySet& properties = fontFaceRule->properties(); | 112 const StylePropertySet& properties = fontFaceRule->properties(); |
| 113 | 113 |
| 114 // Obtain the font-family property and the src property. Both must be define
d. | 114 // Obtain the font-family property and the src property. Both must be define
d. |
| 115 RefPtrWillBeRawPtr<CSSValue> family = properties.getPropertyCSSValue(CSSProp
ertyFontFamily); | 115 RawPtr<CSSValue> family = properties.getPropertyCSSValue(CSSPropertyFontFami
ly); |
| 116 if (!family || (!family->isCustomIdentValue() && !family->isPrimitiveValue()
)) | 116 if (!family || (!family->isCustomIdentValue() && !family->isPrimitiveValue()
)) |
| 117 return nullptr; | 117 return nullptr; |
| 118 RefPtrWillBeRawPtr<CSSValue> src = properties.getPropertyCSSValue(CSSPropert
ySrc); | 118 RawPtr<CSSValue> src = properties.getPropertyCSSValue(CSSPropertySrc); |
| 119 if (!src || !src->isValueList()) | 119 if (!src || !src->isValueList()) |
| 120 return nullptr; | 120 return nullptr; |
| 121 | 121 |
| 122 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(docu
ment)); | 122 RawPtr<FontFace> fontFace = (new FontFace(document)); |
| 123 | 123 |
| 124 if (fontFace->setFamilyValue(*family) | 124 if (fontFace->setFamilyValue(*family) |
| 125 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStyle) | 125 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStyle) |
| 126 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontWeight) | 126 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontWeight) |
| 127 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStretch) | 127 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStretch) |
| 128 && fontFace->setPropertyFromStyle(properties, CSSPropertyUnicodeRange) | 128 && fontFace->setPropertyFromStyle(properties, CSSPropertyUnicodeRange) |
| 129 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontVariant) | 129 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontVariant) |
| 130 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontFeatureSett
ings) | 130 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontFeatureSett
ings) |
| 131 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontDisplay) | 131 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontDisplay) |
| 132 && !fontFace->family().isEmpty() | 132 && !fontFace->family().isEmpty() |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 setPropertyFromString(toDocument(context), s, CSSPropertyFontVariant, &excep
tionState); | 219 setPropertyFromString(toDocument(context), s, CSSPropertyFontVariant, &excep
tionState); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void FontFace::setFeatureSettings(ExecutionContext* context, const String& s, Ex
ceptionState& exceptionState) | 222 void FontFace::setFeatureSettings(ExecutionContext* context, const String& s, Ex
ceptionState& exceptionState) |
| 223 { | 223 { |
| 224 setPropertyFromString(toDocument(context), s, CSSPropertyFontFeatureSettings
, &exceptionState); | 224 setPropertyFromString(toDocument(context), s, CSSPropertyFontFeatureSettings
, &exceptionState); |
| 225 } | 225 } |
| 226 | 226 |
| 227 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) |
| 228 { | 228 { |
| 229 RefPtrWillBeRawPtr<CSSValue> value = parseCSSValue(document, s, propertyID); | 229 RawPtr<CSSValue> value = parseCSSValue(document, s, propertyID); |
| 230 if (value && setPropertyValue(value, propertyID)) | 230 if (value && setPropertyValue(value, propertyID)) |
| 231 return; | 231 return; |
| 232 | 232 |
| 233 String message = "Failed to set '" + s + "' as a property value."; | 233 String message = "Failed to set '" + s + "' as a property value."; |
| 234 if (exceptionState) | 234 if (exceptionState) |
| 235 exceptionState->throwDOMException(SyntaxError, message); | 235 exceptionState->throwDOMException(SyntaxError, message); |
| 236 else | 236 else |
| 237 setError(DOMException::create(SyntaxError, message)); | 237 setError(DOMException::create(SyntaxError, message)); |
| 238 } | 238 } |
| 239 | 239 |
| 240 bool FontFace::setPropertyFromStyle(const StylePropertySet& properties, CSSPrope
rtyID propertyID) | 240 bool FontFace::setPropertyFromStyle(const StylePropertySet& properties, CSSPrope
rtyID propertyID) |
| 241 { | 241 { |
| 242 return setPropertyValue(properties.getPropertyCSSValue(propertyID), property
ID); | 242 return setPropertyValue(properties.getPropertyCSSValue(propertyID), property
ID); |
| 243 } | 243 } |
| 244 | 244 |
| 245 bool FontFace::setPropertyValue(PassRefPtrWillBeRawPtr<CSSValue> value, CSSPrope
rtyID propertyID) | 245 bool FontFace::setPropertyValue(RawPtr<CSSValue> value, CSSPropertyID propertyID
) |
| 246 { | 246 { |
| 247 switch (propertyID) { | 247 switch (propertyID) { |
| 248 case CSSPropertyFontStyle: | 248 case CSSPropertyFontStyle: |
| 249 m_style = value; | 249 m_style = value; |
| 250 break; | 250 break; |
| 251 case CSSPropertyFontWeight: | 251 case CSSPropertyFontWeight: |
| 252 m_weight = value; | 252 m_weight = value; |
| 253 break; | 253 break; |
| 254 case CSSPropertyFontStretch: | 254 case CSSPropertyFontStretch: |
| 255 m_stretch = value; | 255 m_stretch = value; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 ASSERT(m_status != Error || m_error); | 333 ASSERT(m_status != Error || m_error); |
| 334 | 334 |
| 335 if (m_status == Loaded || m_status == Error) { | 335 if (m_status == Loaded || m_status == Error) { |
| 336 if (m_loadedProperty) { | 336 if (m_loadedProperty) { |
| 337 if (m_status == Loaded) | 337 if (m_status == Loaded) |
| 338 m_loadedProperty->resolve(this); | 338 m_loadedProperty->resolve(this); |
| 339 else | 339 else |
| 340 m_loadedProperty->reject(m_error.get()); | 340 m_loadedProperty->reject(m_error.get()); |
| 341 } | 341 } |
| 342 | 342 |
| 343 WillBeHeapVector<RefPtrWillBeMember<LoadFontCallback>> callbacks; | 343 HeapVector<Member<LoadFontCallback>> callbacks; |
| 344 m_callbacks.swap(callbacks); | 344 m_callbacks.swap(callbacks); |
| 345 for (size_t i = 0; i < callbacks.size(); ++i) { | 345 for (size_t i = 0; i < callbacks.size(); ++i) { |
| 346 if (m_status == Loaded) | 346 if (m_status == Loaded) |
| 347 callbacks[i]->notifyLoaded(this); | 347 callbacks[i]->notifyLoaded(this); |
| 348 else | 348 else |
| 349 callbacks[i]->notifyError(this); | 349 callbacks[i]->notifyError(this); |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 } | 352 } |
| 353 | 353 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 369 } | 369 } |
| 370 return m_loadedProperty->promise(scriptState->world()); | 370 return m_loadedProperty->promise(scriptState->world()); |
| 371 } | 371 } |
| 372 | 372 |
| 373 ScriptPromise FontFace::load(ScriptState* scriptState) | 373 ScriptPromise FontFace::load(ScriptState* scriptState) |
| 374 { | 374 { |
| 375 loadInternal(scriptState->executionContext()); | 375 loadInternal(scriptState->executionContext()); |
| 376 return fontStatusPromise(scriptState); | 376 return fontStatusPromise(scriptState); |
| 377 } | 377 } |
| 378 | 378 |
| 379 void FontFace::loadWithCallback(PassRefPtrWillBeRawPtr<LoadFontCallback> callbac
k, ExecutionContext* context) | 379 void FontFace::loadWithCallback(RawPtr<LoadFontCallback> callback, ExecutionCont
ext* context) |
| 380 { | 380 { |
| 381 loadInternal(context); | 381 loadInternal(context); |
| 382 if (m_status == Loaded) | 382 if (m_status == Loaded) |
| 383 callback->notifyLoaded(this); | 383 callback->notifyLoaded(this); |
| 384 else if (m_status == Error) | 384 else if (m_status == Error) |
| 385 callback->notifyError(this); | 385 callback->notifyError(this); |
| 386 else | 386 else |
| 387 m_callbacks.append(callback); | 387 m_callbacks.append(callback); |
| 388 } | 388 } |
| 389 | 389 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 case CSSValueLighter: | 493 case CSSValueLighter: |
| 494 case CSSValueBolder: | 494 case CSSValueBolder: |
| 495 break; | 495 break; |
| 496 default: | 496 default: |
| 497 ASSERT_NOT_REACHED(); | 497 ASSERT_NOT_REACHED(); |
| 498 break; | 498 break; |
| 499 } | 499 } |
| 500 } | 500 } |
| 501 | 501 |
| 502 FontVariant variant = FontVariantNormal; | 502 FontVariant variant = FontVariantNormal; |
| 503 if (RefPtrWillBeRawPtr<CSSValue> fontVariant = m_variant) { | 503 if (RawPtr<CSSValue> fontVariant = m_variant) { |
| 504 // font-variant descriptor can be a value list. | 504 // font-variant descriptor can be a value list. |
| 505 if (fontVariant->isPrimitiveValue()) { | 505 if (fontVariant->isPrimitiveValue()) { |
| 506 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSep
arated(); | 506 RawPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
| 507 list->append(fontVariant); | 507 list->append(fontVariant); |
| 508 fontVariant = list; | 508 fontVariant = list; |
| 509 } else if (!fontVariant->isValueList()) { | 509 } else if (!fontVariant->isValueList()) { |
| 510 return 0; | 510 return 0; |
| 511 } | 511 } |
| 512 | 512 |
| 513 CSSValueList* variantList = toCSSValueList(fontVariant.get()); | 513 CSSValueList* variantList = toCSSValueList(fontVariant.get()); |
| 514 unsigned numVariants = variantList->length(); | 514 unsigned numVariants = variantList->length(); |
| 515 if (!numVariants) | 515 if (!numVariants) |
| 516 return 0; | 516 return 0; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 546 return FontDisplayFallback; | 546 return FontDisplayFallback; |
| 547 case CSSValueOptional: | 547 case CSSValueOptional: |
| 548 return FontDisplayOptional; | 548 return FontDisplayOptional; |
| 549 default: | 549 default: |
| 550 break; | 550 break; |
| 551 } | 551 } |
| 552 } | 552 } |
| 553 return FontDisplayAuto; | 553 return FontDisplayAuto; |
| 554 } | 554 } |
| 555 | 555 |
| 556 static PassOwnPtrWillBeRawPtr<CSSFontFace> createCSSFontFace(FontFace* fontFace,
CSSValue* unicodeRange) | 556 static RawPtr<CSSFontFace> createCSSFontFace(FontFace* fontFace, CSSValue* unico
deRange) |
| 557 { | 557 { |
| 558 Vector<CSSFontFace::UnicodeRange> ranges; | 558 Vector<CSSFontFace::UnicodeRange> ranges; |
| 559 if (CSSValueList* rangeList = toCSSValueList(unicodeRange)) { | 559 if (CSSValueList* rangeList = toCSSValueList(unicodeRange)) { |
| 560 unsigned numRanges = rangeList->length(); | 560 unsigned numRanges = rangeList->length(); |
| 561 for (unsigned i = 0; i < numRanges; i++) { | 561 for (unsigned i = 0; i < numRanges; i++) { |
| 562 CSSUnicodeRangeValue* range = toCSSUnicodeRangeValue(rangeList->item
(i)); | 562 CSSUnicodeRangeValue* range = toCSSUnicodeRangeValue(rangeList->item
(i)); |
| 563 ranges.append(CSSFontFace::UnicodeRange(range->from(), range->to()))
; | 563 ranges.append(CSSFontFace::UnicodeRange(range->from(), range->to()))
; |
| 564 } | 564 } |
| 565 } | 565 } |
| 566 | 566 |
| 567 return adoptPtrWillBeNoop(new CSSFontFace(fontFace, ranges)); | 567 return (new CSSFontFace(fontFace, ranges)); |
| 568 } | 568 } |
| 569 | 569 |
| 570 void FontFace::initCSSFontFace(Document* document, PassRefPtrWillBeRawPtr<CSSVal
ue> src) | 570 void FontFace::initCSSFontFace(Document* document, RawPtr<CSSValue> src) |
| 571 { | 571 { |
| 572 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); | 572 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); |
| 573 if (m_error) | 573 if (m_error) |
| 574 return; | 574 return; |
| 575 | 575 |
| 576 // Each item in the src property's list is a single CSSFontFaceSource. Put t
hem all into a CSSFontFace. | 576 // Each item in the src property's list is a single CSSFontFaceSource. Put t
hem all into a CSSFontFace. |
| 577 ASSERT(src); | 577 ASSERT(src); |
| 578 ASSERT(src->isValueList()); | 578 ASSERT(src->isValueList()); |
| 579 CSSValueList* srcList = toCSSValueList(src.get()); | 579 CSSValueList* srcList = toCSSValueList(src.get()); |
| 580 int srcLength = srcList->length(); | 580 int srcLength = srcList->length(); |
| 581 | 581 |
| 582 for (int i = 0; i < srcLength; i++) { | 582 for (int i = 0; i < srcLength; i++) { |
| 583 // An item in the list either specifies a string (local font name) or a
URL (remote font to download). | 583 // An item in the list either specifies a string (local font name) or a
URL (remote font to download). |
| 584 CSSFontFaceSrcValue* item = toCSSFontFaceSrcValue(srcList->item(i)); | 584 CSSFontFaceSrcValue* item = toCSSFontFaceSrcValue(srcList->item(i)); |
| 585 OwnPtrWillBeRawPtr<CSSFontFaceSource> source = nullptr; | 585 RawPtr<CSSFontFaceSource> source = nullptr; |
| 586 | 586 |
| 587 if (!item->isLocal()) { | 587 if (!item->isLocal()) { |
| 588 const Settings* settings = document ? document->settings() : nullptr
; | 588 const Settings* settings = document ? document->settings() : nullptr
; |
| 589 bool allowDownloading = settings && settings->downloadableBinaryFont
sEnabled(); | 589 bool allowDownloading = settings && settings->downloadableBinaryFont
sEnabled(); |
| 590 if (allowDownloading && item->isSupportedFormat() && document) { | 590 if (allowDownloading && item->isSupportedFormat() && document) { |
| 591 RefPtrWillBeRawPtr<FontResource> fetched = item->fetch(document)
; | 591 RawPtr<FontResource> fetched = item->fetch(document); |
| 592 if (fetched) { | 592 if (fetched) { |
| 593 FontLoader* fontLoader = document->styleEngine().fontSelecto
r()->fontLoader(); | 593 FontLoader* fontLoader = document->styleEngine().fontSelecto
r()->fontLoader(); |
| 594 source = adoptPtrWillBeNoop(new RemoteFontFaceSource(fetched
.release(), fontLoader, CSSValueToFontDisplay(m_display.get()))); | 594 source = (new RemoteFontFaceSource(fetched.release(), fontLo
ader, CSSValueToFontDisplay(m_display.get()))); |
| 595 } | 595 } |
| 596 } | 596 } |
| 597 } else { | 597 } else { |
| 598 source = adoptPtrWillBeNoop(new LocalFontFaceSource(item->resource()
)); | 598 source = (new LocalFontFaceSource(item->resource())); |
| 599 } | 599 } |
| 600 | 600 |
| 601 if (source) | 601 if (source) |
| 602 m_cssFontFace->addSource(source.release()); | 602 m_cssFontFace->addSource(source.release()); |
| 603 } | 603 } |
| 604 | 604 |
| 605 if (m_display) { | 605 if (m_display) { |
| 606 DEFINE_STATIC_LOCAL(EnumerationHistogram, fontDisplayHistogram, ("WebFon
t.FontDisplayValue", FontDisplayEnumMax)); | 606 DEFINE_STATIC_LOCAL(EnumerationHistogram, fontDisplayHistogram, ("WebFon
t.FontDisplayValue", FontDisplayEnumMax)); |
| 607 fontDisplayHistogram.count(CSSValueToFontDisplay(m_display.get())); | 607 fontDisplayHistogram.count(CSSValueToFontDisplay(m_display.get())); |
| 608 } | 608 } |
| 609 } | 609 } |
| 610 | 610 |
| 611 void FontFace::initCSSFontFace(const unsigned char* data, size_t size) | 611 void FontFace::initCSSFontFace(const unsigned char* data, size_t size) |
| 612 { | 612 { |
| 613 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); | 613 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); |
| 614 if (m_error) | 614 if (m_error) |
| 615 return; | 615 return; |
| 616 | 616 |
| 617 RefPtr<SharedBuffer> buffer = SharedBuffer::create(data, size); | 617 RefPtr<SharedBuffer> buffer = SharedBuffer::create(data, size); |
| 618 OwnPtrWillBeRawPtr<BinaryDataFontFaceSource> source = adoptPtrWillBeNoop(new
BinaryDataFontFaceSource(buffer.get(), m_otsParseMessage)); | 618 RawPtr<BinaryDataFontFaceSource> source = (new BinaryDataFontFaceSource(buff
er.get(), m_otsParseMessage)); |
| 619 if (source->isValid()) | 619 if (source->isValid()) |
| 620 setLoadStatus(Loaded); | 620 setLoadStatus(Loaded); |
| 621 else | 621 else |
| 622 setError(DOMException::create(SyntaxError, "Invalid font data in ArrayBu
ffer.")); | 622 setError(DOMException::create(SyntaxError, "Invalid font data in ArrayBu
ffer.")); |
| 623 m_cssFontFace->addSource(source.release()); | 623 m_cssFontFace->addSource(source.release()); |
| 624 } | 624 } |
| 625 | 625 |
| 626 DEFINE_TRACE(FontFace) | 626 DEFINE_TRACE(FontFace) |
| 627 { | 627 { |
| 628 visitor->trace(m_style); | 628 visitor->trace(m_style); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 643 { | 643 { |
| 644 return m_cssFontFace->hadBlankText(); | 644 return m_cssFontFace->hadBlankText(); |
| 645 } | 645 } |
| 646 | 646 |
| 647 bool FontFace::hasPendingActivity() const | 647 bool FontFace::hasPendingActivity() const |
| 648 { | 648 { |
| 649 return m_status == Loading && executionContext() && !executionContext()->act
iveDOMObjectsAreStopped(); | 649 return m_status == Loading && executionContext() && !executionContext()->act
iveDOMObjectsAreStopped(); |
| 650 } | 650 } |
| 651 | 651 |
| 652 } // namespace blink | 652 } // namespace blink |
| OLD | NEW |