Bug 32233 - REGRESSION: Increasing indent deletes text.
Summary: REGRESSION: Increasing indent deletes text.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Enrica Casucci
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2009-12-07 11:38 PST by Michael Thomas
Modified: 2009-12-07 17:32 PST (History)
7 users (show)

See Also:


Attachments
Patch (6.05 KB, patch)
2009-12-07 16:28 PST, Enrica Casucci
no flags Details | Formatted Diff | Diff
Patch2 (6.05 KB, patch)
2009-12-07 16:40 PST, Enrica Casucci
no flags Details | Formatted Diff | Diff
Patch3 (6.04 KB, patch)
2009-12-07 17:07 PST, Enrica Casucci
no flags Details | Formatted Diff | Diff
Patch4 (6.05 KB, patch)
2009-12-07 17:18 PST, Enrica Casucci
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Thomas 2009-12-07 11:38:37 PST
Steps to Reproduce:

1. Go to midas demo: http://www.mozilla.org/editor/midasdemo/
2. Enter the following HTML:

<ul><li><b>foo</b>bar</li></ul>

3. Place your cursor before 'foobar'.
4. Press the 'indent' button.

Actual Result:

Line is indent, unbold test ('bar') is deleted.

Expected Result:

No text is deleted.
Comment 1 Michael Thomas 2009-12-07 11:47:24 PST
Found in latest version of Chrome on LInux. Reproduces in WebKit nightly. Does not reproduce in Sarari 4.0.4 (5531.21.10).
Comment 2 Enrica Casucci 2009-12-07 12:19:14 PST
I'm working on a fix.
Comment 3 Enrica Casucci 2009-12-07 16:28:57 PST
Created attachment 44445 [details]
Patch
Comment 4 WebKit Review Bot 2009-12-07 16:32:48 PST
Attachment 44445 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebCore/editing/CompositeEditCommand.cpp:774:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
WebCore/editing/CompositeEditCommand.cpp:774:  Use 0 instead of NULL.  [readability/null] [5]
Total errors found: 2
Comment 5 Enrica Casucci 2009-12-07 16:40:21 PST
Created attachment 44446 [details]
Patch2

Fixed to make review bot happy.
Comment 6 WebKit Review Bot 2009-12-07 16:43:16 PST
style-queue ran check-webkit-style on attachment 44446 [details] without any errors.
Comment 7 Darin Adler 2009-12-07 16:57:56 PST
Comment on attachment 44446 [details]
Patch2

> +        for (Node* n = start.node()->traverseNextSibling(); n; n = n->nextSibling()) {

What is the rationale for using traverseNextSibling here. Do we really want the parent's next sibling? This seems like it could easily walk entirely out of the part of the subtree we are trying to work on.

> +                lastNode = topNode.get()->firstChild();

No get() needed here.
Comment 8 Enrica Casucci 2009-12-07 17:04:47 PST
(In reply to comment #7)
> (From update of attachment 44446 [details])
> > +        for (Node* n = start.node()->traverseNextSibling(); n; n = n->nextSibling()) {
> 
> What is the rationale for using traverseNextSibling here. Do we really want the
> parent's next sibling? This seems like it could easily walk entirely out of the
> part of the subtree we are trying to work on.
This is exactly the bug I had.
Imagine this markup
DIV
   SPAN
        #text1
   SPAN
        #text2
When trying to clone this paragraph, the old code was looking for the sibling of #text1 which is NULL and  the following SPAN was lost.
We had a test case that was covering various inlne combinations (execCommand/indent-paragraphs.html) but did not cover this one that I've now added with the patch.
Let me know if I'm missing something here.
> 
> > +                lastNode = topNode.get()->firstChild();
> 
> No get() needed here.
Fixed.
Comment 9 Enrica Casucci 2009-12-07 17:07:24 PST
Created attachment 44449 [details]
Patch3
Comment 10 WebKit Review Bot 2009-12-07 17:09:02 PST
style-queue ran check-webkit-style on attachment 44449 [details] without any errors.
Comment 11 Darin Adler 2009-12-07 17:09:50 PST
(In reply to comment #8)
> Let me know if I'm missing something here.

Well, traverseNextSibling, if not passed an argument to limit how far it can iterate, can walk all the way out of a content editable area. Is there some guarantee that won't happen here?
Comment 12 Enrica Casucci 2009-12-07 17:14:28 PST
(In reply to comment #11)
> (In reply to comment #8)
> > Let me know if I'm missing something here.
> 
> Well, traverseNextSibling, if not passed an argument to limit how far it can
> iterate, can walk all the way out of a content editable area. Is there some
> guarantee that won't happen here?

Probably not. I can call it passing outerNode to make sure. I think that would work.
Comment 13 Enrica Casucci 2009-12-07 17:18:53 PST
Created attachment 44450 [details]
Patch4

Limiting traverseNextSibling to outerNode.
Comment 14 WebKit Review Bot 2009-12-07 17:19:29 PST
style-queue ran check-webkit-style on attachment 44450 [details] without any errors.
Comment 15 Darin Adler 2009-12-07 17:22:09 PST
Comment on attachment 44450 [details]
Patch4

> +    if (start.node() != end.node() && !start.node()->isDescendantOf(end.node())) {

Such things would be so much easier to read if we had the flavor of isDescendantOf that includes the node itself.

r=me
Comment 16 Enrica Casucci 2009-12-07 17:32:19 PST
Committed revision 51819.