Bug 113413

Summary: Inserting a blank (" ") at the end of a line does not insert anything in Overtype mode
Product: WebKit Reporter: Sergio Villar Senin <svillar>
Component: HTML EditingAssignee: Sergio Villar Senin <svillar>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, enrica, koivisto, mifenton, rniwa, shezbaig.wk, svillar, tkent, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch rniwa: review+

Description Sergio Villar Senin 2013-03-27 08:54:18 PDT
That's because we're still calling replaceTextInNode() in that case which is wrong because the replace code makes some assumptions that are not valid for this case.
Comment 1 Sergio Villar Senin 2013-03-27 09:23:32 PDT
Created attachment 195341 [details]
Patch
Comment 2 Ryosuke Niwa 2013-03-27 09:27:40 PDT
Comment on attachment 195341 [details]
Patch

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

> Source/WebCore/editing/InsertTextCommand.cpp:106
> +    if (!selectInsertedText)
> +        setEndingSelection(VisibleSelection(endingSelection().visibleEnd(), endingSelection().isDirectional()));

Do we have a test for this?

> LayoutTests/editing/execCommand/overtype.html:33
> -    document.execCommand("InsertText", false, 'FO');
> -    Markup.dump(element, 'After overwritting the first two characters');
> +    document.execCommand("InsertText", false, 'F');
> +    Markup.dump(element, 'After overwritting the first character');

Why are we modifying this test case?
Comment 3 Sergio Villar Senin 2013-03-27 10:53:21 PDT
(In reply to comment #2)
> (From update of attachment 195341 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=195341&action=review
> 
> > Source/WebCore/editing/InsertTextCommand.cpp:106
> > +    if (!selectInsertedText)
> > +        setEndingSelection(VisibleSelection(endingSelection().visibleEnd(), endingSelection().isDirectional()));
> 
> Do we have a test for this?

What do you mean? For the case selectInsertedText == true ? Note that I am not adding any code in that case, it's just a refactoring to allow us to use setEndingSelectionWithoutValidation(). Not really required by the patch, but I just found it convenient.
 
> > LayoutTests/editing/execCommand/overtype.html:33
> > -    document.execCommand("InsertText", false, 'FO');
> > -    Markup.dump(element, 'After overwritting the first two characters');
> > +    document.execCommand("InsertText", false, 'F');
> > +    Markup.dump(element, 'After overwritting the first character');
> 
> Why are we modifying this test case?

Just because the original work was "foo" and as I wanted to overwrite with withespace in the middle and in the end.
Comment 4 Ryosuke Niwa 2013-03-27 10:56:07 PDT
Comment on attachment 195341 [details]
Patch

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

>>> Source/WebCore/editing/InsertTextCommand.cpp:106
>>> +        setEndingSelection(VisibleSelection(endingSelection().visibleEnd(), endingSelection().isDirectional()));
>> 
>> Do we have a test for this?
> 
> What do you mean? For the case selectInsertedText == true ? Note that I am not adding any code in that case, it's just a refactoring to allow us to use setEndingSelectionWithoutValidation(). Not really required by the patch, but I just found it convenient.

Oh, I see. Sorry, I misread your patch.
Comment 5 Sergio Villar Senin 2013-03-27 11:24:35 PDT
Committed r146999: <http://trac.webkit.org/changeset/146999>