refactor(engine): move row slot-width resolution into RowSlots#356
Merged
Conversation
compileHorizontalRow chose its slot widths inline through a three-way flex / explicit-columns / weights branch, and the weight split lived in a private LayoutCompiler.distributeRowSlotWidths. Both belong with the other row slot-width primitives. Move distributeRowSlotWidths onto RowSlots (whose Javadoc already pointed at it) and add RowSlots.resolveLayout, returning the slot widths plus the flex leading / extra-gap in a small SlotLayout record. compileHorizontalRow now calls resolveLayout and reads the three values off the record — byte-identical placement, and LayoutCompiler drops ~64 lines and two now-unused imports. RowSlotsTest gains direct coverage for the weight distribution.
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
LayoutCompileris the engine's largest class. ItscompileHorizontalRowpicked theper-child slot widths inline through a three-way flex / explicit-columns / weights
branch, and the weight split lived in a private
LayoutCompiler.distributeRowSlotWidths.Both are pure row slot-width computation that belongs with the other primitives in
RowSlots(rowAvailableWidth,distributeFlex,distributeColumns,intrinsicColumnWidths) — whose Javadoc already pointed atdistributeRowSlotWidths.What
distributeRowSlotWidthsfromLayoutCompilerintoRowSlotsand repointed its{@link}.RowSlots.resolveLayout(...), which returns the slot widths plus the flex leadingoffset and extra inter-child gap in a small package-private
SlotLayoutrecord — thesame flex / columns / weights dispatch, lifted verbatim.
compileHorizontalRownow callsresolveLayoutand reads the three values off therecord; dropped two now-unused imports.
LayoutCompilerloses ~64 lines.RowSlotsTestgains four pure tests fordistributeRowSlotWidths(even split, weightedsplit, inter-child gap subtraction, zero-total fallback).
Tests
./mvnw -f aggregator/pom.xml verify -pl :graph-compose-qa -am— full compile + javadocgate + the qa visual/parity byte-identity suite (643): green. The row placement is
byte-identical;
resolveLayoutreads no compiler state.RowSlotsTest: 8 tests, 0 failures.Byte-identical lift — the row slot-width dispatch is unchanged. Its branch selection is
exercised by the qa row corpus (as the sibling
distributeFlex/distributeColumnsalready are); the pure weight split now has direct unit coverage.