Implement legacy -webkit-line-clamp (without ellipsis) - #756
Open
nicoburns wants to merge 1 commit into
Open
Conversation
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the legacy
-webkit-line-clamprecipe (display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: N) in Blitz. Ellipsis rendering is intentionally out of scope — content is clamped cleanly at the Nth line boundary (equivalent tomax-lines: N; block-ellipsis: none).Depends on DioxusLabs/stylo#13, which enables
-webkit-line-clamp,-moz-box-orient/-webkit-box-orient,display: -webkit-box/-webkit-inline-box, and Stylo'sadjust_for_webkit_line_clampstyle adjustment for Servo builds.Cargo.tomlpins the stylo crates to that fork commit viagit/rev; this should move back to a crates.io version once released.How it works
Stylo's style adjuster (matching Blink) detects the full legacy recipe at computed-value time and adjusts
displaytoflow-root(orinline-blockfor-webkit-inline-box), leavingoriginal_displayas the-webkit-boxvalue. So no-webkit-boxflex layout is needed — the element lays out as a normal block, and Blitz only adds the N-line height clamp inlayout/inline.rs:Lines past the Nth don't contribute to content height; with
overflow: hiddenthey're clipped, withoverflow: visiblethey still paint (matching Blink's legacy quirk). The gating onoriginal_displaymakes-webkit-line-clampa no-op on elements that aren't legacy webkit boxes (per WPTwebkit-line-clamp-001/002).table.rs/traversal.rsgainDisplayInside::WebkitBoxmatch arms (treated as flow) since the enum variant now exists in Servo builds — this covers the unadjusted case where-webkit-box-orientisn't vertical.Verification
cargo fmt/clippy --workspace/check --workspace/test --workspacepass.examples/assets/line_clamp.htmlrendered viacargo run --example screenshot: clamp-2 +overflow: hiddenshows exactly 2 lines; clamp-3 +overflow: visiblehas 3-line height with later lines painting past the background (Blink quirk).css/css-overflow/line-clamp: 35 passing (up from 31 on main), includingwebkit-line-clamp-001through004,015,023,029,033,034,038,039. Remaining failures are references containing an ellipsis (out of scope), script-driven tests, or line counting in block descendants (not part of this scope).Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/4a6c323b22734b559aa869fdf89fb375
Requested by: @nicoburns
WPT results
4 newly passing, 5 newly failing (net -1).
Full diff (9 changed tests)
Generated by the WPT workflow.