LibWeb: Apply ::first-letter pseudo-element styles#8885
Open
tcl3 wants to merge 5 commits intoLadybirdBrowser:masterfrom
Open
LibWeb: Apply ::first-letter pseudo-element styles#8885tcl3 wants to merge 5 commits intoLadybirdBrowser:masterfrom
::first-letter pseudo-element styles#8885tcl3 wants to merge 5 commits intoLadybirdBrowser:masterfrom
Conversation
bf89115 to
bf28e74
Compare
Add an `AttachToDOMNode` parameter to the Layout::Node constructor that controls whether the newly-constructed node calls `set_layout_node()` on its backing DOM node.
We now apply first letter styles by splitting text with a first-letter style applied into 2 `TextSliceNode` objects. The `DOM::Text` layout node always points at the non first-letter slice and the first-letter slice is reachable via `TextSliceNode::first_letter_slice()`. First letter splitting works by `TreeBuilder` walking a block container's inline descendants to find the first typographic letter unit per the pattern given in css-pseudo level 4, which is then wrapped in an anonymous inline box styled with the `::first-letter` computed properties. Consumers that map between DOM offsets and layout geometry are updated to visit all slices of a `DOM::Text` through `TextOffsetMapping`.
bf28e74 to
139fa52
Compare
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.
We now apply first letter styles by splitting text with a first-letter style applied into 2
TextSliceNodeobjects. TheDOM::Textlayout node always points at the non first-letter slice and the first-letter slice is reachable viaTextSliceNode::first_letter_slice().First letter splitting works by
TreeBuilderwalking a block container's inline descendants to find the first typographic letter unit per the pattern given in css-pseudo level 4, which is then wrapped in an anonymous inline box styled with the::first-lettercomputed properties.Consumers that map between DOM offsets and layout geometry are updated to visit all slices of a
DOM::TextthroughTextOffsetMapping.With this change we pass 359 of the
first-letter-punctuation-*WPT tests because we are following thecss-pseudo-4spec, which has stricter rules for trailing punctuation.