-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
ComputedNode box model helper functions
#21903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… to `ComputedNode`.
| out | ||
| } | ||
|
|
||
| /// Returns the node's padding-box in object-centered physical coordinates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
padding-box -> content-box
| let mut out = self.border_box(); | ||
| out.min.x += self.border.left; | ||
| out.max.x -= self.border.right; | ||
| out.min.y += self.border.top; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a stupid comment because I am new, but is this supposed to be out.min.y += self.border.bottom (and the next line should be out.max.y -= self.border.top)? Same comment about this belongs in content_box too
From reading Rect, I had the impression visually that Rect.min is the lower left point defined as (min.x, min.y) and Rect.max is the upper right point e.g (max.x, max.y), and that the BorderRect left/right/top/bottom values are units “towards its center.” If that’s the case, should min.y should be affected by border.bottom instead?
Objective
Add helper functions to
ComputedNodethat return the bounds of the node's border, padding, and content areas.Solution
Add helper functions
border_box,padding_box, andcontent_boxtoComputedNode.Included a release note. These changes are very trivial and don't really need one, but I've got quite a few more less trivial changes to
ComputedNodethat I want to add later.Testing
This PR also includes a couple of trivial tests.