Bug 73967

Summary: Copy/paste of the same content produces elements with verbose style
Product: WebKit Reporter: Enrica Casucci <enrica>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: enrica, max.hong.shen, rniwa, sullivan
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on: 81737    
Bug Blocks:    

Enrica Casucci
Reported 2011-12-06 17:26:56 PST
Repro steps: 1. Go to http://www-archive.mozilla.org/editor/midasdemo/ 2. Switch to the View HTML Source view 3. Enter the following markup: <b><i style="border: solid red">hello</i></b> 4. Switch to the non HTML source view 5. Select All, then Copy and Paste 6. Switch back to the HTML source view Expected: The markup is the same. Actual: The markup is: <b><i style="border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: red; border-right-color: red; border-bottom-color: red; border-left-color: red; border-width: initial; ">hello</i></b> The border attribute is exploded in all possible border related attributes. This seems to happen only for inline elements.
Attachments
Enrica Casucci
Comment 1 2011-12-06 17:30:35 PST
I'll track down where the regression occurred.
Enrica Casucci
Comment 2 2011-12-07 10:34:54 PST
I don't think this is regression. When generating markup for block style properties we use the verbose form. This doesn't happen when we create a new paragraph and we replicate the style. I belive this is a problem limited to the markup generation code used to great fragments.
Ryosuke Niwa
Comment 3 2011-12-07 11:00:09 PST
(In reply to comment #2) > I don't think this is regression. When generating markup for block style properties we use the verbose form. > This doesn't happen when we create a new paragraph and we replicate the style. I belive this is a problem limited to the markup generation code used to great fragments. Ah, good to know that I didn't cause yet-another regression :) We should fix this though. Annie was looking into improving cssText at some point but don't think she's working on it anymore. She might still be able to give us some insights.
Yi Shen
Comment 4 2012-03-19 13:15:19 PDT
The issue is caused by the inconsistent contents of the inlineStyle and attributes in Element. After step 4, an element got created with the inlineStyle like "border-top-style: solid; border-right-style: solid;blabla ...", and the attributes which is "border: solid red". In step 5, the copy operation generated a markup string by using the element's inlineStyle, however, the style information in attributes got lost. So, after the paste, the new element's inlineStyle and attributes became the same one --- ""border-top-style: solid; border-right-style: solid;blabla ..."" If the test is valid, should we detect the inconsistence and use attributes instead to generate the markup string for copy operation? Any ideas, guys? (In reply to comment #0) > Repro steps: > > 1. Go to http://www-archive.mozilla.org/editor/midasdemo/ > 2. Switch to the View HTML Source view > 3. Enter the following markup: <b><i style="border: solid red">hello</i></b> > 4. Switch to the non HTML source view > 5. Select All, then Copy and Paste > 6. Switch back to the HTML source view > > Expected: > The markup is the same. > > Actual: > The markup is: <b><i style="border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: red; border-right-color: red; border-bottom-color: red; border-left-color: red; border-width: initial; ">hello</i></b> > > The border attribute is exploded in all possible border related attributes. > This seems to happen only for inline elements.
Yi Shen
Comment 5 2012-03-27 11:07:06 PDT
After the code change for bug 81737, the new markup (generated as a result of copy operation) is using shorthand notations as desired, but it raises a new issue for the test of this bug. The new markup string now becomes "border: initial solid red", which seems to be an invalid declaration, because the "initial" keyword is combined with other component values in same declaration, and the webkit wouldn't draw the border for the pasted element. I can file a new bug for it and provide a patch.
Ryosuke Niwa
Comment 6 2012-03-27 11:43:58 PDT
(In reply to comment #5) > After the code change for bug 81737, the new markup (generated as a result of copy operation) is using shorthand notations as desired, but it raises a new issue for the test of this bug. The new markup string now becomes "border: initial solid red", which seems to be an invalid declaration, because the "initial" keyword is combined with other component values in same declaration, and the webkit wouldn't draw the border for the pasted element. I can file a new bug for it and provide a patch. Yeah, we need to fix that bug.
Ryosuke Niwa
Comment 7 2012-03-29 17:29:58 PDT
ToT WebKit generates <b><i style="border: solid red; ">hello</i></b>. I call it good enough since this markup is almost identical to the original markup. Please file new bugs if you find other cases where we still generate needlessly verbose markup.
Note You need to log in before you can comment on or make changes to this bug.