LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Nov 2006 03:32:31 +0000 (03:32 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Nov 2006 03:32:31 +0000 (03:32 +0000)
        Reviewed by harrison

        * editing/execCommand/4641880-1-expected.checksum: Added.
        * editing/execCommand/4641880-1-expected.png: Added.
        * editing/execCommand/4641880-1-expected.txt: Added.
        * editing/execCommand/4641880-1.html: Added.
        * editing/execCommand/4641880-2-expected.checksum: Added.
        * editing/execCommand/4641880-2-expected.png: Added.
        * editing/execCommand/4641880-2-expected.txt: Added.
        * editing/execCommand/4641880-2.html: Added.

WebCore:

        Reviewed by harrison

        <rdar://problem/4641880>
        Setting bullets to existing text grabs subsequent paragraph

        When a selection ends at the start of a paragraph, we rarely paint
        the selection gap before that paragraph, because there often is no gap.
        In a case like this, it's not obvious to the user that the selection
        ends "inside" that paragraph, so it would be confusing if
        InsertUn{Ordered}List and Indent/Outdent operated on that paragraph.

        * editing/FormatBlockCommand.cpp:
        (WebCore::FormatBlockCommand::doApply): Moved the check for editability of
        the selection to a more appropriate place.  Change the endingSelection
        if it ends at the start of a paragraph.
        * editing/IndentOutdentCommand.cpp:
        (WebCore::IndentOutdentCommand::doApply): Ditto.
        * editing/InsertListCommand.cpp:
        (WebCore::InsertListCommand::doApply): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17638 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/execCommand/4641880-1-expected.checksum [new file with mode: 0644]
LayoutTests/editing/execCommand/4641880-1-expected.png [new file with mode: 0644]
LayoutTests/editing/execCommand/4641880-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/4641880-1.html [new file with mode: 0644]
LayoutTests/editing/execCommand/4641880-2-expected.checksum [new file with mode: 0644]
LayoutTests/editing/execCommand/4641880-2-expected.png [new file with mode: 0644]
LayoutTests/editing/execCommand/4641880-2-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/4641880-2.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/FormatBlockCommand.cpp
WebCore/editing/IndentOutdentCommand.cpp
WebCore/editing/InsertListCommand.cpp

index 1f248f3b559936d4d3658e7112221a958fd5a91b..c3ca669ad7b59e9bc637268f17433044b5562e3f 100644 (file)
@@ -1,3 +1,16 @@
+2006-11-06  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by harrison
+
+        * editing/execCommand/4641880-1-expected.checksum: Added.
+        * editing/execCommand/4641880-1-expected.png: Added.
+        * editing/execCommand/4641880-1-expected.txt: Added.
+        * editing/execCommand/4641880-1.html: Added.
+        * editing/execCommand/4641880-2-expected.checksum: Added.
+        * editing/execCommand/4641880-2-expected.png: Added.
+        * editing/execCommand/4641880-2-expected.txt: Added.
+        * editing/execCommand/4641880-2.html: Added.
+
 2006-11-06  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Mitz.
diff --git a/LayoutTests/editing/execCommand/4641880-1-expected.checksum b/LayoutTests/editing/execCommand/4641880-1-expected.checksum
new file mode 100644 (file)
index 0000000..7157fd7
--- /dev/null
@@ -0,0 +1 @@
+81cc1c09ad880deb44d5418f74d134ac
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/4641880-1-expected.png b/LayoutTests/editing/execCommand/4641880-1-expected.png
new file mode 100644 (file)
index 0000000..8ccd9ef
Binary files /dev/null and b/LayoutTests/editing/execCommand/4641880-1-expected.png differ
diff --git a/LayoutTests/editing/execCommand/4641880-1-expected.txt b/LayoutTests/editing/execCommand/4641880-1-expected.txt
new file mode 100644 (file)
index 0000000..7c634b5
--- /dev/null
@@ -0,0 +1,22 @@
+layer at (0,0) size 800x600
+  RenderView 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 {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 756x36
+          text run at (0,0) width 511: "This tests InsertUnorderedList on a selection that ends at the start of a paragraph. "
+          text run at (511,0) width 245: "Since we don't paint the gap before the"
+          text run at (0,18) width 756: "paragraph for most selections like this, we don't perform InsertUnorderedList on the paragraph that the selection ends in."
+      RenderBlock {DIV} at (0,52) size 784x52
+        RenderBlock {UL} at (0,0) size 784x18
+          RenderListItem {LI} at (40,0) size 744x18
+            RenderListMarker at (-17,0) size 7x18
+            RenderText {#text} at (0,0) size 213x18
+              text run at (0,0) width 213: "This paragraph should be in a list."
+        RenderBlock (anonymous) at (0,34) size 784x18
+          RenderText {#text} at (0,0) size 237x18
+            text run at (0,0) width 237: "This paragraph should not be in a list."
+          RenderBR {BR} at (237,14) size 0x0
+selection start: position 0 of child 0 {#text} of child 0 {LI} of child 0 {UL} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
+selection end:   position 35 of child 0 {#text} of child 0 {LI} of child 0 {UL} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/execCommand/4641880-1.html b/LayoutTests/editing/execCommand/4641880-1.html
new file mode 100644 (file)
index 0000000..35208cf
--- /dev/null
@@ -0,0 +1,16 @@
+<p>This tests InsertUnorderedList on a selection that ends at the start of a paragraph.  Since we don't paint the gap before the paragraph for most selections like this, we don't perform InsertUnorderedList on the paragraph that the selection ends in.</p>
+<div id="div" contenteditable="true">
+This paragraph should be in a list.<br>
+This paragraph should not be in a list.</br>
+</div>
+
+<script>
+if (window.layoutTestController)
+    window.layoutTestController.dumpEditingCallBacks();
+
+var div = document.getElementById("div");
+var sel = window.getSelection();
+sel.setPosition(div, 0);
+sel.modify("extend", "forward", "line");
+document.execCommand("InsertUnorderedList");
+</script>
diff --git a/LayoutTests/editing/execCommand/4641880-2-expected.checksum b/LayoutTests/editing/execCommand/4641880-2-expected.checksum
new file mode 100644 (file)
index 0000000..95ea46a
--- /dev/null
@@ -0,0 +1 @@
+ef9c9a6f84c9ab09b2a939fba1bb0b95
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/4641880-2-expected.png b/LayoutTests/editing/execCommand/4641880-2-expected.png
new file mode 100644 (file)
index 0000000..f8c551f
Binary files /dev/null and b/LayoutTests/editing/execCommand/4641880-2-expected.png differ
diff --git a/LayoutTests/editing/execCommand/4641880-2-expected.txt b/LayoutTests/editing/execCommand/4641880-2-expected.txt
new file mode 100644 (file)
index 0000000..20175bf
--- /dev/null
@@ -0,0 +1,20 @@
+layer at (0,0) size 800x600
+  RenderView 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 {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 758x36
+          text run at (0,0) width 424: "This tests Indent on a selection that ends at the start of a paragraph. "
+          text run at (424,0) width 334: "Since we don't paint the gap before the paragraph for"
+          text run at (0,18) width 580: "most selections like this, we don't perform Indent on the paragraph that the selection ends in."
+      RenderBlock {DIV} at (0,52) size 784x36
+        RenderBlock {BLOCKQUOTE} at (40,0) size 744x18
+          RenderText {#text} at (0,0) size 222x18
+            text run at (0,0) width 222: "This paragraph should be indented."
+        RenderBlock (anonymous) at (0,18) size 784x18
+          RenderText {#text} at (0,0) size 246x18
+            text run at (0,0) width 246: "This paragraph should not be indented."
+          RenderBR {BR} at (246,14) size 0x0
+selection start: position 0 of child 0 {#text} of child 0 {BLOCKQUOTE} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
+selection end:   position 0 of child 1 {#text} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/execCommand/4641880-2.html b/LayoutTests/editing/execCommand/4641880-2.html
new file mode 100644 (file)
index 0000000..f883e0d
--- /dev/null
@@ -0,0 +1,16 @@
+<p>This tests Indent on a selection that ends at the start of a paragraph.  Since we don't paint the gap before the paragraph for most selections like this, we don't perform Indent on the paragraph that the selection ends in.</p>
+<div id="div" contenteditable="true">
+This paragraph should be indented.<br>
+This paragraph should not be indented.</br>
+</div>
+
+<script>
+if (window.layoutTestController)
+    window.layoutTestController.dumpEditingCallBacks();
+    
+var div = document.getElementById("div");
+var sel = window.getSelection();
+sel.setPosition(div, 0);
+sel.modify("extend", "forward", "line");
+document.execCommand("Indent");
+</script>
index 2e5da94947acc82b5476a6f79cc042486543c7db..b7e3e5556456f8175a756f60f325bd015a1cbab0 100644 (file)
@@ -1,3 +1,25 @@
+2006-11-06  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by harrison
+        
+        <rdar://problem/4641880>
+        Setting bullets to existing text grabs subsequent paragraph
+        
+        When a selection ends at the start of a paragraph, we rarely paint 
+        the selection gap before that paragraph, because there often is no gap.  
+        In a case like this, it's not obvious to the user that the selection 
+        ends "inside" that paragraph, so it would be confusing if 
+        InsertUn{Ordered}List and Indent/Outdent operated on that paragraph.
+        
+        * editing/FormatBlockCommand.cpp:
+        (WebCore::FormatBlockCommand::doApply): Moved the check for editability of
+        the selection to a more appropriate place.  Change the endingSelection
+        if it ends at the start of a paragraph.
+        * editing/IndentOutdentCommand.cpp:
+        (WebCore::IndentOutdentCommand::doApply): Ditto.
+        * editing/InsertListCommand.cpp:
+        (WebCore::InsertListCommand::doApply): Ditto.
+
 2006-11-06  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Sarge
index d5a2bdba20df118c3c069dff5de1848fb98005ae..3e52340c914491c5bf65d3199f49511952af406a 100644 (file)
@@ -72,12 +72,25 @@ void FormatBlockCommand::doApply()
 {
     if (endingSelection().isNone())
         return;
-
-    if (endingSelection().isRange() && modifyRange())
-        return;
     
     if (!endingSelection().rootEditableElement())
         return;
+
+    VisiblePosition visibleEnd = endingSelection().visibleEnd();
+    VisiblePosition visibleStart = endingSelection().visibleStart();
+    // When a selection ends at the start of a paragraph, we rarely paint 
+    // the selection gap before that paragraph, because there often is no gap.  
+    // In a case like this, it's not obvious to the user that the selection 
+    // ends "inside" that paragraph, so it would be confusing if FormatBlock
+    // operated on that paragraph.
+    // FIXME: We paint the gap before some paragraphs that are indented with left 
+    // margin/padding, but not others.  We should make the gap painting more consistent and 
+    // then use a left margin/padding rule here.
+    if (visibleEnd != visibleStart && isStartOfParagraph(visibleEnd))
+        setEndingSelection(Selection(visibleStart, visibleEnd.previous(true)));
+
+    if (endingSelection().isRange() && modifyRange())
+        return;
     
     String localName, prefix;
     if (!Document::parseQualifiedName(m_tagName, prefix, localName))
index d68ef598f02fe89b1215b0e3710eb1c47062f593..55ee1c9d7c750485e4f6fe871b2e188163de4b9e 100644 (file)
@@ -260,6 +260,19 @@ void IndentOutdentCommand::doApply()
 
     if (!endingSelection().rootEditableElement())
         return;
+        
+    VisiblePosition visibleEnd = endingSelection().visibleEnd();
+    VisiblePosition visibleStart = endingSelection().visibleStart();
+    // When a selection ends at the start of a paragraph, we rarely paint 
+    // the selection gap before that paragraph, because there often is no gap.  
+    // In a case like this, it's not obvious to the user that the selection 
+    // ends "inside" that paragraph, so it would be confusing if Indent/Outdent 
+    // operated on that paragraph.
+    // FIXME: We paint the gap before some paragraphs that are indented with left 
+    // margin/padding, but not others.  We should make the gap painting more consistent and 
+    // then use a left margin/padding rule here.
+    if (visibleEnd != visibleStart && isStartOfParagraph(visibleEnd))
+        setEndingSelection(Selection(visibleStart, visibleEnd.previous(true)));
 
     if (m_typeOfAction == Indent)
         indentRegion();
index b62452619dacf02577619a365090f84895296e65..585a4961824f05bcb0fd1fc0e3586d0af8442e18 100644 (file)
@@ -87,13 +87,26 @@ void InsertListCommand::doApply()
 {
     if (endingSelection().isNone())
         return;
-
-    if (endingSelection().isRange() && modifyRange())
-        return;
     
     if (!endingSelection().rootEditableElement())
         return;
     
+    VisiblePosition visibleEnd = endingSelection().visibleEnd();
+    VisiblePosition visibleStart = endingSelection().visibleStart();
+    // When a selection ends at the start of a paragraph, we rarely paint 
+    // the selection gap before that paragraph, because there often is no gap.  
+    // In a case like this, it's not obvious to the user that the selection 
+    // ends "inside" that paragraph, so it would be confusing if InsertUn{Ordered}List 
+    // operated on that paragraph.
+    // FIXME: We paint the gap before some paragraphs that are indented with left 
+    // margin/padding, but not others.  We should make the gap painting more consistent and 
+    // then use a left margin/padding rule here.
+    if (visibleEnd != visibleStart && isStartOfParagraph(visibleEnd))
+        setEndingSelection(Selection(visibleStart, visibleEnd.previous(true)));
+
+    if (endingSelection().isRange() && modifyRange())
+        return;
+    
     Node* selectionNode = endingSelection().start().node();
     const QualifiedName listTag = (m_type == OrderedList) ? olTag : ulTag;
     Node* listChildNode = enclosingListChild(selectionNode);