Bug 120006 - <br> does not get deleted when inlined after some non-textual content.
Summary: <br> does not get deleted when inlined after some non-textual content.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Arpita Bahuguna
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-19 03:44 PDT by Arpita Bahuguna
Modified: 2013-08-26 05:42 PDT (History)
5 users (show)

See Also:


Attachments
Test page (189 bytes, text/html)
2013-08-19 03:44 PDT, Arpita Bahuguna
no flags Details
Patch (26.61 KB, patch)
2013-08-19 05:03 PDT, Arpita Bahuguna
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2 (777.55 KB, application/zip)
2013-08-19 10:31 PDT, Build Bot
no flags Details
Patch (6.70 KB, patch)
2013-08-22 03:51 PDT, Arpita Bahuguna
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-10 for mac-mountainlion-wk2 (633.91 KB, application/zip)
2013-08-22 05:19 PDT, Build Bot
no flags Details
Patch (12.65 KB, patch)
2013-08-22 06:15 PDT, Arpita Bahuguna
rniwa: review+
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-06 for mac-mountainlion (529.00 KB, application/zip)
2013-08-22 07:23 PDT, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-08 for mac-mountainlion (533.17 KB, application/zip)
2013-08-22 08:23 PDT, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2 (630.64 KB, application/zip)
2013-08-22 13:59 PDT, Build Bot
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arpita Bahuguna 2013-08-19 03:44:07 PDT
Created attachment 209076 [details]
Test page

Fetch the attached testpage and place the cursor at the start of the second line, right before "text2".
Now press backspace (delete backward) so that the two lines merge.

Notice that the lines do not merge and the back-delete does not have any effect.
Comment 1 Arpita Bahuguna 2013-08-19 05:03:35 PDT
Created attachment 209078 [details]
Patch
Comment 2 Build Bot 2013-08-19 10:31:43 PDT
Comment on attachment 209078 [details]
Patch

Attachment 209078 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/1478937

New failing tests:
editing/deleting/delete-inline-br.html
Comment 3 Build Bot 2013-08-19 10:31:44 PDT
Created attachment 209101 [details]
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-12  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.4
Comment 4 Andy Estes 2013-08-19 11:09:18 PDT
Comment on attachment 209078 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=209078&action=review

> Source/WebCore/editing/DeleteSelectionCommand.cpp:323
> -    if (upstreamStartIsBR && downstreamStartIsBR && !(isStartOfBlock(positionBeforeNode(nodeAfterUpstreamStart)) && isEndOfBlock(positionAfterNode(nodeAfterUpstreamStart)))) {
> +    if (upstreamStartIsBR && downstreamStartIsBR && !(isStartOfBlock(positionBeforeNode(nodeAfterUpstreamStart)) && isEndOfBlock(positionAfterNode(nodeAfterDownstreamStart))) && (!nodeAfterUpstreamEnd || !(nodeAfterUpstreamEnd->previousSibling() == nodeAfterUpstreamStart))) {

Just a drive-by comment: I think !(nodeAfterUpstreamEnd->previousSibling() == nodeAfterUpstreamStart) should be nodeAfterUpstreamEnd->previousSibling() != nodeAfterUpstreamStart instead.
Comment 5 Ryosuke Niwa 2013-08-19 12:39:02 PDT
Comment on attachment 209078 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=209078&action=review

> Source/WebCore/ChangeLog:24
> +        Added a check to verify that the inline <br> is not on an empty line if
> +        the end node's previous sibling is the <br> element.

I don't understand this comment.  If end node is a br and its previous sibling is a br, then it IS an empty line.

>> Source/WebCore/editing/DeleteSelectionCommand.cpp:323
>> +    if (upstreamStartIsBR && downstreamStartIsBR && !(isStartOfBlock(positionBeforeNode(nodeAfterUpstreamStart)) && isEndOfBlock(positionAfterNode(nodeAfterDownstreamStart))) && (!nodeAfterUpstreamEnd || !(nodeAfterUpstreamEnd->previousSibling() == nodeAfterUpstreamStart))) {
> 
> Just a drive-by comment: I think !(nodeAfterUpstreamEnd->previousSibling() == nodeAfterUpstreamStart) should be nodeAfterUpstreamEnd->previousSibling() != nodeAfterUpstreamStart instead.

I don't think this fix is correct. What we want to detect here is if the entire line consists of br or not.
Comment 6 Ryosuke Niwa 2013-08-19 12:40:23 PDT
Comment on attachment 209078 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=209078&action=review

> LayoutTests/editing/deleting/delete-inline-br.html:15
> +function editingTest() {
> +    for (i = 0; i < 7; i++) {
> +        moveSelectionForwardByCharacterCommand();
> +    }
> +    deleteCommand();
> +}
> +</script>

This should be a dump-as-markup test.  There is no need for this to be a pixel test.  r- because of this.

> LayoutTests/platform/efl/TestExpectations:1782
> +# Needs to be rebaselined after landing patch for 120006
> +# https://bugs.webkit.org/show_bug.cgi?id=120006
> +webkit.org/b/120006 editing/deleting/delete-br-004.html [ Failure ]
> +webkit.org/b/120006 editing/deleting/delete-br-005.html [ Failure ]
> +webkit.org/b/120006 editing/deleting/delete-br-006.html [ Failure ]

Please don't add these test expectations. Instead, land this patch and rebaseline them after the fact.
Comment 7 Arpita Bahuguna 2013-08-22 03:51:23 PDT
Created attachment 209340 [details]
Patch
Comment 8 Arpita Bahuguna 2013-08-22 04:28:02 PDT
Comment on attachment 209078 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=209078&action=review

>> Source/WebCore/ChangeLog:24
>> +        the end node's previous sibling is the <br> element.
> 
> I don't understand this comment.  If end node is a br and its previous sibling is a br, then it IS an empty line.

The end node is not a <br> is this case. Have now added an explicit check for the same.

>>> Source/WebCore/editing/DeleteSelectionCommand.cpp:323
>>> +    if (upstreamStartIsBR && downstreamStartIsBR && !(isStartOfBlock(positionBeforeNode(nodeAfterUpstreamStart)) && isEndOfBlock(positionAfterNode(nodeAfterDownstreamStart))) && (!nodeAfterUpstreamEnd || !(nodeAfterUpstreamEnd->previousSibling() == nodeAfterUpstreamStart))) {
>> 
>> Just a drive-by comment: I think !(nodeAfterUpstreamEnd->previousSibling() == nodeAfterUpstreamStart) should be nodeAfterUpstreamEnd->previousSibling() != nodeAfterUpstreamStart instead.
> 
> I don't think this fix is correct. What we want to detect here is if the entire line consists of br or not.

Yes, so if the end node's previous sibling is the <br> element and we know that the <br> is inline and the end node is not another <br> element (check added now) then we can assume that the <br> is not on an empty line. (?)

A similar check is done in the code before this where:
 bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && ((nodeAfterDownstreamStart == nodeAfterUpstreamEnd) || (nodeAfterUpstreamEnd && nodeAfterUpstreamEnd->hasTagName(brTag) && nodeAfterUpstreamStart->nextSibling() == nodeAfterUpstreamEnd));
This particularly checks for the condition if we have a <br> following another <br> (<br><br>) and has the check nodeAfterUpstreamStart->nextSibling() == nodeAfterUpstreamEnd.

Even for a case like:
<div contenteditable="true">
<span>text1<input type="text"/><br></span>text2
</div>
In this case both upstreamStart and downstreamStart will point to the <br> element and upstreamEnd will be NULL. So it will set m_startsAtEmptyLine (since my condition checks for !nodeAfterUpstreamEnd).

>> LayoutTests/editing/deleting/delete-inline-br.html:15
>> +</script>
> 
> This should be a dump-as-markup test.  There is no need for this to be a pixel test.  r- because of this.

Have changed the layout testcase.

>> LayoutTests/platform/efl/TestExpectations:1782
>> +webkit.org/b/120006 editing/deleting/delete-br-006.html [ Failure ]
> 
> Please don't add these test expectations. Instead, land this patch and rebaseline them after the fact.

Removed these from the next patch. Shall rebaseline the same after landing the patch.
Comment 9 Arpita Bahuguna 2013-08-22 04:30:25 PDT
(In reply to comment #6)
> (From update of attachment 209078 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=209078&action=review
> 
Thanks for the review Ryosuke. Have uploaded another patch as per the review comments.

> > LayoutTests/editing/deleting/delete-inline-br.html:15
> > +function editingTest() {
> > +    for (i = 0; i < 7; i++) {
> > +        moveSelectionForwardByCharacterCommand();
> > +    }
> > +    deleteCommand();
> > +}
> > +</script>
> 
> This should be a dump-as-markup test.  There is no need for this to be a pixel test.  r- because of this.
> 
> > LayoutTests/platform/efl/TestExpectations:1782
> > +# Needs to be rebaselined after landing patch for 120006
> > +# https://bugs.webkit.org/show_bug.cgi?id=120006
> > +webkit.org/b/120006 editing/deleting/delete-br-004.html [ Failure ]
> > +webkit.org/b/120006 editing/deleting/delete-br-005.html [ Failure ]
> > +webkit.org/b/120006 editing/deleting/delete-br-006.html [ Failure ]
> 
> Please don't add these test expectations. Instead, land this patch and rebaseline them after the fact.
Comment 10 Arpita Bahuguna 2013-08-22 04:31:11 PDT
Comment on attachment 209340 [details]
Patch

Expected failures:
editing/deleting/delete-br-004.html
editing/deleting/delete-br-005.html
editing/deleting/delete-br-006.html
Comment 11 Arpita Bahuguna 2013-08-22 04:32:19 PDT
(In reply to comment #4)
> (From update of attachment 209078 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=209078&action=review
> 
Thanks for the comment Andy. Have made the suggested change.

> > Source/WebCore/editing/DeleteSelectionCommand.cpp:323
> > -    if (upstreamStartIsBR && downstreamStartIsBR && !(isStartOfBlock(positionBeforeNode(nodeAfterUpstreamStart)) && isEndOfBlock(positionAfterNode(nodeAfterUpstreamStart)))) {
> > +    if (upstreamStartIsBR && downstreamStartIsBR && !(isStartOfBlock(positionBeforeNode(nodeAfterUpstreamStart)) && isEndOfBlock(positionAfterNode(nodeAfterDownstreamStart))) && (!nodeAfterUpstreamEnd || !(nodeAfterUpstreamEnd->previousSibling() == nodeAfterUpstreamStart))) {
> 
> Just a drive-by comment: I think !(nodeAfterUpstreamEnd->previousSibling() == nodeAfterUpstreamStart) should be nodeAfterUpstreamEnd->previousSibling() != nodeAfterUpstreamStart instead.
Comment 12 Build Bot 2013-08-22 05:19:33 PDT
Comment on attachment 209340 [details]
Patch

Attachment 209340 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/1426065

New failing tests:
editing/deleting/delete-br-005.html
editing/deleting/delete-br-006.html
editing/deleting/delete-br-004.html
Comment 13 Build Bot 2013-08-22 05:19:35 PDT
Created attachment 209351 [details]
Archive of layout-test-results from webkit-ews-10 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-10  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.4
Comment 14 Arpita Bahuguna 2013-08-22 06:15:09 PDT
Created attachment 209357 [details]
Patch
Comment 15 Arpita Bahuguna 2013-08-22 06:15:37 PDT
Comment on attachment 209357 [details]
Patch

Patch with rebaselines for the qt port.
Comment 16 Build Bot 2013-08-22 07:23:09 PDT
Comment on attachment 209357 [details]
Patch

Attachment 209357 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/1545133

New failing tests:
editing/deleting/delete-br-005.html
editing/deleting/delete-br-006.html
editing/deleting/delete-br-004.html
Comment 17 Build Bot 2013-08-22 07:23:12 PDT
Created attachment 209364 [details]
Archive of layout-test-results from webkit-ews-06 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-06  Port: mac-mountainlion  Platform: Mac OS X 10.8.4
Comment 18 Build Bot 2013-08-22 08:23:02 PDT
Comment on attachment 209357 [details]
Patch

Attachment 209357 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/1380576

New failing tests:
editing/deleting/delete-br-005.html
editing/deleting/delete-br-006.html
editing/deleting/delete-br-004.html
Comment 19 Build Bot 2013-08-22 08:23:05 PDT
Created attachment 209370 [details]
Archive of layout-test-results from webkit-ews-08 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-08  Port: mac-mountainlion  Platform: Mac OS X 10.8.4
Comment 20 Build Bot 2013-08-22 13:59:25 PDT
Comment on attachment 209357 [details]
Patch

Attachment 209357 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/1528339

New failing tests:
editing/deleting/delete-br-005.html
editing/deleting/delete-br-006.html
editing/deleting/delete-br-004.html
Comment 21 Build Bot 2013-08-22 13:59:27 PDT
Created attachment 209393 [details]
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-12  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.4
Comment 22 Arpita Bahuguna 2013-08-26 05:41:49 PDT
Patch Landed: http://trac.webkit.org/changeset/154479