Repository navigation
fix(android,core): preserve inline-flex child layout inside block parents - #248
Open
herefishyfish wants to merge 2 commits into
Open
herefishyfish wants to merge 2 commits into
herefishyfish wants to merge 2 commits into
Conversation
This branch has not been deployed
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.
Why
An element with
display: inline-flex(orinline-grid) inside a block parent loses child centering and horizontal padding, leaving children pinned at(0, 0).Two separate bugs cause this. On Android,
DivextendsScroll->TwoDScrollView->FrameLayout. WhenTextView.placeInlineBoxcallsbox.layout(...)during inline-run draw,Scroll.onLayoutcalledsuper.onLayout, which ranFrameLayout.onLayoutand reset Mason-positioned children back to(0, 0). Inmason-core,DisplayMode::Boxcontainers markedis_text_container(such as<button>) bypassed flexbox and grid layout intree.rsandtree_inline.rs.What changed
TwoDScrollView.kt/Scroll.ktaddprotected open val layoutChildrenInSuper(trueonTwoDScrollView,falseonScroll) soScroll.onLayoutkeeps scroll-offset bookkeeping while skippingFrameLayout.onLayout.crates/mason-core/src/tree.rsandcrates/mason-core/src/tree_inline.rsallowDisplayMode::Boxnodes withDisplay::FlexorDisplay::Gridand non-empty children to run flexbox/grid layout even whenis_text_containeris set.inline_flex_text_container_centers_child_and_applies_padding_in_blockincrates/mason-core/tests/flex_inline_mix.rsand Android instrumented testinlineFlexDivInBlockKeepsPaddingAndCenteringAfterDrawinInlineRunsInstrumentedTest.kt.Blast Radius
Skipping
FrameLayout.onLayoutonScrollalso avoids a redundant child layout pass on every AndroidScroll/Divlayout. PlainTwoDScrollViewsubclasses outsideScrollkeeplayoutChildrenInSuper = true. LeafTextContainernodes without children keep their existing measure path.Verification
cargo test -p mason-core --test flex_inline_mixfailed before the fix ([block] expected 72x36 inline-flex box, got 92x36) and passed after.cargo test -p mason-core -p mason-c --all-targetspassed (0 failed)../gradlew :masonkit:connectedDebugAndroidTest '-Pandroid.testInstrumentationRunnerArguments.class=org.nativescript.mason.masonkit.InlineRunsInstrumentedTest'onemulator-5554(API 33) failed before the fix (got left=0) and passed after (8/8tests passed).Before / After