layout: Add placeholders for text carets after finishing a line#44370
Conversation
|
🔨 Triggering try run (#24659858511) for Linux (WPT) |
|
Test results for linux-wpt from try job (#24659858511): Flaky unexpected result (24)
Stable unexpected results that are known to be intermittent (21)
Stable unexpected results (42)
|
|
|
fc7b48d to
2d89293
Compare
|
🔨 Triggering try run (#24664354334) for Linux (WPT) |
|
Test results for linux-wpt from try job (#24664354334): Flaky unexpected result (39)
Stable unexpected results that are known to be intermittent (17)
|
|
✨ Try run (#24664354334) succeeded. |
2d89293 to
d730cd9
Compare
SimonSapin
left a comment
There was a problem hiding this comment.
A few questions but looks good overall
| self.is_textual_or_password | ||
| .set(self.input_type().is_textual_or_password()); |
There was a problem hiding this comment.
This is in the attribute_mutated method of the VirtualMethods trait. Is that called when initially creating an element from HTML parsing?
There was a problem hiding this comment.
Yes, I believe it is called when the attribute is processed by the parser. There is one more case, which is when there is no type attribute specified at all. In that case this method will not be called.
| /// The primary font used for this container, if one exists. This is the font that is | ||
| /// used when not falling back. | ||
| default_font: Option<FontRef>, |
There was a problem hiding this comment.
What does “not falling back” mean here?
There was a problem hiding this comment.
That means using a fallback font. I write this comment to make this a bit clearer.
| let Some(offsets) = | ||
| self.ifc | ||
| .shared_selection | ||
| .clone() | ||
| .map(|shared_selection| TextRunOffsets { | ||
| shared_selection, | ||
| character_range: line_start_offset..line_start_offset + 1, | ||
| }) | ||
| else { | ||
| return; | ||
| }; |
There was a problem hiding this comment.
Small nit, feel free to ignore
Since we have let Some(…) = unwrapping the Option anyway, calling map is slightly more verbose than necessary:
| let Some(offsets) = | |
| self.ifc | |
| .shared_selection | |
| .clone() | |
| .map(|shared_selection| TextRunOffsets { | |
| shared_selection, | |
| character_range: line_start_offset..line_start_offset + 1, | |
| }) | |
| else { | |
| return; | |
| }; | |
| let Some(shared_selection) = self.ifc.shared_selection.clone() else { | |
| return; | |
| }; | |
| let offsets = TextRunOffsets { | |
| shared_selection, | |
| character_range: line_start_offset..line_start_offset + 1, | |
| }; |
There was a problem hiding this comment.
Oh, good point. I'll make this change.
Instead of readily adding a strut for text carets when processing a line break, wait until a line is finished. This allows placing a strut on the final line. In addition to fixing servo#41338 this will also make it possible to handle line breaks as a separate kind of text run item so that we can preserve shaping results between layouts. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
d730cd9 to
7cf5c2c
Compare
Instead of readily adding a strut for text carets when processing a line
break, wait until a line is finished. This allows placing a strut on the
final line. In addition to fixing #41338 this will also make it possible
to handle line breaks as a separate kind of text run item so that we can
preserve shaping results between layouts.
In addition, some changes are made in script to ensure that these placeholders
are never placed for non-textual input elements.
Testing: This change adds a Servo-specific WPT test. Caret rendering isn't specified.
Fixes: #41338