Bug 112329

Summary: REGRESSION: WebKit doesn't preserve style when copying text from another element
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: HTML EditingAssignee: Pravin D <pravind>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: ahmad.saleem792, arpitabahuguna, buildbot, dglazkov, donggwan.kim, dw.im, enrica, k.wolanski, mifenton, pravind, rniwa, s.choi, vanivhegde, webkit-bug-importer, webkit.review.bot
Priority: P2 Keywords: InRadar, Regression
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
URL: http://jsfiddle.net/fns4w/6/
Attachments:
Description Flags
Approach 1
none
Archive of layout-test-results from gce-cr-linux-08 for chromium-linux-x86_64
none
Reduction
none
Work in progress changes
none
Patch
none
Archive of layout-test-results from webkit-ews-08 for mac-mountainlion
none
Archive of layout-test-results from APPLE-EWS-2 for win-future
none
Archive of layout-test-results from APPLE-EWS-5 for win-future
none
Archive of layout-test-results from webkit-ews-09 for mac-mountainlion-wk2
none
Patch
beidson: review-, buildbot: commit-queue-
Archive of layout-test-results from APPLE-EWS-4 for win-future none

Description Ryosuke Niwa 2013-03-14 01:41:07 PDT
Reproduction steps:
1. Go to http://jsfiddle.net/fns4w/
2. Copy "Copy this" at the bottom
3. Paste it after "todispaly"

Expected result:
The pasted text has the font size of 50px

Actual result:
The pasted text has the default font size
Comment 1 Radar WebKit Bug Importer 2013-03-15 18:53:04 PDT
<rdar://problem/13435950>
Comment 2 Pravin D 2013-03-25 02:08:28 PDT
Created attachment 194803 [details]
Approach 1
Comment 3 WebKit Review Bot 2013-03-25 10:24:37 PDT
Comment on attachment 194803 [details]
Approach 1

Attachment 194803 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://webkit-commit-queue.appspot.com/results/17308243

New failing tests:
editing/pasteboard/5761530-1.html
editing/pasteboard/paste-and-sanitize.html
editing/pasteboard/copy-null-characters.html
editing/pasteboard/paste-blockquote-2.html
editing/deleting/merge-paragraph-from-h6-with-style.html
editing/deleting/merge-paragraph-into-pre.html
editing/deleting/merge-paragraph-from-address.html
editing/pasteboard/paste-blockquote-3.html
editing/deleting/merge-paragraph-into-h1.html
editing/pasteboard/paste-text-with-style-4.html
editing/deleting/merge-paragraph-from-listing.html
editing/deleting/merge-paragraph-from-p-with-style-2.html
editing/deleting/merge-paragraph-into-h1-with-dir-2.html
editing/deleting/merge-paragraph-into-h1-with-dir.html
editing/deleting/merge-paragraph-with-style-from-rule.html
editing/deleting/merge-paragraph-from-h6.html
editing/deleting/merge-paragraph-into-h1-with-style.html
editing/deleting/merge-paragraph-from-p-with-style.html
editing/deleting/delete-to-end-of-paragraph.html
editing/deleting/merge-paragraph-from-p-with-style-3.html
editing/deleting/merge-paragraph-from-h6-with-style-2.html
editing/deleting/merge-whitespace-pre.html
editing/deleting/deleting-line-break-preserves-underline-color.html
Comment 4 WebKit Review Bot 2013-03-25 10:24:41 PDT
Created attachment 194881 [details]
Archive of layout-test-results from gce-cr-linux-08 for chromium-linux-x86_64

The attached test failures were seen while running run-webkit-tests on the chromium-ews.
Bot: gce-cr-linux-08  Port: chromium-linux-x86_64  Platform: Linux-3.3.8-gcg-201212281604-x86_64-with-GCEL-10.04-gcel_10.04
Comment 5 Ryosuke Niwa 2013-04-02 01:14:10 PDT
Created attachment 196093 [details]
Reduction

The problem is in ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline. We’re removing font-size & color
via removeStyleFromRulesAndContext since they’re duplicated in the style rules.

Since the inline style is now empty, we end up erronrously removing span and those rules stops applying to the text.
Comment 6 Ryosuke Niwa 2013-04-02 01:44:23 PDT
This is a regression from Safari 6.0.2.
Comment 7 Ryosuke Niwa 2013-04-02 02:54:29 PDT
This is probably a regression from http://trac.webkit.org/changeset/96870.
Comment 8 Ryosuke Niwa 2013-04-13 01:01:37 PDT
Created attachment 197924 [details]
Work in progress changes

Some work in progress changes for the record. This approach is wrong.
Comment 9 Ryosuke Niwa 2013-04-13 01:03:26 PDT
For the future myself, to fix this bug, I need to distinguish cases where users are deleting paragraphs and we’re merging paragraphs as a part of other operations. In the latter case, we need to preserve all styles including that of style rules for blocks.
Comment 10 Grzegorz Czajkowski 2013-04-25 02:44:03 PDT
*** Bug 115027 has been marked as a duplicate of this bug. ***
Comment 11 Pravin D 2013-06-19 03:57:11 PDT
Created attachment 204984 [details]
Patch
Comment 12 Build Bot 2013-06-19 08:18:07 PDT
Comment on attachment 204984 [details]
Patch

Attachment 204984 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/945237

New failing tests:
editing/deleting/deleting-line-break-preserves-underline-color.html
Comment 13 Build Bot 2013-06-19 08:18:09 PDT
Created attachment 205008 [details]
Archive of layout-test-results from webkit-ews-08 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-08  Port: mac-mountainlion  Platform: Mac OS X 10.8.3
Comment 14 Build Bot 2013-06-19 09:38:00 PDT
Comment on attachment 204984 [details]
Patch

Attachment 204984 [details] did not pass win-ews (win):
Output: http://webkit-queues.appspot.com/results/926251

New failing tests:
editing/deleting/deleting-line-break-preserves-underline-color.html
Comment 15 Build Bot 2013-06-19 09:38:03 PDT
Created attachment 205011 [details]
Archive of layout-test-results from APPLE-EWS-2 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: APPLE-EWS-2  Port: win-future  Platform: CYGWIN_NT-6.1-WOW64-1.7.20-0.266-5-3-i686-32bit
Comment 16 Build Bot 2013-06-19 11:22:56 PDT
Comment on attachment 204984 [details]
Patch

Attachment 204984 [details] did not pass win-ews (win):
Output: http://webkit-queues.appspot.com/results/926269

New failing tests:
editing/deleting/deleting-line-break-preserves-underline-color.html
Comment 17 Build Bot 2013-06-19 11:22:59 PDT
Created attachment 205021 [details]
Archive of layout-test-results from APPLE-EWS-5 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: APPLE-EWS-5  Port: win-future  Platform: CYGWIN_NT-6.1-WOW64-1.7.20-0.266-5-3-i686-32bit
Comment 18 Build Bot 2013-06-20 04:06:29 PDT
Comment on attachment 204984 [details]
Patch

Attachment 204984 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/880486

New failing tests:
editing/deleting/deleting-line-break-preserves-underline-color.html
http/tests/security/cross-origin-plugin-private-browsing-toggled.html
Comment 19 Build Bot 2013-06-20 04:06:33 PDT
Created attachment 205069 [details]
Archive of layout-test-results from webkit-ews-09 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-09  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.3
Comment 20 Pravin D 2013-06-27 04:39:05 PDT
Created attachment 205586 [details]
Patch
Comment 21 Build Bot 2013-06-27 13:32:22 PDT
Comment on attachment 205586 [details]
Patch

Attachment 205586 [details] did not pass win-ews (win):
Output: http://webkit-queues.appspot.com/results/999024

New failing tests:
fast/js/global-constructors-attributes-shared-worker.html
fast/js/global-constructors-attributes-dedicated-worker.html
Comment 22 Build Bot 2013-06-27 13:32:25 PDT
Created attachment 205628 [details]
Archive of layout-test-results from APPLE-EWS-4 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: APPLE-EWS-4  Port: win-future  Platform: CYGWIN_NT-6.1-WOW64-1.7.20-0.266-5-3-i686-32bit
Comment 23 Brady Eidson 2016-05-24 22:01:28 PDT
Comment on attachment 205586 [details]
Patch

Assuming that patches for review since 2013 are stale, r-
Comment 24 Ahmad Saleem 2022-11-30 17:19:57 PST
Using link from URL field, I am not able to reproduce this bug in Safari Technology Preview 159 and it is matching with Chrome Canary 110, where the copy result in 50px text in green color while in case of Firefox Nightly 109, I am getting weird "New Line" in between copied text and contenteditable text.

Just wanted to share updated results. Thanks!
Comment 25 Ryosuke Niwa 2022-12-01 13:58:44 PST
Yeah, this is working now.