Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(577)

Side by Side Diff: sky/engine/core/painting/Offset.cpp

Issue 1214833004: Split Size into Size and Offset. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/painting/Offset.h ('k') | sky/engine/core/painting/Offset.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/Offset.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 Offset DartConverter<Offset>::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 Offset 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 Offset DartConverter<Offset>::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
OLDNEW
« no previous file with comments | « sky/engine/core/painting/Offset.h ('k') | sky/engine/core/painting/Offset.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698