Report actual size (not partial size) but use partial size
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Nov 2004 02:55:18 +0000 (02:55 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Nov 2004 02:55:18 +0000 (02:55 +0000)
        when drawing.

        Reviewed by Maciej.

        * WebCoreSupport.subproj/WebImageData.h:
        * WebCoreSupport.subproj/WebImageData.m:
        (-[WebImageData size]):

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

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

index 9cd4ef5eff08d78d4038adbc42a6200168ca715d..620fe354e67088c0f3b7c65c490d0e7dab992be2 100644 (file)
@@ -1,3 +1,14 @@
+2004-11-11  Richard Williamson   <rjw@apple.com>
+
+        Report actual size (not partial size) but use partial size
+        when drawing.
+
+        Reviewed by Maciej.
+
+        * WebCoreSupport.subproj/WebImageData.h:
+        * WebCoreSupport.subproj/WebImageData.m:
+        (-[WebImageData size]):
+
 2004-11-11  Darin Adler  <darin@apple.com>
 
         Reviewed by John.
index 99077564ebf845b79536410598bd8697b6193465..defd76ae9be69a1305607f6007559b8c392b8e5f 100644 (file)
@@ -165,6 +165,13 @@ static CFDictionaryRef imageSourceOptions;
     float w = CGImageGetWidth(image);
     float h = CGImageGetHeight(image);
 
+    // Is the amount of available bands less than what we need to draw?  If so,
+    // clip.
+    if (h < fr.size.height) {
+       fr.size.height = h;
+       ir.size.height = h;
+    }
+    
     // Flip the coords.
     CGContextSetCompositeOperation (aContext, op);
     CGContextTranslateCTM (aContext, ir.origin.x, ir.origin.y);
@@ -281,12 +288,25 @@ CGPatternCallbacks patternCallbacks = { 0, drawPattern, NULL };
 - (CGSize)size
 {
     float w = 0.f, h = 0.f;
-    CGImageRef image = [self imageAtIndex:0];
-    if (image) {
-        h = CGImageGetHeight(image);
-        w = CGImageGetWidth(image);
+
+    if (!haveSize) {
+       CFDictionaryRef properties = CGImageSourceGetPropertiesAtIndex (imageSource, 0, 0);
+       if (properties) {
+           CFNumberRef num = CFDictionaryGetValue (properties, kCGImagePropertyPixelWidth);
+           if (num)
+               CFNumberGetValue (num, kCFNumberFloat32Type, &w);
+           num = CFDictionaryGetValue (properties, kCGImagePropertyPixelHeight);
+           if (num)
+               CFNumberGetValue (num, kCFNumberFloat32Type, &h);
+
+           size.width = w;
+           size.height = h;
+           
+           haveSize = YES;
+       }
     }
-    return CGSizeMake(w,h);
+    
+    return size;
 }
 
 #define MINIMUM_DURATION (1.0/30.0)