[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
cblu
cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:46:31 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 476537668d7a13b43bb3a356b7520441d839edc9
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jul 9 01:11:58 2003 +0000
Fixed: <rdar://problem/3134494>: no progressive loading for standalone images
Fixed: <rdar://problem/3280633>: exception raised (attempt to create array with nil element) when dragging image out of HTML
Reviewed by rjw.
* Misc.subproj/WebNSViewExtras.h:
* Misc.subproj/WebNSViewExtras.m:
(-[NSView _web_dragPromisedImage:rect:URL:title:event:]): don't take a file type since this can now be gotten from the image
* WebCoreSupport.subproj/WebImageRenderer.h:
* WebCoreSupport.subproj/WebImageRenderer.m:
(-[WebImageRenderer _adjustSizeToPixelDimensions]): new method that rjw factored from incrementalLoadWithBytes:::
(-[WebImageRenderer incrementalLoadWithBytes:length:complete:]): call _adjustSizeToPixelDimensions so we have the correct image size as the image loads
(-[WebImageRenderer MIMEType]): new accessor
* WebView.subproj/WebHTMLViewPrivate.m:
(-[WebHTMLView _handleMouseDragged:]): use renamed _web_dragPromisedImage
* WebView.subproj/WebImageRepresentation.h:
* WebView.subproj/WebImageRepresentation.m:
(-[WebImageRepresentation doneLoading]): new
(-[WebImageRepresentation setDataSource:]): create the image here
(-[WebImageRepresentation receivedData:withDataSource:]): pass data to image
(-[WebImageRepresentation receivedError:withDataSource:]): complete image loading
(-[WebImageRepresentation finishedLoadingWithDataSource:]): complete image loading
* WebView.subproj/WebImageView.h:
* WebView.subproj/WebImageView.m:
(-[WebImageView initWithFrame:]): call setAutoresizingMask so setFrameSize is called often enough
(-[WebImageView dealloc]): tweak
(-[WebImageView haveCompleteImage]): new
(-[WebImageView drawingRect]): new
(-[WebImageView drawRect:]): fill white then draw the image so we never show the previous page
(-[WebImageView setFrameSizeUsingImage]): new, ensures that the view always fills the content area (so we draw over the previous page) and that the view is at least as large as the image.
(-[WebImageView setFrameSize:]): call setFrameSizeUsingImage
(-[WebImageView layout]): call setFrameSizeUsingImage
(-[WebImageView setDataSource:]): store the rep
(-[WebImageView dataSourceUpdated:]): call setNeedsLayout and setNeedsDisplay
(-[WebImageView viewDidMoveToWindow]): tweak
(-[WebImageView validateUserInterfaceItem:]): only allow copy if haveCompleteImage
(-[WebImageView writeImageToPasteboard:]): only writeImageToPasteboard if haveCompleteImage
(-[WebImageView writeSelectionToPasteboard:types:]): tweak
(-[WebImageView menuForEvent:]): tweak
(-[WebImageView mouseDragged:]): only allow drag if haveCompleteImage
(-[WebImageView namesOfPromisedFilesDroppedAtDestination:]): tweak
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4605 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 3c265b8..87254f6 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,47 @@
+2003-07-08 Chris Blumenberg <cblu at apple.com>
+
+ Fixed: <rdar://problem/3134494>: no progressive loading for standalone images
+ Fixed: <rdar://problem/3280633>: exception raised (attempt to create array with nil element) when dragging image out of HTML
+
+ Reviewed by rjw.
+
+ * Misc.subproj/WebNSViewExtras.h:
+ * Misc.subproj/WebNSViewExtras.m:
+ (-[NSView _web_dragPromisedImage:rect:URL:title:event:]): don't take a file type since this can now be gotten from the image
+ * WebCoreSupport.subproj/WebImageRenderer.h:
+ * WebCoreSupport.subproj/WebImageRenderer.m:
+ (-[WebImageRenderer _adjustSizeToPixelDimensions]): new method that rjw factored from incrementalLoadWithBytes:::
+ (-[WebImageRenderer incrementalLoadWithBytes:length:complete:]): call _adjustSizeToPixelDimensions so we have the correct image size as the image loads
+ (-[WebImageRenderer MIMEType]): new accessor
+ * WebView.subproj/WebHTMLViewPrivate.m:
+ (-[WebHTMLView _handleMouseDragged:]): use renamed _web_dragPromisedImage
+ * WebView.subproj/WebImageRepresentation.h:
+ * WebView.subproj/WebImageRepresentation.m:
+ (-[WebImageRepresentation doneLoading]): new
+ (-[WebImageRepresentation setDataSource:]): create the image here
+ (-[WebImageRepresentation receivedData:withDataSource:]): pass data to image
+ (-[WebImageRepresentation receivedError:withDataSource:]): complete image loading
+ (-[WebImageRepresentation finishedLoadingWithDataSource:]): complete image loading
+ * WebView.subproj/WebImageView.h:
+ * WebView.subproj/WebImageView.m:
+ (-[WebImageView initWithFrame:]): call setAutoresizingMask so setFrameSize is called often enough
+ (-[WebImageView dealloc]): tweak
+ (-[WebImageView haveCompleteImage]): new
+ (-[WebImageView drawingRect]): new
+ (-[WebImageView drawRect:]): fill white then draw the image so we never show the previous page
+ (-[WebImageView setFrameSizeUsingImage]): new, ensures that the view always fills the content area (so we draw over the previous page) and that the view is at least as large as the image.
+ (-[WebImageView setFrameSize:]): call setFrameSizeUsingImage
+ (-[WebImageView layout]): call setFrameSizeUsingImage
+ (-[WebImageView setDataSource:]): store the rep
+ (-[WebImageView dataSourceUpdated:]): call setNeedsLayout and setNeedsDisplay
+ (-[WebImageView viewDidMoveToWindow]): tweak
+ (-[WebImageView validateUserInterfaceItem:]): only allow copy if haveCompleteImage
+ (-[WebImageView writeImageToPasteboard:]): only writeImageToPasteboard if haveCompleteImage
+ (-[WebImageView writeSelectionToPasteboard:types:]): tweak
+ (-[WebImageView menuForEvent:]): tweak
+ (-[WebImageView mouseDragged:]): only allow drag if haveCompleteImage
+ (-[WebImageView namesOfPromisedFilesDroppedAtDestination:]): tweak
+
2003-07-08 Dave Hyatt <hyatt at apple.com>
Change minimum font size pref value back to 9. This change
diff --git a/WebKit/Misc.subproj/WebNSViewExtras.h b/WebKit/Misc.subproj/WebNSViewExtras.h
index 41b69ef..0fcc3cd 100644
--- a/WebKit/Misc.subproj/WebNSViewExtras.h
+++ b/WebKit/Misc.subproj/WebNSViewExtras.h
@@ -8,6 +8,7 @@
#define WebDragImageAlpha 0.75
@class WebFrameView;
+ at class WebImageRenderer;
@interface NSView (WebExtras)
@@ -39,11 +40,9 @@
- (NSDragOperation)_web_dragOperationForDraggingInfo:(id <NSDraggingInfo>)sender;
// Resizes and applies alpha to image, extends pboard and sets drag origins for dragging promised image files.
-- (void)_web_dragPromisedImage:(NSImage *)image
+- (void)_web_dragPromisedImage:(WebImageRenderer *)image
rect:(NSRect)rect
URL:(NSURL *)URL
- fileType:(NSString *)fileType
title:(NSString *)title
event:(NSEvent *)event;
-
@end
diff --git a/WebKit/Misc.subproj/WebNSViewExtras.m b/WebKit/Misc.subproj/WebNSViewExtras.m
index 4d25005..44d0f1b 100644
--- a/WebKit/Misc.subproj/WebNSViewExtras.m
+++ b/WebKit/Misc.subproj/WebNSViewExtras.m
@@ -4,12 +4,14 @@
*/
#import <WebKit/WebFrameView.h>
+#import <WebKit/WebImageRenderer.h>
#import <WebKit/WebNSImageExtras.h>
#import <WebKit/WebNSPasteboardExtras.h>
#import <WebKit/WebNSViewExtras.h>
#import <Foundation/NSString_NSURLExtras.h>
#import <Foundation/NSURL_NSURLExtras.h>
+#import <Foundation/NSURLFileTypeMappings.h>
#define WebDragStartHysteresisX 5.0
#define WebDragStartHysteresisY 5.0
@@ -175,10 +177,9 @@
}
#endif
-- (void)_web_dragPromisedImage:(NSImage *)image
+- (void)_web_dragPromisedImage:(WebImageRenderer *)image
rect:(NSRect)rect
URL:(NSURL *)URL
- fileType:(NSString *)fileType
title:(NSString *)title
event:(NSEvent *)event
{
@@ -187,6 +188,15 @@
NSPoint origin;
NSSize offset;
+ NSString *MIMEType = [image MIMEType];
+ NSString *fileType = nil;
+ if (MIMEType && ![MIMEType isEqualToString:@"application/octet-stream"]) {
+ fileType = [[NSURLFileTypeMappings sharedMappings] preferredExtensionForMIMEType:MIMEType];
+ }
+ if (!fileType) {
+ fileType = @"";
+ }
+
if ([image size].height * [image size].width <= WebMaxOriginalImageArea) {
NSSize originalSize = rect.size;
origin = rect.origin;
diff --git a/WebKit/WebCoreSupport.subproj/WebImageRenderer.h b/WebKit/WebCoreSupport.subproj/WebImageRenderer.h
index 285613d..ac7e939 100644
--- a/WebKit/WebCoreSupport.subproj/WebImageRenderer.h
+++ b/WebKit/WebCoreSupport.subproj/WebImageRenderer.h
@@ -33,4 +33,6 @@
- (id)initWithData:(NSData *)data MIMEType:(NSString *)MIME;
+ (void)stopAnimationsInView:(NSView *)aView;
+- (NSString *)MIMEType;
+
@end
diff --git a/WebKit/WebCoreSupport.subproj/WebImageRenderer.m b/WebKit/WebCoreSupport.subproj/WebImageRenderer.m
index c97b7cf..43b9732 100644
--- a/WebKit/WebCoreSupport.subproj/WebImageRenderer.m
+++ b/WebKit/WebCoreSupport.subproj/WebImageRenderer.m
@@ -149,11 +149,21 @@ static NSMutableArray *activeImageRenderers;
return isNull;
}
+- (void)_adjustSizeToPixelDimensions
+{
+ // Force the image to use the pixel size and ignore the dpi.
+ // Ignore any absolute size in the image and always use pixel dimensions.
+ NSBitmapImageRep *imageRep = [[self representations] objectAtIndex:0];
+ NSSize size = NSMakeSize([imageRep pixelsWide], [imageRep pixelsHigh]);
+ [self setCacheMode: NSImageCacheDefault];
+ [imageRep setSize:size];
+ [self setSize:size];
+}
+
- (BOOL)incrementalLoadWithBytes:(const void *)bytes length:(unsigned)length complete:(BOOL)isComplete
{
NSBitmapImageRep *imageRep = [[self representations] objectAtIndex:0];
NSData *data = [[NSData alloc] initWithBytes:bytes length:length];
- NSSize size;
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
// Part of the workaround for bug 3090341.
@@ -180,17 +190,11 @@ static NSMutableArray *activeImageRenderers;
return NO;
case NSImageRepLoadStatusCompleted: // all is well, the full pixelsHigh image is valid.
//printf ("NSImageRepLoadStatusUnexpectedEOF size %d, isComplete %d\n", length, isComplete);
- // Force the image to use the pixel size and ignore the dpi.
- size = NSMakeSize([imageRep pixelsWide], [imageRep pixelsHigh]);
- [self setCacheMode: NSImageCacheDefault];
- [imageRep setSize:size];
-
- // Ignore any absolute size in the image and always use pixel dimensions.
- [self setSize:size];
-
+ [self _adjustSizeToPixelDimensions];
isNull = NO;
return YES;
default:
+ [self _adjustSizeToPixelDimensions];
//printf ("incrementalLoadWithBytes: size %d, isComplete %d\n", length, isComplete);
// We have some valid data. Return YES so we can attempt to draw what we've got.
isNull = NO;
@@ -458,4 +462,9 @@ static NSMutableArray *activeImageRenderers;
return [super size];
}
+- (NSString *)MIMEType
+{
+ return MIMEType;
+}
+
@end
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.m b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
index 10348b0..e365555 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.m
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
@@ -528,10 +528,11 @@ static WebHTMLView *lastHitView = nil;
if (imageURL) {
_private->draggingImageURL = [imageURL retain];
- [self _web_dragPromisedImage:[element objectForKey:WebElementImageKey]
+ WebImageRenderer *image = [element objectForKey:WebElementImageKey];
+ ASSERT([image isKindOfClass:[WebImageRenderer class]]);
+ [self _web_dragPromisedImage:image
rect:[[element objectForKey:WebElementImageRectKey] rectValue]
URL:linkURL ? linkURL : imageURL
- fileType:[[imageURL path] pathExtension]
title:[element objectForKey:WebElementImageAltStringKey]
event:_private->mouseDownEvent];
diff --git a/WebKit/WebView.subproj/WebImageRepresentation.h b/WebKit/WebView.subproj/WebImageRepresentation.h
index 9aa4d73..4c23afa 100644
--- a/WebKit/WebView.subproj/WebImageRepresentation.h
+++ b/WebKit/WebView.subproj/WebImageRepresentation.h
@@ -11,8 +11,10 @@
@interface WebImageRepresentation : NSObject <WebDocumentRepresentation>
{
WebImageRenderer *image;
+ BOOL doneLoading;
NSURL *URL;
}
- (WebImageRenderer *)image;
+- (BOOL)doneLoading;
- (NSURL *)URL;
@end
diff --git a/WebKit/WebView.subproj/WebImageRepresentation.m b/WebKit/WebView.subproj/WebImageRepresentation.m
index 11241f8..ecef129 100644
--- a/WebKit/WebView.subproj/WebImageRepresentation.m
+++ b/WebKit/WebView.subproj/WebImageRepresentation.m
@@ -18,16 +18,6 @@
@implementation WebImageRepresentation
-- init
-{
- self = [super init];
- if (self) {
- //image = [[WebImageRenderer alloc] init];
- }
- return self;
-}
-
-
- (void)dealloc
{
[image release];
@@ -45,26 +35,37 @@
return URL;
}
+- (BOOL)doneLoading
+{
+ return doneLoading;
+}
+
- (void)setDataSource:(WebDataSource *)dataSource
{
URL = [[[dataSource request] URL] retain];
+ image = [[[WebImageRendererFactory sharedFactory] imageRendererWithMIMEType:[[dataSource response] MIMEType]] retain];
}
- (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)dataSource
{
- //[image incrementalLoadWithBytes:[data bytes] length:[data length] complete:isComplete];
+ NSData *allData = [dataSource data];
+ [image incrementalLoadWithBytes:[allData bytes] length:[allData length] complete:NO];
}
- (void)receivedError:(NSError *)error withDataSource:(WebDataSource *)dataSource
{
-
+ NSData *allData = [dataSource data];
+ if ([allData length] > 0) {
+ [image incrementalLoadWithBytes:[allData bytes] length:[allData length] complete:YES];
+ }
+ doneLoading = YES;
}
- (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource
{
- NSData *resourceData = [dataSource data];
- image = [[[WebImageRendererFactory sharedFactory] imageRendererWithBytes:[resourceData bytes]
- length:[resourceData length]] retain];
+ NSData *allData = [dataSource data];
+ [image incrementalLoadWithBytes:[allData bytes] length:[allData length] complete:YES];
+ doneLoading = YES;
}
- (BOOL)canProvideDocumentSource
diff --git a/WebKit/WebView.subproj/WebImageView.h b/WebKit/WebView.subproj/WebImageView.h
index fefd1a1..72667b2 100644
--- a/WebKit/WebView.subproj/WebImageView.h
+++ b/WebKit/WebView.subproj/WebImageView.h
@@ -7,14 +7,11 @@
@class WebImageRepresentation;
@protocol WebDocumentView;
- at protocol WebDocumentDragSettings;
@interface WebImageView : NSView <WebDocumentView>
{
- WebImageRepresentation *representation;
+ WebImageRepresentation *rep;
BOOL needsLayout;
}
-
+ (NSArray *)supportedImageMIMETypes;
-
@end
diff --git a/WebKit/WebView.subproj/WebImageView.m b/WebKit/WebView.subproj/WebImageView.m
index 80b8c46..504cc4e 100644
--- a/WebKit/WebView.subproj/WebImageView.m
+++ b/WebKit/WebView.subproj/WebImageView.m
@@ -33,62 +33,88 @@
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
+ [self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
return self;
}
- (void)dealloc
{
- [[representation image] stopAnimation];
- [representation release];
+ [[rep image] stopAnimation];
+ [rep release];
[super dealloc];
}
+- (BOOL)haveCompleteImage
+{
+ NSSize imageSize = [[rep image] size];
+ return [rep doneLoading] && imageSize.width > 0 && imageSize.width > 0;
+}
+
- (BOOL)isFlipped
{
return YES;
}
+- (NSRect)drawingRect
+{
+ NSSize imageSize = [[rep image] size];
+ return NSMakeRect(0, 0, imageSize.width, imageSize.height);
+}
+
- (void)drawRect:(NSRect)rect
{
if (needsLayout) {
[self layout];
}
- NSImage *image = [representation image];
- if (image) {
- [[representation image] beginAnimationInRect:[self frame] fromRect:[self frame]];
- } else {
- [[NSColor whiteColor] set];
- NSRectFill(rect);
- }
+ [[NSColor whiteColor] set];
+ NSRectFill(rect);
+
+ NSRect drawingRect = [self drawingRect];
+ [[rep image] beginAnimationInRect:drawingRect fromRect:drawingRect];
}
-- (void)setDataSource:(WebDataSource *)dataSource
+// Ensures that the view always fills the content area (so we draw over the previous page)
+// and that the view is at least as large as the image.
+- (void)setFrameSizeUsingImage
{
- representation = [[dataSource representation] retain];
+ NSSize size = [[self _web_superviewOfClass:[NSClipView class]] frame].size;
+ NSSize imageSize = [[rep image] size];
+ size.width = MAX(size.width, imageSize.width);
+ size.height = MAX(size.height, imageSize.height);
+ [super setFrameSize:size];
}
-- (void)dataSourceUpdated:(WebDataSource *)dataSource
+- (void)setFrameSize:(NSSize)size
{
+ [self setFrameSizeUsingImage];
}
-- (void)setNeedsLayout: (BOOL)flag
+- (void)layout
{
- needsLayout = flag;
+ [self setFrameSizeUsingImage];
+ needsLayout = NO;
}
-- (void)layout
+- (void)setDataSource:(WebDataSource *)dataSource
{
- WebImageRenderer *image = [representation image];
- if (image) {
- [self setFrameSize:[image size]];
- } else {
- NSRect superFrame = [[self _web_superviewOfClass:[WebFrameView class]] frame];
- [self setFrame:NSMakeRect(0, 0, NSWidth(superFrame), NSHeight(superFrame))];
+ ASSERT(!rep);
+ rep = [[dataSource representation] retain];
+}
+
+- (void)dataSourceUpdated:(WebDataSource *)dataSource
+{
+ NSSize imageSize = [[rep image] size];
+ if (imageSize.width > 0 && imageSize.height > 0) {
+ [self setNeedsLayout:YES];
+ [self setNeedsDisplay:YES];
}
-
- needsLayout = NO;
+}
+
+- (void)setNeedsLayout: (BOOL)flag
+{
+ needsLayout = flag;
}
- (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow
@@ -104,7 +130,7 @@
- (void)viewDidMoveToWindow
{
if (![self window]){
- [[representation image] stopAnimation];
+ [[rep image] stopAnimation];
}
[super viewDidMoveToWindow];
@@ -118,7 +144,7 @@
- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
{
if ([item action] == @selector(copy:)){
- return ([representation image] != nil);
+ return [self haveCompleteImage];
}
return YES;
@@ -133,14 +159,17 @@
return [super validRequestorForSendType:sendType returnType:returnType];
}
-- (void)writeImageToPasteboard:(NSPasteboard *)pasteboard
+- (BOOL)writeImageToPasteboard:(NSPasteboard *)pasteboard
{
- NSData *TIFFData = [[representation image] TIFFRepresentation];
+ NSData *TIFFData = [self haveCompleteImage] ? [[rep image] TIFFRepresentation] : nil;
- if(TIFFData){
+ if (TIFFData) {
[pasteboard declareTypes:[NSArray arrayWithObject:NSTIFFPboardType] owner:nil];
[pasteboard setData:TIFFData forType:NSTIFFPboardType];
+ return YES;
}
+
+ return NO;
}
- (void)copy:(id)sender
@@ -150,8 +179,7 @@
- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)types
{
- [self writeImageToPasteboard:pasteboard];
- return YES;
+ return [self writeImageToPasteboard:pasteboard];
}
- (NSMenu *)menuForEvent:(NSEvent *)theEvent
@@ -164,9 +192,9 @@
ASSERT(webView);
NSDictionary *element = [NSDictionary dictionaryWithObjectsAndKeys:
- [representation image], WebElementImageKey,
+ [rep image], WebElementImageKey,
[NSValue valueWithRect:[self bounds]], WebElementImageRectKey,
- [representation URL], WebElementImageURLKey,
+ [rep URL], WebElementImageURLKey,
[NSNumber numberWithBool:NO], WebElementIsSelectedKey,
frame, WebElementFrameKey, nil];
@@ -175,23 +203,26 @@
- (void)mouseDragged:(NSEvent *)event
{
+ if (![self haveCompleteImage]) {
+ return;
+ }
+
// Don't allow drags to be accepted by this WebFrameView.
[[[self _web_parentWebFrameView] _webView] unregisterDraggedTypes];
// Retain this view during the drag because it may be released before the drag ends.
[self retain];
- [self _web_dragPromisedImage:[representation image]
- rect:[self bounds]
- URL:[representation URL]
- fileType:[[[representation URL] path] pathExtension]
+ [self _web_dragPromisedImage:[rep image]
+ rect:[self drawingRect]
+ URL:[rep URL]
title:nil
event:event];
}
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
{
- NSURL *URL = [representation URL];
+ NSURL *URL = [rep URL];
[[self webView] _downloadURL:URL toDirectory:[dropDestination path]];
// FIXME: The file is supposed to be created at this point so the Finder places the file
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list