Skip to content

Commit c228737

Browse files
committed
Change initial quota computation to a switch statement
1 parent d97b105 commit c228737

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
@@ -6763,7 +6763,7 @@ sources, specifically task sources that can result in running scripts such as th
67636763
<div algorithm>
67646764
<p>To <dfn>queue a deferred fetch</dfn> given a <a for=/>request</a> <var>request</var>, a
67656765
<a for=fetch>fetch group</a> <var>fetchGroup</var>, a null or {{DOMHighResTimeStamp}}
6766-
<var>activateAfter</var>, and <var>onActivatedWithoutTermination</var>, which is
6766+
<var>activateAfter</var>, and <var>onActivatedWithoutTermination</var>, which is an algorithm that
67676767
takes no arguments:
67686768

67696769
<ol>
@@ -6802,7 +6802,7 @@ takes no arguments:
68026802
<li><p>If the result of calling <a>process a deferred fetch</a> given <var>deferredRecord</var>
68036803
returns true, then <a>queue a global task</a> on the <a>deferred fetch task source</a> with
68046804
<var>request</var>'s <a for=request>client</a>'s
6805-
<a for="environment settings object">global object</a> and
6805+
<a for="environment settings object">global object</a> to run
68066806
<var>onActivatedWithoutTermination</var>.
68076807
</ol>
68086808
</li>
@@ -6834,10 +6834,14 @@ takes no arguments:
68346834
</div>
68356835

68366836
<div algorithm>
6837-
<p>To <dfn>process deferred fetches</dfn> given a <a>fetch group</a> <var>fetchGroup</var>,
6838-
<a for=list>for each</a> <a for="fetch group">deferred fetch record</a> <var>deferredRecord</var> of
6839-
<var>fetchGroup</var>'s <a for="fetch group">deferred fetch records</a>
6840-
<a>process a deferred fetch</a> <var>deferredRecord</var>.
6837+
<p>To <dfn>process deferred fetches</dfn> given a <a>fetch group</a> <var>fetchGroup</var>:
6838+
6839+
<ol>
6840+
<li><p><a for=list>For each</a> <a for="fetch group">deferred fetch record</a>
6841+
<var>deferredRecord</var> of <var>fetchGroup</var>'s
6842+
<a for="fetch group">deferred fetch records</a>, <a>process a deferred fetch</a>
6843+
<var>deferredRecord</var>.
6844+
</ol>
68416845
</div>
68426846

68436847
<div algorithm>
@@ -6867,15 +6871,15 @@ cross-origin nested documents, each reserving 8 kibibytes.
68676871

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

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

70017005
<ol>
7002-
<li><p>Let <var>quota</var> be 0.
7003-
7004-
<li><p>Let <var>quotaForOrigin</var> be 64 kibibytes.
7005-
70067006
<li>
7007-
<p>If <var>controlDocument</var>'s <a>node navigable</a> is a
7008-
<a for=/>top-level traversable</a>, then:
7007+
<p>Let <var>quota</var> be the result of the first matching statement:
70097008

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

7014-
<li>
7015-
<p>Set <var>quota</var> be 640 kibibytes.
7023+
<dt><var>controlDocument</var>'s <a>node navigable</a> is a
7024+
<a for=/>top-level traversable</a> whose not <a>allowed to use</a> the
7025+
<a>policy-controlled feature</a> "{{PermissionsPolicy/deferred-fetch-minimal}}"
7026+
<dd>
7027+
<p>640 kibibytes
70167028
<p class="note allow-2119">640kb should be enough for everyone.
70177029

7018-
<li><p>If <var>controlDocument</var> is <a>allowed to use</a> the
7019-
<a>policy-controlled feature</a> "{{PermissionsPolicy/deferred-fetch-minimal}}", then
7020-
decrement <var>quota</var> by <a>quota reserved for <code>deferred-fetch-minimal</code></a>.
7021-
</ol>
7030+
<dt><var>controlDocument</var>'s <a>node navigable</a>'s <a>navigable container</a>'s
7031+
<a>reserved deferred-fetch quota</a> is <a for="reserved deferred-fetch quota">normal quota</a>,
7032+
and <var>controlDocument</var> is <a>allowed to use</a> the <a>policy-controlled feature</a>
7033+
"{{PermissionsPolicy/deferred-fetch}}"
7034+
<dd><a for="reserved deferred-fetch quota">normal quota</a>
7035+
7036+
<dt><var>controlDocument</var>'s <a>node navigable</a>'s <a>navigable container</a>'s
7037+
<a>reserved deferred-fetch quota</a> is <a for="reserved deferred-fetch quota">minimal quota</a>,
7038+
and <var>controlDocument</var> is <a>allowed to use</a> the <a>policy-controlled feature</a>
7039+
"{{PermissionsPolicy/deferred-fetch-minimal}}"
7040+
<dd><a for="reserved deferred-fetch quota">minimal quota</a>
7041+
</dl>
70227042

7023-
<p>Otherwise:
7043+
<li>
7044+
<p><a for=list>For each</a> <var>navigable</var> in <var>controlDocument</var>'s
7045+
<a>node navigable</a>'s <a>descendant navigables</a> whose <a>container document</a>'s
7046+
<a>deferred-fetch control document</a> is <var>controlDocument</var>, decrement <var>quota</var>
7047+
by <var>navigable</var>'s <a>navigable container</a>'s <a>reserved deferred-fetch quota</a>.
70247048

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

70427055
<li>
70437056
<p><a for=list>For each</a> <a>deferred fetch record</a> <var>deferredRecord</var> of
@@ -7052,19 +7065,15 @@ descendants share a quota of 384 kibibytes. That value is computed as such:
70527065

70537066
<li><p>If <var>deferredRecord</var>'s <a for="deferred fetch record">request</a>'s
70547067
<a for=request>URL</a>'s <a for=url>origin</a> is <a>same origin</a> with <var>origin</var>,
7055-
then decrement <var>quotaForOrigin</var> by <var>requestLength</var>.
7068+
then decrement <var>quotaForRequestOrigin</var> by <var>requestLength</var>.
70567069
</ol>
70577070

7058-
<li><p><a for=list>For each</a> <var>navigable</var> in <var>controlDocument</var>'s
7059-
<a>node navigable</a>'s <a>descendant navigables</a> whose <a>container document</a>'s
7060-
<a>deferred-fetch control document</a> is <var>controlDocument</var>, decrement <var>quota</var> by
7061-
<var>navigable</var>'s <a>navigable container</a>'s <a>reserved deferred-fetch quota</a>.
7062-
7063-
<li><p>If <var>quota</var> is less than 0, then return 0.
7071+
<li><p>If <var>quota</var> is equal or less than 0, then return 0.
70647072

7065-
<li><p>If <var>quota</var> is less than <var>quotaForOrigin</var>, then return <var>quota</var>.
7073+
<li><p>If <var>quota</var> is less than <var>quotaForRequestOrigin</var>, then return
7074+
<var>quota</var>.
70667075

7067-
<li><p>Return <var>quotaForOrigin</var>.
7076+
<li><p>Return <var>quotaForRequestOrigin</var>.
70687077
</ol>
70697078
</div>
70707079

0 commit comments

Comments
 (0)