OLD | NEW |
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 return LengthTypePC; | 97 return LengthTypePC; |
98 default: | 98 default: |
99 return LengthTypeUnknown; | 99 return LengthTypeUnknown; |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 } // namespace | 103 } // namespace |
104 | 104 |
105 bool SVGLengthTearOff::hasExposedLengthUnit() | 105 bool SVGLengthTearOff::hasExposedLengthUnit() |
106 { | 106 { |
| 107 if (target()->isCalculated()) |
| 108 return false; |
| 109 |
107 CSSPrimitiveValue::UnitType unit = target()->typeWithCalcResolved(); | 110 CSSPrimitiveValue::UnitType unit = target()->typeWithCalcResolved(); |
108 return isValidLengthUnit(unit) | 111 return isValidLengthUnit(unit) |
109 || unit == CSSPrimitiveValue::UnitType::Unknown | 112 || unit == CSSPrimitiveValue::UnitType::Unknown |
110 || unit == CSSPrimitiveValue::UnitType::UserUnits; | 113 || unit == CSSPrimitiveValue::UnitType::UserUnits; |
111 } | 114 } |
112 | 115 |
113 SVGLengthType SVGLengthTearOff::unitType() | 116 SVGLengthType SVGLengthTearOff::unitType() |
114 { | 117 { |
115 return hasExposedLengthUnit() ? toSVGLengthType(target()->typeWithCalcResolv
ed()) : LengthTypeUnknown; | 118 return hasExposedLengthUnit() ? toSVGLengthType(target()->typeWithCalcResolv
ed()) : LengthTypeUnknown; |
116 } | 119 } |
(...skipping 20 matching lines...) Expand all Loading... |
137 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); | 140 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); |
138 return; | 141 return; |
139 } | 142 } |
140 | 143 |
141 if (target()->isRelative() && !canResolveRelativeUnits(contextElement())) { | 144 if (target()->isRelative() && !canResolveRelativeUnits(contextElement())) { |
142 exceptionState.throwDOMException(NotSupportedError, "Could not resolve r
elative length."); | 145 exceptionState.throwDOMException(NotSupportedError, "Could not resolve r
elative length."); |
143 return; | 146 return; |
144 } | 147 } |
145 | 148 |
146 SVGLengthContext lengthContext(contextElement()); | 149 SVGLengthContext lengthContext(contextElement()); |
147 target()->setValue(value, lengthContext); | 150 if (target()->isCalculated()) |
| 151 target()->setValueAsNumber(value); |
| 152 else |
| 153 target()->setValue(value, lengthContext); |
| 154 |
148 commitChange(); | 155 commitChange(); |
149 } | 156 } |
150 | 157 |
151 float SVGLengthTearOff::valueInSpecifiedUnits() | 158 float SVGLengthTearOff::valueInSpecifiedUnits() |
152 { | 159 { |
| 160 if (target()->isCalculated()) |
| 161 return 0; |
| 162 |
153 return target()->valueInSpecifiedUnits(); | 163 return target()->valueInSpecifiedUnits(); |
154 } | 164 } |
155 | 165 |
156 void SVGLengthTearOff::setValueInSpecifiedUnits(float value, ExceptionState& exc
eptionState) | 166 void SVGLengthTearOff::setValueInSpecifiedUnits(float value, ExceptionState& exc
eptionState) |
157 { | 167 { |
158 if (isImmutable()) { | 168 if (isImmutable()) { |
159 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); | 169 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); |
160 return; | 170 return; |
161 } | 171 } |
162 target()->setValueInSpecifiedUnits(value); | 172 |
| 173 if (target()->isCalculated()) |
| 174 target()->setValueAsNumber(value); |
| 175 else |
| 176 target()->setValueInSpecifiedUnits(value); |
| 177 |
163 commitChange(); | 178 commitChange(); |
164 } | 179 } |
165 | 180 |
166 String SVGLengthTearOff::valueAsString() | 181 String SVGLengthTearOff::valueAsString() |
167 { | 182 { |
168 // 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 | 183 // 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 |
169 return hasExposedLengthUnit() ? target()->valueAsString() : String::number(0
); | 184 return hasExposedLengthUnit() ? target()->valueAsString() : String::number(0
); |
170 } | 185 } |
171 | 186 |
172 void SVGLengthTearOff::setValueAsString(const String& str, ExceptionState& excep
tionState) | 187 void SVGLengthTearOff::setValueAsString(const String& str, ExceptionState& excep
tionState) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 : SVGPropertyTearOff<SVGLength>(target, contextElement, propertyIsAnimVal, a
ttributeName) | 250 : SVGPropertyTearOff<SVGLength>(target, contextElement, propertyIsAnimVal, a
ttributeName) |
236 { | 251 { |
237 } | 252 } |
238 | 253 |
239 DEFINE_TRACE_WRAPPERS(SVGLengthTearOff) | 254 DEFINE_TRACE_WRAPPERS(SVGLengthTearOff) |
240 { | 255 { |
241 visitor->traceWrappers(contextElement()); | 256 visitor->traceWrappers(contextElement()); |
242 } | 257 } |
243 | 258 |
244 } // namespace blink | 259 } // namespace blink |
OLD | NEW |