Support basic display: contents#2746
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.
Fixes #2210.
Context
#2210 reports that tabbed content generated by Material for MkDocs / PyMdown Extensions is rendered in the wrong order when wrappers use
display: contentsinside a flex container. WeasyPrint currently rejectsdisplay: contentsduring CSS validation, so these wrappers generate real boxes instead of being flattened into their children.The issue thread also mentioned that the same order problem could be reproduced without
display: contentswhen inlinelabelelements are direct flex children. On currentmain, that direct-inline case is already handled correctly by the existing flex item/blockification work related to #1652. The remaining missing part is the actualdisplay: contentswrapper behavior.Changes
display: contentsas a validdisplayvalue.display: contentson the root element back to a normal block-flow root box, avoiding a missing root box.display: contentselements by returning their child boxes instead of a principal box.contentsbox type.Scope and limitations
This is intended as a first, narrow implementation of
display: contents. It fixes the concrete wrapper/flex case from #2210 and keeps the change small enough to review.It does not claim complete CSS Display conformance. In particular, this does not deeply address every possible interaction of
display: contentswith accessibility/tree semantics, unusual pseudo-element behavior, replaced elements, or every layout model. The goal is to provide a useful first fix and let maintainers decide whether this approach is acceptable as a base for broader support.Tests
venv/bin/python -m pytest tests/layout/test_flex.py tests/css/test_validation.pyvenv/bin/python -m pytest tests/layoutvenv/bin/python -m ruff check weasyprint/css/validation/properties.py weasyprint/css/computed_values.py weasyprint/formatting_structure/build.py tests/layout/test_flex.pygit diff --check