Bug 23993

Summary: Underline formatting bleeds into other formatting during delete/backspace
Product: WebKit Reporter: Julie Parent <jparent>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: eric, justin.garcia, rniwa, tony
Priority: P3    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: All   
Attachments:
Description Flags
demonstrates the bug: underline extends to the next line when adjoint lines are merged with deletion none

Description Julie Parent 2009-02-17 14:00:19 PST
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.
Comment 1 Justin Garcia 2009-02-17 16:14:27 PST
*** Bug 23994 has been marked as a duplicate of this bug. ***
Comment 2 Justin Garcia 2009-02-17 16:15:20 PST
Minor thing: in step 3 you write that the "html is ..." but it isn't in that state until after step 5.
Comment 3 Justin Garcia 2009-02-17 17:09:05 PST
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.
Comment 4 Ryosuke Niwa 2009-07-13 18:18:28 PDT
Created attachment 32692 [details]
demonstrates the bug: underline extends to the next line when adjoint lines are merged with deletion
Comment 5 Ryosuke Niwa 2009-07-14 21:13:32 PDT
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>
Comment 6 Ryosuke Niwa 2009-08-04 13:53:41 PDT
This is another bug with ReplaceSelectionCommand as Justin suggested, we need to adjust where we insert the fragment.
Comment 7 Ryosuke Niwa 2009-08-04 15:36:29 PDT
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?
Comment 8 Ryosuke Niwa 2009-08-04 17:07:10 PDT
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.
Comment 9 Tony Chang 2010-01-28 00:05:32 PST
I have a fix for this in bug 21840.
Comment 10 Tony Chang 2010-03-09 21:35:22 PST
Fixed in r55762, which included a layout test for this case.

*** This bug has been marked as a duplicate of bug 21840 ***