Repository navigation
Implement text-transform: capitalize; make uppercase/lowercase language-aware - #947
Merged
Merged
Conversation
Contributor
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
This was referenced Sep 26, 2026
staging-devin-ai-integration
Bot
force-pushed
the
devin/1790390713-text-transform-capitalize
branch
2 times, most recently
from
September 28, 2026 23:23
b308739 to
4359631
Compare
staging-devin-ai-integration
Bot
force-pushed
the
devin/1790390713-text-transform-capitalize
branch
from
October 7, 2026 18:00
4359631 to
2146684
Compare
text-transform: capitalize; use ICU4X case mapping for all case transformstext-transform: capitalize; make uppercase/lowercase language-aware
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
Adds
text-transform: capitalize.uppercaseandlowercaseare now language-aware: non-ASCII text (and Turkic-language text) is mapped with ICU4X instead ofstr::to_uppercase/to_lowercase, and ASCII text takes a byte-mapping fast path that gives the same output. The logic is in a newlayout/text_transform.rs, called frombuild_inline_layout_recursive.Uses linebender/parley#856 (
TreeBuilder::textandTreeBuilder::has_pending_whitespace).parleyis pinned to linebender main at62790943, the #856 merge. That rev changedRun::font()to return&FontData, soblitz-paint/src/text.rsis updated to match.hel<b>lo</b>→ "Hello", and ina<span capitalize>b</span>cthe "b" stays lowercase. A capitalize text node looks back at the last 32 bytes ofbuilder.text()(the white-space-processed text pushed so far), starting from the last forced word break. Ifbuilder.has_pending_whitespace(), the node starts a new word, so no context is used. Nothing is copied or tracked for text nodes that aren't capitalized.TextTransformerstorescontext_start, the builder text length at the last forced word break, plus reusable scratch/output buffers.word_break(builder)is called after a position-inside list marker, at in-flow inline boxes (replaced elements, inline-block, etc.) and at<br>. Out-of-flow and float boxes add no text and don't break words (p<span abs></span>ass→ "Pass").transformreturns&str. Unchanged text is returned borrowed, with no allocation or copy (OutputSinkonly starts writing to the reused buffer at the first difference). ASCII text takes a byte-mapping fast path foruppercase/lowercase, except for Turkic languages (ascii_fast_path_matches_icuchecks it against ICU4X).icu_segmenterword segmentation overcontext + text. In each word that starts inside the current node, the first typographic letter unit (general category Letter or Number) is titlecased withicu_casemap'sTitlecaseMapper(TrailingCase::Unchanged). This skips leading punctuation and leaves circled letters such as ⓐ alone.-x-lang(thelangattribute). This enables Dutchij→IJand Turkish/Azeri dotted and dotless i.casing_languagedrops the language when an explicit script subtag contradicts it (tr-Cyrl→ root casing), as css-text-3 § script tagging requires. ICU4X itself only looks at the language subtag.blitz-domfeatureicu-text-transform(on by default) gatesicu_casemapandwriteable. It's forwarded and on by default inblitz,dioxus-nativeanddioxus-native-dom, and enabled explicitly inapps/browserand the WPT runner. Without it,uppercase/lowercase/titlecase_segmentfall back to stdchar::to_uppercase/to_lowercase(final sigma viastr::to_lowercase). Word segmentation and the letter check are the same either way, but casing is language-insensitive and titlecase is approximated by uppercase (dž→DŽ, ß→SS). CI's Clippy job also lintsblitz-domwith the feature off.icu_casemap,icu_casemap_data,icu_locale_core,icu_propertiesandicu_segmenter, all at 2.3, pluswriteable0.6. Onlyicu_casemapandicu_casemap_dataare new to the tree. Releaseblitzbrowser binary (productionprofile): +71 KiB (+0.26%) with the feature on, about 42 KiB of case-mapping data and 27 KiB of code.WPT
css/css-text/text-transform: 57/113 → 92/113, no regressions. Remaining capitalize failures:capitalize-033: a pixel difference that still happens withtext-transformremoved and "Pass" typed literally. The likely cause is the inline box splitting the shaping run; not investigated further.capitalize-036: needsinnerText.Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/4641a2bf5eca4d4fb140d16886180423
Open in Devin Desktop: https://dioxus.staging.devinenterprise.com/desktop/session/4641a2bf5eca4d4fb140d16886180423?variant=devin-insiders
Requested by: @nicoburns
WPT results
Subtests: 53 newly passing, 0 newly failing (net +53).
Full diff (53 changed tests)
Generated by the WPT workflow.