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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGLengthTearOff.cpp

Issue 1544673003: Refactor propagation of parsing errors for SVG attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 SVGLengthContext lengthContext(contextElement()); 124 SVGLengthContext lengthContext(contextElement());
125 target()->setValue(value, lengthContext); 125 target()->setValue(value, lengthContext);
126 commitChange(); 126 commitChange();
127 } 127 }
128 128
129 float SVGLengthTearOff::valueInSpecifiedUnits() 129 float SVGLengthTearOff::valueInSpecifiedUnits()
130 { 130 {
131 return target()->valueInSpecifiedUnits(); 131 return target()->valueInSpecifiedUnits();
132 } 132 }
133 133
134 void SVGLengthTearOff::setValueInSpecifiedUnits(float value, ExceptionState& es) 134 void SVGLengthTearOff::setValueInSpecifiedUnits(float value, ExceptionState& exc eptionState)
135 { 135 {
136 if (isImmutable()) { 136 if (isImmutable()) {
137 es.throwDOMException(NoModificationAllowedError, "The attribute is read- only."); 137 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only.");
138 return; 138 return;
139 } 139 }
140 target()->setValueInSpecifiedUnits(value); 140 target()->setValueInSpecifiedUnits(value);
141 commitChange(); 141 commitChange();
142 } 142 }
143 143
144 String SVGLengthTearOff::valueAsString() 144 String SVGLengthTearOff::valueAsString()
145 { 145 {
146 // TODO(shanmuga.m@samsung.com): Not all <length> properties have 0 (with no unit) as the default (lacuna) value, Need to return default value instead of 0 146 // TODO(shanmuga.m@samsung.com): Not all <length> properties have 0 (with no unit) as the default (lacuna) value, Need to return default value instead of 0
147 return hasExposedLengthUnit() ? target()->valueAsString() : String::number(0 ); 147 return hasExposedLengthUnit() ? target()->valueAsString() : String::number(0 );
148 } 148 }
149 149
150 void SVGLengthTearOff::setValueAsString(const String& str, ExceptionState& es) 150 void SVGLengthTearOff::setValueAsString(const String& str, ExceptionState& excep tionState)
151 { 151 {
152 if (isImmutable()) { 152 if (isImmutable()) {
153 es.throwDOMException(NoModificationAllowedError, "The attribute is read- only."); 153 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only.");
154 return; 154 return;
155 } 155 }
156 156
157 String oldValue = target()->valueAsString(); 157 String oldValue = target()->valueAsString();
158 158
159 target()->setValueAsString(str, es); 159 SVGParsingError status = target()->setValueAsString(str);
160 160
161 if (!es.hadException() && !hasExposedLengthUnit()) { 161 if (status == NoError && !hasExposedLengthUnit()) {
162 target()->setValueAsString(oldValue, ASSERT_NO_EXCEPTION); // rollback t o old value 162 target()->setValueAsString(oldValue); // rollback to old value
163 es.throwDOMException(SyntaxError, "The value provided ('" + str + "') is invalid."); 163 status = ParsingAttributeFailedError;
164 }
165 if (status != NoError) {
166 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + str + "') is invalid.");
164 return; 167 return;
165 } 168 }
166 169
167 commitChange(); 170 commitChange();
168 } 171 }
169 172
170 void SVGLengthTearOff::newValueSpecifiedUnits(unsigned short unitType, float val ueInSpecifiedUnits, ExceptionState& exceptionState) 173 void SVGLengthTearOff::newValueSpecifiedUnits(unsigned short unitType, float val ueInSpecifiedUnits, ExceptionState& exceptionState)
171 { 174 {
172 if (isImmutable()) { 175 if (isImmutable()) {
173 exceptionState.throwDOMException(NoModificationAllowedError, "The object is read-only."); 176 exceptionState.throwDOMException(NoModificationAllowedError, "The object is read-only.");
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 target()->convertToSpecifiedUnits(toCSSUnitType(unitType), lengthContext); 208 target()->convertToSpecifiedUnits(toCSSUnitType(unitType), lengthContext);
206 commitChange(); 209 commitChange();
207 } 210 }
208 211
209 SVGLengthTearOff::SVGLengthTearOff(PassRefPtrWillBeRawPtr<SVGLength> target, SVG Element* contextElement, PropertyIsAnimValType propertyIsAnimVal, const Qualifie dName& attributeName) 212 SVGLengthTearOff::SVGLengthTearOff(PassRefPtrWillBeRawPtr<SVGLength> target, SVG Element* contextElement, PropertyIsAnimValType propertyIsAnimVal, const Qualifie dName& attributeName)
210 : SVGPropertyTearOff<SVGLength>(target, contextElement, propertyIsAnimVal, a ttributeName) 213 : SVGPropertyTearOff<SVGLength>(target, contextElement, propertyIsAnimVal, a ttributeName)
211 { 214 {
212 } 215 }
213 216
214 } 217 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698