Skip to content

Truly independent web browser

LibWeb: Do not round the overflow clip of single-line text fields

Andreas Kling6e659c16a502
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/node_values.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/node_values.rs
index de51c1da43e..73158c54ad3 100644
--- a/Libraries/LibWeb/Rust/src/painting/visual_context/node_values.rs
+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/node_values.rs
@@ -962,7 +962,10 @@ pub(crate) fn compute_clip_data(layout_arena: &impl PaintRead, slot: NodeSlotId,
// clipping region is not rounded.
// FIXME: Adjust the border radii for the overflow-clip-margin case.
// (see https://drafts.csswg.org/css-overflow-4/#valdef-overflow-clip-margin-length-0 )
- let radii = if overflow_x != overflow::VISIBLE && overflow_y != overflow::VISIBLE {
+ // INTEROP: A single-line text field clips its contents to its padding box without rounding the corners, so that
+ // text selected at the edge of a short field with rounded corners keeps its square highlight.
+ let is_text_input = layout_arena.node_kind_if_live(slot) == Some(crate::layout::node_data::NodeKind::TextInputBox);
+ let radii = if overflow_x != overflow::VISIBLE && overflow_y != overflow::VISIBLE && !is_text_input {
padding_edge_border_radii(style, layout_arena, slot)
} else {
BorderRadii::default()
diff --git a/Tests/LibWeb/Text/expected/display_list/form-control-native-appearance-corners.txt b/Tests/LibWeb/Text/expected/display_list/form-control-native-appearance-corners.txt
index 4a2e0df180b..2cffbc4a079 100644
--- a/Tests/LibWeb/Text/expected/display_list/form-control-native-appearance-corners.txt
+++ b/Tests/LibWeb/Text/expected/display_list/form-control-native-appearance-corners.txt
@@ -3,7 +3,7 @@ AccumulatedVisualContext Tree:
[s0] transform=[1,0,0,1,0,0] origin=(0,0) (Viewport<#document>)
[s1] scroll (Viewport<#document>)
clips:
- [c0 in s1] clip=[1,181 168x18] radii=(3,3,3,3) (TextInputBox<INPUT>)
+ [c0 in s1] clip=[1,181 168x18] (TextInputBox<INPUT>)
[c1 in s1] clip=[5,183 160x14] (BlockContainer<DIV>)
[c2 in s1] clip=[3,213 168x18] (TextInputBox<INPUT>)
[c3 in s1] clip=[7,215 160x14] (BlockContainer<DIV>)
diff --git a/Tests/LibWeb/Text/expected/display_list/input-caret.txt b/Tests/LibWeb/Text/expected/display_list/input-caret.txt
index 8878d846a13..a08218b5cd9 100644
--- a/Tests/LibWeb/Text/expected/display_list/input-caret.txt
+++ b/Tests/LibWeb/Text/expected/display_list/input-caret.txt
@@ -3,7 +3,7 @@ AccumulatedVisualContext Tree:
[s0] transform=[1,0,0,1,0,0] origin=(0,0) (Viewport<#document>)
[s1] scroll (Viewport<#document>)
clips:
- [c0 in s1] clip=[9,9 108x18] radii=(3,3,3,3) (TextInputBox<INPUT>)
+ [c0 in s1] clip=[9,9 108x18] (TextInputBox<INPUT>)
[c1 in s1] clip=[13,11 100x14] (BlockContainer<DIV>)
effects:
[e0 in s0] effects=[]
diff --git a/Tests/LibWeb/Text/expected/display_list/input-focus-switch-selection-and-caret.txt b/Tests/LibWeb/Text/expected/display_list/input-focus-switch-selection-and-caret.txt
index 41440ea4aee..304433f57ee 100644
--- a/Tests/LibWeb/Text/expected/display_list/input-focus-switch-selection-and-caret.txt
+++ b/Tests/LibWeb/Text/expected/display_list/input-focus-switch-selection-and-caret.txt
@@ -3,9 +3,9 @@ AccumulatedVisualContext Tree:
[s0] transform=[1,0,0,1,0,0] origin=(0,0) (Viewport<#document>)
[s1] scroll (Viewport<#document>)
clips:
- [c0 in s1] clip=[9,9 168x18] radii=(3,3,3,3) (TextInputBox<INPUT>#foo)
+ [c0 in s1] clip=[9,9 168x18] (TextInputBox<INPUT>#foo)
[c1 in s1] clip=[13,11 160x14] (BlockContainer<DIV>)
- [c2 in s1] clip=[187,9 167x18] radii=(3,3,3,3) (TextInputBox<INPUT>#bar)
+ [c2 in s1] clip=[187,9 167x18] (TextInputBox<INPUT>#bar)
[c3 in s1] clip=[191,11 159x14] (BlockContainer<DIV>)
effects:
[e0 in s0] effects=[]
diff --git a/Tests/LibWeb/Text/expected/display_list/text-input-clip-is-not-rounded.txt b/Tests/LibWeb/Text/expected/display_list/text-input-clip-is-not-rounded.txt
new file mode 100644
index 00000000000..94999a6d791
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/display_list/text-input-clip-is-not-rounded.txt
@@ -0,0 +1,15 @@
+AccumulatedVisualContext Tree:
+ spatial:
+ [s0] transform=[1,0,0,1,0,0] origin=(0,0) (Viewport<#document>)
+ [s1] scroll (Viewport<#document>)
+ clips:
+ [c0 in s1] clip=[8,10 156x13] (TextInputBox<INPUT>#input)
+ [c1 in s1] clip=[8,10 156x13] (BlockContainer<DIV>)
+ effects:
+ [e0 in s0] effects=[]
+
+DisplayList:
+FillRect@s1/c1/e0 rect=[8,10 23x13] color=rgba(101, 2, 0, 0.8)
+DrawGlyphRun@s1/c1/e0 rect=[8,10 23x13] translation=[8,20.390625] color=rgb(0, 0, 0)
+FillRoundedRectRing@s1/e0 rect=[6,8 160x17] corner_radii=[8x8,8x8,8x8,8x8] widths=[2,2,2,2] color=rgb(61, 174, 233)
+
diff --git a/Tests/LibWeb/Text/input/display_list/text-input-clip-is-not-rounded.html b/Tests/LibWeb/Text/input/display_list/text-input-clip-is-not-rounded.html
new file mode 100644
index 00000000000..6b1156b3e62
--- /dev/null
+++ b/Tests/LibWeb/Text/input/display_list/text-input-clip-is-not-rounded.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ input {
+ font-size: 13px;
+ padding: 0;
+ border: none;
+ border-radius: 7px;
+ background: transparent;
+ }
+</style>
+<input id="input" value="abc">
+<script>
+ test(() => {
+ input.focus();
+ input.select();
+ println(internals.dumpDisplayList());
+ });
+</script>