LayoutTests:
authorlweintraub <lweintraub@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 20 May 2006 00:21:46 +0000 (00:21 +0000)
committerlweintraub <lweintraub@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 20 May 2006 00:21:46 +0000 (00:21 +0000)
        Reviewed by justin.

        Tests for <http://bugzilla.opendarwin.org/show_bug.cgi?id=8931>
        Drag caret not painted for editable sub-frames

        * editing/resources/select-and-drag-iframe.html: Added.
        * editing/selection/drag-in-iframe-expected.checksum: Added.
        * editing/selection/drag-in-iframe-expected.png: Added.
        * editing/selection/drag-in-iframe-expected.txt: Added.
        * editing/selection/drag-in-iframe.html: Added.

WebCore:

        Reviewed by justin.

        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8931>
        Drag caret not painted for editable sub-frames

        Moved the drag caret out of Frame and into Page.
        Only the Frame that contains the drag caret will paint it.

        * editing/SelectionController.h:
        * page/Frame.cpp:
        (WebCore::Frame::dragCaret):
        (WebCore::Frame::setDragCaret):
        (WebCore::Frame::paintDragCaret):
        * page/FramePrivate.h:
        * page/Page.cpp:
        (WebCore::Page::dragCaret):
        (WebCore::Page::setDragCaret):
        * page/Page.h:

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/resources/select-and-drag-iframe.html [new file with mode: 0644]
LayoutTests/editing/selection/drag-in-iframe-expected.checksum [new file with mode: 0644]
LayoutTests/editing/selection/drag-in-iframe-expected.png [new file with mode: 0644]
LayoutTests/editing/selection/drag-in-iframe-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/drag-in-iframe.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/SelectionController.h
WebCore/page/Frame.cpp
WebCore/page/FramePrivate.h
WebCore/page/Page.cpp
WebCore/page/Page.h

index 840e76f..abfb5b5 100644 (file)
@@ -1,3 +1,16 @@
+2006-05-19  Levi Weintraub  <lweintraub@apple.com>
+
+        Reviewed by justin.
+        
+        Tests for <http://bugzilla.opendarwin.org/show_bug.cgi?id=8931>
+        Drag caret not painted for editable sub-frames
+
+        * editing/resources/select-and-drag-iframe.html: Added.
+        * editing/selection/drag-in-iframe-expected.checksum: Added.
+        * editing/selection/drag-in-iframe-expected.png: Added.
+        * editing/selection/drag-in-iframe-expected.txt: Added.
+        * editing/selection/drag-in-iframe.html: Added.
+
 2006-05-17  Geoffrey Garen  <ggaren@apple.com>
 
         - Test for overriding non-autogenerated global constructors.
diff --git a/LayoutTests/editing/resources/select-and-drag-iframe.html b/LayoutTests/editing/resources/select-and-drag-iframe.html
new file mode 100644 (file)
index 0000000..4ebaa43
--- /dev/null
@@ -0,0 +1,3 @@
+<body contenteditable="true" id="dragme">Drag onto me!<br>Or Me!
+
+</body>
\ No newline at end of file
diff --git a/LayoutTests/editing/selection/drag-in-iframe-expected.checksum b/LayoutTests/editing/selection/drag-in-iframe-expected.checksum
new file mode 100644 (file)
index 0000000..48670ad
--- /dev/null
@@ -0,0 +1 @@
+8ca0e17c98959ca8a7e4b907dfccbb41
\ No newline at end of file
diff --git a/LayoutTests/editing/selection/drag-in-iframe-expected.png b/LayoutTests/editing/selection/drag-in-iframe-expected.png
new file mode 100644 (file)
index 0000000..3ef6880
Binary files /dev/null and b/LayoutTests/editing/selection/drag-in-iframe-expected.png differ
diff --git a/LayoutTests/editing/selection/drag-in-iframe-expected.txt b/LayoutTests/editing/selection/drag-in-iframe-expected.txt
new file mode 100644 (file)
index 0000000..8520d58
--- /dev/null
@@ -0,0 +1,24 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 3 of BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > BODY > HTML > #document to 1 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > BODY > HTML > #document to 1 of #text > BODY > HTML > #document toDOMRange:range from 0 of #text > BODY > HTML > #document to 4 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+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
+      RenderPartObject {IFRAME} at (0,0) size 302x152 [border: (1px solid #000000)]
+        layer at (0,0) size 300x150
+          RenderCanvas at (0,0) size 300x150
+        layer at (0,0) size 300x150
+          RenderBlock {HTML} at (0,0) size 300x150
+            RenderBody {BODY} at (8,8) size 284x134
+              RenderText {#text} at (0,0) size 92x18
+                text run at (0,0) width 92: "Drag onto me!"
+              RenderBR {BR} at (92,14) size 0x0
+              RenderText {#text} at (0,18) size 47x18
+                text run at (0,18) width 47: "Or Me!"
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/editing/selection/drag-in-iframe.html b/LayoutTests/editing/selection/drag-in-iframe.html
new file mode 100644 (file)
index 0000000..fa7ecde
--- /dev/null
@@ -0,0 +1,44 @@
+<body contenteditable="true">
+<iframe style="border: 1px solid black;" src="../resources/select-and-drag-iframe.html" id="subframe"></iframe>
+
+<script>
+
+function step2() {
+    // This is a hack because when we try to get the document 
+    // for the subframe to get elements from it, the frame fails to load.
+    eventSender.mouseMoveTo(30, 20);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+    
+    eventSender.leapForward(1000);
+    eventSender.mouseDown();
+    eventSender.leapForward(500);
+    eventSender.mouseMoveTo(200, 20);
+    
+    // Dump pixel results before we drop so we can see where the drag caret is painted.
+    window.layoutTestController.notifyDone();
+    
+    // Drop outside the subframe to avoid strange bugs when dropping content inside an editable frame.
+    eventSender.mouseMoveTo(600, 400);    
+    eventSender.mouseUp();
+    
+    // Mouse down to avoid assertion about multiple frames selections.
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+function runTest() {
+    if (!window.layoutTestController)
+        return;
+
+    window.layoutTestController.waitUntilDone();
+    // Give the iframe a moment to come into being.
+    window.setTimeout(step2, 100);
+}
+
+runTest();
+
+</script>
+</body>
\ No newline at end of file
index 09cb630..db8b2ac 100644 (file)
@@ -1,3 +1,24 @@
+2006-05-19  Levi Weintraub  <lweintraub@apple.com>
+
+        Reviewed by justin.
+        
+        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8931>
+        Drag caret not painted for editable sub-frames
+        
+        Moved the drag caret out of Frame and into Page.
+        Only the Frame that contains the drag caret will paint it.
+
+        * editing/SelectionController.h:
+        * page/Frame.cpp:
+        (WebCore::Frame::dragCaret):
+        (WebCore::Frame::setDragCaret):
+        (WebCore::Frame::paintDragCaret):
+        * page/FramePrivate.h:
+        * page/Page.cpp:
+        (WebCore::Page::dragCaret):
+        (WebCore::Page::setDragCaret):
+        * page/Page.h:
+
 2006-05-19  Alice Liu  <alice.liu@apple.com>
 
         Reviewed by Adele.
index 58b11c2..3d30f32 100644 (file)
@@ -104,8 +104,6 @@ public:
     PassRefPtr<Range> toRange() const { return m_sel.toRange(); }
 
     void debugRenderer(RenderObject*, bool selected) const;
-
-    friend class Frame;
     
     Frame* frame() const;
     
@@ -149,6 +147,9 @@ public:
     void empty();
     //void clear();
     //TextRange *createRange();
+    
+    void needsCaretRepaint();
+    void paintCaret(GraphicsContext*, const IntRect &rect);
 
 #ifndef NDEBUG
     void formatForDebugger(char* buffer, unsigned length) const;
@@ -164,8 +165,6 @@ private:
     VisiblePosition modifyMovingLeftBackward(TextGranularity);
 
     void layout();
-    void needsCaretRepaint();
-    void paintCaret(GraphicsContext*, const IntRect &rect);
     IntRect caretRepaintRect() const;
 
     int xPosForVerticalArrowNavigation(EPositionType, bool recalc = false) const;
index 2fafec9..64674d3 100644 (file)
@@ -53,6 +53,7 @@
 #include "ImageDocument.h"
 #include "MouseEventWithHitTestResults.h"
 #include "NodeList.h"
+#include "Page.h"
 #include "Plugin.h"
 #include "RenderCanvas.h"
 #include "RenderPart.h"
@@ -1125,7 +1126,7 @@ void Frame::setSelectionGranularity(TextGranularity granularity) const
 
 SelectionController& Frame::dragCaret() const
 {
-    return d->m_dragCaret;
+    return d->m_page->dragCaret();
 }
 
 const Selection& Frame::mark() const
@@ -1169,11 +1170,7 @@ void Frame::setSelection(const SelectionController& s, bool closeTyping, bool ke
 
 void Frame::setDragCaret(const SelectionController& dragCaret)
 {
-    if (d->m_dragCaret != dragCaret) {
-        d->m_dragCaret.needsCaretRepaint();
-        d->m_dragCaret = dragCaret;
-        d->m_dragCaret.needsCaretRepaint();
-    }
+    d->m_page->setDragCaret(dragCaret);
 }
 
 void Frame::invalidateSelection()
@@ -1299,7 +1296,10 @@ void Frame::paintCaret(GraphicsContext* p, const IntRect& rect) const
 
 void Frame::paintDragCaret(GraphicsContext* p, const IntRect& rect) const
 {
-    d->m_dragCaret.paintCaret(p, rect);
+    SelectionController& dragCaret = d->m_page->dragCaret();
+    assert(dragCaret.selection().isCaret());
+    if (dragCaret.selection().start().node()->document()->frame() == this)
+        dragCaret.paintCaret(p, rect);
 }
 
 void Frame::urlSelected(const DeprecatedString& url, const String& target)
index 58ca280..92cdd3f 100644 (file)
@@ -182,7 +182,6 @@ namespace WebCore {
         bool m_beganSelectingText;
 
         SelectionController m_selection;
-        SelectionController m_dragCaret;
         Selection m_mark;
         Timer<Frame> m_caretBlinkTimer;
 
index 0caf88d..7ed215f 100644 (file)
@@ -122,4 +122,18 @@ void Page::setNeedsReapplyStylesForSettingsChange(KHTMLSettings* settings)
                 frame->setNeedsReapplyStyles();
 }
 
+SelectionController& Page::dragCaret() const
+{
+    return m_dragCaret;
+}
+
+void Page::setDragCaret(const SelectionController& dragCaret)
+{
+    if (m_dragCaret != dragCaret) {
+        m_dragCaret.needsCaretRepaint();
+        m_dragCaret = dragCaret;
+        m_dragCaret.needsCaretRepaint();
+    }
+}
+
 }
index 801ab6d..185f3c8 100644 (file)
@@ -22,6 +22,7 @@
 #define PAGE_H
 
 #include "PlatformString.h"
+#include "SelectionController.h"
 #include <wtf/HashSet.h>
 
 #if __APPLE__
@@ -61,6 +62,10 @@ namespace WebCore {
 
         static void setNeedsReapplyStyles();
         static void setNeedsReapplyStylesForSettingsChange(KHTMLSettings*);
+        
+        // FIXME: Replace this with a function on the selection controller or change it to Selection instead?
+        void setDragCaret(const SelectionController&);
+        SelectionController& dragCaret() const; // FIXME: Change to pointer?
 
 #if __APPLE__
         Page(WebCorePageBridge*);
@@ -77,6 +82,7 @@ namespace WebCore {
         RefPtr<Frame> m_mainFrame;
         int m_frameCount;
         String m_groupName;
+        mutable SelectionController m_dragCaret;
 
 #if __APPLE__
         WebCorePageBridge* m_bridge;