Skip to content

Only include a container's own end padding in content_size for scroll containers - #1114

Merged
nicoburns merged 2 commits into
mainfrom
devin/1786922561-content-size-padding-scroll-containers-only
Aug 16, 2026
Merged

Only include a container's own end padding in content_size for scroll containers#1114
nicoburns merged 2 commits into
mainfrom
devin/1786922561-content-size-padding-scroll-containers-only

Conversation

@nicoburns

Copy link
Copy Markdown
Member

Objective

Fix ordinary (non-scroll-container) padded boxes propagating spuriously enlarged content sizes to ancestor scroll containers. In Blitz this manifested as a spurious ~34px horizontal scroll on https://csskit.rs at a 1200px viewport: the page's footer (a padded block whose child <p> has negative horizontal margins pulling it into the padding) reported content_size.width = 1234, which propagated up to the root and made the document horizontally scrollable.

Per CSS Overflow, a scroll container's own end-side padding is part of its scrollable overflow region, but a box that is not a scroll container does not extend its overflow region by its own padding. Browsers behave this way: content overflowing into (or past) a non-scroll-container's padding does not enlarge the scrollable overflow contributed to ancestors.

The block, flexbox and grid algorithms now only add the container's own end-side padding (right for LTR, left for RTL, plus bottom) to content_size when the container is a scroll container:

if is_scroll_container {
    content_size.width += if direction.is_rtl() { padding.left } else { padding.right };
    content_size.height += padding.bottom;
}

For flexbox this required threading an is_scroll_container flag through AlgoConstants (cfg-gated on content_size).

Context

  • The unconditional padding addition was introduced to match browser scrollWidth/scrollHeight semantics for scroll containers; this PR keeps that behaviour for scroll containers (the existing content_size_includes_the_containers_own_padding / scroll_height_accounts_for_the_containers_own_padding tests still pass) and only removes it for non-scroll-containers.
  • Added a content_size_excludes_the_own_padding_of_a_non_scroll_container test covering Block/Flex/Grid.
  • Full test suite passes (5829 tests), plus a CHANGELOG entry under Unreleased → Fixed.
  • Verified downstream in Blitz: with this fix the csskit.rs root goes from content_size=1234x3246, scroll_width=34 to content_size=1200x3246, scroll_width=0 (companion Blitz PR bumps the taffy rev).

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

… containers

A box that is not a scroll container does not extend its scrollable
overflow region by its own padding, so block, flexbox and grid layout
now only add the container's end-side padding to its content size when
the container is a scroll container. This matches browser behaviour and
prevents ordinary padded boxes from propagating spurious overflow to
ancestor scroll containers.
@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