48 Commits

Author SHA1 Message Date
Hixie
998895d9b8 Random cleanup of various Dart things in our tree.
I ran this and fixed some of the warnings flagged:
cd ~/dev/mojo/src/sky && find engine/core/painting sdk/example sdk/lib -type f -name '*.dart' | perl -nE 'chomp; local $/ = undef; open(FILE, $_); my $file = <FILE>; print $file; next if $file =~ /^part of/om; say "import \"$_\";"' > all.dart && shelldb analyze all.dart 2>&1 | grep -v 'sky/all.dart'

Then I loaded the affected examples and fixed any bugs I found from running them.

Major change to SDK:

- Fix RenderPadding to get a valid size when it has no child (it was
  previously sizing itself too small by the padding amount).

Minor changes, mostly to examples:

- Fix the 'part of' lines in sky_shell_dart_controller_service_isolate
  to match the library name given in main.dart.

- Remove unused imports in various places.

- Fix example/game/lib/texture.dart to use the new Rect creation APIs.

- Remove unused code in example/mine_digger/lib/main.dart.

- Fix example/raw/hello_world.dart to use the new Size.center API.

- Fix example/rendering/baseline.dart and
  example/rendering/justify_content.dart to have readable text.

- Fix compile error in example/rendering/transform.dart.

- Extend the debugDoesMeetConstraints() method to print useful
  information when it will be used to fire an assert.

- Remove a warning about abstract methods on RenderView that would for
  some reason only sometimes get flagged by the analyzer.

R=abarth@chromium.org, jackson@google.com

Review URL: https://codereview.chromium.org/1215163003.
2015-06-30 12:03:50 -07:00
Hixie
fa70eb0982 Split Size into Size and Offset.
Added a OffsetBase class that Size now inherits from, and added a new
Offset class that also inherits from OffsetBase.

Offset has:
 - dx and dy members
 - zero and infinite static constants
 - a method that returns a new Offset that's the existing one scaled
   by a scalar
 - a unary minus operator
 - operators overloads such that subtracting or adding two Offsets
   gives another Offset
 - a toPoint() method

Added Offset and Size to the dart bindings, so they can be used from C++.

Changed the Canvas API to use Point, Size, and Offset where appropriate:
 - drawLine uses Points now
 - drawCircle uses a Point now
 - drawImage uses a Paint now
 - the constructor uses a Size

Changed Point as follows:
 - added a unary minus
 - Point difference now gives an Offset rather than a Size
 - You can add an Offset to a Point to get a new Point
 - toSize() has been replaced by toOffset()

Changed Rect as follows:
 - renamed upperLeft and lowerRight to topLeft and bottomRight for
   consistency with our other APIs
 - added bottomLeft and topRight for completeness

Changed Size as follows:
 - now inherits from OffsetBase
 - added *, /, ~/, and % operators for scaling sizes
 - subtracting a Size from a Size gives an Offset
 - subtracting an Offset from a Size gives a Size
 - changed the + operator to take an Offset instead of a Size
 - added topLeft, bottomLeft, topRight, bottomRight to match Rect
 - added center for the same reason
 - added shortestSide getter since that was a common pattern
 - removed toPoint()

Changed DrawLooperLayerInfo as follows:
 - setOffset member takes an Offset instead of a Point

Changed BoxConstraints as follows:
 - added biggest getter since it was a common pattern
 - added smallest getter for symmetry

Changed BoxShadow as follows:
 - offset member is an Offset rather than a Size

Changed ViewConstraints as follows:
 - replaced height and width members by a single size member

I did some minor code cleanup in nearby files while I was there,
including sorting sky/engine/core/core.gni alphabetically, and fixing
some warnings in the examples.

BUG=
R=abarth@chromium.org, chinmaygarde@google.com

Review URL: https://codereview.chromium.org/1214833004.
2015-06-26 15:21:29 -07:00
Adam Barth
570cfb6299 Support snapshots in sky_shell (again)
Unbreak support for snapshots now that we have our offline Dart loader. Also,
wire up support for snapshots in sky_shell on Linux.

TBR=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1212623002.
2015-06-25 17:10:35 -07:00
Adam Barth
1a1ef489ee Make it possible to run Sky apps offline
This CL makes it possible to run Sky apps offline by introducing new
DartLibraryProvider subclasses, specifically one that can load directly from
the file system. A future CL will expand this functionality to work with asset
bundles as well.

Currently, the only platform that uses this functionality is Linux, which can
now load a simple Sky app without even loading a network stack. Making this
work on other platforms is work for future CLs.

TBR=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1203143004.
2015-06-25 13:59:22 -07:00
Adam Barth
fa627b4b0e Factor DartLibraryProvider out of DartLoader
This CL factors the network interactions out of DartLoader into a
DartLibraryProvider interface, paving the way for other library providers
(e.g., offline).

As part of this CL, I've renamed DartLoader to DartLibraryLoader and moved the
class into tonic, where it can't have any direct network dependencies.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1202283004.
2015-06-24 09:32:22 -07:00
Adam Barth
d8d7db82a0 Really remove config.h
This CL generated by |sed -i '/sky\/engine\/config.h/d'| and a manual sweep to
catch some oddballs.

TBR=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1206763002.
2015-06-23 23:15:28 -07:00
Adam Barth
1f258f383e Add support for snapshot loading to Sky
This CL adds the ability to load Dart snapshot files created by sky_packager in
Sky. Using a snapshot lets us transmit all the code for an app in a single blob
and should improve startup time. Later CLs will make this codepath easier to
use and evaluate performance.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1197133004.
2015-06-23 18:40:01 -07:00
Adam Barth
50a92ad78a Remove support for "mojo:" libraries
We ended up using "dart:" instead. This change shouldn't have any observable
effects.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1192743011.
2015-06-23 07:42:28 -07:00
John McCutchan
e855c0e1bc Add Observatory mojo_shell hearbeat test
Fix HTTP requests

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1191253005.
2015-06-22 13:27:35 -07:00
John McCutchan
0043e2abf8 Roll dart forward
BUG=
R=zra@google.com

Review URL: https://codereview.chromium.org/1199483004.
2015-06-19 13:23:29 -07:00
Ryan Macnak
9cdd8bb8c7 Track changes to standalone vmservice in mojo and sky embedders.
Standalone changes were in https://codereview.chromium.org/1166433008/

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/1183453004.
2015-06-16 16:58:48 -07:00
Adam Barth
883f673a6b Update Dart dependency and patch dart_controller to account for non-backwards compatible API update
Patch originally by chinmaygarde.

R=chinmaygarde@google.com

Review URL: https://codereview.chromium.org/1185233002.
2015-06-15 18:34:27 -07:00
Chinmay Garde
9bf2fe7f3a Revert "Update Dart dependency and patch dart_controller to account for"
This reverts commit 42bb335967d4d9cbeb1a745111dd0fff985465f2.
2015-06-15 15:32:28 -07:00
Chinmay Garde
e027c6b874 Update Dart dependency and patch dart_controller to account for
non-backwards compatible API update

BUG=
R=abarth@chromium.org

Review URL: https://codereview.chromium.org/1183253002.
2015-06-15 15:11:31 -07:00
Eric Seidel
c1cad6ccda Don't crash when main.dart is a 404.
Ideally we would show a failwhale or some such, but
I don't know how we would bundle that file with our
APK yet.

Fixes https://github.com/domokit/mojo/issues/228

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/1182633002.
2015-06-11 14:07:49 -07:00
Chinmay Garde
ac4f0bebc5 sky/engine updates for iOS targets
R=abarth@chromium.org

Review URL: https://codereview.chromium.org/1163323003.
2015-06-10 16:17:56 -07:00
Adam Barth
c17d58ab28 Fix shutdown crash in Sky
Previously, we would try to close some Dart persistent handles after destroying
the isolate. Now we revoke the weak pointers these handles are using to refer
to the isolate before trying to tear them down.

Fixes https://github.com/domokit/mojo/issues/233

R=chinmaygarde@google.com, eseidel@chromium.org

Review URL: https://codereview.chromium.org/1175053002.
2015-06-10 12:59:07 -07:00
Matt Perry
d745bd3d47 Sky: Add a DartConverterEnum and use that for all our enum needs.
R=abarth@chromium.org, eseidel@chromium.org

Review URL: https://codereview.chromium.org/1170963003.
2015-06-09 15:58:54 -04:00
Adam Barth
1e9184d282 Make Uri.base work in SkyView
R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1153673005
2015-06-03 17:00:44 -07:00
Matt Perry
3aa1e23d7d Sky: Convert TransferMode to an enum.
It looked and smelled like an enum, so lets just make it one. This also gives us a nice toString() method.

R=abarth@chromium.org, eseidel@chromium.org, ianh@google.com

Review URL: https://codereview.chromium.org/1144233004
2015-06-03 16:19:14 -04:00
John McCutchan
87fd276d3d Enable Dart's checked mode in the Sky controller by default for debug builds
This matches the behaviour of the Mojo Dart controller and was requested by tonyg@

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/1152873006
2015-06-03 09:33:17 -07:00
Matt Perry
4f2d78a5bb Re-land "Add a Color class to dart:sky."
The previous patch broke the sky tests. I have updated the framework to use the new Color class.

R=jackson@google.com

Review URL: https://codereview.chromium.org/1159663003
2015-06-02 14:09:42 -04:00
Matt Perry
ffed692545 Revert "Add a Color class to dart:sky."
This reverts commit a413c8319fe9a46dc131f6efe275d014c9cb7eb9.

Reason: seems to have broken Sky tests:
Regressions: Unexpected crashes (2)
  raw/render_box.dart [ Crash ]
  raw/render_flex.dart [ Crash ]

TBR=jackson@google.com

Review URL: https://codereview.chromium.org/1143133007
2015-06-01 18:13:35 -04:00
Matt Perry
326e2324c9 Add a Color class to dart:sky.
R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1161273004
2015-06-01 16:48:48 -04:00
Matt Perry
eaba0b981f Add DartHandleCache and use it to cache strings used when converting Rect and
Point classes.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/1145103005
2015-05-28 13:39:33 -04:00
Collin Jackson
1408fcff9a Don't start the Observatory when testing Sky viewer 2015-05-21 21:03:34 -07:00
Collin Jackson
4c6f6cd8a8 Hard code the port to 8181 2015-05-21 21:03:33 -07:00
Eric Seidel
827e621238 Teach sky_viewer about the new main.dart hotness
R=abarth@chromium.org

Review URL: https://codereview.chromium.org/1147413003
2015-05-21 12:46:36 -07:00
Adam Barth
9f8b9bb96d Teach SkyView path to draw a circle
This CL adds a global view object that can receive a Picture and be signaled to
draw. When using SkyView, this Picture shows up on screen.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1134913003
2015-05-19 14:20:04 -07:00
Adam Barth
1b45682ba9 Teach SkyView code path to print hello, world
This CL makes the SkyView codepath smart enough to print "hello, world" to the
console. The code path is off by default but can be enabled by changing one
line of code.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1131673011
2015-05-19 13:51:12 -07:00
Adam Barth
9a4feca976 Teach SkyView how to load the main script
This CL implements SkyView::Load to start executing Sky content directly from
Dart's main(). This code isn't currently wired up to anything, so it's not yet
tested.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1130353009
2015-05-19 10:55:07 -07:00
John McCutchan
76da439f44 Add Observatory to sky dart_controller
- Bump Dart and Observatory DEPS to 45576 and 45565 respectively.
- Include 'dart:io' in snapshot
- Add 'dart:io' native bindings to sky bindings.
- Initialize 'dart:io' in sky dart_controller.
- Include Observatory and service isolate resources in build.
- Bring up service isolate.
- Start handle watcher isolate from service isolate (hides handle watcher isolate from debugger and Observatory).
- Hook up debugger.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1107803002
2015-05-06 15:36:12 -07:00
Ryan Macnak
a6ffc52bea Ensure isolates have a root library so createMirrorSystem() and spawnUri() are happy.
https://github.com/domokit/mojo/issues/98

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1088263004
2015-04-16 15:49:11 -07:00
Siva Annamalai
9f0601b18e gen_snapshot now generates two snapshot buffers, one for the vm isolate
and another for a regular isolate. These changes account for that change
in the mojo and sky snapshot generation scripts and the controller files.

R=zra@google.com

Review URL: https://codereview.chromium.org/1047883002
2015-04-02 11:31:29 -07:00
Adam Barth
f3df64fa3d Let Dart code running in Sky add events to the trace timeline
This will let us form a wholistic picture of work done in the framework and in
the engine.

R=ojan@chromium.org, rafaelw@chromium.org

Review URL: https://codereview.chromium.org/1028243003
2015-03-23 14:48:06 -07:00
Zachary Anderson
d83427c165 Dart: Removes all but native calls and the handle watcher from the snapshot.
The bindings, core, and application libraries are now referred to as, e.g.:

package:mojo/public/dart/core.dart

Since the handle watcher remains in the snapshot, it no
longer refers to types defined in core.dart. References to types defined
in core.dart are also removed from mojo_natives.cc.

In Dart packaged apps, the SDK is zipped up under mojo/public/dart.

For embedder tests, the SDK is copied into the generated source output directory.

A base_dir parameter is added to the 'dart_package' and 'mojom' GN macros so that
consumers of the Mojo SDK can all import using the same URIs regardless of where
the SDK lives in their source trees.

BUG=
R=erg@chromium.org

Review URL: https://codereview.chromium.org/1027603002
2015-03-23 11:04:03 -07:00
Adam Barth
e26810b1de Add more tracing to Sky
This CL adds trace events:

1) Between requesting a frame and begin frame.
2) In the DartLoader see network latency.
3) While executing |main| and |_init|.

TBR=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1025073003
2015-03-20 16:11:39 -07:00
Eric Seidel
8ad5f14611 Currently we use package: to mean "/gen", which is not at all how
Dart actually expects package: to work.  This CL makes package:foo
map to /packages/foo, similar to how Dartium or bin/dart would expect.

This also means overlaying the /gen directory over the actual package
outputs (as consumers of an SDK would expect) as well as adding
an additional /lib indirection for the actual package source as
the Dart pub tool will expect.

This is far from perfect, but it unlocks us actually producing a
sky SDK.

I expect there may be some fallout from this change as I'm sure I
missed some package: uses.  We also don't have a general solution
for all /foo/bar/baz includes which randomly included parts
of mojo's source directory.  Those will need to be updated to use
a package: and deploy_sdk.py taught how to build a package for them.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/990493002
2015-03-13 16:58:53 -07:00
Adam Barth
e8b988e226 Expose Android sensors to via Mojo services
This CL adds a sensor_service to sky/services and wires it into SkyShell
The plan is to eventually use this data to implement shake-to-refresh.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/962043002
2015-02-27 14:37:50 -08:00
Eric Seidel
3d09314b22 Make WebView::close not crash and start to fix navigation in SkyShell
However WebView::close() no longer crashes.  close() is never called
in MojoShell since mojo can't shutdown yet.

I tried closing the existing WebView and replacing it
but somehow that caused it to only draw red.  After a while
of looking at this with abarth we decided to just load into
the same WebView for now.

Eventually we should do something smarter where we start the
provisional load and only replace the webview once the new one is
ready, but that's a later CL.

R=abarth@chromium.org
BUG=

Review URL: https://codereview.chromium.org/952273003
2015-02-25 15:25:17 -08:00
Zachary Anderson
b3b197fcf8 Dart: Renames dart:mojo_blah -> mojo:blah
This improves consistency with the convention that the dart: scheme is
only for things from the Dart standard library.

BUG=
R=erg@chromium.org

Review URL: https://codereview.chromium.org/951783004
2015-02-25 14:29:41 -08:00
Rafael Weinstein
e53bba60a5 Add dart_invoke to tonic for calls into App code.
This patch adds utility functions which provide a single choke point for calling into sky application code. For now this is only serving the purpose of having a common trace event for calls into app code.

R=abarth@chromium.org, abarth
BUG=

Review URL: https://codereview.chromium.org/941153003
2015-02-24 12:11:19 -08:00
Adam Barth
16db84fde1 Add a basic sky-element custom element
After this CL, you can use <sky-element> to describe custom elements. The
current iteration is very basic and is hardcoded to "example", but its a start.

This CL renames the |init| function to |_init| to prevent importers from
calling it directly. Also, we now pass the <script> element to |_init| to give
some context.

R=ojan@chromium.org, eseidel@chromium.org

Review URL: https://codereview.chromium.org/950493003
2015-02-20 21:45:36 -08:00
Eric Seidel
c78cea7e54 Allow multiple dart <script> tags in .sky files
This does several things:
1.  Teaches sky about asynchronous script execution. Previously once all imports
were loaded and the script text was available, we executed a script and assumed
it completed synchronously.  We left the parser loop to do so, but that was fine
as the next chunk from the background thread would resume the parser.  In this
change scripts now load and execute separately.  The "load" step may trigger
further dart import loads which may cause the execution to happen asynchronously
which required teaching both the DartController and the HTMLScriptRunner to
take callbacks to allow HTMLDocumentParser to know to continue parsing after
the Dart script has resolved its imports and executed.

This required re-working some of how the parser executes scripts and I
re-purposed isWaitingForScripts to include "is the parser blocked" where
as before it was limited only to "does the treebuilder have a script", even
though the imports system may have had pending scripts as well.

I made HTMLScriptRunner live only as long as the script it was executing
since it only contained per-script state at this point.

2.  Fixed an error reporting bug whereby we would not show errors when "init"
failed to execute, only "main".  This required using the dart_mirrors_api.h
which required adding an include path to the core build. :(

3.  Made it possible for a single sky file to contain multiple dart <script>
tags.  Each <script> is a separate library and executes as
soon as </script> is seen.  main or init is called for each.  This required
mangling "urls" for these script blocks since Dart unique's libraries by urls.
Before this change it may have been possible to do <import 'foo.sky'> and then
<script>import 'foo.sky'</script> and have it work!?

R=abarth@chromium.org
BUG=

Review URL: https://codereview.chromium.org/938623005
2015-02-20 11:08:28 -08:00
Eric Seidel
5e47f9a8f2 Make tests/clipping/canvas-rounded-corners.sky actually run.
Because we dump dart errors to LOG(ERROR) (stderr) instead
of console.log / stdout, tests with dart errors just "pass"
and we don't notice they're not running.

This was the case with canvas-rounded-corners.sky.

I don't think this test actually passes yet, despite it
claiming to, but I at least have made it run and not crash.

Required me commenting out a ton of CanvasRenderingContext2D, but
that's fine, it wasn't actually working and it's better to have
it be compiling valid dart.

R=abarth@chromium.org, ojan@chromium.org
BUG=

Review URL: https://codereview.chromium.org/936563002
2015-02-17 12:25:15 -08:00
Adam Barth
374a768d5b Improve DartLoader error handling.
Before this if a dart import 404s, we crash.
This makes some minor improvements in our logging
for better diagnosis of future errors.

R=abarth@chromium.org
BUG=

Review URL: https://codereview.chromium.org/926753002
2015-02-14 20:18:00 -08:00
Adam Barth
52b56750a1 Rename sky/engine/bindings2 to sky/engine/bindings
There's only one bindings system now.

TBR=eseidel@chromium.org

Review URL: https://codereview.chromium.org/915293003
2015-02-12 20:16:17 -08:00
Adam Barth
c6dce9ad07 Add DartController and friends
This CL adds the DartController and associated classes. These classes let you
load and execute dart code.

R=rafaelw@chromium.org
BUG=454613

Review URL: https://codereview.chromium.org/921903002
2015-02-12 13:34:45 -08:00