OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/viewer/internals.h" | 6 #include "sky/viewer/internals.h" |
7 | 7 |
8 #include "mojo/public/cpp/application/connect.h" | 8 #include "mojo/public/cpp/application/connect.h" |
9 #include "mojo/public/cpp/bindings/array.h" | 9 #include "mojo/public/cpp/bindings/array.h" |
10 #include "sky/engine/public/web/WebDocument.h" | 10 #include "sky/engine/public/web/WebDocument.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 void ContentAsText(Dart_NativeArguments args) { | 37 void ContentAsText(Dart_NativeArguments args) { |
38 Dart_Handle result = StdStringToDart(GetInternals()->ContentAsText()); | 38 Dart_Handle result = StdStringToDart(GetInternals()->ContentAsText()); |
39 Dart_SetReturnValue(args, result); | 39 Dart_SetReturnValue(args, result); |
40 } | 40 } |
41 | 41 |
42 void NotifyTestComplete(Dart_NativeArguments args) { | 42 void NotifyTestComplete(Dart_NativeArguments args) { |
43 Dart_Handle test_result = Dart_GetNativeArgument(args, 0); | 43 Dart_Handle test_result = Dart_GetNativeArgument(args, 0); |
44 GetInternals()->NotifyTestComplete(StdStringFromDart(test_result)); | 44 GetInternals()->NotifyTestComplete(StdStringFromDart(test_result)); |
45 } | 45 } |
46 | 46 |
| 47 void PassShellProxyHandle(Dart_NativeArguments args) { |
| 48 Dart_SetIntegerReturnValue(args, GetInternals()->PassShellProxyHandle().value(
)); |
| 49 } |
| 50 |
47 const DartBuiltin::Natives kNativeFunctions[] = { | 51 const DartBuiltin::Natives kNativeFunctions[] = { |
48 {"renderTreeAsText", RenderTreeAsText, 0}, | 52 {"renderTreeAsText", RenderTreeAsText, 0}, |
49 {"contentAsText", ContentAsText, 0}, | 53 {"contentAsText", ContentAsText, 0}, |
50 {"notifyTestComplete", NotifyTestComplete, 1}, | 54 {"notifyTestComplete", NotifyTestComplete, 1}, |
| 55 {"passShellProxyHandle", PassShellProxyHandle, 0}, |
51 }; | 56 }; |
52 | 57 |
53 const DartBuiltin& GetBuiltin() { | 58 const DartBuiltin& GetBuiltin() { |
54 static DartBuiltin& builtin = *new DartBuiltin(kNativeFunctions, | 59 static DartBuiltin& builtin = *new DartBuiltin(kNativeFunctions, |
55 arraysize(kNativeFunctions)); | 60 arraysize(kNativeFunctions)); |
56 return builtin; | 61 return builtin; |
57 } | 62 } |
58 | 63 |
59 Dart_NativeFunction Resolver(Dart_Handle name, | 64 Dart_NativeFunction Resolver(Dart_Handle name, |
60 int argument_count, | 65 int argument_count, |
61 bool* auto_setup_scope) { | 66 bool* auto_setup_scope) { |
62 return GetBuiltin().Resolver(name, argument_count, auto_setup_scope); | 67 return GetBuiltin().Resolver(name, argument_count, auto_setup_scope); |
63 } | 68 } |
64 | 69 |
65 const uint8_t* Symbolizer(Dart_NativeFunction native_function) { | 70 const uint8_t* Symbolizer(Dart_NativeFunction native_function) { |
66 return GetBuiltin().Symbolizer(native_function); | 71 return GetBuiltin().Symbolizer(native_function); |
67 } | 72 } |
68 | 73 |
69 const char kLibraryName[] = "dart:sky.internals"; | 74 const char kLibraryName[] = "dart:sky.internals"; |
70 const char kLibrarySource[] = R"DART( | 75 const char kLibrarySource[] = R"DART( |
71 String renderTreeAsText() native "renderTreeAsText"; | 76 String renderTreeAsText() native "renderTreeAsText"; |
72 String contentAsText() native "contentAsText"; | 77 String contentAsText() native "contentAsText"; |
73 void notifyTestComplete(String test_result) native "notifyTestComplete"; | 78 void notifyTestComplete(String test_result) native "notifyTestComplete"; |
| 79 int passShellProxyHandle() native "passShellProxyHandle"; |
74 )DART"; | 80 )DART"; |
75 | 81 |
76 } // namespace | 82 } // namespace |
77 | 83 |
78 void Internals::Create(Dart_Isolate isolate, DocumentView* document_view) { | 84 void Internals::Create(Dart_Isolate isolate, DocumentView* document_view) { |
79 DartState* state = DartState::From(isolate); | 85 DartState* state = DartState::From(isolate); |
80 state->SetUserData(&kInternalsKey, new Internals(document_view)); | 86 state->SetUserData(&kInternalsKey, new Internals(document_view)); |
81 Dart_Handle library = | 87 Dart_Handle library = |
82 Dart_LoadLibrary(Dart_NewStringFromCString(kLibraryName), | 88 Dart_LoadLibrary(Dart_NewStringFromCString(kLibraryName), |
83 Dart_NewStringFromCString(kLibrarySource), 0, 0); | 89 Dart_NewStringFromCString(kLibrarySource), 0, 0); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 172 } |
167 | 173 |
168 void Internals::pauseAnimations(double pauseTime) { | 174 void Internals::pauseAnimations(double pauseTime) { |
169 if (pauseTime < 0) | 175 if (pauseTime < 0) |
170 return; | 176 return; |
171 | 177 |
172 document_view_->web_view()->mainFrame()->document().pauseAnimationsForTestin
g(pauseTime); | 178 document_view_->web_view()->mainFrame()->document().pauseAnimationsForTestin
g(pauseTime); |
173 } | 179 } |
174 | 180 |
175 } // namespace sky | 181 } // namespace sky |
OLD | NEW |