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

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

Issue 2357463002: Consolidate read-only exception throwing for SVG*TearOffs (Closed)
Patch Set: Baseline updates Created 4 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 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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/svg/SVGAngleTearOff.h" 31 #include "core/svg/SVGAngleTearOff.h"
32 32
33 #include "bindings/core/v8/ExceptionState.h" 33 #include "bindings/core/v8/ExceptionState.h"
34 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
35 #include "core/dom/ExceptionCode.h" 34 #include "core/dom/ExceptionCode.h"
36 #include "core/svg/SVGElement.h" 35 #include "core/svg/SVGElement.h"
37 36
38 namespace blink { 37 namespace blink {
39 38
40 SVGAngleTearOff::SVGAngleTearOff(SVGAngle* targetProperty, SVGElement* contextEl ement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attributeNa me) 39 SVGAngleTearOff::SVGAngleTearOff(SVGAngle* targetProperty, SVGElement* contextEl ement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attributeNa me)
41 : SVGPropertyTearOff<SVGAngle>(targetProperty, contextElement, propertyIsAni mVal, attributeName) 40 : SVGPropertyTearOff<SVGAngle>(targetProperty, contextElement, propertyIsAni mVal, attributeName)
42 { 41 {
43 } 42 }
44 43
45 SVGAngleTearOff::~SVGAngleTearOff() 44 SVGAngleTearOff::~SVGAngleTearOff()
46 { 45 {
47 } 46 }
48 47
49 void SVGAngleTearOff::setValue(float value, ExceptionState& exceptionState) 48 void SVGAngleTearOff::setValue(float value, ExceptionState& exceptionState)
50 { 49 {
51 if (isImmutable()) { 50 if (isImmutable()) {
52 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only."); 51 throwReadOnly(exceptionState);
53 return; 52 return;
54 } 53 }
55
56 target()->setValue(value); 54 target()->setValue(value);
57 commitChange(); 55 commitChange();
58 } 56 }
59 57
60 void SVGAngleTearOff::setValueInSpecifiedUnits(float value, ExceptionState& exce ptionState) 58 void SVGAngleTearOff::setValueInSpecifiedUnits(float value, ExceptionState& exce ptionState)
61 { 59 {
62 if (isImmutable()) { 60 if (isImmutable()) {
63 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only."); 61 throwReadOnly(exceptionState);
64 return; 62 return;
65 } 63 }
66
67 target()->setValueInSpecifiedUnits(value); 64 target()->setValueInSpecifiedUnits(value);
68 commitChange(); 65 commitChange();
69 } 66 }
70 67
71 void SVGAngleTearOff::newValueSpecifiedUnits(unsigned short unitType, float valu eInSpecifiedUnits, ExceptionState& exceptionState) 68 void SVGAngleTearOff::newValueSpecifiedUnits(unsigned short unitType, float valu eInSpecifiedUnits, ExceptionState& exceptionState)
72 { 69 {
73 if (isImmutable()) { 70 if (isImmutable()) {
74 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only."); 71 throwReadOnly(exceptionState);
75 return; 72 return;
76 } 73 }
77
78 if (unitType == SVGAngle::kSvgAngletypeUnknown || unitType > SVGAngle::kSvgA ngletypeGrad) { 74 if (unitType == SVGAngle::kSvgAngletypeUnknown || unitType > SVGAngle::kSvgA ngletypeGrad) {
79 exceptionState.throwDOMException(NotSupportedError, "Cannot set value wi th unknown or invalid units (" + String::number(unitType) + ")."); 75 exceptionState.throwDOMException(NotSupportedError, "Cannot set value wi th unknown or invalid units (" + String::number(unitType) + ").");
80 return; 76 return;
81 } 77 }
82
83 target()->newValueSpecifiedUnits(static_cast<SVGAngle::SVGAngleType>(unitTyp e), valueInSpecifiedUnits); 78 target()->newValueSpecifiedUnits(static_cast<SVGAngle::SVGAngleType>(unitTyp e), valueInSpecifiedUnits);
84 commitChange(); 79 commitChange();
85 } 80 }
86 81
87 void SVGAngleTearOff::convertToSpecifiedUnits(unsigned short unitType, Exception State& exceptionState) 82 void SVGAngleTearOff::convertToSpecifiedUnits(unsigned short unitType, Exception State& exceptionState)
88 { 83 {
89 if (isImmutable()) { 84 if (isImmutable()) {
90 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only."); 85 throwReadOnly(exceptionState);
91 return; 86 return;
92 } 87 }
93
94 if (unitType == SVGAngle::kSvgAngletypeUnknown || unitType > SVGAngle::kSvgA ngletypeGrad) { 88 if (unitType == SVGAngle::kSvgAngletypeUnknown || unitType > SVGAngle::kSvgA ngletypeGrad) {
95 exceptionState.throwDOMException(NotSupportedError, "Cannot convert to u nknown or invalid units (" + String::number(unitType) + ")."); 89 exceptionState.throwDOMException(NotSupportedError, "Cannot convert to u nknown or invalid units (" + String::number(unitType) + ").");
96 return; 90 return;
97 } 91 }
98
99 if (target()->unitType() == SVGAngle::kSvgAngletypeUnknown) { 92 if (target()->unitType() == SVGAngle::kSvgAngletypeUnknown) {
100 exceptionState.throwDOMException(NotSupportedError, "Cannot convert from unknown or invalid units."); 93 exceptionState.throwDOMException(NotSupportedError, "Cannot convert from unknown or invalid units.");
101 return; 94 return;
102 } 95 }
103
104 target()->convertToSpecifiedUnits(static_cast<SVGAngle::SVGAngleType>(unitTy pe)); 96 target()->convertToSpecifiedUnits(static_cast<SVGAngle::SVGAngleType>(unitTy pe));
105 commitChange(); 97 commitChange();
106 } 98 }
107 99
108 void SVGAngleTearOff::setValueAsString(const String& value, ExceptionState& exce ptionState) 100 void SVGAngleTearOff::setValueAsString(const String& value, ExceptionState& exce ptionState)
109 { 101 {
110 if (isImmutable()) { 102 if (isImmutable()) {
111 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only."); 103 throwReadOnly(exceptionState);
112 return; 104 return;
113 } 105 }
114
115 String oldValue = target()->valueAsString(); 106 String oldValue = target()->valueAsString();
116
117 SVGParsingError status = target()->setValueAsString(value); 107 SVGParsingError status = target()->setValueAsString(value);
118
119 if (status == SVGParseStatus::NoError && !hasExposedAngleUnit()) { 108 if (status == SVGParseStatus::NoError && !hasExposedAngleUnit()) {
120 target()->setValueAsString(oldValue); // rollback to old value 109 target()->setValueAsString(oldValue); // rollback to old value
121 status = SVGParseStatus::ParsingFailed; 110 status = SVGParseStatus::ParsingFailed;
122 } 111 }
123 if (status != SVGParseStatus::NoError) { 112 if (status != SVGParseStatus::NoError) {
124 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + value + "') is invalid."); 113 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + value + "') is invalid.");
125 return; 114 return;
126 } 115 }
127
128 commitChange(); 116 commitChange();
129 } 117 }
130 118
131 DEFINE_TRACE_WRAPPERS(SVGAngleTearOff) 119 DEFINE_TRACE_WRAPPERS(SVGAngleTearOff)
132 { 120 {
133 visitor->traceWrappers(contextElement()); 121 visitor->traceWrappers(contextElement());
134 } 122 }
135 123
136 } // namespace blink 124 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698