| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 if (exceptionState.hadException()) | 143 if (exceptionState.hadException()) |
| 144 return nullptr; | 144 return nullptr; |
| 145 } | 145 } |
| 146 | 146 |
| 147 fontFace->initCSSFontFace(toDocument(context)); | 147 fontFace->initCSSFontFace(toDocument(context)); |
| 148 return fontFace; | 148 return fontFace; |
| 149 } | 149 } |
| 150 | 150 |
| 151 PassRefPtr<FontFace> FontFace::create(Document* document, const StyleRuleFontFac
e* fontFaceRule) | 151 PassRefPtr<FontFace> FontFace::create(Document* document, const StyleRuleFontFac
e* fontFaceRule) |
| 152 { | 152 { |
| 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(CSSPro
pertyFontFamily); | 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(CSSProper
tySrc); | 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 = adoptRef<FontFace>(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) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 setPropertyFromString(toDocument(context), s, CSSPropertyWebkitFontFeatureSe
ttings, exceptionState); | 247 setPropertyFromString(toDocument(context), s, CSSPropertyWebkitFontFeatureSe
ttings, exceptionState); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void FontFace::setPropertyFromString(const Document* document, const String& s,
CSSPropertyID propertyID, ExceptionState& exceptionState) | 250 void FontFace::setPropertyFromString(const Document* document, const String& s,
CSSPropertyID propertyID, ExceptionState& exceptionState) |
| 251 { | 251 { |
| 252 RefPtrWillBeRawPtr<CSSValue> value = parseCSSValue(document, s, propertyID); | 252 RefPtrWillBeRawPtr<CSSValue> value = parseCSSValue(document, s, propertyID); |
| 253 if (!value || !setPropertyValue(value, propertyID)) | 253 if (!value || !setPropertyValue(value, propertyID)) |
| 254 exceptionState.throwDOMException(SyntaxError, "Failed to set '" + s + "'
as a property value."); | 254 exceptionState.throwDOMException(SyntaxError, "Failed to set '" + s + "'
as a property value."); |
| 255 } | 255 } |
| 256 | 256 |
| 257 bool FontFace::setPropertyFromStyle(const StylePropertySet* properties, CSSPrope
rtyID propertyID) | 257 bool FontFace::setPropertyFromStyle(const StylePropertySet& properties, CSSPrope
rtyID propertyID) |
| 258 { | 258 { |
| 259 return setPropertyValue(properties->getPropertyCSSValue(propertyID), propert
yID); | 259 return setPropertyValue(properties.getPropertyCSSValue(propertyID), property
ID); |
| 260 } | 260 } |
| 261 | 261 |
| 262 bool FontFace::setPropertyValue(PassRefPtrWillBeRawPtr<CSSValue> value, CSSPrope
rtyID propertyID) | 262 bool FontFace::setPropertyValue(PassRefPtrWillBeRawPtr<CSSValue> value, CSSPrope
rtyID propertyID) |
| 263 { | 263 { |
| 264 switch (propertyID) { | 264 switch (propertyID) { |
| 265 case CSSPropertyFontStyle: | 265 case CSSPropertyFontStyle: |
| 266 m_style = value; | 266 m_style = value; |
| 267 break; | 267 break; |
| 268 case CSSPropertyFontWeight: | 268 case CSSPropertyFontWeight: |
| 269 m_weight = value; | 269 m_weight = value; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } // namespace WebCore | 542 } // namespace WebCore |
| OLD | NEW |