Commit b024701d authored by a.bah@samsung.com's avatar a.bah@samsung.com
Browse files

<br> does not get deleted when inlined after some non-textual content.

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

Patch by Arpita Bahuguna <a.bah@samsung.com> on 2013-08-23
Reviewed by Ryosuke Niwa.

Source/WebCore: 

deleteSelectionCommand does not handle the case when a <br> element is
inlined after some non-textual content (input controls, image etc.).

When doing a back-delete at the start of a line following such a <br>
the two contiguous lines should merge and the <br> should get deleted.
Currently, even though the <br> is deleted, another placeholder <br>
is incorrectly inserted at the same point, thus effectively there is no
change.

We are incorrectly computing the inline <br> to be at the start of an
empty line even though the line is not empty.

Test: editing/deleting/delete-inline-br.html

* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::handleSpecialCaseBRDelete):
Adding a check to verify that the inline <br> is not on an empty line
if the end node is not a <br> element itself and it's previous sibling
is the start <br> element.

Basically we check whether there is another node (end node) following
the <br>, that the node is not a <br> itself, and that the end node's
previous node is the start <br>.

LayoutTests: 

* editing/deleting/delete-inline-br-expected.txt: Added.
* editing/deleting/delete-inline-br.html: Added.
Added a testcase that verifies that the caret is placed at the correct
position after performing a back-delete operation.

* editing/deleting/delete-before-block-image-2-expected.txt:
* platform/mac/editing/deleting/delete-br-004-expected.txt:
* platform/mac/editing/deleting/delete-br-005-expected.txt:
* platform/mac/editing/deleting/delete-br-006-expected.txt:
* platform/qt/editing/deleting/delete-br-004-expected.txt:
* platform/qt/editing/deleting/delete-br-005-expected.txt:
* platform/qt/editing/deleting/delete-br-006-expected.txt:
Rebaselining existing tests. No visual change in behavior for these tests.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154479 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 13be8c45
2013-08-23 Arpita Bahuguna <a.bah@samsung.com>
<br> does not get deleted when inlined after some non-textual content.
https://bugs.webkit.org/show_bug.cgi?id=120006
Reviewed by Ryosuke Niwa.
* editing/deleting/delete-inline-br-expected.txt: Added.
* editing/deleting/delete-inline-br.html: Added.
Added a testcase that verifies that the caret is placed at the correct
position after performing a back-delete operation.
* editing/deleting/delete-before-block-image-2-expected.txt:
* platform/mac/editing/deleting/delete-br-004-expected.txt:
* platform/mac/editing/deleting/delete-br-005-expected.txt:
* platform/mac/editing/deleting/delete-br-006-expected.txt:
* platform/qt/editing/deleting/delete-br-004-expected.txt:
* platform/qt/editing/deleting/delete-br-005-expected.txt:
* platform/qt/editing/deleting/delete-br-006-expected.txt:
Rebaselining existing tests. No visual change in behavior for these tests.
2013-08-23 Peter Gal <galpeter@inf.u-szeged.hu>
 
[WTR] Should dump as text when the mimetype is text/plain
<img id="img" src="../resources/abe.png" style="display: block;">
<img id="img" style="display:block;" src="../resources/abe.png">
Selection: [[object HTMLDivElement], 0]
Testcase for bug 120006: <br> does not get deleted when inlined after some non-textual content. To manually verify this issue, place the caret at the start of the second line and then do a back-delete (backspace). The two lines should then be merged and the caret should get placed after the text control.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS caretRect.left is expectedCaretRect.left
PASS caretRect.top is expectedCaretRect.top
<!DOCTYPE html>
<html>
<head>
<style>
div { border: 1px solid black; }
</style>
<script src="../../fast/js/resources/js-test-pre.js"></script>
<script>
function runTest() {
description('Testcase for bug <a href="https://bugs.webkit.org/show_bug.cgi?id=120006">120006</a>: &lt;br&gt; does not get deleted when inlined after some non-textual content.\nTo manually verify this issue, place the caret at the start of the second line and then do a back-delete (backspace). The two lines should then be merged and the caret should get placed after the text control.');
if (window.internals) {
var selection = window.getSelection();
var testElement = document.getElementById('test');
selection.collapse(testElement, 2);
expectedCaretRect = internals.absoluteCaretBounds(document);
selection.collapse(testElement, 3);
document.execCommand("Delete");
caretRect = internals.absoluteCaretBounds(document);
shouldBe("caretRect.left", "expectedCaretRect.left");
shouldBe("caretRect.top", "expectedCaretRect.top");
testElement.style.display = 'none';
}
}
</script>
<body onLoad="runTest()">
<div contenteditable="true">
<span id="test">text1<input type="text"/><br>text2</span>
</div>
<div id="description"></div>
<div id="console"></div>
</body>
</html>
......@@ -25,7 +25,6 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
......@@ -43,4 +42,5 @@ layer at (0,0) size 800x600
RenderBR {BR} at (14,42) size 0x28
RenderText {#text} at (14,70) size 92x28
text run at (14,70) width 92: "years ago"
RenderText {#text} at (0,0) size 0x0
caret: position 0 of child 3 {#text} of child 1 {SPAN} of child 1 {DIV} of body
......@@ -25,11 +25,9 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
......@@ -46,4 +44,5 @@ layer at (0,0) size 800x600
RenderBR {BR} at (218,36) size 0x0
RenderText {#text} at (14,42) size 92x28
text run at (14,42) width 92: "years ago"
RenderText {#text} at (0,0) size 0x0
caret: position 0 of child 2 {#text} of child 1 {SPAN} of child 1 {DIV} of body
......@@ -25,11 +25,9 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 1 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document
......@@ -49,4 +47,5 @@ layer at (0,0) size 800x600
text run at (157,14) width 61: "seven "
RenderText {#text} at (218,14) size 92x28
text run at (218,14) width 92: "years ago"
RenderText {#text} at (0,0) size 0x0
caret: position 23 of child 0 {#text} of child 1 {SPAN} of child 1 {DIV} of body
......@@ -25,7 +25,6 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
......@@ -43,4 +42,5 @@ layer at (0,0) size 800x600
RenderBR {BR} at (14,42) size 0x28
RenderText {#text} at (14,70) size 91x28
text run at (14,70) width 91: "years ago"
RenderText {#text} at (0,0) size 0x0
caret: position 0 of child 3 {#text} of child 1 {SPAN} of child 1 {DIV} of body
......@@ -25,11 +25,9 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
......@@ -46,4 +44,5 @@ layer at (0,0) size 800x600
RenderBR {BR} at (218,36) size 0x0
RenderText {#text} at (14,42) size 91x28
text run at (14,42) width 91: "years ago"
RenderText {#text} at (0,0) size 0x0
caret: position 0 of child 2 {#text} of child 1 {SPAN} of child 1 {DIV} of body
......@@ -25,11 +25,9 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > SPAN > DIV > BODY > HTML > #document to 9 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: shouldDeleteDOMRange:range from 1 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document
......@@ -49,4 +47,5 @@ layer at (0,0) size 800x600
text run at (157,14) width 61: "seven "
RenderText {#text} at (218,14) size 91x28
text run at (218,14) width 91: "years ago"
RenderText {#text} at (0,0) size 0x0
caret: position 23 of child 0 {#text} of child 1 {SPAN} of child 1 {DIV} of body
2013-08-23 Arpita Bahuguna <a.bah@samsung.com>
<br> does not get deleted when inlined after some non-textual content.
https://bugs.webkit.org/show_bug.cgi?id=120006
Reviewed by Ryosuke Niwa.
deleteSelectionCommand does not handle the case when a <br> element is
inlined after some non-textual content (input controls, image etc.).
When doing a back-delete at the start of a line following such a <br>
the two contiguous lines should merge and the <br> should get deleted.
Currently, even though the <br> is deleted, another placeholder <br>
is incorrectly inserted at the same point, thus effectively there is no
change.
We are incorrectly computing the inline <br> to be at the start of an
empty line even though the line is not empty.
Test: editing/deleting/delete-inline-br.html
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::handleSpecialCaseBRDelete):
Adding a check to verify that the inline <br> is not on an empty line
if the end node is not a <br> element itself and it's previous sibling
is the start <br> element.
Basically we check whether there is another node (end node) following
the <br>, that the node is not a <br> itself, and that the end node's
previous node is the start <br>.
2013-08-23 Renata Hodovan <reni@webkit.org>
 
Missing null-check in HTMLFormElement::rendererIsNeeded()
......@@ -320,7 +320,9 @@ bool DeleteSelectionCommand::handleSpecialCaseBRDelete()
// FIXME: This code doesn't belong in here.
// We detect the case where the start is an empty line consisting of BR not wrapped in a block element.
if (upstreamStartIsBR && downstreamStartIsBR && !(isStartOfBlock(positionBeforeNode(nodeAfterUpstreamStart)) && isEndOfBlock(positionAfterNode(nodeAfterUpstreamStart)))) {
if (upstreamStartIsBR && downstreamStartIsBR
&& !(isStartOfBlock(positionBeforeNode(nodeAfterUpstreamStart)) && isEndOfBlock(positionAfterNode(nodeAfterDownstreamStart)))
&& (!nodeAfterUpstreamEnd || nodeAfterUpstreamEnd->hasTagName(brTag) || nodeAfterUpstreamEnd->previousSibling() != nodeAfterUpstreamStart)) {
m_startsAtEmptyLine = true;
m_endingPosition = 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