forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
25f8c26
commit 4a3497e
Showing
7 changed files
with
52 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!DOCTYPE html> | ||
<link rel="match" href="reference/alternative-style-sheets-ref.html" /> | ||
<link title="preferred" rel="stylesheet" href="data:text/css,html { background: green }"> | ||
<!-- These alternative style sheets shouldn't be applied --> | ||
<link title="alternative" rel="alternate stylesheet" href="data:text/css,html { background: red !important }"> | ||
<link id="no-title" rel="alternate stylesheet" href="data:text/css,html { background: blue !important }"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!DOCTYPE html> | ||
<style> | ||
html { | ||
background-color: green; | ||
} | ||
</style> |
3 changes: 3 additions & 0 deletions
3
Tests/LibWeb/Text/expected/HTMLLinkElement-explicitly-enabled-alternative-stylesheets.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
background color initial value: rgba(0, 0, 0, 0) | ||
background color after preferred style sheet enabled: rgb(255, 0, 0) | ||
background color after alternate style sheet enabled: rgb(0, 128, 0) |
21 changes: 21 additions & 0 deletions
21
Tests/LibWeb/Text/input/HTMLLinkElement-explicitly-enabled-alternative-stylesheets.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters