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 ExceptionCode ec = 0; |
| 60 imp.convertToSpecifiedUnits(unitType, receiver->contextElement(), ec); |
| 61 if (UNLIKELY(ec)) { |
| 62 exception = DartDOMWrapper::exceptionCodeToDartException(ec); |
| 63 goto fail; |
| 64 } |
| 65 |
| 66 receiver->commitChange(); |
| 67 return; |
| 68 } |
| 69 |
| 70 fail: |
| 71 Dart_ThrowException(exception); |
| 72 ASSERT_NOT_REACHED(); |
| 73 } |
| 74 |
| 75 void valueGetter(Dart_NativeArguments args) |
| 76 { |
| 77 DartApiScope dartApiScope; |
| 78 Dart_Handle exception; |
| 79 { |
| 80 SVGPropertyTearOff<SVGLength>* receiver = DartDOMWrapper::receiver< SVGP
ropertyTearOff<SVGLength> >(args); |
| 81 if (receiver->role() == AnimValRole) { |
| 82 exception = Dart_NewString(noModificationsAllowedError); |
| 83 goto fail; |
| 84 } |
| 85 |
| 86 SVGLength& imp = receiver->propertyReference(); |
| 87 ExceptionCode ec = 0; |
| 88 float value = imp.value(receiver->contextElement(), ec); |
| 89 if (UNLIKELY(ec)) { |
| 90 exception = DartDOMWrapper::exceptionCodeToDartException(ec); |
| 91 goto fail; |
| 92 } |
| 93 |
| 94 DartDOMWrapper::returnValue(args, value); |
| 95 return; |
| 96 } |
| 97 |
| 98 fail: |
| 99 Dart_ThrowException(exception); |
| 100 ASSERT_NOT_REACHED(); |
| 101 } |
| 102 |
| 103 void valueSetter(Dart_NativeArguments args) |
| 104 { |
| 105 DartApiScope dartApiScope; |
| 106 Dart_Handle exception; |
| 107 { |
| 108 SVGPropertyTearOff<SVGLength>* receiver = DartDOMWrapper::receiver< SVGP
ropertyTearOff<SVGLength> >(args); |
| 109 ParameterAdapter< float > valueAsFloat(Dart_GetNativeArgument(args, 1)); |
| 110 if (!valueAsFloat.conversionSuccessful()) { |
| 111 exception = valueAsFloat.exception(); |
| 112 goto fail; |
| 113 } |
| 114 |
| 115 SVGLength& imp = receiver->propertyReference(); |
| 116 ExceptionCode ec = 0; |
| 117 imp.setValue(valueAsFloat, receiver->contextElement(), ec); |
| 118 if (UNLIKELY(ec)) { |
| 119 exception = DartDOMWrapper::exceptionCodeToDartException(ec); |
| 120 goto fail; |
| 121 } |
| 122 |
| 123 receiver->commitChange(); |
| 124 return; |
| 125 } |
| 126 |
| 127 fail: |
| 128 Dart_ThrowException(exception); |
| 129 ASSERT_NOT_REACHED(); |
| 130 } |
| 131 |
| 132 } |
| 133 |
| 134 } |
| 135 |
| 136 #endif // ENABLE(SVG) |
OLD | NEW |