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

Unified Diff: third_party/WebKit/Source/core/svg/SVGAnimatedEnumerationBase.cpp

Issue 1412713004: Hoist some pre-condition checks out of SVGAngle/SVGEnumeration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/svg/SVGAnimatedEnumerationBase.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGAnimatedEnumerationBase.cpp b/third_party/WebKit/Source/core/svg/SVGAnimatedEnumerationBase.cpp
index 394e71629da21ba5082f6b811c7a4ae1a7ac0997..0e8c333076cc4157ef48183edeeb52e2386e49e4 100644
--- a/third_party/WebKit/Source/core/svg/SVGAnimatedEnumerationBase.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGAnimatedEnumerationBase.cpp
@@ -29,7 +29,6 @@
*/
#include "config.h"
-
#include "core/svg/SVGAnimatedEnumerationBase.h"
#include "core/svg/SVGElement.h"
@@ -47,9 +46,17 @@ void SVGAnimatedEnumerationBase::setBaseVal(unsigned short value, ExceptionState
return;
}
- baseValue()->setValue(value, exceptionState);
- if (exceptionState.hadException())
+ if (!value) {
+ exceptionState.throwTypeError("The enumeration value provided is 0, which is not settable.");
+ return;
+ }
+
+ if (value > baseValue()->maxExposedEnumValue()) {
+ exceptionState.throwTypeError("The enumeration value provided (" + String::number(value) + ") is larger than the largest allowed value (" + String::number(baseValue()->maxExposedEnumValue()) + ").");
return;
+ }
+
+ baseValue()->setValue(value);
m_baseValueUpdated = true;
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGAngleTearOff.cpp ('k') | third_party/WebKit/Source/core/svg/SVGEnumeration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698