Commit e4b84c50 authored by harrison's avatar harrison

Reviewed by Justin.

        <rdar://problem/4065343> Mail: Deleting a line sometimes makes the insertion point jump to the top of the message

        Test cases added: delete-br-011.html

        * khtml/editing/delete_selection_command.cpp:
        (khtml::DeleteSelectionCommand::handleSpecialCaseBRDelete):
        Make sure m_endingSelection is usable.

        (khtml::DeleteSelectionCommand::doApply):
        Skip general delete related code when just doing handleSpecialCaseBRDelete().

        * layout-tests/editing/deleting/delete-br-011-expected.txt: Added.
        * layout-tests/editing/deleting/delete-br-011.html: Added.
        Mimics composing a Mail.app reply, clicking past the end of the content, and hitting delete key.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@9821 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1d3a8da1
layer at (0,0) size 800x600
RenderCanvas at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock (anonymous) at (0,0) size 784x18
RenderText {TEXT} at (0,0) size 31x18
text run at (0,0) width 31: "hello"
RenderBlock {DIV} at (0,18) size 784x56 [border: (2px solid #FF0000)]
RenderBR {BR} at (14,14) size 0x28
RenderBlock (anonymous) at (0,74) size 784x0
caret: position 1 of child 0 {BR} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
<html>
<head>
<style>
.editing {
border: 2px solid red;
padding: 12px;
font-size: 24px;
}
</style>
<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
<script>
function editingTest() {
for (i = 0; i < 5; i++)
moveSelectionForwardByLineCommand();
deleteCommand();
}
</script>
<title>Editing Test</title>
</head>
<body onload="runEditingTest();" contenteditable id="root">hello<div class="editing" id="test"><br></div><br></body></html>
2005-07-18 David Harrison <harrison@apple.com>
Reviewed by Justin.
<rdar://problem/4065343> Mail: Deleting a line sometimes makes the insertion point jump to the top of the message
Test cases added: delete-br-011.html
* khtml/editing/delete_selection_command.cpp:
(khtml::DeleteSelectionCommand::handleSpecialCaseBRDelete):
Make sure m_endingSelection is usable.
(khtml::DeleteSelectionCommand::doApply):
Skip general delete related code when just doing handleSpecialCaseBRDelete().
* layout-tests/editing/deleting/delete-br-011-expected.txt: Added.
* layout-tests/editing/deleting/delete-br-011.html: Added.
Mimics composing a Mail.app reply, clicking past the end of the content, and hitting delete key.
2005-07-15 Adele Peterson <adele@apple.com>
Written by Anders Carlsson <andersca@mac.com>
......@@ -286,8 +286,9 @@ bool DeleteSelectionCommand::handleSpecialCaseBRDelete()
bool downstreamStartIsBR = m_downstreamStart.node()->hasTagName(HTMLNames::br());
bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && m_downstreamStart.node() == m_upstreamEnd.node();
if (isBROnLineByItself) {
m_endingPosition = Position(m_downstreamStart.node()->parentNode(), m_downstreamStart.node()->nodeIndex());
removeNode(m_downstreamStart.node());
m_endingPosition = m_upstreamStart;
m_endingPosition = m_endingPosition.equivalentDeepPosition();
m_mergeBlocksAfterDelete = false;
return true;
}
......@@ -702,7 +703,6 @@ void DeleteSelectionCommand::doApply()
// set up our state
initializePositionData();
if (!m_startBlock || !m_endBlock) {
// Can't figure out what blocks we're in. This can happen if
// the document structure is not what we are expecting, like if
......@@ -713,6 +713,17 @@ void DeleteSelectionCommand::doApply()
return;
}
// deleting just a BR is handled specially, at least because we do not
// want to replace it with a placeholder BR!
if (handleSpecialCaseBRDelete()) {
calculateTypingStyleAfterDelete(false);
debugPosition("endingPosition ", m_endingPosition);
setEndingSelection(Selection(m_endingPosition, affinity));
clearTransientState();
rebalanceWhitespace();
return;
}
// if all we are deleting is complete paragraph(s), we need to make
// sure a blank paragraph remains when we are done
bool forceBlankParagraph = isStartOfParagraph(VisiblePosition(m_upstreamStart, VP_DEFAULT_AFFINITY)) &&
......@@ -722,10 +733,9 @@ void DeleteSelectionCommand::doApply()
deleteInsignificantTextDownstream(m_trailingWhitespace);
saveTypingStyleState();
insertPlaceholderForAncestorBlockContent();
if (!handleSpecialCaseBRDelete())
handleGeneralDelete();
insertPlaceholderForAncestorBlockContent();
handleGeneralDelete();
// Do block merge if start and end of selection are in different blocks.
moveNodesAfterNode();
......@@ -745,6 +755,7 @@ void DeleteSelectionCommand::doApply()
addBlockPlaceholderIfNeeded(m_endingPosition.node());
calculateTypingStyleAfterDelete(addedPlaceholder);
debugPosition("endingPosition ", m_endingPosition);
setEndingSelection(Selection(m_endingPosition, affinity));
clearTransientState();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment