Fixed <rdar://problem/3926825> Safari ignores GIF loop count
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Jan 2005 21:41:05 +0000 (21:41 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Jan 2005 21:41:05 +0000 (21:41 +0000)
Get loop count from file properties, not image properties.

        Reviewed by Ken Kocienda.

        * WebCoreSupport.subproj/WebImageData.h:
        * WebCoreSupport.subproj/WebImageData.m:
        (-[WebImageData _commonTermination]):
        (-[WebImageData fileProperties]):
        (-[WebImageData _floatProperty:type:at:]):
        (-[WebImageData _floatFileProperty:type:]):
        (-[WebImageData _repetitionCount]):

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

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

index ee73445ba493a8e3e8772bcf8f6e1a4ca180393a..f4b60b37b3ec42cbb4f1a10b2ea31969d16718b0 100644 (file)
@@ -1,3 +1,19 @@
+2005-01-12  Richard Williamson   <rjw@apple.com>
+
+       Fixed <rdar://problem/3926825> Safari ignores GIF loop count
+
+       Get loop count from file properties, not image properties.
+
+        Reviewed by Ken Kocienda.
+
+        * WebCoreSupport.subproj/WebImageData.h:
+        * WebCoreSupport.subproj/WebImageData.m:
+        (-[WebImageData _commonTermination]):
+        (-[WebImageData fileProperties]):
+        (-[WebImageData _floatProperty:type:at:]):
+        (-[WebImageData _floatFileProperty:type:]):
+        (-[WebImageData _repetitionCount]):
+
 2005-01-11  Chris Blumenberg  <cblu@apple.com>
 
        Fixed: <rdar://problem/3934749> assertion failure in WebBaseNetscapePluginView loading movie
index 6ce0b579f1818fb7b265ea03c558d1ef6596326c..de407670568106eb347891171313d99464fda7ba 100644 (file)
@@ -15,6 +15,7 @@
     size_t imagesSize;
     CGImageRef *images;
     size_t imagePropertiesSize;
+    CFDictionaryRef fileProperties;
     CFDictionaryRef *imageProperties;
     CGImageSourceRef imageSource;
 
index a0a0bd21997b9253964a3c090d0f8bddd078e176..b28719e114f949d3763d85ef6be95e3802b87d5c 100644 (file)
@@ -77,6 +77,9 @@ static CFDictionaryRef imageSourceOptions;
     [self _invalidateImages];
     [self _invalidateImageProperties];
         
+    if (fileProperties)
+       CFRelease (fileProperties);
+       
     if (imageSource)
         CFRelease (imageSource); 
         
@@ -197,6 +200,15 @@ static CFDictionaryRef imageSourceOptions;
     return images[index];
 }
 
+- (CFDictionaryRef)fileProperties
+{
+    if (!fileProperties) {
+       fileProperties = CGImageSourceCopyProperties (imageSource, 0);
+    }
+    
+    return fileProperties;
+}
+
 - (CFDictionaryRef)propertiesAtIndex:(size_t)index
 {
     size_t num = [self numberOfImages];
@@ -556,7 +568,6 @@ CGPatternCallbacks patternCallbacks = { 0, drawPattern, NULL };
         return 0.f;
     }
     
-    // FIXME:  Use constant instead of DelayTime
     CFNumberRef num = CFDictionaryGetValue (typeProperties, property);
     if (!num) {
         [decodeLock unlock];
@@ -571,6 +582,38 @@ CGPatternCallbacks patternCallbacks = { 0, drawPattern, NULL };
     return value;
 }
 
+- (float)_floatFileProperty:(CFStringRef)property type:(CFStringRef)type 
+{
+    [decodeLock lock];
+    
+    CFDictionaryRef properties = [self fileProperties];
+    if (!properties) {
+        [decodeLock unlock];
+        return 0.f;
+    }
+    
+    if (type) {
+       properties = CFDictionaryGetValue (properties, type);
+       if (!properties) {
+           [decodeLock unlock];
+           return 0.f;
+       }
+    }
+    
+    CFNumberRef num = CFDictionaryGetValue (properties, property);
+    if (!num) {
+        [decodeLock unlock];
+        return 0.f;
+    }
+    
+    float value = 0.f;
+    CFNumberGetValue (num, kCFNumberFloat32Type, &value);
+
+    [decodeLock unlock];
+    
+    return value;
+}
+
 #define MINIMUM_DURATION (1.0/30.0)
 
 - (float)_frameDurationAt:(size_t)i
@@ -619,7 +662,7 @@ CGPatternCallbacks patternCallbacks = { 0, drawPattern, NULL };
 
 - (int)_repetitionCount
 {
-    return [self _floatProperty:kCGImagePropertyGIFLoopCount type:kCGImagePropertyGIFDictionary at:0];
+    return [self _floatFileProperty:kCGImagePropertyGIFLoopCount type:kCGImagePropertyGIFDictionary];
 }
 
 - (BOOL)isAnimationFinished