Skip to content

Commit 6be68fd

Browse files
committed
parley: Apply clipping to text input rendering
We lay out text for text inputs with text_overflow == Clip, so we should also render it like that. Fixes #10055
1 parent 6e08b62 commit 6be68fd

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

internal/core/textlayout/sharedparley.rs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,20 +1587,34 @@ pub fn draw_text_input(
15871587
.fill_rectange_with_color(selection_rect, text_input.selection_background_color());
15881588
});
15891589

1590-
layout.draw(
1591-
item_renderer,
1592-
platform_fill_brush,
1593-
None,
1594-
&mut |item_renderer, font, font_size, brush, y_offset, glyphs_it| {
1595-
item_renderer.draw_glyph_run(font, font_size, brush, y_offset, glyphs_it);
1596-
},
1590+
item_renderer.save_state();
1591+
1592+
let render = item_renderer.combine_clip(
1593+
LogicalRect::new(LogicalPoint::default(), size),
1594+
LogicalBorderRadius::zero(),
1595+
LogicalLength::zero(),
15971596
);
15981597

1599-
if let Some(cursor_pos) = visual_representation.cursor_position {
1600-
let cursor_rect = layout
1601-
.cursor_rect_for_byte_offset(cursor_pos, text_input.text_cursor_width() * scale_factor);
1602-
item_renderer.fill_rectange_with_color(cursor_rect, visual_representation.cursor_color);
1598+
if render {
1599+
layout.draw(
1600+
item_renderer,
1601+
platform_fill_brush,
1602+
None,
1603+
&mut |item_renderer, font, font_size, brush, y_offset, glyphs_it| {
1604+
item_renderer.draw_glyph_run(font, font_size, brush, y_offset, glyphs_it);
1605+
},
1606+
);
1607+
1608+
if let Some(cursor_pos) = visual_representation.cursor_position {
1609+
let cursor_rect = layout.cursor_rect_for_byte_offset(
1610+
cursor_pos,
1611+
text_input.text_cursor_width() * scale_factor,
1612+
);
1613+
item_renderer.fill_rectange_with_color(cursor_rect, visual_representation.cursor_color);
1614+
}
16031615
}
1616+
1617+
item_renderer.restore_state();
16041618
}
16051619

16061620
pub fn text_size(

0 commit comments

Comments
 (0)