LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Sep 2006 01:17:24 +0000 (01:17 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Sep 2006 01:17:24 +0000 (01:17 +0000)
        Reviewed by harrison

        <rdar://problem/4674869>
        REGRESSION: selecting text to write over results in cursor jumping to middle of next line

        * editing/deleting/whitespace-pre-1-expected.checksum: Added.
        * editing/deleting/whitespace-pre-1-expected.png: Added.
        * editing/deleting/whitespace-pre-1-expected.txt: Added.
        * editing/deleting/whitespace-pre-1.html: Added.

WebCore:

        Reviewed by harrison

        <rdar://problem/4674869>
        REGRESSION: selecting text to write over results in cursor jumping to middle of next line

        * editing/SelectionController.cpp:
        (WebCore::SelectionController::modify): Added lineBoundary to test fix.
        * editing/visible_units.cpp:
        (WebCore::endOfLine): If the last box on the line is a lineBreak, return the
        position before it, not after it.

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

LayoutTests/ChangeLog
LayoutTests/editing/deleting/whitespace-pre-1-expected.checksum [new file with mode: 0644]
LayoutTests/editing/deleting/whitespace-pre-1-expected.png [new file with mode: 0644]
LayoutTests/editing/deleting/whitespace-pre-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/whitespace-pre-1.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/SelectionController.cpp
WebCore/editing/visible_units.cpp

index 562df34895c1bd19f7970a485c59239e0b6e0df8..73afcdfbac5b14348efd6c8d4ca5a157a1cfc94a 100644 (file)
@@ -1,3 +1,15 @@
+2006-09-15  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by harrison
+        
+        <rdar://problem/4674869>
+        REGRESSION: selecting text to write over results in cursor jumping to middle of next line
+
+        * editing/deleting/whitespace-pre-1-expected.checksum: Added.
+        * editing/deleting/whitespace-pre-1-expected.png: Added.
+        * editing/deleting/whitespace-pre-1-expected.txt: Added.
+        * editing/deleting/whitespace-pre-1.html: Added.
+
 2006-09-15  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Justin.
diff --git a/LayoutTests/editing/deleting/whitespace-pre-1-expected.checksum b/LayoutTests/editing/deleting/whitespace-pre-1-expected.checksum
new file mode 100644 (file)
index 0000000..dd38d8b
--- /dev/null
@@ -0,0 +1 @@
+e47891b51d798b8fa7fcd1f12c7a167a
\ No newline at end of file
diff --git a/LayoutTests/editing/deleting/whitespace-pre-1-expected.png b/LayoutTests/editing/deleting/whitespace-pre-1-expected.png
new file mode 100644 (file)
index 0000000..06c4420
Binary files /dev/null and b/LayoutTests/editing/deleting/whitespace-pre-1-expected.png differ
diff --git a/LayoutTests/editing/deleting/whitespace-pre-1-expected.txt b/LayoutTests/editing/deleting/whitespace-pre-1-expected.txt
new file mode 100644 (file)
index 0000000..c32fac3
--- /dev/null
@@ -0,0 +1,23 @@
+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: shouldDeleteDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 49 of #text > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 49 of #text > DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 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 784x18
+        RenderText {#text} at (0,0) size 213x18
+          text run at (0,0) width 213: "This tests for a bug in endOfLine."
+      RenderBlock {DIV} at (0,34) size 784x54
+        RenderText {#text} at (0,0) size 353x54
+          text run at (0,0) width 0: " "
+          text run at (0,18) width 353: "There should be three paragraphs in this editable region."
+          text run at (353,18) width 0: " "
+          text run at (0,36) width 192: "The first one should be empty."
+caret: position 0 of child 0 {#text} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/deleting/whitespace-pre-1.html b/LayoutTests/editing/deleting/whitespace-pre-1.html
new file mode 100644 (file)
index 0000000..a01b994
--- /dev/null
@@ -0,0 +1,14 @@
+<p>This tests for a bug in endOfLine.</p>
+
+<div id="test" contenteditable="true" style="white-space:pre;">You should not see this paragraph after the test.
+There should be three paragraphs in this editable region.
+The first one should be empty.</div>
+
+<script>
+var e = document.getElementById("test");
+var s = window.getSelection();
+
+s.setPosition(e, 0);
+s.modify("extend", "forward", "lineBoundary");
+document.execCommand("Delete");
+</script>
\ No newline at end of file
index a2c47eb5470f9e621d6a94ee04963f0fc2f70e72..142b5debb80a7c7fc50a8603cd7b9d3b7f2301b4 100644 (file)
@@ -1,3 +1,16 @@
+2006-09-15  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by harrison
+        
+        <rdar://problem/4674869>
+        REGRESSION: selecting text to write over results in cursor jumping to middle of next line
+
+        * editing/SelectionController.cpp:
+        (WebCore::SelectionController::modify): Added lineBoundary to test fix.
+        * editing/visible_units.cpp:
+        (WebCore::endOfLine): If the last box on the line is a lineBreak, return the
+        position before it, not after it.
+
 2006-09-15  Krzysztof Kowalczyk  <kkowalczyk@gmail.com>
 
         Reviewed by Adam.
index ad316d8fc02367eba8b5a81168bbf3504dc8d4de..380bc7c29831ef853ca3fac30d58a7d47e1c06bc 100644 (file)
@@ -430,6 +430,8 @@ bool SelectionController::modify(const String &alterString, const String &direct
         granularity = LineGranularity;
     else if (granularityStringLower == "paragraph")
         granularity = ParagraphGranularity;
+    else if (granularityStringLower == "lineboundary")
+        granularity = LineBoundary;
     else if (granularityStringLower == "documentboundary")
         granularity = DocumentBoundary;
     else
index d34d442aa04129698a690d08fec947678b60cfaf..b69f03cdc6a8abd419a7f149604013bd5a4e088d 100644 (file)
@@ -352,7 +352,9 @@ VisiblePosition endOfLine(const VisiblePosition &c)
         endOffset = 0;
     } else if (endBox->isInlineTextBox()) {
         InlineTextBox *endTextBox = static_cast<InlineTextBox *>(endBox);
-        endOffset = endTextBox->m_start + endTextBox->m_len;
+        endOffset = endTextBox->m_start;
+        if (!endTextBox->isLineBreak())
+            endOffset += endTextBox->m_len;
     }
     
     return VisiblePosition(endNode, endOffset, VP_UPSTREAM_IF_POSSIBLE);