Fixed <rdar://problem/3885073> REGRESSION: Tab images at top of news.com.com replica...
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Nov 2004 03:20:36 +0000 (03:20 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Nov 2004 03:20:36 +0000 (03:20 +0000)
Correctly account for scaled image size and clipping.

        Reviewed by Maciej.

        * WebCoreSupport.subproj/WebImageData.h:
        * WebCoreSupport.subproj/WebImageData.m:
        * WebCoreSupport.subproj/WebImageRenderer.m:
        (-[WebImageRenderer drawImageInRect:fromRect:compositeOperator:context:]):

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

WebKit/ChangeLog
WebKit/WebCoreSupport.subproj/WebImageData.h
WebKit/WebCoreSupport.subproj/WebImageData.m
WebKit/WebCoreSupport.subproj/WebImageRenderer.m

index 2a8a1cfda831d9c4184b08dbbe78a36891adab2a..30839ff618dd1ad5426d4aaf3b12f054b2e31f4e 100644 (file)
@@ -1,3 +1,16 @@
+2004-11-17  Richard Williamson   <rjw@apple.com>
+
+       Fixed <rdar://problem/3885073> REGRESSION: Tab images at top of news.com.com replicated and squished
+
+       Correctly account for scaled image size and clipping.
+
+        Reviewed by Maciej.
+
+        * WebCoreSupport.subproj/WebImageData.h:
+        * WebCoreSupport.subproj/WebImageData.m:
+        * WebCoreSupport.subproj/WebImageRenderer.m:
+        (-[WebImageRenderer drawImageInRect:fromRect:compositeOperator:context:]):
+
 2004-11-17  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Richard.
index 1e230b61621fd17dc8343dd3c3ce86cc04c3317b..aeecf94b60b5e513a78615fd4eaaebf77bb3c3a5 100644 (file)
@@ -36,6 +36,7 @@
 - (size_t)numberOfImages;
 - (CGImageRef)imageAtIndex:(size_t)index;
 - (BOOL)incrementalLoadWithBytes:(const void *)bytes length:(unsigned)length complete:(BOOL)isComplete;
+- (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr adjustedSize:(CGSize)size compositeOperation:(CGCompositeOperation)op context:(CGContextRef)aContext;
 - (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr compositeOperation:(CGCompositeOperation)op context:(CGContextRef)aContext;
 - (void)tileInRect:(CGRect)rect fromPoint:(CGPoint)point context:(CGContextRef)aContext;
 - (BOOL)isNull;
index c1a80df597b3412cde1f0b559442095d93946afd..b70f269cfeabd65a06212e07a93edbd798241ef8 100644 (file)
@@ -215,7 +215,7 @@ static CFDictionaryRef imageSourceOptions;
     return YES;
 }
 
-- (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr compositeOperation:(CGCompositeOperation)op context:(CGContextRef)aContext;
+- (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr adjustedSize:(CGSize)adjustedSize compositeOperation:(CGCompositeOperation)op context:(CGContextRef)aContext;
 {    
     CGImageRef image = [self imageAtIndex:index];
     
@@ -224,16 +224,17 @@ static CFDictionaryRef imageSourceOptions;
 
     CGContextSaveGState (aContext);
 
-    //float w = CGImageGetWidth(image);
+    // Get the height of the portion of the image that is currently decoded.  This
+    // could be less that the actual height.
     float h = CGImageGetHeight(image);
 
     // Is the amount of available bands less than what we need to draw?  If so,
     // clip.
-    BOOL clipping = NO;
+    BOOL clipped = NO;
     if (h < fr.size.height) {
        fr.size.height = h;
        ir.size.height = h;
-       clipping = YES;
+       clipped = YES;
     }
     
     // Flip the coords.
@@ -248,9 +249,7 @@ static CFDictionaryRef imageSourceOptions;
     // If we're drawing a sub portion of the image then create
     // a image for the sub portion and draw that.
     // Test using example site at http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html
-    if (fr.origin.x != 0 || fr.origin.y != 0 || 
-       fr.size.width != ir.size.width || fr.size.height != fr.size.height ||
-       clipping) {
+    if (clipped == NO && (fr.size.width != adjustedSize.width || fr.size.height != adjustedSize.height)) {
         image = CGImageCreateWithImageInRect (image, fr);
         if (image) {
             CGContextDrawImage (aContext, ir, image);
@@ -265,6 +264,11 @@ static CFDictionaryRef imageSourceOptions;
     CGContextRestoreGState (aContext);
 }
 
+- (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr compositeOperation:(CGCompositeOperation)op context:(CGContextRef)aContext;
+{    
+    [self drawImageAtIndex:index inRect:ir fromRect:fr adjustedSize:[self size] compositeOperation:op context:aContext];
+}
+
 static void drawPattern (void * info, CGContextRef context)
 {
     CGImageRef image = (CGImageRef)info;
index 2c655e0b4d5a9700f0089342a88efbc1ddc396b5..ed9455d2e04df3d6b0dfffdacd7ab99d75abefbf 100644 (file)
     if (op == kCGCompositeUnknown)
         op = kCGCompositeSover;
         
-    [imageData drawImageAtIndex:[imageData currentFrame] inRect:CGRectMake(ir.origin.x, ir.origin.y, ir.size.width, ir.size.height) 
-                    fromRect:CGRectMake(fr.origin.x, fr.origin.y, fr.size.width, fr.size.height) 
-                    compositeOperation:op context:aContext];
+    if (isSizeAdjusted) {
+       [imageData drawImageAtIndex:[imageData currentFrame] inRect:CGRectMake(ir.origin.x, ir.origin.y, ir.size.width, ir.size.height) 
+                       fromRect:CGRectMake(fr.origin.x, fr.origin.y, fr.size.width, fr.size.height) 
+                       adjustedSize:CGSizeMake(adjustedSize.width, adjustedSize.height)
+                       compositeOperation:op context:aContext];
+    }
+    else {
+       [imageData drawImageAtIndex:[imageData currentFrame] inRect:CGRectMake(ir.origin.x, ir.origin.y, ir.size.width, ir.size.height) 
+                       fromRect:CGRectMake(fr.origin.x, fr.origin.y, fr.size.width, fr.size.height) 
+                       compositeOperation:op context:aContext];
+    }
 
     targetAnimationRect = ir;
     [self _startOrContinueAnimationIfNecessary];