mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This is a proof of concept for replacing ui/views code with Sky instead. erg says this will allow him to delete 10s of thousands of LOC from mojo. Mojo does not yet expose the current binary's URL: https://docs.google.com/a/chromium.org/document/d/1AQ2y6ekzvbdaMF5WrUQmneyXJnke-MnYYL4Gz1AKDos So I've worked around that by passing the url of the binary via the helper script. I discovered several bugs in the wm_flow code including that it doesn't handle view resizes (during embiggen). Related, I discovered that every time a new window is made it drops the connections to the embedded.cc app from the previous window, since the ViewManagerDelegate is incorrectly implemented as part of the ApplicationDelegate on both app.cc and embedded.cc. We'd need to split out a separate per-view object in both of those apps to handle the ViewManagerDelegate calls. There are some changes to logging during loading as well as the CopyToFile helper to have better error reporting. I hit several issues early on trying to get mojo to load the http: urls correctly, including eventually running out of disk space on my /tmp and mojo then silently failing to launch the app (due to mojo never clearing its caches crbug.com/446302). I had to re-write the mojo_demo.sh script in python as well as split the sky_server handling code out of skydb into a separate python module in order to cleanly launch sky_server. We could use a separate server if we wanted to but the primary benefit of sky_server is that it sets up the proper url->disk mappings into the generated file directories, etc. BUG=443439 R=abarth@chromium.org Review URL: https://codereview.chromium.org/817573003
SkyElement
SkyElement is the framework for creating...yup...Sky Elements. It take heavy inspriation from Polymer and isn't very fully featured...yet
Declaring an element
<import src="../path/to/sky-element.sky" as="SkyElement" />
<template>
<my-other-element>Hello, {{ place }}</my-other-element>
</template>
<script>
// SkyElement takes a single object as it's only parameter
SkyElement({
name: 'my-element', // required. The element's tag-name
attached: function() {
this.place = 'World';
}, // optional
detached: function() {}, // optional
attributeChanged: function(attrName, newValue, oldValue) {} // optional
});
</script>
Note that an element's declared ShadowDOM is the previous <template>
element to the <script> element which defines the element.
Databinding
SkyElement's databinding support is derived from Polymer's. At the moment, there are some key differences:
There is not yet support for
- Declarative event handlers
- Inline expressions
- Self-observation (e.g.
fooChanged()gets invoked whenthis.foois changed) - Computed properties (e.g. the computed block)
- Conditional attributes (e.g.
<my-foo checked?="{{ val }}")
Also, because there are so few built-in elements in Sky, the default behavior of HTMLElement with bindings is to assign to the property. e.g.
<my-foo bar="{{ bas }}">
Will not setAttribute on the my-foo, instead it will assign to the bar
property of my-foo. There are two exceptions to this: class & style --
those stillsetAttribute.