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 12 matching lines...) Expand all Loading... |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
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 "config.h" | 31 #include "config.h" |
32 | 32 |
33 #include "core/svg/SVGPointTearOff.h" | 33 #include "bindings/core/dart/shared_lib/DartNativeExtensions.h" |
34 | 34 |
35 #include "bindings/core/v8/ExceptionState.h" | 35 #include "bindings/core/dart/DartUtilities.h" |
36 #include "core/dom/ExceptionCode.h" | |
37 #include "core/svg/SVGElement.h" | |
38 #include "core/svg/SVGMatrixTearOff.h" | |
39 | 36 |
40 namespace blink { | 37 namespace blink { |
41 | 38 |
42 SVGPointTearOff::SVGPointTearOff(PassRefPtrWillBeRawPtr<SVGPoint> target, SVGEle
ment* contextElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedNa
me& attributeName) | 39 #if defined(ENABLE_DART_NATIVE_EXTENSIONS) |
43 : SVGPropertyTearOff<SVGPoint>(target, contextElement, propertyIsAnimVal, at
tributeName) | 40 Dart_Handle DartNativeExtensions::loadExtension(const String& url, Dart_Handle p
arentLibrary) |
44 { | 41 { |
| 42 String userUri = url.substring(String("dart-ext:").length()); |
| 43 |
| 44 String name; |
| 45 String path; |
| 46 size_t index = userUri.reverseFind('/'); |
| 47 if (index == kNotFound) { |
| 48 name = userUri; |
| 49 path = "./"; |
| 50 } else if (index == userUri.length() - 1) { |
| 51 return Dart_NewApiError("Extension name missing."); |
| 52 } else { |
| 53 name = userUri.substring(index + 1); |
| 54 path = userUri.substring(0, index + 1); |
| 55 } |
| 56 |
| 57 void* libraryHandle = 0; |
| 58 Dart_Handle result = loadExtensionLibrary(path, name, &libraryHandle); |
| 59 if (Dart_IsError(result)) { |
| 60 return result; |
| 61 } |
| 62 |
| 63 String initFunctionName = name + "_Init"; |
| 64 |
| 65 typedef Dart_Handle (*InitFunctionType)(Dart_Handle library); |
| 66 InitFunctionType fn; |
| 67 result = resolveSymbol(libraryHandle, initFunctionName, reinterpret_cast<voi
d**>(&fn)); |
| 68 if (Dart_IsError(result)) { |
| 69 return result; |
| 70 } |
| 71 |
| 72 return (*fn)(parentLibrary); |
| 73 } |
| 74 #else |
| 75 Dart_Handle DartNativeExtensions::loadExtension(const String& url, Dart_Handle p
arentLibrary) |
| 76 { |
| 77 return Dart_NewApiError("Native extensions are not enabled."); |
| 78 } |
| 79 #endif // defined(ENABLE_DART_NATIVE_EXTENSIONS) |
| 80 |
45 } | 81 } |
46 | 82 |
47 void SVGPointTearOff::setX(float f, ExceptionState& exceptionState) | |
48 { | |
49 if (isImmutable()) { | |
50 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); | |
51 return; | |
52 } | |
53 | 83 |
54 target()->setX(f); | |
55 commitChange(); | |
56 } | |
57 | |
58 void SVGPointTearOff::setY(float f, ExceptionState& exceptionState) | |
59 { | |
60 if (isImmutable()) { | |
61 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib
ute is read-only."); | |
62 return; | |
63 } | |
64 | |
65 target()->setY(f); | |
66 commitChange(); | |
67 } | |
68 | |
69 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGPointTearOff::matrixTransform(PassRef
PtrWillBeRawPtr<SVGMatrixTearOff> matrix) | |
70 { | |
71 FloatPoint point = target()->matrixTransform(matrix->value()); | |
72 return SVGPointTearOff::create(SVGPoint::create(point), 0, PropertyIsNotAnim
Val); | |
73 } | |
74 | |
75 } | |
OLD | NEW |