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.
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.
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.
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.
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.
- 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
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
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
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
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
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
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