Bug 61466

Summary: WebKit duplicates styles from css rules on copy and paste
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: HTML EditingAssignee: Ryosuke Niwa <rniwa>
Status: RESOLVED FIXED    
Severity: Enhancement CC: darin, dglazkov, enrica, eric, jparent, justin.garcia, leviw, ojan, sullivan, tony, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 12319, 34564    
Attachments:
Description Flags
fixes the bug
enrica: review+, webkit.review.bot: commit-queue-
Archive of layout-test-results from ec2-cr-linux-03 none

Description Ryosuke Niwa 2011-05-25 13:50:48 PDT
When an element has style applied by CSS rules, WebKit duplicates that style in inline style declaration when the element is copied and pasted in the same document.  We should remove inline styles that duplicates CSS rules on paste to reduce the markup size.
Comment 1 Ryosuke Niwa 2011-05-25 17:44:49 PDT
Created attachment 94890 [details]
fixes the bug
Comment 2 Ryosuke Niwa 2011-05-25 17:45:49 PDT
This is possibly the most exciting patch I'm submitting this month.
Comment 3 Levi Weintraub 2011-05-25 18:04:31 PDT
(In reply to comment #2)
> This is possibly the most exciting patch I'm submitting this month.

This really is exciting!
Comment 4 WebKit Review Bot 2011-05-26 01:33:21 PDT
Comment on attachment 94890 [details]
fixes the bug

Attachment 94890 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/8736190

New failing tests:
editing/pasteboard/5780697-2.html
Comment 5 WebKit Review Bot 2011-05-26 01:33:26 PDT
Created attachment 94940 [details]
Archive of layout-test-results from ec2-cr-linux-03

The attached test failures were seen while running run-webkit-tests on the chromium-ews.
Bot: ec2-cr-linux-03  Port: Chromium  Platform: Linux-2.6.35-28-virtual-x86_64-with-Ubuntu-10.10-maverick
Comment 6 Ryosuke Niwa 2011-05-26 07:54:42 PDT
It seems like editing/pasteboard/5780697-2.html has a Chromium-specific expected results.  Regardless, we just to rebaseline it.
Comment 7 Enrica Casucci 2011-05-26 10:11:08 PDT
Comment on attachment 94890 [details]
fixes the bug

View in context: https://bugs.webkit.org/attachment.cgi?id=94890&action=review

Looks good to me.

> Source/WebCore/editing/ReplaceSelectionCommand.cpp:479
> +void ReplaceSelectionCommand::negateStyleRulesThatAffectAppearanceAndRemoveRedundantInlineStyleDecl()

That is an insanely long method name! :-). I guess it is very descriptive.
Comment 8 Ryosuke Niwa 2011-05-26 10:28:18 PDT
Thanks for the review, Enrica!

Per IRC discussion I'll rename negateStyleRulesThatAffectAppearanceAndRemoveRedundantInlineStyleDecl to removeRedundantStylesAndKeepStyleSpanInline before landing it.

Also, I'll include the rebaseline for platform/chromium-win/editing/pasteboard/5780697-2-expected.txt.

I'll still have to rebaseline GTK & Qt as they also have separate expected results for 5780697-2.html
Comment 9 Ryosuke Niwa 2011-05-26 10:49:42 PDT
Committed r87400: <http://trac.webkit.org/changeset/87400>