Skip to content

Commit ea14be5

Browse files
domenicfoolip
authored andcommitted
Remove the pending dialog stack in favor of the top layer
This avoids the problems noted in whatwg#2268 with attempting to keep the two different stacks in sync, and overall simplifies the model. Fixes whatwg#2268. This commit also updates the definition of "blocked by a modal dialog" to account for shadow DOM.
1 parent b324468 commit ea14be5

File tree

1 file changed

+22
-64
lines changed

1 file changed

+22
-64
lines changed

source

Lines changed: 22 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -57079,17 +57079,6 @@ interface <dfn>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
5707957079

5708057080
</ol>
5708157081

57082-
<hr>
57083-
57084-
<p>Each <code>Document</code> has a stack of <code>dialog</code> elements known as the
57085-
<dfn>pending dialog stack</dfn>. When a <code>Document</code> is created, this stack must be
57086-
initialized to be empty.</p>
57087-
57088-
<p>When an element is added to the <span>pending dialog stack</span>, it must also be <span
57089-
data-x="top-layer-add">added</span> to the <span>top layer</span>. When an element is removed from
57090-
the <span>pending dialog stack</span>, it must be <span data-x="list remove">removed</span>
57091-
from the <span>top layer</span>. <ref spec=FULLSCREEN></p>
57092-
5709357082
<p>When the <dfn><code data-x="dom-dialog-showModal">showModal()</code></dfn> method is invoked,
5709457083
the user agent must run the following steps:</p>
5709557084

@@ -57113,8 +57102,10 @@ interface <dfn>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
5711357102
<li><p>Let <var>subject</var>'s <span>node document</span> be <span data-x="blocked by a
5711457103
modal dialog">blocked by the modal dialog</span> <var>subject</var>.</p></li>
5711557104

57116-
<li><p>Push <var>subject</var> onto <var>subject</var>'s
57117-
<span>node document</span>'s <span>pending dialog stack</span>.</p></li>
57105+
<li><p>If <var>subject</var>'s <span>node document</span>'s <span>top layer</span> does not
57106+
already <span data-x="list contains">contain</span> <var>subject</var>, then <span
57107+
data-x="top-layer-add">add</span> <var>subject</var> to <var>subject</var>'s <span>node
57108+
document</span>'s <span>top layer</span>.</p></li>
5711857109

5711957110
<li><p>Run the <span>dialog focusing steps</span> for <var>subject</var>.</p></li>
5712057111

@@ -57146,22 +57137,8 @@ interface <dfn>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
5714657137

5714757138
<p>If at any time a <code>dialog</code> element is <span data-x="node is removed from a
5714857139
document">removed from a <code>Document</code></span>, then if that <code>dialog</code> is in that
57149-
<code>Document</code>'s <span>pending dialog stack</span>, the following steps must be run:</p>
57150-
57151-
<ol>
57152-
57153-
<li><p>Let <var>subject</var> be that <code>dialog</code> element and <var>document</var> be the <code>Document</code> from which it is being removed.</p></li>
57154-
57155-
<li><p>Remove <var>subject</var> from <var>document</var>'s <span>pending
57156-
dialog stack</span>.</p></li>
57157-
57158-
<li><p>If <var>document</var>'s <span>pending dialog stack</span> is not empty, then let
57159-
<var>document</var> be <span data-x="blocked by a modal dialog">blocked by the modal
57160-
dialog</span> that is at the top of <var>document</var>'s <span>pending dialog
57161-
stack</span>. Otherwise, let <var>document</var> be no longer <span>blocked by a modal
57162-
dialog</span> at all.</p></li>
57163-
57164-
</ol>
57140+
<code>Document</code>'s <span>top layer</span>, it must be <span
57141+
data-x="list remove">removed</span> from it.</p>
5716557142

5716657143
<p>When the <dfn><code data-x="dom-dialog-close">close()</code></dfn> method is invoked, the user
5716757144
agent must <span>close the dialog</span> that the method was invoked on. If the method was invoked
@@ -57184,23 +57161,8 @@ interface <dfn>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
5718457161
<li><p>If the argument <var>result</var> was provided, then set the <code
5718557162
data-x="dom-dialog-returnValue">returnValue</code> attribute to the value of <var>result</var>.</p></li>
5718657163

57187-
<li>
57188-
57189-
<p>If <var>subject</var> is in its <code>Document</code>'s <span>pending dialog
57190-
stack</span>, then:</p>
57191-
57192-
<ol>
57193-
57194-
<li><p>Remove <var>subject</var> from that <span>pending dialog stack</span>.</p></li>
57195-
57196-
<li><p>If that <span>pending dialog stack</span> is not empty, then let <var>subject</var>'s <span>node document</span> be <span data-x="blocked by a modal
57197-
dialog">blocked by the modal dialog</span> that is at the top of the <span>pending dialog
57198-
stack</span>. Otherwise, let <var>document</var> be no longer <span>blocked by a modal
57199-
dialog</span> at all.</p></li>
57200-
57201-
</ol>
57202-
57203-
</li>
57164+
<li><p>If <var>subject</var> is in its <code>Document</code>'s <span>top layer</span>, then <span
57165+
data-x="list remove">remove</span> it.</p></li>
5720457166

5720557167
<li><p><span>Queue a task</span> to <span data-x="concept-event-fire">fire an event</span> named
5720657168
<code data-x="event-close">close</code> at <var>subject</var>.</p></li>
@@ -57213,14 +57175,11 @@ interface <dfn>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
5721357175

5721457176
<hr>
5721557177

57216-
<p id="canceling-dialogs"><strong>Canceling dialogs</strong>: When a <code>Document</code>'s
57217-
<span>pending dialog stack</span> is not empty, user agents may provide a user interface that,
57218-
upon activation, <span data-x="queue a task">queues a task</span> to run these steps:
57178+
<p id="canceling-dialogs"><strong>Canceling dialogs</strong>: When <code>Document</code> is
57179+
<span>blocked by a modal dialog</span> <var>dialog</var>, user agents may provide a user interface
57180+
that, upon activation, <span data-x="queue a task">queues a task</span> to run these steps:
5721957181

5722057182
<ol>
57221-
<li><p>Let <var>dialog</var> be the top <code>dialog</code> element on the
57222-
<code>Document</code>'s <span>pending dialog stack</span>.</p></li>
57223-
5722457183
<li><p>Let <var>close</var> be the result of <span data-x="concept-event-fire">firing an
5722557184
event</span> named <code data-x="event-cancel">cancel</code> at <var>dialog</var>, with the <code
5722657185
data-x="dom-Event-cancelable">cancelable</code> attribute initialized to true.</p></li>
@@ -72332,20 +72291,19 @@ END:VCARD</pre>
7233272291
<span>nested browsing context</span>'s <span>active document</span>, and all nodes in that
7233372292
<code>Document</code>, must be marked as <span>inert</span>.</p>
7233472293

72335-
<p>An entire <code>Document</code> can be marked as <dfn>blocked by a modal dialog</dfn>
72336-
<var>subject</var>. While a <code>Document</code> is so marked, every node that is <span
72337-
data-x="in a document">in the <code>Document</code></span>, with the exception of the
72338-
<var>subject</var> element and its descendants, must be marked <span>inert</span>. (The elements
72339-
excepted by this paragraph can additionally be marked <span>inert</span> through other means;
72340-
being part of a modal dialog does not "protect" a node from being marked <span>inert</span>.)</p>
72341-
72342-
<p>Only one element at a time can mark a <code>Document</code> as being <span>blocked by a modal
72343-
dialog</span>. When a new <code>dialog</code> is made to <span data-x="blocked by a modal
72344-
dialog">block</span> a <code>Document</code>, the previous element, if any, stops blocking the
72345-
<code>Document</code>.</p>
72294+
<p>A <code>Document</code> <var>document</var> is <dfn>blocked by a modal dialog</dfn>
72295+
<var>subject</var> if <var>subject</var> is the topmost <code>dialog</code> element in
72296+
<var>document</var>'s <span>top layer</span>. While <var>document</var> is so blocked, every node
72297+
that is <span>connected</span> to <var>document</var>, with the exception of the
72298+
<var>subject</var> element and its <span data-x="shadow-including descendant">shadow-including
72299+
descendants</span>, must be marked <span>inert</span>. (The elements excepted by this paragraph
72300+
can additionally be marked <span>inert</span> through other means; being part of a modal dialog
72301+
does not "protect" a node from being marked <span>inert</span>.)</p>
7234672302

7234772303
<p class="note">The <code>dialog</code> element's <code
72348-
data-x="dom-dialog-showModal">showModal()</code> method makes use of this mechanism.</p>
72304+
data-x="dom-dialog-showModal">showModal()</code> method causes this mechanism to trigger, by <span
72305+
data-x="top-layer-add">adding</span> the <code>dialog</code> element to its <span>node
72306+
document</span>'s <span>top layer</span>.</p>
7234972307

7235072308

7235172309

0 commit comments

Comments
 (0)