Fix forced breaks in flex rows#2743
Open
moreaki wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a narrow forced-break path for row flex containers. When a row flex item requests a forced page break before or after another item, the flex line is split at that item boundary and the remaining items resume on the next page.
Part of #2400.
Root Cause
Flex layout already delegates final child layout to the normal block layout machinery, but it did not inspect break opportunities between flex items. As a result,
break-before: pageandbreak-after: pageon row flex items were ignored, even though block and table layout already honor the same break values between sibling boxes.Changes
block_level_page_breakandforce_page_breakto detect forced page breaks between row flex items.break-before: page,break-after: page, and a wrapped-row boundary.Known Remaining Scope
This intentionally handles a small, reviewable slice of flex breaks. Remaining work includes:
break-beforeon the first flex item, which needs parent/container-level coordination to avoid pointless blank pages.left/right/recto/versobehavior and page-name selection tests.avoidvalues, which require finding earlier/later legal flex-line break opportunities.break-inside: avoidfor row flex items, especially when one item fragments and another should remain unbroken.Validation
venv/bin/python -m pytest tests/layout/test_flex.pyvenv/bin/python -m pytest tests/layoutvenv/bin/python -m ruff check weasyprint/layout/flex.py tests/layout/test_flex.py