LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 May 2006 23:49:48 +0000 (23:49 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 May 2006 23:49:48 +0000 (23:49 +0000)
        Reviewed by levi

        * editing/selection/designmode-no-caret-expected.checksum: Added.
        * editing/selection/designmode-no-caret-expected.png: Added.
        * editing/selection/designmode-no-caret-expected.txt: Added.
        * editing/selection/designmode-no-caret.html: Added.

WebCore:

        Reviewed by levi

        <rdar://problem/4549610> REGRESSION: No initial cursor in Mail reply or Blot document
        <rdar://problem/4560698> Mail is very crashy in Leopard9A182, WebCore::Range::compareBoundaryPoints(WebCore::Node*, int, WebCore::Node*, int)

        * page/Frame.cpp:
        (WebCore::Frame::setSelectionFromNone): Find the body and stick a caret
        in it.

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

LayoutTests/ChangeLog
LayoutTests/editing/selection/designmode-no-caret-expected.checksum [new file with mode: 0644]
LayoutTests/editing/selection/designmode-no-caret-expected.png [new file with mode: 0644]
LayoutTests/editing/selection/designmode-no-caret-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/designmode-no-caret.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/page/Frame.cpp

index 2421dbb7829a8bd405080e40a7f9daf7ff73790f..19e901beb454ec9e60bb0d3dd42c20b75b4bfe31 100644 (file)
@@ -1,3 +1,12 @@
+2006-05-24  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+
+        * editing/selection/designmode-no-caret-expected.checksum: Added.
+        * editing/selection/designmode-no-caret-expected.png: Added.
+        * editing/selection/designmode-no-caret-expected.txt: Added.
+        * editing/selection/designmode-no-caret.html: Added.
+
 2006-05-24  Geoffrey Garen  <ggaren@apple.com>
 
         - Layout test for http://bugzilla.opendarwin.org/show_bug.cgi?id=9095
diff --git a/LayoutTests/editing/selection/designmode-no-caret-expected.checksum b/LayoutTests/editing/selection/designmode-no-caret-expected.checksum
new file mode 100644 (file)
index 0000000..e19a9fd
--- /dev/null
@@ -0,0 +1 @@
+3b1c405abdef2c706783a17104ea2231
\ No newline at end of file
diff --git a/LayoutTests/editing/selection/designmode-no-caret-expected.png b/LayoutTests/editing/selection/designmode-no-caret-expected.png
new file mode 100644 (file)
index 0000000..f957383
Binary files /dev/null and b/LayoutTests/editing/selection/designmode-no-caret-expected.png differ
diff --git a/LayoutTests/editing/selection/designmode-no-caret-expected.txt b/LayoutTests/editing/selection/designmode-no-caret-expected.txt
new file mode 100644 (file)
index 0000000..6876ea9
--- /dev/null
@@ -0,0 +1,15 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of HTML > #document to 1 of HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x70
+  RenderBlock {HTML} at (0,0) size 800x70
+    RenderBody {BODY} at (8,8) size 784x54
+      RenderText {#text} at (0,0) size 784x54
+        text run at (0,0) width 759: "This tests to see that a caret is placed inside an editable document that is entirely editable even when no caret is requested"
+        text run at (0,18) width 118: "programmatically. "
+        text run at (118,18) width 187: "We do this as a convenience. "
+        text run at (305,18) width 479: "Right now, we only do this convenience when a document's frame becomes"
+        text run at (0,36) width 378: "first responder or when a document's window becomes key."
+caret: position 0 of child 0 {#text} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/selection/designmode-no-caret.html b/LayoutTests/editing/selection/designmode-no-caret.html
new file mode 100644 (file)
index 0000000..9777a7c
--- /dev/null
@@ -0,0 +1,10 @@
+This tests to see that a caret is placed inside an editable document that is entirely editable even when no caret is requested programmatically.  We do this as a convenience.  Right now, we only do this convenience when a document's frame becomes first responder or when a document's window becomes key.
+<script>
+document.designMode = "on";
+if (window.layoutTestController) {
+    window.layoutTestController.waitUntilDone();
+    window.layoutTestController.setMainFrameIsFirstResponder(false);
+    window.layoutTestController.setMainFrameIsFirstResponder(true);
+    window.layoutTestController.notifyDone();
+}
+</script>
\ No newline at end of file
index 8dfbba969546513b93d463d0a1eb0b1200d1b988..ca3cbe7c12ab3c98890c26f063f2c4048dfb3257 100644 (file)
@@ -1,3 +1,14 @@
+2006-05-24  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+        
+        <rdar://problem/4549610> REGRESSION: No initial cursor in Mail reply or Blot document
+        <rdar://problem/4560698> Mail is very crashy in Leopard9A182, WebCore::Range::compareBoundaryPoints(WebCore::Node*, int, WebCore::Node*, int)
+
+        * page/Frame.cpp:
+        (WebCore::Frame::setSelectionFromNone): Find the body and stick a caret 
+        in it.
+
 2006-05-24  Geoffrey Garen  <ggaren@apple.com>
 
         Rubber stamped by Anders.
index 64674d3662c8fa4453978f5f91ec50f75a8740fa..528521b855d3f9c8fe49d02e84018dea2a0432e3 100644 (file)
@@ -3215,22 +3215,17 @@ void Frame::setMediaType(const String& type)
 
 void Frame::setSelectionFromNone()
 {
-    // Put the caret someplace if the selection is empty and the part is editable.
-    // This has the effect of flashing the caret in a contentEditable view automatically 
-    // without requiring the programmer to set a selection explicitly.
+    // Put a caret inside the body if the entire frame is editable (either the 
+    // entire WebView is editable or designMode is on for this document).
     Document *doc = document();
-    if (doc && selection().isNone() && isContentEditable()) {
-        Node *node = doc->documentElement();
-        while (node) {
-            // Look for a block flow, but skip over the HTML element, since we really
-            // want to get at least as far as the the BODY element in a document.
-            if (node->isBlockFlow() && node->hasTagName(htmlTag))
-                break;
-            node = node->traverseNextNode();
-        }
-        if (node)
-            setSelection(SelectionController(Position(node, 0), DOWNSTREAM));
-    }
+    if (!doc || !selection().isNone() || !isContentEditable())
+        return;
+        
+    Node* node = doc->documentElement();
+    while (node && !node->hasTagName(bodyTag))
+        node = node->traverseNextNode();
+    if (node)
+        setSelection(SelectionController(Position(node, 0), DOWNSTREAM));
 }
 
 bool Frame::displaysWithFocusAttributes() const