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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGAngleTearOff.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, 1 month 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 if (isImmutable()) { 90 if (isImmutable()) {
91 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only."); 91 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only.");
92 return; 92 return;
93 } 93 }
94 94
95 if (unitType == SVGAngle::SVG_ANGLETYPE_UNKNOWN || unitType > SVGAngle::SVG_ ANGLETYPE_GRAD) { 95 if (unitType == SVGAngle::SVG_ANGLETYPE_UNKNOWN || unitType > SVGAngle::SVG_ ANGLETYPE_GRAD) {
96 exceptionState.throwDOMException(NotSupportedError, "Cannot convert to u nknown or invalid units (" + String::number(unitType) + ")."); 96 exceptionState.throwDOMException(NotSupportedError, "Cannot convert to u nknown or invalid units (" + String::number(unitType) + ").");
97 return; 97 return;
98 } 98 }
99 99
100 target()->convertToSpecifiedUnits(static_cast<SVGAngle::SVGAngleType>(unitTy pe), exceptionState); 100 if (target()->unitType() == SVGAngle::SVG_ANGLETYPE_UNKNOWN) {
101 if (!exceptionState.hadException()) 101 exceptionState.throwDOMException(NotSupportedError, "Cannot convert from unknown or invalid units.");
102 commitChange(); 102 return;
103 }
104
105 target()->convertToSpecifiedUnits(static_cast<SVGAngle::SVGAngleType>(unitTy pe));
106 commitChange();
103 } 107 }
104 108
105 void SVGAngleTearOff::setValueAsString(const String& value, ExceptionState& exce ptionState) 109 void SVGAngleTearOff::setValueAsString(const String& value, ExceptionState& exce ptionState)
106 { 110 {
107 if (isImmutable()) { 111 if (isImmutable()) {
108 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only."); 112 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only.");
109 return; 113 return;
110 } 114 }
111 115
112 String oldValue = target()->valueAsString(); 116 String oldValue = target()->valueAsString();
113 117
114 target()->setValueAsString(value, exceptionState); 118 target()->setValueAsString(value, exceptionState);
115 119
116 if (!exceptionState.hadException() && !hasExposedAngleUnit()) { 120 if (!exceptionState.hadException() && !hasExposedAngleUnit()) {
117 target()->setValueAsString(oldValue, ASSERT_NO_EXCEPTION); // rollback t o old value 121 target()->setValueAsString(oldValue, ASSERT_NO_EXCEPTION); // rollback t o old value
118 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + value + "') is invalid."); 122 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + value + "') is invalid.");
119 return; 123 return;
120 } 124 }
121 125
122 commitChange(); 126 commitChange();
123 } 127 }
124 128
125 } 129 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGAngle.cpp ('k') | third_party/WebKit/Source/core/svg/SVGAnimatedEnumerationBase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698