OLD | NEW |
| (Empty) |
1 // Copyright 2011, Google Inc. | |
2 // All rights reserved. | |
3 // | |
4 // Redistribution and use in source and binary forms, with or without | |
5 // modification, are permitted provided that the following conditions are | |
6 // met: | |
7 // | |
8 // * Redistributions of source code must retain the above copyright | |
9 // notice, this list of conditions and the following disclaimer. | |
10 // * Redistributions in binary form must reproduce the above | |
11 // copyright notice, this list of conditions and the following disclaimer | |
12 // in the documentation and/or other materials provided with the | |
13 // distribution. | |
14 // * Neither the name of Google Inc. nor the names of its | |
15 // contributors may be used to endorse or promote products derived from | |
16 // this software without specific prior written permission. | |
17 // | |
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
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. | |
29 | |
30 #include "config.h" | |
31 #include "DartSVGLength.h" | |
32 | |
33 #if ENABLE(SVG) | |
34 | |
35 namespace WebCore { | |
36 | |
37 namespace DartSVGLengthInternal { | |
38 | |
39 static const char* noModificationsAllowedError = "No modifications allowed"; | |
40 | |
41 void convertToSpecifiedUnitsCallback(Dart_NativeArguments args) | |
42 { | |
43 DartApiScope dartApiScope; | |
44 Dart_Handle exception; | |
45 { | |
46 SVGPropertyTearOff<SVGLength>* receiver = DartDOMWrapper::receiver< SVGP
ropertyTearOff<SVGLength> >(args); | |
47 if (receiver->role() == AnimValRole) { | |
48 exception = Dart_NewString(noModificationsAllowedError); | |
49 goto fail; | |
50 } | |
51 | |
52 ParameterAdapter< int > unitType(Dart_GetNativeArgument(args, 1)); | |
53 if (!unitType.conversionSuccessful()) { | |
54 exception = unitType.exception(); | |
55 goto fail; | |
56 } | |
57 | |
58 SVGLength& imp = receiver->propertyReference(); | |
59 SVGLengthContext lengthContext(receiver->contextElement()); | |
60 ExceptionCode ec = 0; | |
61 imp.convertToSpecifiedUnits(unitType, lengthContext, ec); | |
62 if (UNLIKELY(ec)) { | |
63 exception = DartDOMWrapper::exceptionCodeToDartException(ec); | |
64 goto fail; | |
65 } | |
66 | |
67 receiver->commitChange(); | |
68 return; | |
69 } | |
70 | |
71 fail: | |
72 Dart_ThrowException(exception); | |
73 ASSERT_NOT_REACHED(); | |
74 } | |
75 | |
76 void valueGetter(Dart_NativeArguments args) | |
77 { | |
78 DartApiScope dartApiScope; | |
79 Dart_Handle exception; | |
80 { | |
81 SVGPropertyTearOff<SVGLength>* receiver = DartDOMWrapper::receiver< SVGP
ropertyTearOff<SVGLength> >(args); | |
82 if (receiver->role() == AnimValRole) { | |
83 exception = Dart_NewString(noModificationsAllowedError); | |
84 goto fail; | |
85 } | |
86 | |
87 SVGLength& imp = receiver->propertyReference(); | |
88 SVGLengthContext lengthContext(receiver->contextElement()); | |
89 ExceptionCode ec = 0; | |
90 float value = imp.value(lengthContext, ec); | |
91 if (UNLIKELY(ec)) { | |
92 exception = DartDOMWrapper::exceptionCodeToDartException(ec); | |
93 goto fail; | |
94 } | |
95 | |
96 DartDOMWrapper::returnValue(args, value); | |
97 return; | |
98 } | |
99 | |
100 fail: | |
101 Dart_ThrowException(exception); | |
102 ASSERT_NOT_REACHED(); | |
103 } | |
104 | |
105 void valueSetter(Dart_NativeArguments args) | |
106 { | |
107 DartApiScope dartApiScope; | |
108 Dart_Handle exception; | |
109 { | |
110 SVGPropertyTearOff<SVGLength>* receiver = DartDOMWrapper::receiver< SVGP
ropertyTearOff<SVGLength> >(args); | |
111 ParameterAdapter< float > valueAsFloat(Dart_GetNativeArgument(args, 1)); | |
112 if (!valueAsFloat.conversionSuccessful()) { | |
113 exception = valueAsFloat.exception(); | |
114 goto fail; | |
115 } | |
116 | |
117 SVGLength& imp = receiver->propertyReference(); | |
118 SVGLengthContext lengthContext(receiver->contextElement()); | |
119 ExceptionCode ec = 0; | |
120 imp.setValue(valueAsFloat, lengthContext, ec); | |
121 if (UNLIKELY(ec)) { | |
122 exception = DartDOMWrapper::exceptionCodeToDartException(ec); | |
123 goto fail; | |
124 } | |
125 | |
126 receiver->commitChange(); | |
127 return; | |
128 } | |
129 | |
130 fail: | |
131 Dart_ThrowException(exception); | |
132 ASSERT_NOT_REACHED(); | |
133 } | |
134 | |
135 } | |
136 | |
137 } | |
138 | |
139 #endif // ENABLE(SVG) | |
OLD | NEW |