Commit 1eaecaa
committed
LibWeb: Insert newlines between block-level elements when copying text
The visible_text_in_range() helper used for clipboard serialisation only
iterated over Text nodes, ignoring the block-level element boundaries
between them. Selecting text that spans multiple <div> (or other block)
elements would therefore produce a result with all the text concatenated
without any separating newlines.
Fix by also processing Element nodes while iterating the range: if an
element's layout node is a block container or a line-break node (<br>),
and the output buffer already contains some text, append a newline
before continuing. This matches the plain-text serialisation behaviour
of other browsers for the common case.
Fixes #7315.1 parent de10db6 commit 1eaecaa
File tree
1 file changed
+15
-1
lines changed- Libraries/LibWeb/HTML
1 file changed
+15
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
2977 | 2978 | | |
2978 | 2979 | | |
2979 | 2980 | | |
2980 | | - | |
| 2981 | + | |
2981 | 2982 | | |
| 2983 | + | |
| 2984 | + | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
2982 | 2996 | | |
2983 | 2997 | | |
2984 | 2998 | | |
| |||
0 commit comments