| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/css/FontFace.h" | 32 #include "core/css/FontFace.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/ExceptionState.h" | 34 #include "bindings/core/v8/ExceptionState.h" |
| 35 #include "bindings/core/v8/ScriptState.h" | 35 #include "bindings/core/v8/ScriptState.h" |
| 36 #include "bindings/core/v8/UnionTypesCore.h" | 36 #include "bindings/core/v8/UnionTypesCore.h" |
| 37 #include "core/CSSValueKeywords.h" | 37 #include "core/CSSValueKeywords.h" |
| 38 #include "core/css/BinaryDataFontFaceSource.h" | 38 #include "core/css/BinaryDataFontFaceSource.h" |
| 39 #include "core/css/CSSCustomIdentValue.h" |
| 39 #include "core/css/CSSFontFace.h" | 40 #include "core/css/CSSFontFace.h" |
| 40 #include "core/css/CSSFontFaceSrcValue.h" | 41 #include "core/css/CSSFontFaceSrcValue.h" |
| 41 #include "core/css/CSSFontSelector.h" | 42 #include "core/css/CSSFontSelector.h" |
| 42 #include "core/css/CSSPrimitiveValue.h" | 43 #include "core/css/CSSPrimitiveValue.h" |
| 43 #include "core/css/CSSUnicodeRangeValue.h" | 44 #include "core/css/CSSUnicodeRangeValue.h" |
| 44 #include "core/css/CSSValueList.h" | 45 #include "core/css/CSSValueList.h" |
| 45 #include "core/css/FontFaceDescriptors.h" | 46 #include "core/css/FontFaceDescriptors.h" |
| 46 #include "core/css/LocalFontFaceSource.h" | 47 #include "core/css/LocalFontFaceSource.h" |
| 47 #include "core/css/RemoteFontFaceSource.h" | 48 #include "core/css/RemoteFontFaceSource.h" |
| 48 #include "core/css/StylePropertySet.h" | 49 #include "core/css/StylePropertySet.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 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()); |
| 106 return fontFace.release(); | 107 return fontFace.release(); |
| 107 } | 108 } |
| 108 | 109 |
| 109 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(Document* document, const Styl
eRuleFontFace* fontFaceRule) | 110 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(Document* document, const Styl
eRuleFontFace* fontFaceRule) |
| 110 { | 111 { |
| 111 const StylePropertySet& properties = fontFaceRule->properties(); | 112 const StylePropertySet& properties = fontFaceRule->properties(); |
| 112 | 113 |
| 113 // 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. |
| 114 RefPtrWillBeRawPtr<CSSValue> family = properties.getPropertyCSSValue(CSSProp
ertyFontFamily); | 115 RefPtrWillBeRawPtr<CSSValue> family = properties.getPropertyCSSValue(CSSProp
ertyFontFamily); |
| 115 if (!family || !family->isPrimitiveValue()) | 116 if (!family || (!family->isCustomIdentValue() && !family->isPrimitiveValue()
)) |
| 116 return nullptr; | 117 return nullptr; |
| 117 RefPtrWillBeRawPtr<CSSValue> src = properties.getPropertyCSSValue(CSSPropert
ySrc); | 118 RefPtrWillBeRawPtr<CSSValue> src = properties.getPropertyCSSValue(CSSPropert
ySrc); |
| 118 if (!src || !src->isValueList()) | 119 if (!src || !src->isValueList()) |
| 119 return nullptr; | 120 return nullptr; |
| 120 | 121 |
| 121 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(docu
ment)); | 122 RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(docu
ment)); |
| 122 | 123 |
| 123 if (fontFace->setFamilyValue(toCSSPrimitiveValue(family.get())) | 124 if (fontFace->setFamilyValue(*family) |
| 124 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStyle) | 125 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStyle) |
| 125 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontWeight) | 126 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontWeight) |
| 126 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStretch) | 127 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontStretch) |
| 127 && fontFace->setPropertyFromStyle(properties, CSSPropertyUnicodeRange) | 128 && fontFace->setPropertyFromStyle(properties, CSSPropertyUnicodeRange) |
| 128 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontVariant) | 129 && fontFace->setPropertyFromStyle(properties, CSSPropertyFontVariant) |
| 129 && fontFace->setPropertyFromStyle(properties, CSSPropertyWebkitFontFeatu
reSettings) | 130 && fontFace->setPropertyFromStyle(properties, CSSPropertyWebkitFontFeatu
reSettings) |
| 130 && !fontFace->family().isEmpty() | 131 && !fontFace->family().isEmpty() |
| 131 && fontFace->traits().bitfield()) { | 132 && fontFace->traits().bitfield()) { |
| 132 fontFace->initCSSFontFace(document, src); | 133 fontFace->initCSSFontFace(document, src); |
| 133 return fontFace.release(); | 134 return fontFace.release(); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 case CSSPropertyWebkitFontFeatureSettings: | 264 case CSSPropertyWebkitFontFeatureSettings: |
| 264 m_featureSettings = value; | 265 m_featureSettings = value; |
| 265 break; | 266 break; |
| 266 default: | 267 default: |
| 267 ASSERT_NOT_REACHED(); | 268 ASSERT_NOT_REACHED(); |
| 268 return false; | 269 return false; |
| 269 } | 270 } |
| 270 return true; | 271 return true; |
| 271 } | 272 } |
| 272 | 273 |
| 273 bool FontFace::setFamilyValue(CSSPrimitiveValue* familyValue) | 274 bool FontFace::setFamilyValue(const CSSValue& familyValue) |
| 274 { | 275 { |
| 275 AtomicString family; | 276 AtomicString family; |
| 276 if (familyValue->isCustomIdent()) { | 277 if (familyValue.isCustomIdentValue()) { |
| 277 family = AtomicString(familyValue->getStringValue()); | 278 family = AtomicString(toCSSCustomIdentValue(familyValue).value()); |
| 278 } else if (familyValue->isValueID()) { | 279 } else if (toCSSPrimitiveValue(familyValue).isValueID()) { |
| 279 // We need to use the raw text for all the generic family types, since @
font-face is a way of actually | 280 // We need to use the raw text for all the generic family types, since @
font-face is a way of actually |
| 280 // defining what font to use for those types. | 281 // defining what font to use for those types. |
| 281 switch (familyValue->getValueID()) { | 282 switch (toCSSPrimitiveValue(familyValue).getValueID()) { |
| 282 case CSSValueSerif: | 283 case CSSValueSerif: |
| 283 family = FontFamilyNames::webkit_serif; | 284 family = FontFamilyNames::webkit_serif; |
| 284 break; | 285 break; |
| 285 case CSSValueSansSerif: | 286 case CSSValueSansSerif: |
| 286 family = FontFamilyNames::webkit_sans_serif; | 287 family = FontFamilyNames::webkit_sans_serif; |
| 287 break; | 288 break; |
| 288 case CSSValueCursive: | 289 case CSSValueCursive: |
| 289 family = FontFamilyNames::webkit_cursive; | 290 family = FontFamilyNames::webkit_cursive; |
| 290 break; | 291 break; |
| 291 case CSSValueFantasy: | 292 case CSSValueFantasy: |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 { | 613 { |
| 613 return m_cssFontFace->hadBlankText(); | 614 return m_cssFontFace->hadBlankText(); |
| 614 } | 615 } |
| 615 | 616 |
| 616 bool FontFace::hasPendingActivity() const | 617 bool FontFace::hasPendingActivity() const |
| 617 { | 618 { |
| 618 return m_status == Loading && executionContext() && !executionContext()->act
iveDOMObjectsAreStopped(); | 619 return m_status == Loading && executionContext() && !executionContext()->act
iveDOMObjectsAreStopped(); |
| 619 } | 620 } |
| 620 | 621 |
| 621 } // namespace blink | 622 } // namespace blink |
| OLD | NEW |