Skip to content

Commit cdd48e1

Browse files
annevkdomenic
authored andcommitted
Editorial: put properties shared across globals on mixin
This makes the following editorial changes: * Groups base64, timer, and ImageBitmap properties on a single mixin. * Removes overloading of timer methods in favor of a union type It is expected that other standards will make use of this mixin, e.g., Fetch will use it to define fetch().
1 parent 38139b4 commit cdd48e1

File tree

1 file changed

+108
-102
lines changed

1 file changed

+108
-102
lines changed

source

Lines changed: 108 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -87530,29 +87530,55 @@ interface <dfn>DocumentAndElementEventHandlers</dfn> {
8753087530
</div>
8753187531

8753287532

87533-
<h3 id="atob">Base64 utility methods</h3>
87533+
<h3 id="windoworworkerglobalscope-mixin">The <code>WindowOrWorkerGlobalScope</code> mixin</h3>
8753487534

87535-
<p>The <code data-x="dom-windowbase64-atob">atob()</code> and <code
87536-
data-x="dom-windowbase64-btoa">btoa()</code> methods allow authors to transform content to and from
87537-
the base64 encoding.</p>
87535+
<p>The <code>WindowOrWorkerGlobalScope</code> mixin is for use of APIs that are to be exposed on
87536+
<code>Window</code> and <code>WorkerGlobalScope</code> objects.</p>
8753887537

87539-
<!-- v2: actual binary support -->
87538+
<p class="note">Other standards are encouraged to further extend it using <code data-x="">partial
87539+
interface <span>WindowOrWorkerGlobalScope</span> { &hellip; };</code> along with an appropriate
87540+
reference.</p>
8754087541

87541-
<pre class="idl">[NoInterfaceObject, Exposed=(Window,Worker)]
87542-
interface <dfn>WindowBase64</dfn> {
87543-
DOMString <span data-x="dom-windowbase64-btoa">btoa</span>(DOMString btoa);
87544-
DOMString <span data-x="dom-windowbase64-atob">atob</span>(DOMString atob);
87542+
<pre class="idl">typedef (DOMString or <span data-x="idl-Function">Function</span>) <dfn>TimerHandler</dfn>;
87543+
87544+
[NoInterfaceObject, Exposed=(Window,Worker)]
87545+
interface <dfn>WindowOrWorkerGlobalScope</dfn> {
87546+
// base64 utility methods
87547+
DOMString <span data-x="dom-btoa">btoa</span>(DOMString data);
87548+
DOMString <span data-x="dom-atob">atob</span>(DOMString data);
87549+
87550+
// timers
87551+
long <span data-x="dom-setTimeout">setTimeout</span>(<span>TimerHandler</span> handler, optional long timeout = 0, any... arguments);
87552+
void <span data-x="dom-clearTimeout">clearTimeout</span>(optional long handle = 0);
87553+
long <span data-x="dom-setInterval">setInterval</span>(<span>TimerHandler</span> handler, optional long timeout = 0, any... arguments);
87554+
void <span data-x="dom-clearInterval">clearInterval</span>(optional long handle = 0);
87555+
87556+
// ImageBitmap
87557+
Promise&lt;<span>ImageBitmap</span>&gt; <span data-x="dom-createImageBitmap">createImageBitmap</span>(<span>ImageBitmapSource</span> image, optional <span>ImageBitmapOptions</span> options);
87558+
Promise&lt;<span>ImageBitmap</span>&gt; <span data-x="dom-createImageBitmap">createImageBitmap</span>(<span>ImageBitmapSource</span> image, long sx, long sy, long sw, long sh, optional <span>ImageBitmapOptions</span> options);
8754587559
};
87546-
<span>Window</span> implements <span>WindowBase64</span>;
87547-
<span>WorkerGlobalScope</span> implements <span>WindowBase64</span>;</pre>
87560+
<span>Window</span> implements <span>WindowOrWorkerGlobalScope</span>;
87561+
<span>WorkerGlobalScope</span> implements <span>WindowOrWorkerGlobalScope</span>;</pre>
87562+
87563+
<!-- Demonstrating the need for wrapping of the timeout argument value treated as long rather than clamping or treating as double:
87564+
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1228
87565+
Demonstrating the need for the timeout argument to be signed rather than unsigned:
87566+
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1229
87567+
-->
87568+
87569+
87570+
<h3 id="atob">Base64 utility methods</h3>
87571+
87572+
<p>The <code data-x="dom-atob">atob()</code> and <code data-x="dom-btoa">btoa()</code> methods
87573+
allow developers to transform content to and from the base64 encoding.</p>
8754887574

8754987575
<p class="note">In these APIs, for mnemonic purposes, the "b" can be considered to stand for
8755087576
"binary", and the "a" for "ASCII". In practice, though, for primarily historical reasons, both the
8755187577
input and output of these functions are Unicode strings.</p>
8755287578

8755387579
<dl class="domintro">
8755487580

87555-
<dt><var>result</var> = <var>window</var> . <code subdfn data-x="dom-windowbase64-btoa">btoa</code>( <var>data</var> )</dt>
87581+
<dt><var>result</var> = self . <code subdfn data-x="dom-btoa">btoa</code>( <var>data</var> )</dt>
8755687582

8755787583
<dd>
8755887584

@@ -87565,7 +87591,7 @@ interface <dfn>WindowBase64</dfn> {
8756587591

8756687592
</dd>
8756787593

87568-
<dt><var>result</var> = <var>window</var> . <code subdfn data-x="dom-windowbase64-atob">atob</code>( <var>data</var> )</dt>
87594+
<dt><var>result</var> = self . <code subdfn data-x="dom-atob">atob</code>( <var>data</var> )</dt>
8756987595

8757087596
<dd>
8757187597

@@ -87583,17 +87609,19 @@ interface <dfn>WindowBase64</dfn> {
8758387609

8758487610
<div w-nodev>
8758587611

87586-
<p>The <dfn><code data-x="dom-windowbase64-btoa">btoa()</code></dfn> method must throw an
87587-
<code>InvalidCharacterError</code> exception if the method's first argument contains any character
87588-
whose code point is greater than U+00FF. Otherwise, the user agent must convert that argument to a
87589-
sequence of octets whose <var>n</var>th octet is the eight-bit representation of the code
87590-
point of the <var>n</var>th character of the argument, and then must apply the base64
87591-
algorithm to that sequence of octets, and return the result. <ref spec=RFC4648><!--base64--></p> <!-- Aryeh says: This seems to be what all
87592-
browsers do as of January 2011 (except IE, which doesn't support these functions at all). -->
87612+
<p>The <dfn data-x="dom-btoa"><code id="dom-windowbase64-btoa">btoa(<var>data</var>)</code></dfn>
87613+
method must throw an <code>InvalidCharacterError</code> exception if <var>data</var> contains any
87614+
character whose code point is greater than U+00FF. Otherwise, the user agent must convert
87615+
<var>data</var> to a sequence of octets whose <var>n</var>th octet is the eight-bit representation
87616+
of the code point of the <var>n</var>th character of <var>data</var>, and then must apply the
87617+
base64 algorithm to that sequence of octets, and return the result. <ref
87618+
spec=RFC4648><!--base64--></p>
87619+
<!-- Aryeh says: This seems to be what all browsers do as of January 2011 (except IE, which
87620+
doesn't support these functions at all). -->
8759387621

8759487622

87595-
<p>The <dfn><code data-x="dom-windowbase64-atob">atob()</code></dfn> method must run the following
87596-
steps to parse the string passed in the method's first argument:</p>
87623+
<p>The <dfn data-x="dom-atob"><code id="dom-windowbase64-atob">atob(<var>data</var>)</code></dfn>
87624+
method, when invoked, must run the following steps:</p>
8759787625

8759887626
<ol>
8759987627

@@ -87605,23 +87633,22 @@ interface <dfn>WindowBase64</dfn> {
8760587633
https://lists.w3.org/Archives/Public/public-whatwg-archive/2011May/0207.html
8760687634
-->
8760787635

87608-
<li><p>Let <var>input</var> be the string being parsed.</p></li>
87609-
87610-
<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
87636+
<li><p>Let <var>position</var> be a pointer into <var>data</var>, initially
8761187637
pointing at the start of the string.</p></li>
8761287638

87613-
<li><p>Remove all <span data-x="space character">space characters</span> from <var>input</var>.</p></li>
87639+
<li><p>Remove all <span data-x="space character">space characters</span> from
87640+
<var>data</var>.</p></li>
8761487641

87615-
<li><p>If the length of <var>input</var> divides by 4 leaving no remainder, then: if
87616-
<var>input</var> ends with one or two U+003D EQUALS SIGN (=) characters, remove them
87617-
from <var>input</var>.</p></li>
87642+
<li><p>If the length of <var>data</var> divides by 4 leaving no remainder, then: if
87643+
<var>data</var> ends with one or two U+003D EQUALS SIGN (=) characters, remove them from
87644+
<var>data</var>.</p></li>
8761887645

87619-
<li><p>If the length of <var>input</var> divides by 4 leaving a remainder of 1, throw an
87646+
<li><p>If the length of <var>data</var> divides by 4 leaving a remainder of 1, throw an
8762087647
<code>InvalidCharacterError</code> exception and abort these steps.</p>
8762187648

8762287649
<li>
8762387650

87624-
<p>If <var>input</var> contains a character that is not in the following list of
87651+
<p>If <var>data</var> contains a character that is not in the following list of
8762587652
characters and character ranges, throw an <code>InvalidCharacterError</code> exception and abort
8762687653
these steps:</p>
8762787654

@@ -87640,8 +87667,8 @@ interface <dfn>WindowBase64</dfn> {
8764087667

8764187668
<li>
8764287669

87643-
<p>While <var>position</var> does not point past the end of <var>input</var>,
87644-
run these substeps:</p>
87670+
<p>While <var>position</var> does not point past the end of <var>data</var>, run these
87671+
substeps:</p>
8764587672

8764687673
<ol>
8764787674

@@ -88256,31 +88283,13 @@ interface <dfn>WindowBase64</dfn> {
8825688283

8825788284
<h3 id="timers">Timers</h3>
8825888285

88259-
<p>The <code data-x="dom-windowtimers-setTimeout">setTimeout()</code>
88260-
and <code data-x="dom-windowtimers-setInterval">setInterval()</code>
88261-
methods allow authors to schedule timer-based callbacks.</p>
88262-
88263-
<pre class="idl">[NoInterfaceObject, Exposed=(Window,Worker)]
88264-
interface <dfn>WindowTimers</dfn> {
88265-
long <span data-x="dom-windowtimers-setTimeout">setTimeout</span>(<span data-x="idl-Function">Function</span> handler, optional long timeout = 0, any... arguments);
88266-
long <span data-x="dom-windowtimers-setTimeout">setTimeout</span>(DOMString handler, optional long timeout = 0, any... arguments);
88267-
void <span data-x="dom-windowtimers-clearTimeout">clearTimeout</span>(optional long handle = 0);
88268-
long <span data-x="dom-windowtimers-setInterval">setInterval</span>(<span data-x="idl-Function">Function</span> handler, optional long timeout = 0, any... arguments);
88269-
long <span data-x="dom-windowtimers-setInterval">setInterval</span>(DOMString handler, optional long timeout = 0, any... arguments);
88270-
void <span data-x="dom-windowtimers-clearInterval">clearInterval</span>(optional long handle = 0);
88271-
};
88272-
<span>Window</span> implements <span>WindowTimers</span>;
88273-
<span>WorkerGlobalScope</span> implements <span>WindowTimers</span>;</pre>
88274-
88275-
<!-- Demonstrating the need for wrapping of the timeout argument value treated as long rather than clamping or treating as double:
88276-
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1228
88277-
Demonstrating the need for the timeout argument to be signed rather than unsigned:
88278-
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1229
88279-
-->
88286+
<p>The <code data-x="dom-setTimeout">setTimeout()</code> and <code
88287+
data-x="dom-setInterval">setInterval()</code> methods allow authors to schedule timer-based
88288+
callbacks.</p>
8828088289

8828188290
<dl class="domintro">
8828288291

88283-
<dt><var>handle</var> = <var>window</var> . <code subdfn data-x="dom-windowtimers-setTimeout">setTimeout</code>( <var>handler</var> [, <var>timeout</var> [, <var>arguments</var>... ] ] )</dt>
88292+
<dt><var>handle</var> = self . <code subdfn data-x="dom-setTimeout">setTimeout</code>( <var>handler</var> [, <var>timeout</var> [, <var>arguments</var>... ] ] )</dt>
8828488293

8828588294
<dd>
8828688295

@@ -88289,26 +88298,25 @@ interface <dfn>WindowTimers</dfn> {
8828988298

8829088299
</dd>
8829188300

88292-
<dt><var>handle</var> = <var>window</var> . <code data-x="dom-windowtimers-setTimeout">setTimeout</code>( <var>code</var> [, <var>timeout</var> ] )</dt>
88301+
<dt><var>handle</var> = self . <code data-x="dom-setTimeout">setTimeout</code>( <var>code</var> [, <var>timeout</var> ] )</dt>
8829388302

8829488303
<dd>
8829588304

8829688305
<p>Schedules a timeout to compile and run <var>code</var> after <var>timeout</var> milliseconds.</p>
8829788306

8829888307
</dd>
8829988308

88300-
<dt><var>window</var> . <code subdfn data-x="dom-windowtimers-clearTimeout">clearTimeout</code>( <var>handle</var> )</dt>
88309+
<dt>self . <code subdfn data-x="dom-clearTimeout">clearTimeout</code>( <var>handle</var> )</dt>
8830188310
<!-- don't mention that the handle is optional, since if omitted, the method does nothing -->
8830288311

8830388312
<dd>
8830488313

88305-
<p>Cancels the timeout set with <code data-x="dom-windowtimers-setTimeout">setTimeout()</code>
88306-
or <code data-x="dom-windowtimers-setInterval">setInterval()</code> identified by
88307-
<var>handle</var>.</p>
88314+
<p>Cancels the timeout set with <code data-x="dom-setTimeout">setTimeout()</code> or <code
88315+
data-x="dom-setInterval">setInterval()</code> identified by <var>handle</var>.</p>
8830888316

8830988317
</dd>
8831088318

88311-
<dt><var>handle</var> = <var>window</var> . <code subdfn data-x="dom-windowtimers-setInterval">setInterval</code>( <var>handler</var> [, <var>timeout</var> [, <var>arguments</var>... ] ] )</dt>
88319+
<dt><var>handle</var> = self . <code subdfn data-x="dom-setInterval">setInterval</code>( <var>handler</var> [, <var>timeout</var> [, <var>arguments</var>... ] ] )</dt>
8831288320

8831388321
<dd>
8831488322

@@ -88317,22 +88325,21 @@ interface <dfn>WindowTimers</dfn> {
8831788325

8831888326
</dd>
8831988327

88320-
<dt><var>handle</var> = <var>window</var> . <code data-x="dom-windowtimers-setInterval">setInterval</code>( <var>code</var> [, <var>timeout</var> ] )</dt>
88328+
<dt><var>handle</var> = self . <code data-x="dom-setInterval">setInterval</code>( <var>code</var> [, <var>timeout</var> ] )</dt>
8832188329

8832288330
<dd>
8832388331

8832488332
<p>Schedules a timeout to compile and run <var>code</var> every <var>timeout</var> milliseconds.</p>
8832588333

8832688334
</dd>
8832788335

88328-
<dt><var>window</var> . <code subdfn data-x="dom-windowtimers-clearInterval">clearInterval</code>( <var>handle</var> )</dt>
88336+
<dt>self . <code subdfn data-x="dom-clearInterval">clearInterval</code>( <var>handle</var> )</dt>
8832988337
<!-- don't mention that the handle is optional, since if omitted, the method does nothing -->
8833088338

8833188339
<dd>
8833288340

88333-
<p>Cancels the timeout set with <code data-x="dom-windowtimers-setInterval">setInterval()
88334-
</code> or <code data-x="dom-windowtimers-setTimeout">setTimeout()</code> identified by <var>
88335-
handle</var>.</p>
88341+
<p>Cancels the timeout set with <code data-x="dom-setInterval">setInterval()</code> or <code
88342+
data-x="dom-setTimeout">setTimeout()</code> identified by <var>handle</var>.</p>
8833688343

8833788344
</dd>
8833888345

@@ -88346,34 +88353,41 @@ interface <dfn>WindowTimers</dfn> {
8834688353

8834788354
<div w-nodev>
8834888355

88349-
<p>Objects that implement the <code>WindowTimers</code> interface have a <dfn>list of active
88350-
timers</dfn>. Each entry in this lists is identified by a number, which must be unique within the
88351-
list for the lifetime of the object that implements the <code>WindowTimers</code> interface.</p>
88356+
<p>Objects that implement the <code>WindowOrWorkerGlobalScope</code> mixin have a <dfn>list of
88357+
active timers</dfn>. Each entry in this lists is identified by a number, which must be unique
88358+
within the list for the lifetime of the object that implements the
88359+
<code>WindowOrWorkerGlobalScope</code> mixin.</p>
8835288360

8835388361
<hr>
8835488362

88355-
<p>The <dfn><code data-x="dom-windowtimers-setTimeout">setTimeout()</code></dfn> method must return
88356-
the value returned by the <span>timer initialisation steps</span>, passing them the method's
88357-
arguments, the object on which the method for which the algorithm is running is implemented (a
88358-
<code>Window</code> or <code>WorkerGlobalScope</code> object) as the <var>method
88359-
context</var>, and the <var>repeat</var> flag set to false.</p>
88360-
88361-
<p>The <dfn><code data-x="dom-windowtimers-setInterval">setInterval()</code></dfn> method must
88362-
return the value returned by the <span>timer initialisation steps</span>, passing them the
88363-
method's arguments, the object on which the method for which the algorithm is running is
88364-
implemented (a <code>Window</code> or <code>WorkerGlobalScope</code> object) as the <var>method context</var>, and the <var>repeat</var> flag set to true.</p>
88365-
88366-
<p>The <dfn><code data-x="dom-windowtimers-clearTimeout">clearTimeout()</code></dfn> and <dfn><code data-x="dom-windowtimers-clearInterval">clearInterval()</code></dfn> methods must clear the
88367-
entry identified as <var>handle</var> from the <span>list of active timers</span> of the
88368-
<code>WindowTimers</code> object on which the method was invoked, if any, where <var>handle</var> is the argument passed to the method. (If <var>handle</var> does
88369-
not identify an entry in the <span>list of active timers</span> of the <code>WindowTimers</code>
88370-
object on which the method was invoked, the method does nothing.)</p>
88371-
88372-
<p class="note">Because <code data-x="dom-windowtimers-clearTimeout">clearTimeout()</code> and
88373-
<code data-x="dom-windowtimers-clearInterval">clearInterval()</code> clear entries from the same
88374-
list, either method can be used to clear timers created by
88375-
<code data-x="dom-windowtimers-setTimeout">setTimeout()</code> or
88376-
<code data-x="dom-windowtimers-setInterval">setInterval()</code>.</p>
88363+
<p>The <dfn data-x="dom-setTimeout"><code
88364+
id="dom-windowtimers-setTimeout">setTimeout()</code></dfn> method must return the value returned
88365+
by the <span>timer initialisation steps</span>, passing them the method's arguments, the object on
88366+
which the method for which the algorithm is running is implemented (a <code>Window</code> or
88367+
<code>WorkerGlobalScope</code> object) as the <var>method context</var>, and the <var>repeat</var>
88368+
flag set to false.</p>
88369+
88370+
<p>The <dfn data-x="dom-setInterval"><code
88371+
id="dom-windowtimers-setInterval">setInterval()</code></dfn> method must return the value returned
88372+
by the <span>timer initialisation steps</span>, passing them the method's arguments, the object on
88373+
which the method for which the algorithm is running is implemented (a <code>Window</code> or
88374+
<code>WorkerGlobalScope</code> object) as the <var>method context</var>, and the <var>repeat</var>
88375+
flag set to true.</p>
88376+
88377+
<p>The <dfn data-x="dom-clearTimeout"><code
88378+
id="dom-windowtimers-clearTimeout">clearTimeout()</code></dfn> and <dfn
88379+
data-x="dom-clearInterval"><code id="dom-windowtimers-clearInterval">clearInterval()</code></dfn>
88380+
methods must clear the entry identified as <var>handle</var> from the <span>list of active
88381+
timers</span> of the <code>WindowOrWorkerGlobalScope</code> object on which the method was
88382+
invoked, if any, where <var>handle</var> is the argument passed to the method. (If
88383+
<var>handle</var> does not identify an entry in the <span>list of active timers</span> of the
88384+
<code>WindowOrWorkerGlobalScope</code> object on which the method was invoked, the method does
88385+
nothing.)</p>
88386+
88387+
<p class="note">Because <code data-x="dom-clearTimeout">clearTimeout()</code> and <code
88388+
data-x="dom-clearInterval">clearInterval()</code> clear entries from the same list, either method
88389+
can be used to clear timers created by <code data-x="dom-setTimeout">setTimeout()</code> or <code
88390+
data-x="dom-setInterval">setInterval()</code>.</p>
8837788391

8837888392
<hr>
8837988393

@@ -90372,15 +90386,7 @@ dictionary <dfn>ImageBitmapOptions</dfn> {
9037290386
<span>ImageOrientation</span> <span data-x="dom-ImageBitmapOptions-imageOrientation">imageOrientation</span> = "<span data-x="dom-ImageOrientation-none">none</span>";
9037390387
<span>PremultiplyAlpha</span> <span data-x="dom-ImageBitmapOptions-premultiplyAlpha">premultiplyAlpha</span> = "<span data-x="dom-PremultiplyAlpha-default">default</span>";
9037490388
<span>ColorspaceConversion</span> <span data-x="dom-ImageBitmapOptions-colorspaceConversion">colorspaceConversion</span> = "<span data-x="dom-ColorspaceConversion-default">default</span>";
90375-
};
90376-
90377-
[NoInterfaceObject, Exposed=(Window,Worker)]
90378-
interface <dfn>ImageBitmapFactories</dfn> {
90379-
Promise&lt;<span>ImageBitmap</span>&gt; <span data-x="dom-createImageBitmap">createImageBitmap</span>(<span>ImageBitmapSource</span> image, optional <span>ImageBitmapOptions</span> options);
90380-
Promise&lt;<span>ImageBitmap</span>&gt; <span data-x="dom-createImageBitmap">createImageBitmap</span>(<span>ImageBitmapSource</span> image, long sx, long sy, long sw, long sh, optional <span>ImageBitmapOptions</span> options);
90381-
};
90382-
<span>Window</span> implements <span>ImageBitmapFactories</span>;
90383-
<span>WorkerGlobalScope</span> implements <span>ImageBitmapFactories</span>;</pre>
90389+
};</pre>
9038490390

9038590391
<p>An <code>ImageBitmap</code> object represents a bitmap image that can be painted to a canvas
9038690392
without undue latency.</p>
@@ -90392,8 +90398,8 @@ interface <dfn>ImageBitmapFactories</dfn> {
9039290398

9039390399
<dl class="domintro">
9039490400

90395-
<dt><var>promise</var> = <var>Window</var> . <code subdfn data-x="dom-createImageBitmap">createImageBitmap</code>(<var>image</var> [, <var>options</var> ])</dt>
90396-
<dt><var>promise</var> = <var>Window</var> . <code data-x="dom-createImageBitmap">createImageBitmap</code>(<var>image</var>, <var>sx</var>, <var>sy</var>, <var>sw</var>, <var>sh</var> [, <var>options</var> ])</dt>
90401+
<dt><var>promise</var> = self . <code subdfn data-x="dom-createImageBitmap">createImageBitmap</code>(<var>image</var> [, <var>options</var> ])</dt>
90402+
<dt><var>promise</var> = self . <code data-x="dom-createImageBitmap">createImageBitmap</code>(<var>image</var>, <var>sx</var>, <var>sy</var>, <var>sw</var>, <var>sh</var> [, <var>options</var> ])</dt>
9039790403

9039890404
<dd>
9039990405

0 commit comments

Comments
 (0)