OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sky/engine/core/painting/Point.h" | 5 #include "sky/engine/core/painting/Point.h" |
6 | 6 |
7 #include "sky/engine/core/script/dom_dart_state.h" | 7 #include "sky/engine/core/script/dom_dart_state.h" |
8 #include "sky/engine/tonic/dart_error.h" | 8 #include "sky/engine/tonic/dart_error.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 // Convert handle.x,y ==> SkPoint. | 13 // Convert handle.x,y ==> SkPoint. |
14 Point DartConverter<Point>::FromDart(Dart_Handle handle) { | 14 Point DartConverter<Point>::FromDart(Dart_Handle handle) { |
15 Point result; | |
16 result.is_null = true; | |
17 | |
18 DCHECK(!LogIfError(handle)); | 15 DCHECK(!LogIfError(handle)); |
19 | |
20 Dart_Handle x_value = | 16 Dart_Handle x_value = |
21 Dart_GetField(handle, DOMDartState::Current()->x_handle()); | 17 Dart_GetField(handle, DOMDartState::Current()->x_handle()); |
22 Dart_Handle y_value = | 18 Dart_Handle y_value = |
23 Dart_GetField(handle, DOMDartState::Current()->y_handle()); | 19 Dart_GetField(handle, DOMDartState::Current()->y_handle()); |
24 | |
25 double x = 0.0, y = 0.0; | 20 double x = 0.0, y = 0.0; |
26 Dart_Handle err = Dart_DoubleValue(x_value, &x); | 21 Dart_Handle err = Dart_DoubleValue(x_value, &x); |
27 DCHECK(!LogIfError(err)); | 22 DCHECK(!LogIfError(err)); |
28 err = Dart_DoubleValue(y_value, &y); | 23 err = Dart_DoubleValue(y_value, &y); |
29 DCHECK(!LogIfError(err)); | 24 DCHECK(!LogIfError(err)); |
| 25 |
| 26 Point result; |
30 result.sk_point.set(x, y); | 27 result.sk_point.set(x, y); |
31 result.is_null = false; | 28 result.is_null = false; |
32 return result; | 29 return result; |
33 } | 30 } |
34 | 31 |
35 Point DartConverter<Point>::FromArgumentsWithNullCheck( | 32 Point DartConverter<Point>::FromArgumentsWithNullCheck( |
36 Dart_NativeArguments args, | 33 Dart_NativeArguments args, |
37 int index, | 34 int index, |
38 Dart_Handle& exception) { | 35 Dart_Handle& exception) { |
39 return FromDart(Dart_GetNativeArgument(args, index)); | 36 return FromDart(Dart_GetNativeArgument(args, index)); |
40 } | 37 } |
41 | 38 |
42 } // namespace blink | 39 } // namespace blink |
OLD | NEW |