[webkit-changes] cvs commit: WebKit/WebCoreSupport.subproj WebGraphicsBridge.h WebGraphicsBridge.m WebImageData.m WebImageRenderer.h WebImageRenderer.m WebImageRendererFactory.m

Darin darin at opensource.apple.com
Tue Aug 16 10:36:39 PDT 2005


darin       05/08/16 10:36:38

  Modified:    .        ChangeLog
               kwq      KWQKHTMLPart.mm WebCoreGraphicsBridge.h
                        WebCoreGraphicsBridge.m
               .        ChangeLog
               WebCoreSupport.subproj WebGraphicsBridge.h
                        WebGraphicsBridge.m WebImageData.m
                        WebImageRenderer.h WebImageRenderer.m
                        WebImageRendererFactory.m
  Log:
  WebCore:
  
          Reviewed by Beth Dakin.
  
          - removed some unnecessary code
  
          * kwq/KWQKHTMLPart.mm: (KWQKHTMLPart::imageFromRect): Remove code to call
          setAdditionalPatternPhase since that is no longer needed.
  
          * kwq/WebCoreGraphicsBridge.h: Remove unused setAdditionalPatternPhase,
          createRGBColorSpace, createGrayColorSpace, and createCMYKColorSpace methods.
          * kwq/WebCoreGraphicsBridge.m: Ditto.
  
  WebKit:
  
          Reviewed by Beth Dakin.
  
          - removed some unnecessary code
  
          * WebCoreSupport.subproj/WebGraphicsBridge.h: Removed pattern-phase related field and methods.
          * WebCoreSupport.subproj/WebGraphicsBridge.m: Ditto.
  
          * WebCoreSupport.subproj/WebImageData.m: Tweaked formatting and removed some unused code
          inside #if and comments.
  
          * WebCoreSupport.subproj/WebImageRenderer.h: Removed USE_CGIMAGEREF (which is always true now).
          * WebCoreSupport.subproj/WebImageRenderer.m: Removed old non-CGImageRef code.
  
          * WebCoreSupport.subproj/WebImageRendererFactory.m:
          (-[WebImageRendererFactory imageRendererWithMIMEType:]): Removed non-USE_CGIMAGEREF code.
          (-[WebImageRendererFactory imageRendererWithData:MIMEType:]): Ditto.
          (-[WebImageRendererFactory imageRendererWithSize:]): Ditto.
          (-[WebImageRendererFactory imageRendererWithName:]): Ditto.
  
  Revision  Changes    Path
  1.4585    +13 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.4584
  retrieving revision 1.4585
  diff -u -r1.4584 -r1.4585
  --- ChangeLog	16 Aug 2005 09:17:29 -0000	1.4584
  +++ ChangeLog	16 Aug 2005 17:36:24 -0000	1.4585
  @@ -1,3 +1,16 @@
  +2005-08-16  Darin Adler  <darin at apple.com>
  +
  +        Reviewed by Beth Dakin.
  +
  +        - removed some unnecessary code
  +
  +        * kwq/KWQKHTMLPart.mm: (KWQKHTMLPart::imageFromRect): Remove code to call
  +        setAdditionalPatternPhase since that is no longer needed.
  +
  +        * kwq/WebCoreGraphicsBridge.h: Remove unused setAdditionalPatternPhase,
  +        createRGBColorSpace, createGrayColorSpace, and createCMYKColorSpace methods.
  +        * kwq/WebCoreGraphicsBridge.m: Ditto.
  +
   2005-08-16  Eric Seidel  <eseidel at apple.com>
           Fix by Tobias Lidskog <tobiaslidskog at mac.com>
   
  
  
  
  1.660     +4 -16     WebCore/kwq/KWQKHTMLPart.mm
  
  Index: KWQKHTMLPart.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQKHTMLPart.mm,v
  retrieving revision 1.659
  retrieving revision 1.660
  diff -u -r1.659 -r1.660
  --- KWQKHTMLPart.mm	14 Aug 2005 09:12:44 -0000	1.659
  +++ KWQKHTMLPart.mm	16 Aug 2005 17:36:32 -0000	1.660
  @@ -3398,24 +3398,12 @@
           [resultImage setFlipped:YES];
           [resultImage lockFocus];
   
  -        [NSGraphicsContext saveGraphicsState];
  -        NSPoint translation = { -(NSMinX(rect) - NSMinX(bounds)), -(NSMinY(rect) - NSMinY(bounds)) };
  -        CGContextTranslateCTM((CGContext *)[[NSGraphicsContext currentContext] graphicsPort], translation.x, translation.y);
  -
  -        // We change the coord system at the CG level, out from under the AK focus machinery, because it doesn't
  -        // work to change the coord system of a focused view.  However, WebImageRenderer uses the difference
  -        // between the focused view's coord system and the window's coord system to adjust the pattern phase, and
  -        // that calc ignores our translation.  So we must tell it about this extra phase offset.
  -
  -        // Window is not flipped, we are, so y coord must be inverted when describing phase, which is a
  -        // window level notion.
  -        translation.y = -translation.y;
  -        [[WebCoreGraphicsBridge sharedBridge] setAdditionalPatternPhase:translation];
  +        CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
   
  +        CGContextSaveGState(context);
  +        CGContextTranslateCTM(context, bounds.origin.x - rect.origin.x, bounds.origin.y - rect.origin.y);
           [view drawRect:rect];
  -
  -        [[WebCoreGraphicsBridge sharedBridge] setAdditionalPatternPhase:NSZeroPoint];
  -        [NSGraphicsContext restoreGraphicsState];
  +        CGContextRestoreGState(context);
   
           [resultImage unlockFocus];
           [resultImage setFlipped:NO];
  
  
  
  1.6       +0 -5      WebCore/kwq/WebCoreGraphicsBridge.h
  
  Index: WebCoreGraphicsBridge.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/WebCoreGraphicsBridge.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- WebCoreGraphicsBridge.h	14 Oct 2004 01:26:53 -0000	1.5
  +++ WebCoreGraphicsBridge.h	16 Aug 2005 17:36:32 -0000	1.6
  @@ -30,10 +30,5 @@
   + (WebCoreGraphicsBridge *)sharedBridge;
   - (void)setFocusRingStyle:(NSFocusRingPlacement)placement radius:(int)radius color:(NSColor *)color;
   - (void)setDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc;
  -- (void)setAdditionalPatternPhase:(NSPoint)phase;
  -
  -- (CGColorSpaceRef)createRGBColorSpace;
  -- (CGColorSpaceRef)createGrayColorSpace;
  -- (CGColorSpaceRef)createCMYKColorSpace;
   
   @end
  
  
  
  1.6       +0 -19     WebCore/kwq/WebCoreGraphicsBridge.m
  
  Index: WebCoreGraphicsBridge.m
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/WebCoreGraphicsBridge.m,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- WebCoreGraphicsBridge.m	14 Oct 2004 01:26:53 -0000	1.5
  +++ WebCoreGraphicsBridge.m	16 Aug 2005 17:36:32 -0000	1.6
  @@ -54,23 +54,4 @@
   {
   }
   
  -- (void)setAdditionalPatternPhase:(NSPoint)phase
  -{
  -}
  -
  -- (CGColorSpaceRef)createRGBColorSpace
  -{
  -    return 0;
  -}
  -
  -- (CGColorSpaceRef)createGrayColorSpace
  -{
  -    return 0;
  -}
  -
  -- (CGColorSpaceRef)createCMYKColorSpace
  -{
  -    return 0;
  -}
  -
   @end
  
  
  
  1.3291    +21 -0     WebKit/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebKit/ChangeLog,v
  retrieving revision 1.3290
  retrieving revision 1.3291
  diff -u -r1.3290 -r1.3291
  --- ChangeLog	15 Aug 2005 21:28:58 -0000	1.3290
  +++ ChangeLog	16 Aug 2005 17:36:33 -0000	1.3291
  @@ -1,3 +1,24 @@
  +2005-08-16  Darin Adler  <darin at apple.com>
  +
  +        Reviewed by Beth Dakin.
  +
  +        - removed some unnecessary code
  +
  +        * WebCoreSupport.subproj/WebGraphicsBridge.h: Removed pattern-phase related field and methods.
  +        * WebCoreSupport.subproj/WebGraphicsBridge.m: Ditto.
  +
  +        * WebCoreSupport.subproj/WebImageData.m: Tweaked formatting and removed some unused code
  +        inside #if and comments.
  +
  +        * WebCoreSupport.subproj/WebImageRenderer.h: Removed USE_CGIMAGEREF (which is always true now).
  +        * WebCoreSupport.subproj/WebImageRenderer.m: Removed old non-CGImageRef code.
  +
  +        * WebCoreSupport.subproj/WebImageRendererFactory.m:
  +        (-[WebImageRendererFactory imageRendererWithMIMEType:]): Removed non-USE_CGIMAGEREF code.
  +        (-[WebImageRendererFactory imageRendererWithData:MIMEType:]): Ditto.
  +        (-[WebImageRendererFactory imageRendererWithSize:]): Ditto.
  +        (-[WebImageRendererFactory imageRendererWithName:]): Ditto.
  +
   2005-08-15  Darin  <darin at apple.com>
   	
           Reviewed by Beth.
  
  
  
  1.5       +0 -6      WebKit/WebCoreSupport.subproj/WebGraphicsBridge.h
  
  Index: WebGraphicsBridge.h
  ===================================================================
  RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebGraphicsBridge.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WebGraphicsBridge.h	5 Jun 2005 17:54:40 -0000	1.4
  +++ WebGraphicsBridge.h	16 Aug 2005 17:36:37 -0000	1.5
  @@ -26,15 +26,9 @@
    * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
   
  -#import <Cocoa/Cocoa.h>
   #import <WebCore/WebCoreGraphicsBridge.h>
   
   @interface WebGraphicsBridge : WebCoreGraphicsBridge
  -{
  -    NSPoint _phase;
  -}
  -
   + (void)createSharedBridge;
   + (WebGraphicsBridge *)sharedBridge;
  -- (NSPoint)additionalPatternPhase;
   @end
  
  
  
  1.12      +8 -20     WebKit/WebCoreSupport.subproj/WebGraphicsBridge.m
  
  Index: WebGraphicsBridge.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebGraphicsBridge.m,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- WebGraphicsBridge.m	1 Aug 2005 19:11:20 -0000	1.11
  +++ WebGraphicsBridge.m	16 Aug 2005 17:36:37 -0000	1.12
  @@ -29,8 +29,6 @@
   #import "WebGraphicsBridge.h"
   
   #import "WebAssertions.h"
  -
  -#import "WebImageRenderer.h"
   #import <WebKitSystemInterface.h>
   
   @implementation WebGraphicsBridge
  @@ -50,30 +48,20 @@
   
   - (void)setFocusRingStyle:(NSFocusRingPlacement)placement radius:(int)radius color:(NSColor *)color
   {
  -	WKSetFocusRingStyle(placement, radius, color);
  +    WKSetFocusRingStyle(placement, radius, color);
   }
   
  -// 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.
  +// Dashboard wants to set the drag image during dragging, but Cocoa does not allow this.
  +// Instead we drop down to the CG API.
   - (void)setDraggingImage:(NSImage *)image at:(NSPoint)offset
   {
  -	WKSetDragImage(image, offset);
  -	
  -    // Hack:  We must post an event to wake up the NSDragManager, which is sitting in a nextEvent call
  -    // up the stack from us because the CF drag manager is too lame to use the RunLoop by itself.  This
  -    // is the most innocuous event, per Kristen.
  -    
  +    WKSetDragImage(image, offset);
  +
  +    // Hack: We must post an event to wake up the NSDragManager, which is sitting in a nextEvent call
  +    // up the stack from us because the CF drag manager does not use the run loop by itself.
  +    // This is the most innocuous event to use, per Kristen.
       NSEvent *ev = [NSEvent mouseEventWithType:NSMouseMoved location:NSZeroPoint modifierFlags:0 timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:0 pressure:0];
       [NSApp postEvent:ev atStart:YES];
   }
   
  -- (void)setAdditionalPatternPhase:(NSPoint)phase
  -{
  -    _phase = phase;
  -}
  -
  -- (NSPoint)additionalPatternPhase {
  -    return _phase;
  -}
  -
   @end
  
  
  
  1.44      +129 -153  WebKit/WebCoreSupport.subproj/WebImageData.m
  
  Index: WebImageData.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebImageData.m,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- WebImageData.m	15 Aug 2005 21:29:00 -0000	1.43
  +++ WebImageData.m	16 Aug 2005 17:36:37 -0000	1.44
  @@ -26,18 +26,17 @@
    * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
   
  -#import <WebKit/WebAssertions.h>
  -#import <WebKit/WebGraphicsBridge.h>
  -#import <WebKit/WebImageData.h>
  -#import <WebKit/WebImageDecoder.h>
  -#import <WebKit/WebImageRenderer.h>
  -#import <WebKit/WebImageRendererFactory.h>
  -#import <WebKit/WebKitSystemBits.h>
  -#import <WebKitSystemInterface.h>
  +#import "WebImageData.h"
   
  -#import <WebCore/WebCoreImageRenderer.h>
  +#import "WebAssertions.h"
  +#import "WebGraphicsBridge.h"
  +#import "WebImageDecoder.h"
  +#import "WebImageRenderer.h"
  +#import "WebImageRendererFactory.h"
  +#import "WebKitSystemBits.h"
   
  -#ifdef USE_CGIMAGEREF
  +#import <WebKitSystemInterface.h>
  +#import <WebCore/WebCoreImageRenderer.h>
   
   // Forward declarations of internal methods.
   @interface WebImageData (WebInternal)
  @@ -49,20 +48,18 @@
   - (void)_stopAnimation;
   - (void)_nextFrame;
   - (CFDictionaryRef)_imageSourceOptions;
  --(void)_createPDFWithData:(NSData *)data;
  +- (void)_createPDFWithData:(NSData *)data;
   - (CGPDFDocumentRef)_PDFDocumentRef;
   - (BOOL)_PDFDrawFromRect:(NSRect)srcRect toRect:(NSRect)dstRect operation:(NSCompositingOperation)op alpha:(float)alpha flipped:(BOOL)flipped context:(CGContextRef)context;
   - (void)_cacheImages:(size_t)optionalIndex allImages:(BOOL)allImages;
   @end
   
  -
   @implementation WebImageData
   
   + (void)initialize
   {
  -    // Currently threaded decoding doesn't play well with the WebCore cache.  Until
  -    // those issues are resolved threaded decoding is OFF by default, even on dual CPU
  -    // machines.
  +    // Currently threaded decoding doesn't play well with the WebCore cache.
  +    // Until those issues are resolved threaded decoding is OFF by default, even on dual CPU machines.
       //[WebImageRendererFactory setShouldUseThreadedDecoding:(WebNumberOfCPUs() >= 2 ? YES : NO)];
       [WebImageRendererFactory setShouldUseThreadedDecoding:NO];
   }
  @@ -74,7 +71,7 @@
       if ([WebImageRendererFactory shouldUseThreadedDecoding])
           decodeLock = [[NSLock alloc] init];
   
  -    imageSource = CGImageSourceCreateIncremental ([self _imageSourceOptions]);
  +    imageSource = CGImageSourceCreateIncremental([self _imageSourceOptions]);
       sizeAvailable = NO;
       
       return self;
  @@ -92,21 +89,21 @@
   
   - (void)_commonTermination
   {
  -    ASSERT (!frameTimer);
  +    ASSERT(!frameTimer);
       
       [self _invalidateImages];
       [self _invalidateImageProperties];
           
       if (fileProperties)
  -        CFRelease (fileProperties);
  +        CFRelease(fileProperties);
   
       if (imageSource)
  -        CFRelease (imageSource); 
  +        CFRelease(imageSource); 
           
       if (animatingRenderers)
  -        CFRelease (animatingRenderers);
  +        CFRelease(animatingRenderers);
   
  -    free (frameDurations);
  +    free(frameDurations);
   }
   
   - (void)dealloc
  @@ -130,7 +127,7 @@
       WebImageData *copy;
   
       copy = [[WebImageData alloc] init];
  -    CFRetain (imageSource);
  +    CFRetain(imageSource);
       copy->imageSource = imageSource;
       
       return copy;
  @@ -155,9 +152,9 @@
           size_t i;
           for (i = 0; i < imagesSize; i++) {
               if (images[i])
  -                CFRelease (images[i]);
  +                CFRelease(images[i]);
           }
  -        free (images);
  +        free(images);
           images = 0;
           
           isSolidColor = NO;
  @@ -173,10 +170,10 @@
       size_t i;
       for (i = 0; i < imagePropertiesSize; i++) {
           if (imageProperties[i])
  -            CFRelease (imageProperties[i]);
  +            CFRelease(imageProperties[i]);
       }
  -    free (imageProperties);
  -    imageProperties = 0;
  +    free(imageProperties);
  +    imageProperties = NULL;
       imagePropertiesSize = 0;
   }
   
  @@ -184,9 +181,9 @@
   {
       static CFDictionaryRef imageSourceOptions;
       if (!imageSourceOptions) {
  -        const void * keys[2] = { kCGImageSourceShouldCache, 0 };
  +        const void *keys[2] = { kCGImageSourceShouldCache, 0 };
           keys[1] = WKPreferRGB32Key();
  -        const void * values[2] = { kCFBooleanTrue, kCFBooleanTrue };
  +        const void *values[2] = { kCFBooleanTrue, kCFBooleanTrue };
           imageSourceOptions = CFDictionaryCreate(NULL, keys, values, 2, 
               &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
       }
  @@ -198,19 +195,19 @@
       CGColorSpaceRef uncorrectedColorSpace = 0;
       CGImageRef noColorCorrectionImage = 0;
   
  -    if (!CFDictionaryGetValue (props, kCGImagePropertyProfileName)) {
  -        CFStringRef colorModel = CFDictionaryGetValue (props, kCGImagePropertyColorModel);
  +    if (!CFDictionaryGetValue(props, kCGImagePropertyProfileName)) {
  +        CFStringRef colorModel = CFDictionaryGetValue(props, kCGImagePropertyColorModel);
   
           if (colorModel) {
  -            if (CFStringCompare (colorModel, CFSTR("RGB"), 0) == kCFCompareEqualTo)
  +            if (CFStringCompare(colorModel, CFSTR("RGB"), 0) == kCFCompareEqualTo)
                   uncorrectedColorSpace = CGColorSpaceCreateDeviceRGB();
  -            else if (CFStringCompare (colorModel, CFSTR("Gray"), 0) == kCFCompareEqualTo)
  +            else if (CFStringCompare(colorModel, CFSTR("Gray"), 0) == kCFCompareEqualTo)
                   uncorrectedColorSpace = CGColorSpaceCreateDeviceGray();
           }
   
           if (uncorrectedColorSpace) {
  -            noColorCorrectionImage = CGImageCreateCopyWithColorSpace (image, uncorrectedColorSpace);
  -            CFRelease (uncorrectedColorSpace);
  +            noColorCorrectionImage = CGImageCreateCopyWithColorSpace(image, uncorrectedColorSpace);
  +            CFRelease(uncorrectedColorSpace);
           }
       }
       return noColorCorrectionImage;
  @@ -221,7 +218,7 @@
       if (index >= [self numberOfImages])
           return 0;
   
  -    if (!images || images[index] == 0){
  +    if (!images || images[index] == 0) {
           [self _cacheImages:index allImages:NO];
       }
       
  @@ -231,7 +228,7 @@
   - (CFDictionaryRef)fileProperties
   {
       if (!fileProperties) {
  -        fileProperties = CGImageSourceCopyProperties (imageSource, [self _imageSourceOptions]);
  +        fileProperties = CGImageSourceCopyProperties(imageSource, [self _imageSourceOptions]);
       }
       
       return fileProperties;
  @@ -241,79 +238,63 @@
   {
       size_t num = [self numberOfImages];
       
  -    // Number of images changed!
  +    // if number of properties changed, clear the cache.
       if (imagePropertiesSize && num > imagePropertiesSize) {
  -        // Clear cache.
           [self _invalidateImageProperties];
       }
   
  -    if (imageProperties == 0 && num) {
  -        imageProperties = (CFDictionaryRef *)malloc (num * sizeof(CFDictionaryRef));
  +    if (imageProperties == NULL && num) {
  +        imageProperties = (CFDictionaryRef *)malloc(num * sizeof(CFDictionaryRef));
           size_t i;
           for (i = 0; i < num; i++) {
  -#if USE_DEPRECATED_IMAGESOURCE_API
  -            imageProperties[i] = CGImageSourceGetPropertiesAtIndex (imageSource, i, [self _imageSourceOptions]);
  -            if (imageProperties[i])
  -                CFRetain (imageProperties[i]);
  -#else
  -            imageProperties[i] = CGImageSourceCopyPropertiesAtIndex (imageSource, i, [self _imageSourceOptions]);
  -#endif
  +            imageProperties[i] = CGImageSourceCopyPropertiesAtIndex(imageSource, i, [self _imageSourceOptions]);
           }
           imagePropertiesSize = num;
       }
       
       if (index < num) {
  -        // If image properties are nil, try to get them again.  May have attempted to
  -        // get them before enough data was available in the header.
  -        if (imageProperties[index] == 0) {
  -#if USE_DEPRECATED_IMAGESOURCE_API
  -            imageProperties[index] = CGImageSourceGetPropertiesAtIndex (imageSource, index, [self _imageSourceOptions]);
  -            if (imageProperties[index])
  -                CFRetain (imageProperties[index]);
  -#else
  -            imageProperties[index] = CGImageSourceCopyPropertiesAtIndex (imageSource, index, [self _imageSourceOptions]);
  -#endif
  +        // If image properties are nil, try to get them again.
  +        // Earlier, we may have attempted to get them before enough data was available in the header.
  +        if (imageProperties[index] == NULL) {
  +            imageProperties[index] = CGImageSourceCopyPropertiesAtIndex(imageSource, index, [self _imageSourceOptions]);
           }
  -        
           return imageProperties[index];
       }
       
       return 0;
   }
   
  -- (void)_checkSolidColor: (CGImageRef)image
  +- (void)_checkSolidColor:(CGImageRef)image
   {
       isSolidColor = NO;
  -    if( solidColor ) {
  +    if (solidColor) {
           CFRelease(solidColor);
           solidColor = NULL;
       }
       
  -    // Currently we only check for solid color in the important special case of a 1x1 image
  -    if( image && CGImageGetWidth(image)==1 && CGImageGetHeight(image)==1 ) {
  +    // Currently we only check for solid color in the important special case of a 1x1 image.
  +    if (image && CGImageGetWidth(image) == 1 && CGImageGetHeight(image) == 1) {
           float pixel[4]; // RGBA
           CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
  -// This #if won't be needed once the CG header that includes kCGBitmapByteOrder32Host is included in the OS
  -#if __ppc__	
  -        CGContextRef bmap = CGBitmapContextCreate(&pixel,1,1,8*sizeof(float),sizeof(pixel),space,
  -                                                  kCGImageAlphaPremultipliedLast | kCGBitmapFloatComponents);
  +// This #if won't be needed once the CG header that includes kCGBitmapByteOrder32Host is included in the OS.
  +#if __ppc__
  +        CGContextRef bmap = CGBitmapContextCreate(&pixel, 1, 1, 8*sizeof(float), sizeof(pixel), space,
  +            kCGImageAlphaPremultipliedLast | kCGBitmapFloatComponents);
   #else
  -        CGContextRef bmap = CGBitmapContextCreate(&pixel,1,1,8*sizeof(float),sizeof(pixel),space,
  -                                                  kCGImageAlphaPremultipliedLast | kCGBitmapFloatComponents | kCGBitmapByteOrder32Host);
  +        CGContextRef bmap = CGBitmapContextCreate(&pixel, 1, 1, 8*sizeof(float), sizeof(pixel), space,
  +            kCGImageAlphaPremultipliedLast | kCGBitmapFloatComponents | kCGBitmapByteOrder32Host);
   #endif
  -        if( bmap ) {
  +        if (bmap) {
               NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
               [[NSGraphicsContext graphicsContextWithGraphicsPort:bmap flipped:NO] setCompositingOperation:NSCompositeCopy];
               [pool release];
   
  -            CGRect dst = {{0,0},{1,1}};
  -            CGContextDrawImage(bmap,dst,image);
  -            if( pixel[3] > 0 )
  +            CGRect dst = { {0, 0}, {1, 1} };
  +            CGContextDrawImage(bmap, dst, image);
  +            if (pixel[3] > 0)
                   solidColor = CGColorCreate(space,pixel);
               isSolidColor = YES;
               CFRelease(bmap);
  -            /*NSLog(@"WebImageData %p: 1x1 image has color {%f,%f,%f,%f} => %p",
  -                  self,pixel[0],pixel[1],pixel[2],pixel[3],solidColor);*/
           } else {
               ERROR("Couldn't create CGBitmapContext");
           }
  @@ -338,15 +319,15 @@
       }
       for (i = from; i < to; i++) {
           if (!images) {
  -            images = (CGImageRef *)calloc (imagesSize, sizeof(CGImageRef));
  +            images = (CGImageRef *)calloc(imagesSize, sizeof(CGImageRef));
           }
   
  -        images[i] = CGImageSourceCreateImageAtIndex (imageSource, i, [self _imageSourceOptions]);
  +        images[i] = CGImageSourceCreateImageAtIndex(imageSource, i, [self _imageSourceOptions]);
       }
       
  -    if (from==0 && to>0) {
  +    if (from == 0 && to > 0) {
           // Loaded image 0. Check whether it's a solid color:
  -        [self _checkSolidColor: images[0]];
  +        [self _checkSolidColor:images[0]];
       }
   }
   
  @@ -362,7 +343,7 @@
       }
       else {
           // The work of decoding is actually triggered by image creation.
  -        CGImageSourceUpdateData (imageSource, data, isComplete);
  +        CGImageSourceUpdateData(imageSource, data, isComplete);
           [self _invalidateImages];
           [self _cacheImages:0 allImages:YES];
       }
  @@ -409,10 +390,10 @@
       // to indicate that the image is 'ready' for layout until we know the size.  So, we
       // have to try getting the meta until we have a valid width and height property.
       if (imageSourceStatus >= kCGImageStatusIncomplete) {
  -        CFDictionaryRef image0Properties = CGImageSourceCopyPropertiesAtIndex (imageSource, 0, [self _imageSourceOptions]);
  -        if  (image0Properties) {
  -            CFNumberRef widthNumber = CFDictionaryGetValue (image0Properties, kCGImagePropertyPixelWidth);
  -            CFNumberRef heightNumber = CFDictionaryGetValue (image0Properties, kCGImagePropertyPixelHeight);
  +        CFDictionaryRef image0Properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, [self _imageSourceOptions]);
  +        if (image0Properties) {
  +            CFNumberRef widthNumber = CFDictionaryGetValue(image0Properties, kCGImagePropertyPixelWidth);
  +            CFNumberRef heightNumber = CFDictionaryGetValue(image0Properties, kCGImagePropertyPixelHeight);
               sizeAvailable = widthNumber && heightNumber;
               
               if (imageProperties) {
  @@ -421,7 +402,7 @@
               }
               else {
                   imagePropertiesSize = [self numberOfImages];
  -                imageProperties = (CFDictionaryRef *)calloc (imagePropertiesSize, sizeof(CFDictionaryRef));
  +                imageProperties = (CFDictionaryRef *)calloc(imagePropertiesSize, sizeof(CFDictionaryRef));
               }
                   
               imageProperties[0] = image0Properties;
  @@ -443,12 +424,11 @@
       }
   #endif
       
  -    CFDataRef data = CFDataCreate (NULL, bytes, length);
  +    CFDataRef data = CFDataCreate(NULL, bytes, length);
       
       if (callback) {
           [WebImageDecoder performDecodeWithImage:self data:data isComplete:isComplete callback:callback];
  -    }
  -    else {
  +    } else {
           if (isPDF) {
               if (isComplete) {
                   [self _createPDFWithData:(NSData *)data];
  @@ -456,11 +436,11 @@
           }
           else {
               [self _invalidateImages];
  -            CGImageSourceUpdateData (imageSource, data, isComplete);
  +            CGImageSourceUpdateData(imageSource, data, isComplete);
           }
       }
       
  -    CFRelease (data);
  +    CFRelease(data);
   
       // Image properties will not be available until the first frame of the file
       // reaches kCGImageStatusIncomplete.  New as of ImageIO-55, see 4031602. 
  @@ -473,16 +453,14 @@
   
   - (void)_fillSolidColorInRect:(CGRect)rect compositeOperation:(NSCompositingOperation)op context:(CGContextRef)aContext
   {
  -    /*NSLog(@"WebImageData %p: filling with color %p, in {%.0f,%.0f, %.0f x %.0f}",
  -          self,solidColor,rect.origin.x,rect.origin.y,rect.size.width,rect.size.height);*/
  -    if( solidColor ) {
  -        CGContextSaveGState (aContext);
  +    if (solidColor) {
  +        CGContextSaveGState(aContext);
           CGContextSetFillColorWithColor(aContext, solidColor);
           NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
           [[NSGraphicsContext graphicsContextWithGraphicsPort:aContext flipped:NO] setCompositingOperation:op];
           [pool release];
  -        CGContextFillRect (aContext, rect);
  -        CGContextRestoreGState (aContext);
  +        CGContextFillRect(aContext, rect);
  +        CGContextRestoreGState(aContext);
       }
   }
   
  @@ -490,13 +468,12 @@
   {
       if (isPDF) {
           [self _PDFDrawFromRect:NSMakeRect(fr.origin.x, fr.origin.y, fr.size.width, fr.size.height)
  -                toRect:NSMakeRect(ir.origin.x, ir.origin.y, ir.size.width, ir.size.height)
  -                operation:op 
  -                alpha:1.0 
  -                flipped:YES
  -                context:aContext];
  -    }
  -    else {
  +            toRect:NSMakeRect(ir.origin.x, ir.origin.y, ir.size.width, ir.size.height)
  +            operation:op 
  +            alpha:1.0 
  +            flipped:YES
  +            context:aContext];
  +    } else {
           [decodeLock lock];
           
           CGImageRef image = [self imageAtIndex:index];
  @@ -507,10 +484,9 @@
           }
           
           if( isSolidColor && index==0 ) {
  -            [self _fillSolidColorInRect: ir compositeOperation: op context: aContext];
  -
  +            [self _fillSolidColorInRect:ir compositeOperation:op context:aContext];
           } else {
  -            CGContextSaveGState (aContext);
  +            CGContextSaveGState(aContext);
               
               // Get the height (in adjusted, i.e. scaled, coords) of the portion of the image
               // that is currently decoded.  This could be less that the actual height.
  @@ -537,9 +513,9 @@
               NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
               [[NSGraphicsContext graphicsContextWithGraphicsPort:aContext flipped:NO] setCompositingOperation:op];
               [pool release];
  -            CGContextTranslateCTM (aContext, ir.origin.x, ir.origin.y);
  -            CGContextScaleCTM (aContext, 1, -1);
  -            CGContextTranslateCTM (aContext, 0, -ir.size.height);
  +            CGContextTranslateCTM(aContext, ir.origin.x, ir.origin.y);
  +            CGContextScaleCTM(aContext, 1, -1);
  +            CGContextTranslateCTM(aContext, 0, -ir.size.height);
               
               // Translated to origin, now draw at 0,0.
               ir.origin.x = ir.origin.y = 0;
  @@ -556,18 +532,18 @@
                   fr.size.width /= xscale;
                   fr.size.height /= yscale;
                   
  -                image = CGImageCreateWithImageInRect (image, fr);
  +                image = CGImageCreateWithImageInRect(image, fr);
                   if (image) {
  -                    CGContextDrawImage (aContext, ir, image);
  -                    CFRelease (image);
  +                    CGContextDrawImage(aContext, ir, image);
  +                    CFRelease(image);
                   }
               }
               // otherwise draw the whole image.
               else { 
  -                CGContextDrawImage (aContext, ir, image);
  +                CGContextDrawImage(aContext, ir, image);
               }
   
  -            CGContextRestoreGState (aContext);
  +            CGContextRestoreGState(aContext);
           }
           
           [decodeLock unlock];
  @@ -579,21 +555,21 @@
       [self drawImageAtIndex:index inRect:ir fromRect:fr adjustedSize:[self size] compositeOperation:op context:aContext];
   }
   
  -static void drawPattern (void * info, CGContextRef context)
  +static void drawPattern(void * info, CGContextRef context)
   {
       WebImageData *data = (WebImageData *)info;
       
       CGImageRef image = [data imageAtIndex:[data currentFrame]];
       float w = CGImageGetWidth(image);
       float h = CGImageGetHeight(image);
  -    CGContextDrawImage (context, CGRectMake(0, [data size].height-h, w, h), image);    
  +    CGContextDrawImage(context, CGRectMake(0, [data size].height - h, w, h), image);    
   }
   
   static const CGPatternCallbacks patternCallbacks = { 0, drawPattern, NULL };
   
   - (void)tileInRect:(CGRect)rect fromPoint:(CGPoint)point context:(CGContextRef)aContext
   {
  -    ASSERT (aContext);
  +    ASSERT(aContext);
   
       [decodeLock lock];
       
  @@ -604,9 +580,8 @@
           return;
       }
   
  -    if( frame == 0 && isSolidColor ) {
  -        [self _fillSolidColorInRect: rect compositeOperation: NSCompositeSourceOver context: aContext];
  -        
  +    if (frame == 0 && isSolidColor) {
  +        [self _fillSolidColorInRect:rect compositeOperation:NSCompositeSourceOver context:aContext];
       } else {
           CGSize tileSize = [self size];
           
  @@ -614,6 +589,12 @@
           NSRect oneTileRect;
           oneTileRect.origin.x = rect.origin.x + fmodf(fmodf(-point.x, tileSize.width) - tileSize.width, tileSize.width);
           oneTileRect.origin.y = rect.origin.y + fmodf(fmodf(-point.y, tileSize.height) - tileSize.height, tileSize.height);
  +// I think this is a simpler way to say the same thing. Also, if either point.x or point.y is negative, both
  +// methods will end up with the wrong answer. For example, fmod(-22,5) is -2, which is the correct delta to
  +// the start of the pattern, but fmod(-(-23), 5) is 3.  This is the delta to the *end* of the pattern
  +// instead of the start, so oneTileRect will be too far right.
  +//      oneTileRect.origin.x = rect.origin.x - fmodf(point.x, size.width);
  +//      oneTileRect.origin.y = rect.origin.y - fmodf(point.y, size.height);
           oneTileRect.size.height = tileSize.height;
           oneTileRect.size.width = tileSize.width;
   
  @@ -653,14 +634,13 @@
               [[NSGraphicsContext graphicsContextWithGraphicsPort:aContext flipped:NO] setCompositingOperation:NSCompositeSourceOver];
               [pool release];
   
  -            CGContextFillRect (aContext, rect);
  +            CGContextFillRect(aContext, rect);
   
  -            CGPatternRelease (pattern);
  +            CGContextRestoreGState(aContext);
   
  -            CGContextRestoreGState (aContext);
  -        }
  -        else {
  -            ERROR ("unable to create pattern");
  +            CGPatternRelease(pattern);
  +        } else {
  +            ERROR("unable to create pattern");
           }
       }
       
  @@ -676,25 +656,23 @@
   
   - (CGSize)size
   {
  -    float w = 0.f, h = 0.f;
  -
       if (isPDF) {
           if (_PDFDoc) {
               CGRect mediaBox = [_PDFDoc mediaBox];
               return mediaBox.size;
           }
  -    }
  -    else {
  +    } else {
           if (sizeAvailable && !haveSize) {
               [decodeLock lock];
               CFDictionaryRef properties = [self propertiesAtIndex:0];
               if (properties) {
  -                CFNumberRef num = CFDictionaryGetValue (properties, kCGImagePropertyPixelWidth);
  +                float w = 0.f, h = 0.f;
  +                CFNumberRef num = CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth);
                   if (num)
  -                    CFNumberGetValue (num, kCFNumberFloat32Type, &w);
  -                num = CFDictionaryGetValue (properties, kCGImagePropertyPixelHeight);
  +                    CFNumberGetValue(num, kCFNumberFloat32Type, &w);
  +                num = CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight);
                   if (num)
  -                    CFNumberGetValue (num, kCFNumberFloat32Type, &h);
  +                    CFNumberGetValue(num, kCFNumberFloat32Type, &h);
   
                   size.width = w;
                   size.height = h;
  @@ -718,20 +696,20 @@
           return 0.f;
       }
       
  -    CFDictionaryRef typeProperties = CFDictionaryGetValue (properties, type);
  +    CFDictionaryRef typeProperties = CFDictionaryGetValue(properties, type);
       if (!typeProperties) {
           [decodeLock unlock];
           return 0.f;
       }
       
  -    CFNumberRef num = CFDictionaryGetValue (typeProperties, property);
  +    CFNumberRef num = CFDictionaryGetValue(typeProperties, property);
       if (!num) {
           [decodeLock unlock];
           return 0.f;
       }
       
       float value = 0.f;
  -    CFNumberGetValue (num, kCFNumberFloat32Type, &value);
  +    CFNumberGetValue(num, kCFNumberFloat32Type, &value);
   
       [decodeLock unlock];
       
  @@ -751,21 +729,21 @@
       }
       
       if (type) {
  -        properties = CFDictionaryGetValue (properties, type);
  +        properties = CFDictionaryGetValue(properties, type);
           if (!properties) {
               [decodeLock unlock];
               return 0.f;
           }
       }
       
  -    CFNumberRef num = CFDictionaryGetValue (properties, property);
  +    CFNumberRef num = CFDictionaryGetValue(properties, property);
       if (!num) {
           [decodeLock unlock];
           return 0.f;
       }
       
       float value = 0.f;
  -    CFNumberGetValue (num, kCFNumberFloat32Type, &value);
  +    CFNumberGetValue(num, kCFNumberFloat32Type, &value);
   
       [decodeLock unlock];
   
  @@ -796,15 +774,15 @@
   {
       size_t num = [self numberOfImages];
       if (frameDurationsSize && num > frameDurationsSize) {
  -        free (frameDurations);
  -        frameDurations = 0;
  +        free(frameDurations);
  +        frameDurations = NULL;
           frameDurationsSize = 0;
       }
       
       if (!frameDurations) {
           size_t i;
   
  -        frameDurations = (float *)malloc (sizeof(float) * num);
  +        frameDurations = (float *)malloc(sizeof(float) * num);
           for (i = 0; i < num; i++) {
               frameDurations[i] = [self _frameDurationAt:i];
           }
  @@ -850,7 +828,7 @@
       // before actually stopping them because the process of stopping them
       // will modify the active animations and animating renderer collections.
       while ((animation = [objectEnumerator nextObject])) {
  -        NSSet *renderersInView = (NSSet *)CFDictionaryGetValue (animation->animatingRenderers, aView);
  +        NSSet *renderersInView = (NSSet *)CFDictionaryGetValue(animation->animatingRenderers, aView);
           if (renderersInView) {
               if (!renderersToStop)
                   renderersToStop = [[NSMutableSet alloc] init];
  @@ -866,9 +844,9 @@
   - (void)addAnimatingRenderer:(WebImageRenderer *)r inView:(NSView *)view
   {
       if (!animatingRenderers)
  -        animatingRenderers = CFDictionaryCreateMutable (NULL, 0, NULL, &kCFTypeDictionaryValueCallBacks);
  +        animatingRenderers = CFDictionaryCreateMutable(NULL, 0, NULL, &kCFTypeDictionaryValueCallBacks);
       
  -    NSMutableSet *renderers = (NSMutableSet *)CFDictionaryGetValue (animatingRenderers, view);
  +    NSMutableSet *renderers = (NSMutableSet *)CFDictionaryGetValue(animatingRenderers, view);
       if (!renderers) {
           renderers = [[NSMutableSet alloc] init];
           CFDictionaryAddValue(animatingRenderers, view, renderers);
  @@ -888,10 +866,10 @@
       NSEnumerator *viewEnumerator = [(NSMutableDictionary *)animatingRenderers keyEnumerator];
       NSView *view;
       while ((view = [viewEnumerator nextObject])) {
  -        NSMutableSet *renderers = (NSMutableSet *)CFDictionaryGetValue (animatingRenderers, view);
  +        NSMutableSet *renderers = (NSMutableSet *)CFDictionaryGetValue(animatingRenderers, view);
           [renderers removeObject:r];
           if ([renderers count] == 0) {
  -            CFDictionaryRemoveValue (animatingRenderers, view);
  +            CFDictionaryRemoveValue(animatingRenderers, view);
           }
       }
       
  @@ -1007,13 +985,13 @@
       hScale = dstRect.size.width  / srcRect.size.width;
       vScale = dstRect.size.height / srcRect.size.height;
   
  -    CGContextTranslateCTM (context, dstRect.origin.x - srcRect.origin.x * hScale, dstRect.origin.y - srcRect.origin.y * vScale);
  -    CGContextScaleCTM (context, hScale, vScale);
  +    CGContextTranslateCTM(context, dstRect.origin.x - srcRect.origin.x * hScale, dstRect.origin.y - srcRect.origin.y * vScale);
  +    CGContextScaleCTM(context, hScale, vScale);
   
       // Reverse if flipped image.
       if (flipped) {
           CGContextScaleCTM(context, 1, -1);
  -        CGContextTranslateCTM (context, 0, -dstRect.size.height);
  +        CGContextTranslateCTM(context, 0, -dstRect.size.height);
       }
   
       // Clip to destination in case we are imaging part of the source only
  @@ -1029,5 +1007,3 @@
   }
   
   @end
  -
  -#endif
  
  
  
  1.33      +1 -35     WebKit/WebCoreSupport.subproj/WebImageRenderer.h
  
  Index: WebImageRenderer.h
  ===================================================================
  RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebImageRenderer.h,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- WebImageRenderer.h	5 Jun 2005 17:54:40 -0000	1.32
  +++ WebImageRenderer.h	16 Aug 2005 17:36:37 -0000	1.33
  @@ -30,11 +30,6 @@
   
   @protocol WebCoreImageRenderer;
   
  -#ifndef OMIT_TIGER_FEATURES
  -#define USE_CGIMAGEREF YES
  -#endif
  -
  -#ifdef USE_CGIMAGEREF
   @class WebImageData;
   
   @interface WebImageRenderer : NSObject <WebCoreImageRenderer>
  @@ -66,32 +61,7 @@
   
   @end
   
  -#else   // Panther version of WebImageRenderer ------------------------------------
  -
  - at class WebInternalImage;
  -
  - at interface WebImageRenderer : NSObject <WebCoreImageRenderer>
  -{
  -    WebInternalImage *image;
  -}
  -
  -- (id)initWithMIMEType:(NSString *)MIME;
  -- (id)initWithData:(NSData *)data MIMEType:(NSString *)MIME;
  -- (id)initWithContentsOfFile:(NSString *)filename;
  -
  -- (NSImage *)image;
  -- (NSString *)MIMEType;
  -- (NSData *)TIFFRepresentation;
  -- (int)frameCount;
  -
  -- (void)setOriginalData:(NSData *)data;
  -
  -+ (void)stopAnimationsInView:(NSView *)aView;
  -
  - at end
  -
  -#endif
  -
  +// FIXME: This class needs its own header and source file.
   @interface WebPDFDocument : NSObject
   {
       CGPDFDocumentRef _document;
  @@ -109,7 +79,3 @@
   - (int)              pageCount;
   - (void)             adjustCTM:(CGContextRef)context;
   @end
  -
  -CGColorSpaceRef WebCGColorSpaceCreateRGB(void);
  -CGColorSpaceRef WebCGColorSpaceCreateGray(void);
  -CGColorSpaceRef WebCGColorSpaceCreateCMYK(void);
  
  
  
  1.106     +4 -1160   WebKit/WebCoreSupport.subproj/WebImageRenderer.m
  
  Index: WebImageRenderer.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebImageRenderer.m,v
  retrieving revision 1.105
  retrieving revision 1.106
  diff -u -r1.105 -r1.106
  --- WebImageRenderer.m	15 Aug 2005 21:29:00 -0000	1.105
  +++ WebImageRenderer.m	16 Aug 2005 17:36:37 -0000	1.106
  @@ -38,8 +38,6 @@
   
   #import <WebCore/WebCoreImageRenderer.h>
   
  -#ifdef USE_CGIMAGEREF
  -
   #import <WebKit/WebImageData.h>
   
   // Forward declarations of internal methods.
  @@ -287,1118 +285,16 @@
   
   @end
   
  -#else
  -
  - at interface WebInternalImage : NSImage <NSCopying>
  -{
  -    NSTimer *frameTimer;
  -    NSView *frameView;
  -    NSRect imageRect;
  -    NSRect targetRect;
  -
  -    int loadStatus;
  -
  -    NSColor *patternColor;
  -    int patternColorLoadStatus;
  -
  -    int repetitionsComplete;
  -    BOOL animationFinished;
  -    
  -    NSPoint tilePoint;
  -    BOOL animatedTile;
  -
  -    int compositeOperator;
  -    id redirectContext;
  -    CGContextRef context;
  -    BOOL needFlushRasterCache;
  -    BOOL rasterFlushing;
  -    NSImageCacheMode rasterFlushingOldMode;
  -    
  -    NSString *MIMEType;
  -    BOOL isNull;
  -    int useCount;
  -
  -    CGImageRef cachedImageRef;
  -    
  -    id _PDFDoc;
  -        
  - at public    
  -    NSData *originalData;
  -}
  -
  -- (id)initWithMIMEType:(NSString *)MIME;
  -- (id)initWithData:(NSData *)data MIMEType:(NSString *)MIME;
  -
  -- (void)releasePatternColor;
  -
  -- (NSString *)MIMEType;
  -- (int)frameCount;
  -
  -- (BOOL)incrementalLoadWithBytes:(const void *)bytes length:(unsigned)length complete:(BOOL)isComplete callback:(id)c;
  -- (void)resize:(NSSize)s;
  -- (void)drawImageInRect:(NSRect)ir fromRect:(NSRect)fr;
  -- (void)drawImageInRect:(NSRect)ir fromRect:(NSRect)fr compositeOperator:(NSCompositingOperation)compsiteOperator context:(CGContextRef)context;
  -- (void)stopAnimation;
  -- (void)tileInRect:(NSRect)rect fromPoint:(NSPoint)point context:(CGContextRef)aContext;
  -- (BOOL)isNull;
  -- (void)increaseUseCount;
  -- (void)decreaseUseCount;
  -- (WebImageRenderer *)createRendererIfNeeded;
  -- (void)flushRasterCache;
  -- (CGImageRef)imageRef;
  -
  -+ (void)stopAnimationsInView:(NSView *)aView;
  -- (void)resetAnimation;
  -
  -- (void)startAnimationIfNecessary;
  -- (NSGraphicsContext *)_beginRedirectContext:(CGContextRef)aContext;
  -- (void)_endRedirectContext:(NSGraphicsContext *)aContext;
  -- (void)_needsRasterFlush;
  -- (BOOL)_PDFDrawFromRect:(NSRect)srcRect toRect:(NSRect)dstRect operation:(NSCompositingOperation)op alpha:(float)alpha flipped:(BOOL)flipped;
  -
  - at end
  -
  -extern NSString *NSImageLoopCount;
  -
  -/*
  -    We need to get the AppKit to redirect drawing to our
  -    CGContext.  There is currently (on Panther) no public
  -    way to make this happen.  So we create a NSCGSContext
  -    subclass and twiddle it's _cgsContext ivar directly.
  -    Very fragile, but the only way...
  -*/
  - at interface NSCGSContext : NSGraphicsContext {
  -    CGContextRef _cgsContext;
  -}
  - at end
  -
  -static CGImageRef _createImageRef(NSBitmapImageRep *rep);
  -
  - at interface NSBitmapImageRep (AppKitInternals)
  -- (CGImageRef)_CGImageRef;
  - at end
  -
  - at interface NSFocusStack : NSObject
  - at end
  -
  - at interface WebImageContext : NSCGSContext {
  -  @private
  -    NSFocusStack* _focusStack;
  -    NSRect        _bounds;
  -    BOOL          _isFlipped;
  -}
  -- (id)initWithBounds:(NSRect)b context:(CGContextRef)context;
  -- (NSRect)bounds;
  - at end
  -
  -
  - at implementation WebImageContext
  -
  -- (id)initWithBounds:(NSRect)b context:(CGContextRef)context {
  -    
  -    self = [super init];
  -    if (self != nil) {
  -	_bounds     = b;
  -	_isFlipped  = YES;
  -        if (context) {
  -            _cgsContext = CGContextRetain(context);
  -        }
  -    }
  -    
  -    return self;
  -}
  -
  -- (void)dealloc
  -{
  -    [_focusStack release];
  -    if (_cgsContext) {
  -        CGContextRelease(_cgsContext);
  -        _cgsContext = 0; // super dealloc may also release
  -    }
  -    [super dealloc];
  -}
  -
  -- (void)finalize
  -{
  -    if (_cgsContext) {
  -        CGContextRelease(_cgsContext);
  -        _cgsContext = 0; // super finalize may also release
  -    }
  -    [super finalize];
  -}
  -
  -- (void)saveGraphicsState
  -{
  -    if (_cgsContext) {
  -        CGContextSaveGState(_cgsContext);
  -    }
  -}
  -
  -- (void)restoreGraphicsState
  -{
  -    if (_cgsContext) {
  -        CGContextRestoreGState(_cgsContext);
  -    }
  -}
  -
  -- (BOOL)isDrawingToScreen
  -{
  -    return NO;
  -}
  -
  -- (void *)focusStack
  -{
  -    if (!_focusStack) _focusStack = [[NSFocusStack allocWithZone:NULL] init];
  -    return _focusStack;
  -}
  -
  -- (void)setFocusStack:(void *)stack
  -{
  -    id oldstack = _focusStack;
  -    _focusStack = [(id)stack retain];
  -    [oldstack release];
  -}
  -
  -- (NSRect)bounds
  -{
  -    return _bounds;
  -}
  -
  -- (BOOL)isFlipped
  -{
  -    return _isFlipped;
  -}
  -
  - at end
  -
  -#define MINIMUM_DURATION (1.0/30.0)
  -
  - at implementation WebInternalImage
  -
  -static NSMutableSet *activeImageRenderers;
  -
  -+ (void)stopAnimationsInView:(NSView *)aView
  -{
  -    NSEnumerator *objectEnumerator = [activeImageRenderers objectEnumerator];
  -    WebInternalImage *renderer;
  -    NSMutableSet *renderersToStop = [[NSMutableSet alloc] init];
  -
  -    while ((renderer = [objectEnumerator nextObject])) {
  -        if (renderer->frameView == aView) {
  -            [renderersToStop addObject: renderer];
  -        }
  -    }
  -
  -    objectEnumerator = [renderersToStop objectEnumerator];
  -    while ((renderer = [objectEnumerator nextObject])) {
  -        if (renderer->frameView == aView) {
  -            [renderer stopAnimation];
  -        }
  -    }
  -    [renderersToStop release];
  -}
  -
  -- (id)initWithMIMEType:(NSString *)MIME
  -{
  -    self = [super init];
  -    if (self != nil) {
  -        // Work around issue with flipped images and TIFF by never using the image cache.
  -        // See bug 3344259 and related bugs.
  -        [self setCacheMode:NSImageCacheNever];
  -
  -        loadStatus = NSImageRepLoadStatusUnknownType;
  -        MIMEType = [MIME copy];
  -        isNull = YES;
  -        compositeOperator = (int)NSCompositeSourceOver;
  -    }
  -    
  -    return self;
  -}
  -
  -- (id)initWithData:(NSData *)data MIMEType:(NSString *)MIME
  -{
  -    WebInternalImage *result = nil;
  -
  -    NS_DURING
  -    
  -        result = [super initWithData:data];
  -        if (result != nil) {
  -            // Work around issue with flipped images and TIFF by never using the image cache.
  -            // See bug 3344259 and related bugs.
  -            [result setCacheMode:NSImageCacheNever];
  -    
  -            result->loadStatus = NSImageRepLoadStatusUnknownType;
  -            result->MIMEType = [MIME copy];
  -            result->isNull = [data length] == 0;
  -            result->compositeOperator = (int)NSCompositeSourceOver;
  -        }
  -
  -    NS_HANDLER
  -
  -        result = nil;
  -
  -    NS_ENDHANDLER
  -
  -    return result;
  -}
  -
  -- (id)initWithContentsOfFile:(NSString *)filename
  -{
  -    NSBundle *bundle = [NSBundle bundleForClass:[self class]];
  -    NSString *imagePath = [bundle pathForResource:filename ofType:@"tiff"];
  -    WebInternalImage *result = nil;
  -
  -    NS_DURING
  -
  -        result = [super initWithContentsOfFile:imagePath];
  -        if (result != nil) {
  -            // Work around issue with flipped images and TIFF by never using the image cache.
  -            // See bug 3344259 and related bugs.
  -            [result setCacheMode:NSImageCacheNever];
  -    
  -            result->loadStatus = NSImageRepLoadStatusUnknownType;
  -            result->compositeOperator = (int)NSCompositeSourceOver;
  -        }
  -        
  -    NS_HANDLER
  -
  -        result = nil;
  -
  -    NS_ENDHANDLER
  -
  -    return result;
  -}
  -
  -- (void)increaseUseCount
  -{
  -    useCount++;
  -}
  -
  -- (void)decreaseUseCount
  -{
  -    useCount--;
  -}
  -
  -- (WebImageRenderer *)createRendererIfNeeded
  -{
  -    // If an animated image appears multiple times in a given page, we
  -    // must create multiple WebCoreImageRenderers so that each copy
  -    // animates. However, we don't want to incur the expense of
  -    // re-decoding for the very first use on a page, since QPixmap
  -    // assignment always calls this method, even when just fetching
  -    // the image from the cache for the first time for a page.
  -    if (originalData && useCount) {
  -        return [[[WebImageRendererFactory sharedFactory] imageRendererWithData:originalData MIMEType:MIMEType] retain];
  -    }
  -    return nil;
  -}
  -
  -- copyWithZone:(NSZone *)zone
  -{
  -    // FIXME: If we copy while doing an incremental load, it won't work.
  -    WebInternalImage *copy;
  -
  -    copy = [super copyWithZone:zone];
  -    copy->MIMEType = [MIMEType copy];
  -    copy->originalData = [originalData retain];
  -    copy->frameTimer = nil;
  -    copy->frameView = nil;
  -    copy->patternColor = nil;
  -    copy->compositeOperator = compositeOperator;
  -    copy->context = 0;
  -
  -    return copy;
  -}
  -
  -- (BOOL)isNull
  -{
  -    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]);
  -    [imageRep setSize:size];
  -        
  -    [self setScalesWhenResized:YES];
  -    [self setSize:size];
  -}
  -
  -- (BOOL)incrementalLoadWithBytes:(const void *)bytes length:(unsigned)length complete:(BOOL)isComplete callback:(id)c
  -{
  -    NSArray *reps = [self representations];
  -    NSBitmapImageRep *imageRep = [reps count] > 0 ? [[self representations] objectAtIndex:0] : nil;
  -    
  -    if (imageRep && [imageRep isKindOfClass: [NSBitmapImageRep class]]) {
  -        NSData *data = [[NSData alloc] initWithBytes:bytes length:length];
  -
  -        NS_DURING
  -            // Get rep again to avoid bogus compiler warning.
  -            NSBitmapImageRep *aRep = [[self representations] objectAtIndex:0];
  -
  -            loadStatus = [aRep incrementalLoadFromData:data complete:isComplete];
  -        NS_HANDLER
  -            loadStatus = NSImageRepLoadStatusInvalidData; // Arbitrary choice; any error will do.
  -        NS_ENDHANDLER
  -
  -        // Hold onto the original data in case we need to copy this image.  (Workaround for appkit NSImage
  -        // copy flaw).
  -        if (isComplete && [self frameCount] > 1)
  -            originalData = data;
  -        else
  -            [data release];
  -
  -        switch (loadStatus) {
  -        case NSImageRepLoadStatusUnknownType:       // not enough data to determine image format. please feed me more data
  -            //printf ("NSImageRepLoadStatusUnknownType size %d, isComplete %d\n", length, isComplete);
  -            return NO;
  -        case NSImageRepLoadStatusReadingHeader:     // image format known, reading header. not yet valid. more data needed
  -            //printf ("NSImageRepLoadStatusReadingHeader size %d, isComplete %d\n", length, isComplete);
  -            return NO;
  -        case NSImageRepLoadStatusWillNeedAllData:   // can't read incrementally. will wait for complete data to become avail.
  -            //printf ("NSImageRepLoadStatusWillNeedAllData size %d, isComplete %d\n", length, isComplete);
  -            return NO;
  -        case NSImageRepLoadStatusInvalidData:       // image decompression encountered error.
  -            //printf ("NSImageRepLoadStatusInvalidData size %d, isComplete %d\n", length, isComplete);
  -            return NO;
  -        case NSImageRepLoadStatusUnexpectedEOF:     // ran out of data before full image was decompressed.
  -            //printf ("NSImageRepLoadStatusUnexpectedEOF size %d, isComplete %d\n", length, isComplete);
  -            return NO;
  -        case NSImageRepLoadStatusCompleted:         // all is well, the full pixelsHigh image is valid.
  -            //printf ("NSImageRepLoadStatusCompleted size %d, isComplete %d\n", length, isComplete);
  -            [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;
  -            return YES;
  -        }
  -    }
  -    else {
  -        if (isComplete) {
  -            originalData = [[NSData alloc] initWithBytes:bytes length:length];
  -            if ([MIMEType isEqual:@"application/pdf"]) {
  -                Class repClass = [NSImageRep imageRepClassForData:originalData];
  -                if (repClass) {
  -                    NSImageRep *rep = [[repClass alloc] initWithData:originalData];
  -                    [self addRepresentation:rep];
  -                }
  -            }
  -            isNull = NO;
  -            return YES;
  -        }
  -    }
  -    return NO;
  -}
  -
  -- (void)dealloc
  -{
  -    ASSERT(frameTimer == nil);
  -    ASSERT(frameView == nil);
  -    [patternColor release];
  -    [MIMEType release];
  -    [originalData release];
  -    
  -    if (context) {
  -        CGContextRelease(context);
  -        context = 0;
  -    }
  -
  -    if (cachedImageRef) {
  -        CGImageRelease (cachedImageRef);
  -        cachedImageRef = 0;
  -    }
  -    
  -    [_PDFDoc release];
  -
  -    [super dealloc];
  -}
  -
  -- (void)finalize
  -{
  -    ASSERT(frameTimer == nil);
  -    ASSERT(frameView == nil);
  -
  -    if (context) {
  -        CGContextRelease(context);
  -    }
  -
  -    if (cachedImageRef) {
  -        CGImageRelease (cachedImageRef);
  -        cachedImageRef = 0;
  -    }
  -    
  -    [super finalize];
  -}
  -
  -- (id)firstRepProperty:(NSString *)propertyName
  -{
  -    id firstRep = [[self representations] objectAtIndex:0];
  -    id property = nil;
  -    if ([firstRep respondsToSelector:@selector(valueForProperty:)])
  -        property = [firstRep valueForProperty:propertyName];
  -    return property;
  -}
  -
  -- (int)frameCount
  -{
  -    id property = [self firstRepProperty:NSImageFrameCount];
  -    return property ? [property intValue] : 1;
  -}
  -
  -- (int)currentFrame
  -{
  -    id property = [self firstRepProperty:NSImageCurrentFrame];
  -    return property ? [property intValue] : 1;
  -}
  -
  -- (void)setCurrentFrame:(int)frame
  -{
  -    NSBitmapImageRep *imageRep = [[self representations] objectAtIndex:0];
  -    [imageRep setProperty:NSImageCurrentFrame withValue:[NSNumber numberWithInt:frame]];
  -}
  -
  -- (float)unadjustedFrameDuration
  -{
  -    id property = [self firstRepProperty:NSImageCurrentFrameDuration];
  -    return property ? [property floatValue] : 0.0;
  -}
  -
  -- (float)frameDuration
  -{
  -    float duration = [self unadjustedFrameDuration];
  -    if (duration < MINIMUM_DURATION) {
  -        /*
  -            Many annoying ads specify a 0 duration to make an image flash
  -            as quickly as possible.  However a zero duration is faster than
  -            the refresh rate.  We need to pick a minimum duration.
  -            
  -            Browsers handle the minimum time case differently.  IE seems to use something
  -            close to 1/30th of a second.  Konqueror uses 0.  The ImageMagick library
  -            uses 1/100th.  The units in the GIF specification are 1/100th of second.
  -            We will use 1/30th of second as the minimum time.
  -        */
  -        duration = MINIMUM_DURATION;
  -    }
  -    return duration;
  -}
  -
  -- (int)repetitionCount
  -{
  -    id property = [self firstRepProperty:NSImageLoopCount];
  -    int count = property ? [property intValue] : 0;
  -    return count;
  -}
  -
  -- (void)scheduleFrame
  -{
  -    if (frameTimer && [frameTimer isValid])
  -        return;
  -    frameTimer = [[NSTimer scheduledTimerWithTimeInterval:[self frameDuration]
  -                                                    target:self
  -                                                  selector:@selector(nextFrame:)
  -                                                  userInfo:nil
  -                                                   repeats:NO] retain];
  -}
  -
  -- (NSGraphicsContext *)_beginRedirectContext:(CGContextRef)aContext
  -{
  -    NSGraphicsContext *oldContext = 0;
  -    if (aContext) {
  -        oldContext = [NSGraphicsContext currentContext];
  -        // Assumes that we are redirecting to a CGBitmapContext.
  -        size_t w = CGBitmapContextGetWidth (aContext);
  -        size_t h = CGBitmapContextGetHeight (aContext);
  -        redirectContext = [[WebImageContext alloc] initWithBounds:NSMakeRect(0, 0, (float)w, (float)h) context:aContext];
  -        [NSGraphicsContext setCurrentContext:redirectContext];
  -    }
  -    return oldContext; 
  -}
  -
  -- (void)_endRedirectContext:(NSGraphicsContext *)aContext
  -{
  -    if (aContext) {
  -        [NSGraphicsContext setCurrentContext:aContext];
  -        [redirectContext autorelease];
  -        redirectContext = 0;
  -    }
  -}
  -
  -- (void)_needsRasterFlush
  -{
  -#if 0
  -    if (needFlushRasterCache && [MIMEType isEqual: @"application/pdf"]) {
  -        // FIXME:  At this point we need to flush the cached rasterized PDF.
  -    }
  -#endif
  -}
  -
  -- (void)_adjustColorSpace
  -{
  -#if COLORMATCH_EVERYTHING
  -    NSArray *reps = [self representations];
  -    NSBitmapImageRep *imageRep = [reps count] > 0 ? [[self representations] objectAtIndex:0] : nil;
  -    if (imageRep && [imageRep isKindOfClass: [NSBitmapImageRep class]] &&
  -        [imageRep valueForProperty:NSImageColorSyncProfileData] == nil &&
  -        [[imageRep colorSpaceName] isEqualToString:NSDeviceRGBColorSpace]) {
  -        [imageRep setColorSpaceName:NSCalibratedRGBColorSpace];
  -    }
  -#else
  -    NSArray *reps = [self representations];
  -    NSBitmapImageRep *imageRep = [reps count] > 0 ? [[self representations] objectAtIndex:0] : nil;
  -    if (imageRep && [imageRep isKindOfClass: [NSBitmapImageRep class]] &&
  -        [imageRep valueForProperty:NSImageColorSyncProfileData] == nil &&
  -        [[imageRep colorSpaceName] isEqualToString:NSCalibratedRGBColorSpace]) {
  -        [imageRep setColorSpaceName:NSDeviceRGBColorSpace];
  -    }
  -#endif
  -}
  -
  -
  -- (void)drawClippedToValidInRect:(NSRect)ir fromRect:(NSRect)fr
  -{
  -    [self _adjustColorSpace];
  -
  -    if (loadStatus >= 0) {
  -        // The last line might be a partial line, so the number of complete lines is the number
  -        // we get from NSImage minus one.
  -        int numCompleteLines = loadStatus - 1;
  -        if (numCompleteLines <= 0) {
  -            return;
  -        }
  -        int pixelsHigh = [[[self representations] objectAtIndex:0] pixelsHigh];
  -        if (pixelsHigh > numCompleteLines) {
  -            // Figure out how much of the image is OK to draw.  We can't simply
  -            // use numCompleteLines because the image may be scaled.
  -            float clippedImageHeight = floor([self size].height * numCompleteLines / pixelsHigh);
  -            
  -            // Figure out how much of the source is OK to draw from.
  -            float clippedSourceHeight = clippedImageHeight - fr.origin.y;
  -            if (clippedSourceHeight < 1) {
  -                return;
  -            }
  -            
  -            // Figure out how much of the destination we are going to draw to.
  -            float clippedDestinationHeight = ir.size.height * clippedSourceHeight / fr.size.height;
  -
  -            // Reduce heights of both rectangles without changing their positions.
  -            // In the flipped case, just adjusting the height is sufficient.
  -            ASSERT([self isFlipped]);
  -            ASSERT([[NSView focusView] isFlipped]);
  -            ir.size.height = clippedDestinationHeight;
  -            fr.size.height = clippedSourceHeight;
  -        }
  -    }
  -    
  -    if (context) {
  -        NSGraphicsContext *oldContext = [self _beginRedirectContext:context];
  -        [self _needsRasterFlush];
  -
  -        // If we have PDF then draw the PDF ourselves, bypassing the NSImage caching mechanisms,
  -        // but only do this when we're rendering to an offscreen context.  NSImage will always
  -        // cache the PDF image at it's native resolution, thus, causing artifacts when the image
  -        // is drawn into a scaled or rotated context.
  -        if ([MIMEType isEqual:@"application/pdf"])
  -            [self _PDFDrawFromRect:fr toRect:ir operation:compositeOperator alpha:1.0 flipped:YES];
  -        else
  -            [self drawInRect:ir fromRect:fr operation:compositeOperator fraction: 1.0];
  -
  -        [self _endRedirectContext:oldContext];
  -    }
  -    else {
  -        [self drawInRect:ir fromRect:fr operation:compositeOperator fraction: 1.0];
  -    }
  -}
  -
  -- (CGPDFDocumentRef)_PDFDocumentRef
  -{
  -    if (!_PDFDoc) {
  -        _PDFDoc = [[WebPDFDocument alloc] initWithData:originalData];
  -    }
  -        
  -    return [_PDFDoc documentRef];
  -}
  -
  -- (void)_PDFDraw
  -{
  -    CGPDFDocumentRef document = [self _PDFDocumentRef];
  -    if (document != NULL) {
  -        CGContextRef _context  = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
  -        CGRect       mediaBox = [_PDFDoc mediaBox];
  -        
  -        CGContextSaveGState(_context);
  -        // Rotate translate image into position according to doc properties.
  -        [_PDFDoc adjustCTM:_context];	
  -
  -        // Media box may have non-zero origin which we ignore. CGPDFDocumentShowPage pages start
  -        // at 1, not 0.
  -        CGContextDrawPDFDocument(_context, CGRectMake(0, 0, mediaBox.size.width, mediaBox.size.height), document, 1);
  -
  -        CGContextRestoreGState(_context);
  -    }
  -}
  -
  -- (BOOL)_PDFDrawFromRect:(NSRect)srcRect toRect:(NSRect)dstRect operation:(NSCompositingOperation)op alpha:(float)alpha flipped:(BOOL)flipped
  -{
  -    // FIXME:  The rasterized PDF should be drawn into a cache, and the raster then composited.
  -    
  -    CGContextRef _context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
  -    float hScale, vScale;
  -
  -    CGContextSaveGState(_context);
  -
  -    [[NSGraphicsContext currentContext] setCompositingOperation:op];
  -    // Scale and translate so the document is rendered in the correct location.
  -    hScale = dstRect.size.width  / srcRect.size.width;
  -    vScale = dstRect.size.height / srcRect.size.height;
  -
  -    CGContextTranslateCTM (_context, dstRect.origin.x - srcRect.origin.x * hScale, dstRect.origin.y - srcRect.origin.y * vScale);
  -    CGContextScaleCTM (_context, hScale, vScale);
  -
  -    // Reverse if flipped image.
  -    if (flipped) {
  -        CGContextScaleCTM(_context, 1, -1);
  -        CGContextTranslateCTM (_context, 0, -(dstRect.origin.y + dstRect.size.height));
  -    }
  -
  -    // Clip to destination in case we are imaging part of the source only
  -    CGContextClipToRect(_context, CGRectIntegral(*(CGRect*)&srcRect));
  -
  -    // and draw
  -    [self _PDFDraw];
  -
  -    // done with our fancy transforms
  -    CGContextRestoreGState(_context);
  -
  -    return YES;
  -}
  -
  -- (void)resetAnimation
  -{
  -    [self stopAnimation];
  -    [self setCurrentFrame:0];
  -    repetitionsComplete = 0;
  -    animationFinished = NO;
  -}
  -
  -- (void)nextFrame:(id)context
  -{
  -    int currentFrame;
  -    
  -    // Release the timer that just fired.
  -    [frameTimer release];
  -    frameTimer = nil;
  -    
  -    currentFrame = [self currentFrame] + 1;
  -    if (currentFrame >= [self frameCount]) {
  -        repetitionsComplete += 1;
  -        if ([self repetitionCount] && repetitionsComplete >= [self repetitionCount]) {
  -            animationFinished = YES;
  -            return;
  -        }
  -        currentFrame = 0;
  -    }
  -    [self setCurrentFrame:currentFrame];
  -    
  -    // Release the tiling pattern so next frame will update the pattern if we're tiling.
  -    [patternColor release];
  -    patternColor = nil;
  -    
  -    [frameView setNeedsDisplayInRect:targetRect];
  -}
  -
  -// Will be called when the containing view is displayed by WebCore RenderImage (via QPainter).
  -// If the image is an animated image it will begin animating.  If the image is already animating,
  -// it's frame will have been advanced by nextFrame:.
  -//
  -// Also used to draw the image by WebImageView.
  -- (void)drawImageInRect:(NSRect)ir fromRect:(NSRect)fr
  -{
  -    if (animatedTile){
  -        [self tileInRect:ir fromPoint:tilePoint context:context];
  -    }
  -    else {
  -        [self drawClippedToValidInRect:ir fromRect:fr];
  -        imageRect = fr;
  -        targetRect = ir;
  -        [self startAnimationIfNecessary];
  -    }
  -}
  -
  -- (void)flushRasterCache
  -{
  -    needFlushRasterCache = YES;
  -}
  -
  -- (void)drawImageInRect:(NSRect)ir fromRect:(NSRect)fr compositeOperator:(NSCompositingOperation)operator context:(CGContextRef)aContext
  -{
  -    compositeOperator = operator;
  -    
  -    if (aContext != context) {
  -        if (aContext) {
  -            CGContextRetain(aContext);
  -        }
  -        if (context) {
  -            CGContextRelease(context);
  -        }
  -        context = aContext;
  -    }
  -        
  -    [self drawImageInRect:ir fromRect:fr];
  -}
  -
  -- (void)startAnimationIfNecessary
  -{
  -    if ([self frameCount] > 1 && !animationFinished) {
  -        NSView *newView = [NSView focusView];
  -        if (newView != frameView){
  -            [frameView release];
  -            frameView = [newView retain];
  -        }
  -        [self scheduleFrame];
  -        if (!activeImageRenderers) {
  -            activeImageRenderers = [[NSMutableSet alloc] init];
  -        }
  -        [activeImageRenderers addObject:self];
  -    }
  -}
  -
  -- (void)stopAnimation
  -{
  -    [frameTimer invalidate];
  -    [frameTimer release];
  -    frameTimer = nil;
  -    
  -    [frameView release];
  -    frameView = nil;
  -
  -    [activeImageRenderers removeObject:self];
  -}
  -
  -- (void)tileInRect:(NSRect)rect fromPoint:(NSPoint)point context:(CGContextRef)aContext
  -{
  -    // These calculations are only correct for the flipped case.
  -    ASSERT([self isFlipped]);
  -    ASSERT([[NSView focusView] isFlipped]);
  -
  -    [self _adjustColorSpace];
  -
  -    NSSize size = [self size];
  -
  -    // Check and see if a single draw of the image can cover the entire area we are supposed to tile.
  -    NSRect oneTileRect;
  -    oneTileRect.origin.x = rect.origin.x + fmodf(fmodf(-point.x, size.width) - size.width, size.width);
  -    oneTileRect.origin.y = rect.origin.y + fmodf(fmodf(-point.y, size.height) - size.height, size.height);
  -// I think this is a simpler way to say the same thing.  Also, if either point.x or point.y is negative, both
  -// methods would end up with the wrong answer.  For example, fmod(-22,5) is -2, which is the correct delta to
  -// the start of the pattern, but fmod(-(-23), 5) is 3.  This is the delta to the *end* of the pattern
  -// instead of the start, so onTileRect will be too far right.
  -//    oneTileRect.origin.x = rect.origin.x - fmodf(point.x, size.width);
  -//    oneTileRect.origin.y = rect.origin.y - fmodf(point.y, size.height);
  -    oneTileRect.size = size;
  -
  -    // If the single image draw covers the whole area, then just draw once.
  -    if (NSContainsRect(oneTileRect, rect)) {
  -        NSRect fromRect;
  -
  -        fromRect.origin.x = rect.origin.x - oneTileRect.origin.x;
  -        fromRect.origin.y = rect.origin.y - oneTileRect.origin.y;
  -        fromRect.size = rect.size;
  -        
  -        [self drawClippedToValidInRect:rect fromRect:fromRect];
  -        return;
  -    }
  -
  -    // If we only have a partial image, just do nothing, because CoreGraphics will not help us tile
  -    // with a partial image. But maybe later we can fix this by constructing a pattern image that's
  -    // transparent where needed.
  -    if (loadStatus != NSImageRepLoadStatusCompleted) {
  -        return;
  -    }
  -    
  -    // Since we need to tile, construct an NSColor so we can get CoreGraphics to do it for us.
  -    if (patternColorLoadStatus != loadStatus) {
  -        [patternColor release];
  -        patternColor = nil;
  -    }
  -    if (patternColor == nil) {
  -        patternColor = [[NSColor colorWithPatternImage:self] retain];
  -        patternColorLoadStatus = loadStatus;
  -    }
  -        
  -    NSGraphicsContext *oldContext = [self _beginRedirectContext:context];
  -    [self _needsRasterFlush];
  -    
  -    [NSGraphicsContext saveGraphicsState];
  -    
  -    CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
  -    CGPoint transformedOrigin = CGPointApplyAffineTransform(rect.origin, CGContextGetCTM(aContext));
  -    CGContextSetPatternPhase(context, CGSizeMake(transformedOrigin.x, transformedOrigin.y));    
  -    [patternColor set];
  -    [NSBezierPath fillRect:rect];
  -    
  -    [NSGraphicsContext restoreGraphicsState];
  -
  -    [self _endRedirectContext:oldContext];
  -
  -    animatedTile = YES;
  -    tilePoint = point;
  -    targetRect = rect;
  -    [self startAnimationIfNecessary];
  -}
  -
  -- (void)resize:(NSSize)s
  -{
  -    [self setScalesWhenResized:YES];
  -    [self setSize:s];
  -}
  -
  -- (NSString *)MIMEType
  -{
  -    return MIMEType;
  -}
  -
  -// Try hard to get a CGImageRef.  First try to snag one from the
  -// NSBitmapImageRep, then try to create one.  In some cases we may
  -// not be able to create one.
  -- (CGImageRef)imageRef
  -{
  -    CGImageRef ref = 0;
  -    
  -    if (cachedImageRef)
  -        return cachedImageRef;
  -        
  -    if ([[self representations] count] > 0) {
  -        NSBitmapImageRep *rep = [[self representations] objectAtIndex:0];
  -        
  -        if ([rep respondsToSelector:@selector(_CGImageRef)])
  -            ref =  [rep _CGImageRef];
  -            
  -        if (!ref) {
  -            cachedImageRef = _createImageRef(rep);
  -            ref = cachedImageRef;
  -        }
  -    }
  -    return ref;
  -}
  -
  -- (void)releasePatternColor
  -{
  -    [patternColor release];
  -    patternColor = nil;
  -}
  -
  - at end
  -
  - at implementation WebImageRenderer
  -
  -- (id)initWithMIMEType:(NSString *)MIME
  -{
  -    WebInternalImage *i = [[WebInternalImage alloc] initWithMIMEType:MIME];
  -    if (i == nil) {
  -        [self dealloc];
  -        return nil;
  -    }
  -    [self init];
  -    image = i;
  -    return self;
  -}
  -
  -- (id)initWithData:(NSData *)data MIMEType:(NSString *)MIME
  -{
  -    WebInternalImage *i = [[WebInternalImage alloc] initWithData:data MIMEType:MIME];
  -    if (i == nil) {
  -        [self dealloc];
  -        return nil;
  -    }
  -    [self init];
  -    image = i;
  -    return self;
  -}
  -
  -- (id)initWithContentsOfFile:(NSString *)filename
  -{
  -    WebInternalImage *i = [[WebInternalImage alloc] initWithContentsOfFile:filename];
  -    if (i == nil) {
  -        [self dealloc];
  -        return nil;
  -    }
  -    [self init];
  -    image = i;
  -    return self;
  -}
  -
  -- (void)dealloc
  -{
  -    [image releasePatternColor];
  -    [image release];
  -    [super dealloc];
  -}
  -
  -- (NSImage *)image
  -{
  -    return image;
  -}
  -
  -- (NSString *)MIMEType
  -{
  -    return [image MIMEType];
  -}
  -
  -- (NSData *)TIFFRepresentation
  -{
  -    return [image TIFFRepresentation];
  -}
  -
  -- (int)frameCount
  -{
  -    return [image frameCount];
  -}
  -
  -- (void)setOriginalData:(NSData *)data
  -{
  -    NSData *oldData = image->originalData;
  -    image->originalData = [data retain];
  -    [oldData release];
  -}
  -
  -+ (void)stopAnimationsInView:(NSView *)aView
  -{
  -    [WebInternalImage stopAnimationsInView:aView];
  -}
  -
  -- (BOOL)incrementalLoadWithBytes:(const void *)bytes length:(unsigned)length complete:(BOOL)isComplete callback:(id)c
  -{
  -    return [image incrementalLoadWithBytes:bytes length:length complete:isComplete callback:c];
  -}
  -
  -- (NSSize)size
  -{
  -    if (!image)
  -	return NSZeroSize;
  -	
  -    return [image size];
  -}
  -
  -- (void)resize:(NSSize)s
  -{
  -    [image resize:s];
  -}
  -
  -- (void)drawImageInRect:(NSRect)ir fromRect:(NSRect)fr
  -{
  -    [image drawImageInRect:ir fromRect:fr];
  -}
  -
  -- (void)drawImageInRect:(NSRect)ir fromRect:(NSRect)fr compositeOperator:(NSCompositingOperation)compsiteOperator context:(CGContextRef)context
  -{
  -    [image drawImageInRect:ir fromRect:fr compositeOperator:compsiteOperator context:context];
  -}
  -
  -- (void)resetAnimation
  -{
  -    [image resetAnimation];
  -}
  -
  -- (void)stopAnimation
  -{
  -    [image stopAnimation];
  -}
  -
  -- (void)tileInRect:(NSRect)r fromPoint:(NSPoint)p context:(CGContextRef)context
  -{
  -    [image tileInRect:r fromPoint:p context:context];
  -}
  -
  -- (BOOL)isNull
  -{
  -    return image == nil || [image isNull];
  -}
  -
  -- (id <WebCoreImageRenderer>)retainOrCopyIfNeeded
  -{
  -    WebImageRenderer *newRenderer = [image createRendererIfNeeded];
  -    if (newRenderer) {
  -        return newRenderer;
  -    }
  -    [self retain];
  -    return self;
  -}
  -
  -- (void)increaseUseCount
  -{
  -    [image increaseUseCount];
  -}
  -
  -- (void)decreaseUseCount
  -{
  -    [image decreaseUseCount];
  -}
  -
  -- (void)flushRasterCache
  -{
  -    [image flushRasterCache];
  -}
  -
  -- (CGImageRef)imageRef
  -{
  -    return [image imageRef];
  -}
  -
  -- (id)copyWithZone:(NSZone *)zone
  -{
  -    WebImageRenderer *copy = [[WebImageRenderer alloc] init];
  -    copy->image = [image copy];
  -    return copy;
  -}
  -
  - at end
  -
  -static CGImageRef _createImageRef(NSBitmapImageRep *rep) {
  -    BOOL isPlanar = [rep isPlanar];
  -    if (isPlanar)
  -        return 0;
  -        
  -    const unsigned char *bitmapData = [rep bitmapData];
  -    int pixelsWide = [rep pixelsWide];
  -    int pixelsHigh = [rep pixelsHigh];
  -    int bitsPerSample = [rep bitsPerSample];
  -    int bitsPerPixel = [rep bitsPerPixel];
  -    int bytesPerRow = [rep bytesPerRow];
  -    BOOL hasAlpha = [rep hasAlpha];
  -    CGImageRef image;
  -    CGDataProviderRef dataProvider;
  -
  -    CGColorSpaceRef colorSpace = WebCGColorSpaceCreateRGB();
  -    dataProvider = CGDataProviderCreateWithData(NULL, bitmapData, pixelsHigh * bytesPerRow, NULL);
  -
  -    image = CGImageCreate(pixelsWide, pixelsHigh, bitsPerSample, bitsPerPixel, bytesPerRow, colorSpace,
  -                          hasAlpha ? kCGImageAlphaPremultipliedLast : kCGImageAlphaNone,
  -                          dataProvider, NULL, false /*shouldInterpolate*/, kCGRenderingIntentDefault);
  -
  -    CGDataProviderRelease(dataProvider);
  -    CGColorSpaceRelease(colorSpace);	
  -
  -    return image;
  -}
  -
  -#endif
  -
   //------------------------------------------------------------------------------------
   
   @implementation WebPDFDocument
   
  -static void ReleasePDFDocumentData(void *info, const void *data, size_t size) {
  -    [(NSData*)info autorelease];
  +static void ReleasePDFDocumentData(void *info, const void *data, size_t size)
  +{
  +    [(id)info autorelease];
   }
   
  -- (id) initWithData:(NSData*)data
  +- (id)initWithData:(NSData*)data
   {
       self = [super init];
       if (self != nil)
  @@ -1516,55 +412,3 @@
   }
   
   @end
  -
  -CGColorSpaceRef WebCGColorSpaceCreateRGB(void)
  -{
  -#ifdef COLORMATCH_EVERYTHING
  -#if BUILDING_ON_PANTHER
  -    return CGColorSpaceCreateWithName(kCGColorSpaceUserRGB);
  -#else // !BUILDING_ON_PANTHER
  -    return CGColorSpaceCreateDeviceRGB();
  -#endif // BUILDING_ON_PANTHER
  -#else // !COLORMATCH_EVERYTHING
  -#if BUILDING_ONPANTHER
  -    return CGColorSpaceCreateDeviceRGB();
  -#else // !BUILDING_ON_PANTHER
  -    return CGColorSpaceCreateDeviceRGB();
  -#endif // BUILDING_ON_PANTHER
  -#endif    
  -}
  -
  -CGColorSpaceRef WebCGColorSpaceCreateGray(void)
  -{
  -#ifdef COLORMATCH_EVERYTHING
  -#if BUILDING_ON_PANTHER
  -    return CGColorSpaceCreateWithName(kCGColorSpaceUserGray);
  -#else // !BUILDING_ON_PANTHER
  -    return CGColorSpaceCreateDeviceGray();
  -#endif // BUILDING_ON_PANTHER
  -#else // !COLORMATCH_EVERYTHING
  -#if BUILDING_ONPANTHER
  -    return CGColorSpaceCreateDeviceGray();
  -#else // !BUILDING_ON_PANTHER
  -    return CGColorSpaceCreateDeviceGray();
  -#endif // BUILDING_ON_PANTHER
  -#endif    
  -}
  -
  -CGColorSpaceRef WebCGColorSpaceCreateCMYK(void)
  -{
  -#ifdef COLORMATCH_EVERYTHING
  -#if BUILDING_ON_PANTHER
  -    return CGColorSpaceCreateWithName(kCGColorSpaceUserCMYK);
  -#else // !BUILDING_ON_PANTHER
  -    return CGColorSpaceCreateDeviceCMYK();
  -#endif // BUILDING_ON_PANTHER
  -#else // !COLORMATCH_EVERYTHING
  -#if BUILDING_ONPANTHER
  -    return CGColorSpaceCreateDeviceCMYK();
  -#else // !BUILDING_ON_PANTHER
  -    // FIXME: no device CMYK
  -    return CGColorSpaceCreateDeviceCMYK();
  -#endif // BUILDING_ON_PANTHER
  -#endif    
  -}
  
  
  
  1.31      +4 -58     WebKit/WebCoreSupport.subproj/WebImageRendererFactory.m
  
  Index: WebImageRendererFactory.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebImageRendererFactory.m,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- WebImageRendererFactory.m	14 Jul 2005 02:43:51 -0000	1.30
  +++ WebImageRendererFactory.m	16 Aug 2005 17:36:37 -0000	1.31
  @@ -49,29 +49,7 @@
   
   - (id <WebCoreImageRenderer>)imageRendererWithMIMEType:(NSString *)MIMEType
   {
  -    WebImageRenderer *imageRenderer = [[WebImageRenderer alloc] initWithMIMEType:MIMEType];
  -
  -#ifndef USE_CGIMAGEREF
  -    NSImage *image = [imageRenderer image];
  -
  -    if (![MIMEType isEqual:@"application/pdf"]) {
  -        NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initForIncrementalLoad];
  -        [image addRepresentation:rep];
  -        [rep autorelease];
  -    }
  -
  -    [image setFlipped:YES];
  -    
  -    // Turn the default caching mode back on when the image has completed load.
  -    // Caching intermediate progressive representations causes problems for
  -    // progressive loads.  We also rely on the NSBitmapImageRep surviving during
  -    // incremental loads.  See 3165631 and 3262592.
  -    [image setCacheMode: NSImageCacheNever];
  -
  -    [image setScalesWhenResized:NO];
  -#endif
  -        
  -    return [imageRenderer autorelease];
  +    return [[[WebImageRenderer alloc] initWithMIMEType:MIMEType] autorelease];
   }
   
   - (id <WebCoreImageRenderer>)imageRenderer
  @@ -81,30 +59,7 @@
   
   - (id <WebCoreImageRenderer>)imageRendererWithData:(NSData*)data MIMEType:(NSString *)MIMEType
   {
  -    WebImageRenderer *imageRenderer = [[WebImageRenderer alloc] initWithData:data MIMEType:MIMEType];
  -
  -#ifndef USE_CGIMAGEREF
  -    NSImage *image = [imageRenderer image];
  -
  -    NSArray *reps = [image representations];
  -    if ([reps count] == 0){
  -        [imageRenderer release];
  -        return nil;
  -    }
  -    
  -    // Force the image to use the pixel size and ignore the dpi.
  -    [image setScalesWhenResized:NO];
  -    if ([reps count] > 0){
  -        NSImageRep *rep = [reps objectAtIndex:0];
  -        [rep setSize:NSMakeSize([rep pixelsWide], [rep pixelsHigh])];
  -        if ([imageRenderer frameCount] > 1)
  -            [imageRenderer setOriginalData:data];
  -    }
  -    
  -    [image setFlipped:YES];
  -#endif
  -
  -    return [imageRenderer autorelease];
  +    return [[[WebImageRenderer alloc] initWithData:data MIMEType:MIMEType] autorelease];
   }
   
   - (id <WebCoreImageRenderer>)imageRendererWithBytes:(const void *)bytes length:(unsigned)length MIMEType:(NSString *)MIMEType
  @@ -122,21 +77,12 @@
   
   - (id <WebCoreImageRenderer>)imageRendererWithSize:(NSSize)s
   {
  -    WebImageRenderer *imageRenderer = [[[WebImageRenderer alloc] initWithSize:s] autorelease];
  -#ifndef USE_CGIMAGEREF
  -    [[imageRenderer image] setScalesWhenResized:NO];
  -#endif
  -    return imageRenderer;
  +    return [[[WebImageRenderer alloc] initWithSize:s] autorelease];
   }
   
   - (id <WebCoreImageRenderer>)imageRendererWithName:(NSString *)name
   {
  -    WebImageRenderer *imageRenderer = [[[WebImageRenderer alloc] initWithContentsOfFile:name] autorelease];
  -#ifndef USE_CGIMAGEREF
  -    [[imageRenderer image] setScalesWhenResized:NO];
  -    [[imageRenderer image] setFlipped:YES];
  -#endif
  -    return imageRenderer;
  +    return [[[WebImageRenderer alloc] initWithContentsOfFile:name] autorelease];
   }
   
   struct CompositeOperator
  
  
  



More information about the webkit-changes mailing list