mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Merge the Sky Engine changes from the SkyDart branch
This CL flips the switch to make Sky use Dart. TBR=eseidel@chromium.org BUG=454613 Review URL: https://codereview.chromium.org/922893002
This commit is contained in:
parent
5f719fecde
commit
deedba409a
9
examples/dart-library.sky
Normal file
9
examples/dart-library.sky
Normal file
@ -0,0 +1,9 @@
|
||||
<div>
|
||||
<script>
|
||||
|
||||
getPlace() {
|
||||
return "world";
|
||||
}
|
||||
|
||||
</script>
|
||||
</div>
|
82
examples/dart-mojo.sky
Normal file
82
examples/dart-mojo.sky
Normal file
@ -0,0 +1,82 @@
|
||||
#!mojo mojo:sky_viewer
|
||||
<sky>
|
||||
<import src="dart-library.sky" as="library" />
|
||||
<script>
|
||||
import 'dart:async';
|
||||
import '/mojo/public/dart/application.dart';
|
||||
import 'dart:mojo_bindings';
|
||||
import 'dart:mojo_core';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:sky.internals' as internals;
|
||||
|
||||
import 'package:mojo/services/network/public/interfaces/network_service.mojom.dart';
|
||||
import 'package:mojo/services/network/public/interfaces/url_loader.mojom.dart';
|
||||
import 'package:mojo/public/interfaces/application/shell.mojom.dart' as shell_mojom;
|
||||
|
||||
class WGet extends Application {
|
||||
NetworkServiceProxy _networkService;
|
||||
UrlLoaderProxy _urlLoaderProxy;
|
||||
|
||||
WGet.fromHandle(MojoHandle handle) : super.fromHandle(handle);
|
||||
WGet(MojoMessagePipeEndpoint endpoint) : super(endpoint);
|
||||
|
||||
void initialize(List<String> args) {
|
||||
run(args);
|
||||
}
|
||||
|
||||
run(List<String> args) async {
|
||||
if (args == null || args.length != 2) {
|
||||
throw "Expected URL argument";
|
||||
}
|
||||
|
||||
ByteData bodyData = await _getUrl(args[1]);
|
||||
print("read ${bodyData.lengthInBytes} bytes");
|
||||
|
||||
_closeProxies();
|
||||
close();
|
||||
}
|
||||
|
||||
Future<ByteData> _getUrl(String url) async {
|
||||
_initProxiesIfNeeded();
|
||||
|
||||
var urlRequest = new UrlRequest()
|
||||
..url = url
|
||||
..autoFollowRedirects = true;
|
||||
|
||||
var urlResponse = await _urlLoaderProxy.start(urlRequest);
|
||||
print("url => ${urlResponse.response.url}");
|
||||
print("status_line => ${urlResponse.response.statusLine}");
|
||||
print("mime_type => ${urlResponse.response.mimeType}");
|
||||
|
||||
return DataPipeDrainer.drainHandle(urlResponse.response.body);
|
||||
}
|
||||
|
||||
void _initProxiesIfNeeded() {
|
||||
if (_networkService == null) {
|
||||
_networkService = new NetworkServiceProxy.unbound();
|
||||
connectToService("mojo:network_service", _networkService);
|
||||
}
|
||||
if (_urlLoaderProxy == null) {
|
||||
_urlLoaderProxy = new UrlLoaderProxy.unbound();
|
||||
_networkService.createUrlLoader(_urlLoaderProxy);
|
||||
}
|
||||
}
|
||||
|
||||
void _closeProxies() {
|
||||
_urlLoaderProxy.close();
|
||||
_networkService.close();
|
||||
_urlLoaderProxy = null;
|
||||
_networkService = null;
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
var messagePipe = new MojoMessagePipe();
|
||||
var wget = new WGet(messagePipe.endpoints[1]);
|
||||
wget.listen();
|
||||
var shellProxy = new shell_mojom.ShellProxy.fromHandle(new MojoHandle(internals.passShellProxyHandle()));
|
||||
wget.initializeFromShellProxy(shellProxy, ["mojo:wget", "http://www.google.com"]);
|
||||
}
|
||||
|
||||
</script>
|
||||
</sky>
|
14
examples/dart.sky
Normal file
14
examples/dart.sky
Normal file
@ -0,0 +1,14 @@
|
||||
#!mojo mojo:sky_viewer
|
||||
<sky>
|
||||
<import src="dart-library.sky" as="library" />
|
||||
<script>
|
||||
import "dart:sky" as sky;
|
||||
|
||||
main() {
|
||||
var text = new sky.Text("Hello");
|
||||
print(text.data);
|
||||
// print(text.firstChild);
|
||||
}
|
||||
</script>
|
||||
</sky>
|
||||
w
|
@ -1,6 +1,5 @@
|
||||
#!mojo mojo:sky_viewer
|
||||
<sky>
|
||||
<import src="fps-counter.sky" />
|
||||
<style>
|
||||
square {
|
||||
margin: 50px;
|
||||
@ -10,20 +9,23 @@ square {
|
||||
}
|
||||
</style>
|
||||
<square />
|
||||
<fps-counter showHistory="true" />
|
||||
<script>
|
||||
var square = document.querySelector('square');
|
||||
var timeBase = 0;
|
||||
import "dart:sky";
|
||||
|
||||
function animate(time) {
|
||||
if (!timeBase)
|
||||
timeBase = time;
|
||||
var delta = time - timeBase;
|
||||
var rotation = Math.floor(delta / 10);
|
||||
square.style.transform = 'rotate(' + rotation + 'deg)';
|
||||
requestAnimationFrame(animate);
|
||||
void main() {
|
||||
Element square = document.querySelector('square');
|
||||
double timeBase = null;
|
||||
|
||||
void animate(double time) {
|
||||
if (timeBase == null)
|
||||
timeBase = time;
|
||||
double delta = time - timeBase;
|
||||
int rotation = (delta / 10).floor();
|
||||
square.style.setProperty("transform", 'rotate(${rotation}deg)');
|
||||
window.requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
window.requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
</script>
|
||||
</sky>
|
||||
|
Loading…
Reference in New Issue
Block a user