[Gmail] Style is merged when text is copied from one row to another
Categories
(Core :: DOM: Editor, defect, P3)
Tracking
()
People
(Reporter: gmoldovan, Assigned: masayuki)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
Found in
- Nightly 110.0a1
Affected versions
- 110.0a1
- 109.0b8
- 108.0.1
Affected platforms
- Ubuntu 22
- Windows 10
- macOS 10.14
Steps to reproduce
- Go to https://mail.google.com and log in with a valid account.
- Click on "Compose" to open up a new e-mail window.
- Write 2-3 rows, each with a different style: Bold, Italic, Underline or Text color.
- Copy the last row (or only part of it) and paste it at the end of the other rows.
- Observe the style.
Expected result
The copied text is correctly pasted at the end of each row and it's style it's preserved.
Actual result
The copied text is pasted at the end of the rows but it's style is merged with the style of the rows it was pasted on.
Regression range
- Will look for one asap, if there is one.
Notes
- This behavior can also be observed when using Cut-Paste operation.
- Dragging & Dropping works as expected, the initial style of the row is preserved.
- Does not reproduce in Chrome.
| Assignee | ||
Comment 1•3 years ago
|
||
It seems that Blink inserts pasted content into the nearest block element directly.
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/replace_selection_command.cc;l=1280;drc=41482404045cb6689ea898d109dbdcfe3365a529
| Assignee | ||
Comment 3•3 years ago
|
||
Gmail cancels paste event, and do document.execCommand("insertHTML", false "...") for inserting the pasted content with perhaps sanitizing. At this time, we preserve the existing style at the insertion point.
| Assignee | ||
Comment 4•3 years ago
•
|
||
Hmm, changing it to Clear causes only one "UNEXPECTED-PASS" in editing/run. This is too few. This means that there are no enough tests. I need to write some tests and confirm Chrome's behavior.
| Assignee | ||
Comment 5•3 years ago
|
||
The inconsistent behavior was intentionally implemented in bug 587461 about 10 years ago. At that moment, Opera (Presto) behaved same as current Gecko. However, now, Gecko is the only browser engine of this behavior. Additionally, the behavior is inconsistent from the case of pasting content. This inconsistency causes that web apps cannot implement sanitizing pasting handler with canceling paste event and inserting safe content with execCommand("insertHTML"). Therefore, I believe that changing our behavior again must make sense.
| Assignee | ||
Comment 6•3 years ago
•
|
||
FYI for Thunderbird folks: I'll change insertHTML command handler to make it work same as paste handler. If it's not suitable for Thunderbird users, let me know. I'll make it switchable with a new pref later.
| Assignee | ||
Comment 7•3 years ago
|
||
Currently, Gecko inserts content at insertion point as-is. However, Chrome
insert new content with splitting inline parents. Simply, this incompatibility
potentially causes different behavior from the other browsers. Additionally,
this behavior is different from the our paste handler itself. Therefore, web
apps cannot use execCommand("insertHTML") for inserting pasted content after
sanitizing its content and preventing the paste handler (this is what we see in
Gmail). Therefore, we should align the behavior to Chrome and use same
arguments as the our paste handler.
If Thunderbird users do not want this change, we need to make the behavior
switchable with a new pref later.
Depends on D168183
Comment 8•3 years ago
|
||
Should this block bug 1341152?
Comment 10•3 years ago
|
||
Comment 12•3 years ago
|
||
| bugherder | ||
Updated•3 years ago
|
Comment 14•3 years ago
|
||
Reproduced the issue with Firefox 110.0a1 (2023-01-06) using the steps from the description on MacOS 12.
The issue is verified fixed with Firefox 112.0a1 (20230226214053) and Firefox 111.0b6 (20230226190100) on Windows 10, macOS 12 and Ubuntu 22.
Description
•