| 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/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/core/painting/Point.h" | 6 #include "sky/engine/core/painting/Point.h" |
| 7 | 7 |
| 8 #include "sky/engine/core/script/dom_dart_state.h" | 8 #include "sky/engine/core/script/dom_dart_state.h" |
| 9 #include "sky/engine/tonic/dart_error.h" | 9 #include "sky/engine/tonic/dart_error.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 // Convert dartPoint.x,y ==> SkPoint. | 14 // Convert handle.x,y ==> SkPoint. |
| 15 Point DartConverter<Point>::FromArgumentsWithNullCheck( | 15 Point DartConverter<Point>::FromDart(Dart_Handle handle) { |
| 16 Dart_NativeArguments args, | |
| 17 int index, | |
| 18 Dart_Handle& exception) { | |
| 19 Point result; | 16 Point result; |
| 20 result.is_null = true; | 17 result.is_null = true; |
| 21 | 18 |
| 22 Dart_Handle dartPoint = Dart_GetNativeArgument(args, index); | 19 DCHECK(!LogIfError(handle)); |
| 23 DCHECK(!LogIfError(dartPoint)); | |
| 24 | 20 |
| 25 Dart_Handle x_value = | 21 Dart_Handle x_value = |
| 26 Dart_GetField(dartPoint, DOMDartState::Current()->x_handle()); | 22 Dart_GetField(handle, DOMDartState::Current()->x_handle()); |
| 27 Dart_Handle y_value = | 23 Dart_Handle y_value = |
| 28 Dart_GetField(dartPoint, DOMDartState::Current()->y_handle()); | 24 Dart_GetField(handle, DOMDartState::Current()->y_handle()); |
| 29 | 25 |
| 30 double x = 0.0, y = 0.0; | 26 double x = 0.0, y = 0.0; |
| 31 Dart_Handle err = Dart_DoubleValue(x_value, &x); | 27 Dart_Handle err = Dart_DoubleValue(x_value, &x); |
| 32 DCHECK(!LogIfError(err)); | 28 DCHECK(!LogIfError(err)); |
| 33 err = Dart_DoubleValue(y_value, &y); | 29 err = Dart_DoubleValue(y_value, &y); |
| 34 DCHECK(!LogIfError(err)); | 30 DCHECK(!LogIfError(err)); |
| 35 result.sk_point.set(x, y); | 31 result.sk_point.set(x, y); |
| 36 result.is_null = false; | 32 result.is_null = false; |
| 37 return result; | 33 return result; |
| 38 } | 34 } |
| 39 | 35 |
| 36 Point DartConverter<Point>::FromArgumentsWithNullCheck( |
| 37 Dart_NativeArguments args, |
| 38 int index, |
| 39 Dart_Handle& exception) { |
| 40 return FromDart(Dart_GetNativeArgument(args, index)); |
| 41 } |
| 42 |
| 40 } // namespace blink | 43 } // namespace blink |
| OLD | NEW |