LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Oct 2006 21:29:49 +0000 (21:29 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Oct 2006 21:29:49 +0000 (21:29 +0000)
        Reviewed by john

        <http://bugs.webkit.org/show_bug.cgi?id=11333>
        Writely Editor: After inserting a HR element, pressing return key creates a copy of this HR element in the document

        * editing/inserting/insert-br-009-expected.checksum: Added.
        * editing/inserting/insert-br-009-expected.png: Added.
        * editing/inserting/insert-br-009-expected.txt: Added.
        * editing/inserting/insert-br-009.html: Added.
        * editing/inserting/insert-paragraph-01-expected.checksum: Added.
        * editing/inserting/insert-paragraph-01-expected.png: Added.
        * editing/inserting/insert-paragraph-01-expected.txt: Added.
        * editing/inserting/insert-paragraph-01.html: Added.
        * editing/inserting/insert-paragraph-02-expected.checksum: Added.
        * editing/inserting/insert-paragraph-02-expected.png: Added.
        * editing/inserting/insert-paragraph-02-expected.txt: Added.
        * editing/inserting/insert-paragraph-02.html: Added.
        * editing/inserting/insert-paragraph-03-expected.checksum: Added.
        * editing/inserting/insert-paragraph-03-expected.png: Added.
        * editing/inserting/insert-paragraph-03-expected.txt: Added.
        * editing/inserting/insert-paragraph-03.html: Added.
        * editing/inserting/insert-paragraph-04-expected.checksum: Added.
        * editing/inserting/insert-paragraph-04-expected.png: Added.
        * editing/inserting/insert-paragraph-04-expected.txt: Added.
        * editing/inserting/insert-paragraph-04.html: Added.

WebCore:

        Reviewed by john

        <http://bugs.webkit.org/show_bug.cgi?id=11333>
        Writely Editor: After inserting a HR element, pressing return key creates a copy of this HR element in the document

        Added special cases in InsertLineBreakCommand for inserting before
        and after tables and horizontal rules.  Also, perform InsertLineBreak
        instead of InsertParagraphSeparator at these positions.

        * editing/InsertLineBreakCommand.cpp:
        (WebCore::InsertLineBreakCommand::doApply):  Use the canonical form
        of the caret position when we check for the new special cases because
        we know that we canonicalize VisiblePositions to those positions.
        Added code to handle inserting before/after tables and horizontal rules.
        Fixed a bug when inserting at the end of a block (it checked for a collapse
        of the inserted br by looking for the absence of a br, but the line break
        might have been a '\n' in white-space:pre text).  Removed unused LOGs.
        * editing/InsertParagraphSeparatorCommand.cpp:
        (WebCore::InsertParagraphSeparatorCommand::doApply): Perform an
        InsertLineBreakCommand when before/after a table or a horizontal rule
        so that we don't have to maintain two pieces of special case code.
        Migrated to enclosingBlock.
        * editing/htmlediting.cpp: Added a FIXME.
        * editing/visible_units.cpp:
        (WebCore::startOfParagraph): Added a workaround for 8622.

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

27 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/inserting/insert-br-009-expected.checksum [new file with mode: 0644]
LayoutTests/editing/inserting/insert-br-009-expected.png [new file with mode: 0644]
LayoutTests/editing/inserting/insert-br-009-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-br-009.html [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-01-expected.checksum [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-01-expected.png [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-01-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-01.html [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-02-expected.checksum [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-02-expected.png [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-02-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-02.html [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-03-expected.checksum [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-03-expected.png [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-03-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-03.html [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-04-expected.checksum [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-04-expected.png [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-04-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/insert-paragraph-04.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/InsertLineBreakCommand.cpp
WebCore/editing/InsertParagraphSeparatorCommand.cpp
WebCore/editing/ReplaceSelectionCommand.cpp
WebCore/editing/htmlediting.cpp
WebCore/editing/visible_units.cpp

index 4bab21e..aad420e 100644 (file)
@@ -1,3 +1,31 @@
+2006-10-20  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by john
+
+        <http://bugs.webkit.org/show_bug.cgi?id=11333>
+        Writely Editor: After inserting a HR element, pressing return key creates a copy of this HR element in the document
+
+        * editing/inserting/insert-br-009-expected.checksum: Added.
+        * editing/inserting/insert-br-009-expected.png: Added.
+        * editing/inserting/insert-br-009-expected.txt: Added.
+        * editing/inserting/insert-br-009.html: Added.
+        * editing/inserting/insert-paragraph-01-expected.checksum: Added.
+        * editing/inserting/insert-paragraph-01-expected.png: Added.
+        * editing/inserting/insert-paragraph-01-expected.txt: Added.
+        * editing/inserting/insert-paragraph-01.html: Added.
+        * editing/inserting/insert-paragraph-02-expected.checksum: Added.
+        * editing/inserting/insert-paragraph-02-expected.png: Added.
+        * editing/inserting/insert-paragraph-02-expected.txt: Added.
+        * editing/inserting/insert-paragraph-02.html: Added.
+        * editing/inserting/insert-paragraph-03-expected.checksum: Added.
+        * editing/inserting/insert-paragraph-03-expected.png: Added.
+        * editing/inserting/insert-paragraph-03-expected.txt: Added.
+        * editing/inserting/insert-paragraph-03.html: Added.
+        * editing/inserting/insert-paragraph-04-expected.checksum: Added.
+        * editing/inserting/insert-paragraph-04-expected.png: Added.
+        * editing/inserting/insert-paragraph-04-expected.txt: Added.
+        * editing/inserting/insert-paragraph-04.html: Added.
+
 2006-10-20  Geoffrey Garen  <ggaren@apple.com>
 
         RS by Beth "pants on fire" Dakin.
diff --git a/LayoutTests/editing/inserting/insert-br-009-expected.checksum b/LayoutTests/editing/inserting/insert-br-009-expected.checksum
new file mode 100644 (file)
index 0000000..52f8170
--- /dev/null
@@ -0,0 +1 @@
+06a9921d2f31aeb62fcb75ec8d218dc5
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/insert-br-009-expected.png b/LayoutTests/editing/inserting/insert-br-009-expected.png
new file mode 100644 (file)
index 0000000..3a495c1
Binary files /dev/null and b/LayoutTests/editing/inserting/insert-br-009-expected.png differ
diff --git a/LayoutTests/editing/inserting/insert-br-009-expected.txt b/LayoutTests/editing/inserting/insert-br-009-expected.txt
new file mode 100644 (file)
index 0000000..767b169
--- /dev/null
@@ -0,0 +1,26 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+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 774x36
+          text run at (0,0) width 316: "This tests for a bug in InsertLineBreakCommand. "
+          text run at (316,0) width 458: "Only one line break should be inserted and the caret should end up at the"
+          text run at (0,18) width 194: "end of the bordered div below."
+      RenderBlock {DIV} at (0,52) size 784x56 [border: (1px solid #000000)]
+        RenderText {#text} at (1,1) size 80x18
+          text run at (1,1) width 80: "Hello world."
+          text run at (81,1) width 0: " "
+        RenderText {#text} at (1,19) size 0x18
+          text run at (1,19) width 0: " "
+        RenderText {#text} at (1,37) size 0x18
+          text run at (1,37) width 0: " "
+caret: position 0 of child 2 {#text} of child 1 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/inserting/insert-br-009.html b/LayoutTests/editing/inserting/insert-br-009.html
new file mode 100644 (file)
index 0000000..fe80b8c
--- /dev/null
@@ -0,0 +1,11 @@
+<p>This tests for a bug in InsertLineBreakCommand.  Only one line break should be inserted and the caret should end up at the end of the bordered div below.</p><div contenteditable="true" id="div" style="white-space:pre; border: 1px solid black;">Hello world.
+
+</div>
+
+<script>
+var sel = window.getSelection();
+var div = document.getElementById("div");
+sel.setPosition(div, 0);
+sel.modify("move", "forward", "line");
+document.execCommand("InsertLineBreak");
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/insert-paragraph-01-expected.checksum b/LayoutTests/editing/inserting/insert-paragraph-01-expected.checksum
new file mode 100644 (file)
index 0000000..fe563ff
--- /dev/null
@@ -0,0 +1 @@
+8502a7a6c36819e5a467687b118771b0
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/insert-paragraph-01-expected.png b/LayoutTests/editing/inserting/insert-paragraph-01-expected.png
new file mode 100644 (file)
index 0000000..598cadc
Binary files /dev/null and b/LayoutTests/editing/inserting/insert-paragraph-01-expected.png differ
diff --git a/LayoutTests/editing/inserting/insert-paragraph-01-expected.txt b/LayoutTests/editing/inserting/insert-paragraph-01-expected.txt
new file mode 100644 (file)
index 0000000..b201f6a
--- /dev/null
@@ -0,0 +1,25 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of TABLE > DIV > BODY > HTML > #document to 0 of TABLE > DIV > BODY > HTML > #document toDOMRange:range from 0 of TABLE > DIV > BODY > HTML > #document to 0 of TABLE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+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 769x36
+          text run at (0,0) width 353: "This tests inserting a paragraph separator before a table. "
+          text run at (353,0) width 416: "There should be an empty paragraph before the table and the caret"
+          text run at (0,18) width 192: "should be just before the table."
+      RenderBlock {DIV} at (0,52) size 784x46
+        RenderBlock (anonymous) at (0,0) size 784x18
+          RenderBR {BR} at (0,0) size 0x18
+        RenderTable {TABLE} at (0,18) size 31x28 [border: (1px outset #808080)]
+          RenderTableSection {TBODY} at (1,1) size 29x26
+            RenderTableRow {TR} at (0,2) size 29x22
+              RenderTableCell {TD} at (2,2) size 25x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 21x18
+                  text run at (2,2) width 21: "foo"
+caret: position 0 of child 1 {TABLE} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/inserting/insert-paragraph-01.html b/LayoutTests/editing/inserting/insert-paragraph-01.html
new file mode 100644 (file)
index 0000000..4be7bea
--- /dev/null
@@ -0,0 +1,9 @@
+<p>This tests inserting a paragraph separator before a table.  There should be an empty paragraph before the table and the caret should be just before the table.</p>
+<div contenteditable="true" id="div"><table border="1"><tr><td>foo</td></tr></table></div>
+
+<script>
+var sel = window.getSelection();
+var div = document.getElementById("div");
+sel.setPosition(div, 0);
+document.execCommand("InsertParagraph");
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/insert-paragraph-02-expected.checksum b/LayoutTests/editing/inserting/insert-paragraph-02-expected.checksum
new file mode 100644 (file)
index 0000000..b7dd7ee
--- /dev/null
@@ -0,0 +1 @@
+ccd32bf82878146c98da8dd3c9bdf729
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/insert-paragraph-02-expected.png b/LayoutTests/editing/inserting/insert-paragraph-02-expected.png
new file mode 100644 (file)
index 0000000..ddc29a9
Binary files /dev/null and b/LayoutTests/editing/inserting/insert-paragraph-02-expected.png differ
diff --git a/LayoutTests/editing/inserting/insert-paragraph-02-expected.txt b/LayoutTests/editing/inserting/insert-paragraph-02-expected.txt
new file mode 100644 (file)
index 0000000..e1ca664
--- /dev/null
@@ -0,0 +1,33 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of TABLE > DIV > BODY > HTML > #document to 1 of TABLE > DIV > BODY > HTML > #document toDOMRange:range from 1 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+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 770x36
+          text run at (0,0) width 341: "This tests inserting a paragraph separator after a table. "
+          text run at (341,0) width 429: "There should be an empty paragraph between the table and 'bar' and"
+          text run at (0,18) width 271: "the caret should be in the empty paragraph."
+      RenderBlock {DIV} at (0,52) size 784x64
+        RenderTable {TABLE} at (0,0) size 31x28 [border: (1px outset #808080)]
+          RenderTableSection {TBODY} at (1,1) size 29x26
+            RenderTableRow {TR} at (0,2) size 29x22
+              RenderTableCell {TD} at (2,2) size 25x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 21x18
+                  text run at (2,2) width 21: "foo"
+        RenderBlock (anonymous) at (0,28) size 784x36
+          RenderBR {BR} at (0,0) size 0x18
+          RenderText {#text} at (0,18) size 20x18
+            text run at (0,18) width 20: "bar"
+caret: position 0 of child 1 {BR} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/inserting/insert-paragraph-02.html b/LayoutTests/editing/inserting/insert-paragraph-02.html
new file mode 100644 (file)
index 0000000..6af62c4
--- /dev/null
@@ -0,0 +1,14 @@
+<p>This tests inserting a paragraph separator after a table.  There should be an empty paragraph between the table and 'bar' and the caret should be in the empty paragraph.</p>
+<div contenteditable="true" id="div"><table border="1"><tr><td>foo</td></tr></table>bar</div>
+
+<script>
+var sel = window.getSelection();
+var div = document.getElementById("div");
+sel.setPosition(div, 0);
+sel.modify("move", "forward", "character");
+sel.modify("move", "forward", "character");
+sel.modify("move", "forward", "character");
+sel.modify("move", "forward", "character");
+sel.modify("move", "forward", "character");
+document.execCommand("InsertParagraph");
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/insert-paragraph-03-expected.checksum b/LayoutTests/editing/inserting/insert-paragraph-03-expected.checksum
new file mode 100644 (file)
index 0000000..0089b67
--- /dev/null
@@ -0,0 +1 @@
+d7fa2730b0a757db2ee6a7f6f444a5ef
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/insert-paragraph-03-expected.png b/LayoutTests/editing/inserting/insert-paragraph-03-expected.png
new file mode 100644 (file)
index 0000000..575901e
Binary files /dev/null and b/LayoutTests/editing/inserting/insert-paragraph-03-expected.png differ
diff --git a/LayoutTests/editing/inserting/insert-paragraph-03-expected.txt b/LayoutTests/editing/inserting/insert-paragraph-03-expected.txt
new file mode 100644 (file)
index 0000000..8c3bc31
--- /dev/null
@@ -0,0 +1,28 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document toDOMRange:range from 3 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+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 760x36
+          text run at (0,0) width 414: "This tests inserting a paragraph separator before a horizontal rule. "
+          text run at (414,0) width 346: "You should see 'foo', empty paragraph, horizontal rule,"
+          text run at (0,18) width 371: "'bar', and the caret should be just before the horizontal rule."
+      RenderBlock {DIV} at (0,52) size 784x72
+        RenderBlock (anonymous) at (0,0) size 784x36
+          RenderText {#text} at (0,0) size 21x18
+            text run at (0,0) width 21: "foo"
+          RenderBR {BR} at (21,14) size 0x0
+          RenderBR {BR} at (0,18) size 0x18
+        RenderBlock {HR} at (0,44) size 784x2 [border: (1px inset #000000)]
+        RenderBlock (anonymous) at (0,54) size 784x18
+          RenderText {#text} at (0,0) size 20x18
+            text run at (0,0) width 20: "bar"
+caret: position 0 of child 3 {HR} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/inserting/insert-paragraph-03.html b/LayoutTests/editing/inserting/insert-paragraph-03.html
new file mode 100644 (file)
index 0000000..052175d
--- /dev/null
@@ -0,0 +1,11 @@
+<p>This tests inserting a paragraph separator before a horizontal rule.  You should see 'foo', empty paragraph, horizontal rule, 'bar', and the caret should be just before the horizontal rule.</p>
+<div contenteditable="true" id="div">foo<hr>bar</div>
+
+<script>
+var sel = window.getSelection();
+var div = document.getElementById("div");
+sel.setPosition(div, 0);
+sel.modify("move", "forward", "word");
+sel.modify("move", "forward", "character");
+document.execCommand("InsertParagraph");
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/insert-paragraph-04-expected.checksum b/LayoutTests/editing/inserting/insert-paragraph-04-expected.checksum
new file mode 100644 (file)
index 0000000..7729a11
--- /dev/null
@@ -0,0 +1 @@
+6693c962d1dfd64fdf8e7cf90a1b353e
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/insert-paragraph-04-expected.png b/LayoutTests/editing/inserting/insert-paragraph-04-expected.png
new file mode 100644 (file)
index 0000000..6d67784
Binary files /dev/null and b/LayoutTests/editing/inserting/insert-paragraph-04-expected.png differ
diff --git a/LayoutTests/editing/inserting/insert-paragraph-04-expected.txt b/LayoutTests/editing/inserting/insert-paragraph-04-expected.txt
new file mode 100644 (file)
index 0000000..38c513b
--- /dev/null
@@ -0,0 +1,40 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > B > BODY > HTML > #document to 3 of DIV > B > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of DIV > B > BODY > HTML > #document to 2 of DIV > B > BODY > HTML > #document toDOMRange:range from 2 of DIV > B > BODY > HTML > #document to 2 of DIV > B > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+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 784x54
+        RenderText {#text} at (0,0) size 782x36
+          text run at (0,0) width 402: "This tests inserting a paragraph separator after a horizontal rule. "
+          text run at (402,0) width 380: "You should see 'foo', empty paragraph, horizontal rule, 'bar',"
+          text run at (0,18) width 329: "and the caret should be just after the horizontal rule. "
+        RenderInline {B} at (0,0) size 777x36
+          RenderText {#text} at (329,18) size 777x36
+            text run at (329,18) width 168: "This demonstrates 8345. "
+            text run at (497,18) width 280: "The caret after a horizontal rule is drawn"
+            text run at (0,36) width 381: "in the same location as the caret before a horizontal rule."
+      RenderBlock (anonymous) at (0,70) size 784x0
+        RenderInline {B} at (0,0) size 0x0
+          RenderText {#text} at (0,0) size 0x0
+      RenderBlock (anonymous) at (0,70) size 784x72
+        RenderBlock {DIV} at (0,0) size 784x72
+          RenderBlock (anonymous) at (0,0) size 784x18
+            RenderText {#text} at (0,0) size 21x18
+              text run at (0,0) width 21: "foo"
+          RenderBlock {HR} at (0,26) size 784x2 [border: (1px inset #000000)]
+          RenderBlock (anonymous) at (0,36) size 784x36
+            RenderBR {BR} at (0,0) size 0x18
+            RenderText {#text} at (0,18) size 24x18
+              text run at (0,18) width 24: "bar"
+      RenderBlock (anonymous) at (0,142) size 784x0
+        RenderInline {B} at (0,0) size 0x0
+caret: position 0 of child 2 {BR} of child 1 {DIV} of child 1 {B} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/inserting/insert-paragraph-04.html b/LayoutTests/editing/inserting/insert-paragraph-04.html
new file mode 100644 (file)
index 0000000..8f2fcff
--- /dev/null
@@ -0,0 +1,12 @@
+<p>This tests inserting a paragraph separator after a horizontal rule.  You should see 'foo', empty paragraph, horizontal rule, 'bar', and the caret should be just after the horizontal rule. <b>This demonstrates 8345.  The caret after a horizontal rule is drawn in the same location as the caret before a horizontal rule.</p>
+<div contenteditable="true" id="div">foo<hr>bar</div>
+
+<script>
+var sel = window.getSelection();
+var div = document.getElementById("div");
+sel.setPosition(div, 0);
+sel.modify("move", "forward", "word");
+sel.modify("move", "forward", "character");
+sel.modify("move", "forward", "character");
+document.execCommand("InsertParagraph");
+</script>
\ No newline at end of file
index 525dadd..4016f2e 100644 (file)
@@ -1,3 +1,31 @@
+2006-10-23  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by john
+        
+        <http://bugs.webkit.org/show_bug.cgi?id=11333>
+        Writely Editor: After inserting a HR element, pressing return key creates a copy of this HR element in the document
+        
+        Added special cases in InsertLineBreakCommand for inserting before
+        and after tables and horizontal rules.  Also, perform InsertLineBreak
+        instead of InsertParagraphSeparator at these positions.
+
+        * editing/InsertLineBreakCommand.cpp:
+        (WebCore::InsertLineBreakCommand::doApply):  Use the canonical form
+        of the caret position when we check for the new special cases because 
+        we know that we canonicalize VisiblePositions to those positions.
+        Added code to handle inserting before/after tables and horizontal rules.  
+        Fixed a bug when inserting at the end of a block (it checked for a collapse
+        of the inserted br by looking for the absence of a br, but the line break 
+        might have been a '\n' in white-space:pre text).  Removed unused LOGs.
+        * editing/InsertParagraphSeparatorCommand.cpp:
+        (WebCore::InsertParagraphSeparatorCommand::doApply): Perform an 
+        InsertLineBreakCommand when before/after a table or a horizontal rule
+        so that we don't have to maintain two pieces of special case code.
+        Migrated to enclosingBlock.
+        * editing/htmlediting.cpp: Added a FIXME.
+        * editing/visible_units.cpp:
+        (WebCore::startOfParagraph): Added a workaround for 8622.
+        
 2006-10-23  Adam Roben  <aroben@apple.com>
 
         Reviewed by Adele.
index 544f7ed..ab51f5e 100644 (file)
@@ -30,7 +30,6 @@
 #include "Document.h"
 #include "Element.h"
 #include "Frame.h"
-#include "Logging.h"
 #include "Text.h"
 #include "VisiblePosition.h"
 #include "Range.h"
@@ -86,6 +85,7 @@ void InsertLineBreakCommand::doApply()
         return;
 
     Position pos(selection.start().upstream());
+    Position canonicalPos(VisiblePosition(pos).deepEquivalent());
 
     pos = positionAvoidingSpecialElementBoundary(pos);
 
@@ -106,28 +106,37 @@ void InsertLineBreakCommand::doApply()
     if (isTabSpan) {
         insertNodeAtTabSpanPosition(nodeToInsert.get(), pos);
         setEndingSelection(Selection(Position(nodeToInsert->traverseNextNode(), 0), DOWNSTREAM));
-    } else if (isEndOfBlock(VisiblePosition(pos, selection.affinity()))) {
-        Node* block = pos.node()->enclosingBlockFlowElement();
-        
-        // Insert an extra break element so that there will be a blank line after the last
-        // inserted line break. In HTML, a line break at the end of a block ends the last
-        // line in the block, while in editable text, a line break at the end of block
-        // creates a last blank line. We need an extra break element to get HTML to act
-        // the way editable text would.
-        bool haveBreak = pos.downstream().node()->hasTagName(brTag) && pos.downstream().offset() == 0;
+    } else if (canonicalPos.node()->renderer() && canonicalPos.node()->renderer()->isTable() ||
+               canonicalPos.node()->hasTagName(hrTag)) {
+        if (canonicalPos.offset() == 0) {
+            insertNodeBefore(nodeToInsert.get(), canonicalPos.node());
+            // Insert an extra br if the just inserted one collapsed.
+            if (!isStartOfParagraph(VisiblePosition(Position(nodeToInsert.get(), 0))))
+                insertNodeBefore(createBreakElement(document()).get(), nodeToInsert.get());
+            // Leave the selection where it was, just before the table/horizontal rule.
+        } else if (canonicalPos.offset() == maxDeepOffset(canonicalPos.node())) {
+            insertNodeAfter(nodeToInsert.get(), canonicalPos.node());
+            setEndingSelection(Selection(VisiblePosition(Position(nodeToInsert.get(), 0))));
+        } else
+            // There aren't any VisiblePositions like this yet.
+            ASSERT_NOT_REACHED();
+    // FIXME: The following doesn't handle positions at the ends of anonymous blocks, and
+    // those cases are buggy.
+    } else if (isEndOfBlock(selection.visibleStart())) {
         insertNodeAt(nodeToInsert.get(), pos.node(), pos.offset());
-        if (!haveBreak)
-            insertNodeAfter(createBreakElement(document()).get(), nodeToInsert.get());
-            
-        setEndingSelection(Selection(Position(block, maxDeepOffset(block)), DOWNSTREAM));
+        VisiblePosition endingPosition(endOfBlock(VisiblePosition(pos)));
+        
+        // Insert an extra br if the inserted one collapsed.
+        if (!isStartOfParagraph(endingPosition))
+            insertNodeBefore(createBreakElement(document()).get(), nodeToInsert.get());
+        
+        setEndingSelection(Selection(endingPosition));
     } else if (pos.offset() <= pos.node()->caretMinOffset()) {
-        LOG(Editing, "input newline case 2");
         // Insert node before downstream position, and place caret there as well. 
         Position endingPosition = pos.downstream();
         insertNodeBeforePosition(nodeToInsert.get(), endingPosition);
         setEndingSelection(Selection(endingPosition, DOWNSTREAM));
     } else if (pos.offset() >= pos.node()->caretMaxOffset()) {
-        LOG(Editing, "input newline case 3");
         // Insert BR after this node. Place caret in the position that is downstream
         // of the current position, reckoned before inserting the BR in between.
         Position endingPosition = pos.downstream();
@@ -135,7 +144,6 @@ void InsertLineBreakCommand::doApply()
         setEndingSelection(Selection(endingPosition, DOWNSTREAM));
     } else {
         // Split a text node
-        LOG(Editing, "input newline case 4");
         ASSERT(pos.node()->isTextNode());
         
         // Do the split
index 230b056..10f74c1 100644 (file)
@@ -97,8 +97,12 @@ void InsertParagraphSeparatorCommand::doApply()
     
     // FIXME: Turn into an InsertLineBreak in other cases where we don't want to do the splitting/cloning that
     // InsertParagraphSeparator does.
-    Node* block = pos.node()->enclosingBlockFlowElement();
-    if (!block || !block->parentNode() || block->renderer() && block->renderer()->isTableCell()) {
+    Node* block = enclosingBlock(pos.node());
+    Position canonicalPos = VisiblePosition(pos).deepEquivalent();
+    if (!block || !block->parentNode() || 
+        block->renderer() && block->renderer()->isTableCell() ||
+        canonicalPos.node()->renderer() && canonicalPos.node()->renderer()->isTable() ||
+        canonicalPos.node()->hasTagName(hrTag)) {
         applyCommandToComposite(new InsertLineBreakCommand(document()));
         return;
     }
index 851ca7f..e1b6226 100644 (file)
@@ -537,7 +537,7 @@ void ReplaceSelectionCommand::doApply()
         return;
     
     // 1) Insert the content.
-    // 2) Restore the styles of inserted nodes (since styles were removed during the test insertion).
+    // 2) Remove redundant styles and style tags, this inner <b> for example: <b>foo <b>bar</b> baz</b>.
     // 3) Merge the start of the added content with the content before the position being pasted into.
     // 4) Do one of the following: a) expand the last br if the fragment ends with one and it collapsed,
     // b) merge the last paragraph of the incoming fragment with the paragraph that contained the 
index d102314..efac6df 100644 (file)
@@ -271,6 +271,9 @@ bool isBlock(Node* node)
 }
 
 // FIXME: Deploy this in all of the places where enclosingBlockFlow/enclosingBlockFlowOrTableElement are used.
+// FIXME: Pass a position to this function.  The enclosing block of [table, x] for example, should be the 
+// block that contains the table and not the table, and this function should be the only one responsible for 
+// knowing about these kinds of special cases.
 Node* enclosingBlock(Node* node)
 {
     if (isBlock(node))
index b69f03c..ab33ca0 100644 (file)
@@ -563,6 +563,13 @@ VisiblePosition nextSentencePosition(const VisiblePosition &c)
 VisiblePosition startOfParagraph(const VisiblePosition &c)
 {
     Position p = c.deepEquivalent();
+    // FIXME: Use the leftmost candidate.  Canonicalization should give us the leftmost candidate,
+    // but it sometimes doesn't because of 8622.
+    if (p.upstream().inRenderedContent()) {
+        p = p.upstream();
+        ASSERT(VisiblePosition(p) == c);
+    }
+
     Node *startNode = p.node();
 
     if (!startNode)