-
Notifications
You must be signed in to change notification settings - Fork 107
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
Accurate sizes: Add ancestor block context #1795
base: feature/1511-incorporate-layout-constraints-from-ancestors
Are you sure you want to change the base?
Accurate sizes: Add ancestor block context #1795
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/1511-incorporate-layout-constraints-from-ancestors #1795 +/- ##
=============================================================================================
Coverage ? 57.53%
=============================================================================================
Files ? 84
Lines ? 6544
Branches ? 0
=============================================================================================
Hits ? 3765
Misses ? 2779
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…ors' into add/ancestor-block-context
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.
Thanks for getting this going @mukeshpanchal27. I can see where you're going but think that this introduces competing approaches to solving the same problem.
In #1701 we introduced the concept of max_alignment
context, which is meant to be a way for ancestor blocks to share information about their alignment to inner blocks to use during rendering.
This approach is doing something similar by storing an array of the ancestor block hierarchy and their widths in a nested array that blocks can use during rendering.
Both have merits, but we should probably consolidate on one or the other approach and not both. In order to avoid passing a full array of block_width_data
values to blocks that have to be looped through, we probably need to update the logic in auto_sizes_filter_render_block_context()
that sets max_alignment
context so that the alignment of a nested container block doesn't increase the max_alignment
value.
For example, if you have a block structure like this:
group (align: 'default') > group (align: 'full') > image
The max_alignment
context value should be 'default' since both the second group block and the image block will both be constrained by the max width of the first group block. However, we didn't consider nested blocks in the original implementation, so currently the max_alignment
passed to the image will be 'full', resulting in an incorrect sizes
value.
By handling nested alignment values with by keeping the max_alignment
value updated we can avoid the need to pass the full array of nested block alignment values to the image block for it to loop through, like you're doing in #1818.
I do like the way you're calculating column widths by passing column_count
context, but am think we might want to keep that context and container alignment width separate. What do you think?
Summary
This PR add the ancestor block context for image and cover block that help to calculation of img
sizes
attributes.See #1511
The context for ancestor block after the PR.
Group > Image
Columns > Column > Image
Group > Columns > Column ( 50% ) > Image