Repository navigation
Commit 988d755
[web_paragraph] Honor kTextHeightNone in TextStyle and ParagraphStyle (flutter#193733)
Part of flutter#193731. Split out of flutter#193403 (first of four independent PRs;
the others are flutter#193734 and flutter#193736, and flutter#193403 itself will be rebased
on top once these land).
### Problem
- `ChildStyleNode._height` converted `style.height ==
ui.kTextHeightNone` to `null` *before* falling back to `parent._height`,
so a child `TextStyle(height: ui.kTextHeightNone)` could never override
a non-null parent height (`ParagraphStyle(height: 3.0)` +
`pushStyle(TextStyle(height: kTextHeightNone))` still laid out the line
at 3x).
- `LineBlock` only checked `span.style.height == null`, so
`ParagraphStyle(height: ui.kTextHeightNone)` (`0.0`) multiplied the line
ascent/descent by `0.0` instead of disabling the height multiplier.
### Fix
- `ChildStyleNode._height` keeps `style.height` as-is: `style.height ??
parent._height`. `kTextHeightNone` now reaches `LineBlock`, which is the
one place that interprets it.
- `LineBlock`: `height == null || height == ui.kTextHeightNone` → raw
font ascent/descent, no scaling (same as the native path, where
`paragraph_builder.cc` sets `has_height_override = style.height !=
kTextHeightNone`).
- `LineBlock` uses `StyleManager.defaultFontSize` instead of a hardcoded
`14.0`.
- `WebStrutStyle` already normalizes `kTextHeightNone` to `null` in its
constructor, so struts need no change.
### Tests
- `paragraph_get_boxes_test.dart`: `layout with kTextHeightNone disables
parent height multiplier`, `layout with
ParagraphStyle(kTextHeightNone)`.
- **WebParagraph corpus (`preferWebParagraph` + `forceTestFonts` vs
`origin/master` `b7315d76579e`)**: 20,012 tests (18,765 executed, 1,247
skipped) — **503 -> 503 failures (0 fixed standalone, +2 new tests
passing, 0 regressions)**.
- *Note:* Existing corpus tests for `kTextHeightNone` also depend on
other issues (`test/ui/paragraph_builder_test.dart: kTextHeightNone
StrutStyle` is unlocked in flutter#193774 once `StrutStyle` is applied;
`test/painting/text_painter_test.dart: kTextHeightNone unsets the text
height multiplier` still fails due to Chromium's integer-rounded
`FlutterTest` font metrics at `10px` where `ascent + descent = 11 !=
10`).
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md1 parent 8ee3e3d commit 988d755
3 files changed
Lines changed: 52 additions & 5 deletions
File tree
- engine/src/flutter/lib/web_ui
- lib/src/engine/web_paragraph
- test/webparagraph
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
1193 | 1194 | | |
1194 | 1195 | | |
1195 | 1196 | | |
1196 | | - | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
1197 | 1200 | | |
1198 | 1201 | | |
1199 | 1202 | | |
1200 | 1203 | | |
1201 | | - | |
| 1204 | + | |
1202 | 1205 | | |
1203 | 1206 | | |
1204 | 1207 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1504 | 1504 | | |
1505 | 1505 | | |
1506 | 1506 | | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
1507 | 1510 | | |
1508 | | - | |
1509 | | - | |
1510 | | - | |
| 1511 | + | |
1511 | 1512 | | |
1512 | 1513 | | |
1513 | 1514 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
304 | 347 | | |
0 commit comments