browser: skip print-only stylesheets when fetching linked CSS

A <link rel=stylesheet media="print"> must not apply on screen; fetching
and injecting it let print rules override the screen layout (e.g. the
Guardian's print sheet). Skip links whose media is print-only.
This commit is contained in:
SGavrl committed 2026-07-11 20:36:58 +00:00
1 parent e27a3bc5b0
commit 58dee6330e
1 file changed
+10
+10
View File
@@ -394,6 +394,16 @@ impl Page {
let mut links = Vec::new();
for lid in link_ids {
if let Some(node) = dom.get_node(lid) {
// Skip print-only stylesheets: a `<link media="print">`
// must not apply on screen. Some sites (e.g. the
// Guardian) ship a print sheet whose rules otherwise
// overrode the screen masthead/section styling.
if let Some(media) = node.get_attribute("media") {
let m = media.to_ascii_lowercase();
if m.contains("print") && !m.contains("screen") && !m.contains("all") {
continue;
}
}
if let Some(href) = node.get_attribute("href") {
links.push(href.to_string());
}