Skip to content

Implement flex-wrap: balance and flex-line-count (CSS Flexbox Level 2) - #12

Open
nicoburns wants to merge 3 commits into
mainfrom
devin/1786712136-flex-wrap-balance
Open

Implement flex-wrap: balance and flex-line-count (CSS Flexbox Level 2)#12
nicoburns wants to merge 3 commits into
mainfrom
devin/1786712136-flex-wrap-balance

Conversation

@nicoburns

@nicoburns nicoburns commented Aug 14, 2026

Copy link
Copy Markdown
Member

Summary

Implements CSS Flexbox Level 2 flex-wrap: balance and the flex-line-count longhand, Servo-only and gated behind a new layout.flexbox.balance pref (default false; always off for Gecko).

flex-wrap switches from a generated keyword enum to a custom bitflags type (matching the approach in DioxusLabs/firefox#1), used as both specified and computed value, parsing the Level 2 grammar nowrap | [ wrap | wrap-reverse ] || balance via the derived bitflags parser:

#[css(bitflags(
    single = "nowrap",
    mixed = "wrap,wrap-reverse,balance",
    validate_mixed = "Self::validate_and_simplify"
))]
#[repr(C)]
pub struct FlexWrap(u8);
bitflags! {
    impl FlexWrap: u8 {
        const NOWRAP = 0;
        const WRAP = 1 << 0;
        const WRAP_REVERSE = 1 << 1;
        const BALANCE = 1 << 2;
    }
}

validate_and_simplify rejects wrap wrap-reverse, rejects balance unless static_prefs::pref!("layout.flexbox.balance") is true (the pref lookup is servo-cfg'd, so it always fails on Gecko), and simplifies wrap balancebalance (canonical serialization: balance, wrap-reverse balance). nowrap balance is rejected by the bitflags grammar (nowrap is single).

Gecko's manual flex_wrap glue in gecko.mako.rs is removed; in the Firefox tree StyleFlexWrap becomes a cbindgen-exported type sharing this representation (see DioxusLabs/firefox#1).

flex-line-count is a new Servo-only longhand (positive <integer>, initial 1), servo_pref = "layout.flexbox.balance", not generated for Gecko.

Verified with cargo build --features servo and cargo check (no features), both clean.

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/b7bd5b365d054b87a6053872323832b2
Requested by: @nicoburns

…el 2

Adds the full Level 2 flex-wrap grammar (nowrap | [ wrap | wrap-reverse ] || balance)
with Balance and WrapReverseBalance computed values, and a new flex-line-count
longhand (positive integer, initial 1). Both are Servo-only, gated behind the
new layout.flexbox.balance pref, and disabled for Gecko.
@staging-devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant