| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 100 } |
| 101 | 101 |
| 102 PassRefPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicStr
ing& family, const String& source, const Dictionary& descriptors, ExceptionState
& exceptionState) | 102 PassRefPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicStr
ing& family, const String& source, const Dictionary& descriptors, ExceptionState
& exceptionState) |
| 103 { | 103 { |
| 104 RefPtrWillBeRawPtr<CSSValue> src = parseCSSValue(toDocument(context), source
, CSSPropertySrc); | 104 RefPtrWillBeRawPtr<CSSValue> src = parseCSSValue(toDocument(context), source
, CSSPropertySrc); |
| 105 if (!src || !src->isValueList()) { | 105 if (!src || !src->isValueList()) { |
| 106 exceptionState.throwDOMException(SyntaxError, "The source provided ('" +
source + "') could not be parsed as a value list."); | 106 exceptionState.throwDOMException(SyntaxError, "The source provided ('" +
source + "') could not be parsed as a value list."); |
| 107 return nullptr; | 107 return nullptr; |
| 108 } | 108 } |
| 109 | 109 |
| 110 RefPtr<FontFace> fontFace = adoptRef<FontFace>(new FontFace(src)); | 110 RefPtr<FontFace> fontFace = adoptRefWillBeRefCountedGarbageCollected<FontFac
e>(new FontFace(src)); |
| 111 fontFace->setFamily(context, family, exceptionState); | 111 fontFace->setFamily(context, family, exceptionState); |
| 112 if (exceptionState.hadException()) | 112 if (exceptionState.hadException()) |
| 113 return nullptr; | 113 return nullptr; |
| 114 | 114 |
| 115 String value; | 115 String value; |
| 116 if (descriptors.get("style", value)) { | 116 if (descriptors.get("style", value)) { |
| 117 fontFace->setStyle(context, value, exceptionState); | 117 fontFace->setStyle(context, value, exceptionState); |
| 118 if (exceptionState.hadException()) | 118 if (exceptionState.hadException()) |
| 119 return nullptr; | 119 return nullptr; |
| 120 } | 120 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 const StylePropertySet& properties = fontFaceRule->properties(); | 153 const StylePropertySet& properties = fontFaceRule->properties(); |
| 154 | 154 |
| 155 // Obtain the font-family property and the src property. Both must be define
d. | 155 // Obtain the font-family property and the src property. Both must be define
d. |
| 156 RefPtrWillBeRawPtr<CSSValue> family = properties.getPropertyCSSValue(CSSProp
ertyFontFamily); | 156 RefPtrWillBeRawPtr<CSSValue> family = properties.getPropertyCSSValue(CSSProp
ertyFontFamily); |
| 157 if (!family || !family->isValueList()) | 157 if (!family || !family->isValueList()) |
| 158 return nullptr; | 158 return nullptr; |
| 159 RefPtrWillBeRawPtr<CSSValue> src = properties.getPropertyCSSValue(CSSPropert
ySrc); | 159 RefPtrWillBeRawPtr<CSSValue> src = properties.getPropertyCSSValue(CSSPropert
ySrc); |
| 160 if (!src || !src->isValueList()) | 160 if (!src || !src->isValueList()) |
| 161 return nullptr; | 161 return nullptr; |
| 162 | 162 |
| 163 RefPtr<FontFace> fontFace = adoptRef<FontFace>(new FontFace(src)); | 163 RefPtr<FontFace> fontFace = adoptRefWillBeRefCountedGarbageCollected<FontFac
e>(new FontFace(src)); |
| 164 | 164 |
| 165 if (fontFace->setFamilyValue(toCSSValueList(family.get())) | 165 if (fontFace->setFamilyValue(toCSSValueList(family.get())) |
| 166 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStyle) | 166 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStyle) |
| 167 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontWeight) | 167 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontWeight) |
| 168 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStretch) | 168 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStretch) |
| 169 && fontFace->setPropertyFromStyle(properties, CSSPropertyUnicodeRange) | 169 && fontFace->setPropertyFromStyle(properties, CSSPropertyUnicodeRange) |
| 170 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontVariant) | 170 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontVariant) |
| 171 && fontFace->setPropertyFromStyle(properties, CSSPropertyWebkitFontFeatu
reSettings) | 171 && fontFace->setPropertyFromStyle(properties, CSSPropertyWebkitFontFeatu
reSettings) |
| 172 && !fontFace->family().isEmpty() | 172 && !fontFace->family().isEmpty() |
| 173 && fontFace->traitsMask()) { | 173 && fontFace->traitsMask()) { |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 traitsMask |= FontWeight100Mask; | 446 traitsMask |= FontWeight100Mask; |
| 447 break; | 447 break; |
| 448 default: | 448 default: |
| 449 ASSERT_NOT_REACHED(); | 449 ASSERT_NOT_REACHED(); |
| 450 break; | 450 break; |
| 451 } | 451 } |
| 452 } else { | 452 } else { |
| 453 traitsMask |= FontWeight400Mask; | 453 traitsMask |= FontWeight400Mask; |
| 454 } | 454 } |
| 455 | 455 |
| 456 if (RefPtr<CSSValue> fontVariant = m_variant) { | 456 if (RefPtrWillBeRawPtr<CSSValue> fontVariant = m_variant) { |
| 457 // font-variant descriptor can be a value list. | 457 // font-variant descriptor can be a value list. |
| 458 if (fontVariant->isPrimitiveValue()) { | 458 if (fontVariant->isPrimitiveValue()) { |
| 459 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSep
arated(); | 459 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSep
arated(); |
| 460 list->append(fontVariant); | 460 list->append(fontVariant); |
| 461 fontVariant = list; | 461 fontVariant = list; |
| 462 } else if (!fontVariant->isValueList()) { | 462 } else if (!fontVariant->isValueList()) { |
| 463 return 0; | 463 return 0; |
| 464 } | 464 } |
| 465 | 465 |
| 466 CSSValueList* variantList = toCSSValueList(fontVariant.get()); | 466 CSSValueList* variantList = toCSSValueList(fontVariant.get()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 | 532 |
| 533 if (source) { | 533 if (source) { |
| 534 #if ENABLE(SVG_FONTS) | 534 #if ENABLE(SVG_FONTS) |
| 535 source->setSVGFontFaceElement(item->svgFontFaceElement()); | 535 source->setSVGFontFaceElement(item->svgFontFaceElement()); |
| 536 #endif | 536 #endif |
| 537 m_cssFontFace->addSource(source.release()); | 537 m_cssFontFace->addSource(source.release()); |
| 538 } | 538 } |
| 539 } | 539 } |
| 540 } | 540 } |
| 541 | 541 |
| 542 void FontFace::trace(Visitor* visitor) |
| 543 { |
| 544 visitor->trace(m_src); |
| 545 visitor->trace(m_style); |
| 546 visitor->trace(m_weight); |
| 547 visitor->trace(m_stretch); |
| 548 visitor->trace(m_unicodeRange); |
| 549 visitor->trace(m_variant); |
| 550 visitor->trace(m_featureSettings); |
| 551 } |
| 552 |
| 542 } // namespace WebCore | 553 } // namespace WebCore |
| OLD | NEW |