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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "core/dom/ExceptionCode.h" | 52 #include "core/dom/ExceptionCode.h" |
53 #include "core/dom/StyleEngine.h" | 53 #include "core/dom/StyleEngine.h" |
54 #include "core/frame/Frame.h" | 54 #include "core/frame/Frame.h" |
55 #include "core/frame/Settings.h" | 55 #include "core/frame/Settings.h" |
56 #include "core/svg/SVGFontFaceElement.h" | 56 #include "core/svg/SVGFontFaceElement.h" |
57 #include "platform/fonts/FontDescription.h" | 57 #include "platform/fonts/FontDescription.h" |
58 #include "platform/fonts/FontTraitsMask.h" | 58 #include "platform/fonts/FontTraitsMask.h" |
59 | 59 |
60 namespace WebCore { | 60 namespace WebCore { |
61 | 61 |
| 62 DEFINE_GC_INFO(FontFace); |
| 63 |
62 class FontFaceReadyPromiseResolver { | 64 class FontFaceReadyPromiseResolver { |
63 public: | 65 public: |
64 static PassOwnPtr<FontFaceReadyPromiseResolver> create(ScriptPromise promise
, ExecutionContext* context) | 66 static PassOwnPtr<FontFaceReadyPromiseResolver> create(ScriptPromise promise
, ExecutionContext* context) |
65 { | 67 { |
66 return adoptPtr(new FontFaceReadyPromiseResolver(promise, context)); | 68 return adoptPtr(new FontFaceReadyPromiseResolver(promise, context)); |
67 } | 69 } |
68 | 70 |
69 void resolve(PassRefPtr<FontFace> fontFace) | 71 void resolve(PassRefPtr<FontFace> fontFace) |
70 { | 72 { |
71 ScriptScope scope(m_scriptState); | 73 ScriptScope scope(m_scriptState); |
(...skipping 28 matching lines...) Expand all Loading... |
100 } | 102 } |
101 | 103 |
102 PassRefPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicStr
ing& family, const String& source, const Dictionary& descriptors, ExceptionState
& exceptionState) | 104 PassRefPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicStr
ing& family, const String& source, const Dictionary& descriptors, ExceptionState
& exceptionState) |
103 { | 105 { |
104 RefPtrWillBeRawPtr<CSSValue> src = parseCSSValue(toDocument(context), source
, CSSPropertySrc); | 106 RefPtrWillBeRawPtr<CSSValue> src = parseCSSValue(toDocument(context), source
, CSSPropertySrc); |
105 if (!src || !src->isValueList()) { | 107 if (!src || !src->isValueList()) { |
106 exceptionState.throwDOMException(SyntaxError, "The source provided ('" +
source + "') could not be parsed as a value list."); | 108 exceptionState.throwDOMException(SyntaxError, "The source provided ('" +
source + "') could not be parsed as a value list."); |
107 return 0; | 109 return 0; |
108 } | 110 } |
109 | 111 |
110 RefPtr<FontFace> fontFace = adoptRef<FontFace>(new FontFace(src)); | 112 RefPtr<FontFace> fontFace = adoptRefCountedWillBeRefCountedGarbageCollected<
FontFace>(new FontFace(src)); |
111 fontFace->setFamily(context, family, exceptionState); | 113 fontFace->setFamily(context, family, exceptionState); |
112 if (exceptionState.hadException()) | 114 if (exceptionState.hadException()) |
113 return 0; | 115 return 0; |
114 | 116 |
115 String value; | 117 String value; |
116 if (descriptors.get("style", value)) { | 118 if (descriptors.get("style", value)) { |
117 fontFace->setStyle(context, value, exceptionState); | 119 fontFace->setStyle(context, value, exceptionState); |
118 if (exceptionState.hadException()) | 120 if (exceptionState.hadException()) |
119 return 0; | 121 return 0; |
120 } | 122 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 const StylePropertySet* properties = fontFaceRule->properties(); | 155 const StylePropertySet* properties = fontFaceRule->properties(); |
154 | 156 |
155 // Obtain the font-family property and the src property. Both must be define
d. | 157 // Obtain the font-family property and the src property. Both must be define
d. |
156 RefPtrWillBeRawPtr<CSSValue> family = properties->getPropertyCSSValue(CSSPro
pertyFontFamily); | 158 RefPtrWillBeRawPtr<CSSValue> family = properties->getPropertyCSSValue(CSSPro
pertyFontFamily); |
157 if (!family || !family->isValueList()) | 159 if (!family || !family->isValueList()) |
158 return 0; | 160 return 0; |
159 RefPtrWillBeRawPtr<CSSValue> src = properties->getPropertyCSSValue(CSSProper
tySrc); | 161 RefPtrWillBeRawPtr<CSSValue> src = properties->getPropertyCSSValue(CSSProper
tySrc); |
160 if (!src || !src->isValueList()) | 162 if (!src || !src->isValueList()) |
161 return 0; | 163 return 0; |
162 | 164 |
163 RefPtr<FontFace> fontFace = adoptRef<FontFace>(new FontFace(src)); | 165 RefPtr<FontFace> fontFace = adoptRefCountedWillBeRefCountedGarbageCollected<
FontFace>(new FontFace(src)); |
164 | 166 |
165 if (fontFace->setFamilyValue(toCSSValueList(family.get())) | 167 if (fontFace->setFamilyValue(toCSSValueList(family.get())) |
166 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStyle) | 168 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStyle) |
167 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontWeight) | 169 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontWeight) |
168 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStretch) | 170 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStretch) |
169 && fontFace->setPropertyFromStyle(properties, CSSPropertyUnicodeRange) | 171 && fontFace->setPropertyFromStyle(properties, CSSPropertyUnicodeRange) |
170 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontVariant) | 172 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontVariant) |
171 && fontFace->setPropertyFromStyle(properties, CSSPropertyWebkitFontFeatu
reSettings) | 173 && fontFace->setPropertyFromStyle(properties, CSSPropertyWebkitFontFeatu
reSettings) |
172 && !fontFace->family().isEmpty() | 174 && !fontFace->family().isEmpty() |
173 && fontFace->traitsMask()) { | 175 && fontFace->traitsMask()) { |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 traitsMask |= FontWeight100Mask; | 448 traitsMask |= FontWeight100Mask; |
447 break; | 449 break; |
448 default: | 450 default: |
449 ASSERT_NOT_REACHED(); | 451 ASSERT_NOT_REACHED(); |
450 break; | 452 break; |
451 } | 453 } |
452 } else { | 454 } else { |
453 traitsMask |= FontWeight400Mask; | 455 traitsMask |= FontWeight400Mask; |
454 } | 456 } |
455 | 457 |
456 if (RefPtr<CSSValue> fontVariant = m_variant) { | 458 if (RefPtrWillBeRawPtr<CSSValue> fontVariant = m_variant) { |
457 // font-variant descriptor can be a value list. | 459 // font-variant descriptor can be a value list. |
458 if (fontVariant->isPrimitiveValue()) { | 460 if (fontVariant->isPrimitiveValue()) { |
459 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSep
arated(); | 461 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSep
arated(); |
460 list->append(fontVariant); | 462 list->append(fontVariant); |
461 fontVariant = list; | 463 fontVariant = list; |
462 } else if (!fontVariant->isValueList()) { | 464 } else if (!fontVariant->isValueList()) { |
463 return 0; | 465 return 0; |
464 } | 466 } |
465 | 467 |
466 CSSValueList* variantList = toCSSValueList(fontVariant.get()); | 468 CSSValueList* variantList = toCSSValueList(fontVariant.get()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 | 534 |
533 if (source) { | 535 if (source) { |
534 #if ENABLE(SVG_FONTS) | 536 #if ENABLE(SVG_FONTS) |
535 source->setSVGFontFaceElement(item->svgFontFaceElement()); | 537 source->setSVGFontFaceElement(item->svgFontFaceElement()); |
536 #endif | 538 #endif |
537 m_cssFontFace->addSource(source.release()); | 539 m_cssFontFace->addSource(source.release()); |
538 } | 540 } |
539 } | 541 } |
540 } | 542 } |
541 | 543 |
| 544 void FontFace::trace(Visitor* visitor) |
| 545 { |
| 546 visitor->trace(m_src); |
| 547 visitor->trace(m_style); |
| 548 visitor->trace(m_weight); |
| 549 visitor->trace(m_stretch); |
| 550 visitor->trace(m_unicodeRange); |
| 551 visitor->trace(m_variant); |
| 552 visitor->trace(m_featureSettings); |
| 553 } |
| 554 |
542 } // namespace WebCore | 555 } // namespace WebCore |
OLD | NEW |