Skip to content

Lightpanda: the headless browser designed for AI and automation

css: trim stylesheet cap comments

Adrià Arrufat834b58b2ae48
diff --git a/src/browser/Frame.zig b/src/browser/Frame.zig
index 4477c18e9..47a64bbdc 100644
--- a/src/browser/Frame.zig
+++ b/src/browser/Frame.zig
@@ -2554,11 +2554,8 @@ pub fn queueHashChange(self: *Frame, old_url: []const u8, new_url: []const u8) !
});
}
-// Hard cap on a single external stylesheet body. CSS rule storage is per-
-// arena so a hostile sheet could otherwise inflate page memory. Real sites
-// ship aggregated sheets above 2 MiB (caltrain.com's Drupal theme is
-// 2.35 MB, with Bootstrap's `.dropdown-menu { display: none }` inside), and a
-// dropped sheet leaves hidden menus and tab panels in innerText.
+// CSS rule storage is per-arena, so a hostile sheet could otherwise inflate
+// page memory. Chrome has no cap, and aggregated theme sheets exceed 2 MiB.
pub const MAX_STYLESHEET_BYTES: usize = 4 * 1024 * 1024;
// Synchronously fetch and parse an external `<link rel=stylesheet>`.
diff --git a/src/testing.zig b/src/testing.zig
index f1b651c56..6554b9933 100644
--- a/src/testing.zig
+++ b/src/testing.zig
@@ -1163,8 +1163,7 @@ fn testHTTPHandler(req: *std.http.Server.Request) !void {
}
if (std.mem.eql(u8, path, "/styles/large.css")) {
- // 2.5 MiB, past the old 2 MiB cap, with the rule under test last so
- // the whole body has to be parsed for it to apply.
+ // Over 2 MiB, with the rule under test last.
const chunk = ".pad { color: #abcdef; } "; // 25 bytes
const tail = ".large-hide { display: none; }";
const repeats = 5 * 1024 * 1024 / 2 / chunk.len;