Fixed <rdar://problem/3911719> REGRESSION: Images no longer scale vertically
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Dec 2004 01:20:31 +0000 (01:20 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Dec 2004 01:20:31 +0000 (01:20 +0000)
Account for scaling correctly when taking into account progressively
  loaded images.

Also added implementation of repetition count for animated GIF images.
Also replaced strings with new constants from CFImageProperties.h

Also fixed possible problem with -(NSSize)size implementation,
relevant to Panther only.

        Reviewed by Chris.

        * WebCoreSupport.subproj/WebImageData.m:
        (-[WebImageData _floatProperty:type:at:]):
        (-[WebImageData _frameDurationAt:]):
        (-[WebImageData _repetitionCount]):
        * WebCoreSupport.subproj/WebImageRenderer.m:
        (-[WebImageRenderer size]):

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

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

index 0a579dca22e103a882c40c86a68378d9f148bafa..cae7a606dfcc4ce2702953ff45d5322d3a7f0af1 100644 (file)
@@ -1,3 +1,24 @@
+2004-12-08  Richard Williamson   <rjw@apple.com>
+
+       Fixed <rdar://problem/3911719> REGRESSION: Images no longer scale vertically
+       Account for scaling correctly when taking into account progressively
+       loaded images.
+
+       Also added implementation of repetition count for animated GIF images.
+       Also replaced strings with new constants from CFImageProperties.h
+
+       Also fixed possible problem with -(NSSize)size implementation,
+       relevant to Panther only.
+
+        Reviewed by Chris.
+
+        * WebCoreSupport.subproj/WebImageData.m:
+        (-[WebImageData _floatProperty:type:at:]):
+        (-[WebImageData _frameDurationAt:]):
+        (-[WebImageData _repetitionCount]):
+        * WebCoreSupport.subproj/WebImageRenderer.m:
+        (-[WebImageRenderer size]):
+
 2004-12-08  Chris Blumenberg  <cblu@apple.com>
 
        Removed NPN wrappers since these no longer need to be defined to make the QT plug-in work
index 4aa599d8ba7892a9e3f06433cfbc698b5cbc14bf..92f4324c631fb59ad3ecc12eb58fd095796ad407 100644 (file)
@@ -264,10 +264,12 @@ static CFDictionaryRef imageSourceOptions;
     // Is the amount of available bands less than what we need to draw?  If so,
     // clip.
     BOOL clipped = NO;
-    if (h < fr.size.height) {
-        fr.size.height = h;
-        ir.size.height = h;
-        clipped = YES;
+    CGSize actualSize = [self size];
+    if (h != actualSize.height) {
+       float proportionLoaded = h/actualSize.height;
+       fr.size.height = fr.size.height * proportionLoaded;
+       ir.size.height = ir.size.height * proportionLoaded;
+       clipped = YES;
     }
     
     // Flip the coords.
@@ -427,9 +429,7 @@ CGPatternCallbacks patternCallbacks = { 0, drawPattern, NULL };
     return size;
 }
 
-#define MINIMUM_DURATION (1.0/30.0)
-
-- (float)_frameDurationAt:(size_t)i
+- (float)_floatProperty:(CFStringRef)property type:(CFStringRef)type at:(size_t)i
 {
     [decodeLock lock];
     
@@ -439,22 +439,32 @@ CGPatternCallbacks patternCallbacks = { 0, drawPattern, NULL };
         return 0.f;
     }
     
-    // FIXME:  Use constant instead of {GIF}
-    CFDictionaryRef GIFProperties = CFDictionaryGetValue (properties, @"{GIF}");
-    if (!GIFProperties) {
+    CFDictionaryRef typeProperties = CFDictionaryGetValue (properties, type);
+    if (!typeProperties) {
         [decodeLock unlock];
         return 0.f;
     }
     
     // FIXME:  Use constant instead of DelayTime
-    CFNumberRef num = CFDictionaryGetValue (GIFProperties, @"DelayTime");
+    CFNumberRef num = CFDictionaryGetValue (typeProperties, property);
     if (!num) {
         [decodeLock unlock];
         return 0.f;
     }
     
-    float duration = 0.f;
-    CFNumberGetValue (num, kCFNumberFloat32Type, &duration);
+    float value = 0.f;
+    CFNumberGetValue (num, kCFNumberFloat32Type, &value);
+
+    [decodeLock unlock];
+    
+    return value;
+}
+
+#define MINIMUM_DURATION (1.0/30.0)
+
+- (float)_frameDurationAt:(size_t)i
+{
+    float duration = [self _floatProperty:kCGImagePropertyGIFDelayTime type:kCGImagePropertyGIFDictionary at:i];
     if (duration < MINIMUM_DURATION) {
         /*
             Many annoying ads specify a 0 duration to make an image flash
@@ -468,9 +478,6 @@ CGPatternCallbacks patternCallbacks = { 0, drawPattern, NULL };
         */
         duration = MINIMUM_DURATION;
     }
-
-    [decodeLock unlock];
-    
     return duration;
 }
 
@@ -501,8 +508,7 @@ CGPatternCallbacks patternCallbacks = { 0, drawPattern, NULL };
 
 - (int)_repetitionCount
 {
-    // FIXME:  Need to get this from CG folks.
-    return 0;
+    return [self _floatProperty:kCGImagePropertyGIFLoopCount type:kCGImagePropertyGIFDictionary at:0];
 }
 
 - (BOOL)isAnimationFinished
index 9e0decf48d1e9b06d1148f1c69dbc20fdef74a8f..39859caeaa4178568c88f526bfa53556d0419657 100644 (file)
@@ -1261,6 +1261,9 @@ static NSMutableSet *activeImageRenderers;
 
 - (NSSize)size
 {
+    if (!image)
+       return NSZeroSize;
+       
     return [image size];
 }