Skip to content

Avoid origin assumptions in box model API. - #1813

Merged
xStrom merged 1 commit into
linebender:mainfrom
xStrom:box-sanity
May 29, 2026
Merged

xStrom merged 1 commit into
linebender:mainfrom
xStrom:box-sanity

Conversation

@xStrom

@xStrom xStrom commented May 26, 2026

Copy link
Copy Markdown
Member

The layout accessor methods content_box_size, border_box_size, and paint_box_size are encouraging direct usage without considering the origin of these boxes, which leads to subtle bugs.

This PR removes those context methods, plus WidgetState::border_box_size.

The size can still be accessed through e.g. border_box().size(), while making correct usage in general more likely. For example border_box().contains(pos) instead of border_box_size().to_rect().contains(pos), or border_box().center() instead of border_box_size() / 2..

A few widgets got updated with the more robust approach of using e.g. .center(), but generally e.g. content_box_size() just got replaced with content_box().size(). Thus, this PR is focused on changing the API in a way that is more conducive to correct use, but analyzing and fixing all existing widget code is out of scope for this PR.

This PR also adds a few more box model tests, to make sure that these APIs actually work as advertised.

@xStrom xStrom added masonry Issues relating to the Masonry widget layer needs review Needs review before proceeding. labels May 26, 2026

@PoignardAzur PoignardAzur left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@xStrom xStrom removed the needs review Needs review before proceeding. label May 29, 2026
@xStrom
xStrom added this pull request to the merge queue May 29, 2026
Merged via the queue into linebender:main with commit a956bf2 May 29, 2026
17 checks passed
@xStrom
xStrom deleted the box-sanity branch May 29, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

masonry Issues relating to the Masonry widget layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants