Skip to content

Commit 1b2fac9

Browse files
committed
Fire events at elements by default, falling back to documents
Fixes #89. Tests: web-platform-tests/wpt#6017
1 parent cbdc4f7 commit 1b2fac9

File tree

1 file changed

+56
-19
lines changed

1 file changed

+56
-19
lines changed

fullscreen.bs

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,30 @@ security risk, or platform limitation.
133133
</ul>
134134
<!-- cross-process -->
135135

136+
<hr>
137+
138+
<p>To <dfn>fire a fullscreen event</dfn> named <var>e</var> for an (<var>element</var>,
139+
<var>document</var>) <a>pair</a>, run these steps:
140+
141+
<ol>
142+
<li><p>Let <var>target</var> be <var>element</var> if <var>element</var> is <a>connected</a>
143+
and its <a>node document</a> is <var>document</var>, and otherwise let <var>target</var> be
144+
<var>document</var>.
145+
146+
<li><p><a>Fire an event</a> named <var>e</var>, with its {{Event/bubbles}} and {{Event/composed}}
147+
attributes set to true, at <var>target</var>.
148+
</ol>
149+
136150

137151

138152
<h2 id=api>API</h2>
139153

140154
<pre class=idl>
141155
partial interface Element {
142156
Promise&lt;void> requestFullscreen();
157+
158+
attribute EventHandler onfullscreenchange;
159+
attribute EventHandler onfullscreenerror;
143160
};
144161

145162
partial interface Document {
@@ -156,6 +173,8 @@ partial interface DocumentOrShadowRoot {
156173
[LenientSetter] readonly attribute Element? fullscreenElement;
157174
};
158175
</pre>
176+
<!-- The event handler attributes are intentially not in a partial DocumentAndElementEventHandlers
177+
interface, which is implemented by Document and HTMLElement, not Element. -->
159178

160179
<dl class=domintro>
161180
<dt><code><var>promise</var> = <var>element</var> . {{Element/requestFullscreen()}}</code>
@@ -241,9 +260,9 @@ these steps:
241260
<!-- cross-process; check is only needed on pending as it is recursive already -->
242261
</ul>
243262

244-
<li><p>If <var>error</var> is true, <a>fire an event</a> named <code>fullscreenerror</code> on
245-
<var>pendingDoc</var>, reject <var>promise</var> with a <code>TypeError</code> exception, and
246-
terminate these steps.
263+
<li><p>If <var>error</var> is true, <a>fire a fullscreen event</a> named
264+
<code>fullscreenerror</code> for (<var>pending</var>, <var>pendingDoc</var>), reject
265+
<var>promise</var> with a <code>TypeError</code> exception, and terminate these steps.
247266

248267
<li><p>Let <var>fullscreenElements</var> be an <a>ordered set</a> initially consisting of
249268
<var>pending</var>.
@@ -253,7 +272,7 @@ these steps:
253272
<var>fullscreenElements</var>.
254273
<!-- cross-process -->
255274

256-
<li><p>Let <var>eventDocs</var> be a new <a>ordered set</a>.
275+
<li><p>Let <var>eventPairs</var> be a new <a>ordered set</a>.
257276

258277
<li>
259278
<p><a>For each</a> <var>element</var> in <var>fullscreenElements</var>:
@@ -266,16 +285,19 @@ these steps:
266285

267286
<p class=note>No need to notify observers when nothing has changed.
268287

269-
<li><p>Otherwise, <a for=set>append</a> <var>doc</var> to <var>eventDocs</var>.
288+
<li><p>Otherwise, <a for=set>append</a> (<var>element</var>, <var>doc</var>) to
289+
<var>eventPairs</var>.
270290

271291
<li><p>If <var>element</var> is <var>pending</var> and <var>pending</var> is an <{iframe}>
272292
<a>element</a>, then set <var>element</var>'s <a>iframe fullscreen flag</a>.
273293

274294
<li><p><a lt="fullscreen an element">Fullscreen <var>element</var></a> within <var>doc</var>.
275295
</ol>
276296

277-
<li><p><a>For each</a> <var>doc</var> in <var>eventDocs</var>, <a>fire an event</a>
278-
named <code>fullscreenchange</code> on <var>doc</var>.
297+
<li><p><a>For each</a> (<var>element</var>, <var>document</var>) in <var>eventPairs</var>:
298+
<a>fire a fullscreen event</a> named <code>fullscreenchange</code> for (<var>element</var>,
299+
<var>document</var>).
300+
</ol>
279301

280302
<li><p>Resolve <var>promise</var> with undefined.
281303
</ol>
@@ -397,25 +419,36 @@ could be an open <{dialog}> element.
397419
<code>TypeError</code> exception, and terminate these steps.
398420
<!-- cross-process -->
399421

422+
<li><p>Let <var>eventPairs</var> be a new <a>ordered set</a>.
423+
400424
<li><p>Let <var>descendantDocs</var> be an <a>ordered set</a> consisting of <var>doc</var>'s
401425
<a>descendant browsing contexts</a>' <a>active documents</a> whose <a>fullscreen element</a> is
402426
non-null, if any, in <em>reverse</em> <a>tree order</a>.
403427
<!-- cross-process -->
404428

405-
<li><p><a>For each</a> <var>descendantDoc</var> in <var>descendantDocs</var>,
406-
<a lt="unfullscreen a document">unfullscreen <var>descendantDoc</var></a>.
407-
<!-- cross-process -->
429+
<li>
430+
<p><a>For each</a> <var>descendantDoc</var> in <var>descendantDocs</var>:
408431

409-
<li><p><a>For each</a> <var>exitDoc</var> in <var>exitDocs</var>,
410-
<a lt="unfullscreen an element">unfullscreen</a> <var>exitDoc</var>'s <a>fullscreen element</a>.
432+
<ol>
433+
<li><p><a for=set>Append</a> (<var>descendantDoc</var>'s <a>fullscreen element</a>,
434+
<var>descendantDoc</var>) to <var>eventPairs</var>.
411435

412-
<li><p><a>For each</a> <var>descendantDoc</var> in <var>descendantDocs</var>,
413-
<a>fire an event</a> named <code>fullscreenchange</code> on <var>descendantDoc</var>.
414-
<!-- cross-process -->
436+
<li><p><a lt="unfullscreen a document">Unfullscreen <var>descendantDoc</var></a>.
437+
</ol>
415438

416-
<li><p><a>For each</a> <var>exitDoc</var> in <var>exitDocs</var>, <a>fire an event</a> named
417-
<code>fullscreenchange</code> on <var>exitDoc</var>.
418-
<!-- cross-process -->
439+
<li>
440+
<p><a>For each</a> <var>exitDoc</var> in <var>exitDocs</var>:
441+
442+
<ol>
443+
<li><p><a for=set>Append</a> (<var>exitDoc</var>'s <a>fullscreen element</a>,
444+
<var>exitDoc</var>) to <var>eventPairs</var>.
445+
446+
<li><p><a lt="unfullscreen an element">Unfullscreen</a> <var>exitDoc</var>'s <a>fullscreen element</a>.
447+
</ol>
448+
449+
<li><p><a>For each</a> (<var>element</var>, <var>document</var>) in <var>eventPairs</var>:
450+
<a>fire a fullscreen event</a> named <code>fullscreenchange</code> for (<var>element</var>,
451+
<var>document</var>).
419452

420453
<li><p>Resolve <var>promise</var> with undefined.
421454
</ol>
@@ -429,7 +462,8 @@ return the result of running <a>exit fullscreen</a> on the <a>context object</a>
429462
<hr>
430463

431464
<p>The following are the <a>event handlers</a> (and their corresponding
432-
<a>event handler event types</a>) that must be supported on <a for=/>documents</a> as attributes:
465+
<a>event handler event types</a>) that must be supported by {{Element}} and {{Document}} objects as
466+
<a>event handler IDL attributes</a>:
433467

434468
<table>
435469
<thead>
@@ -445,6 +479,9 @@ return the result of running <a>exit fullscreen</a> on the <a>context object</a>
445479
<td><code>fullscreenerror</code>
446480
</table>
447481

482+
<p class=note>These are not supported by {{ShadowRoot}} or {{Window}} objects, and there are no
483+
corresponding <a>event handler content attributes</a> for {{Element}} objects in any namespace.
484+
448485

449486

450487
<h2 id=ui>UI</h2>

0 commit comments

Comments
 (0)