Repository navigation
Visualize: a page is laid out as a browser lays it out - #1201
Merged
Merged
Conversation
Every page the tool has drawn on this machine was drawn again beside Chrome, and what differed is fixed where GPUI can draw it. A line of text with boxes in it wraps word by word around them. A grid's auto track is as wide as its widest item, an item fills its area, and a table's column has the same room in every row; both widths are measured once for a theme. A flex item of text narrows to its row, and one that cannot wrap is not made narrower than what it holds. A width is the content box's. A transparent border keeps its room, a border of another colour is drawn, and a gradient is drawn stop by stop. An <svg> draws a <symbol> of another, takes the size and the paint the page's styles give it, and is painted in a colour CSS mixes; a sheet of symbols draws nothing. line-clamp, translate(), vertical-align, justify-items and table-layout are read. <ins> is inline, and <code> has no background of its own.
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
Every page
tcode_visualizehas drawn on the maintainer's machine (76 calls, 50 distinct pages that could still be read and compared) was drawn again by the renderer and by Chrome at the same width, side by side. What differed is fixed incrates/ui/src/html/where GPUI can draw it.What a page now gets that it did not:
<code>or a highlighted<ins>wraps around it; no line begins with what closes a phrase; a box on a line sits on the line's baseline.place-items/justify-itemsset an item across its column as well as down its row.width/heightsize the content box unlessbox-sizing: border-box; a transparent border keeps its room and is not drawn; a border of another colour than the box's is drawn;linear-gradientof more than two stops along an axis is drawn stop by stop;line-clamp,transform: translate(),vertical-align,table-layout: fixed.color-mix()/light-dark()as a paint (was black);<use>of a<symbol>in another<svg>; a zero-size sheet of symbols draws nothing (was an error box); an<svg>sized only by CSS is drawn to that size;<g fill>reaches its<text>; the theme's fonts as familiesusvgcan look up;fill/strokethe page's rules give the<svg>itself.<ins>and other phrasing tags are inline;<code>has no background of its own, as in a browser.measureis the one new mechanism: GPUI lays each row out by itself, so what the rows of a column share has to be known before they are built. It is bounded (MAX_MEASUREDcells, past which columns fall back to even shares), as are the word boxes of a line (MAX_WORDS).Lead::SpaceandTextSink::spacego: the white space between two boxes of a line is now a run of the page's text.Evidence
main, the six tests added here fail:an_auto_track_is_as_wide_as_what_it_holds,a_table_column_is_as_wide_in_every_row,a_width_is_the_content_box_unless_the_page_says,text_beside_a_box_wraps_in_its_line,an_svg_draws_a_symbol_of_another,an_svg_is_painted_in_a_colour_css_mixes(9 passed, 6 failed).After:
cargo nextest run -p tcode-ui --locked: 505 passed.cargo clippy -p tcode-ui --all-targets --locked -- -D warningsandcargo fmt --all --checkclean.After: all 50 are within 41 px of Chrome's height, 49 within 25 px; a second page-by-page comparison found no structural difference on most of them. The pages were also drawn at 360 px and one in the dark theme.
Each test states a contract a recorded page depends on and drives
HtmlViewin a window as the chat does; none existed for these, and each fails without the change.Not checked: the running app. The pages were drawn offscreen through
HtmlViewwith the macOS Metal renderer and the system text system, not looked at in a Tcode window. Windows and Linux were not drawn; the one platform branch (the half width CoreText leaves off a full-width mark at a word's end) iscfg!(target_vendor = "apple").Left as it is, with the cause:
transform: rotate(),radial-gradient,backdrop-filter, a border of another colour on a rounded box.·is drawn wide, a gap stands before(after a CJK character, emoji are drawn large.1frtrack is not widened by content that does not wrap, which a browser's automatic minimum does; one row of one page is still clipped.Merge Danger
Door: two-way
One commit in one module; reverting it restores the previous drawing. Nothing is stored and the wire is unchanged.
Blast Radius: visuals
Every stored
tcode_visualizepage is drawn differently on every client. A page that relied on the old behaviour (a padded box sized as border-box,<code>with a grey background) changes with it. Pages with grids ofautotracks or tables are laid out once more than before for each theme.