mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-26 12:17:52 +00:00
LibWeb: Make text cursor same height as text
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Previously we would paint the cursor the entire height of the text fragment - this didn't look great with large line-heights. Now we only paint it the height of the actual text, with the top of the cursor aligning with the font "ascent" and the bottom the "descent".
This commit is contained in:
parent
71b039a721
commit
ba62679a7a
Notes:
github-actions[bot]
2025-08-16 13:48:38 +00:00
Author: https://github.com/Calme1709
Commit: ba62679a7a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5874
1 changed files with 6 additions and 2 deletions
|
@ -723,11 +723,15 @@ void paint_cursor_if_needed(DisplayListRecordingContext& context, TextPaintable
|
|||
auto const& font = fragment.glyph_run() ? fragment.glyph_run()->font() : fragment.layout_node().first_available_font();
|
||||
auto cursor_offset = font.width(text.substring_view(0, cursor_position->offset() - fragment.start_offset()));
|
||||
|
||||
auto font_metrics = font.pixel_metrics();
|
||||
|
||||
auto cursor_height = font_metrics.ascent + font_metrics.descent;
|
||||
|
||||
CSSPixelRect cursor_rect {
|
||||
fragment_rect.x() + CSSPixels::nearest_value_for(cursor_offset),
|
||||
fragment_rect.top(),
|
||||
fragment_rect.top() + fragment.baseline() - CSSPixels::nearest_value_for(font_metrics.ascent),
|
||||
1,
|
||||
fragment_rect.height()
|
||||
CSSPixels::nearest_value_for(cursor_height)
|
||||
};
|
||||
auto cursor_device_rect = context.rounded_device_rect(cursor_rect).to_type<int>();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue