80 Commits

Author SHA1 Message Date
Adam Barth
63b6ffb281 Normalize import paths for Sky modules
This CL simplifies the sky_server to only map the build directory into /gen,
which will make the deploy script simpler. This CL updates all the imports to
use the /gen prefix when referring to generated files.

TBR=eseidel@chromium.org

Review URL: https://codereview.chromium.org/881093003
2015-01-27 17:04:40 -08:00
Adam Barth
a251a157a7 The scrollbar in sky-scrollable should fade in and out
Also, move the vbar after the scrollable div so that it draws on top.

R=esprehn@chromium.org

Review URL: https://codereview.chromium.org/879003002
2015-01-27 11:11:49 -08:00
Adam Barth
c3fc9e9663 Add wheel support to sky-scrollable
This CL plumbs wheel events through Sky again and uses them in sky-scrollable.

R=ojan@chromium.org

Review URL: https://codereview.chromium.org/876853005
2015-01-27 09:58:22 -08:00
Adam Barth
73d3d84b27 Add a scrollbar to sky-scrollable
Ideally the scrollbar would animate out when you stop scrolling, but we're not
quite that good yet.

R=ojan@chromium.org

Review URL: https://codereview.chromium.org/882583002
2015-01-26 21:37:25 -08:00
James Robinson
dddf8f294f Remove Client relationship between mojo.Shell/mojo.Application
Instead of mojo.Shell and mojo.Application being clients of each other
they are now separate interfaces. An implementation of mojo.Application
receives a handle to the shell in its Initialize call, as described in
this doc:

https://docs.google.com/document/d/1xjt_TPjTu0elix8fNdBgWmnjJdJAtqSr1XDS_C-Ct8E/edit?usp=sharing

An analogous change is made to the content handler definition.

In C++, this is handled by the mojo::ApplicationImpl class which stores
shell handle in its implementation of Initialize. Thus the only change
for most C++ applications is the meaning of the handle in MojoMain is
different, although mains that use the ApplicationRunners do the same
thing with it.  Connecting to other apps is largely the same although
instead of grabbing the ApplicationImpl's client() to talk to the shell
code must now use the ApplicationImpl::shell() getter.

In JavaScript, the initialization sequence is a bit different although
this is hidden mostly in the Application class which calls initialize()
on its subclass with the same set of parameters. Connecting to another
application looks different, especially for sky code using the shell
proxy handle exposed via internals. Hans has some ideas about how to
make this a bit nicer.

Python apps similarly need to change their startup sequence a bit. I
didn't find a common library to take care of this dance, although it's
possible I just missed it.

Other languages probably a bit of reworking - I fixed everything here
that is covered by mojob.py test but some might be missing.

This patch also uses typed handles (i.e. InterfacePtr<> or
InterfaceRequest<> or their type aliases) wherever possible instead of
ScopedMessagePipeHandle for clarity.

R=davemoore@chromium.org

Review URL: https://codereview.chromium.org/868463008
2015-01-26 17:53:08 -08:00
Adam Barth
d05380e397 sky-scrollable should use a reasonable fling curve
This CL uses the aura fling curve to ease flings. Also, I've made Event#timeStamp
use consistent units and timebase with the requestAnimationFrame timestamp. Now
both are doubles of milliseconds since the epoch.

R=esprehn@chromium.org

Review URL: https://codereview.chromium.org/880473003
2015-01-26 17:34:28 -08:00
Adam Barth
7ded81cc4f Add a basic sky-scrollable element that scrolls
We still need to polish sky-scrollable, but it basically works.

R=esprehn@chromium.org

Review URL: https://codereview.chromium.org/875953004
2015-01-26 13:29:38 -08:00
Adam Barth
c51ca09e15 Move sky-box,-button,-checkbox,-radio out of their directories
Instead of having a separate directory for every Sky element, we should just
put them in the general framework directory. Once the framework is more
complicated, we'll probably want to organize it a bit better, but for now there
aren't enough files to justify having so many directories.

R=esprehn@chromium.org

Review URL: https://codereview.chromium.org/874303003
2015-01-26 09:20:25 -08:00
Adam Barth
3ddae5ea36 Switch KeyboardEvents over to NewEventHandler
This CL moves KeyboardEvents from the old event model to NewEventHandler. This
CL keeps the basic structure of keydown, keypress, keyup events even though
that's a bit wacky. As with pointer and gesture events, this CL removes
PlatformKeyboardEvent in favor of just using WebKeyboardEvent. I've also made
WebKeyboardEvent align more closely with Mojo's keyboard event.

The CL does change one important aspect of key event handling: on the web the
"keyCode" property of KeyboardEvent changes its meaning depending on whether
the event is a keydown or a keypress event. For the former events, keyCode is
the "virtual" (i.e., windows) key code where for the latter events, keyCode is
the character code. To be more precise, I've renamed keyCode to virtualKeyCode
and I've given it a zero (unknown key code) value during keypress events.

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

Review URL: https://codereview.chromium.org/872233002
2015-01-25 22:46:50 -08:00
Elliott Sprehn
0275d42ac7 Add the <t> element and ignore whitespace outside it.
We now only preserve the whitespace inside a <t> element inside
the parser. This removes the known n^2 from reattaching whitespace
which should make parsing and appending nodes faster. I also
removed the dead WhitespaceMode code from the parser, and made
the dom-seralizer.sky auto indent the markup so the test output
would be readable.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/867963006
2015-01-23 16:50:00 -08:00
Adam Barth
b361c4b6c3 Switch Sky to pointer events
This CL switches Sky to a pointer events model that unifies mouse and touch
with a common event model. This implementation is just enough to make the
example widgets work. The rest of the design is in the specs, which we hope to
converge with over time.

R=ojan@chromium.org

Review URL: https://codereview.chromium.org/866213004
2015-01-23 09:38:45 -08:00
Elliott Sprehn
9612dcf25f Don't set expression attributes before they're bound.
We were cloning elements with all the attributes that contained
expressions like attrName="{{ foo }}" which meant we'd go through the
reflection process converting that value and also call the
attrNameChanged() callback and the attributeChanged() with the braced
string which the element didn't really want to know about.

After this patch we create a "clone source node" which is a copy of the
original element without the attributes that have the expressions and
use that when cloning, then we assign the properties using data binding
later.

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

Review URL: https://codereview.chromium.org/868973002
2015-01-22 17:04:10 -08:00
Benjamin Lerman
69be2dee41 Adding keyboard service.
This allows to show the soft keyboard on Android.

Also updated platform_viewport_android to dispatch key events.

R=abarth@chromium.org
BUG=449002

Review URL: https://codereview.chromium.org/856063002
2015-01-22 10:19:09 +01:00
Elliott Sprehn
5e18888a0b Be more strict about attributes in sky-binder.
Instead of making all the built in attributes be global we match them to the
elements they actually apply to. I also removed a bunch of attributes that no
longer work in Sky (but haven't been removed from HTMLAttributeNames.in) yet,
or which we plan to remove.

I also removed the title property from HTMLElement. The <sky-box> widget forgot
to declare its title attribute and no error was generated because of the title
property existing on all elements. Sky doesn't have this so lets remove the API
now and clean up the C++ later.

R=ojan@chromium.org

Review URL: https://codereview.chromium.org/807243003
2015-01-16 14:41:07 -08:00
Elliott Sprehn
9650c274b6 Fix <sky-input> data binding when editing deletes the last char.
contenteditable would remove the Text node inside the
editable area which would mean setting the value attr
of the <sky-input> would stop updating the editable
area.

Instead we add the text back if editing removed it.

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

Review URL: https://codereview.chromium.org/788953006
2015-01-16 14:39:03 -08:00
Elliott Sprehn
8291177a0c Combine element registries from sky-binder and sky-element.
We now have an element-registry.sky module that exposes API to register
elements with attributes and event handlers. Right now it's an API on
the module itself, eventually the module will export an ElementRegistry
object since we'll need one per module once the custom element registry
is one per module.

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

Review URL: https://codereview.chromium.org/856693002
2015-01-15 20:31:32 -08:00
Elliott Sprehn
fb18e53311 Require a type for SkyElement attributes.
Instead of defaulting to string require a specific type.

R=ojan@chromium.org

Review URL: https://codereview.chromium.org/858453002
2015-01-15 17:34:26 -08:00
Elliott Sprehn
f607133c18 Turn on harmony arrays and regexp.
adamk@ says these are pretty stable.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/845403009
2015-01-15 17:12:17 -08:00
Elliott Sprehn
5ef6774cd9 Add two way data binding.
All reflected attributes two way bind on SkyElement, so now doing
<sky-element name="sky-input" attributes="value:string"> is enough
to get two way binding on the value attribute so users doing
<sky-input value="{{ inputValue }}"> will get the inputValue property
updated as the user types.

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

Review URL: https://codereview.chromium.org/850383002
2015-01-15 15:03:44 -08:00
Tony Gentilcore
8c6f9a4a57 Fix inspector unittests.
BUG=
R=ojan@chromium.org

Review URL: https://codereview.chromium.org/821643007
2015-01-14 11:32:24 -08:00
Tony Gentilcore
3cce869dd5 Convert the inspector framework to use ES6 classes.
BUG=
R=esprehn@chromium.org

Review URL: https://codereview.chromium.org/837933003
2015-01-13 18:49:43 -08:00
Elliott Sprehn
0a258c1921 Allow on-* event handlers on <sky-element>.
Now instead of calling addEventListener inside the created() callback you just
add on-{eventName} attributes to the <sky-element> around your element
definition. The attribute defines what method on your element to call when the
event with {eventName} is dispatched through your element.

Implementing this required refactoring how sky-element.sky stored information
from each registered element. Now instead of storing just a map of templates
we store a map of ElementRegistration objects which have metadata about the
element. Future patches will combine this system with the element registration
system in sky-binder.

R=ojan@chromium.org

Review URL: https://codereview.chromium.org/845283003
2015-01-12 18:25:22 -08:00
James Robinson
375d0f44e0 Remove client relationship between sky::Inspector{Front,Back}end
This removes the client relationship between the sky::InspectorFrontend
and sky::InspectorBackend mojo interfaces. Instead, the two are now
unrelated (in the mojom) and just happen to be often used together.
The inspector service provides the InspectorFrontend interface to
connecting applications and optimistically tries to connect to the
InspectorBackend interface of applications that connect, in case they
want to receive messages.  The front and back end interfaces are both
broadcast APIs, so no attempt is made to keep track of which binding
is which. If they did need to be correlated this could be easily
accomplished by allocating a new object to keep a
mojo::Binding<sky::InspectorFrontend> and the corresponding
sky::InspectorBackendPtr.

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

Review URL: https://codereview.chromium.org/835463003
2015-01-09 14:50:39 -08:00
Elliott Sprehn
a25c88d9c6 console.error when using unknown attributes in templates.
Log an error whenever an element has an unknown attribute in a template.
This means you can't use generic attributes like Polymer, but we
probably want to discourage that anyway since attribute selectors should
be avoided for most things.

R=ojan@chromium.org

Review URL: https://codereview.chromium.org/845523004
2015-01-08 16:52:12 -08:00
Elliott Sprehn
6352ce5f7e Prevent expandos on all SkyElements.
Expandos make v8 sad, lets not allow them.

R=ojan@chromium.org

Review URL: https://codereview.chromium.org/835353004
2015-01-08 15:30:18 -08:00
Adam Barth
3b86add20e Flex the inside of the input control
We really need delegated focus from the container to the control, but this will
do for now.

TBR=esprehn@chromium.org

Review URL: https://codereview.chromium.org/844763004
2015-01-08 13:29:30 -08:00
Adam Barth
64a7d49358 Implement <sky-input>
This CL contains a basic input element.

R=esprehn@chromium.org

Review URL: https://codereview.chromium.org/831353003
2015-01-08 13:22:00 -08:00
Eric Seidel
1ff137055e Move wm_flow off of views and onto Sky
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
2015-01-06 14:40:41 -08:00
Elliott Sprehn
6d61fe6ce8 Automate reflected properties in SkyElement.
Now you can use the attributes attribute on <sky-element> that
accepts a set of name:type comma separated pairs to control
the reflected attributes. ex. attributes="size:number"

Each attribute creates a getter and a setter on the element that returns
the correct type and will coerce the string attribute values into the
right type. It also correctly hooks into the data binding system.

A new callback is added: {name}Changed(oldValue, newValue) which will
be invoked whenever the attribute with that name changes and gets the
correctly coerced type values. See the <sky-radio> or <sky-checkbox>
widgets for examples of using the new callback.

Number attributes default to 0, booleans to false, and strings to empty
string. There is no way provided to set a different default, for that you
can use hasAttribute in the created callback to conditionally set a value.
Don't just assign the property there otherwise you'll overwrite the value
from the parser.

Another behavior change from making this work is that now attributeChanged()
is called for each attribute, even when the element is created by the
parser.

Overall this allows a nice simplification to the <sky-button>,
<sky-radio> and <sky-checkbox> widgets.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/836923002
2015-01-05 20:12:58 -08:00
Elliott Sprehn
84c4c1eb69 Improve the appearance of <sky-checkbox>
The unicode char never showed up for me, lets do what polymer does for
now.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/836723006
2015-01-05 14:28:16 -08:00
Elliott Sprehn
ceb4dbc927 Fix detached callback and add isAttached to SkyElements.
There was a typo in the name of the detached callback which is now fixed,
and also allow querying if an element is attached.

R=rafaelw@chromium.org

Review URL: https://codereview.chromium.org/806133003
2015-01-05 12:54:43 -08:00
Hans Muller
0333bd80a7 Mojo JS Bindings: Eliminate foo$ and Stub and Proxy class members
Warning: this change will require Chrome changes. See
https://codereview.chromium.org/803173009/#msg6.

Added ProxyBindings and StubBindings methods that expose
bindings-related properties for generated Proxy and Stub classes
without risking name collisions.

Outgoing "in/out" interface valued parameters are now specified as
functions that are applied to the out value.

Note: the leading capital in the Proxy,StubBindings() methods is
unconventional. It seemed OK given their unusual role: they can be
viewed as transformers from "Foo" objects to "FooBindings" objects.

BUG=
R=esprehn@chromium.org

Review URL: https://codereview.chromium.org/803173009
2015-01-05 12:46:09 -08:00
Elliott Sprehn
a897ad7053 Fix resource clean up in TemplateIterator.close()
I had forgotten to rename the properties here.

TBR=ojan@chromium.org

Review URL: https://codereview.chromium.org/829993004
2015-01-03 12:40:42 -08:00
Elliott Sprehn
213c093956 Add a basic SkyBinder test.
TBR=ojan@chromium.org

Review URL: https://codereview.chromium.org/831033002
2015-01-02 19:56:45 -08:00
Elliott Sprehn
1a21f72ed5 Switch to SkyBinder
SkyBinder is a rewrite of TemplateBinding.sky that uses classes and weak maps
and doesn't add expandos to any of the DOM objects.

It has a few differences from TemplateBinding.sky:
- null doesn't create instances in repeats.
- One time bindings are removed ([[ expr ]]), we'll add them back later.
- The bind attribute is removed.

The system is also less generic and is specialized to be used when
creating SkyElement instances.

The commit history that created SkyBinder can be found at:
https://github.com/esprehn/sky-binder/commits/master

TBR=ojan@chromium.org

Review URL: https://codereview.chromium.org/821353003
2015-01-02 19:42:13 -08:00
Elliott Sprehn
d3fbe58e94 Add shadowRootReady callback for SkyElement.
This is called right after stamping the template into the ShadowRoot.
This is a useful place to querySelector/getElementById for elements
inside the ShadowRoot.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/817053002
2014-12-19 14:01:49 -08:00
Elliott Sprehn
c7d8c77498 Add declarataive event handlers.
Now inside the <template> of a SkyElement you can use
on-eventName="method" on any element to add event listeners.

For example you can write <sky-button on-click="handleClick">
and then define handleClick(event) on the element class that
contains the button.

In adding this and tests I also realized that property bindings
were not setup on the initial call to bind(), which is now
fixed in this patch (See change to Node.prototype.bind).

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

Review URL: https://codereview.chromium.org/812713005
2014-12-19 13:10:16 -08:00
Eric Seidel
bdaf418370 Add super-basic sky widgets.
Eventually we'll want to replace these with something
fancier like polymer, but this exercise helped us
find several bugs in the engine as well as
removed one more blocker from using Sky to
replace mojo/views usage in mojo/examples.

R=esprehn@chromium.org
BUG=443439

Review URL: https://codereview.chromium.org/809233002
2014-12-18 13:01:43 -08:00
Eric Seidel
0b8c9cf3ac Use existing unicode.sky instead of re-inventing
I somehow missed this function the first time.

This is already tested by
tests/framework/xmlhttprequest/unicode-post.sky

R=esprehn@chromium.org
BUG=

Review URL: https://codereview.chromium.org/806043002
2014-12-17 12:11:42 -08:00
Elliott Sprehn
b3400475d5 Make SkyElement more classy.
The syntax for implementing a SkyElement is now:

<sky-element name="element-name">
<template>
  <!-- template here -->
</template>
<script>
module.exports = class extends SkyElement {
  attached() {
     // ...
  }
  // .. methods here ..
}.register();
</script>
</sky-element>

The register() static method on SkyElement subclasses calls
document.registerElement() and returns the generated constructor.
It uses the parent <sky-element>'s name attribute to set the name
of the element.

R=rafaelw@chromium.org

Review URL: https://codereview.chromium.org/788943003
2014-12-16 16:28:28 -08:00
Eric Seidel
a9776838ee Add POST support to XHR as well as .status and statusText support
Also fixed all the XHR tests to actually run and work
I learned from elliot that the it function has to
take a "done" argument to be treated asynchronously.

My utf8 conversion is a hack, but we deleted
window.TextEncoder (it was a module) when we forked.
We could resurrect TextEncoder (and probably should)
but I've left that for a separate change.

I also augmented sky_server to have a special /echo_post
handler so we can test POST requests.

R=esprehn@chromium.org
BUG=

Committed: 5ef81d249b

Review URL: https://codereview.chromium.org/810523002
2014-12-16 11:20:40 -08:00
Eric Seidel
1fb39d65dd Revert "Add POST support to XHR as well as .status and statusText support"
This reverts commit 5ef81d249b841f44c9593ffb0158d64c7e0febfc.

This appeared to make 5 XHR tests timeout.  Not sure why yet.
TBR=esprehn@chromium.org

Review URL: https://codereview.chromium.org/808663002
2014-12-15 18:37:44 -08:00
Eric Seidel
6f33a75051 Add POST support to XHR as well as .status and statusText support
Also fixed all the XHR tests to actually run and work
I learned from elliot that the it function has to
take a "done" argument to be treated asynchronously.

My utf8 conversion is a hack, but we deleted
window.TextEncoder (it was a module) when we forked.
We could resurrect TextEncoder (and probably should)
but I've left that for a separate change.

I also augmented sky_server to have a special /echo_post
handler so we can test POST requests.

R=esprehn@chromium.org
BUG=

Review URL: https://codereview.chromium.org/810523002
2014-12-15 16:09:51 -08:00
Eric Seidel
6bd317d504 Add responseType='arraybuffer' support to XHR
Also moved existing XHR tests from tests/services
to tests/framework to better match the location
of the XHR code itself.

R=ojan@chromium.org

Review URL: https://codereview.chromium.org/805503002
2014-12-12 12:03:50 -08:00
Colin Blundell
a450ba1353 Restructure public side of network service.
This CL goes from this:
  //mojo/services/public/cpp/network
  //mojo/services/public/interfaces/network

to this:
  //mojo/services/network/public/cpp
  //mojo/services/network/public/interfaces

This CL also makes the Mojo-side changes required to roll this change into
Chromium.

TBR=beng

Review URL: https://codereview.chromium.org/789243002
2014-12-10 16:28:40 +01:00
Elliott Sprehn
f1a6cd9799 Use a JS markup serializer.
This makes MarkupAccumulator and all related code into dead code.

R=ojan@chromium.org

Review URL: https://codereview.chromium.org/771093002
2014-12-02 10:09:35 -08:00
Yury Semikhatsky
b22d85f975 Populate scope sections with variable name/values
Now when debugger is paused scope sections are properly populated with corresponding name:value pairs for all variables.

Eventually InjectedScript may become something like a regular Sky module but at the moment I don't see how to do this gracefully given that it is parametrised by InjectedScriptHost binding. So at the moment I just store it in "injectedScript" property on the global object,

BUG=435243
R=abarth@chromium.org

Review URL: https://codereview.chromium.org/766683005
2014-11-27 21:00:06 +03:00
Elliott Sprehn
253b5bed74 Only allow one shadowRoot.
R=ojan@chromium.org

Review URL: https://codereview.chromium.org/759663003
2014-11-26 13:54:14 -05:00
Adam Barth
a2aedc2d68 Move XMLHttpRequest#responseText to a getter
Moving this property to a getter lets the implementation of the object change
the value but prevents clients of the API from changing the value, which is the
expected behavior.

R=esprehn@chromium.org

Review URL: https://codereview.chromium.org/746953002
2014-11-21 00:09:50 -08:00
Adam Barth
1766fb0ba7 Hide XMLHttpRequest's private state using Symbol
It's not really hidden because you can reflect out the symbols, but this is a
start. We might use a WeakMap in the future if we really need hiding.

R=esprehn@chromium.org

Review URL: https://codereview.chromium.org/753473002
2014-11-21 00:00:44 -08:00