| 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 RawPtr<CSSValue> parseCSSValue(const Document* document, const String& va
lue, CSSPropertyID propertyID) | 66 static CSSValue* parseCSSValue(const Document* document, const String& value, CS
SPropertyID 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 RawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString&
family, StringOrArrayBufferOrArrayBufferView& source, const FontFaceDescriptors
& descriptors) | 72 FontFace* FontFace::create(ExecutionContext* context, const AtomicString& family
, StringOrArrayBufferOrArrayBufferView& source, const FontFaceDescriptors& descr
iptors) |
| 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 RawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString&
family, const String& source, const FontFaceDescriptors& descriptors) | 84 FontFace* FontFace::create(ExecutionContext* context, const AtomicString& family
, const String& source, const FontFaceDescriptors& descriptors) |
| 85 { | 85 { |
| 86 RawPtr<FontFace> fontFace = new FontFace(context, family, descriptors); | 86 FontFace* fontFace = new FontFace(context, family, descriptors); |
| 87 | 87 |
| 88 RawPtr<CSSValue> src = parseCSSValue(toDocument(context), source, CSSPropert
ySrc); | 88 CSSValue* src = parseCSSValue(toDocument(context), source, CSSPropertySrc); |
| 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; |
| 94 } | 94 } |
| 95 | 95 |
| 96 RawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString&
family, PassRefPtr<DOMArrayBuffer> source, const FontFaceDescriptors& descripto
rs) | 96 FontFace* FontFace::create(ExecutionContext* context, const AtomicString& family
, PassRefPtr<DOMArrayBuffer> source, const FontFaceDescriptors& descriptors) |
| 97 { | 97 { |
| 98 RawPtr<FontFace> fontFace = new FontFace(context, family, descriptors); | 98 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; |
| 101 } | 101 } |
| 102 | 102 |
| 103 RawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString&
family, PassRefPtr<DOMArrayBufferView> source, const FontFaceDescriptors& descr
iptors) | 103 FontFace* FontFace::create(ExecutionContext* context, const AtomicString& family
, PassRefPtr<DOMArrayBufferView> source, const FontFaceDescriptors& descriptors) |
| 104 { | 104 { |
| 105 RawPtr<FontFace> fontFace = new FontFace(context, family, descriptors); | 105 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; |
| 108 } | 108 } |
| 109 | 109 |
| 110 RawPtr<FontFace> FontFace::create(Document* document, const StyleRuleFontFace* f
ontFaceRule) | 110 FontFace* FontFace::create(Document* document, const StyleRuleFontFace* fontFace
Rule) |
| 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 RawPtr<CSSValue> family = properties.getPropertyCSSValue(CSSPropertyFontFami
ly); | 115 CSSValue* family = properties.getPropertyCSSValue(CSSPropertyFontFamily); |
| 116 if (!family || (!family->isFontFamilyValue() && !family->isPrimitiveValue())
) | 116 if (!family || (!family->isFontFamilyValue() && !family->isPrimitiveValue())
) |
| 117 return nullptr; | 117 return nullptr; |
| 118 RawPtr<CSSValue> src = properties.getPropertyCSSValue(CSSPropertySrc); | 118 CSSValue* src = properties.getPropertyCSSValue(CSSPropertySrc); |
| 119 if (!src || !src->isValueList()) | 119 if (!src || !src->isValueList()) |
| 120 return nullptr; | 120 return nullptr; |
| 121 | 121 |
| 122 RawPtr<FontFace> fontFace = new FontFace(document); | 122 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() |
| 133 && fontFace->traits().bitfield()) { | 133 && fontFace->traits().bitfield()) { |
| 134 fontFace->initCSSFontFace(document, src); | 134 fontFace->initCSSFontFace(document, src); |
| 135 return fontFace.release(); | 135 return fontFace; |
| 136 } | 136 } |
| 137 return nullptr; | 137 return nullptr; |
| 138 } | 138 } |
| 139 | 139 |
| 140 FontFace::FontFace(ExecutionContext* context) | 140 FontFace::FontFace(ExecutionContext* context) |
| 141 : ActiveScriptWrappable(this) | 141 : ActiveScriptWrappable(this) |
| 142 , ActiveDOMObject(context) | 142 , ActiveDOMObject(context) |
| 143 , m_status(Unloaded) | 143 , m_status(Unloaded) |
| 144 { | 144 { |
| 145 suspendIfNeeded(); | 145 suspendIfNeeded(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 setPropertyFromString(toDocument(context), s, CSSPropertyFontVariant, &excep
tionState); | 221 setPropertyFromString(toDocument(context), s, CSSPropertyFontVariant, &excep
tionState); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void FontFace::setFeatureSettings(ExecutionContext* context, const String& s, Ex
ceptionState& exceptionState) | 224 void FontFace::setFeatureSettings(ExecutionContext* context, const String& s, Ex
ceptionState& exceptionState) |
| 225 { | 225 { |
| 226 setPropertyFromString(toDocument(context), s, CSSPropertyFontFeatureSettings
, &exceptionState); | 226 setPropertyFromString(toDocument(context), s, CSSPropertyFontFeatureSettings
, &exceptionState); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void FontFace::setPropertyFromString(const Document* document, const String& s,
CSSPropertyID propertyID, ExceptionState* exceptionState) | 229 void FontFace::setPropertyFromString(const Document* document, const String& s,
CSSPropertyID propertyID, ExceptionState* exceptionState) |
| 230 { | 230 { |
| 231 RawPtr<CSSValue> value = parseCSSValue(document, s, propertyID); | 231 CSSValue* value = parseCSSValue(document, s, propertyID); |
| 232 if (value && setPropertyValue(value, propertyID)) | 232 if (value && setPropertyValue(value, propertyID)) |
| 233 return; | 233 return; |
| 234 | 234 |
| 235 String message = "Failed to set '" + s + "' as a property value."; | 235 String message = "Failed to set '" + s + "' as a property value."; |
| 236 if (exceptionState) | 236 if (exceptionState) |
| 237 exceptionState->throwDOMException(SyntaxError, message); | 237 exceptionState->throwDOMException(SyntaxError, message); |
| 238 else | 238 else |
| 239 setError(DOMException::create(SyntaxError, message)); | 239 setError(DOMException::create(SyntaxError, message)); |
| 240 } | 240 } |
| 241 | 241 |
| 242 bool FontFace::setPropertyFromStyle(const StylePropertySet& properties, CSSPrope
rtyID propertyID) | 242 bool FontFace::setPropertyFromStyle(const StylePropertySet& properties, CSSPrope
rtyID propertyID) |
| 243 { | 243 { |
| 244 return setPropertyValue(properties.getPropertyCSSValue(propertyID), property
ID); | 244 return setPropertyValue(properties.getPropertyCSSValue(propertyID), property
ID); |
| 245 } | 245 } |
| 246 | 246 |
| 247 bool FontFace::setPropertyValue(RawPtr<CSSValue> value, CSSPropertyID propertyID
) | 247 bool FontFace::setPropertyValue(CSSValue* value, CSSPropertyID propertyID) |
| 248 { | 248 { |
| 249 switch (propertyID) { | 249 switch (propertyID) { |
| 250 case CSSPropertyFontStyle: | 250 case CSSPropertyFontStyle: |
| 251 m_style = value; | 251 m_style = value; |
| 252 break; | 252 break; |
| 253 case CSSPropertyFontWeight: | 253 case CSSPropertyFontWeight: |
| 254 m_weight = value; | 254 m_weight = value; |
| 255 break; | 255 break; |
| 256 case CSSPropertyFontStretch: | 256 case CSSPropertyFontStretch: |
| 257 m_stretch = value; | 257 m_stretch = value; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 } | 371 } |
| 372 return m_loadedProperty->promise(scriptState->world()); | 372 return m_loadedProperty->promise(scriptState->world()); |
| 373 } | 373 } |
| 374 | 374 |
| 375 ScriptPromise FontFace::load(ScriptState* scriptState) | 375 ScriptPromise FontFace::load(ScriptState* scriptState) |
| 376 { | 376 { |
| 377 loadInternal(scriptState->getExecutionContext()); | 377 loadInternal(scriptState->getExecutionContext()); |
| 378 return fontStatusPromise(scriptState); | 378 return fontStatusPromise(scriptState); |
| 379 } | 379 } |
| 380 | 380 |
| 381 void FontFace::loadWithCallback(RawPtr<LoadFontCallback> callback, ExecutionCont
ext* context) | 381 void FontFace::loadWithCallback(LoadFontCallback* callback, ExecutionContext* co
ntext) |
| 382 { | 382 { |
| 383 loadInternal(context); | 383 loadInternal(context); |
| 384 if (m_status == Loaded) | 384 if (m_status == Loaded) |
| 385 callback->notifyLoaded(this); | 385 callback->notifyLoaded(this); |
| 386 else if (m_status == Error) | 386 else if (m_status == Error) |
| 387 callback->notifyError(this); | 387 callback->notifyError(this); |
| 388 else | 388 else |
| 389 m_callbacks.append(callback); | 389 m_callbacks.append(callback); |
| 390 } | 390 } |
| 391 | 391 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 case CSSValueLighter: | 495 case CSSValueLighter: |
| 496 case CSSValueBolder: | 496 case CSSValueBolder: |
| 497 break; | 497 break; |
| 498 default: | 498 default: |
| 499 ASSERT_NOT_REACHED(); | 499 ASSERT_NOT_REACHED(); |
| 500 break; | 500 break; |
| 501 } | 501 } |
| 502 } | 502 } |
| 503 | 503 |
| 504 FontVariant variant = FontVariantNormal; | 504 FontVariant variant = FontVariantNormal; |
| 505 if (RawPtr<CSSValue> fontVariant = m_variant) { | 505 if (CSSValue* fontVariant = m_variant) { |
| 506 // font-variant descriptor can be a value list. | 506 // font-variant descriptor can be a value list. |
| 507 if (fontVariant->isPrimitiveValue()) { | 507 if (fontVariant->isPrimitiveValue()) { |
| 508 RawPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); | 508 CSSValueList* list = CSSValueList::createCommaSeparated(); |
| 509 list->append(fontVariant); | 509 list->append(fontVariant); |
| 510 fontVariant = list; | 510 fontVariant = list; |
| 511 } else if (!fontVariant->isValueList()) { | 511 } else if (!fontVariant->isValueList()) { |
| 512 return 0; | 512 return 0; |
| 513 } | 513 } |
| 514 | 514 |
| 515 CSSValueList* variantList = toCSSValueList(fontVariant.get()); | 515 CSSValueList* variantList = toCSSValueList(fontVariant); |
| 516 unsigned numVariants = variantList->length(); | 516 unsigned numVariants = variantList->length(); |
| 517 if (!numVariants) | 517 if (!numVariants) |
| 518 return 0; | 518 return 0; |
| 519 | 519 |
| 520 for (unsigned i = 0; i < numVariants; ++i) { | 520 for (unsigned i = 0; i < numVariants; ++i) { |
| 521 switch (toCSSPrimitiveValue(variantList->item(i))->getValueID()) { | 521 switch (toCSSPrimitiveValue(variantList->item(i))->getValueID()) { |
| 522 case CSSValueNormal: | 522 case CSSValueNormal: |
| 523 variant = FontVariantNormal; | 523 variant = FontVariantNormal; |
| 524 break; | 524 break; |
| 525 case CSSValueSmallCaps: | 525 case CSSValueSmallCaps: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 548 return FontDisplayFallback; | 548 return FontDisplayFallback; |
| 549 case CSSValueOptional: | 549 case CSSValueOptional: |
| 550 return FontDisplayOptional; | 550 return FontDisplayOptional; |
| 551 default: | 551 default: |
| 552 break; | 552 break; |
| 553 } | 553 } |
| 554 } | 554 } |
| 555 return FontDisplayAuto; | 555 return FontDisplayAuto; |
| 556 } | 556 } |
| 557 | 557 |
| 558 static RawPtr<CSSFontFace> createCSSFontFace(FontFace* fontFace, CSSValue* unico
deRange) | 558 static CSSFontFace* createCSSFontFace(FontFace* fontFace, CSSValue* unicodeRange
) |
| 559 { | 559 { |
| 560 Vector<UnicodeRange> ranges; | 560 Vector<UnicodeRange> ranges; |
| 561 if (CSSValueList* rangeList = toCSSValueList(unicodeRange)) { | 561 if (CSSValueList* rangeList = toCSSValueList(unicodeRange)) { |
| 562 unsigned numRanges = rangeList->length(); | 562 unsigned numRanges = rangeList->length(); |
| 563 for (unsigned i = 0; i < numRanges; i++) { | 563 for (unsigned i = 0; i < numRanges; i++) { |
| 564 CSSUnicodeRangeValue* range = toCSSUnicodeRangeValue(rangeList->item
(i)); | 564 CSSUnicodeRangeValue* range = toCSSUnicodeRangeValue(rangeList->item
(i)); |
| 565 ranges.append(UnicodeRange(range->from(), range->to())); | 565 ranges.append(UnicodeRange(range->from(), range->to())); |
| 566 } | 566 } |
| 567 } | 567 } |
| 568 | 568 |
| 569 return new CSSFontFace(fontFace, ranges); | 569 return new CSSFontFace(fontFace, ranges); |
| 570 } | 570 } |
| 571 | 571 |
| 572 void FontFace::initCSSFontFace(Document* document, RawPtr<CSSValue> src) | 572 void FontFace::initCSSFontFace(Document* document, CSSValue* src) |
| 573 { | 573 { |
| 574 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); | 574 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); |
| 575 if (m_error) | 575 if (m_error) |
| 576 return; | 576 return; |
| 577 | 577 |
| 578 // Each item in the src property's list is a single CSSFontFaceSource. Put t
hem all into a CSSFontFace. | 578 // Each item in the src property's list is a single CSSFontFaceSource. Put t
hem all into a CSSFontFace. |
| 579 ASSERT(src); | 579 ASSERT(src); |
| 580 ASSERT(src->isValueList()); | 580 ASSERT(src->isValueList()); |
| 581 CSSValueList* srcList = toCSSValueList(src.get()); | 581 CSSValueList* srcList = toCSSValueList(src); |
| 582 int srcLength = srcList->length(); | 582 int srcLength = srcList->length(); |
| 583 | 583 |
| 584 for (int i = 0; i < srcLength; i++) { | 584 for (int i = 0; i < srcLength; i++) { |
| 585 // An item in the list either specifies a string (local font name) or a
URL (remote font to download). | 585 // An item in the list either specifies a string (local font name) or a
URL (remote font to download). |
| 586 CSSFontFaceSrcValue* item = toCSSFontFaceSrcValue(srcList->item(i)); | 586 CSSFontFaceSrcValue* item = toCSSFontFaceSrcValue(srcList->item(i)); |
| 587 RawPtr<CSSFontFaceSource> source = nullptr; | 587 CSSFontFaceSource* source = nullptr; |
| 588 | 588 |
| 589 if (!item->isLocal()) { | 589 if (!item->isLocal()) { |
| 590 const Settings* settings = document ? document->settings() : nullptr
; | 590 const Settings* settings = document ? document->settings() : nullptr
; |
| 591 bool allowDownloading = settings && settings->downloadableBinaryFont
sEnabled(); | 591 bool allowDownloading = settings && settings->downloadableBinaryFont
sEnabled(); |
| 592 if (allowDownloading && item->isSupportedFormat() && document) { | 592 if (allowDownloading && item->isSupportedFormat() && document) { |
| 593 RawPtr<FontResource> fetched = item->fetch(document); | 593 FontResource* fetched = item->fetch(document); |
| 594 if (fetched) { | 594 if (fetched) { |
| 595 FontLoader* fontLoader = document->styleEngine().fontSelecto
r()->fontLoader(); | 595 FontLoader* fontLoader = document->styleEngine().fontSelecto
r()->fontLoader(); |
| 596 source = new RemoteFontFaceSource(fetched.release(), fontLoa
der, CSSValueToFontDisplay(m_display.get())); | 596 source = new RemoteFontFaceSource(fetched, fontLoader, CSSVa
lueToFontDisplay(m_display.get())); |
| 597 } | 597 } |
| 598 } | 598 } |
| 599 } else { | 599 } else { |
| 600 source = new LocalFontFaceSource(item->resource()); | 600 source = new LocalFontFaceSource(item->resource()); |
| 601 } | 601 } |
| 602 | 602 |
| 603 if (source) | 603 if (source) |
| 604 m_cssFontFace->addSource(source.release()); | 604 m_cssFontFace->addSource(source); |
| 605 } | 605 } |
| 606 | 606 |
| 607 if (m_display) { | 607 if (m_display) { |
| 608 DEFINE_STATIC_LOCAL(EnumerationHistogram, fontDisplayHistogram, ("WebFon
t.FontDisplayValue", FontDisplayEnumMax)); | 608 DEFINE_STATIC_LOCAL(EnumerationHistogram, fontDisplayHistogram, ("WebFon
t.FontDisplayValue", FontDisplayEnumMax)); |
| 609 fontDisplayHistogram.count(CSSValueToFontDisplay(m_display.get())); | 609 fontDisplayHistogram.count(CSSValueToFontDisplay(m_display.get())); |
| 610 } | 610 } |
| 611 } | 611 } |
| 612 | 612 |
| 613 void FontFace::initCSSFontFace(const unsigned char* data, size_t size) | 613 void FontFace::initCSSFontFace(const unsigned char* data, size_t size) |
| 614 { | 614 { |
| 615 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); | 615 m_cssFontFace = createCSSFontFace(this, m_unicodeRange.get()); |
| 616 if (m_error) | 616 if (m_error) |
| 617 return; | 617 return; |
| 618 | 618 |
| 619 RefPtr<SharedBuffer> buffer = SharedBuffer::create(data, size); | 619 RefPtr<SharedBuffer> buffer = SharedBuffer::create(data, size); |
| 620 RawPtr<BinaryDataFontFaceSource> source = new BinaryDataFontFaceSource(buffe
r.get(), m_otsParseMessage); | 620 BinaryDataFontFaceSource* source = new BinaryDataFontFaceSource(buffer.get()
, m_otsParseMessage); |
| 621 if (source->isValid()) | 621 if (source->isValid()) |
| 622 setLoadStatus(Loaded); | 622 setLoadStatus(Loaded); |
| 623 else | 623 else |
| 624 setError(DOMException::create(SyntaxError, "Invalid font data in ArrayBu
ffer.")); | 624 setError(DOMException::create(SyntaxError, "Invalid font data in ArrayBu
ffer.")); |
| 625 m_cssFontFace->addSource(source.release()); | 625 m_cssFontFace->addSource(source); |
| 626 } | 626 } |
| 627 | 627 |
| 628 DEFINE_TRACE(FontFace) | 628 DEFINE_TRACE(FontFace) |
| 629 { | 629 { |
| 630 visitor->trace(m_style); | 630 visitor->trace(m_style); |
| 631 visitor->trace(m_weight); | 631 visitor->trace(m_weight); |
| 632 visitor->trace(m_stretch); | 632 visitor->trace(m_stretch); |
| 633 visitor->trace(m_unicodeRange); | 633 visitor->trace(m_unicodeRange); |
| 634 visitor->trace(m_variant); | 634 visitor->trace(m_variant); |
| 635 visitor->trace(m_featureSettings); | 635 visitor->trace(m_featureSettings); |
| 636 visitor->trace(m_display); | 636 visitor->trace(m_display); |
| 637 visitor->trace(m_error); | 637 visitor->trace(m_error); |
| 638 visitor->trace(m_loadedProperty); | 638 visitor->trace(m_loadedProperty); |
| 639 visitor->trace(m_cssFontFace); | 639 visitor->trace(m_cssFontFace); |
| 640 visitor->trace(m_callbacks); | 640 visitor->trace(m_callbacks); |
| 641 ActiveDOMObject::trace(visitor); | 641 ActiveDOMObject::trace(visitor); |
| 642 } | 642 } |
| 643 | 643 |
| 644 bool FontFace::hadBlankText() const | 644 bool FontFace::hadBlankText() const |
| 645 { | 645 { |
| 646 return m_cssFontFace->hadBlankText(); | 646 return m_cssFontFace->hadBlankText(); |
| 647 } | 647 } |
| 648 | 648 |
| 649 bool FontFace::hasPendingActivity() const | 649 bool FontFace::hasPendingActivity() const |
| 650 { | 650 { |
| 651 return m_status == Loading && getExecutionContext() && !getExecutionContext(
)->activeDOMObjectsAreStopped(); | 651 return m_status == Loading && getExecutionContext() && !getExecutionContext(
)->activeDOMObjectsAreStopped(); |
| 652 } | 652 } |
| 653 | 653 |
| 654 } // namespace blink | 654 } // namespace blink |
| OLD | NEW |