A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.

To request an account, ask an autoconfirmed user on Chat (such as one of these permanent autoconfirmed members).

Component Model Use Cases: Difference between revisions

From WHATWG Wiki
Jump to navigation Jump to search
No edit summary
 
(132 intermediate revisions by 10 users not shown)
Line 1: Line 1:
== Component Model (aka XBL2) Use Cases ==
{{obsolete|see=http://www.w3.org/2008/webapps/wiki/Component_Model_Use_Cases}}


'''WORK IN PROGRESS'''
These use cases represent a set of problems we are trying to solve by implementing a [[Component_Model | component model]] for the web.


A canonical set of uses cases that represents the set of problems we are trying to solve by implementing a component model. For implementation details, see [http://dev.w3.org/2006/xbl2/Overview.html XBL2 Spec].
=Custom Controls=


=== Built-in HTML Elements and Their Behaviors ===
Current practice for sizable web applications is to use JavaScript libraries to provide a system to support the construction of custom controls. Implementing these controls can be made simpler and more interoperable with runtime support.


Does:
==Layout Manager==
* provide a uniform way to browsers to implement complex HTML elements, such as video/audio, sliders, progress elements, etc. possibly using scripting.
* provide light-weight implementations of specialized markup languages


Needs:
{| cellpadding="8" cellspacing="0"
* shadow DOM
|+style="caption-side:top; text-align: left; color:Gray" | Layout Manager Use Case Parameters
* UA-level attachment
! align="right" valign="top" | Who
* ability to designate and use DOM SPIs only within the shadow scope
| Web Framework Engineer
* ability to completely hide implementation details from author and user
|-
* restricted post-UA-level styling using pseudoclasses
! align="right" valign="top" | What
* style/event propagation control at the borders of the shadow DOM
| Build a layout library, consisting of a UI layout primitives, such as ''panel'', ''resizeable panel'', ''tab group'', ''stack'', ''accordion containers'', etc.
* high performance, especially compared to native implementation
|-
! align="right" valign="top" | Purpose
|
* Allow web application developers to easily build constrained layout and populate it with arbitrary HTML content.
* Provide a way for developers to build their own layout primitives by extending the provided ones.
|-
! align="right" valign="top" | Examples
|
* [http://dojotoolkit.org/reference-guide/dijit/layout.html#dijit-layout Dijit Layout]
* [http://code.google.com/webtoolkit/doc/latest/DevGuideUiPanels.html GWT Panels]
* [http://dev.sencha.com/deploy/ext-4.0.2a/docs/#/api/Ext.panel.AbstractPanel Sencha Panels]
* [http://guides.sproutcore.com/views.html SproutCore Views]
|-
! align="right" valign="top" | Desirable Properties
|
* [[Component_Model#Composability | Composability]] -- a method to compose layouts with both UI primitives and DOM elements.
* [[Component_Model#Extensibility | Extensibility]] -- a way to build on layout primitives to create new ones.
* [[Component_Model#Encapsulation | Encapsulation]] -- styles, defined to hold layout in place should not be in danger of being stomped on by the author stylesheets.
* [[Component_Model#Performance | Performance]] -- layouts built with layout manager should appear quickly, avoiding re-flows and [http://en.wikipedia.org/wiki/Flash_of_unstyled_content FOUC]-like symptoms.
|}


Could use:
==Widget Mix-and-Match==
* declarative templating/binding


Doesn't care:
{| cellpadding="8" cellspacing="0"
* mutable templates
|+ style="caption-side:top; text-align: left; color:Gray" | Mix-and-matching Use Case Parameters
* dynamic attachment/detachment
! align="right" valign="top" | Who
* template inheritance
| Web Application Engineer
* attachment using CSS or DOM
|-
* content element (output ports), since they can't have children (this may change)
! align="right" valign="top" | What
* attribute/pseudo forwarding
| Build an application using multiple existing controls from several frameworks.
* xml:base handling
|-
! align="right" valign="top" | Purpose
|
* Write application faster by reusing code.
* Avoid having to exclusively go with one framework.
|-
! align="right" valign="top" | Examples
|
* [http://stackoverflow.com/questions/4534274/how-do-you-access-dijit-elements-in-jquery How do you access Dijit elements in JQuery]
* [http://yehudakatz.com/2011/06/11/using-sproutcore-2-0-with-jquery-ui/ Using SproutCore 2.0 with jQuery UI]
* [http://stackoverflow.com/questions/394601/which-javascript-framework-jquery-vs-dojo-vs Which JavaScript framework (jQuery vs Dojo vs … )?]
|-
! align="right" valign="top" | Desirable Properties
|
* [[Component_Model#Consistency | Consistency]] -- a compatible way to expose properties and methods across widget frameworks.
* [[Component_Model#Composability | Composability]] -- a method to compose with cross-framework widgets.
|}


Interesting scenarios:
==Rendering Form Controls with SVG==
* If an input range element is implemented using this functionality, what happens to its shadow DOM if author attempts to add shadow DOM to that element?
* Implement a video/audio element. How can the binding reach into a private supporting API that is not available to the author?


== Custom Widget System ==
{| cellpadding="8" cellspacing="0"
|+ style="caption-side:top; text-align: left; color:Gray" | SVG Form Controls Use Case Parameters
! align="right" valign="top" | Who
| Web Application Engineer or Web Framework Engineer
|-
! align="right" valign="top" | What
| Create a set of UI controls that act like standard HTML forms controls, but use SVG for rendering.
|-
! align="right" valign="top" | Purpose
|
* Provide custom appearance of form controls, consistent with overall the Web application theme.
* Make the form controls scale beautifully for various resolutions and form factors.
|-
! align="right" valign="top" | Examples
|
[http://docs.sproutcore.com/#doc=SC.ImageButtonView&src=false SproutCore's ImageButtonView], [http://dev.sencha.com/deploy/touch/docs/?class=Ext.form.Number Sencha's Number] -- examples of extensive themed form control hierarchy.
|-
! align="right" valign="top" | Desirable Properties
|
* [[Component_Model#Consistency | Consistency]] -- the controls should act just like any other DOM elements.
* [[Component_Model#Encapsulation | Encapsulation]] -- the document shouldn't be able to accidentally mess up the rendering of the controls.
* [[Component_Model#Performance | Performance]] -- load quickly, avoid [http://en.wikipedia.org/wiki/Flash_of_unstyled_content FOUC]-like symptoms when using controls.
|}


Does:
==Contacts Widget==
* provide a uniform way (i.e. DOM) to declare widget APIs
* encapsulate widget implementation details
* enable control over how styles and events outside of a widget affect it
* enable widget styling primitives
* asynchronously instantiate and initialize widgets (for instance, display a widget without starting up a script context, then progressively enhance with script).
* allow seamless reuse a widget written using various libraries or frameworks
* allow using widgets declaratively, with minimal knowledge of the underlying implementation
* provide a way to create new widgets by extending existing widgets


Needs:
{| cellpadding="8" cellspacing="0"
* shadow DOM
|+ style="caption-side:top; text-align: left; color:Gray" | Contacts Widget Use Case Parameters
* content element (output ports)
! align="right" valign="top" | Who
* style/event propagation control at the borders of the shadow DOM
| Web Application Engineer
* attachment using CSS and DOM
|-
* separate instantiation and binding phases (or another way to allow asynchronous binding)
! align="right" valign="top" | What
* attribute/pseudo forwarding
| Build a drop-in Contacts widget, which has a pre-defined appearance and shows a list of your contacts, with a way to change the widget to compact or full view and to tell the widget to refresh its state.
* declarative templating/binding
|-
! align="right" valign="top" | Purpose
|
* Use the widget anywhere in the application without having to worry about styles affecting its appearance.
* Hide details of loading contact data and other plumbing of the widget from the consuming code with a stable API.
|-
! align="right" valign="top" | Examples
| [http://i.imgur.com/4eDXM.png A screenshot of Google+ "in your circles" widget]
|-
! align="right" valign="top" | Desirable Properties
|
* [[Component_Model#Encapsulation | Encapsulation]] -- means to ensure style of the document does not affect the widget, and widget's logic is kept to the widget.
* [[Component_Model#Composability | Composability]] -- easily added anywhere in the DOM tree.
|}


Could use:
==Like/+1 Button==
* dynamic attachment/detachment
* template inheritance


Doesn't care:
{| cellpadding="8" cellspacing="0"
* mutable templates
|+ style="caption-side:top; text-align: left; color:Gray" | Like/+1 Button Use Case Parameters
* xml:base handling
! align="right" valign="top" | Who
| Web Application Engineer
|-
! align="right" valign="top" | What
| Build a drop-in widget with a pre-defined appearance of a button, showing a count of likes/+1s for this instance of a button (count is stored at a central location), embeddable on any document on the Web.
|-
! align="right" valign="top" | Purpose
|
* Provide a simple vehicle for Web authors to embed the button.
* Isolate widget implementation details from the document.
|-
! align="right" valign="top" | Examples
|
* [http://developers.facebook.com/docs/reference/plugins/like/ Facebook Like button embedding instructions]
* [http://www.google.com/webmasters/+1/button/ Google +1 button embedding instructions]
|-
! align="right" valign="top" | Desirable Properties
|
* [[Component_Model#Encapsulation | Encapsulation]] -- means to ensure style of the document does not affect the widget, and widget's logic is kept to the widget.
* [[Component_Model#Confinement | Confinement]] -- a way to completely isolate the widget implementation from the document in which it is being embedded.
* [[Component_Model#Performance | Performance]] -- don't block the page load.
|}


Interesting scenarios:
==Table-based Charts==
* Implement a "polaroid frame" widget? This widget, when bound to any element would display its contents in a Polaroid(tm)-like frame.
* Suppose the widget system has a centralized "settings" widget, with which all other widgets should communicate to add their settings. Implement this communication, provided that all widgets are opaque elements.
* Implement a "tab set" widget. As you add "tabs" to it, tab titles appear in a row at the top, and tab contents appear in the main area, only visible when the corresponding tab title is selected.
* '''Tens of Thousands of Widgets'''. The implementation should be able to efficiently handle a very large number of instances from the same template (see [http://lists.w3.org/Archives/Public/public-webapps/2010OctDec/0979.html discussion]).


===Insertion Points, Not Containers===
{| cellpadding="8" cellspacing="0"
Output ports need to be insertion points, not cointainers. If the output port is a container (that is, an existing element in the shadow subtree is designated as a place to add the "light" nodes), some layout scenarios aren't possible. In this example, you can not use flexbox to layout all of the paragraphs in the story:
|+ style="caption-side:top; text-align: left; color:Gray" | Table-based Charts Use Case Parameters
<pre>
! align="right" valign="top" | Who
<template>
| Web Framework Engineer
    <p>Once upon a time,
|-
    <content includes="p">
! align="right" valign="top" | What
    <p>And they lived happily ever after
| Provide a way to represent table data markup as charts or diagrams.
</template>
|-
</pre>
! align="right" valign="top" | Purpose
It is useful to think of the output port as a [https://developer.mozilla.org/en/DOM:range.collapsed collapsed range].
| Make it easy for Web authors to create charts and diagrams using table markup.
|-
! align="right" valign="top" | Examples
|
* [http://www.wait-till-i.com/2008/01/08/generating-charts-from-accessible-data-tables-using-the-google-charts-api/ Christian Heilmann's tochart script]
|-
! align="right" valign="top" | Desirable Properties
|
* [[Component_Model#Composability | Composability]] -- one should be able to make chart by creating a table, imperatively or declaratively.
* [[Component_Model#Performance | Performance]] -- no FOUC or blocking load when charts are loaded.
|}


==Shadow Subtree Mutation===
==Timezone selection via Image==


Because content element is an insertion point, what happens when the elements around it change? What happens when the insertion point moves?
{| cellpadding="8" cellspacing="0"
* '''Modifying includes attribute'''. What happens when you modify the <code>includes</code> element on the output port?
|+ style="caption-side:top; text-align: left; color:Gray" | Timezone selection via Image Use Case Parameters
* '''Nested shadow subtrees'''. Suppose you have an element <code>x-bar</code>, instantiated from this template:
! align="right" valign="top" | Who
<pre>
| Web Framework Engineer
<template>
|-
    <div>
! align="right" valign="top" | What
        <x-foo>
| Graphical representation of a timezone selector that shows a world map in addition to/instead of a drop-down list.
            <span>Blah</span>
|-
            <content></content>
! align="right" valign="top" | Purpose
      </x-foo>
| Make it easy for Web authors to spruce up time zone selection (or similar).
    </div>
|-
</pre>
! align="right" valign="top" | Examples
And <code>x-foo</code> is instantiated from this template:
|
<pre>
* [http://www.timezonecheck.com Time Zone Map]
<template>
|-
    <span>
! align="right" valign="top" | Desirable Properties
        <content></content>
|
    </span>
* [[Component_Model#Extensibility | Extensibility]] -- Basically extending &lt;select&gt;. Should fall back to a simple &lt;select&gt; where components are not supported.
</template>
* [[Component_Model#Consistency | Consistency]] -- Extend the &lt;select&gt; API for item selection.
</pre>
|}
Sequence of actions:
*# Add a <code>div</code> element to <code>x-bar</code>.
*# Move <code>content</code> element in <code>x-bar</code> template as the first child of <code>div</code>
What happens?


=== Layout Manager ===
==Entry-helper==


Does:
{| cellpadding="8" cellspacing="0"
* provide a framework for client-side restructuring of content to accommodate layout
|+ style="caption-side:top; text-align: left; color:Gray" | Entry-helper Use Case Parameters
* support both imperative a declarative layout models
! align="right" valign="top" | Who
* provide templating/theming capabilities
| Web Framework Engineer, Web Application Engineer
|-
! align="right" valign="top" | What
| Add an entry-helper (drop-down) list to input fields.
|-
! align="right" valign="top" | Purpose
|
Help the user fill in a form field, show suggestions and acceptable values, speed up data entry.
|-
! align="right" valign="top" | Examples
|
* Most browser's address bar or web search field
|-
! align="right" valign="top" | Desirable Properties
|
* [[Component_Model#Extensibility | Extensibility]] -- Basically extending &lt;input&gt;. Should fall back to a simple &lt;input&gt; where components are not supported.
|}


Needs:
=Built-in HTML Elements=
* shadow DOM
* content element (output ports)
* attachment using CSS and DOM
* separate instantiation and binding phases (or another way to allow asynchronous binding)


Could use:
Many non-trivial (i.e. with additional behavior and styling beyond the standard box model) elements that exist in HTML today could be implemented using HTML/CSS/JS. It makes sense to provide a standardized way to accomplish this, with the short-term goals of reducing the size of browsers C++ code and making new element implementation easier, and the long-term goal of converging built-in HTML element implementations across browsers.


Doesn't care:
{| cellpadding="8" cellspacing="0"
* mutable templates
|+ style="caption-side:top; text-align: left; color:Gray" | Built-in HTML Elements Use Case Parameters
* xml:base handling
! align="right" valign="top" | Who
| Browser Engineer
|-
! align="right" valign="top" | What
| Implement a built-in HTML element by composing or extending existing HTML elements
|-
! align="right" valign="top" | Purpose
|
* Reduce amount of custom UI code (fewer bugs, less code rot, leading to fewer future bugs).
* Remove magic: make it easier for authors to grok control behavior in familiar terms, allow authors to style controls using CSS.
* ''Stretch'': specify built-in element behavior in terms of the component model specification.
|-
! align="right" valign="top" | Desirable Properties
|
* [[Component_Model#Encapsulation | Encapsulation]] -- ensure that implementation details are not exposed to the document
* [[Component_Model#Desugaring | Desugaring]] -- explain appearance and behavior of controls in terms of CSS/DOM.
|}
 
==Media Controls For The Video Element==
 
Using DOM elements, build a media controls panel for the [http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#the-video-element video element]. The media controls include:
* timeline slider
* stop/start, replay, closed-captioning, forward, rewind and volume buttons, and
* a volume control, which is revealed when hovering over the volume button.
 
The implementation details of the media controls should not be accessible or perceptible from outside of the video element. Document styles should not interfere with the styles of the media controls panel. However, we must provide a way for an author to explicitly style all parts of the media controls panel.
 
==Details/Summary Elements==
 
Implement [http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#the-details-element details] and [http://www.whatwg.org/specs/web-apps/current-work/multipage/interactive-elements.html#the-summary-element summary] elements. According to the spec, the first <code>summary</code> element found in the flow content is used to represent a summary or legend of details. In case a <code>summary</code> element is not found, the UA is supposed to auto-generate some fallback content. The <code>details</code> element itself needs to have a marker indicating whether <code>details</code> element is open or closed - i.e., whether all contents of <details> are shown, or only the summary.
 
Just like media controls, the implementation should not be accessible by the consumer of the elements. For example, the reordering of flow content to position <code>summary</code> element as first item in the disclosure widget should be imperceptible to DOM traversal methods.

Latest revision as of 15:46, 10 November 2012

This document is obsolete.

For more information, see: http://www.w3.org/2008/webapps/wiki/Component_Model_Use_Cases


These use cases represent a set of problems we are trying to solve by implementing a component model for the web.

Custom Controls

Current practice for sizable web applications is to use JavaScript libraries to provide a system to support the construction of custom controls. Implementing these controls can be made simpler and more interoperable with runtime support.

Layout Manager

Layout Manager Use Case Parameters
Who Web Framework Engineer
What Build a layout library, consisting of a UI layout primitives, such as panel, resizeable panel, tab group, stack, accordion containers, etc.
Purpose
  • Allow web application developers to easily build constrained layout and populate it with arbitrary HTML content.
  • Provide a way for developers to build their own layout primitives by extending the provided ones.
Examples
Desirable Properties
  • Composability -- a method to compose layouts with both UI primitives and DOM elements.
  • Extensibility -- a way to build on layout primitives to create new ones.
  • Encapsulation -- styles, defined to hold layout in place should not be in danger of being stomped on by the author stylesheets.
  • Performance -- layouts built with layout manager should appear quickly, avoiding re-flows and FOUC-like symptoms.

Widget Mix-and-Match

Mix-and-matching Use Case Parameters
Who Web Application Engineer
What Build an application using multiple existing controls from several frameworks.
Purpose
  • Write application faster by reusing code.
  • Avoid having to exclusively go with one framework.
Examples
Desirable Properties
  • Consistency -- a compatible way to expose properties and methods across widget frameworks.
  • Composability -- a method to compose with cross-framework widgets.

Rendering Form Controls with SVG

SVG Form Controls Use Case Parameters
Who Web Application Engineer or Web Framework Engineer
What Create a set of UI controls that act like standard HTML forms controls, but use SVG for rendering.
Purpose
  • Provide custom appearance of form controls, consistent with overall the Web application theme.
  • Make the form controls scale beautifully for various resolutions and form factors.
Examples

SproutCore's ImageButtonView, Sencha's Number -- examples of extensive themed form control hierarchy.

Desirable Properties
  • Consistency -- the controls should act just like any other DOM elements.
  • Encapsulation -- the document shouldn't be able to accidentally mess up the rendering of the controls.
  • Performance -- load quickly, avoid FOUC-like symptoms when using controls.

Contacts Widget

Contacts Widget Use Case Parameters
Who Web Application Engineer
What Build a drop-in Contacts widget, which has a pre-defined appearance and shows a list of your contacts, with a way to change the widget to compact or full view and to tell the widget to refresh its state.
Purpose
  • Use the widget anywhere in the application without having to worry about styles affecting its appearance.
  • Hide details of loading contact data and other plumbing of the widget from the consuming code with a stable API.
Examples A screenshot of Google+ "in your circles" widget
Desirable Properties
  • Encapsulation -- means to ensure style of the document does not affect the widget, and widget's logic is kept to the widget.
  • Composability -- easily added anywhere in the DOM tree.

Like/+1 Button

Like/+1 Button Use Case Parameters
Who Web Application Engineer
What Build a drop-in widget with a pre-defined appearance of a button, showing a count of likes/+1s for this instance of a button (count is stored at a central location), embeddable on any document on the Web.
Purpose
  • Provide a simple vehicle for Web authors to embed the button.
  • Isolate widget implementation details from the document.
Examples
Desirable Properties
  • Encapsulation -- means to ensure style of the document does not affect the widget, and widget's logic is kept to the widget.
  • Confinement -- a way to completely isolate the widget implementation from the document in which it is being embedded.
  • Performance -- don't block the page load.

Table-based Charts

Table-based Charts Use Case Parameters
Who Web Framework Engineer
What Provide a way to represent table data markup as charts or diagrams.
Purpose Make it easy for Web authors to create charts and diagrams using table markup.
Examples
Desirable Properties
  • Composability -- one should be able to make chart by creating a table, imperatively or declaratively.
  • Performance -- no FOUC or blocking load when charts are loaded.

Timezone selection via Image

Timezone selection via Image Use Case Parameters
Who Web Framework Engineer
What Graphical representation of a timezone selector that shows a world map in addition to/instead of a drop-down list.
Purpose Make it easy for Web authors to spruce up time zone selection (or similar).
Examples
Desirable Properties
  • Extensibility -- Basically extending <select>. Should fall back to a simple <select> where components are not supported.
  • Consistency -- Extend the <select> API for item selection.

Entry-helper

Entry-helper Use Case Parameters
Who Web Framework Engineer, Web Application Engineer
What Add an entry-helper (drop-down) list to input fields.
Purpose

Help the user fill in a form field, show suggestions and acceptable values, speed up data entry.

Examples
  • Most browser's address bar or web search field
Desirable Properties
  • Extensibility -- Basically extending <input>. Should fall back to a simple <input> where components are not supported.

Built-in HTML Elements

Many non-trivial (i.e. with additional behavior and styling beyond the standard box model) elements that exist in HTML today could be implemented using HTML/CSS/JS. It makes sense to provide a standardized way to accomplish this, with the short-term goals of reducing the size of browsers C++ code and making new element implementation easier, and the long-term goal of converging built-in HTML element implementations across browsers.

Built-in HTML Elements Use Case Parameters
Who Browser Engineer
What Implement a built-in HTML element by composing or extending existing HTML elements
Purpose
  • Reduce amount of custom UI code (fewer bugs, less code rot, leading to fewer future bugs).
  • Remove magic: make it easier for authors to grok control behavior in familiar terms, allow authors to style controls using CSS.
  • Stretch: specify built-in element behavior in terms of the component model specification.
Desirable Properties
  • Encapsulation -- ensure that implementation details are not exposed to the document
  • Desugaring -- explain appearance and behavior of controls in terms of CSS/DOM.

Media Controls For The Video Element

Using DOM elements, build a media controls panel for the video element. The media controls include:

  • timeline slider
  • stop/start, replay, closed-captioning, forward, rewind and volume buttons, and
  • a volume control, which is revealed when hovering over the volume button.

The implementation details of the media controls should not be accessible or perceptible from outside of the video element. Document styles should not interfere with the styles of the media controls panel. However, we must provide a way for an author to explicitly style all parts of the media controls panel.

Details/Summary Elements

Implement details and summary elements. According to the spec, the first summary element found in the flow content is used to represent a summary or legend of details. In case a summary element is not found, the UA is supposed to auto-generate some fallback content. The details element itself needs to have a marker indicating whether details element is open or closed - i.e., whether all contents of <details> are shown, or only the summary.

Just like media controls, the implementation should not be accessible by the consumer of the elements. For example, the reordering of flow content to position summary element as first item in the disclosure widget should be imperceptible to DOM traversal methods.