| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 return 0; | 95 return 0; |
| 96 RefPtr<MutableStylePropertySet> parsedStyle = MutableStylePropertySet::creat
e(); | 96 RefPtr<MutableStylePropertySet> parsedStyle = MutableStylePropertySet::creat
e(); |
| 97 BisonCSSParser::parseValue(parsedStyle.get(), propertyID, s, true, HTMLStand
ardMode, 0); | 97 BisonCSSParser::parseValue(parsedStyle.get(), propertyID, s, true, HTMLStand
ardMode, 0); |
| 98 return parsedStyle->getPropertyCSSValue(propertyID); | 98 return parsedStyle->getPropertyCSSValue(propertyID); |
| 99 } | 99 } |
| 100 | 100 |
| 101 PassRefPtr<FontFace> FontFace::create(const AtomicString& family, const String&
source, const Dictionary& descriptors, ExceptionState& exceptionState) | 101 PassRefPtr<FontFace> FontFace::create(const AtomicString& family, const String&
source, const Dictionary& descriptors, ExceptionState& exceptionState) |
| 102 { | 102 { |
| 103 RefPtr<CSSValue> src = parseCSSValue(source, CSSPropertySrc); | 103 RefPtr<CSSValue> src = parseCSSValue(source, CSSPropertySrc); |
| 104 if (!src || !src->isValueList()) { | 104 if (!src || !src->isValueList()) { |
| 105 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); | 105 exceptionState.throwDOMException(SyntaxError, "The source provided ('" +
source + "') could not be parsed as a value list."); |
| 106 return 0; | 106 return 0; |
| 107 } | 107 } |
| 108 | 108 |
| 109 RefPtr<FontFace> fontFace = adoptRef<FontFace>(new FontFace(src)); | 109 RefPtr<FontFace> fontFace = adoptRef<FontFace>(new FontFace(src)); |
| 110 fontFace->setFamily(family, exceptionState); | 110 fontFace->setFamily(family, exceptionState); |
| 111 if (exceptionState.hadException()) | 111 if (exceptionState.hadException()) |
| 112 return 0; | 112 return 0; |
| 113 | 113 |
| 114 String value; | 114 String value; |
| 115 if (descriptors.get("style", value)) { | 115 if (descriptors.get("style", value)) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 239 |
| 240 void FontFace::setFeatureSettings(const String& s, ExceptionState& exceptionStat
e) | 240 void FontFace::setFeatureSettings(const String& s, ExceptionState& exceptionStat
e) |
| 241 { | 241 { |
| 242 setPropertyFromString(s, CSSPropertyWebkitFontFeatureSettings, exceptionStat
e); | 242 setPropertyFromString(s, CSSPropertyWebkitFontFeatureSettings, exceptionStat
e); |
| 243 } | 243 } |
| 244 | 244 |
| 245 void FontFace::setPropertyFromString(const String& s, CSSPropertyID propertyID,
ExceptionState& exceptionState) | 245 void FontFace::setPropertyFromString(const String& s, CSSPropertyID propertyID,
ExceptionState& exceptionState) |
| 246 { | 246 { |
| 247 RefPtr<CSSValue> value = parseCSSValue(s, propertyID); | 247 RefPtr<CSSValue> value = parseCSSValue(s, propertyID); |
| 248 if (!value || !setPropertyValue(value, propertyID)) | 248 if (!value || !setPropertyValue(value, propertyID)) |
| 249 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); | 249 exceptionState.throwDOMException(SyntaxError, "Failed to set '" + s + "'
as a property value."); |
| 250 } | 250 } |
| 251 | 251 |
| 252 bool FontFace::setPropertyFromStyle(const StylePropertySet* properties, CSSPrope
rtyID propertyID) | 252 bool FontFace::setPropertyFromStyle(const StylePropertySet* properties, CSSPrope
rtyID propertyID) |
| 253 { | 253 { |
| 254 return setPropertyValue(properties->getPropertyCSSValue(propertyID), propert
yID); | 254 return setPropertyValue(properties->getPropertyCSSValue(propertyID), propert
yID); |
| 255 } | 255 } |
| 256 | 256 |
| 257 bool FontFace::setPropertyValue(PassRefPtr<CSSValue> value, CSSPropertyID proper
tyID) | 257 bool FontFace::setPropertyValue(PassRefPtr<CSSValue> value, CSSPropertyID proper
tyID) |
| 258 { | 258 { |
| 259 switch (propertyID) { | 259 switch (propertyID) { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 unsigned numRanges = rangeList->length(); | 531 unsigned numRanges = rangeList->length(); |
| 532 for (unsigned i = 0; i < numRanges; i++) { | 532 for (unsigned i = 0; i < numRanges; i++) { |
| 533 CSSUnicodeRangeValue* range = toCSSUnicodeRangeValue(rangeList->item
WithoutBoundsCheck(i)); | 533 CSSUnicodeRangeValue* range = toCSSUnicodeRangeValue(rangeList->item
WithoutBoundsCheck(i)); |
| 534 cssFontFace->ranges().add(range->from(), range->to()); | 534 cssFontFace->ranges().add(range->from(), range->to()); |
| 535 } | 535 } |
| 536 } | 536 } |
| 537 return cssFontFace; | 537 return cssFontFace; |
| 538 } | 538 } |
| 539 | 539 |
| 540 } // namespace WebCore | 540 } // namespace WebCore |
| OLD | NEW |