Skip to content

Commit fd52823

Browse files
committed
Make algo a bit more readable
1 parent 6b4976b commit fd52823

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

fetch.bs

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,7 +2762,10 @@ not <a for=Document>fully active</a>. It has the following <a for=struct>items</
27622762
</dl>
27632763

27642764
<p>Each <a>navigable container</a> has an associated number
2765-
<dfn>reserved deferred-fetch quota</dfn>. Unless stated otherwise, it is 0.
2765+
<dfn>reserved deferred-fetch quota</dfn>. Its possible values are
2766+
<dfn for="reserved deferred-fetch quota">minimal quota</dfn>, which is 8 kibibytes,
2767+
<dfn for="reserved deferred-fetch quota">normal quota</dfn>, which is 64 kibibytes, or 0. Unless
2768+
stated otherwise, it is 0.
27662769

27672770
<hr>
27682771

@@ -7033,14 +7036,13 @@ descendants share a quota of 384 kibibytes. That value is computed as such:
70337036
<li>
70347037
<p>If <var>otherContainer</var> is null, then:
70357038

7036-
<p class=note>Initialize the quota from the top-level traversable.
7039+
<p class=note>Accumulate the <a for=/>top-level traversable</a>'s initial quota.
70377040

70387041
<ol>
7039-
<li><p>Assert: <var>quota</var> is 0.
7042+
<li><p>If <var>otherDocument</var> is not <a>allowed to use</a> the
7043+
<a>policy-controlled feature</a> "{{PermissionsPolicy/deferred-fetch}}", then return 0.
70407044

7041-
<li><p>If <var>otherDocument</var> is not
7042-
<a>allowed to use</a> the <a>policy-controlled feature</a>
7043-
"{{PermissionsPolicy/deferred-fetch}}", then return 0.
7045+
<li><p>Assert: <var>quota</var> is 0.
70447046

70457047
<li>
70467048
<p>Set <var>quota</var> be 640 kibibytes.
@@ -7049,30 +7051,35 @@ descendants share a quota of 384 kibibytes. That value is computed as such:
70497051
<li><p>If <var>otherDocument</var> is <a>allowed to use</a> the
70507052
<a>policy-controlled feature</a> "{{PermissionsPolicy/deferred-fetch-minimal}}", then
70517053
decrement <var>quota</var> by <a>max containers with minimal quota</a>, multiplied by
7052-
<a for="reserved deferred-fetch quota">minimal</a>.
7054+
<a for="reserved deferred-fetch quota">minimal quota</a>.
70537055
</ol>
70547056

70557057
<li>
70567058
<p>Otherwise, if any of the following conditions is true:
7059+
70577060
<ul class=brief>
70587061
<li><p><var>otherContainer</var>'s <a>reserved deferred-fetch quota</a> is
7059-
<a for="reserved deferred-fetch quota">normal</a>, and <var>otherDocument</var> is
7062+
<a for="reserved deferred-fetch quota">normal quota</a>, and <var>otherDocument</var> is
70607063
<a>allowed to use</a> the <a>policy-controlled feature</a>
70617064
"{{PermissionsPolicy/deferred-fetch}}"
70627065

70637066
<li><p><var>otherContainer</var>'s <a>reserved deferred-fetch quota</a> is
7064-
<a for="reserved deferred-fetch quota">minimal</a>, and <var>otherDocument</var> is
7067+
<a for="reserved deferred-fetch quota">minimal quota</a>, and <var>otherDocument</var> is
70657068
<a>allowed to use</a> the <a>policy-controlled feature</a>
70667069
"{{PermissionsPolicy/deferred-fetch-minimal}}"
70677070
</ul>
70687071

70697072
<p>then increment <var>quota</var> by <var>otherContainer</var>'s
70707073
<a>reserved deferred-fetch quota</a>.
7074+
<p class=note>Accumulate quota granted by parent documents.
70717075

70727076
<li>
70737077
<p><a for=list>For each</a> <a>deferred fetch record</a> <var>deferredRecord</var> of
70747078
<var>otherDocument</var>'s <a for=fetch>fetch group</a>'s
70757079
<a for="fetch group">deferred fetch records</a>:</p>
7080+
7081+
<p class=note>Account for quota on deferred fetches performed by <a>same origin</a> clients.
7082+
70767083
<ol>
70777084
<li><p>Let <var>requestLength</var> be the <a>total request length</a> of
70787085
<var>deferredRecord</var>'s <a for="deferred fetch record">request</a>.
@@ -7085,17 +7092,17 @@ descendants share a quota of 384 kibibytes. That value is computed as such:
70857092
</ol>
70867093
</ol>
70877094

7088-
<li><p>Otherwise, if <var>otherDocument</var>'s <a>container document</a> is a {{Document}} whose
7089-
<a for=Document>origin</a> is <a>same origin</a> with <var>requestClientDocument</var>'s
7090-
<a for=Document>origin</a>, then decrement <var>quota</var> by <var>otherNavigable</var>'s
7091-
<a>navigable container</a>'s <a>reserved deferred-fetch quota</a>.
7092-
</ol>
7093-
7094-
<li><p>If <var>quota</var> is less than 0, than return 0.
7095+
<li>
7096+
<p>If <var>otherDocument</var>'s <a>container document</a> is a {{Document}} whose
7097+
<a for=Document>origin</a> is <a>same origin</a> with <var>requestClientDocument</var>'s
7098+
<a for=Document>origin</a>, then decrement <var>quota</var> by <var>otherNavigable</var>'s
7099+
<a>navigable container</a>'s <a>reserved deferred-fetch quota</a>.
70957100

7096-
<li><p>If <var>quota</var> is less than <var>quotaForOrigin</var>, then
7097-
return <var>quota</var>.
7101+
<p class=note>Account for quota granted to child documents.
7102+
</ol>
70987103

7104+
<li><p>If <var>quota</var> is less than 0, then return 0.
7105+
<li><p>If <var>quota</var> is less than <var>quotaForOrigin</var>, then return <var>quota</var>.
70997106
<li><p>Return <var>quotaForOrigin</var>.
71007107
</ol>
71017108
</div>
@@ -7120,8 +7127,8 @@ shared.
71207127
for "{{PermissionsPolicy/deferred-fetch}}", <var>container</var> and <var>originToNavigateTo</var>
71217128
is <code>Enabled</code>, and the <a>available deferred-fetch quota</a> for
71227129
<var>container</var>'s <a>container document</a> is equal or greater than
7123-
<a for="reserved deferred-fetch quota">normal</a>, then set <var>container</var>'s
7124-
<a>reserved deferred-fetch quota</a> to <a for="reserved deferred-fetch quota">normal</a> and
7130+
<a for="reserved deferred-fetch quota">normal quota</a>, then set <var>container</var>'s
7131+
<a>reserved deferred-fetch quota</a> to <a for="reserved deferred-fetch quota">normal quota</a> and
71257132
return.
71267133

71277134
<li><p>If the <a data-lt="define an inherited policy for feature in container">inherited policy</a>
@@ -7137,11 +7144,11 @@ shared.
71377144
<a>node navigable</a>'s <a for=navigable>top-level traversable</a>'s
71387145
<a>descendant navigables</a>, <a for=list data-lt=remove>removing</a> any <a for=/>navigable</a>
71397146
whose <a>reserved deferred-fetch quota</a> is not
7140-
<a for="reserved deferred-fetch quota">minimal</a> .
7147+
<a for="reserved deferred-fetch quota">minimal quota</a> .
71417148

71427149
<li><p>If <var>containersWithReservedMinimalQuota</var>'s <a for=list>size</a> is less
71437150
than <a>max containers with minimal quota</a>, then set <var>container</var>'s
7144-
<a>reserved deferred-fetch quota</a> to <a for="reserved deferred-fetch quota">minimal</a>.
7151+
<a>reserved deferred-fetch quota</a> to <a for="reserved deferred-fetch quota">minimal quota</a>.
71457152
</ol>
71467153
</div>
71477154

0 commit comments

Comments
 (0)