Skip to content

Commit b5a12a7

Browse files
committed
Split task handles to allow canceling only lose interest tasks, and do that for all upstream interest sources on any "show" interest change
1 parent 9abafb2 commit b5a12a7

File tree

1 file changed

+104
-36
lines changed

1 file changed

+104
-36
lines changed

source

Lines changed: 104 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -91849,11 +91849,12 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
9184991849
elements</span> in the document that have a non-null <span>active interest target</span>, in the
9185091850
order that interest was <span data-x="gain interest">gained</span>.</p>
9185191851

91852-
<p>Every <span data-x="HTML elements">HTML element</span> has a <dfn>pending interest change
91853-
handle</dfn>, which is a <span>unique internal value</span> or null, initially null.</p>
91852+
<p>Every <span data-x="HTML elements">HTML element</span> has a <dfn>pending gain interest
91853+
handle</dfn> and a <dfn>pending lose interest handle</dfn>, which are both a <span>unique internal
91854+
value</span> or null, initially null.</p>
9185491855

91855-
<p class="note">The <span>pending interest change handle</span> is used to abort steps that run
91856-
after a timeout.</p>
91856+
<p class="note">These handles are used to abort steps that run after a timeout, effectively
91857+
canceling the tasks.</p>
9185791858

9185891859
<p>Every element has an element-or-null <dfn>active interest source</dfn>, initially null.</p>
9185991860

@@ -91895,17 +91896,26 @@ dictionary <dfn dictionary>InterestEventInit</dfn> : <span>EventInit</span> {
9189591896
<var>show</var>:</p>
9189691897

9189791898
<ol>
91898-
<li><p>Let <var>nearestSource</var> be <var>element</var>'s <span>nearest inclusive active
91899-
interest source</span>.</p></li>
91900-
9190191899
<li>
91902-
<p>If <var>nearestSource</var> is not null, <span>handle interest change</span> for
91903-
<var>nearestSource</var> and <var>show</var>.</p>
91900+
<p>If <var>show</var> is true:</p>
91901+
91902+
<ol>
91903+
<li>
91904+
<p>For each element <var>upstream</var> in <var>element</var>'s <span>recursive active
91905+
interest sources</span>:</p>
91906+
91907+
<ol>
91908+
<li>
91909+
<p>Set <var>upstream</var>'s <span>pending lose interest handle</span> to null.</p>
9190491910

91905-
<p class="note">User interactions such as hovering or focusing an interest target or its
91906-
descendants have the same effect as interactions with the interest source. This prevents
91907-
interest from being lost while the user is interacting with the target. Since an element can
91908-
simultaneously be both an interest source and target, the following steps are still run.</p>
91911+
<p class="note">This effectively cancels any pending task to <span>lose interest</span> for
91912+
<var>upstream</var>. User interactions such as hovering or focusing an interest target or
91913+
its descendants prevent those tasks for running, so that interest isn't lost while the user
91914+
is interacting with the target.</p>
91915+
</li>
91916+
</ol>
91917+
</li>
91918+
</ol>
9190991919
</li>
9191091920

9191191921
<li><p>If <var>element</var> is not an <code>a</code>, <code>area</code>, or <code>button</code>
@@ -91930,64 +91940,120 @@ dictionary <dfn dictionary>InterestEventInit</dfn> : <span>EventInit</span> {
9193091940

9193191941
<li><p>Let <var>uniqueHandle</var> be null.</p></li>
9193291942

91943+
<li><p>Let <var>task</var> be null.</p></li>
91944+
9193391945
<li>
91934-
<p>Let <var>task</var> be a <span data-x="concept-task">task</span> that runs the following
91946+
<p>If <var>show</var> is true, set <var>task</var> to a <span data-x="concept-task">task</span> that runs the following
9193591947
substeps:</p>
9193691948

9193791949
<ol>
9193891950
<li><p><span>Assert</span>: <var>uniqueHandle</var> is a <span>unique internal value</span>,
9193991951
not null.</p></li>
9194091952

91941-
<li><p>If <var>uniqueHandle</var> is not in <var>element</var>'s <span>pending interest
91942-
change handle</span>, then abort these steps.</p></li>
91953+
<li><p>If <var>uniqueHandle</var> is not <var>element</var>'s <span>pending gain interest
91954+
handle</span>, then abort these steps.</p></li>
9194391955

91944-
<li><p>Set <var>element</var>'s <span>pending interest change handle</span> to null.</p></li>
91956+
<li><p>Set <var>element</var>'s <span>pending gain interest handle</span> to null.</p></li>
9194591957

9194691958
<li><p>If the <span>interest ready check</span> for <var>element</var> and <var>target</var>
9194791959
returns false, then abort these steps.</p></li>
9194891960

91949-
<li><p>If <var>show</var> is true, then <span>gain interest</span> in <var>element</var> with
91950-
<var>target</var>.</p></li>
91961+
<li><p><span>Gain interest</span> in <var>element</var> with <var>target</var>.</p></li>
91962+
</ol>
91963+
</li>
9195191964

91952-
<li><p>Otherwise, <span>lose interest</span> in <var>element</var> with
91953-
<var>target</var>.</p></li>
91965+
<li>
91966+
<p>Otherwise, set <var>task</var> to a <span data-x="concept-task">task</span> that runs the following
91967+
substeps:</p>
91968+
91969+
<ol>
91970+
<li><p><span>Assert</span>: <var>uniqueHandle</var> is a <span>unique internal value</span>,
91971+
not null.</p></li>
91972+
91973+
<li><p>If <var>uniqueHandle</var> is not <var>element</var>'s <span>pending lose interest
91974+
handle</span>, then abort these steps.</p></li>
91975+
91976+
<li><p>Set <var>element</var>'s <span>pending lose interest handle</span> to null.</p></li>
91977+
91978+
<li><p>If the <span>interest ready check</span> for <var>element</var> and <var>target</var>
91979+
returns false, then abort these steps.</p></li>
91980+
91981+
<li><p><span>Lose interest</span> in <var>element</var> with <var>target</var>.</p></li>
9195491982
</ol>
91983+
</li>
9195591984

91956-
<li><p>Let <var>completionStep</var> be an algorithm step which <span data-x="queue a global
91957-
task">queues a global task</span> on the <span>timer task source</span> given
91958-
<var>global</var> to run <var>task</var>.</p></li>
91985+
<li><p><span>Assert</span>: <var>task</var> is a <span
91986+
data-x="concept-task">task</span>.</p></li>
91987+
91988+
<li><p>Let <var>completionStep</var> be an algorithm step which <span data-x="queue a global
91989+
task">queues a global task</span> on the <span>timer task source</span> given
91990+
<var>global</var> to run <var>task</var>.</p></li>
9195991991

9196091992
<li><p>Set <var>uniqueHandle</var> to the result of <span data-x="run steps after a
9196191993
timeout">running steps after a timeout</span> given <var>global</var>, "<code
9196291994
data-x="">interest change</code>", <var>timeout</var>, and
9196391995
<var>completionStep</var>.</p></li>
9196491996

91965-
<li><p>Set <var>element</var>'s <span>pending interest change handle</span> to
91997+
<li><p>If <var>show</var> is true, set <var>element</var>'s <span>pending gain interest
91998+
handle</span> to <var>uniqueHandle</var>.</p></li>
91999+
92000+
<li><p>Otherwise, set <var>element</var>'s <span>pending lose interest handle</span> to
9196692001
<var>uniqueHandle</var>.</p></li>
9196792002
</ol>
9196892003
</div>
9196992004

9197092005
<div algorithm>
91971-
<p>To find the <dfn>nearest inclusive active interest source</dfn> given an element
91972-
<var>element</var>, perform the following steps. They return an element or null.</p>
92006+
<p>To find the <dfn>recursive active interest sources</dfn> given an element <var>element</var>,
92007+
perform the following steps. They return a <span>list</span> of zero or more elements.</p>
9197392008

9197492009
<ol>
91975-
<li><p>Let <var>current</var> be <var>element</var>.</p></li>
92010+
<li><p>Let <var>sources</var> be an empty <span>list</span>.</p></li>
92011+
92012+
<li><p>Let <var>pending</var> be an empty <span>queue</span>.</p></li>
92013+
92014+
<li><p><span>Enqueue</span> <var>element</var> in <var>pending</var>.</p></li>
9197692015

9197792016
<li>
91978-
<p>While <var>current</var> is not null:</p>
92017+
<p>While <var>pending</var> <span data-x="list is empty">is not empty</span>:</p>
9197992018

9198092019
<ol>
91981-
<li><p>If <var>current</var>'s <span>active interest source</span> is not null, then return
91982-
that <span>active interest source</span>.</p></li>
92020+
<li><p>Let <var>current</var> be the result of <span data-x="dequeue">dequeuing</span> from
92021+
<var>pending</var>.</p></li>
92022+
92023+
<li>
92024+
<p>While <var>current</var> is not null:</p>
92025+
92026+
<ol>
92027+
<li><p>Let <var>source</var> be <var>current</var>'s <span>active interest
92028+
source</span>.</p></li>
9198392029

91984-
<li><p>Set <var>current</var> to <var>current</var>'s <span>parent element</span>.</p></li>
92030+
<li>
92031+
<p>If <var>source</var> is not null and <var>sources</var> does not <span data-x="list
92032+
contains">contain</span> <var>source</var>:</p>
92033+
92034+
<ol>
92035+
<li><p><span data-x="list append">Append</span> <var>source</var> to
92036+
<var>sources</var>.</p></li>
92037+
92038+
<li><p><span>Enqueue</span> <var>source</var> in <var>pending</var>.</p></li>
92039+
</ol>
92040+
</li>
92041+
92042+
<li><p>Set <var>current</var> to <var>current</var>'s <span>parent element</span>.</p></li>
92043+
</ol>
92044+
</li>
9198592045
</ol>
9198692046
</li>
9198792047

91988-
<li><p>Return null.</p></li>
92048+
<li><p>Return <var>sources</var>.</p></li>
9198992049
</ol>
91990-
</div>
92050+
</div>
92051+
92052+
<p class="note">The <span>recursive active interest sources</span> algorithm finds all elements
92053+
whose <span>active interest target</span> contains (inclusively) a given element, as well as any
92054+
elements that indirect interest sources through the same condition applied recursively. In effect,
92055+
all "upstream" interest sources in a graph of active interest target relations are found. Because
92056+
cycles are possible, it is defined iteratively to avoid infinite loops.</p>
9199192057

9199292058
<div algorithm>
9199392059
<p>The <dfn>interest ready check</dfn> for an <span data-x="HTML elements">HTML element</span>
@@ -92023,7 +92089,7 @@ dictionary <dfn dictionary>InterestEventInit</dfn> : <span>EventInit</span> {
9202392089
<ol>
9202492090
<li>
9202592091
<p>If <var>source</var>'s <span>active interest target</span> is <var>target</var>, then set
92026-
<var>source</var>'s <span>pending interest change handle</span> to null and return.</p>
92092+
<var>source</var>'s <span>pending lose interest handle</span> to null and return.</p>
9202792093

9202892094
<p class="note">Interest has already been gained for the correct target and there is nothing
9202992095
to do except to cancel pending tasks.</p>
@@ -92131,7 +92197,9 @@ dictionary <dfn dictionary>InterestEventInit</dfn> : <span>EventInit</span> {
9213192197

9213292198
<li><p>Set <var>target</var>'s <span>active interest source</span> to null.</p></li>
9213392199

92134-
<li><p>Set <var>source</var>'s <span>pending interest change handle</span> to null.</p></li>
92200+
<li><p>Set <var>source</var>'s <span>pending gain interest handle</span> to null.</p></li>
92201+
92202+
<li><p>Set <var>source</var>'s <span>pending lose interest handle</span> to null.</p></li>
9213592203
</ol>
9213692204
</div>
9213792205

0 commit comments

Comments
 (0)