WebCore:

2009-04-22  Justin Garcia  <justin.garcia@apple.com>

        Reviewed by Darin Adler.

        https://bugs.webkit.org/show_bug.cgi?id=25322
        Can't delete empty paragraph after a block image
        
        Empty paragraph removal would have been handled by mergeParagraphs, but we stopped short
        because of some code that avoided problems that would arise from Positions that would go
        bad during deletion.  
        
        We have several checks that prevent us from using bad Positions, this one in particular
        was added to avoid bad Positions that result from text removal.  So, I removed the check
        and started correctly updating m_downstreamEnd during text removal so that it doesn't go
        bad.  m_upstreamStart doesn't need to be updated during text removal, since only text
        after it will ever be removed.

        * editing/DeleteSelectionCommand.cpp:
        (WebCore::DeleteSelectionCommand::deleteTextFromNode):
        (WebCore::DeleteSelectionCommand::handleGeneralDelete):
        (WebCore::DeleteSelectionCommand::mergeParagraphs):

LayoutTests:

2009-04-22  Justin Garcia  <justin.garcia@apple.com>

        Reviewed by Darin Adler.
        
        https://bugs.webkit.org/show_bug.cgi?id=25322
        Can't delete empty paragraph after a block image

        * editing/deleting/25322-1-expected.txt: Added.
        * editing/deleting/25322-1.html: Added.
        * editing/deleting/25322-2-expected.txt: Added.
        * editing/deleting/25322-2.html: Added.
        * editing/deleting/25322-3-expected.txt: Added.
        * editing/deleting/25322-3.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@42763 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6757628b
2009-04-22 Justin Garcia <justin.garcia@apple.com>
Reviewed by Darin Adler.
https://bugs.webkit.org/show_bug.cgi?id=25322
Can't delete empty paragraph after a block image
* editing/deleting/25322-1-expected.txt: Added.
* editing/deleting/25322-1.html: Added.
* editing/deleting/25322-2-expected.txt: Added.
* editing/deleting/25322-2.html: Added.
* editing/deleting/25322-3-expected.txt: Added.
* editing/deleting/25322-3.html: Added.
2009-04-22 Darin Adler <darin@apple.com>
* platform/mac/svg/W3C-SVG-1.1/animate-elem-36-t-expected.txt: Fixed one
......
This tests to make sure that placing the caret in an empty paragraph after a block image and pressing delete removes the empty paragraph. The editable region below should contain only an image followed by a caret.
<img src="../resources/abe.png" style="display:block; padding: 3px;">
<head>
<script>
function runTest() {
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
window.setTimeout(afterDelay, 20);
}
function afterDelay() {
forCaret = document.getElementById("forCaret");
window.getSelection().setPosition(forCaret, 0);
document.execCommand("Delete");
if (window.layoutTestController) {
document.body.innerText = document.getElementById("description").innerText + "\n\n" + document.getElementById("edit").innerHTML;
layoutTestController.notifyDone();
}
}
</script>
</head>
<body onLoad="runTest();">
<div id="description">This tests to make sure that placing the caret in an empty paragraph after a block image and pressing delete removes the empty paragraph. The editable region below should contain only an image followed by a caret.</div>
<div id="edit" contentEditable="true"><img src="../resources/abe.png" style="display:block; padding: 3px;"><div id="forCaret"><br></div></div>
</body>
This tests to make sure that placing the caret in an empty paragraph after a block image and pressing delete removes the empty paragraph. The editable region below should contain only an image followed by a caret.
<img src="../resources/abe.png" style="display:block; padding: 3px;">
<head>
<script>
function runTest() {
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
window.setTimeout(afterDelay, 20);
}
function afterDelay() {
edit = document.getElementById("edit");
window.getSelection().setPosition(edit, edit.childNodes.length);
document.execCommand("Delete");
if (window.layoutTestController) {
document.body.innerText = document.getElementById("description").innerText + "\n\n" + edit.innerHTML;
layoutTestController.notifyDone();
}
}
</script>
</head>
<body onLoad="runTest();">
<div id="description">This tests to make sure that placing the caret in an empty paragraph after a block image and pressing delete removes the empty paragraph. The editable region below should contain only an image followed by a caret.</div>
<div id="edit" contentEditable="true"><img src="../resources/abe.png" style="display:block; padding: 3px;"><br></div>
</body>
This tests to make sure that placing the caret at the beginning of a paragraph of text just after a block image and pressing delete does not move the text. It cannot be made inline with the image since it's a block image. The editable region below should contain an image followed by a paragraph of text.
<img src="../resources/abe.png" style="display:block; padding: 3px;">This text should be in its own paragraph.
<head>
<script>
function runTest() {
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
window.setTimeout(afterDelay, 20);
}
function afterDelay() {
forCaret = document.getElementById("forCaret");
window.getSelection().setPosition(forCaret, 0);
document.execCommand("Delete");
if (window.layoutTestController) {
document.body.innerText = document.getElementById("description").innerText + "\n\n" + document.getElementById("edit").innerHTML;
layoutTestController.notifyDone();
}
}
</script>
</head>
<body onLoad="runTest();">
<div id="description">This tests to make sure that placing the caret at the beginning of a paragraph of text just after a block image and pressing delete does not move the text. It cannot be made inline with the image since it's a block image. The editable region below should contain an image followed by a paragraph of text.</div>
<div id="edit" contentEditable="true"><img src="../resources/abe.png" style="display:block; padding: 3px;"><div id="forCaret">This text should be in its own paragraph.</div></div>
</body>
2009-04-22 Justin Garcia <justin.garcia@apple.com>
Reviewed by Darin Adler.
https://bugs.webkit.org/show_bug.cgi?id=25322
Can't delete empty paragraph after a block image
Empty paragraph removal would have been handled by mergeParagraphs, but we stopped short
because of some code that avoided problems that would arise from Positions that would go
bad during deletion.
We have several checks that prevent us from using bad Positions, this one in particular
was added to avoid bad Positions that result from text removal. So, I removed the check
and started correctly updating m_downstreamEnd during text removal so that it doesn't go
bad. m_upstreamStart doesn't need to be updated during text removal, since only text
after it will ever be removed.
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::deleteTextFromNode):
(WebCore::DeleteSelectionCommand::handleGeneralDelete):
(WebCore::DeleteSelectionCommand::mergeParagraphs):
2009-04-22 Oliver Hunt <oliver@apple.com>
Reviewed by Darin Adler.
......@@ -390,6 +390,7 @@ void DeleteSelectionCommand::deleteTextFromNode(PassRefPtr<Text> node, unsigned
updatePositionForTextRemoval(node.get(), offset, count, m_endingPosition);
updatePositionForTextRemoval(node.get(), offset, count, m_leadingWhitespace);
updatePositionForTextRemoval(node.get(), offset, count, m_trailingWhitespace);
updatePositionForTextRemoval(node.get(), offset, count, m_downstreamEnd);
CompositeEditCommand::deleteTextFromNode(node, offset, count);
}
......@@ -487,7 +488,6 @@ void DeleteSelectionCommand::handleGeneralDelete()
Text *text = static_cast<Text *>(m_downstreamEnd.node());
if (m_downstreamEnd.m_offset > 0) {
deleteTextFromNode(text, 0, m_downstreamEnd.m_offset);
m_downstreamEnd = Position(text, 0);
}
// Remove children of m_downstreamEnd.node() that come after m_upstreamStart.
// Don't try to remove children if m_upstreamStart was inside m_downstreamEnd.node()
......@@ -556,9 +556,8 @@ void DeleteSelectionCommand::mergeParagraphs()
if (Range::compareBoundaryPoints(m_upstreamStart, m_downstreamEnd) > 0)
return;
// FIXME: Merging will always be unnecessary in this case, but we really bail here because this is a case where
// deletion commonly fails to adjust its endpoints, which would cause the visible position comparison below to false negative.
if (m_endBlock == m_startBlock)
// There's nothing to merge.
if (m_upstreamStart == m_downstreamEnd)
return;
VisiblePosition startOfParagraphToMove(m_downstreamEnd);
......
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