Bug 91783

Summary: execCommand copies the backgroung-color of the enclosing element to the element being edited.
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, darin, enrica, mifenton, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Ryosuke Niwa 2012-07-19 14:18:43 PDT
What steps will reproduce the problem?
1. Open a blank/any page.
2. Open the developer tool console.
3. Execute the following JS from the console:

var body = document.getElementsByTagName('body')[0];
body.contentEditable = true;
body.style['cssText'] = 'background-color: white;';

4. Now type some text into the page. (e.g aaa)
5. select the text typed in 4.
6. from the js console:

document.execCommand('insertUnorderedList');


What is the expected result?

body.innerHTML should give
"<ul><li>aaa</li></ul>"

What happens instead?

body.innerHTML gives
"<ul><li><span style="background-color: white; ">aaa</span></li></ul>"

Please provide any additional information below. Attach a screenshot if
possible.

It can also be reproduced with other commands e.g insertOrderedList.
Comment 1 Ryosuke Niwa 2012-07-19 14:18:55 PDT
http://crbug.com/137466
Comment 2 Sukolsak Sakshuwong 2012-07-27 05:01:24 PDT
Created attachment 154908 [details]
Patch
Comment 3 Ryosuke Niwa 2012-07-27 11:15:37 PDT
Comment on attachment 154908 [details]
Patch

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

The code change looks right.

> LayoutTests/editing/style/redundant-background-color.html:6
> +<script src="../../resources/testharness.js"></script>
> +<script src="../../resources/testharnessreport.js"></script>

We don't normally use testharness.js for webkit regression tests. Use dump-as-markup.js in LayoutTests/resources/ instead.
Comment 4 Sukolsak Sakshuwong 2012-07-27 13:07:23 PDT
Created attachment 155033 [details]
Patch
Comment 5 WebKit Review Bot 2012-07-27 17:32:31 PDT
Comment on attachment 155033 [details]
Patch

Clearing flags on attachment: 155033

Committed r123940: <http://trac.webkit.org/changeset/123940>
Comment 6 WebKit Review Bot 2012-07-27 17:32:35 PDT
All reviewed patches have been landed.  Closing bug.