Repository navigation
Fix: measure inline boxes inside inline roots and send SoftWrap property (#175) - #177
Merged
Merged
Conversation
…rty (#175) When an inline-outside element like a button is placed directly in a block container, blitz-dom wraps it in an AnonymousBlock marked as an inline root. Previously, MeasuredTree routed inline roots with inline boxes to Route::Blitz, which bypassed MeasuredTree and prevented the button's text from being measured by the renderer measurer. Furthermore, paint/bridge omitted PropertyKind::SoftWrap for unconstrained text runs, causing compose-rust to default softWrap to true and soft-wrap Korean syllables when font metrics slightly exceeded Parley's advance. This pre-measures inline boxes in MeasuredTree so that descendant text runs participate in the layout measurer, and ensures PropertyKind::SoftWrap is explicitly set on Text plan nodes. Not compiled.
…-line runs (FR-34)
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.
Closes #175
Root Cause
<button style="display: inline-flex">) is a direct child of a block container,blitz-domwraps inline-outside children in anAnonymousBlockmarkedIS_INLINE_ROOT.MeasuredTree::route,prepare_inlinesees that inline boxes exist (!layout.inline_boxes().is_empty()) and returnsNone, directing the node toRoute::Blitz.Route::Blitzdelegated to<BaseDocument as LayoutPartialTree>::compute_child_layout, which usesBaseDocument's internal layout to recursively size inline boxes, bypassingMeasuredTree. BecauseMeasuredTreewas never visited for the button or its text,self.textscontained no measured text entry for the button's label.paint/build.rs), the missing text fell back toself.parley_runs(). Parley measured the Hangul characters with its font metrics.paint/bridge.rs,PropertyKind::SoftWrapwas not sent for unconstrained text runs. Incompose-rust(TextResolution.kt),softWrapdefaulted totrue. When Compose renderedBasicTextconstrained byModifier.width(run.rect.width), its Skia font metrics slightly exceeded Parley's advance width. BecausesoftWrapwastrue, Compose soft-wrapped the Korean syllable to line 2 (Korean allows breaks between syllables under normal word breaking). BecausemaxLines = 1, line 2 was clipped, but the advance width was reserved, leaving다 연.<div style="display: flex">placed the button as a flex item instead of inside an anonymous block, routing it throughRoute::Flexand measuring its text run directly with the renderer measurer.Fix
pre_measure_inline_boxestoMeasuredTreeso that inline boxes inside inline roots are laid out byMeasuredTreebefore blitz-dom lays out the line, ensuring descendant text runs are measured byRendererMeasurerand recorded inself.texts.paint/bridge.rs, explicitly sendPropertyKind::SoftWrapastext.soft_wrapfor text runs.tests/fr34_html_text.rsandtests/fr34_html_bridge.rs.Not compiled.