[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

ojan at chromium.org ojan at chromium.org
Thu Apr 8 02:18:10 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 77dae9d94137deda9b63559ed2f00b7d3d968e89
Author: ojan at chromium.org <ojan at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Mar 9 23:41:38 2010 +0000

    2010-03-03  Ojan Vafai  <ojan at chromium.org>
    
            Reviewed by Adam Barth.
    
            undo after smartdelete should select the deleted space
            https://bugs.webkit.org/show_bug.cgi?id=35713
    
            * editing/undo/undo-smart-delete-reversed-selection-expected.txt: Added.
            * editing/undo/undo-smart-delete-reversed-selection.html: Added.
            * editing/undo/undo-smart-delete-word-expected.txt: Added.
            * editing/undo/undo-smart-delete-word.html: Added.
    2010-03-03  Ojan Vafai  <ojan at chromium.org>
    
            Reviewed by Adam Barth.
    
            undo after smartdelete should select the deleted space
            https://bugs.webkit.org/show_bug.cgi?id=35713
    
            TextEdit behavior is to select the deleted space after a smartdelete.
    
            Tests: editing/undo/undo-smart-delete-reversed-selection.html
                   editing/undo/undo-smart-delete-word.html
    
            * editing/DeleteSelectionCommand.cpp:
            (WebCore::DeleteSelectionCommand::setStartingSelectionOnSmartDelete):
            (WebCore::DeleteSelectionCommand::initializePositionData):
            * editing/DeleteSelectionCommand.h:
            * editing/VisibleSelection.cpp:
            (WebCore::VisibleSelection::setWithoutValidation):
            This assert looks bogus to me. undo-smart-delete-reversed-selection.html hits it
            but not as a result of the other changes in this patch. The granularity when
            deleting after making a wordgranularity selection is wordgranularity, not charactergranularity.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55752 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 374d593..072a084 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2010-03-03  Ojan Vafai  <ojan at chromium.org>
+
+        Reviewed by Adam Barth.
+
+        undo after smartdelete should select the deleted space
+        https://bugs.webkit.org/show_bug.cgi?id=35713
+
+        * editing/undo/undo-smart-delete-reversed-selection-expected.txt: Added.
+        * editing/undo/undo-smart-delete-reversed-selection.html: Added.
+        * editing/undo/undo-smart-delete-word-expected.txt: Added.
+        * editing/undo/undo-smart-delete-word.html: Added.
+
 2010-03-09  Anton Muhin  <antonm at chromium.org>
 
         Reviewed by Darin Fisher.
diff --git a/LayoutTests/editing/undo/undo-smart-delete-reversed-selection-expected.txt b/LayoutTests/editing/undo/undo-smart-delete-reversed-selection-expected.txt
new file mode 100644
index 0000000..0dc77db
--- /dev/null
+++ b/LayoutTests/editing/undo/undo-smart-delete-reversed-selection-expected.txt
@@ -0,0 +1,5 @@
+Tests: 
+Double-click the green "a" and drag backwards to select "bar baz" with word granularity. Delete, then undo the delete. The space that got smart deleted should now be selected and the anchor of the selection should be at the end of the selection.
+
+foo bar baz biz
+PASSED
diff --git a/LayoutTests/editing/undo/undo-smart-delete-reversed-selection.html b/LayoutTests/editing/undo/undo-smart-delete-reversed-selection.html
new file mode 100644
index 0000000..217bbfb
--- /dev/null
+++ b/LayoutTests/editing/undo/undo-smart-delete-reversed-selection.html
@@ -0,0 +1,70 @@
+<html>
+<head>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function getStringForNode(node) {
+    return node + "(" + node.data + ")";
+}
+
+function editingTest() {
+    var start = document.getElementById("start");
+    var x = start.offsetLeft + 5;
+    var middleY = start.offsetTop + start.offsetHeight / 2;
+    var endX = document.getElementById("end").offsetLeft;
+
+    eventSender.mouseMoveTo(x, middleY);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+    eventSender.mouseDown();
+
+    eventSender.mouseMoveTo(endX, middleY);
+    eventSender.mouseUp();
+
+    document.execCommand("Delete");
+    document.execCommand("Undo");
+    
+    var selection = window.getSelection();
+    if (selection.anchorNode != start.nextSibling ||
+        selection.anchorOffset != 1 ||
+        selection.focusNode != document.getElementById("root").firstChild ||
+        selection.focusOffset != 4) {
+        document.getElementById("result").innerHTML = "FAILED. Selection was " +
+          "anchorNode:" + getStringForNode(selection.anchorNode) +
+          " anchorOffset:" + selection.anchorOffset +
+          " focusNode:" + getStringForNode(selection.focusNode) +
+          " focusOffset:" + selection.focusOffset;
+    } else
+        document.getElementById("result").innerHTML = "PASSED";
+}
+
+</script>
+</head> 
+<body>
+
+<div class="explanation">
+<div class="scenario">
+Tests: 
+<br>
+Double-click the green "a" and drag backwards to select "bar baz" with word granularity. Delete, then undo the delete. The space that got smart deleted should now be selected and the anchor of the selection should be at the end of the selection.
+</div>
+</div>
+<br>
+<div contenteditable id="root">
+foo b<span id="end">a</span>r b<span id="start" style="color:green">a</span>z biz
+</div>
+
+<div id="result"></div>
+<script>
+layoutTestController.waitUntilDone();
+setTimeout(function() {
+    editingTest();
+    layoutTestController.notifyDone();
+}, 1000);
+</script>
+
+</body>
+</html>
diff --git a/LayoutTests/editing/undo/undo-smart-delete-word-expected.txt b/LayoutTests/editing/undo/undo-smart-delete-word-expected.txt
new file mode 100644
index 0000000..8b6a733
--- /dev/null
+++ b/LayoutTests/editing/undo/undo-smart-delete-word-expected.txt
@@ -0,0 +1,4 @@
+Tests: 
+Select a word via double-click. Delete. Then undo the delete. The space that got smart deleted should now be selected.
+foo bar baz
+PASSED
diff --git a/LayoutTests/editing/undo/undo-smart-delete-word.html b/LayoutTests/editing/undo/undo-smart-delete-word.html
new file mode 100644
index 0000000..1e2feb1
--- /dev/null
+++ b/LayoutTests/editing/undo/undo-smart-delete-word.html
@@ -0,0 +1,58 @@
+<html>
+<head>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function editingTest() {
+    var word = document.getElementById("word");
+    var x = word.offsetLeft;
+    var y = word.offsetTop;
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+
+    document.execCommand("Delete");
+    document.execCommand("Undo");
+    
+    var selection = window.getSelection();
+    if (selection.anchorNode != document.getElementById("root").firstChild ||
+        selection.anchorOffset != 4 ||
+        selection.focusNode != word.firstChild ||
+        selection.focusOffset != 3) {
+        document.getElementById("result").innerHTML = "FAILED";
+        console.log(selection.anchorNode);
+        console.log(selection.anchorOffset);
+        console.log(selection.focusNode);
+        console.log(selection.focusOffset);        
+    } else
+        document.getElementById("result").innerHTML = "PASSED";
+}
+
+</script>
+</head> 
+<body>
+
+<div class="explanation">
+<div class="scenario">
+Tests: 
+<br>
+Select a word via double-click. Delete. Then undo the delete. The space that got smart deleted should now be selected.
+</div>
+</div>
+
+<div contenteditable id="root">
+foo <span id="word">bar</span> baz
+</div>
+
+<div id="result"></div>
+<script>
+editingTest();
+</script>
+
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 98e4193..9e1f717 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-03-03  Ojan Vafai  <ojan at chromium.org>
+
+        Reviewed by Adam Barth.
+
+        undo after smartdelete should select the deleted space
+        https://bugs.webkit.org/show_bug.cgi?id=35713
+
+        TextEdit behavior is to select the deleted space after a smartdelete.
+
+        Tests: editing/undo/undo-smart-delete-reversed-selection.html
+               editing/undo/undo-smart-delete-word.html
+
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::setStartingSelectionOnSmartDelete):
+        (WebCore::DeleteSelectionCommand::initializePositionData):
+        * editing/DeleteSelectionCommand.h:
+        * editing/VisibleSelection.cpp:
+        (WebCore::VisibleSelection::setWithoutValidation):
+        This assert looks bogus to me. undo-smart-delete-reversed-selection.html hits it
+        but not as a result of the other changes in this patch. The granularity when
+        deleting after making a wordgranularity selection is wordgranularity, not charactergranularity.
+
 2010-03-09  Steve Falkenburg  <sfalken at apple.com>
 
         Rubber stamped by Adam Roben.
diff --git a/WebCore/editing/DeleteSelectionCommand.cpp b/WebCore/editing/DeleteSelectionCommand.cpp
index d3d9cc9..8027b14 100644
--- a/WebCore/editing/DeleteSelectionCommand.cpp
+++ b/WebCore/editing/DeleteSelectionCommand.cpp
@@ -161,6 +161,20 @@ void DeleteSelectionCommand::initializeStartEnd(Position& start, Position& end)
     }
 }
 
+void DeleteSelectionCommand::setStartingSelectionOnSmartDelete(Position& start, Position& end)
+{
+    VisiblePosition newBase;
+    VisiblePosition newExtent;
+    if (startingSelection().isBaseFirst()) {
+        newBase = start;
+        newExtent = end;
+    } else {
+        newBase = end;
+        newExtent = start;        
+    }
+    setStartingSelection(VisibleSelection(newBase, newExtent));            
+}
+    
 void DeleteSelectionCommand::initializePositionData()
 {
     Position start, end;
@@ -230,6 +244,8 @@ void DeleteSelectionCommand::initializePositionData()
             m_upstreamStart = pos.upstream();
             m_downstreamStart = pos.downstream();
             m_leadingWhitespace = m_upstreamStart.leadingWhitespacePosition(visiblePos.affinity());
+
+            setStartingSelectionOnSmartDelete(m_upstreamStart, m_upstreamEnd);
         }
         
         // trailing whitespace is only considered for smart delete if there is no leading
@@ -241,6 +257,8 @@ void DeleteSelectionCommand::initializePositionData()
             m_upstreamEnd = pos.upstream();
             m_downstreamEnd = pos.downstream();
             m_trailingWhitespace = m_downstreamEnd.trailingWhitespacePosition(VP_DEFAULT_AFFINITY);
+
+            setStartingSelectionOnSmartDelete(m_downstreamStart, m_downstreamEnd);
         }
     }
     
diff --git a/WebCore/editing/DeleteSelectionCommand.h b/WebCore/editing/DeleteSelectionCommand.h
index c8872ef..44a005c 100644
--- a/WebCore/editing/DeleteSelectionCommand.h
+++ b/WebCore/editing/DeleteSelectionCommand.h
@@ -51,6 +51,7 @@ private:
     virtual bool preservesTypingStyle() const;
 
     void initializeStartEnd(Position&, Position&);
+    void setStartingSelectionOnSmartDelete(Position&, Position&);
     void initializePositionData();
     void saveTypingStyleState();
     void insertPlaceholderForAncestorBlockContent();
diff --git a/WebCore/editing/VisibleSelection.cpp b/WebCore/editing/VisibleSelection.cpp
index baef2b5..571fe2b 100644
--- a/WebCore/editing/VisibleSelection.cpp
+++ b/WebCore/editing/VisibleSelection.cpp
@@ -441,7 +441,6 @@ void VisibleSelection::setWithoutValidation(const Position& base, const Position
     ASSERT(!extent.isNull());
     ASSERT(base != extent);
     ASSERT(m_affinity == DOWNSTREAM);
-    ASSERT(m_granularity == CharacterGranularity);
     m_base = base;
     m_extent = extent;
     m_baseIsFirst = comparePositions(base, extent) <= 0;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list