John J Barton | 9 Feb 19:15

connection ceremony for iframe postMessage communications

Recently I've been working with iframe messaging. The postMessage
solution has a lot of advantages and good traction across iframes,
WebWorkers, and browser extensions, with lots of overlap with Web
Sockets.

However the technology has two significant problems.  First is the
"contentWindow that is not a window" confusion I discussed recently.
Second concerns the connection setup. I describe the second problem
here.

The basic communications solution is simple enough:
  window.addEventListener('message', handler, false);  // I'm listening!
  portToOtherWindow.postMessage(message);  // I'm talking to you!

However the solution has two significant problems:
  1. There is no way to know if portToOtherWindow is connected before
you issue postMessage()
  2. All iframes send messages to the same "handler".

The first problem arises because web apps are increasingly
asynchronous for load performance and other reasons.

This leads developers to look for events that will tell them about
'load' on iframes, and that leads them to try
iframe.contentWindow.addEventListener(). It works fine for same-domain
iframes, but fails for cross-domain.

The second problem arises because the handler is attached to the
window and not to an object related to the connection between the two
windows.
(Continue reading)

John J Barton | 9 Feb 18:04

xframe or iframe type='cross-domain'

I've been working with cross-domain iframes. This technology has a lot
of potential, but the current API is very difficult to use. Just
search the web for cross-domain iframe info and you can read how many
developers are confused.

I believe a simple change could make a huge difference. My suggestions
are related to http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html

The current model for a cross-domain iframe is "it's just a restricted
same-domain iframe". So both iframes have a contentWindow property as
their key API anchor. Sounds consistent and economical. But it's not,
because developer code written to process contentWindow references
cannot work with cross-domain iframe contentWindow objects.

As far as I can tell, a cross-domain iframe contentWindow has only one
valid property, postMessage(). By no stretch of anyone's imagination
is the object a "window". Calling this thing we get a "contentWindow"
is a mean lie to developers; it forces us into "Exception-oriented
programming" where we try every recipe on the Web looking for
something that does not emit errors.

On the other hand, there is an important Web API focused on
postMessage() as outlined in the spec above. Generally (though not
exclusively) the spec refers to objects with postMessage() as "ports".

Thus my proposal:
  1. create a spec-only base class element with the current properties
of iframe, except no "contentWindow" or "contentDocument"
  2. inherit iframe from the spec-only base class, add contentWindow
and contentDocument
(Continue reading)

Rick Waldron | 9 Feb 15:56
Picon
Gravatar

Templates 2: The Real World

Hey everyone, 

I've been following the "HTML Parsing and the <template> element" thread/conversation since it began yesterday and it's very interesting, but one thing keeps coming to mind - has anyone working on <template> spent any significant time using the existing web "template" systems and practices? 

Here are a few that are fairly common and in production use:

Mustache.js (logic-less)

Embedded.js (logic)

JST (gaining developer mindshare)

This list is by no means intended to be comprehensive or to imply any endorsement - in fact, I don't use any of these (I use underscore.js's super simple "pre-compiled" templates)



Benchmarking information:


Rick
Ms2ger | 9 Feb 13:26
Picon

[clipboard] Event definition

Hi Hallvord,

At 
<http://dev.w3.org/2006/webapi/clipops/clipops.html#clipboard-event-interface>, 
a reference to DOM *2* Events is made; it should be updated.

Also, the initClipboardEvent method should be removed in favour of a 
constructor, as described at 
<http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#constructing-events>.

HTH
Ms2ger

Arthur Barstow | 9 Feb 13:08
Picon

CfC: publish WD of Clipboard API and events; deadline February 16

This is a Call for Consensus to publish a new WD of the Clipboard API 
and events spec using the latest ED as the basis (Hallvord has not yet 
prepared it for publication in /TR/):

    http://dev.w3.org/2006/webapi/clipops/clipops.html

Agreement to this proposal: a) indicates support for publishing a new 
WD; and b) does not necessarily indicate support of the contents of the WD.

If you have any comments or concerns about this proposal, please send 
them to public-webapps by February 16 at the latest.

As with all of our CfCs, positive response is preferred and encouraged 
and silence will be assumed to be agreement with the proposal.

-ArtB

Adam Barth | 9 Feb 00:16

Re: [webcomponents] HTML Parsing and the <template> element

On Wed, Feb 8, 2012 at 2:47 PM, Rafael Weinstein <rafaelw <at> chromium.org> wrote:
> Here's a real-world example, that's probably relatively simple
> compared to "high traffic" web pages (i.e. amazon or facebook)
>
> http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/template/api_template.html?revision=120962&content-type=text%2Fplain
>
> that produces each page of the chrome extensions API doc, e.g.
>
> http://code.google.com/chrome/extensions/contextMenus.html
>
> This uses jstemplate. Do a search in the first link. Every time you
> see "jsdisplay" or "jsselect", think <template>.

It's a bit hard for me to understand that example because I don't know
how jstemplate works.

I'm just suggesting that rather than trying to jam a square peg
(<template>) into a round hole (the HTML parser), there might be a way
of reshaping both the peg and the hole into an octagon.

Adam

> On Wed, Feb 8, 2012 at 2:36 PM, Adam Barth <w3c <at> adambarth.com> wrote:
>> On Wed, Feb 8, 2012 at 2:20 PM, Erik Arvidsson <arv <at> chromium.org> wrote:
>>> On Wed, Feb 8, 2012 at 14:10, Adam Barth <w3c <at> adambarth.com> wrote:
>>>> ... Do you have a concrete example of
>>>> where nested <template> declarations are required?
>>>
>>> When working with tree like structures it is comment to use recursive templates.
>>>
>>> http://code.google.com/p/mdv/source/browse/use_cases/tree.html
>>
>> I'm not sure I fully understand how templates work, so please forgive
>> me if I'm butchering it, but here's how I could imagine changing that
>> example:
>>
>> === Original ===
>>
>> <ul class="tree">
>>  <template iterate id=t1>
>>    <li class="{{ children | toggle('has-children') }}">{{name}}
>>      <ul>
>>        <template ref=t1 iterate=children></template>
>>      </ul>
>>    </li>
>>  </template>
>> </ul>
>>
>> === Changed ===
>>
>> <ul class="tree">
>>  <template iterate id=t1>
>>    <li class="{{ children | toggle('has-children') }}">{{name}}
>>      <ul>
>>        <template-reference ref=t1 iterate=children></template-reference>
>>      </ul>
>>    </li>
>>  </template>
>> </ul>
>>
>> (Obviously you'd want a snappier name than <template-reference> to
>> reference another template element.)
>>
>> I looked at the other examples in the same directory and I didn't see
>> any other examples of nested <template> declarations.
>>
>> Adam

Dimitri Glazkov | 8 Feb 23:00

[webcomponents] HTML Parsing and the <template> element

Hello folks!

You may be familiar with the work around the <template> element, or a
way to declare document fragments in HTML (see
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-November/033868.html
for some background).

In trying to understand how this newfangled beast would work, I
started researching HTML parsing, and--oh boy was I ever sorry! Err..
I mean.. --and investigating how the contents of the <template>
element could be parsed.

So far, I have two ideas. Both introduce changes to HTML parsing
algorithm. Both have flaws, and I thought the best thing to do would
be to share the data with the experts and seek their opinions. Those
of you cc'd -- you're the designated experts :)

== IDEA 1: Keep template contents parsing in the tokenizer ==

PRO: if we could come up with a way to perceive the stuff between
<template> and </template> as a character stream, we enable a set of
use cases where the template contents does not need to be a complete
HTML subtree. For example, I could define a template that sets up a
start of a table, then a few that provide repetition patterns for
rows/cells, and then one to close out a table:

<template id="head"><table><caption>Nyan-nyan</caption><thead> ...
<tbody></template>
<template id="row"><tr><template><td> ... </td></template></tr></template>
<template id="foot"></tbody></table></template>

Then I could slam these templates together with some API and produce
an arbitrary set of tables.

PRO: Since the template contents are parsed as string, we create
opportunities for performance optimizations at the UA level. If a
bunch of templates is declared, but only a handful is used, we could
parse template contents on demand, thus reducing the churn of DOM
elements.

CON: Tokenizer needs to be really smart and will start looking a lot
like a specialized parser. At first glance, <template> behaves much
like a <textarea> -- any tags inside will just be treated as
characters. It works until you realize that templates sometimes need
to be nested. Any use case that involves building a
larger-than-one-dimensional data representation (like tables) will
involve nested templates. This makes things rather tricky. I made an
attempt of sketching this out here:
http://dvcs.w3.org/hg/webcomponents/raw-file/a28e16cc4167/spec/templates/index.html#parsing.
As you can see, this adds a largish set of new states to tokenizer.
And it is still incomplete, breaking in cases like
<template><script>alert('<template> is
awesome!');</script></template>.

It could be argued that--while pursuing the tokenizer algorithm
perfection--we could just stop at some point of complexity and issue a
stern warning for developers to not get too crazy, because stuff will
break -- akin to including "</script>" string in your Javascript code.

== IDEA 2: Just tweak insertion modes ==

PRO: It's a lot less intrusive to the parser -- just adjust insertion
modes to allow <template> tags in places where they would ordinary be
ignored or foster-parented, and add a new insertion for template
contents to let all tags in. I made a quick sketch here:
http://dvcs.w3.org/hg/webcomponents/raw-file/c96f051ca008/spec/templates/index.html#parsing
(Note: more massaging is needed to make it really work)

CON: You can't address fun partial-tree scenarios.

Which idea appeals to you? Perhaps you have better ideas? Please share.

:DG<

Picon
Favicon

CfC by 02-14: Add IME API to the charter

Hi,

thanks to Mike and the Google guys, we have  
http://dvcs.w3.org/hg/ime-api/raw-file/default/use-cases/Overview.html  
which explains what an IME API would do and why it would be useful. I  
believe we have editors but it doesn't name a test facilitator (don't  
blame me, Art chose that as the name ;) ) and we need one. I am assuming  
that will be forthcoming, so this is a formal call for Consensus to add  
this item to the charter.

Silence will be considered assent, positive response is preferred, and the  
deadline is the end of Tuesday 14th February.

cheers

Chaals

--

-- 
Charles 'chaals' McCathieNevile  Opera Software, Standards Group
     je parle français -- hablo español -- jeg kan litt norsk
http://my.opera.com/chaals       Try Opera: http://www.opera.com

Michael[tm] Smith | 8 Feb 03:06
Picon
Favicon
Gravatar

Enabling a Web app to override auto rotation?

About portrait-landscape auto rotation on current mobile/tablet
browsers/platforms: If a user has auto rotation set on their mobile or
tablet, I know it's possible for a particular native application to
override that setting and stay in whatever screen orientation it wants.

My question is if it is currently possible for a Web application to do the
same thing; that is, to prevent the browser on the device from
auto-rotating into a different mode. 

  --Mike

--

-- 
Michael[tm] Smith
http://people.w3.org/mike/+

Dimitri Glazkov | 7 Feb 20:41

[webcomponents] Considering declarative event handlers

Folks,

To make Web Components more usable, I would like to consider providing
a way to declare event handlers in markup. As I look over the use
cases and try to implement them using the proposed syntax
(http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html),
a pattern emerges, where a bunch of event handlers is declared and
registered early in the lifecycle of the custom elements
(http://dvcs.w3.org/hg/webcomponents/raw-file/tip/samples/entry-helper.html,
http://dglazkov.github.com/Tabs/tabs-control.js as rough examples).

Even thought it's a perfectly workable solution, it also implies that
we must run script in order to just write up the events. However,
given that the <template> element takes care of setting up the initial
state of the shadow DOM subtree for the custom element, in many
controls, the only script that runs during initialization will be just
wiring up events.

It seems that we can do better. Consider this inspirational example
(loosely reimagines Internet Explorer's existing functionality
http://msdn.microsoft.com/en-us/library/ms533746(v=vs.85).aspx):

<element name="x-tab-manager">
<template>
<div class="container">
...
<div class="overflow">
    <script event="click">
        // "this" is the parent div element.
        // "event" is the current event object.
        if (event.target.className != 'more')
            return;
        if (this.moreOpened)
            this.closeMore();
       ...
    </script>
</div>

...

</div>
</template>
</element>

In other words, this imaginary new thing will operate similarly to the
<style scoped>, where it registers an event handler on the parent
element of its declaration.

The pros are:
* It's declarative and intuitively logical
* The script does not have to run (or even compile) until event fires
* The author does not need to imperatively go find the element in the
tree to attach an event handler to it

The cons are:
* It's a new syntax
* It doesn't allow to close over the event handler code, which is a
common way to manage variable scoping in JS.

I would appreciate any thoughts, ideas, or results of existing
research on this. I am sure someone had thought about this harder and
longer than I did.

:DG<

bugzilla | 7 Feb 15:18
Picon

[Bug 15927] New: [IndexedDB] Allowing "." and " " in keys specified using keyPath

https://www.w3.org/Bugs/Public/show_bug.cgi?id=15927

           Summary: [IndexedDB] Allowing "." and " " in keys specified
                    using keyPath
           Product: WebAppsWG
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Indexed Database API
        AssignedTo: dave.null <at> w3.org
        ReportedBy: odinho <at> opera.com
         QAContact: member-webapi-cvs <at> w3.org
                CC: mike <at> w3.org, public-webapps <at> w3.org

I've been trying to find any decision/answer about IndexedDB keypath and "." to
seperate objects.

It's very possible I could get data from a third party that has:

   obj["my.key"] = thing

and I'd want to have a keypath that accesses  my.key  like that, so NOT like:

  obj = { my: { key: thing } }

Similarly about spaces:  obj["my key"] = "blabla"

It would introduce some extra complexity to support this, sure, and it might
not be worth it at all, but has it been discussed on its own?

--

-- 
Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.