LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Jul 2006 21:54:32 +0000 (21:54 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Jul 2006 21:54:32 +0000 (21:54 +0000)
        Reviewed by levi

        <rdar://problem/4618389> REGRESSION: After applying a link to the last word of a sentence, a new selection is created at the start of the sentence

        * editing/selection/replace-selection-1-expected.checksum: Added.
        * editing/selection/replace-selection-1-expected.png: Added.
        * editing/selection/replace-selection-1-expected.txt: Added.
        * editing/selection/replace-selection-1.html: Added.

WebCore:

        Reviewed by levi

        <rdar://problem/4618389> REGRESSION: After applying a link to the last word of a sentence, a new selection is created at the start of the sentence

        * dom/Document.cpp:
        (WebCore::Document::updateSelection):

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

LayoutTests/ChangeLog
LayoutTests/editing/selection/replace-selection-1-expected.checksum [new file with mode: 0644]
LayoutTests/editing/selection/replace-selection-1-expected.png [new file with mode: 0644]
LayoutTests/editing/selection/replace-selection-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/replace-selection-1.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/Document.cpp

index 204672942173cb6765532740dd9673f22e3b366a..812095cf355a735b534696c1580f393a7c58c0a8 100644 (file)
@@ -1,3 +1,14 @@
+2006-07-17  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+        
+        <rdar://problem/4618389> REGRESSION: After applying a link to the last word of a sentence, a new selection is created at the start of the sentence
+
+        * editing/selection/replace-selection-1-expected.checksum: Added.
+        * editing/selection/replace-selection-1-expected.png: Added.
+        * editing/selection/replace-selection-1-expected.txt: Added.
+        * editing/selection/replace-selection-1.html: Added.
+
 2006-07-14  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by levi
diff --git a/LayoutTests/editing/selection/replace-selection-1-expected.checksum b/LayoutTests/editing/selection/replace-selection-1-expected.checksum
new file mode 100644 (file)
index 0000000..5a07df2
--- /dev/null
@@ -0,0 +1 @@
+77cc0796aaf51dcf279e5fce59b1e1b6
\ No newline at end of file
diff --git a/LayoutTests/editing/selection/replace-selection-1-expected.png b/LayoutTests/editing/selection/replace-selection-1-expected.png
new file mode 100644 (file)
index 0000000..fd2fa9d
Binary files /dev/null and b/LayoutTests/editing/selection/replace-selection-1-expected.png differ
diff --git a/LayoutTests/editing/selection/replace-selection-1-expected.txt b/LayoutTests/editing/selection/replace-selection-1-expected.txt
new file mode 100644 (file)
index 0000000..d2255cb
--- /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: shouldChangeSelectedDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 0 of #text > A > DIV > BODY > HTML > #document toDOMRange:range from 4 of #text > A > DIV > BODY > HTML > #document to 4 of #text > A > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+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 775x36
+          text run at (0,0) width 581: "This tests for a bug when a selection is replaced by content with selectReplacement == true. "
+          text run at (581,0) width 194: "Below, you should see 'A new"
+          text run at (0,18) width 58: "link' and "
+          text run at (58,18) width 153: "'link' should be selected."
+      RenderBlock {DIV} at (0,52) size 784x18
+        RenderText {#text} at (0,0) size 47x18
+          text run at (0,0) width 47: "A new "
+        RenderInline {A} at (0,0) size 24x18 [color=#0000EE]
+          RenderText {#text} at (47,0) size 24x18
+            text run at (47,0) width 24: "link"
+selection start: position 0 of child 0 {#text} of child 1 {A} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
+selection end:   position 4 of child 0 {#text} of child 1 {A} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/selection/replace-selection-1.html b/LayoutTests/editing/selection/replace-selection-1.html
new file mode 100644 (file)
index 0000000..c75e4ac
--- /dev/null
@@ -0,0 +1,12 @@
+<p>This tests for a bug when a selection is replaced by content with selectReplacement == true.  Below, you should see 'A new link' and  'link' should be selected.</p>
+<div id="test" contenteditable="true">A new link</div>
+
+<script>
+var s = window.getSelection();
+var e = document.getElementById("test");
+
+s.setBaseAndExtent(e.firstChild, 6, e.firstChild, 10);
+document.execCommand("InsertHTML", false, "<a id='link' href='http://www.google.com'>link</a>");
+e = document.getElementById("link");
+s.setBaseAndExtent(e.firstChild, 0, e.firstChild, 4);
+</script>
\ No newline at end of file
index dc62cc7cf161173fa4fc4a6240ae3c4cd82dc626..b443a7608a2809bff3b0147fbdee2af9d9e7d29c 100644 (file)
@@ -1,3 +1,12 @@
+2006-07-17  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+        
+        <rdar://problem/4618389> REGRESSION: After applying a link to the last word of a sentence, a new selection is created at the start of the sentence
+        
+        * dom/Document.cpp:
+        (WebCore::Document::updateSelection):
+
 2006-07-17  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Beth.
index 6544be173aa4d9e8a331c64fff4de6b1605d41b2..61236c58effd33b0262ff8fba1b3d2b672364be9 100644 (file)
@@ -1081,8 +1081,10 @@ void Document::updateSelection()
         Position endPos = s.selection().visibleEnd().deepEquivalent();
         if (endPos.upstream().inRenderedContent())
             endPos = endPos.upstream();
-            
-        if (startPos.isNotNull() && endPos.isNotNull()) {
+        
+        // We can get into a state where the selection endpoints map to the same VisiblePosition when a selection is deleted
+        // because we don't yet notify the SelectionController of text removal.
+        if (startPos.isNotNull() && endPos.isNotNull() && s.selection().visibleStart() != s.selection().visibleEnd()) {
             RenderObject *startRenderer = startPos.node()->renderer();
             RenderObject *endRenderer = endPos.node()->renderer();
             static_cast<RenderView*>(renderer())->setSelection(startRenderer, startPos.offset(), endRenderer, endPos.offset());