LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Sep 2006 19:31:56 +0000 (19:31 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Sep 2006 19:31:56 +0000 (19:31 +0000)
        Reviewed by john

        * editing/pasteboard/subframe-dragndrop-1-expected.checksum: Added.
        * editing/pasteboard/subframe-dragndrop-1-expected.png: Added.
        * editing/pasteboard/subframe-dragndrop-1-expected.txt: Added.
        * editing/pasteboard/subframe-dragndrop-1.html: Added.

WebCore:

        Reviewed by john

        <http://bugzilla.opendarwin.org/show_bug.cgi?id=7165>
        TinyMCE: Dragging & dropping content always leaves a copy when editing inside a subframe

        * editing/MoveSelectionCommand.cpp:
        (WebCore::MoveSelectionCommand::MoveSelectionCommand): Set the document
        to the position-to-move-to's document, not the fragment's document.  The
        fragment's document is the document used to create the fragment and is irrelavant.

WebKit:

        Reviewed by john

        <http://bugzilla.opendarwin.org/show_bug.cgi?id=7165>
        TinyMCE: Dragging & dropping content always leaves a copy when editing inside a subframe

        The top level WebHTMLView is responsible for performing dragging operations, but
        the inner view, the view that holds the drag caret, should be consulted to determine
        if the drag is a move drag.

        * WebCoreSupport/WebFrameBridge.m:
        (-[WebFrameBridge startDraggingImage:at:operation:event:sourceIsDHTML:DHTMLWroteData:]):
        * WebKit.xcodeproj/project.pbxproj:
        * WebView/WebHTMLView.m:
        (-[NSArray dragImage:at:offset:event:pasteboard:source:slideBack:]): Don't set initatedDrag here, because
        it's only the top level WebHTMLView that performs this operation.
        (-[WebHTMLView _setInitiatedDrag:]): Added.
        (-[WebHTMLView _initiatedDrag]): Ditto.
        (-[WebHTMLView _canProcessDragWithDraggingInfo:]): Ask the innerView if it initiated the drag,
        not the top level view.
        (-[WebHTMLView _isMoveDrag]): The top level view asks the innerView if it should perform
        a move drag, so don't ASSERT _isTopHTMLView.
        (-[WebHTMLView draggingUpdatedWithDraggingInfo:actionMask:]): Ask the innerView if _isMoveDrag.
        (-[WebHTMLView concludeDragForDraggingInfo:actionMask:]): Ditto.
        * WebView/WebHTMLViewInternal.h: Added two private SPI so that
        the top level WebHTMLView can set and get the initiatedDrag BOOL.

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

LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/subframe-dragndrop-1-expected.checksum [new file with mode: 0644]
LayoutTests/editing/pasteboard/subframe-dragndrop-1-expected.png [new file with mode: 0644]
LayoutTests/editing/pasteboard/subframe-dragndrop-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/subframe-dragndrop-1.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/MoveSelectionCommand.cpp
WebKit/ChangeLog
WebKit/WebCoreSupport/WebFrameBridge.m
WebKit/WebView/WebHTMLView.m
WebKit/WebView/WebHTMLViewInternal.h

index 3f51d9b3d197237d445b5449f1d0def1d10b0c4e..3f90a37b0ec03f58915ba07e11bbdff8c95762fc 100644 (file)
@@ -1,3 +1,12 @@
+2006-09-20  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by john
+
+        * editing/pasteboard/subframe-dragndrop-1-expected.checksum: Added.
+        * editing/pasteboard/subframe-dragndrop-1-expected.png: Added.
+        * editing/pasteboard/subframe-dragndrop-1-expected.txt: Added.
+        * editing/pasteboard/subframe-dragndrop-1.html: Added.
+
 2006-09-20  Rob Buis  <buis@kde.org>
 
         Reviewed by eseidel.
@@ -9,7 +18,7 @@
         * svg/W3C-SVG-1.1/painting-marker-02-f-expected.checksum:
         * svg/W3C-SVG-1.1/painting-marker-02-f-expected.png:
         * svg/custom/invalid-css-expected.txt:
-
+        
 2006-09-20  Julien Palmas  <julien.palmas@gmail.com>
 
         Reviewed by eseidel.  Landed by eseidel.
diff --git a/LayoutTests/editing/pasteboard/subframe-dragndrop-1-expected.checksum b/LayoutTests/editing/pasteboard/subframe-dragndrop-1-expected.checksum
new file mode 100644 (file)
index 0000000..69ca5ca
--- /dev/null
@@ -0,0 +1 @@
+2a7b32ad6cb0b2b7231c0956bcbc5a24
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/subframe-dragndrop-1-expected.png b/LayoutTests/editing/pasteboard/subframe-dragndrop-1-expected.png
new file mode 100644 (file)
index 0000000..2138e83
Binary files /dev/null and b/LayoutTests/editing/pasteboard/subframe-dragndrop-1-expected.png differ
diff --git a/LayoutTests/editing/pasteboard/subframe-dragndrop-1-expected.txt b/LayoutTests/editing/pasteboard/subframe-dragndrop-1-expected.txt
new file mode 100644 (file)
index 0000000..9fa2683
--- /dev/null
@@ -0,0 +1,36 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of BODY > HTML > #document to 0 of BODY > HTML > #document toDOMRange:range from 11 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 2 of BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 11 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document toDOMRange:range from 6 of #text > BODY > HTML > #document to 6 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 6 of #text > BODY > HTML > #document to 6 of #text > BODY > HTML > #document toDOMRange:range from 4 of #text > BODY > HTML > #document to 7 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 11 of #text > BODY > HTML > #document to 11 of #text > BODY > HTML > #document givenAction:WebViewInsertActionDropped
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 4 of #text > BODY > HTML > #document to 7 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
+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 (0,0) size 800x584
+      RenderBlock (anonymous) at (0,0) size 800x300
+        RenderPartObject {IFRAME} at (0,0) size 300x300
+          layer at (0,0) size 300x300
+            RenderView at (0,0) size 300x300
+          layer at (0,0) size 300x300
+            RenderBlock {HTML} at (0,0) size 300x300
+              RenderBody {BODY} at (8,8) size 284x284 [bgcolor=#FFFFE0]
+                RenderText {#text} at (0,0) size 47x18
+                  text run at (0,0) width 47: "foo baz"
+                RenderText {#text} at (47,0) size 24x18
+                  text run at (47,0) width 24: " bar"
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {P} at (0,316) size 800x36
+        RenderText {#text} at (0,0) size 795x36
+          text run at (0,0) width 795: "This test uses the eventSender to do drag and drop. To run it manually, drag the word selected in the above subframe and drop"
+          text run at (0,18) width 80: "it after 'baz'. "
+          text run at (80,18) width 213: "The result should be 'foo baz bar'."
diff --git a/LayoutTests/editing/pasteboard/subframe-dragndrop-1.html b/LayoutTests/editing/pasteboard/subframe-dragndrop-1.html
new file mode 100644 (file)
index 0000000..7657e88
--- /dev/null
@@ -0,0 +1,44 @@
+<body style="margin: 0px; padding: 0px;">
+<iframe style="margin: 0; padding: 0; height: 300px; width: 300px;" src="../resources/contenteditable-iframe-src.html"></iframe>
+<p>This test uses the eventSender to do drag and drop. To run it manually, drag the word selected in the above subframe and drop it after 'baz'.  The result should be 'foo baz bar'.</p>
+<script>
+function runTest() {
+    var frame = frames[0];
+    var doc = frame.document;
+    var sel = frame.getSelection();
+    sel.setPosition(doc.body, 0);
+    doc.execCommand("InsertText", false, "foo bar baz");
+    
+    if (window.layoutTestController) {
+        // Attempt to put the mouse over the word 'bar'.  The proper way to do this 
+        // would be to put 'bar' inside an id'd span so that we'd know it's coordinates exactly.
+        var x = 50;
+        var y = 15;
+        eventSender.mouseMoveTo(x, y);
+
+        // Select 'bar'
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+        
+        // Pause so that the mouse down will start a drag instead of a triple click.
+        eventSender.leapForward(1500);
+        
+        eventSender.mouseDown();
+        eventSender.leapForward(1000);
+        
+        x += 100;
+        // Drop it like it's hot.
+        eventSender.mouseMoveTo(x, y);
+        eventSender.mouseUp();
+        
+        window.layoutTestController.notifyDone();
+    }
+}
+if (window.layoutTestController)
+    window.layoutTestController.waitUntilDone();
+// Give the subframe a moment to load.
+window.setTimeout(runTest, 100);
+</script>
+</body>
\ No newline at end of file
index ac020c4a8273dae8f9dd73e8c3a972f076515f45..a6eb2176f4b4390107799026a040caeaaebb4dbe 100644 (file)
@@ -1,3 +1,15 @@
+2006-09-20  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by john
+        
+        <http://bugzilla.opendarwin.org/show_bug.cgi?id=7165>
+        TinyMCE: Dragging & dropping content always leaves a copy when editing inside a subframe
+
+        * editing/MoveSelectionCommand.cpp:
+        (WebCore::MoveSelectionCommand::MoveSelectionCommand): Set the document
+        to the position-to-move-to's document, not the fragment's document.  The 
+        fragment's document is the document used to create the fragment and is irrelavant.
+
 2006-09-21  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Anders
index e2809ed0a51c2ebf5ea010aeb6effe21a180c84a..b2637a78089ec7d82dd0fa5609ba52a7fea6fd60 100644 (file)
@@ -32,7 +32,7 @@
 namespace WebCore {
 
 MoveSelectionCommand::MoveSelectionCommand(PassRefPtr<DocumentFragment> fragment, const Position& position, bool smartMove) 
-    : CompositeEditCommand(fragment->document()), m_fragment(fragment), m_position(position), m_smartMove(smartMove)
+    : CompositeEditCommand(position.node()->document()), m_fragment(fragment), m_position(position), m_smartMove(smartMove)
 {
     ASSERT(m_fragment);
 }
index 07478d4f45bba93d909e0b1cea9d4df191ef16df..b2804028c912fee60d74a22b995b61a4560dfa72 100644 (file)
@@ -1,3 +1,31 @@
+2006-09-20  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by john
+        
+        <http://bugzilla.opendarwin.org/show_bug.cgi?id=7165>
+        TinyMCE: Dragging & dropping content always leaves a copy when editing inside a subframe
+        
+        The top level WebHTMLView is responsible for performing dragging operations, but
+        the inner view, the view that holds the drag caret, should be consulted to determine
+        if the drag is a move drag.
+
+        * WebCoreSupport/WebFrameBridge.m:
+        (-[WebFrameBridge startDraggingImage:at:operation:event:sourceIsDHTML:DHTMLWroteData:]):
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebView/WebHTMLView.m:
+        (-[NSArray dragImage:at:offset:event:pasteboard:source:slideBack:]): Don't set initatedDrag here, because
+        it's only the top level WebHTMLView that performs this operation.
+        (-[WebHTMLView _setInitiatedDrag:]): Added.
+        (-[WebHTMLView _initiatedDrag]): Ditto.
+        (-[WebHTMLView _canProcessDragWithDraggingInfo:]): Ask the innerView if it initiated the drag,
+        not the top level view.
+        (-[WebHTMLView _isMoveDrag]): The top level view asks the innerView if it should perform
+        a move drag, so don't ASSERT _isTopHTMLView.
+        (-[WebHTMLView draggingUpdatedWithDraggingInfo:actionMask:]): Ask the innerView if _isMoveDrag.
+        (-[WebHTMLView concludeDragForDraggingInfo:actionMask:]): Ditto.
+        * WebView/WebHTMLViewInternal.h: Added two private SPI so that
+        the top level WebHTMLView can set and get the initiatedDrag BOOL.
+
 2006-09-20  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Tim Omernick
index dd502707ed569357b08c5f251c3f1c9c94cbbe76..1e283d0598f7f79c4fdc79e67a20c6546771fe40 100644 (file)
@@ -1188,6 +1188,7 @@ static BOOL loggedObjectCacheSize = NO;
 {
     WebHTMLView *docView = (WebHTMLView *)[[_frame frameView] documentView];
     ASSERT([docView isKindOfClass:[WebHTMLView class]]);
+    [docView _setInitiatedDrag:YES];
     return [docView _startDraggingImage:dragImage at:dragLoc operation:op event:event sourceIsDHTML:flag DHTMLWroteData:dhtmlWroteData];
 }
 
index 233a473ecc2f317bf3ca83bbe814e01d255023fd..ec7f9a01d7154e285ffbe1cff51780810d65bf61 100644 (file)
@@ -2827,8 +2827,7 @@ done:
     }
 
     WebView *webView = [self _webView];
-
-    _private->initiatedDrag = YES;
+    
     [webView _setInitiatedDrag:YES];
 
     // Retain this view during the drag because it may be released before the drag ends.
@@ -5017,6 +5016,16 @@ static DOMRange *unionDOMRanges(DOMRange *a, DOMRange *b)
     return [_private->dataSource webFrame];
 }
 
+- (void)_setInitiatedDrag:(BOOL)flag
+{
+    _private->initiatedDrag = flag;
+}
+
+- (BOOL)_initiatedDrag
+{
+    return _private->initiatedDrag;
+}
+
 @end
 
 @implementation WebHTMLView (WebNSTextInputSupport)
@@ -5701,9 +5710,14 @@ static DOMRange *unionDOMRanges(DOMRange *a, DOMRange *b)
 
     NSPoint point = [self convertPoint:[draggingInfo draggingLocation] fromView:nil];
     NSDictionary *element = [self elementAtPoint:point allowShadowContent:YES];
-    if ([[self _webView] isEditable] || [[element objectForKey:WebElementDOMNodeKey] isContentEditable]) {
+    ASSERT(element);
+    WebFrame *innerFrame = (WebFrame *)[element objectForKey:WebElementFrameKey];
+    ASSERT(innerFrame);
+    ASSERT([innerFrame isKindOfClass:[WebFrame class]]);
+    WebHTMLView* innerView = (WebHTMLView *)[[innerFrame frameView] documentView];
+    if ([[element objectForKey:WebElementDOMNodeKey] isContentEditable]) {
         // Can't drag onto the selection being dragged.
-        if (_private->initiatedDrag && [[element objectForKey:WebElementIsSelectedKey] boolValue])
+        if ([innerView _initiatedDrag] && [[element objectForKey:WebElementIsSelectedKey] boolValue])
             return NO;
         return YES;
     }
@@ -5713,9 +5727,8 @@ static DOMRange *unionDOMRanges(DOMRange *a, DOMRange *b)
 
 - (BOOL)_isMoveDrag
 {
-    ASSERT([self _isTopHTMLView]);
     return _private->initiatedDrag
-        && [self _isEditable] && [self _hasSelection]
+        && [[self _bridge] isSelectionEditable]
         && !([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask);
 }
 
@@ -5739,7 +5752,14 @@ static DOMRange *unionDOMRanges(DOMRange *a, DOMRange *b)
         else {
             WebView *webView = [self _webView];
             [webView moveDragCaretToPoint:[webView convertPoint:[draggingInfo draggingLocation] fromView:nil]];
-            operation = [self _isMoveDrag] ? NSDragOperationMove : NSDragOperationCopy;
+            NSPoint point = [self convertPoint:[draggingInfo draggingLocation] fromView:nil];
+            NSDictionary *element = [self elementAtPoint:point allowShadowContent:YES];
+            ASSERT(element);
+            WebFrame *innerFrame = (WebFrame *)[element objectForKey:WebElementFrameKey];
+            ASSERT(innerFrame);
+            ASSERT([innerFrame isKindOfClass:[WebFrame class]]);
+            WebHTMLView* innerView = (WebHTMLView *)[[innerFrame frameView] documentView];
+            operation = [innerView _isMoveDrag] ? NSDragOperationMove : NSDragOperationCopy;
         }
     } else
         [[self _webView] removeDragCaret];
@@ -5777,6 +5797,7 @@ static DOMRange *unionDOMRanges(DOMRange *a, DOMRange *b)
     WebFrame *innerFrame = (WebFrame *)[element objectForKey:WebElementFrameKey];
     ASSERT(innerFrame);
     ASSERT([innerFrame isKindOfClass:[WebFrame class]]);
+    WebHTMLView* innerView = (WebHTMLView *)[[innerFrame frameView] documentView];
     WebFrameBridge *innerBridge = [innerFrame _bridge];
 
     if ([self _isNSColorDrag:draggingInfo]) {
@@ -5796,14 +5817,14 @@ static DOMRange *unionDOMRanges(DOMRange *a, DOMRange *b)
     BOOL didInsert = NO;
     if ([self _canProcessDragWithDraggingInfo:draggingInfo]) {
         NSPasteboard *pasteboard = [draggingInfo draggingPasteboard];
-        if ([self _isMoveDrag] || [innerBridge isDragCaretRichlyEditable]) { 
+        if ([innerView _isMoveDrag] || [innerBridge isDragCaretRichlyEditable]) { 
             DOMRange *range = [innerBridge dragCaretDOMRange];
             BOOL chosePlainText;
             DOMDocumentFragment *fragment = [self _documentFragmentFromPasteboard:pasteboard
                 inContext:range allowPlainText:YES chosePlainText:&chosePlainText];
             if (fragment && [self _shouldInsertFragment:fragment replacingDOMRange:range givenAction:WebViewInsertActionDropped]) {
                 [[webView _UIDelegateForwarder] webView:webView willPerformDragDestinationAction:WebDragDestinationActionEdit forDraggingInfo:draggingInfo];
-                if ([self _isMoveDrag]) {
+                if ([innerView _isMoveDrag]) {
                     BOOL smartMove = [innerBridge selectionGranularity] == WebBridgeSelectByWord && [self _canSmartReplaceWithPasteboard:pasteboard];
                     [innerBridge moveSelectionToDragCaret:fragment smartMove:smartMove];
                 } else {
index 7046ee0ce69586e5782b6281311394b8590025a5..769152cb11118345444056354716b03f9c9701ab 100644 (file)
 - (void)_willMakeFirstResponderForNodeFocus;
 - (id<WebHTMLHighlighter>)_highlighterForType:(NSString*)type;
 - (WebFrame *)_frame;
+- (void)_setInitiatedDrag:(BOOL)flag;
+- (BOOL)_initiatedDrag;
 @end