Reviewed by Darin.
authorharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Apr 2005 20:13:42 +0000 (20:13 +0000)
committerharrison <harrison@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Apr 2005 20:13:42 +0000 (20:13 +0000)
        <rdar://problem/4083333> When deleting link at end of sentence, entire sentence gets deleted

        * khtml/editing/htmlediting.cpp:
        (khtml::DeleteSelectionCommand::initializePositionData):
        Work around bug #4103339 (whose real fix is somewhat risky), so this fix can get into a software update.

        (khtml::DeleteSelectionCommand::handleGeneralDelete):
        Add isAncestor check when comparing m_downstreamEnd.node() and m_startNode.

        * layout-tests/editing/deleting/delete-4083333-fix-expected.txt: Added.
        * layout-tests/editing/deleting/delete-4083333-fix.html: Added.

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

LayoutTests/editing/deleting/delete-4083333-fix-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/delete-4083333-fix.html [new file with mode: 0644]
WebCore/ChangeLog-2005-08-23
WebCore/khtml/editing/htmlediting.cpp

diff --git a/LayoutTests/editing/deleting/delete-4083333-fix-expected.txt b/LayoutTests/editing/deleting/delete-4083333-fix-expected.txt
new file mode 100644 (file)
index 0000000..fe17567
--- /dev/null
@@ -0,0 +1,14 @@
+layer at (0,0) size 800x600
+  RenderCanvas 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 784x56 [border: (2px solid #FF0000)]
+        RenderInline {SPAN} at (0,0) size 106x28
+          RenderText {TEXT} at (14,14) size 80x28
+            text run at (14,14) width 80: "this is a "
+          RenderInline {A} at (0,0) size 26x28 [color=#0000EE]
+            RenderText {TEXT} at (94,14) size 26x28
+              text run at (94,14) width 26: "lin"
+        RenderText {TEXT} at (0,0) size 0x0
+caret: position 3 of child 0 {TEXT} of child 1 {A} of child 1 {SPAN} of child 0 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/deleting/delete-4083333-fix.html b/LayoutTests/editing/deleting/delete-4083333-fix.html
new file mode 100644 (file)
index 0000000..b29b9f2
--- /dev/null
@@ -0,0 +1,34 @@
+<html> 
+<head>
+
+<style>
+.editing { 
+    border: 2px solid red; 
+    padding: 12px; 
+    font-size: 24px; 
+}
+</style>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+
+function editingTest() {
+       moveSelectionForwardByLineCommand();    
+    deleteCommand(); 
+}
+
+</script>
+
+<title>Editing Test</title> 
+</head> 
+<body>
+<div contenteditable id="root" class="editing">
+<span id="test">this is a <A href="www.apple.com">link</A></span>
+</div>
+
+<script>
+runEditingTest();
+</script>
+
+</body>
+</html>
index a3605f4ed8094c2a5167887c758d1f59a8be862f..2cd174968cbfd48ea2d36c3004aa154e3b90be2d 100644 (file)
@@ -1,3 +1,19 @@
+2005-04-29  David Harrison  <harrison@apple.com>
+
+        Reviewed by Darin.
+
+        <rdar://problem/4083333> When deleting link at end of sentence, entire sentence gets deleted
+        
+        * khtml/editing/htmlediting.cpp:
+        (khtml::DeleteSelectionCommand::initializePositionData):
+        Work around bug #4103339 (whose real fix is somewhat risky), so this fix can get into a software update.
+        
+        (khtml::DeleteSelectionCommand::handleGeneralDelete):
+        Add isAncestor check when comparing m_downstreamEnd.node() and m_startNode.
+
+        * layout-tests/editing/deleting/delete-4083333-fix-expected.txt: Added.
+        * layout-tests/editing/deleting/delete-4083333-fix.html: Added.
+
 2005-04-29  Darin Adler  <darin@apple.com>
 
         Reviewed by Dave Harrison.
index e5c1e0375fcbb82ca3f485b91f330bab0c7e07ea..c097d7d36961a9b5da5802eb53ac5bf5b5fcfdbf 100644 (file)
@@ -2618,7 +2618,10 @@ void DeleteSelectionCommand::initializePositionData()
     // Handle leading and trailing whitespace, as well as smart delete adjustments to the selection
     //
     m_leadingWhitespace = m_upstreamStart.leadingWhitespacePosition(m_selectionToDelete.startAffinity());
-    m_trailingWhitespace = m_downstreamEnd.trailingWhitespacePosition(VP_DEFAULT_AFFINITY);
+    // NOTE: Workaround for bug <rdar://problem/4103339> is to avoid calculating trailingWhitespacePosition
+    // if the m_downstreamEnd is at the end of a paragraph.
+    if (!isEndOfParagraph(VisiblePosition(m_downstreamEnd, VP_DEFAULT_AFFINITY)))
+        m_trailingWhitespace = m_downstreamEnd.trailingWhitespacePosition(VP_DEFAULT_AFFINITY);
 
     if (m_smartDelete) {
     
@@ -2815,6 +2818,7 @@ void DeleteSelectionCommand::handleGeneralDelete()
         startOffset = 0;
     }
 
+    // Done adjusting the start.  See if we're all done.
     if (!m_startNode)
         return;
 
@@ -2881,7 +2885,8 @@ void DeleteSelectionCommand::handleGeneralDelete()
             }
         }
 
-        if (m_downstreamEnd.node() != m_startNode && m_downstreamEnd.node()->inDocument() && m_downstreamEnd.offset() >= m_downstreamEnd.node()->caretMinOffset()) {
+        
+        if (m_downstreamEnd.node() != m_startNode && !m_upstreamStart.node()->isAncestor(m_downstreamEnd.node()) && m_downstreamEnd.node()->inDocument() && m_downstreamEnd.offset() >= m_downstreamEnd.node()->caretMinOffset()) {
             if (m_downstreamEnd.offset() >= maxDeepOffset(m_downstreamEnd.node())) {
                 // need to delete whole node
                 // we can get here if this is the last node in the block