[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

trey trey at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:47:16 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit df6d1a2e6d92199f1d31bbe359e4307542ebe066
Author: trey <trey at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jun 17 08:30:25 2004 +0000

    WebCore:
    
    	3698514 - coordinates in ondragstart and ondrag events are wrong
    
    	This part fixes the ondragstart coords.  We salt away the window-based mouseDown
    	location, since we need that when we dispatch the ondragstart event.  Previously
    	we were errantly using a mouseDown point that had already been converted to view
    	coords, and then the dispatch converted it again.
    
            Reviewed by Maciej.
    
            * kwq/KWQKHTMLPart.h:
            * kwq/KWQKHTMLPart.mm:
            (KWQKHTMLPart::khtmlMouseMoveEvent):  Use window based mouse event coords to dispatch event.
            (KWQKHTMLPart::mouseDown):  Save window based mouse event coords .
    
    WebKit:
    
    	3698514 - coordinates in ondragstart and ondrag events are wrong
    
    	This part fixes the ondrag coords.  I thought Cocoa passed us the mouse location
    	in draggedImage:movedTo:, but no, it's the position of the dragged image.
    	WebCore needs the mouse location, so to calc that we must save away the
    	offset of the mouse relative to the image when we kick off the drag.
    
            Reviewed by Maciej.
    
            * Misc.subproj/WebNSViewExtras.h:
            * Misc.subproj/WebNSViewExtras.m:
            (-[NSView _web_dragImage:rect:event:pasteboard:source:offset:]): Add the ability
    	to return the offset of the cursor wrt to the drag image, since this routine
    	generates its own drag image and positions it.
            * WebView.subproj/WebHTMLView.m:
            (-[WebHTMLView _startDraggingImage:at:operation:event:sourceIsDHTML:DHTMLWroteData:]):
    	Calc the offset of the cursor wrt to the drag image in the myriad of ways
    	that we kick off the drag.
            (-[WebHTMLView draggedImage:movedTo:]):  Adjust the location by the
    	offset we save when we kicked off the drag.
            (-[WebHTMLView draggedImage:endedAt:operation:]):  Ditto.
            * WebView.subproj/WebHTMLViewInternal.h:
            * WebView.subproj/WebImageView.m:
            (-[WebImageView mouseDragged:]):  Pass nil for new arg, we don't care.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6876 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 1796c2c..07658eb 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,19 @@
+2004-06-17  Trey Matteson  <trey at apple.com>
+
+	3698514 - coordinates in ondragstart and ondrag events are wrong
+
+	This part fixes the ondragstart coords.  We salt away the window-based mouseDown
+	location, since we need that when we dispatch the ondragstart event.  Previously
+	we were errantly using a mouseDown point that had already been converted to view
+	coords, and then the dispatch converted it again.
+
+        Reviewed by Maciej.
+
+        * kwq/KWQKHTMLPart.h:
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::khtmlMouseMoveEvent):  Use window based mouse event coords to dispatch event.
+        (KWQKHTMLPart::mouseDown):  Save window based mouse event coords .
+
 2004-06-16  David Hyatt  <hyatt at apple.com>
 
 	Fix for 3596620, implement a subset of CSS3 text truncation for Emerson.
diff --git a/WebCore/kwq/KWQKHTMLPart.h b/WebCore/kwq/KWQKHTMLPart.h
index 98537c9..f3c830b 100644
--- a/WebCore/kwq/KWQKHTMLPart.h
+++ b/WebCore/kwq/KWQKHTMLPart.h
@@ -353,6 +353,8 @@ private:
     bool _sendingEventToSubview;
     bool _mouseDownMayStartDrag;
     bool _mouseDownMayStartSelect;
+    // in our window's coords
+    int _mouseDownWinX, _mouseDownWinY;
     // in our view's coords
     int _mouseDownX, _mouseDownY;
     
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index 5b9f00c..7482959 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -2001,7 +2001,7 @@ void KWQKHTMLPart::khtmlMouseMoveEvent(MouseMoveEvent *event)
                         _dragClipboard->setDragImageElement(_dragSrc, QPoint(_mouseDownX - srcX, _mouseDownY - srcY));
                     }
                     
-                    _mouseDownMayStartDrag = dispatchDragSrcEvent(EventImpl::DRAGSTART_EVENT, QPoint(_mouseDownX, _mouseDownY));
+                    _mouseDownMayStartDrag = dispatchDragSrcEvent(EventImpl::DRAGSTART_EVENT, QPoint(_mouseDownWinX, _mouseDownWinY));
                     // Invalidate clipboard here against anymore pasteboard writing for security.  The drag
                     // image can still be changed as we drag, but not the pasteboard data.
                     _dragClipboard->setAccessPolicy(KWQClipboard::ImageWritable);
@@ -2242,7 +2242,9 @@ void KWQKHTMLPart::mouseDown(NSEvent *event)
     NSEvent *oldCurrentEvent = _currentEvent;
     _currentEvent = KWQRetain(event);
     NSPoint loc = [event locationInWindow];
-    d->m_view->viewportToContents((int)loc.x, (int)loc.y, _mouseDownX, _mouseDownY);
+    _mouseDownWinX = (int)loc.x;
+    _mouseDownWinY = (int)loc.y;
+    d->m_view->viewportToContents(_mouseDownWinX, _mouseDownWinY, _mouseDownX, _mouseDownY);
 
     NSResponder *oldFirstResponderAtMouseDownTime = _firstResponderAtMouseDownTime;
     // Unlike other places in WebCore where we get the first
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 3da5ff7..3dfc160 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,30 @@
+2004-06-17  Trey Matteson  <trey at apple.com>
+
+	3698514 - coordinates in ondragstart and ondrag events are wrong
+
+	This part fixes the ondrag coords.  I thought Cocoa passed us the mouse location
+	in draggedImage:movedTo:, but no, it's the position of the dragged image.
+	WebCore needs the mouse location, so to calc that we must save away the
+	offset of the mouse relative to the image when we kick off the drag.
+
+        Reviewed by Maciej.
+
+        * Misc.subproj/WebNSViewExtras.h:
+        * Misc.subproj/WebNSViewExtras.m:
+        (-[NSView _web_dragImage:rect:event:pasteboard:source:offset:]): Add the ability
+	to return the offset of the cursor wrt to the drag image, since this routine
+	generates its own drag image and positions it.
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView _startDraggingImage:at:operation:event:sourceIsDHTML:DHTMLWroteData:]):
+	Calc the offset of the cursor wrt to the drag image in the myriad of ways
+	that we kick off the drag.	
+        (-[WebHTMLView draggedImage:movedTo:]):  Adjust the location by the
+	offset we save when we kicked off the drag.
+        (-[WebHTMLView draggedImage:endedAt:operation:]):  Ditto.
+        * WebView.subproj/WebHTMLViewInternal.h:
+        * WebView.subproj/WebImageView.m:
+        (-[WebImageView mouseDragged:]):  Pass nil for new arg, we don't care.
+
 2004-06-16  David Hyatt  <hyatt at apple.com>
 
 	In order to support truncation in Emerson, enhance pointToOffset so that it needn't include partial
diff --git a/WebKit/Misc.subproj/WebNSViewExtras.h b/WebKit/Misc.subproj/WebNSViewExtras.h
index feadce6..a456abd 100644
--- a/WebKit/Misc.subproj/WebNSViewExtras.h
+++ b/WebKit/Misc.subproj/WebNSViewExtras.h
@@ -45,5 +45,7 @@
                   rect:(NSRect)rect
                  event:(NSEvent *)event
             pasteboard:(NSPasteboard *)pasteboard 
-                source:(id)source;
+                source:(id)source
+                offset:(NSPoint *)dragImageOffset;
+
 @end
diff --git a/WebKit/Misc.subproj/WebNSViewExtras.m b/WebKit/Misc.subproj/WebNSViewExtras.m
index a398832..47430a1 100644
--- a/WebKit/Misc.subproj/WebNSViewExtras.m
+++ b/WebKit/Misc.subproj/WebNSViewExtras.m
@@ -179,6 +179,7 @@
                  event:(NSEvent *)event
             pasteboard:(NSPasteboard *)pasteboard 
                 source:(id)source
+                offset:(NSPoint *)dragImageOffset
 {
     NSPoint mouseDownPoint = [self convertPoint:[event locationInWindow] fromView:nil];
     NSImage *dragImage;
@@ -211,6 +212,13 @@
         origin = NSMakePoint(mouseDownPoint.x - offset.width, mouseDownPoint.y - offset.height);
     }
 
+    // This is the offset from the lower left corner of the image to the mouse location.  Because we
+    // are a flipped view the calculation of Y is inverted.
+    if (dragImageOffset) {
+        dragImageOffset->x = mouseDownPoint.x - origin.x;
+        dragImageOffset->y = origin.y - mouseDownPoint.y;
+    }
+    
     // Per kwebster, offset arg is ignored
     [self dragImage:dragImage at:origin offset:NSZeroSize event:event pasteboard:pasteboard source:source slideBack:YES];
 }
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index 55d3ff3..19980f8 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -812,6 +812,7 @@ static WebHTMLView *lastHitView = nil;
         } else {
             dragLoc = NSMakePoint(mouseDownPoint.x - wcDragLoc.x, mouseDownPoint.y + wcDragLoc.y);
         }
+        _private->dragOffset = wcDragLoc;
     }
     
     WebView *webView = [self _webView];
@@ -834,7 +835,8 @@ static WebHTMLView *lastHitView = nil;
                             rect:[[element objectForKey:WebElementImageRectKey] rectValue]
                            event:_private->mouseDownEvent
                       pasteboard:pasteboard
-                          source:source];
+                          source:source
+                          offset:&_private->dragOffset];
         } else {
             [self dragImage:dragImage
                          at:dragLoc
@@ -855,6 +857,8 @@ static WebHTMLView *lastHitView = nil;
             dragImage = [self _dragImageForLinkElement:element];
             NSSize offset = NSMakeSize([dragImage size].width / 2, -DRAG_LABEL_BORDER_Y);
             dragLoc = NSMakePoint(mouseDraggedPoint.x - offset.width, mouseDraggedPoint.y - offset.height);
+            _private->dragOffset.x = offset.width;
+            _private->dragOffset.y = -offset.height;        // inverted because we are flipped
         }
         // HACK:  We should pass the mouseDown event instead of the mouseDragged!  This hack gets rid of
         // a flash of the image at the mouseDown location when the drag starts.
@@ -875,6 +879,8 @@ static WebHTMLView *lastHitView = nil;
             [dragImage _web_dissolveToFraction:WebDragImageAlpha];
             NSRect visibleSelectionRect = [[self _bridge] visibleSelectionRect];
             dragLoc = NSMakePoint(NSMinX(visibleSelectionRect), NSMaxY(visibleSelectionRect));
+            _private->dragOffset.x = mouseDownPoint.x - dragLoc.x;
+            _private->dragOffset.y = dragLoc.y - mouseDownPoint.y;        // inverted because we are flipped
         }
         [self dragImage:dragImage
                      at:dragLoc
@@ -893,6 +899,8 @@ static WebHTMLView *lastHitView = nil;
             dragImage = [[[NSImage alloc] initWithContentsOfFile:imagePath] autorelease];
             NSSize imageSize = [dragImage size];
             dragLoc = NSMakePoint(mouseDownPoint.x - imageSize.width/2, mouseDownPoint.y + imageSize.height/2);
+            _private->dragOffset.x = imageSize.width/2;
+            _private->dragOffset.y = imageSize.height/2;        // inverted because we are flipped
         }
         [self dragImage:dragImage
                      at:dragLoc
@@ -1807,14 +1815,16 @@ static WebHTMLView *lastHitView = nil;
 
 - (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenLoc
 {
-    NSPoint windowLoc = [[self window] convertScreenToBase:screenLoc];
-    [[self _bridge] dragSourceMovedTo:windowLoc];
+    NSPoint windowImageLoc = [[self window] convertScreenToBase:screenLoc];
+    NSPoint windowMouseLoc = NSMakePoint(windowImageLoc.x + _private->dragOffset.x, windowImageLoc.y + _private->dragOffset.y);
+    [[self _bridge] dragSourceMovedTo:windowMouseLoc];
 }
 
 - (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
 {
-    NSPoint windowLoc = [[self window] convertScreenToBase:aPoint];
-    [[self _bridge] dragSourceEndedAt:windowLoc operation:operation];
+    NSPoint windowImageLoc = [[self window] convertScreenToBase:aPoint];
+    NSPoint windowMouseLoc = NSMakePoint(windowImageLoc.x + _private->dragOffset.x, windowImageLoc.y + _private->dragOffset.y);
+    [[self _bridge] dragSourceEndedAt:windowMouseLoc operation:operation];
 
     _private->initiatedDrag = NO;
     [[self _webView] _setInitiatedDrag:NO];
@@ -1825,7 +1835,7 @@ static WebHTMLView *lastHitView = nil;
     // Once the dragging machinery kicks in, we no longer get mouse drags or the up event.
     // khtml expects to get balanced down/up's, so we must fake up a mouseup.
     NSEvent *fakeEvent = [NSEvent mouseEventWithType:NSLeftMouseUp
-                                            location:windowLoc
+                                            location:windowMouseLoc
                                        modifierFlags:[[NSApp currentEvent] modifierFlags]
                                            timestamp:[NSDate timeIntervalSinceReferenceDate]
                                         windowNumber:[[self window] windowNumber]
diff --git a/WebKit/WebView.subproj/WebHTMLViewInternal.h b/WebKit/WebView.subproj/WebHTMLViewInternal.h
index 3acf835..7f7643d 100644
--- a/WebKit/WebView.subproj/WebHTMLViewInternal.h
+++ b/WebKit/WebView.subproj/WebHTMLViewInternal.h
@@ -15,6 +15,8 @@
     // Is WebCore handling drag destination duties (DHTML dragging)?
     BOOL webCoreHandlingDrag;
     NSDragOperation webCoreDragOp;
+    // Offset from lower left corner of dragged image to mouse location (when we're the drag source)
+    NSPoint dragOffset;
     
     id savedSubviews;
     BOOL subviewsSetAside;
diff --git a/WebKit/WebView.subproj/WebImageView.m b/WebKit/WebView.subproj/WebImageView.m
index 9cd4066..e2531b5 100644
--- a/WebKit/WebView.subproj/WebImageView.m
+++ b/WebKit/WebView.subproj/WebImageView.m
@@ -261,7 +261,8 @@
                     rect:[self drawingRect]
                    event:mouseDraggedEvent
               pasteboard:pasteboard
-                  source:source];
+                  source:source
+                  offset:NULL];
 }
 
 - (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list