From 3d36cb25bfda0198ad93ecbe29829a1d4793a6be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Fri, 29 May 2026 13:07:50 -0400 Subject: [PATCH] fix(servo): enable CSS Grid so grid layouts stop collapsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `Preferences::default()` is Servo's conservative library default and ships `layout_grid_enabled: false`. `Servo::new` forwards prefs to Stylo (`prefs::set` -> `stylo_static_prefs::set_pref!("layout.grid.enabled")`), so with the gate off Stylo blockifies `display: grid`: every grid container collapses to `display: block` and grid-based page layouts stack into a single column — the "broken" rendering reported on modern sites. `ely_servo_preferences()` only flipped `dom_intersection_observer_enabled` and inherited the grid default, so ELY rendered grid pages collapsed while Servo's own servoshell (which enables the pref) renders them correctly. The layout path is implemented — servo-layout drives `DisplayInside::Grid` through Taffy — so enabling the pref is the real fix, not a workaround. Verified with a deterministic `display: grid; grid-template-columns: 1fr 1fr 1fr` page: 9 stacked full-width bars before, a 3x3 grid after. Wikipedia/HN/GitHub/google.com re-checked unchanged; full workspace test suite green. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/ely_servo_host/src/runtime.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/ely_servo_host/src/runtime.rs b/crates/ely_servo_host/src/runtime.rs index 234ba31..0102d6f 100644 --- a/crates/ely_servo_host/src/runtime.rs +++ b/crates/ely_servo_host/src/runtime.rs @@ -241,7 +241,18 @@ fn install_rustls_provider() { } fn ely_servo_preferences() -> Preferences { - Preferences { dom_intersection_observer_enabled: true, ..Preferences::default() } + // `Preferences::default()` is Servo's conservative *library* default and ships + // CSS Grid off. `Servo::new` forwards prefs to Stylo via `prefs::set`, and with + // `layout.grid.enabled` off Stylo blockifies `display: grid`, collapsing every + // grid container to `display: block` — modern grid layouts stack into one column + // (the "broken" rendering on grid-based sites). The layout path is implemented + // (servo-layout drives `DisplayInside::Grid` through Taffy), so an embedder + // building a browser must enable it, exactly as Servo's own servoshell does. + Preferences { + dom_intersection_observer_enabled: true, + layout_grid_enabled: true, + ..Preferences::default() + } } impl ServoHost for SoftwareServoHost {