[Webkit-unassigned] [Bug 71771] Inserting empty html moves caret

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Apr 8 12:36:11 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=71771





--- Comment #1 from Antaryami Pandia <antaryami.pandia at motorola.com>  2012-04-08 12:36:11 PST ---
To find the issue I tried to compare the scenerios when we add a and non-empty string and when add an empty string.Below is my analysis:- 

Case 1. Insert a non-empty string
When we add a non-empty string the method "createFragmentFromMarkup" creates a fragments with child having the value of the string to be inserted.And then "executeInsertFragment" method is called. This method in turns calls the "ReplaceSelectionCommand::performTrivialReplace" method, which actually insert the string directly into the text node. Then it calculates the caret rect accordingly. If I have placed the cursor in 16th pos and clicked the button then it adds the string and calculates the width till 17th character and places the caret. Point to note is that while calculating the caret position the start position of the text node (to which the string is inserted) is considered. So if the start pos is (0,0) then the caret position should be (0+width of 17 characters, 0).

Case 2. Insert empty string 
When we add a empty string the method "createFragmentFromMarkup" creates a fragments with the child being set to false. In "ReplaceSelectionCommand::performTrivialReplace" there is a check for child of the fragments. Since the child is not there it return false. And the flow progress to call the "CompositeEditCommand::splitTextNode" method, which goes on and creates another rendertext with 16 characters(I have placed the cursor in 16th position and click on the button).

Because of this new text run, while calculating rect for the caret rather then considering the start position as the start of the text node (to which the empty string is inserted), it takes the end position of this new text run as the start position. say if the width of 16 charactes is 80px then, it takes the start pos as (80, 0). Hence it cacluates the caret position as (80 + width of 16 characters, 0) or (160, 0) which should be actually (80, 0).

Hence the caret is drawn on the wrong position.

I think the "DocumentFragment" plays a role  in deciding the flow of inserting a empty/non-empty string. So can we have a check for the child of documentfragment before proceeding with the "InsertHTML" command, say in "executeInsertFragment" method.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list