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/Size.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 ==> SkSize. |
14 Point DartConverter<Point>::FromDart(Dart_Handle handle) { | 14 Size DartConverter<Size>::FromDart(Dart_Handle handle) { |
15 Point result; | 15 DCHECK(!LogIfError(handle)); |
16 result.is_null = true; | 16 Dart_Handle dx_value = |
| 17 Dart_GetField(handle, DOMDartState::Current()->dx_handle()); |
| 18 Dart_Handle dy_value = |
| 19 Dart_GetField(handle, DOMDartState::Current()->dy_handle()); |
| 20 double dx = 0.0, dy = 0.0; |
| 21 Dart_Handle err = Dart_DoubleValue(dx_value, &dx); |
| 22 DCHECK(!LogIfError(err)); |
| 23 err = Dart_DoubleValue(dy_value, &dy); |
| 24 DCHECK(!LogIfError(err)); |
17 | 25 |
18 DCHECK(!LogIfError(handle)); | 26 Size result; |
19 | 27 result.sk_size.set(dx, dy); |
20 Dart_Handle x_value = | |
21 Dart_GetField(handle, DOMDartState::Current()->x_handle()); | |
22 Dart_Handle y_value = | |
23 Dart_GetField(handle, DOMDartState::Current()->y_handle()); | |
24 | |
25 double x = 0.0, y = 0.0; | |
26 Dart_Handle err = Dart_DoubleValue(x_value, &x); | |
27 DCHECK(!LogIfError(err)); | |
28 err = Dart_DoubleValue(y_value, &y); | |
29 DCHECK(!LogIfError(err)); | |
30 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 Size DartConverter<Size>::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 |