Re: [widgets] Interface published

On Thu, Nov 19, 2009 at 2:03 PM, Kai Hendry <> wrote:
> Please forgive the informal prose.

Yeah, like we are soooooo serious here! :P If it makes you feel
better, I'm responding to your email in my pajamas :)

But yeah, lets keep it professional.

> This late rant is prompted by [Widget interface spec (Last
> Call)](
> Widget APIs or rather [Widgets 1.0: The widget
> Interface]( is largely about exposing what's
> defined in the widget [configuration
> document](
> to the Widget developer.
> **WHY?** You may rightly ask. The widget developer should know his own name and
> email address whilst writing a function to mail him a [bug
> report]( I guess
> someone has argued that slapping new `widget.` attributes makes it easier for
> library developers. [BONDI]( incidentally rightly (imo),
> didn't bother with this mapping.

I agree. Accessing all the config file metadata is kinda pointless.

> Another reason WHY pointed out by
> [robin]( is that the simple
> Widget interface exposed by the widget runtime, would implement
> [locale support](
> and give you the localised interface. I.e. it's doing a bit of work behind the
> scenes for the convenience of Widget developers and well...  non-English
> speakers. However again, one can argue that Widget developers can implement
> their own locale support, which isn't that hard (they have probably done it
> before), but it would probably suck.

This is true. One is certainly free to do that, but I don't know why
you would if you get it for free in widgets.

> Ok, in an [example](
> Widget configuration file, like `config.xml`, you might find:
>        <widget xmlns=""
> id="" version="0.4.2"
> viewmodes="fullscreen">
> Which maps onto the [Widget interface]( as:
> = "";
>        widget.version = "0.4.2";
> Though what about viewmodes? Hmm...

Viewmode attribute would be defined by the viewmode spec. Viewmode
also relates to CSS.

> Then:
>        <name short="WebC">Web Commander</name>
> Maps as:
> = "Web Commander";
>        widget.shortName = "WebC";
> Ok, the attribute `short` was used as a prefix to `name` which has
> become capitialised in order to make it easier to distinguish. Ok,
> fine. However this is there is _an inconsistency_ with:
>        <author href=""
> email="">LiMo Foundation</author>
> Maps to the Widget interface like so:
> = "LiMo Foundation";
>        widget.authorEmail = "";
>        widget.authorHref = "";
> Now the author element attributes like `email` and `href` become
> suffixed to `author`. You see how `shortName, should be **nameShort**?

do'h! Might not be too late to change that. We will put in on the
agenda for discussion. I need to check who has implemented that so far
(if anyone!). If no one has implemented, then I will change it.

> Other elements can be found on the `config.xml` such as:
>          <feature name="" required="true"/>
>          <license href=""/>
>          <content src="index.html"/>
>          <feature name="" required="true"/>
>          <feature name="" required="true"/>
> However there is no mapping to the [Widget
> interface]( Who decides what gets mapped
> and what doesn't? Wouldn't it be simpler and more consistent to just map
> everything?

Re: license, see:

Features, if they are APIs, are made available as defined by their
respective specifications (e.g., on the Window object).  And you are
looking at the content already (document.location).

> It does get tricky especially thinking about the possible multiply
> nested <>.
> Also some punks might overload the `config.xml` with  _openURL_ which
> would clash.

No, openURL is spec'ed to ignore relative references.

> I understand some elements like the [feature
> elements](
> and undefined (proprietary) elements like:
>        <access network="false" localfs="false" remote_scripts="false"/>
>        <billing required="true"/>

OMG! What's that billing thing!?!?!? and that access element does not
comply to WARP :)

> ..are perhaps only relevant and used by particular runtimes, though
> shouldn't there be convention and reasoning for why (and why **not**)
> certain interfaces are exposed in the [widget interface
> specification](

No. That's beyond the scope of our work. Implementers are free to do
whatever they want with their proprietary extensions.

> If the <> was
> mandatory, which I think it should be since many widgets I've come across rely
> on **setPreferenceForKey** and **preferenceForKey** conventions, wouldn't it be
> sensible to put the interfaces all into this **preference** [Web
> storage]( mechanism?
> Consider read-only keys like:
>        widget.getItem("name")
>        widget.getItem("nameShort")
>        widget.getItem("authorEmail")
>        widget.getItem("licencseHref")

I think I have misunderstood what you said, but polluting the
widget.preferences object would be wrong because one would expect it
to be clean from the start. Any time you wanted to iterate over the
keys, you would need to have code to skip over those preset keys (that
would be bad). Also, it would be confusing when calling
preferences.clear(), etc.

However, a generic "getItem" might have been nice (and extensible)
means at getting at the metadata of the config doc. However, it's a
bit late to be having this discussion 3 years after this spec has been
on the table.

> Though perhaps ideally when you did a `widget.getItem`, you received the JSON
> representation of the XML fragment. Though I'm not entirely sure if there is a
> standard way to map XML onto JSON. You might as well canonicalise the whole
> `config.xml` as a JSON string bound to **widget.config**. There, simple.  Or
> `innerXML` if a JSON translation isn't possible.

Don't go crazy :) I think it would be fine to just pass back the
textContent, or value if it is an attribute.

> Btw the Widget interface as it stands are all readonly except for
> [preferences]( and
> [openURL](
> # widthxheight
> It's unclear to me if
> [width]( and
> [height]( map to the
> `config.xml` or the real actual viewport size.

The P&C spec sez:

"A numeric attribute greater than 0 that indicates the preferred
viewport height of the instantiated custom start file in CSS pixels

    Authoring Guidelines: It is optional for authors to use the height
attribute with a widget element. This value is only applicable to
particular view modes, meaning that for certain view modes this value
is ignored. The view modes that honor the value of the height
attribute are defined in the [Widgets-Views] specification.

In other words, <widget width/height> are just a sizing hints.

The TWI spec sez:
"Upon getting the width/height  attribute, a user agent must return an
number that represents the width of the widget instance’s viewport in
[CSS21] pixels."

That is, the pixels that represent the size of the view port (the area
that is being rendered).

> Surely one can defer to
> `window.screen.width` and `window.screen.height` instead? I know it says
> `screen`, but just imagine it says `viewport`?

No, screen.width and screen.height means the screens width and height
(like 640x480)! not the viewport's width and height (apples and

Also, HTML5's Window interface does not define the screen object... if
the bible does not says it exists, then it does not exist :)

> # My final proposal Widget interface proposal after thinking about it
> for two hours
>        interface Widget {
>                readonly attribute DOMString     config; // innerXML or rather JSON
> representation of configuration document
>                readonly attribute Storage       preferences; // key value
>                void openURL(in DOMString iri);
>        };

I like the last two :)

Kind regards,

Marcos Caceres

Received on Wednesday, 25 November 2009 14:52:58 UTC