Steps to reproduce: 1. Go to your favorite contentEditable based rich text editor (like http://www.mozilla.org/editor/midasdemo/) 2. Type "Foo Bar" on the first line (without quotes). Press Enter. 3. Type "Baz" on the second line. (html is Foo <span class="Apple-style-span" style="text-decoration: underline;">Bar</span><div>Baz</div>) 4. Double-click on "Bar" to highlight it. 5. Press underline from the toolbar. 6. Go to the beginning of the second line. 7. Press Backspace. Result: Everything moved from the second line to the first is underlined (html is Foo <span class="Apple-style-span" style="text-decoration: underline;">BarBaz</span> Expected: Just "Bar" to be underlined. Notes: I've repro'ed on Chrome 1.0 Windows and a webkit nightly on Mac. This also repros if you use delete at the end of the first line, rather than backspace at the beginning of the second line.
*** Bug 23994 has been marked as a duplicate of this bug. ***
Minor thing: in step 3 you write that the "html is ..." but it isn't in that state until after step 5.
Also notice that pasting text that isn't underlined anywhere inside, just before or just after underlined content will incorrectly underline the pasted content. This is because the pasted content goes into an element with text-decoration: underline, and every descendant of such an element, no matter what, will be underlined. In the bold case, pasted content goes into a bold tag, but the pasted content is surrounded by a span with font-weight: normal, which negates the boldness. We need a function positionAvoidingTextDecoration or the like in ReplaceSelectionCommand to fix this.
Created attachment 32692 [details] demonstrates the bug: underline extends to the next line when adjoint lines are merged with deletion
I noticed that there is -webkit-text-decorations-in-effect property is added in the result. Does anyone know what this property is for? <span class="Apple-style-span" style="text-decoration: underline;">hello<span class="Apple-style-span" style="-webkit-text-decorations-in-effect: none; ">world</span></span>
This is another bug with ReplaceSelectionCommand as Justin suggested, we need to adjust where we insert the fragment.
Around the line 865, we have insertNodeAtAndUpdateNodesInserted(refNode, insertionPos); And refNode->showTreeForThis() results in: SPAN 0x1af7ee50 CLASS=Apple-style-span STYLE=border-collapse: separate; color: rgb(0, 0, 0); font-family: Times; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; #text 0x1af7f170 "world" Is it even correct to have "-webkit-text-decoration: none" here? If so, when are you taking care of it? handleStyleSpans?
Justin and I talked on IRC, and it's maybe sensible to delete all style-spans and reapply ApplyStyleCommand because we need to push down text decoration and other styles and apply them again.
I have a fix for this in bug 21840.
Fixed in r55762, which included a layout test for this case. *** This bug has been marked as a duplicate of bug 21840 ***