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.
Turns out I had misimplemented Rect.center.
While I was here, I also implemented Rect.width and Rect.height (to
help avoid making that mistake again), and copied shortestSide from
Side to Rect so that we can avoid having to allocate a Size to get the
shortest side from a Rect.
R=abarth@chromium.org
Review URL: https://codereview.chromium.org/1216013003.
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.
New asserts:
- verify that after layout, the size fits the constraints
- verify that after layout, the size isn't infinite
- verify that you don't set the size in performLayout() if you have
sizedByParent set
- verify that nobody reads your size during layout except you, or your
parent if they said parentUsesSize:true
Fixes some bugs found by those asserts:
- RenderBlock, RenderStack, and RenderScaffold were not always setting
parentUsesSize correctly
- RenderScaffold was setting its slot entries to null rather than
removing them when the slot went away, which led to null derefs in
certain circumstances
Also, rename a local variable in RenderStack.performLayout() because
it was shadowing a variable on the object itself, which was really
confusing when I first tried to debug this function...
R=abarth@chromium.org
Review URL: https://codereview.chromium.org/1213473003.
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 also fixes the C++ side to give the right baseline information.
Previously it was giving the baseline distance for the font, but not
for the actual laid-out text.
I considered also providing a "defaultBaseline" accessor that returns
the distance for the actual dominant baseline, but it turns out right
now we never decide the baseline is ideographic. We always use the
alphabetic baseline. We should probably fix that...
R=eseidel@chromium.org
Review URL: https://codereview.chromium.org/1200233002.
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.
This file doesn't belong in the SDK because it is an implementation detail of
the Sky engine. Instead, this CL moves the code for dart:sky.internals into the
snapshot. This CL is a step towards merging dart:sky.internals with dart:sky,
which also resides in the snapshot.
R=eseidel@chromium.org
Review URL: https://codereview.chromium.org/1200953007.
Previously, the wavy underline code only knew how to draw a complete
period.
This change adds the ability to draw a partial period of the wave.
Previously, the code tried, but failed, for reasons I cannot
determine, to fit the width of the inline by extending the period to
be an integral factor of the width.
This is bad because as you type text, the underline wave of earlier
characters would jiggle.
This fixes that by not changing the period of the wave when the length changes.
It's interesting to compare this to the previous code. Here's a test
that shows this in Safari/Chrome:
http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=3543
Notice how as you type "i"s, the underline changes how far it extends
(obviously a bug) but also what the period of the wave is (which looks
especially ugly when typing).
Firefox, on the other hand, renders something that isn't actually a
wave; it's a saw-tooth pattern with straight lines between each
direction change. This works for small font sizes at low densities,
but is not great on modern screens.
This CL addresses this issue by computing the bezier curve control
points for the curve that consists of just the remaining fraction of
the period. To do this, however, it allocates an object and solves a
bezier for x (which includes a numerical integration), which is
certainly a performance concern. Apps that try to wavy-underline an
entire UI are going to maybe suffer. Since this is typically going to
be used for spelling checkers, it means people who spell better will
have better performance.
(I haven't tested this to see what the perf impact actually is. If
it's actually bad, we can probably cache the results of the
integration pretty trivially.)
R=eseidel@chromium.org
Review URL: https://codereview.chromium.org/1189403005.
We've had a number of reports of a missing dependency in the build. I managed
to reproduce the issue locally today and this patch fixed the issue I was
seeing. Hopefully it fixes the issues other folks were seeing too.
The problem was that the C++ code we generate from IDL files depended on
various event classes in core, which in turn depended on the generated event
names files. This CL ensures that the event names files are created before we
try to build the C++ code generated from the IDL files.
TBR=eseidel@chromium.org
Review URL: https://codereview.chromium.org/1178173004.