[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:44:36 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit e51ab60271cac5b5e4571c3393a82dca17332916
Author: trey <trey at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jun 8 22:17:43 2004 +0000

    WebCore:
    
    	A DHTML drag source can now change the dragging image during the drag.  Currently
    	it may only be set to a static image.
    
            Reviewed by John
    
            * kwq/KWQKHTMLPart.mm:
            (KWQKHTMLPart::dragSourceMovedTo):  If the ondrag event handler set an image,
    	pass it to WebKit.
            * kwq/WebCoreBridge.h:
    
    WebKit:
    
    	A DHTML drag source can now change the dragging image during the drag.  Currently
    	it may only be set to a static image.
    
            Reviewed by John
    
            * WebCoreSupport.subproj/WebBridge.m:
            (-[WebBridge setDraggingImage:at:]):  Typical bridge glue.
            * WebView.subproj/WebHTMLView.m:
            (FlipImageSpec):  New utility, copied from AppKit.
            (-[WebHTMLView _setDraggingImage:at:]):  Mostly copied from AppKit.  Sets the drag
    	image using CG API.
            * WebView.subproj/WebHTMLViewPrivate.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6795 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 1d6501c..70ff7e1 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,15 @@
+2004-06-08  Trey Matteson  <trey at apple.com>
+
+	A DHTML drag source can now change the dragging image during the drag.  Currently
+	it may only be set to a static image.
+
+        Reviewed by John
+
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::dragSourceMovedTo):  If the ondrag event handler set an image,
+	pass it to WebKit.
+        * kwq/WebCoreBridge.h:
+
 2004-06-08  Ken Kocienda  <kocienda at apple.com>
 
         Reviewed by Hyatt
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index 79c9ebe..d0c862c 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -2033,8 +2033,13 @@ void KWQKHTMLPart::khtmlMouseMoveEvent(MouseMoveEvent *event)
 void KWQKHTMLPart::dragSourceMovedTo(const QPoint &loc)
 {
     if (!_dragSrc.isNull()) {
+        NSImage *dragImage = nil;
+        NSPoint dragLoc = NSZeroPoint;
         // for now we don't care if event handler cancels default behavior, since there is none
-        dispatchDragSrcEvent(EventImpl::DRAG_EVENT, loc, false, NULL, NULL, NULL);
+        dispatchDragSrcEvent(EventImpl::DRAG_EVENT, loc, false, &dragImage, &dragLoc, NULL);
+        if (dragImage) {
+            [_bridge setDraggingImage:dragImage at:dragLoc];
+        }
     }
 }
 
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 2fed699..59bfd25 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -428,6 +428,7 @@ typedef enum {
 - (NSString *)MIMETypeForPath:(NSString *)path;
 
 - (BOOL)startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc operation:(NSDragOperation)op event:(NSEvent *)event;
+- (void)setDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc;
 - (void)handleAutoscrollForMouseDragged:(NSEvent *)event;
 - (BOOL)mayStartDragWithMouseDragged:(NSEvent *)event;
 
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index c9bd3d4..0217865 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,18 @@
+2004-06-08  Trey Matteson  <trey at apple.com>
+
+	A DHTML drag source can now change the dragging image during the drag.  Currently
+	it may only be set to a static image.
+
+        Reviewed by John
+
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge setDraggingImage:at:]):  Typical bridge glue.
+        * WebView.subproj/WebHTMLView.m:
+        (FlipImageSpec):  New utility, copied from AppKit.
+        (-[WebHTMLView _setDraggingImage:at:]):  Mostly copied from AppKit.  Sets the drag
+	image using CG API.
+        * WebView.subproj/WebHTMLViewPrivate.h:
+
 2004-06-08  Chris Blumenberg  <cblu at apple.com>
 
 	Fixed: <rdar://problem/3640423>: (REGRESSION: can't paste text copied from web page into Excel (due to HTML on the pasteboard?))
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.m b/WebKit/WebCoreSupport.subproj/WebBridge.m
index 9554480..564439c 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.m
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.m
@@ -994,6 +994,13 @@ static BOOL loggedObjectCacheSize = NO;
     return [docView _startDraggingImage:dragImage at:dragLoc operation:op event:event];
 }
 
+- (void)setDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc
+{
+    WebHTMLView *docView = (WebHTMLView *)[[_frame frameView] documentView];
+    ASSERT([docView isKindOfClass:[WebHTMLView class]]);
+    [docView _setDraggingImage:dragImage at:dragLoc];
+}
+
 - (void)handleAutoscrollForMouseDragged:(NSEvent *)event;
 {
     WebHTMLView *docView = (WebHTMLView *)[[_frame frameView] documentView];
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index 676f66b..ad04f95 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -51,6 +51,9 @@
 
 #import <CoreGraphics/CGContextGState.h>
 
+#import <HIServices/CoreDrag.h>
+#import <HIServices/CoreDragPriv.h>
+
 #define TextDragDelay                    0.15
 
 // By imaging to a width a little wider than the available pixels,
@@ -884,6 +887,95 @@ static WebHTMLView *lastHitView = nil;
     return YES;
 }
 
+static void FlipImageSpec(CoreDragImageSpec* imageSpec) {    
+    // run through and swap each row. we'll need a temporary row to hold the swapped row
+    //
+    unsigned char* tempRow = malloc(imageSpec->bytesPerRow);
+    int            planes  = imageSpec->isPlanar ? imageSpec->samplesPerPixel : 1;
+    
+    int p;
+    for (p = 0; p < planes; p++) {
+	unsigned char* topRow = (unsigned char*)imageSpec->data[p];
+	unsigned char* botRow = topRow + (imageSpec->pixelsHigh - 1) * imageSpec->bytesPerRow;
+	int i;
+	for (i = 0; i < imageSpec->pixelsHigh / 2; i++, topRow += imageSpec->bytesPerRow, botRow -= imageSpec->bytesPerRow) {
+	    bcopy(topRow,  tempRow, imageSpec->bytesPerRow);
+	    bcopy(botRow,  topRow,  imageSpec->bytesPerRow);
+	    bcopy(tempRow, botRow,  imageSpec->bytesPerRow);
+	}
+    }
+    free(tempRow);
+}
+
+// Dashboard wants to set the drag image during dragging, but Cocoa does not allow this.  Instead we drop
+// down to the CG API.  Converting an NSImage to a CGImageSpec is copied from NSDragManager.
+- (void)_setDraggingImage:(NSImage *)image at:(NSPoint)offset
+{
+    NSSize 		imageSize = [image size];
+    CGPoint             imageOffset = {-offset.x, -(imageSize.height - offset.y)};
+    CGRect		imageRect= CGRectMake(0, 0, imageSize.width, imageSize.height);
+    NSBitmapImageRep 	*bitmapImage;
+    CoreDragImageSpec	imageSpec;
+    CGSRegionObj 	imageShape;
+    BOOL                flipImage;
+    OSStatus		error;
+    
+    // if the image contains an NSBitmapImageRep, we are done
+    bitmapImage = (NSBitmapImageRep *)[image bestRepresentationForDevice:nil];    
+    if (bitmapImage == nil || ![bitmapImage isKindOfClass:[NSBitmapImageRep class]] || !NSEqualSizes([bitmapImage size], imageSize)) {
+        // otherwise we need to render the image and get the bitmap data from it
+        [image lockFocus];
+        bitmapImage = [[NSBitmapImageRep alloc] initWithFocusedViewRect:*(NSRect *)&imageRect];
+        [image unlockFocus];
+        
+	// we may have to flip the bits we just read if the iamge was flipped since it means the cache was also
+	// and CoreDragSetImage can't take a transform for rendering.
+	flipImage = [image isFlipped];
+        
+    } else {
+        flipImage = NO;
+        [bitmapImage retain];
+    }
+    ASSERT_WITH_MESSAGE(bitmapImage, "dragging image does not contain bitmap");
+
+    imageSpec.version = kCoreDragImageSpecVersionOne;
+    imageSpec.pixelsWide = [bitmapImage pixelsWide];
+    imageSpec.pixelsHigh = [bitmapImage pixelsHigh];
+    imageSpec.bitsPerSample = [bitmapImage bitsPerSample];
+    imageSpec.samplesPerPixel = [bitmapImage samplesPerPixel];
+    imageSpec.bitsPerPixel = [bitmapImage bitsPerPixel];
+    imageSpec.bytesPerRow = [bitmapImage bytesPerRow];
+    imageSpec.isPlanar = [bitmapImage isPlanar];
+    imageSpec.hasAlpha = [bitmapImage hasAlpha];
+    [bitmapImage getBitmapDataPlanes:(unsigned char **)imageSpec.data];
+    
+    // if image was flipped, we have an upside down bitmap since the cache is rendered flipped
+    //
+    if (flipImage) {
+	FlipImageSpec(&imageSpec);
+    }
+    
+    error = CGSNewRegionWithRect(&imageRect, &imageShape);
+    ASSERT_WITH_MESSAGE(error == kCGErrorSuccess, "Error getting shape for image: %d", error);
+    if (error != kCGErrorSuccess) {
+        [bitmapImage release];
+        return;
+    }
+    
+    // make sure image has integer offset
+    //
+    imageOffset.x = floor(imageOffset.x + 0.5);
+    imageOffset.y = floor(imageOffset.y + 0.5);
+    
+    // TODO: what is overallAlpha for window?
+    error = CoreDragSetImage(CoreDragGetCurrentDrag(), imageOffset, &imageSpec, imageShape, 1.0);
+    CGSReleaseRegion(imageShape);
+    ASSERT_WITH_MESSAGE(error == kCGErrorSuccess, "Error setting image for drag: %d", error);
+    
+    [bitmapImage release];
+}
+
+
 - (void)_handleAutoscrollForMouseDragged:(NSEvent *)event
 {
     [self autoscroll:event];
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.h b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
index d00a486..667fe20 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.h
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
@@ -46,6 +46,7 @@
 
 - (NSImage *)_dragImageForLinkElement:(NSDictionary *)element;
 - (BOOL)_startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc operation:(NSDragOperation)op event:(NSEvent *)event;
+- (void)_setDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc;
 - (void)_handleAutoscrollForMouseDragged:(NSEvent *)event;
 - (BOOL)_mayStartDragWithMouseDragged:(NSEvent *)event;
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list