Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: Source/core/css/FontFace.cpp

Issue 128043003: Improve core/css exception messages. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Test. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSStyleSheet.cpp ('k') | Source/core/css/FontFaceSet.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « Source/core/css/CSSStyleSheet.cpp ('k') | Source/core/css/FontFaceSet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698