LayoutTests:
authorlweintraub <lweintraub@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Jul 2006 18:28:28 +0000 (18:28 +0000)
committerlweintraub <lweintraub@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Jul 2006 18:28:28 +0000 (18:28 +0000)
        Reviewed by justin

        <rdar://problem/4622763> Deleting from beginning of paragraph following a table deletes rather than selects the table

        * editing/deleting/delete-block-table-expected.checksum: Added.
        * editing/deleting/delete-block-table-expected.png: Added.
        * editing/deleting/delete-block-table-expected.txt: Added.
        * editing/deleting/delete-block-table.html: Added.
        * editing/deleting/delete-hr-expected.checksum: Added.
        * editing/deleting/delete-hr-expected.png: Added.
        * editing/deleting/delete-hr-expected.txt: Added.
        * editing/deleting/delete-hr.html: Added.
        * editing/deleting/delete-to-select-table-expected.png:
        * editing/execCommand/insertHorizontalRule-expected.txt:
        * fast/lists/markers-in-selection-expected.txt:

WebCore:

        Reviewed by justin

        <rdar://problem/4622763> Deleting from beginning of paragraph following a table deletes rather than selects the table

        * editing/DeleteSelectionCommand.cpp:
        (WebCore::DeleteSelectionCommand::initializeStartEnd): Added selection expansion for HRs.
        (WebCore::DeleteSelectionCommand::initializePositionData): Now uses enclosingBlockFlowOrTableElement
        instead of enclosingBlockFlowElement.
        (WebCore::DeleteSelectionCommand::removeNode): Use to identify that we need a placeholder
        when the start or end block is removed.
        (WebCore::DeleteSelectionCommand::handleGeneralDelete): Added check for canHaveChildrenForEditing
        to keep things like HRs from being given children.
        (WebCore::DeleteSelectionCommand::doApply): Switched to use member variable for needPlaceholder.
        * editing/DeleteSelectionCommand.h: Made needPlaceholder a member variable.
        * editing/TypingCommand.cpp:
        (WebCore::TypingCommand::deleteKeyPressed): Fixed selection bug for tables and open typing commands.
        (WebCore::TypingCommand::forwardDeleteKeyPressed): Ditto.
        * editing/htmlediting.cpp:
        (WebCore::editingIgnoresContent): Added check for HRs, since it's not considered a widget.
        * editing/visible_units.cpp:
        (WebCore::startOfParagraph): Fix for HRs and tables.
        (WebCore::endOfParagraph): Ditto.

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

19 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/deleting/delete-block-table-expected.checksum [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-table-expected.png [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-table-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-block-table.html [new file with mode: 0644]
LayoutTests/editing/deleting/delete-hr-expected.checksum [new file with mode: 0644]
LayoutTests/editing/deleting/delete-hr-expected.png [new file with mode: 0644]
LayoutTests/editing/deleting/delete-hr-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-hr.html [new file with mode: 0644]
LayoutTests/editing/deleting/delete-to-select-table-expected.png
LayoutTests/editing/execCommand/insertHorizontalRule-expected.txt
LayoutTests/fast/lists/markers-in-selection-expected.txt
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/editing/DeleteSelectionCommand.cpp
WebCore/editing/DeleteSelectionCommand.h
WebCore/editing/TypingCommand.cpp
WebCore/editing/htmlediting.cpp
WebCore/editing/visible_units.cpp

index f24eee4025f9816ccb0dddd7faf0a84d99dfa496..675e0410a59ec13be62ce50ef206bd68ee8ee972 100644 (file)
@@ -1,3 +1,21 @@
+2006-07-13  Levi Weintraub  <lweintraub@apple.com>
+
+        Reviewed by justin
+
+        <rdar://problem/4622763> Deleting from beginning of paragraph following a table deletes rather than selects the table
+
+        * editing/deleting/delete-block-table-expected.checksum: Added.
+        * editing/deleting/delete-block-table-expected.png: Added.
+        * editing/deleting/delete-block-table-expected.txt: Added.
+        * editing/deleting/delete-block-table.html: Added.
+        * editing/deleting/delete-hr-expected.checksum: Added.
+        * editing/deleting/delete-hr-expected.png: Added.
+        * editing/deleting/delete-hr-expected.txt: Added.
+        * editing/deleting/delete-hr.html: Added.
+        * editing/deleting/delete-to-select-table-expected.png:
+        * editing/execCommand/insertHorizontalRule-expected.txt:
+        * fast/lists/markers-in-selection-expected.txt:
+
 2006-07-12  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Reviewed by Adele.
diff --git a/LayoutTests/editing/deleting/delete-block-table-expected.checksum b/LayoutTests/editing/deleting/delete-block-table-expected.checksum
new file mode 100644 (file)
index 0000000..a15a3d6
--- /dev/null
@@ -0,0 +1 @@
+2fd485862090aecc8236f85c20c323fa
\ No newline at end of file
diff --git a/LayoutTests/editing/deleting/delete-block-table-expected.png b/LayoutTests/editing/deleting/delete-block-table-expected.png
new file mode 100644 (file)
index 0000000..b8d0c51
Binary files /dev/null and b/LayoutTests/editing/deleting/delete-block-table-expected.png differ
diff --git a/LayoutTests/editing/deleting/delete-block-table-expected.txt b/LayoutTests/editing/deleting/delete-block-table-expected.txt
new file mode 100644 (file)
index 0000000..0499436
--- /dev/null
@@ -0,0 +1,31 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 7 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 0 of SPAN > DIV > BODY > HTML > #document to 0 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of SPAN > DIV > BODY > HTML > #document to 0 of SPAN > DIV > BODY > HTML > #document toDOMRange:range from 0 of TABLE > DIV > BODY > HTML > #document to 0 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of TABLE > DIV > BODY > HTML > #document to 0 of SPAN > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of SPAN > DIV > BODY > HTML > #document to 0 of SPAN > 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 {DIV} at (0,0) size 784x36
+        RenderBlock {DIV} at (0,0) size 784x18
+          RenderText {#text} at (0,0) size 43x18
+            text run at (0,0) width 43: "Before"
+        RenderBlock (anonymous) at (0,18) size 784x18
+          RenderInline {SPAN} at (0,0) size 21x18
+            RenderText {#text} at (0,0) size 21x18
+              text run at (0,0) width 21: "fter"
+          RenderText {#text} at (0,0) size 0x0
+caret: position 0 of child 0 {#text} of child 3 {SPAN} of child 0 {DIV} of child 2 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/deleting/delete-block-table.html b/LayoutTests/editing/deleting/delete-block-table.html
new file mode 100644 (file)
index 0000000..719359a
--- /dev/null
@@ -0,0 +1,37 @@
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+<script>
+function editingTest() {
+    var selection = window.getSelection();
+    var s = document.getElementById("start");
+    selection.setPosition(s, 0);
+    execMoveSelectionForwardByCharacterCommand();
+    for (i = 0; i < 3; i++) {
+        deleteCommand();
+    }
+}
+</script>
+<div contenteditable="true" id="test">
+<div>Before</div>
+  <table style="border:3px solid #aaa;">
+    <tr>
+      <td>
+        Foo
+      </td>
+      <td>
+        baz
+      </td>
+    </tr>
+    <tr>
+      <td>
+        bar
+      </td>
+      <td>
+        buffalo
+      </td>
+    </tr>
+  </table>
+<span id="start">after</span>
+</div>
+<script>
+runEditingTest();
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/deleting/delete-hr-expected.checksum b/LayoutTests/editing/deleting/delete-hr-expected.checksum
new file mode 100644 (file)
index 0000000..a15a3d6
--- /dev/null
@@ -0,0 +1 @@
+2fd485862090aecc8236f85c20c323fa
\ No newline at end of file
diff --git a/LayoutTests/editing/deleting/delete-hr-expected.png b/LayoutTests/editing/deleting/delete-hr-expected.png
new file mode 100644 (file)
index 0000000..b8d0c51
Binary files /dev/null and b/LayoutTests/editing/deleting/delete-hr-expected.png differ
diff --git a/LayoutTests/editing/deleting/delete-hr-expected.txt b/LayoutTests/editing/deleting/delete-hr-expected.txt
new file mode 100644 (file)
index 0000000..00446fb
--- /dev/null
@@ -0,0 +1,27 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 7 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 0 of SPAN > DIV > BODY > HTML > #document to 0 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 4 of DIV > BODY > HTML > #document to 0 of SPAN > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of SPAN > DIV > BODY > HTML > #document to 0 of SPAN > DIV > BODY > HTML > #document toDOMRange:range from 0 of SPAN > DIV > BODY > HTML > #document to 0 of SPAN > 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 {DIV} at (0,0) size 784x36
+        RenderBlock {DIV} at (0,0) size 784x18
+          RenderText {#text} at (0,0) size 43x18
+            text run at (0,0) width 43: "Before"
+        RenderBlock (anonymous) at (0,18) size 784x18
+          RenderInline {SPAN} at (0,0) size 21x18
+            RenderText {#text} at (0,0) size 21x18
+              text run at (0,0) width 21: "fter"
+          RenderText {#text} at (0,0) size 0x0
+caret: position 0 of child 0 {#text} of child 3 {SPAN} of child 0 {DIV} of child 2 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/deleting/delete-hr.html b/LayoutTests/editing/deleting/delete-hr.html
new file mode 100644 (file)
index 0000000..e154493
--- /dev/null
@@ -0,0 +1,20 @@
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+<script>
+function editingTest() {
+    var selection = window.getSelection();
+    var s = document.getElementById("start");
+    selection.setPosition(s, 0);
+    execMoveSelectionForwardByCharacterCommand();
+    for (i = 0; i < 2; i++) {
+        deleteCommand();
+    }
+}
+</script>
+<div contenteditable="true" id="test">
+<div>Before</div>
+  <hr>
+<span id="start">after</span>
+</div>
+<script>
+runEditingTest();
+</script>
\ No newline at end of file
index acba6084ab9c34e403d07b6f477b48b03d9781fb..16c762c5b44b59205af645a4bf496f3e721a3120 100644 (file)
Binary files a/LayoutTests/editing/deleting/delete-to-select-table-expected.png and b/LayoutTests/editing/deleting/delete-to-select-table-expected.png differ
index 26dd9b3b5da37e2a7e20229ceb707f67281fa326..08c6a66bfa8483c7e7f2933e9e7dade332c7b443 100644 (file)
@@ -4,7 +4,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of HR > DIV > BODY > HTML > #document to 0 of HR > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 2 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 EDITING DELEGATE: shouldEndEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
@@ -15,7 +15,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of HR > DIV > BODY > HTML > #document to 0 of HR > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 2 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 layer at (0,0) size 800x600
index ef99537c41cc71210f45dfad0abc9d4790084926..6d3c5f8087408120430fd6def044769f8e999dcf 100644 (file)
@@ -68,4 +68,4 @@ layer at (0,0) size 800x600
         RenderText {#text} at (0,0) size 0x0
         RenderText {#text} at (0,0) size 0x0
 selection start: position 0 of child 7 {HR} of child 1 {BODY} of child 0 {HTML} of document
-selection end:   position 0 of child 21 {HR} of child 1 {BODY} of child 0 {HTML} of document
+selection end:   position 1 of child 21 {HR} of child 1 {BODY} of child 0 {HTML} of document
index 778e8e6a36d92f4d43f906ebf83cb52c0c51966c..3dafb019d08a32ea8d5b73c0bb84234b36c384af 100644 (file)
@@ -1,3 +1,28 @@
+2006-07-12  Levi Weintraub  <lweintraub@apple.com>
+
+        Reviewed by justin
+
+        <rdar://problem/4622763> Deleting from beginning of paragraph following a table deletes rather than selects the table
+
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::initializeStartEnd): Added selection expansion for HRs.
+        (WebCore::DeleteSelectionCommand::initializePositionData): Now uses enclosingBlockFlowOrTableElement
+        instead of enclosingBlockFlowElement.
+        (WebCore::DeleteSelectionCommand::removeNode): Use to identify that we need a placeholder
+        when the start or end block is removed.
+        (WebCore::DeleteSelectionCommand::handleGeneralDelete): Added check for canHaveChildrenForEditing
+        to keep things like HRs from being given children.
+        (WebCore::DeleteSelectionCommand::doApply): Switched to use member variable for needPlaceholder.
+        * editing/DeleteSelectionCommand.h: Made needPlaceholder a member variable.
+        * editing/TypingCommand.cpp:
+        (WebCore::TypingCommand::deleteKeyPressed): Fixed selection bug for tables and open typing commands.
+        (WebCore::TypingCommand::forwardDeleteKeyPressed): Ditto.
+        * editing/htmlediting.cpp:
+        (WebCore::editingIgnoresContent): Added check for HRs, since it's not considered a widget.
+        * editing/visible_units.cpp:
+        (WebCore::startOfParagraph): Fix for HRs and tables.
+        (WebCore::endOfParagraph): Ditto.
+
 2006-07-13  Alexey Proskuryakov  <ap@nypop.com>
 
         Reviewed by Darin.
index 0ee439bce98c81c572bc239fa4441cf5b7e20059..2e82e1a11d6dcbe13cf1369dd910b79d0393d3ba 100644 (file)
                FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
 /* End PBXBuildFile section */
 
-/* Begin PBXBuildStyle section */
-               D098D47C0A65E2F400D1917D /* Development */ = {
-                       isa = PBXBuildStyle;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = NO;
-                       };
-                       name = Development;
-               };
-               D098D47D0A65E2F400D1917D /* Deployment */ = {
-                       isa = PBXBuildStyle;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = YES;
-                       };
-                       name = Deployment;
-               };
-/* End PBXBuildStyle section */
-
-/* Begin PBXBuildStyle section */
-               D098D45B0A65D5A600D1917D /* Development */ = {
-                       isa = PBXBuildStyle;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = NO;
-                       };
-                       name = Development;
-               };
-               D098D45C0A65D5A600D1917D /* Deployment */ = {
-                       isa = PBXBuildStyle;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = YES;
-                       };
-                       name = Deployment;
-               };
-/* End PBXBuildStyle section */
-
 /* Begin PBXContainerItemProxy section */
                DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
-                       buildSettings = {
-                       };
-                       buildStyles = (
-                               D098D47C0A65E2F400D1917D /* Development */,
-                               D098D47D0A65E2F400D1917D /* Deployment */,
-                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index 3d9ece0d01fa0932229134ca8270bfe29ce38c13..852a5638fc9c880a563c60d71d8cba18740151c4 100644 (file)
@@ -77,6 +77,13 @@ void DeleteSelectionCommand::initializeStartEnd()
     Position start = m_selectionToDelete.start();
     Position end = m_selectionToDelete.end();
  
+    // For HR's, we'll get a position at (HR,1) when hitting delete from the beginning of the previous line, or (HR,0) when forward deleting,
+    // but in these cases, we want to delete it, so manually expand the selection
+    if (start.node()->hasTagName(hrTag))
+        start = Position(start.node(), 0);
+    else if (end.node()->hasTagName(hrTag))
+        end = Position(end.node(), 1);
+    
     while (1) {
         startSpecialContainer = 0;
         endSpecialContainer = 0;
@@ -156,8 +163,8 @@ void DeleteSelectionCommand::initializePositionData()
     //
     // Handle setting start and end blocks and the start node.
     //
-    m_startBlock = m_downstreamStart.node()->enclosingBlockFlowElement();
-    m_endBlock = m_upstreamEnd.node()->enclosingBlockFlowElement();
+    m_startBlock = m_downstreamStart.node()->enclosingBlockFlowOrTableElement();
+    m_endBlock = m_upstreamEnd.node()->enclosingBlockFlowOrTableElement();
 }
 
 void DeleteSelectionCommand::saveTypingStyleState()
@@ -227,6 +234,11 @@ void DeleteSelectionCommand::removeNode(Node *node)
         return;
     }
     
+    if (node == m_startBlock && !isEndOfBlock(VisiblePosition(m_startBlock.get(), 0, DOWNSTREAM).previous()))
+        m_needPlaceholder = true;
+    else if (node == m_endBlock && !isStartOfBlock(VisiblePosition(m_endBlock.get(), maxDeepOffset(m_endBlock.get()), DOWNSTREAM).next()))
+        m_needPlaceholder = true;
+    
     // FIXME: Update the endpoints of the range being deleted.
     updatePositionForNodeRemoval(node, m_endingPosition);
     updatePositionForNodeRemoval(node, m_leadingWhitespace);
@@ -260,9 +272,9 @@ void DeleteSelectionCommand::handleGeneralDelete()
 {
     int startOffset = m_upstreamStart.offset();
     Node* startNode = m_upstreamStart.node();
-
-    // Never remove the start block.
-    if (startNode == m_startBlock && startOffset == 0) {
+    
+    // Never remove the start block unless it's a table, in which case we won't merge content in.
+    if (startNode == m_startBlock && startOffset == 0 && canHaveChildrenForEditing(startNode) && !startNode->hasTagName(tableTag)) {
         startOffset = 0;
         startNode = startNode->traverseNextNode();
     }
@@ -512,9 +524,9 @@ void DeleteSelectionCommand::doApply()
     EAffinity affinity = m_selectionToDelete.affinity();
     
     Position downstreamEnd = m_selectionToDelete.end().downstream();
-    bool needPlaceholder = isStartOfParagraph(m_selectionToDelete.visibleStart()) &&
-                           isEndOfParagraph(m_selectionToDelete.visibleEnd()) &&
-                           !(downstreamEnd.node()->hasTagName(brTag) && downstreamEnd.offset() == 0);
+    m_needPlaceholder = isStartOfParagraph(m_selectionToDelete.visibleStart()) &&
+                        isEndOfParagraph(m_selectionToDelete.visibleEnd()) &&
+                        !(downstreamEnd.node()->hasTagName(brTag) && downstreamEnd.offset() == 0);
     
     // set up our state
     initializePositionData();
@@ -546,10 +558,11 @@ void DeleteSelectionCommand::doApply()
     handleGeneralDelete();
     
     fixupWhitespace();
+
+    RefPtr<Node> placeholder = m_needPlaceholder ? createBreakElement(document()) : 0;
     
     mergeParagraphs();
     
-    RefPtr<Node> placeholder = needPlaceholder ? createBreakElement(document()) : 0;
     if (placeholder)
         insertNodeAt(placeholder.get(), m_endingPosition.node(), m_endingPosition.offset());
 
index fa12823eb46f784ceeee52d221fa11befd1119ae..9b91af4f702573263114f1dbca766555fe65198c 100644 (file)
@@ -59,6 +59,7 @@ private:
     bool m_hasSelectionToDelete;
     bool m_smartDelete;
     bool m_mergeBlocksAfterDelete;
+    bool m_needPlaceholder;
 
     // This data is transient and should be cleared at the end of the doApply function.
     Selection m_selectionToDelete;
index 789628cbf32d82da5af8b0b446858ca02849fe4c..0d2c05e6c4a1ccb2a8c03a18e56a49be6f7ff4e5 100644 (file)
@@ -335,9 +335,13 @@ void TypingCommand::deleteKeyPressed()
             SelectionController sc = SelectionController(endingSelection().start(), endingSelection().end(), SEL_DEFAULT_AFFINITY);
             sc.modify(SelectionController::EXTEND, SelectionController::BACKWARD, m_granularity);
             Position upstreamStart = endingSelection().start().upstream();
+            VisiblePosition visibleStart = endingSelection().visibleStart();
+            if (visibleStart == startOfParagraph(visibleStart))
+                upstreamStart = visibleStart.previous(true).deepEquivalent().upstream();
             // When deleting tables: Select the table first, then perform the deletion
             if (upstreamStart.node()->renderer() && upstreamStart.node()->renderer()->isTable() && upstreamStart.offset() == maxDeepOffset(upstreamStart.node())) {
-                setEndingSelection(Selection(Position(upstreamStart.node(), 0), upstreamStart, DOWNSTREAM));
+                setEndingSelection(Selection(Position(upstreamStart.node(), 0), endingSelection().start(), DOWNSTREAM));
+                typingAddedToOpenCommand();
                 return;
             }
             selectionToDelete = sc.selection();
@@ -370,9 +374,13 @@ void TypingCommand::forwardDeleteKeyPressed()
             SelectionController sc = SelectionController(endingSelection().start(), endingSelection().end(), SEL_DEFAULT_AFFINITY);
             sc.modify(SelectionController::EXTEND, SelectionController::FORWARD, m_granularity);
             Position downstreamEnd = endingSelection().end().downstream();
+            VisiblePosition visibleEnd = endingSelection().visibleEnd();
+            if (visibleEnd == endOfParagraph(visibleEnd))
+                downstreamEnd = visibleEnd.next(true).deepEquivalent().downstream();
             // When deleting tables: Select the table first, then perform the deletion
             if (downstreamEnd.node()->renderer() && downstreamEnd.node()->renderer()->isTable() && downstreamEnd.offset() == 0) {
-                setEndingSelection(Selection(downstreamEnd, Position(downstreamEnd.node(), maxDeepOffset(downstreamEnd.node())), DOWNSTREAM));
+                setEndingSelection(Selection(endingSelection().end(), Position(downstreamEnd.node(), maxDeepOffset(downstreamEnd.node())), DOWNSTREAM));
+                typingAddedToOpenCommand();
                 return;
             }
             selectionToDelete = sc.selection();
index 661b77f7dd7876793e9683bf91a089851ebd9652..58e131474f9d61dcbcafbf9b69d18706825daeec 100644 (file)
@@ -60,12 +60,13 @@ bool editingIgnoresContent(const Node *node)
         return true;
     
     if (node->renderer())
-        return node->renderer()->isWidget() || node->renderer()->isImage() || node->renderer()->isFormElement();
+        return node->renderer()->isWidget() || node->renderer()->isImage() || node->renderer()->isHR();
 
     return node->hasTagName(appletTag) ||
            node->hasTagName(embedTag) ||
            node->hasTagName(iframeTag) ||
            node->hasTagName(imgTag) ||
+           node->hasTagName(hrTag) ||
            static_cast<const HTMLElement *>(node)->isGenericFormElement();
 }
 
index 8e9bb994765ccc6fc8a76f88c650bde62ad891bb..2888e950572332e138354dbe2014ee311ccd0fbf 100644 (file)
@@ -544,8 +544,15 @@ VisiblePosition startOfParagraph(const VisiblePosition &c)
 {
     Position p = c.deepEquivalent();
     Node *startNode = p.node();
+
     if (!startNode)
         return VisiblePosition();
+    
+    if (startNode->renderer()
+        && ((startNode->renderer()->isTable() && !startNode->renderer()->isInline())
+            || startNode->renderer()->isHR())
+        && p.offset() == maxDeepOffset(startNode))
+        return VisiblePosition(Position(startNode, 0));
 
     Node *startBlock = startNode->enclosingBlockFlowElement();
 
@@ -594,12 +601,19 @@ VisiblePosition startOfParagraph(const VisiblePosition &c)
 }
 
 VisiblePosition endOfParagraph(const VisiblePosition &c)
-{
+{    
     if (c.isNull())
         return VisiblePosition();
 
     Position p = c.deepEquivalent();
-    Node *startNode = p.node();
+    Node* startNode = p.node();
+
+    if (startNode->renderer()
+        && ((startNode->renderer()->isTable() && !startNode->renderer()->isInline())
+            || startNode->renderer()->isHR())
+        && p.offset() == 0)
+        return VisiblePosition(Position(startNode, maxDeepOffset(startNode)));
+    
     Node *startBlock = startNode->enclosingBlockFlowElement();
     Node *stayInsideBlock = startBlock;