mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 15:43:20 +00:00
LibWeb: Resolve relative lengths in @font-face using correct viewport
As with everywhere else we should be using the document rather than the window's viewports. Fixes #6467
This commit is contained in:
parent
29fb63c928
commit
3708fc6aa7
Notes:
github-actions[bot]
2025-10-16 09:28:48 +00:00
Author: https://github.com/Calme1709
Commit: 3708fc6aa7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6482
Reviewed-by: https://github.com/tcl3 ✅
6 changed files with 92 additions and 1 deletions
|
@ -77,7 +77,7 @@ ParsedFontFace ParsedFontFace::from_descriptors(CSSFontFaceDescriptors const& de
|
||||||
font_family = extract_font_name(*value);
|
font_family = extract_font_name(*value);
|
||||||
|
|
||||||
ComputationContext computation_context {
|
ComputationContext computation_context {
|
||||||
.length_resolution_context = Length::ResolutionContext::for_window(*descriptors.parent_rule()->parent_style_sheet()->owning_document()->window())
|
.length_resolution_context = Length::ResolutionContext::for_document(*descriptors.parent_rule()->parent_style_sheet()->owning_document())
|
||||||
};
|
};
|
||||||
|
|
||||||
Optional<int> weight;
|
Optional<int> weight;
|
||||||
|
|
6
Tests/LibWeb/Crash/CSS/font-face-dom-parser.html
Normal file
6
Tests/LibWeb/Crash/CSS/font-face-dom-parser.html
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<script>
|
||||||
|
new DOMParser().parseFromString(
|
||||||
|
`<style>@font-face { font-family: a; src: url(); }</style>`,
|
||||||
|
"text/html"
|
||||||
|
);
|
||||||
|
</script>
|
BIN
Tests/LibWeb/Ref/data/fail.woff
Normal file
BIN
Tests/LibWeb/Ref/data/fail.woff
Normal file
Binary file not shown.
BIN
Tests/LibWeb/Ref/data/pass.woff
Normal file
BIN
Tests/LibWeb/Ref/data/pass.woff
Normal file
Binary file not shown.
|
@ -0,0 +1,35 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html class="reftest-wait">
|
||||||
|
<body>
|
||||||
|
<iframe
|
||||||
|
id="iframe"
|
||||||
|
width="500"
|
||||||
|
srcdoc="
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<style>
|
||||||
|
@font-face {
|
||||||
|
font-family: test;
|
||||||
|
src: url(../data/pass.woff) format(woff);
|
||||||
|
}
|
||||||
|
|
||||||
|
#foo {
|
||||||
|
font-family: test;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
<p>Test passes if the word PASS appears below.</p>
|
||||||
|
<p id='foo'>P</p>
|
||||||
|
</body>
|
||||||
|
</html>"
|
||||||
|
onload="waitForFonts()"
|
||||||
|
></iframe>
|
||||||
|
<script>
|
||||||
|
function waitForFonts() {
|
||||||
|
iframe.contentDocument.fonts.ready.then(() => {
|
||||||
|
document.documentElement.classList = "";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,50 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html class="reftest-wait">
|
||||||
|
<head>
|
||||||
|
<link
|
||||||
|
rel="match"
|
||||||
|
href="../../expected/font-face-descriptor-relative-length-iframe-ref.html"
|
||||||
|
/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<iframe
|
||||||
|
id="iframe"
|
||||||
|
width="500"
|
||||||
|
srcdoc="
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<style>
|
||||||
|
@font-face {
|
||||||
|
font-family: test;
|
||||||
|
src: url(../../data/fail.woff) format(woff);
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: test;
|
||||||
|
src: url(../../data/pass.woff) format(woff);
|
||||||
|
/* Should compute to '100' because 100vw = 500px */
|
||||||
|
font-weight: calc(100 + (sign(100vw - 500px) * 1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
#foo {
|
||||||
|
font-family: test;
|
||||||
|
font-weight: 100;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
<p>Test passes if the word PASS appears below.</p>
|
||||||
|
<p id='foo'>P</p>
|
||||||
|
</body>
|
||||||
|
</html>"
|
||||||
|
onload="waitForFonts()"
|
||||||
|
></iframe>
|
||||||
|
<script>
|
||||||
|
function waitForFonts() {
|
||||||
|
iframe.contentDocument.fonts.ready.then(() => {
|
||||||
|
document.documentElement.classList = "";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue