Skip to content

Commit 2e8599f

Browse files
committed
Change initial quota computation to a switch statement
1 parent b74644e commit 2e8599f

File tree

1 file changed

+60
-51
lines changed

1 file changed

+60
-51
lines changed

fetch.bs

Lines changed: 60 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6767,7 +6767,7 @@ sources, specifically task sources that can result in running scripts such as th
67676767
<div algorithm>
67686768
<p>To <dfn>queue a deferred fetch</dfn> given a <a for=/>request</a> <var>request</var>, a
67696769
<a for=fetch>fetch group</a> <var>fetchGroup</var>, a null or {{DOMHighResTimeStamp}}
6770-
<var>activateAfter</var>, and <var>onActivatedWithoutTermination</var>, which is
6770+
<var>activateAfter</var>, and <var>onActivatedWithoutTermination</var>, which is an algorithm that
67716771
takes no arguments:
67726772

67736773
<ol>
@@ -6806,7 +6806,7 @@ takes no arguments:
68066806
<li><p>If the result of calling <a>process a deferred fetch</a> given <var>deferredRecord</var>
68076807
returns true, then <a>queue a global task</a> on the <a>deferred fetch task source</a> with
68086808
<var>request</var>'s <a for=request>client</a>'s
6809-
<a for="environment settings object">global object</a> and
6809+
<a for="environment settings object">global object</a> to run
68106810
<var>onActivatedWithoutTermination</var>.
68116811
</ol>
68126812
</li>
@@ -6838,10 +6838,14 @@ takes no arguments:
68386838
</div>
68396839

68406840
<div algorithm>
6841-
<p>To <dfn>process deferred fetches</dfn> given a <a>fetch group</a> <var>fetchGroup</var>,
6842-
<a for=list>for each</a> <a for="fetch group">deferred fetch record</a> <var>deferredRecord</var> of
6843-
<var>fetchGroup</var>'s <a for="fetch group">deferred fetch records</a>
6844-
<a>process a deferred fetch</a> <var>deferredRecord</var>.
6841+
<p>To <dfn>process deferred fetches</dfn> given a <a>fetch group</a> <var>fetchGroup</var>:
6842+
6843+
<ol>
6844+
<li><p><a for=list>For each</a> <a for="fetch group">deferred fetch record</a>
6845+
<var>deferredRecord</var> of <var>fetchGroup</var>'s
6846+
<a for="fetch group">deferred fetch records</a>, <a>process a deferred fetch</a>
6847+
<var>deferredRecord</var>.
6848+
</ol>
68456849
</div>
68466850

68476851
<div algorithm>
@@ -6871,15 +6875,15 @@ cross-origin nested documents, each reserving 8 kibibytes.
68716875

68726876
<p>The top-level {{Document}}, and subsequently its nested documents, can control how much of their
68736877
quota is delegates to cross-origin child documents, using permissions policy. By default,
6874-
"{{PermissionsPolicy/deferred-fetch-minimal}}" is enabled for any origin, while
6878+
the "{{PermissionsPolicy/deferred-fetch-minimal}}" policy is enabled for any origin, while
68756879
"{{PermissionsPolicy/deferred-fetch}}" is enabled for the top-level document's origin only.
68766880
By relaxing the "{{PermissionsPolicy/deferred-fetch}}" policy for particular origins and nested
68776881
documents, the top-level document can allocate 64 kibibytes to those nested documents. Similarly, by
68786882
restricting the "{{PermissionsPolicy/deferred-fetch-minimal}}" policy for a particular origin or
68796883
nested document, the document can prevent the document from reserving the 8 kibibytes it would
6880-
receive by default. By disabling "{{PermissionsPolicy/deferred-fetch-minimal}}" for the top-leve
6881-
document itself, the entire 128 kibibytes delegated quota is collected back into the main pool of
6882-
640 kibibytes.
6884+
receive by default. By disabling the "{{PermissionsPolicy/deferred-fetch-minimal}}" policy for the
6885+
top-level document itself, the entire 128 kibibytes delegated quota is collected back into the main
6886+
pool of 640 kibibytes.
68836887

68846888
<p>Out of the allocated quota for a {{Document}}, only 64 kibibytes can be used concurrently for the
68856889
same reporting origin (the <a for=/>request</a>'s <a for=request>URL</a>'s <a for=url>origin</a>).
@@ -7003,45 +7007,54 @@ descendants share a quota of 384 kibibytes. That value is computed as such:
70037007
<var>controlDocument</var> and an <a for=/>origin</a>-or-null <var>origin</var>:
70047008

70057009
<ol>
7006-
<li><p>Let <var>quota</var> be 0.
7007-
7008-
<li><p>Let <var>quotaForOrigin</var> be 64 kibibytes.
7009-
70107010
<li>
7011-
<p>If <var>controlDocument</var>'s <a>node navigable</a> is a
7012-
<a for=/>top-level traversable</a>, then:
7011+
<p>Let <var>quota</var> be the result of the first matching statement:
70137012

7014-
<ol>
7015-
<li><p>If <var>controlDocument</var> is not <a>allowed to use</a> the
7016-
<a>policy-controlled feature</a> "{{PermissionsPolicy/deferred-fetch}}", then return 0.
7013+
<dl class=switch>
7014+
<dt><var>controlDocument</var>'s <a>node navigable</a> is a
7015+
<a for=/>top-level traversable</a> whose not <a>allowed to use</a> the
7016+
<a>policy-controlled feature</a> "{{PermissionsPolicy/deferred-fetch}}"
7017+
<dd>0
7018+
7019+
<dt><var>controlDocument</var>'s <a>node navigable</a> is a
7020+
<a for=/>top-level traversable</a> whose <a>allowed to use</a> the
7021+
<a>policy-controlled feature</a> "{{PermissionsPolicy/deferred-fetch-minimal}}"
7022+
<dd>
7023+
<p>512 kibibytes
7024+
<p class=note>The default of 640 kibibytes, decremented By
7025+
<a>quota reserved for <code>deferred-fetch-minimal</code></a>)
70177026

7018-
<li>
7019-
<p>Set <var>quota</var> be 640 kibibytes.
7027+
<dt><var>controlDocument</var>'s <a>node navigable</a> is a
7028+
<a for=/>top-level traversable</a> whose not <a>allowed to use</a> the
7029+
<a>policy-controlled feature</a> "{{PermissionsPolicy/deferred-fetch-minimal}}"
7030+
<dd>
7031+
<p>640 kibibytes
70207032
<p class="note allow-2119">640kb should be enough for everyone.
70217033

7022-
<li><p>If <var>controlDocument</var> is <a>allowed to use</a> the
7023-
<a>policy-controlled feature</a> "{{PermissionsPolicy/deferred-fetch-minimal}}", then
7024-
decrement <var>quota</var> by <a>quota reserved for <code>deferred-fetch-minimal</code></a>.
7025-
</ol>
7034+
<dt><var>controlDocument</var>'s <a>node navigable</a>'s <a>navigable container</a>'s
7035+
<a>reserved deferred-fetch quota</a> is <a for="reserved deferred-fetch quota">normal quota</a>,
7036+
and <var>controlDocument</var> is <a>allowed to use</a> the <a>policy-controlled feature</a>
7037+
"{{PermissionsPolicy/deferred-fetch}}"
7038+
<dd><a for="reserved deferred-fetch quota">normal quota</a>
7039+
7040+
<dt><var>controlDocument</var>'s <a>node navigable</a>'s <a>navigable container</a>'s
7041+
<a>reserved deferred-fetch quota</a> is <a for="reserved deferred-fetch quota">minimal quota</a>,
7042+
and <var>controlDocument</var> is <a>allowed to use</a> the <a>policy-controlled feature</a>
7043+
"{{PermissionsPolicy/deferred-fetch-minimal}}"
7044+
<dd><a for="reserved deferred-fetch quota">minimal quota</a>
7045+
</dl>
70267046

7027-
<p>Otherwise:
7047+
<li>
7048+
<p><a for=list>For each</a> <var>navigable</var> in <var>controlDocument</var>'s
7049+
<a>node navigable</a>'s <a>descendant navigables</a> whose <a>container document</a>'s
7050+
<a>deferred-fetch control document</a> is <var>controlDocument</var>, decrement <var>quota</var>
7051+
by <var>navigable</var>'s <a>navigable container</a>'s <a>reserved deferred-fetch quota</a>.
70287052

7029-
<ol>
7030-
<li><p>Let <var>container</var> be <var>controlDocument</var>'s <a>node navigable</a>'s
7031-
<a>navigable container</a>.
7032-
7033-
<li><p>If <var>container</var>'s <a>reserved deferred-fetch quota</a> is
7034-
<a for="reserved deferred-fetch quota">normal quota</a>, and <var>controlDocument</var> is
7035-
<a>allowed to use</a> the <a>policy-controlled feature</a>
7036-
"{{PermissionsPolicy/deferred-fetch}}", then set <var>quota</var> to
7037-
<a for="reserved deferred-fetch quota">normal quota</a>.
7038-
7039-
<li><p>Otherwise, if <var>container</var>'s <a>reserved deferred-fetch quota</a> is
7040-
<a for="reserved deferred-fetch quota">minimal quota</a>, and <var>controlDocument</var> is
7041-
<a>allowed to use</a> the <a>policy-controlled feature</a>
7042-
"{{PermissionsPolicy/deferred-fetch-minimal}}", then set <var>quota</var> to
7043-
<a for="reserved deferred-fetch quota">minimal quota</a>.
7044-
</ol>
7053+
<p class=note>Delegate some of the quota to nested documents that reserved it.
7054+
7055+
<li><p>If <var>quota</var> is equal or less than 0, then return 0.
7056+
7057+
<li><p>Let <var>quotaForRequestOrigin</var> be 64 kibibytes.
70457058

70467059
<li>
70477060
<p><a for=list>For each</a> <a>deferred fetch record</a> <var>deferredRecord</var> of
@@ -7056,19 +7069,15 @@ descendants share a quota of 384 kibibytes. That value is computed as such:
70567069

70577070
<li><p>If <var>deferredRecord</var>'s <a for="deferred fetch record">request</a>'s
70587071
<a for=request>URL</a>'s <a for=url>origin</a> is <a>same origin</a> with <var>origin</var>,
7059-
then decrement <var>quotaForOrigin</var> by <var>requestLength</var>.
7072+
then decrement <var>quotaForRequestOrigin</var> by <var>requestLength</var>.
70607073
</ol>
70617074

7062-
<li><p><a for=list>For each</a> <var>navigable</var> in <var>controlDocument</var>'s
7063-
<a>node navigable</a>'s <a>descendant navigables</a> whose <a>container document</a>'s
7064-
<a>deferred-fetch control document</a> is <var>controlDocument</var>, decrement <var>quota</var> by
7065-
<var>navigable</var>'s <a>navigable container</a>'s <a>reserved deferred-fetch quota</a>.
7066-
7067-
<li><p>If <var>quota</var> is less than 0, then return 0.
7075+
<li><p>If <var>quota</var> is equal or less than 0, then return 0.
70687076

7069-
<li><p>If <var>quota</var> is less than <var>quotaForOrigin</var>, then return <var>quota</var>.
7077+
<li><p>If <var>quota</var> is less than <var>quotaForRequestOrigin</var>, then return
7078+
<var>quota</var>.
70707079

7071-
<li><p>Return <var>quotaForOrigin</var>.
7080+
<li><p>Return <var>quotaForRequestOrigin</var>.
70727081
</ol>
70737082
</div>
70747083

0 commit comments

Comments
 (0)