Bug 24981
Summary: | Crazy backspace/delete behavior | ||
---|---|---|---|
Product: | WebKit | Reporter: | Julie Parent <jparent> |
Component: | HTML Editing | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED WORKSFORME | ||
Severity: | Normal | CC: | eric, justin.garcia, ojan, rniwa |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | PC | ||
OS: | OS X 10.5 | ||
URL: | http://jparent.googlepages.com/brokenBackspace.html |
Julie Parent
1. Go to http://jparent.googlepages.com/brokenBackspace.html or paste the following HTML into your favorite contentEditable region: <h3>heading</h3> other text
2. Put your cursor before the "o" in other
3. Hit backspace
Result: The "o" stays where it is, the "t" moves onto the next line, and "her text" merges up onto the line with "heading". Html is: <h3>heading<span class="Apple-style-span" style="font-size: 16px; font-weight: normal; ">her text</span></h3>o<br>t
Expected result: "other text" merges onto the line wiht "heading"
Notes:
* This also happens if you put the cursor after the "g" in heading and hit delete.
* The problem is clearly with the whitespace before "other text". With only one whitespace, only the "o" gets left behind, with two whitespaces, the "ot" get left behind, with three whitespaces, "oth" get left behind, etc.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Julie Parent
I think this happens for all blocks. If you replace the <H3> in my example with a <DIV>, <OL><LI>, <BLOCKQUOTE> it also repros.
swethanagaraj
Hi,
I have been analysing the code for this bug, these are the observation made
In Webkit\WebCore\editing\deleteselectioncommand.cpp
-CompositeEditCommand::deleteTextFromNode(node, offset, count) method will
remove the white-space from the string=" other text" and gives us string="other text", without space.
but still the offSet value will be '3', which should be made to '0' before the call to
VisiblePosition startOfParagraphToMove(m_downstreamEnd) method in
mergeParagraphs()
else from the 3rd postion of "other text" which is from 'h' it will merge with heading.
so to reset the offset to zero , call m_upstreamStart = m_selectionToDelete.start() and
m_downstreamEnd = m_selectionToDelete.end() method before making a call to
VisiblePosition startOfParagraphToMove(m_downstreamEnd) in mergeParagraphs()
this would eliminate the problem due to white-space.
Ryosuke Niwa
I can't reproduce this bug. Maybe it has been fixed?
Julie Parent
I can't repro anymore either. I'll mark as fixed.