LibWeb: Support loading alternative style sheets

Alternative style sheets are now fetched and are applied to the
document if they are explicitly enabled by removing the disabled
attribute.
This commit is contained in:
Tim Ledbetter
2024-04-16 21:02:50 +01:00
committed by Andreas Kling
parent 25f8c26624
commit 4a3497e9cd
Notes: sideshowbarker 2024-07-17 03:03:15 +09:00
7 changed files with 52 additions and 8 deletions

View File

@@ -0,0 +1,21 @@
<!DOCTYPE html>
<script src="include.js"></script>
<link title="preferred" disabled rel="stylesheet" href="data:text/css,html { background: rgb(255, 0, 0) }">
<link title="alternative" disabled rel="alternate stylesheet" href="data:text/css,html { background: rgb(0, 128, 0) !important }">
<script>
asyncTest(done => {
const documentStyle = getComputedStyle(document.documentElement);
println(`background color initial value: ${documentStyle.backgroundColor}`);
const primaryLink = document.querySelector("link[title=preferred]");
const alternativeLink = document.querySelector("link[title=alternative]");
primaryLink.onload = () => {
println(`background color after preferred style sheet enabled: ${documentStyle.backgroundColor}`);
alternativeLink.disabled = false;
};
alternativeLink.onload = () => {
println(`background color after alternate style sheet enabled: ${documentStyle.backgroundColor}`);
done();
};
primaryLink.disabled = false;
});
</script>