| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->baseAddr
ess()), source->byteLength()); | 105 fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->baseAddr
ess()), source->byteLength()); |
| 106 return fontFace.release(); | 106 return fontFace.release(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(Document* document, const Styl
eRuleFontFace* fontFaceRule) | 109 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(Document* document, const Styl
eRuleFontFace* fontFaceRule) |
| 110 { | 110 { |
| 111 const StylePropertySet& properties = fontFaceRule->properties(); | 111 const StylePropertySet& properties = fontFaceRule->properties(); |
| 112 | 112 |
| 113 // Obtain the font-family property and the src property. Both must be define
d. | 113 // Obtain the font-family property and the src property. Both must be define
d. |
| 114 RefPtrWillBeRawPtr<CSSValue> family = properties.getPropertyCSSValue(CSSProp
ertyFontFamily); | 114 RefPtrWillBeRawPtr<CSSValue> family = properties.getPropertyCSSValue(CSSProp
ertyFontFamily); |
| 115 if (!family || !family->isValueList()) | 115 if (!family || !family->isPrimitiveValue()) |
| 116 return nullptr; | 116 return nullptr; |
| 117 RefPtrWillBeRawPtr<CSSValue> src = properties.getPropertyCSSValue(CSSPropert
ySrc); | 117 RefPtrWillBeRawPtr<CSSValue> src = properties.getPropertyCSSValue(CSSPropert
ySrc); |
| 118 if (!src || !src->isValueList()) | 118 if (!src || !src->isValueList()) |
| 119 return nullptr; | 119 return nullptr; |
| 120 | 120 |
| 121 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(docu
ment)); | 121 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(docu
ment)); |
| 122 | 122 |
| 123 if (fontFace->setFamilyValue(toCSSValueList(family.get())) | 123 if (fontFace->setFamilyValue(toCSSPrimitiveValue(family.get())) |
| 124 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStyle) | 124 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStyle) |
| 125 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontWeight) | 125 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontWeight) |
| 126 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStretch) | 126 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStretch) |
| 127 && fontFace->setPropertyFromStyle(properties, CSSPropertyUnicodeRange) | 127 && fontFace->setPropertyFromStyle(properties, CSSPropertyUnicodeRange) |
| 128 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontVariant) | 128 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontVariant) |
| 129 && fontFace->setPropertyFromStyle(properties, CSSPropertyWebkitFontFeatu
reSettings) | 129 && fontFace->setPropertyFromStyle(properties, CSSPropertyWebkitFontFeatu
reSettings) |
| 130 && !fontFace->family().isEmpty() | 130 && !fontFace->family().isEmpty() |
| 131 && fontFace->traits().bitfield()) { | 131 && fontFace->traits().bitfield()) { |
| 132 fontFace->initCSSFontFace(document, src); | 132 fontFace->initCSSFontFace(document, src); |
| 133 return fontFace.release(); | 133 return fontFace.release(); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 case CSSPropertyWebkitFontFeatureSettings: | 263 case CSSPropertyWebkitFontFeatureSettings: |
| 264 m_featureSettings = value; | 264 m_featureSettings = value; |
| 265 break; | 265 break; |
| 266 default: | 266 default: |
| 267 ASSERT_NOT_REACHED(); | 267 ASSERT_NOT_REACHED(); |
| 268 return false; | 268 return false; |
| 269 } | 269 } |
| 270 return true; | 270 return true; |
| 271 } | 271 } |
| 272 | 272 |
| 273 bool FontFace::setFamilyValue(CSSValueList* familyList) | 273 bool FontFace::setFamilyValue(CSSPrimitiveValue* familyValue) |
| 274 { | 274 { |
| 275 // The font-family descriptor has to have exactly one family name. | |
| 276 if (familyList->length() != 1) | |
| 277 return false; | |
| 278 | |
| 279 CSSPrimitiveValue* familyValue = toCSSPrimitiveValue(familyList->item(0)); | |
| 280 AtomicString family; | 275 AtomicString family; |
| 281 if (familyValue->isCustomIdent()) { | 276 if (familyValue->isCustomIdent()) { |
| 282 family = AtomicString(familyValue->getStringValue()); | 277 family = AtomicString(familyValue->getStringValue()); |
| 283 } else if (familyValue->isValueID()) { | 278 } 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 | 279 // 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. | 280 // defining what font to use for those types. |
| 286 switch (familyValue->getValueID()) { | 281 switch (familyValue->getValueID()) { |
| 287 case CSSValueSerif: | 282 case CSSValueSerif: |
| 288 family = FontFamilyNames::webkit_serif; | 283 family = FontFamilyNames::webkit_serif; |
| 289 break; | 284 break; |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 { | 612 { |
| 618 return m_cssFontFace->hadBlankText(); | 613 return m_cssFontFace->hadBlankText(); |
| 619 } | 614 } |
| 620 | 615 |
| 621 bool FontFace::hasPendingActivity() const | 616 bool FontFace::hasPendingActivity() const |
| 622 { | 617 { |
| 623 return m_status == Loading && executionContext() && !executionContext()->act
iveDOMObjectsAreStopped(); | 618 return m_status == Loading && executionContext() && !executionContext()->act
iveDOMObjectsAreStopped(); |
| 624 } | 619 } |
| 625 | 620 |
| 626 } // namespace blink | 621 } // namespace blink |
| OLD | NEW |