Skip to content

Commit

Permalink
fonts: Store web fonts in the per-Layout FontContext
Browse files Browse the repository at this point in the history
This moves mangement of web fonts to the per-Layout `FontContext`,
preventing web fonts from being available in different Documents.

Fixes #12920.

Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
  • Loading branch information
2 people authored and servo-wpt-sync committed May 20, 2024
1 parent 76a4828 commit 13d894d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
17 changes: 17 additions & 0 deletions css/css-fonts/downloadable-font-scoped-to-document-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>

<html>
<head>
<title>CSS fonts: Web fonts loaded in a document are not available in other documents</title>
<link rel="author" title="Martin Robinson" href="mrobinson@igalia.com">
<link rel="author" title="Mukilan Thiyagarajan" href="mukilan@igalia.com">
</head>

<body>
<p>Test passes if Ahem is only used in the first iframe.</p>
<iframe src="support/iframe-using-ahem-as-web-font.html"></iframe>
<iframe src="support/iframe-without-web-font.html"></iframe>
</body>

</html>

28 changes: 28 additions & 0 deletions css/css-fonts/downloadable-font-scoped-to-document.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>

<html class="reftest-wait">
<head>
<title>CSS fonts: Web fonts loaded in a document are not available in other documents</title>
<link rel="author" title="Martin Robinson" href="mrobinson@igalia.com">
<link rel="author" title="Mukilan Thiyagarajan" href="mukilan@igalia.com">
<link rel="match" href="downloadable-font-scoped-to-document-ref.html">
<link rel="help" href="https://drafts.csswg.org/css-fonts/#font-face-rule">
</head>

<body>
<p>Test passes if Ahem is only used in the first iframe.</p>
<iframe id="iframe1" src="support/iframe-using-ahem-as-web-font.html"></iframe>
<iframe id="iframe2" src=""></iframe>

<script>
// Delay the loading of the second iframe to make it more likely that the font
// has loaded properly into the first iframe.
iframe1.onload = () => {
iframe2.src ="support/iframe-missing-font-face-rule.html";
document.documentElement.classList.remove('reftest-wait');
};
</script>
</body>

</html>

2 changes: 2 additions & 0 deletions css/css-fonts/support/iframe-missing-font-face-rule.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE html>
<div style="font-size: 30px; font-family: CustomFontFamily">Hello!</div>
8 changes: 8 additions & 0 deletions css/css-fonts/support/iframe-using-ahem-as-web-font.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<style>
@font-face {
font-family: CustomFontFamily;
src: url(/fonts/Ahem.ttf);
}
</style>
<div style="font-size: 30px; font-family: CustomFontFamily">Hello!</div>
2 changes: 2 additions & 0 deletions css/css-fonts/support/iframe-without-web-font.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE html>
<div style="font-size: 30px;">Hello!</div>

0 comments on commit 13d894d

Please sign in to comment.