Skip to content

Commit 938208d

Browse files
committed
[css-font-loading] Prevent a FontFaceSet from triggering load events every time there's any layout operation that might request fonts.
1 parent 23b0509 commit 938208d

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed

css-font-loading/Overview.bs

+16-12
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,13 @@ The <code>FontFaceSet</code> Interface</h2>
504504
Authors can use the events and methods defined here to allow greater control over actions
505505
that are dependent upon the availability of specific fonts.
506506

507-
There are <dfn>no pending font loads</dfn> for a given {{FontFaceSet}} whenever all of the following are true:
507+
There are <dfn>no pending font loads</dfn> for a given {{FontFaceSet}} whenever
508+
none of its contained {{FontFace}} objects have a {{FontFace/status}} of <code>"loading"</code>.
509+
510+
For {{FontFaceSet}}s that are <a>font sources</a>,
511+
in addition to the above constriant,
512+
the following must all be true
513+
for them to be considered as having <a>no pending font loads</a>:
508514

509515
<ul>
510516
<li>
@@ -513,20 +519,12 @@ The <code>FontFaceSet</code> Interface</h2>
513519
<li>
514520
There are no pending stylesheet requests.
515521

516-
<li>
517-
There are no <a>available font faces</a>
518-
with a {{FontFace/status}} of "loading".
519-
520522
<li>
521523
There are no pending layout operations which might cause the user agent to request a font.
522524
</ul>
523525

524-
If any of the above conditions are false,
525-
there are <dfn>possibly pending font loads</dfn>.
526-
527-
Issue: The above is wrong; it assumes that you're only asking about the <a>font source</a>.
528-
The {{FontFaceSet/status}} promise needs to pay attention to what {{FontFaceSet}} it's attached to.
529-
I guess only the <a>font source's</a> {{FontFaceSet/status}} promise should care about pending layout operations.
526+
If a {{FontFaceSet}} can't be considered to have <a>no pending font loads</a>,
527+
it instead has <dfn>possibly pending font loads</dfn>.
530528

531529
<!--
532530
████████ ██ ██ ████████ ██ ██ ████████ ██████
@@ -584,7 +582,7 @@ Events</h3>
584582
The {{FontFaceSetLoadEvent/fontfaces}} attribute is initialized to the given list of {{FontFace}} objects.
585583
</ol>
586584

587-
Whenever one or more <a>available font faces</a> for a given {{FontFaceSet}}
585+
Whenever one or more {{FontFace}} objects within a given {{FontFaceSet}}
588586
change their {{FontFace/status}} attribute to "loading",
589587
the user agent must run the following steps:
590588

@@ -634,6 +632,12 @@ Events</h3>
634632
user agents must run these steps:
635633

636634
<ol>
635+
<li>
636+
If this is not the first time the {{FontFaceSet}} has had <a>no pending font loads</a>,
637+
and none of its contained {{FontFace}} objects began loading
638+
since the last time it had <a>no pending font loads</a>,
639+
abort this algorithm.
640+
637641
<li>
638642
Set <var>font face set's</var> {{FontFaceSet/status}} attribute to "loaded".
639643

css-font-loading/Overview.html

+17-15
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,13 @@ <h2 class="heading settled" data-level=3 id=FontFaceSet-interface><span class=se
573573
Authors can use the events and methods defined here to allow greater control over actions
574574
that are dependent upon the availability of specific fonts.</p>
575575

576-
<p>There are <dfn data-dfn-type=dfn data-noexport="" id=no-pending-font-loads>no pending font loads<a class=self-link href=#no-pending-font-loads></a></dfn> for a given <code class=idl><a data-link-type=idl href=#dom-fontfaceset title=FontFaceSet>FontFaceSet</a></code> whenever all of the following are true:</p>
576+
<p>There are <dfn data-dfn-type=dfn data-noexport="" id=no-pending-font-loads>no pending font loads<a class=self-link href=#no-pending-font-loads></a></dfn> for a given <code class=idl><a data-link-type=idl href=#dom-fontfaceset title=FontFaceSet>FontFaceSet</a></code> whenever
577+
none of its contained <code class=idl><a data-link-type=idl href=#dom-fontface title=FontFace>FontFace</a></code> objects have a <code class=idl><a data-link-for=FontFace data-link-type=idl href=#dom-fontface-status title=status>status</a></code> of <code>"loading"</code>.</p>
578+
579+
<p>For <code class=idl><a data-link-type=idl href=#dom-fontfaceset title=FontFaceSet>FontFaceSet</a></code>s that are <a data-link-type=dfn href=#font-source title="font sources">font sources</a>,
580+
in addition to the above constriant,
581+
the following must all be true
582+
for them to be considered as having <a data-link-type=dfn href=#no-pending-font-loads title="no pending font loads">no pending font loads</a>:</p>
577583

578584
<ul>
579585
<li>
@@ -582,20 +588,12 @@ <h2 class="heading settled" data-level=3 id=FontFaceSet-interface><span class=se
582588
<li>
583589
There are no pending stylesheet requests.
584590

585-
<li>
586-
There are no <a data-link-type=dfn href=#available-font-faces title="available font faces">available font faces</a>
587-
with a <code class=idl><a data-link-for=FontFace data-link-type=idl href=#dom-fontface-status title=status>status</a></code> of "loading".
588-
589591
<li>
590592
There are no pending layout operations which might cause the user agent to request a font.
591593
</ul>
592594

593-
<p>If any of the above conditions are false,
594-
there are <dfn data-dfn-type=dfn data-noexport="" id=possibly-pending-font-loads>possibly pending font loads<a class=self-link href=#possibly-pending-font-loads></a></dfn>.</p>
595-
596-
<p class=issue id=issue-8f48960a><a class=self-link href=#issue-8f48960a></a>The above is wrong; it assumes that you’re only asking about the <a data-link-type=dfn href=#font-source title="font source">font source</a>.
597-
The <code class=idl><a data-link-for=FontFaceSet data-link-type=idl href=#dom-fontfaceset-status title=status>status</a></code> promise needs to pay attention to what <code class=idl><a data-link-type=idl href=#dom-fontfaceset title=FontFaceSet>FontFaceSet</a></code> it’s attached to.
598-
I guess only the <a data-link-type=dfn href=#font-source title="font source’s">font source’s</a> <code class=idl><a data-link-for=FontFaceSet data-link-type=idl href=#dom-fontfaceset-status title=status>status</a></code> promise should care about pending layout operations.</p>
595+
<p>If a <code class=idl><a data-link-type=idl href=#dom-fontfaceset title=FontFaceSet>FontFaceSet</a></code> can’t be considered to have <a data-link-type=dfn href=#no-pending-font-loads title="no pending font loads">no pending font loads</a>,
596+
it instead has <dfn data-dfn-type=dfn data-noexport="" id=possibly-pending-font-loads>possibly pending font loads<a class=self-link href=#possibly-pending-font-loads></a></dfn>.</p>
599597

600598

601599

@@ -645,7 +643,7 @@ <h3 class="heading settled" data-level=3.1 id=FontFaceSet-events><span class=sec
645643
The <code class=idl><a data-link-for=FontFaceSetLoadEvent data-link-type=idl href=#dom-fontfacesetloadevent-fontfaces title=fontfaces>fontfaces</a></code> attribute is initialized to the given list of <code class=idl><a data-link-type=idl href=#dom-fontface title=FontFace>FontFace</a></code> objects.
646644
</ol>
647645

648-
<p>Whenever one or more <a data-link-type=dfn href=#available-font-faces title="available font faces">available font faces</a> for a given <code class=idl><a data-link-type=idl href=#dom-fontfaceset title=FontFaceSet>FontFaceSet</a></code>
646+
<p>Whenever one or more <code class=idl><a data-link-type=idl href=#dom-fontface title=FontFace>FontFace</a></code> objects within a given <code class=idl><a data-link-type=idl href=#dom-fontfaceset title=FontFaceSet>FontFaceSet</a></code>
649647
change their <code class=idl><a data-link-for=FontFace data-link-type=idl href=#dom-fontface-status title=status>status</a></code> attribute to "loading",
650648
the user agent must run the following steps:</p>
651649

@@ -695,6 +693,12 @@ <h3 class="heading settled" data-level=3.1 id=FontFaceSet-events><span class=sec
695693
user agents must run these steps:</p>
696694

697695
<ol>
696+
<li>
697+
If this is not the first time the <code class=idl><a data-link-type=idl href=#dom-fontfaceset title=FontFaceSet>FontFaceSet</a></code> has had <a data-link-type=dfn href=#no-pending-font-loads title="no pending font loads">no pending font loads</a>,
698+
and none of its contained <code class=idl><a data-link-type=idl href=#dom-fontface title=FontFace>FontFace</a></code> objects began loading
699+
since the last time it had <a data-link-type=dfn href=#no-pending-font-loads title="no pending font loads">no pending font loads</a>,
700+
abort this algorithm.
701+
698702
<li>
699703
Set <var>font face set’s</var> <code class=idl><a data-link-for=FontFaceSet data-link-type=idl href=#dom-fontfaceset-status title=status>status</a></code> attribute to "loaded".
700704

@@ -1232,6 +1236,4 @@ <h2 class="no-num heading settled" id=references><span class=content>References<
12321236
Should it be the url of the document?
12331237
Is that correct for workers too,
12341238
or should they use their worker url?
1235-
Is that always defined?<a href=#issue-0c9d1948></a></div><div class=issue>The above is wrong; it assumes that you’re only asking about the <a data-link-type=dfn href=#font-source title="font source">font source</a>.
1236-
The <code class=idl><a data-link-for=FontFaceSet data-link-type=idl href=#dom-fontfaceset-status title=status>status</a></code> promise needs to pay attention to what <code class=idl><a data-link-type=idl href=#dom-fontfaceset title=FontFaceSet>FontFaceSet</a></code> it’s attached to.
1237-
I guess only the <a data-link-type=dfn href=#font-source title="font source’s">font source’s</a> <code class=idl><a data-link-for=FontFaceSet data-link-type=idl href=#dom-fontfaceset-status title=status>status</a></code> promise should care about pending layout operations.<a href=#issue-8f48960a></a></div></div>
1239+
Is that always defined?<a href=#issue-0c9d1948></a></div></div>

0 commit comments

Comments
 (0)