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

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Apr 15 23:31:13 PDT 2012


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





--- Comment #4 from Antaryami Pandia (apandia) <antaryami.pandia at motorola.com>  2012-04-15 23:31:13 PST ---
Created an attachment (id=137281)
 --> (https://bugs.webkit.org/attachment.cgi?id=137281&action=review)
Patch for discussion.

As I have mentioned earlier, when we try to insert an empty string, the method "ReplaceSelectionCommand::performTrivialReplace" return false. And the flow progress to call the "CompositeEditCommand::splitTextNode" method. This method the calls "SplitTextNodeCommand::doApply" to perform next step. It is in this method that the DOm tree is modified.

In "SplitTextNodeCommand::doApply" first a substring is created till the current caret position. Means if the caret was at posion 16 when I click the button to insert empty string, then a substring is created with first 16 characters. Code snippet:-
    String prefixText = m_text2->substringData(0, m_offset, ec); 

After that a text node is craeted with that substring. Code snippet:-
    m_text1 = Text::create(document(), prefixText);

After crating the text node, it calls the "insertText1AndTrimText2" method. This method inserts the new text node before the actual text node.
    m_text2->parentNode()->insertBefore(m_text1.get(), m_text2.get(), ec);

The call to "splitTextNode" was added in http://wkbug.com/65824. It replaces the call to "splitTextNodeContainingElement", which was added in http://wkbug.com/56874.
And this block (in http://wkbug.com/56874 containing "splitTextNodeContainingElement") was placed before the check for fragment.

As per my understanding if we place the cursor in the middle of a text node and try to insert some text between, then we split text node. But in this case we have nothing to insert i.e the string to be inserted is empty. So I think check for fragments should precedes the call to code block containing splitTextNode. I am attaching the code change for discussion.

-- 
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