Changeset 47585 in webkit
- Timestamp:
- Aug 20, 2009, 12:24:38 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/WebCore/ChangeLog ¶
r47583 r47585 1 2009-08-20 Dan Bernstein <mitz@apple.com> 2 3 Reviewed by Geoffrey Garen. 4 5 Replace many manually-released CFTypeRefs with RetainPtrs 6 https://bugs.webkit.org/show_bug.cgi?id=28498 7 8 * platform/graphics/cg/ColorCG.cpp: 9 (WebCore::createCGColor): 10 * platform/graphics/cg/GradientCG.cpp: 11 (WebCore::Gradient::platformGradient): 12 * platform/graphics/cg/GraphicsContextCG.cpp: 13 (WebCore::GraphicsContext::platformContext): 14 (WebCore::GraphicsContext::applyStrokePattern): 15 (WebCore::GraphicsContext::applyFillPattern): 16 (WebCore::GraphicsContext::setPlatformShadow): 17 (WebCore::GraphicsContext::setURLForRect): 18 * platform/graphics/cg/GraphicsContextPlatformPrivateCG.h: 19 (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate): 20 (WebCore::GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate): 21 * platform/graphics/cg/ImageBufferCG.cpp: 22 (WebCore::ImageBuffer::ImageBuffer): 23 * platform/graphics/cg/ImageCG.cpp: 24 (WebCore::BitmapImage::checkForSolidColor): 25 (WebCore::Image::drawPattern): 26 * platform/graphics/cg/ImageSourceCG.cpp: 27 (WebCore::ImageSource::setData): 28 (WebCore::ImageSource::isSizeAvailable): 29 (WebCore::ImageSource::frameSizeAtIndex): 30 (WebCore::ImageSource::repetitionCount): 31 (WebCore::ImageSource::createFrameAtIndex): 32 (WebCore::ImageSource::frameDurationAtIndex): 33 * platform/graphics/cg/PDFDocumentImage.cpp: 34 (WebCore::PDFDocumentImage::dataChanged): 35 * platform/graphics/cg/PathCG.cpp: 36 (WebCore::createScratchContext): 37 (WebCore::Path::contains): 38 * platform/graphics/mac/FontCustomPlatformData.cpp: 39 (WebCore::createFontCustomPlatformData): 40 * platform/graphics/mac/GraphicsContextMac.mm: 41 (WebCore::GraphicsContext::drawFocusRing): 42 * platform/graphics/mac/ImageMac.mm: 43 (WebCore::BitmapImage::getTIFFRepresentation): 44 * platform/mac/ClipboardMac.mm: 45 (WebCore::cocoaTypeFromMIMEType): 46 (WebCore::MIMETypeFromCocoaType): 47 * platform/mac/WebCoreNSStringExtras.mm: 48 (stringEncodingForResource): 49 * platform/network/mac/FormDataStreamMac.mm: 50 (WebCore::advanceCurrentStream): 51 (WebCore::setHTTPBody): 52 * platform/text/mac/TextCodecMac.cpp: 53 (WebCore::TextCodecMac::encode): 54 1 55 2009-08-20 Shinichiro Hamaji <hamaji@chromium.org> 2 56 -
TabularUnified trunk/WebCore/platform/graphics/cg/ColorCG.cpp ¶
r41345 r47585 30 30 31 31 #include <wtf/Assertions.h> 32 #include <wtf/RetainPtr.h> 32 33 #include <ApplicationServices/ApplicationServices.h> 33 34 … … 76 77 CMGetSystemProfile(&prof); 77 78 78 CGColorSpaceRef rgbSpace = CGColorSpaceCreateWithPlatformColorSpace(prof);79 RetainPtr<CGColorSpaceRef> rgbSpace(AdoptCF, CGColorSpaceCreateWithPlatformColorSpace(prof)); 79 80 80 if (rgbSpace != NULL) 81 { 82 float components[4] = {c.red() / 255.0f, c.green() / 255.0f, c.blue() / 255.0f, c.alpha() / 255.0f}; 83 color = CGColorCreate(rgbSpace, components); 84 CGColorSpaceRelease(rgbSpace); 81 if (rgbSpace) { 82 CGFloat components[4] = { static_cast<CGFloat>(c.red()) / 255, static_cast<CGFloat>(c.green()) / 255, 83 static_cast<CGFloat>(c.blue()) / 255, static_cast<CGFloat>(c.alpha()) / 255 }; 84 color = CGColorCreate(rgbSpace.get(), components); 85 85 } 86 86 -
TabularUnified trunk/WebCore/platform/graphics/cg/GradientCG.cpp ¶
r31830 r47585 59 59 const CGFloat colorComponentRanges[4 * 2] = { 0, 1, 0, 1, 0, 1, 0, 1 }; 60 60 const CGFunctionCallbacks gradientCallbacks = { 0, gradientCallback, 0 }; 61 CGFunctionRef colorFunction = CGFunctionCreate(this, 1, intervalRanges, 4, colorComponentRanges, &gradientCallbacks);61 RetainPtr<CGFunctionRef> colorFunction(AdoptCF, CGFunctionCreate(this, 1, intervalRanges, 4, colorComponentRanges, &gradientCallbacks)); 62 62 63 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();63 static CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 64 64 65 65 if (m_radial) 66 m_gradient = CGShadingCreateRadial(colorSpace, m_p0, m_r0, m_p1, m_r1, colorFunction , true, true);66 m_gradient = CGShadingCreateRadial(colorSpace, m_p0, m_r0, m_p1, m_r1, colorFunction.get(), true, true); 67 67 else 68 m_gradient = CGShadingCreateAxial(colorSpace, m_p0, m_p1, colorFunction, true, true); 69 70 CGColorSpaceRelease(colorSpace); 71 CGFunctionRelease(colorFunction); 68 m_gradient = CGShadingCreateAxial(colorSpace, m_p0, m_p1, colorFunction.get(), true, true); 72 69 73 70 return m_gradient; -
TabularUnified trunk/WebCore/platform/graphics/cg/GraphicsContextCG.cpp ¶
r47360 r47585 88 88 ASSERT(!paintingDisabled()); 89 89 ASSERT(m_data->m_cgContext); 90 return m_data->m_cgContext ;90 return m_data->m_cgContext.get(); 91 91 } 92 92 … … 393 393 CGContextRef cgContext = platformContext(); 394 394 395 CGPatternRef platformPattern = m_common->state.strokePattern.get()->createPlatformPattern(getCTM());395 RetainPtr<CGPatternRef> platformPattern(AdoptCF, m_common->state.strokePattern.get()->createPlatformPattern(getCTM())); 396 396 if (!platformPattern) 397 397 return; 398 398 399 CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(0); 400 CGContextSetStrokeColorSpace(cgContext, patternSpace); 401 CGColorSpaceRelease(patternSpace); 399 RetainPtr<CGColorSpaceRef> patternSpace(AdoptCF, CGColorSpaceCreatePattern(0)); 400 CGContextSetStrokeColorSpace(cgContext, patternSpace.get()); 402 401 403 402 const CGFloat patternAlpha = 1; 404 CGContextSetStrokePattern(cgContext, platformPattern, &patternAlpha); 405 CGPatternRelease(platformPattern); 403 CGContextSetStrokePattern(cgContext, platformPattern.get(), &patternAlpha); 406 404 } 407 405 … … 410 408 CGContextRef cgContext = platformContext(); 411 409 412 CGPatternRef platformPattern = m_common->state.fillPattern.get()->createPlatformPattern(getCTM());410 RetainPtr<CGPatternRef> platformPattern(AdoptCF, m_common->state.fillPattern.get()->createPlatformPattern(getCTM())); 413 411 if (!platformPattern) 414 412 return; 415 413 416 CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(0); 417 CGContextSetFillColorSpace(cgContext, patternSpace); 418 CGColorSpaceRelease(patternSpace); 414 RetainPtr<CGColorSpaceRef> patternSpace(AdoptCF, CGColorSpaceCreatePattern(0)); 415 CGContextSetFillColorSpace(cgContext, patternSpace.get()); 419 416 420 417 const CGFloat patternAlpha = 1; 421 CGContextSetFillPattern(cgContext, platformPattern, &patternAlpha); 422 CGPatternRelease(platformPattern); 418 CGContextSetFillPattern(cgContext, platformPattern.get(), &patternAlpha); 423 419 } 424 420 … … 732 728 CGContextSetShadow(context, CGSizeMake(width, height), blurRadius); 733 729 else { 734 CGColorRef colorCG = createCGColor(color);730 RetainPtr<CGColorRef> colorCG(AdoptCF, createCGColor(color)); 735 731 CGContextSetShadowWithColor(context, 736 732 CGSizeMake(width, height), 737 733 blurRadius, 738 colorCG); 739 CGColorRelease(colorCG); 734 colorCG.get()); 740 735 } 741 736 } … … 1001 996 return; 1002 997 1003 CFURLRef urlRef = link.createCFURL(); 1004 if (urlRef) { 1005 CGContextRef context = platformContext(); 1006 1007 // Get the bounding box to handle clipping. 1008 CGRect box = CGContextGetClipBoundingBox(context); 1009 1010 IntRect intBox((int)box.origin.x, (int)box.origin.y, (int)box.size.width, (int)box.size.height); 1011 IntRect rect = destRect; 1012 rect.intersect(intBox); 1013 1014 CGPDFContextSetURLForRect(context, urlRef, 1015 CGRectApplyAffineTransform(rect, CGContextGetCTM(context))); 1016 1017 CFRelease(urlRef); 1018 } 998 RetainPtr<CFURLRef> urlRef(AdoptCF, link.createCFURL()); 999 if (!urlRef) 1000 return; 1001 1002 CGContextRef context = platformContext(); 1003 1004 // Get the bounding box to handle clipping. 1005 CGRect box = CGContextGetClipBoundingBox(context); 1006 1007 IntRect intBox((int)box.origin.x, (int)box.origin.y, (int)box.size.width, (int)box.size.height); 1008 IntRect rect = destRect; 1009 rect.intersect(intBox); 1010 1011 CGPDFContextSetURLForRect(context, urlRef.get(), 1012 CGRectApplyAffineTransform(rect, CGContextGetCTM(context))); 1019 1013 } 1020 1014 -
TabularUnified trunk/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h ¶
r44821 r47585 39 39 , m_userToDeviceTransformKnownToBeIdentity(false) 40 40 { 41 CGContextRetain(m_cgContext);42 41 } 43 42 44 43 ~GraphicsContextPlatformPrivate() 45 44 { 46 CGContextRelease(m_cgContext);47 45 } 48 46 … … 81 79 #endif 82 80 83 CGContextRefm_cgContext;81 RetainPtr<CGContextRef> m_cgContext; 84 82 bool m_userToDeviceTransformKnownToBeIdentity; 85 83 }; -
TabularUnified trunk/WebCore/platform/graphics/cg/ImageBufferCG.cpp ¶
r47099 r47585 71 71 ASSERT((reinterpret_cast<size_t>(m_data.m_data) & 2) == 0); 72 72 73 CGColorSpaceRefcolorSpace;73 RetainPtr<CGColorSpaceRef> colorSpace; 74 74 switch(imageColorSpace) { 75 75 case DeviceRGB: 76 colorSpace = CGColorSpaceCreateDeviceRGB();76 colorSpace.adoptCF(CGColorSpaceCreateDeviceRGB()); 77 77 break; 78 78 case GrayScale: 79 colorSpace = CGColorSpaceCreateDeviceGray();79 colorSpace.adoptCF(CGColorSpaceCreateDeviceGray()); 80 80 break; 81 81 #if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) 82 82 case LinearRGB: 83 colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGBLinear);83 colorSpace.adoptCF(CGColorSpaceCreateWithName(kCGColorSpaceGenericRGBLinear)); 84 84 break; 85 85 #endif 86 86 default: 87 colorSpace = CGColorSpaceCreateDeviceRGB();87 colorSpace.adoptCF(CGColorSpaceCreateDeviceRGB()); 88 88 break; 89 89 } 90 90 91 CGContextRef cgContext = CGBitmapContextCreate(m_data.m_data, size.width(), size.height(), 8, bytesPerRow, 92 colorSpace, (imageColorSpace == GrayScale) ? kCGImageAlphaNone : kCGImageAlphaPremultipliedLast); 93 CGColorSpaceRelease(colorSpace); 91 RetainPtr<CGContextRef> cgContext(AdoptCF, CGBitmapContextCreate(m_data.m_data, size.width(), size.height(), 8, bytesPerRow, 92 colorSpace.get(), (imageColorSpace == GrayScale) ? kCGImageAlphaNone : kCGImageAlphaPremultipliedLast)); 94 93 if (!cgContext) 95 94 return; 96 95 97 m_context.set(new GraphicsContext(cgContext ));96 m_context.set(new GraphicsContext(cgContext.get())); 98 97 m_context->scale(FloatSize(1, -1)); 99 98 m_context->translate(0, -size.height()); 100 CGContextRelease(cgContext);101 99 success = true; 102 100 } -
TabularUnified trunk/WebCore/platform/graphics/cg/ImageCG.cpp ¶
r46002 r47585 102 102 { 103 103 m_checkedForSolidColor = true; 104 if (frameCount() > 1) 104 if (frameCount() > 1) { 105 105 m_isSolidColor = false; 106 else { 107 CGImageRef image = frameAtIndex(0); 108 109 // Currently we only check for solid color in the important special case of a 1x1 image. 110 if (image && CGImageGetWidth(image) == 1 && CGImageGetHeight(image) == 1) { 111 unsigned char pixel[4]; // RGBA 112 CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); 113 CGContextRef bmap = CGBitmapContextCreate(pixel, 1, 1, 8, sizeof(pixel), space, 114 kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); 115 if (bmap) { 116 GraphicsContext(bmap).setCompositeOperation(CompositeCopy); 117 CGRect dst = { {0, 0}, {1, 1} }; 118 CGContextDrawImage(bmap, dst, image); 119 if (pixel[3] == 0) 120 m_solidColor = Color(0, 0, 0, 0); 121 else 122 m_solidColor = Color(pixel[0] * 255 / pixel[3], pixel[1] * 255 / pixel[3], pixel[2] * 255 / pixel[3], pixel[3]); 123 m_isSolidColor = true; 124 CFRelease(bmap); 125 } 126 CFRelease(space); 127 } 106 return; 107 } 108 109 CGImageRef image = frameAtIndex(0); 110 111 // Currently we only check for solid color in the important special case of a 1x1 image. 112 if (image && CGImageGetWidth(image) == 1 && CGImageGetHeight(image) == 1) { 113 unsigned char pixel[4]; // RGBA 114 static CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); 115 RetainPtr<CGContextRef> bmap(AdoptCF, CGBitmapContextCreate(pixel, 1, 1, 8, sizeof(pixel), space, 116 kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big)); 117 if (!bmap) 118 return; 119 GraphicsContext(bmap.get()).setCompositeOperation(CompositeCopy); 120 CGRect dst = { {0, 0}, {1, 1} }; 121 CGContextDrawImage(bmap.get(), dst, image); 122 if (pixel[3] == 0) 123 m_solidColor = Color(0, 0, 0, 0); 124 else 125 m_solidColor = Color(pixel[0] * 255 / pixel[3], pixel[1] * 255 / pixel[3], pixel[2] * 255 / pixel[3], pixel[3]); 126 m_isSolidColor = true; 128 127 } 129 128 } … … 253 252 float h = CGImageGetHeight(tileImage); 254 253 255 CGImageRefsubImage;254 RetainPtr<CGImageRef> subImage; 256 255 if (tileRect.size() == size()) 257 256 subImage = tileImage; … … 260 259 // because sub-images are only used for border-image, which only renders when the image is fully decoded. 261 260 ASSERT(h == height()); 262 subImage = CGImageCreateWithImageInRect(tileImage, tileRect);261 subImage.adoptCF(CGImageCreateWithImageInRect(tileImage, tileRect)); 263 262 } 264 263 … … 276 275 if (w == size().width() && h == size().height()) 277 276 #endif 278 CGContextDrawTiledImage(context, FloatRect(adjustedX, adjustedY, scaledTileWidth, scaledTileHeight), subImage );277 CGContextDrawTiledImage(context, FloatRect(adjustedX, adjustedY, scaledTileWidth, scaledTileHeight), subImage.get()); 279 278 else { 280 279 #endif … … 289 288 // The top of a partially-decoded image is drawn at the bottom of the tile. Map it to the top. 290 289 matrix = CGAffineTransformTranslate(matrix, 0, size().height() - h); 291 CGPatternRef pattern = CGPatternCreate(subImage, CGRectMake(0, 0, tileRect.width(), tileRect.height()), 292 matrix, tileRect.width(), tileRect.height(), 293 kCGPatternTilingConstantSpacing, true, &patternCallbacks); 294 if (pattern == NULL) { 295 if (subImage != tileImage) 296 CGImageRelease(subImage); 290 RetainPtr<CGPatternRef> pattern(AdoptCF, CGPatternCreate(subImage.get(), CGRectMake(0, 0, tileRect.width(), tileRect.height()), 291 matrix, tileRect.width(), tileRect.height(), 292 kCGPatternTilingConstantSpacing, true, &patternCallbacks)); 293 if (!pattern) { 297 294 ctxt->restore(); 298 295 return; 299 296 } 300 297 301 CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(NULL);298 RetainPtr<CGColorSpaceRef> patternSpace(AdoptCF, CGColorSpaceCreatePattern(0)); 302 299 303 300 CGFloat alpha = 1; 304 CGColorRef color = CGColorCreateWithPattern(patternSpace, pattern, &alpha); 305 CGContextSetFillColorSpace(context, patternSpace); 306 CGColorSpaceRelease(patternSpace); 307 CGPatternRelease(pattern); 301 RetainPtr<CGColorRef> color(AdoptCF, CGColorCreateWithPattern(patternSpace.get(), pattern.get(), &alpha)); 302 CGContextSetFillColorSpace(context, patternSpace.get()); 308 303 309 304 // FIXME: Really want a public API for this. It is just CGContextSetBaseCTM(context, CGAffineTransformIdentiy). … … 311 306 CGContextSetPatternPhase(context, CGSizeZero); 312 307 313 CGContextSetFillColorWithColor(context, color );308 CGContextSetFillColorWithColor(context, color.get()); 314 309 CGContextFillRect(context, CGContextGetClipBoundingBox(context)); 315 316 CGColorRelease(color); 317 310 318 311 #ifndef BUILDING_ON_TIGER 319 312 } 320 313 #endif 321 314 322 if (subImage != tileImage)323 CGImageRelease(subImage);324 315 ctxt->restore(); 325 316 -
TabularUnified trunk/WebCore/platform/graphics/cg/ImageSourceCG.cpp ¶
r46527 r47585 110 110 // On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge. We use SharedBuffer's ability 111 111 // to wrap itself inside CFData to get around this, ensuring that ImageIO is really looking at the SharedBuffer. 112 CFDataRef cfData = data->createCFData();112 RetainPtr<CFDataRef> cfData(AdoptCF, data->createCFData()); 113 113 #else 114 114 // If no NSData is available, then we know SharedBuffer will always just be a vector. That means no secret changes can occur to it behind the … … 116 116 data->ref(); 117 117 CFAllocatorContext context = {0, data, 0, 0, 0, 0, 0, &sharedBufferDerefCallback, 0}; 118 CFAllocatorRef derefAllocator = CFAllocatorCreate(kCFAllocatorDefault, &context); 119 CFDataRef cfData = CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(data->data()), data->size(), derefAllocator); 120 CFRelease(derefAllocator); 118 RetainPtr<CFAllocatorRef> derefAllocator(AdoptCF, CFAllocatorCreate(kCFAllocatorDefault, &context)); 119 RetainPtr<CFDataRef> cfData(AdoptCF, CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(data->data()), data->size(), derefAllocator.get())); 121 120 #endif 122 CGImageSourceUpdateData(m_decoder, cfData, allDataReceived); 123 CFRelease(cfData); 121 CGImageSourceUpdateData(m_decoder, cfData.get(), allDataReceived); 124 122 } 125 123 … … 139 137 // Ragnaros yells: TOO SOON! You have awakened me TOO SOON, Executus! 140 138 if (imageSourceStatus >= kCGImageStatusIncomplete) { 141 CFDictionaryRef image0Properties = CGImageSourceCopyPropertiesAtIndex(m_decoder, 0, imageSourceOptions());139 RetainPtr<CFDictionaryRef> image0Properties(AdoptCF, CGImageSourceCopyPropertiesAtIndex(m_decoder, 0, imageSourceOptions())); 142 140 if (image0Properties) { 143 CFNumberRef widthNumber = (CFNumberRef)CFDictionaryGetValue(image0Properties , kCGImagePropertyPixelWidth);144 CFNumberRef heightNumber = (CFNumberRef)CFDictionaryGetValue(image0Properties , kCGImagePropertyPixelHeight);141 CFNumberRef widthNumber = (CFNumberRef)CFDictionaryGetValue(image0Properties.get(), kCGImagePropertyPixelWidth); 142 CFNumberRef heightNumber = (CFNumberRef)CFDictionaryGetValue(image0Properties.get(), kCGImagePropertyPixelHeight); 145 143 result = widthNumber && heightNumber; 146 CFRelease(image0Properties);147 144 } 148 145 } … … 154 151 { 155 152 IntSize result; 156 CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions());153 RetainPtr<CFDictionaryRef> properties(AdoptCF, CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions())); 157 154 if (properties) { 158 155 int w = 0, h = 0; 159 CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(properties , kCGImagePropertyPixelWidth);156 CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(properties.get(), kCGImagePropertyPixelWidth); 160 157 if (num) 161 158 CFNumberGetValue(num, kCFNumberIntType, &w); 162 num = (CFNumberRef)CFDictionaryGetValue(properties , kCGImagePropertyPixelHeight);159 num = (CFNumberRef)CFDictionaryGetValue(properties.get(), kCGImagePropertyPixelHeight); 163 160 if (num) 164 161 CFNumberGetValue(num, kCFNumberIntType, &h); 165 162 result = IntSize(w, h); 166 CFRelease(properties);167 163 } 168 164 return result; … … 181 177 182 178 // A property with value 0 means loop forever. 183 CFDictionaryRef properties = CGImageSourceCopyProperties(m_decoder, imageSourceOptions());179 RetainPtr<CFDictionaryRef> properties(AdoptCF, CGImageSourceCopyProperties(m_decoder, imageSourceOptions())); 184 180 if (properties) { 185 CFDictionaryRef gifProperties = (CFDictionaryRef)CFDictionaryGetValue(properties , kCGImagePropertyGIFDictionary);181 CFDictionaryRef gifProperties = (CFDictionaryRef)CFDictionaryGetValue(properties.get(), kCGImagePropertyGIFDictionary); 186 182 if (gifProperties) { 187 183 CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(gifProperties, kCGImagePropertyGIFLoopCount); … … 190 186 } else 191 187 result = cAnimationNone; // Turns out we're not a GIF after all, so we don't animate. 192 193 CFRelease(properties);194 188 } 195 189 … … 207 201 return 0; 208 202 209 CGImageRef image = CGImageSourceCreateImageAtIndex(m_decoder, index, imageSourceOptions());203 RetainPtr<CGImageRef> image(AdoptCF, CGImageSourceCreateImageAtIndex(m_decoder, index, imageSourceOptions())); 210 204 CFStringRef imageUTI = CGImageSourceGetType(m_decoder); 211 205 static const CFStringRef xbmUTI = CFSTR("public.xbitmap-image"); 212 206 if (!imageUTI || !CFEqual(imageUTI, xbmUTI)) 213 return image ;207 return image.releaseRef(); 214 208 215 209 // If it is an xbm image, mask out all the white areas to render them transparent. 216 210 const CGFloat maskingColors[6] = {255, 255, 255, 255, 255, 255}; 217 CGImageRef maskedImage = CGImageCreateWithMaskingColors(image, maskingColors);211 RetainPtr<CGImageRef> maskedImage(AdoptCF, CGImageCreateWithMaskingColors(image.get(), maskingColors)); 218 212 if (!maskedImage) 219 return image; 220 221 CGImageRelease(image); 222 return maskedImage; 213 return image.releaseRef(); 214 215 return maskedImage.releaseRef(); 223 216 } 224 217 … … 234 227 235 228 float duration = 0; 236 CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions());229 RetainPtr<CFDictionaryRef> properties(AdoptCF, CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions())); 237 230 if (properties) { 238 CFDictionaryRef typeProperties = (CFDictionaryRef)CFDictionaryGetValue(properties , kCGImagePropertyGIFDictionary);231 CFDictionaryRef typeProperties = (CFDictionaryRef)CFDictionaryGetValue(properties.get(), kCGImagePropertyGIFDictionary); 239 232 if (typeProperties) { 240 233 CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(typeProperties, kCGImagePropertyGIFDelayTime); … … 242 235 CFNumberGetValue(num, kCFNumberFloatType, &duration); 243 236 } 244 CFRelease(properties);245 237 } 246 238 -
TabularUnified trunk/WebCore/platform/graphics/cg/PDFDocumentImage.cpp ¶
r45781 r47585 69 69 // On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge. We use SharedBuffer's ability 70 70 // to wrap itself inside CFData to get around this, ensuring that ImageIO is really looking at the SharedBuffer. 71 CFDataRef data = this->data()->createCFData();71 RetainPtr<CFDataRef> data(AdoptCF, this->data()->createCFData()); 72 72 #else 73 73 // If no NSData is available, then we know SharedBuffer will always just be a vector. That means no secret changes can occur to it behind the 74 74 // scenes. We use CFDataCreateWithBytesNoCopy in that case. 75 CFDataRef data = CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(this->data()->data()), this->data()->size(), kCFAllocatorNull);75 RetainPtr<CFDataRef> data(AdoptCF, CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(this->data()->data()), this->data()->size(), kCFAllocatorNull)); 76 76 #endif 77 CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(data); 78 CFRelease(data); 79 m_document = CGPDFDocumentCreateWithProvider(dataProvider); 80 CGDataProviderRelease(dataProvider); 77 RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(data.get())); 78 m_document = CGPDFDocumentCreateWithProvider(dataProvider.get()); 81 79 setCurrentPage(0); 82 80 } -
TabularUnified trunk/WebCore/platform/graphics/cg/PathCG.cpp ¶
r45873 r47585 50 50 { 51 51 CGDataConsumerCallbacks callbacks = { putBytesNowhere, 0 }; 52 CGDataConsumerRef consumer = CGDataConsumerCreate(0, &callbacks); 53 CGContextRef context = CGPDFContextCreate(consumer, 0, 0); 54 CGDataConsumerRelease(consumer); 52 RetainPtr<CGDataConsumerRef> consumer(AdoptCF, CGDataConsumerCreate(0, &callbacks)); 53 CGContextRef context = CGPDFContextCreate(consumer.get(), 0, 0); 55 54 56 55 CGFloat black[4] = { 0, 0, 0, 1 }; … … 130 129 131 130 // CGPathContainsPoint returns false for non-closed paths, as a work-around, we copy and close the path first. Radar 4758998 asks for a better CG API to use 132 CGMutablePathRef path = copyCGPathClosingSubpaths(m_path); 133 bool ret = CGPathContainsPoint(path, 0, point, rule == RULE_EVENODD ? true : false); 134 CGPathRelease(path); 131 RetainPtr<CGMutablePathRef> path(AdoptCF, copyCGPathClosingSubpaths(m_path)); 132 bool ret = CGPathContainsPoint(path.get(), 0, point, rule == RULE_EVENODD ? true : false); 135 133 return ret; 136 134 } -
TabularUnified trunk/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp ¶
r40375 r47585 47 47 ATSFontRef fontRef = 0; 48 48 49 RetainPtr<CGFontRef> cgFontRef; 50 49 51 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) 50 52 RetainPtr<CFDataRef> bufferData(AdoptCF, buffer->createCFData()); 51 53 RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(bufferData.get())); 52 54 53 CGFontRef cgFontRef = CGFontCreateWithDataProvider(dataProvider.get());55 cgFontRef.adoptCF(CGFontCreateWithDataProvider(dataProvider.get())); 54 56 if (!cgFontRef) 55 57 return 0; … … 76 78 } 77 79 78 CGFontRef cgFontRef = CGFontCreateWithPlatformFont(&fontRef);80 cgFontRef.adoptCF(CGFontCreateWithPlatformFont(&fontRef)); 79 81 #ifndef BUILDING_ON_TIGER 80 82 // Workaround for <rdar://problem/5675504>. 81 if (cgFontRef && !CGFontGetNumberOfGlyphs(cgFontRef)) { 82 CFRelease(cgFontRef); 83 if (cgFontRef && !CGFontGetNumberOfGlyphs(cgFontRef.get())) 83 84 cgFontRef = 0; 84 }85 85 #endif 86 86 if (!cgFontRef) { … … 90 90 #endif // !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) 91 91 92 return new FontCustomPlatformData(containerRef, fontRef, cgFontRef );92 return new FontCustomPlatformData(containerRef, fontRef, cgFontRef.releaseRef()); 93 93 } 94 94 -
TabularUnified trunk/WebCore/platform/graphics/mac/GraphicsContextMac.mm ¶
r43389 r47585 51 51 int radius = (focusRingWidth() - 1) / 2; 52 52 int offset = radius + focusRingOffset(); 53 CGColorRef colorRef = color.isValid() ? createCGColor(color) : 0; 53 RetainPtr<CGColorRef> colorRef; 54 if (color.isValid()) 55 colorRef.adoptCF(createCGColor(color)); 54 56 55 CGMutablePathRef focusRingPath = CGPathCreateMutable();57 RetainPtr<CGMutablePathRef> focusRingPath(AdoptCF, CGPathCreateMutable()); 56 58 const Vector<IntRect>& rects = focusRingRects(); 57 59 unsigned rectCount = rects.size(); 58 60 for (unsigned i = 0; i < rectCount; i++) 59 CGPathAddRect(focusRingPath , 0, CGRectInset(rects[i], -offset, -offset));61 CGPathAddRect(focusRingPath.get(), 0, CGRectInset(rects[i], -offset, -offset)); 60 62 61 63 CGContextRef context = platformContext(); … … 64 66 #endif 65 67 CGContextBeginPath(context); 66 CGContextAddPath(context, focusRingPath );67 wkDrawFocusRing(context, colorRef , radius);68 CGContextAddPath(context, focusRingPath.get()); 69 wkDrawFocusRing(context, colorRef.get(), radius); 68 70 #ifdef BUILDING_ON_TIGER 69 71 CGContextEndTransparencyLayer(context); 70 72 #endif 71 CGColorRelease(colorRef);72 73 CGPathRelease(focusRingPath);74 73 } 75 74 -
TabularUnified trunk/WebCore/platform/graphics/mac/ImageMac.mm ¶
r35731 r47585 95 95 RetainPtr<CFMutableDataRef> data(AdoptCF, CFDataCreateMutable(0, 0)); 96 96 // FIXME: Use type kCGImageTypeIdentifierTIFF constant once is becomes available in the API 97 CGImageDestinationRef destination = CGImageDestinationCreateWithData(data.get(), CFSTR("public.tiff"), numValidFrames, 0);98 97 RetainPtr<CGImageDestinationRef> destination(AdoptCF, CGImageDestinationCreateWithData(data.get(), CFSTR("public.tiff"), numValidFrames, 0)); 98 99 99 if (!destination) 100 100 return 0; 101 101 102 102 for (unsigned i = 0; i < numValidFrames; ++i) 103 CGImageDestinationAddImage(destination , images[i], 0);103 CGImageDestinationAddImage(destination.get(), images[i], 0); 104 104 105 CGImageDestinationFinalize(destination); 106 CFRelease(destination); 105 CGImageDestinationFinalize(destination.get()); 107 106 108 107 m_tiffRep = data; -
TabularUnified trunk/WebCore/platform/mac/ClipboardMac.mm ¶
r45168 r47585 83 83 // Try UTI now 84 84 NSString *mimeType = qType; 85 CFStringRef UTIType = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, (CFStringRef)mimeType, NULL); 86 if (UTIType) { 87 CFStringRef pbType = UTTypeCopyPreferredTagWithClass(UTIType, kUTTagClassNSPboardType); 88 CFRelease(UTIType); 85 RetainPtr<CFStringRef> utiType(AdoptCF, UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, (CFStringRef)mimeType, NULL)); 86 if (utiType) { 87 CFStringRef pbType = UTTypeCopyPreferredTagWithClass(utiType.get(), kUTTagClassNSPboardType); 89 88 if (pbType) 90 89 return HardAutorelease(pbType); … … 104 103 105 104 // Now try the general UTI mechanism 106 CFStringRef UTIType = UTTypeCreatePreferredIdentifierForTag(kUTTagClassNSPboardType, (CFStringRef)type, NULL); 107 if (UTIType) { 108 CFStringRef mimeType = UTTypeCopyPreferredTagWithClass(UTIType, kUTTagClassMIMEType); 109 CFRelease(UTIType); 110 if (mimeType) { 111 String result = mimeType; 112 CFRelease(mimeType); 113 return result; 114 } 105 RetainPtr<CFStringRef> utiType(AdoptCF, UTTypeCreatePreferredIdentifierForTag(kUTTagClassNSPboardType, (CFStringRef)type, NULL)); 106 if (utiType) { 107 RetainPtr<CFStringRef> mimeType(AdoptCF, UTTypeCopyPreferredTagWithClass(utiType.get(), kUTTagClassMIMEType)); 108 if (mimeType) 109 return String(mimeType.get()); 115 110 } 116 111 -
TabularUnified trunk/WebCore/platform/mac/WebCoreNSStringExtras.mm ¶
r38333 r47585 29 29 #import "config.h" 30 30 #import "WebCoreNSStringExtras.h" 31 32 #import <wtf/RetainPtr.h> 31 33 32 34 BOOL stringIsCaseInsensitiveEqualToString(NSString *first, NSString *second) … … 70 72 { 71 73 short resRef = HomeResFile(resource); 72 if (ResError() != noErr) {74 if (ResError() != noErr) 73 75 return NSMacOSRomanStringEncoding; 74 }75 76 76 77 // Get the FSRef for the current resource file 77 78 FSRef fref; 78 79 OSStatus error = FSGetForkCBInfo(resRef, 0, NULL, NULL, NULL, &fref, NULL); 79 if (error != noErr) {80 if (error != noErr) 80 81 return NSMacOSRomanStringEncoding; 81 }82 82 83 CFURLRef URL = CFURLCreateFromFSRef(NULL, &fref);84 if ( URL == NULL) {83 RetainPtr<CFURLRef> url(AdoptCF, CFURLCreateFromFSRef(NULL, &fref)); 84 if (!url) 85 85 return NSMacOSRomanStringEncoding; 86 } 87 88 NSString *path = [(NSURL *)URL path]; 89 CFRelease(URL); 90 86 87 NSString *path = [(NSURL *)url.get() path]; 88 91 89 // Get the lproj directory name 92 90 path = [path stringByDeletingLastPathComponent]; 93 if (!stringIsCaseInsensitiveEqualToString([path pathExtension], @"lproj")) {91 if (!stringIsCaseInsensitiveEqualToString([path pathExtension], @"lproj")) 94 92 return NSMacOSRomanStringEncoding; 95 }96 93 97 94 NSString *directoryName = [[path stringByDeletingPathExtension] lastPathComponent]; 98 CFStringRef locale = CFLocaleCreateCanonicalLocaleIdentifierFromString(NULL, (CFStringRef)directoryName);99 if ( locale == NULL) {95 RetainPtr<CFStringRef> locale(AdoptCF, CFLocaleCreateCanonicalLocaleIdentifierFromString(NULL, (CFStringRef)directoryName)); 96 if (!locale) 100 97 return NSMacOSRomanStringEncoding; 101 } 102 98 103 99 LangCode lang; 104 100 RegionCode region; 105 error = LocaleStringToLangAndRegionCodes([(NSString *)locale UTF8String], &lang, ®ion); 106 CFRelease(locale); 107 if (error != noErr) { 101 error = LocaleStringToLangAndRegionCodes([(NSString *)locale.get() UTF8String], &lang, ®ion); 102 if (error != noErr) 108 103 return NSMacOSRomanStringEncoding; 109 } 110 104 111 105 TextEncoding encoding; 112 106 error = UpgradeScriptInfoToTextEncoding(kTextScriptDontCare, lang, region, NULL, &encoding); 113 if (error != noErr) {107 if (error != noErr) 114 108 return NSMacOSRomanStringEncoding; 115 }116 109 117 110 return encoding; -
TabularUnified trunk/WebCore/platform/network/mac/FormDataStreamMac.mm ¶
r46822 r47585 162 162 } else { 163 163 const String& path = nextInput.m_shouldGenerateFile ? nextInput.m_generatedFilename : nextInput.m_filename; 164 CFStringRef filename = path.createCFString(); 165 CFURLRef fileURL = CFURLCreateWithFileSystemPath(0, filename, kCFURLPOSIXPathStyle, FALSE); 166 CFRelease(filename); 167 form->currentStream = CFReadStreamCreateWithFile(0, fileURL); 168 CFRelease(fileURL); 164 RetainPtr<CFStringRef> filename(AdoptCF, path.createCFString()); 165 RetainPtr<CFURLRef> fileURL(AdoptCF, CFURLCreateWithFileSystemPath(0, filename.get(), kCFURLPOSIXPathStyle, FALSE)); 166 form->currentStream = CFReadStreamCreateWithFile(0, fileURL.get()); 169 167 } 170 168 form->remainingElements.removeLast(); … … 376 374 FormContext formContext = { formData.releaseRef(), length }; 377 375 378 CFReadStreamRef stream =wkCreateCustomCFReadStream(formCreate, formFinalize,376 RetainPtr<CFReadStreamRef> stream(AdoptCF, wkCreateCustomCFReadStream(formCreate, formFinalize, 379 377 formOpen, formRead, formCanRead, formClose, formSchedule, formUnschedule, 380 &formContext); 381 [request setHTTPBodyStream:(NSInputStream *)stream]; 382 CFRelease(stream); 378 &formContext)); 379 [request setHTTPBodyStream:(NSInputStream *)stream.get()]; 383 380 } 384 381 -
TabularUnified trunk/WebCore/platform/text/mac/TextCodecMac.cpp ¶
r47341 r47585 284 284 String copy(characters, length); 285 285 copy.replace('\\', m_backslashAsCurrencySymbol); 286 CFStringRef cfs = copy.createCFString();286 RetainPtr<CFStringRef> cfs(AdoptCF, copy.createCFString()); 287 287 288 288 CFIndex startPos = 0; 289 CFIndex charactersLeft = CFStringGetLength(cfs );289 CFIndex charactersLeft = CFStringGetLength(cfs.get()); 290 290 Vector<char> result; 291 291 size_t size = 0; … … 294 294 CFRange range = CFRangeMake(startPos, charactersLeft); 295 295 CFIndex bufferLength; 296 CFStringGetBytes(cfs , range, m_encoding, lossByte, false, NULL, 0x7FFFFFFF, &bufferLength);296 CFStringGetBytes(cfs.get(), range, m_encoding, lossByte, false, NULL, 0x7FFFFFFF, &bufferLength); 297 297 298 298 result.grow(size + bufferLength); 299 299 unsigned char* buffer = reinterpret_cast<unsigned char*>(result.data() + size); 300 CFIndex charactersConverted = CFStringGetBytes(cfs , range, m_encoding, lossByte, false, buffer, bufferLength, &bufferLength);300 CFIndex charactersConverted = CFStringGetBytes(cfs.get(), range, m_encoding, lossByte, false, buffer, bufferLength, &bufferLength); 301 301 size += bufferLength; 302 302 303 303 if (charactersConverted != charactersLeft) { 304 unsigned badChar = CFStringGetCharacterAtIndex(cfs , startPos + charactersConverted);304 unsigned badChar = CFStringGetCharacterAtIndex(cfs.get(), startPos + charactersConverted); 305 305 ++charactersConverted; 306 306 if ((badChar & 0xFC00) == 0xD800 && charactersConverted != charactersLeft) { // is high surrogate 307 UniChar low = CFStringGetCharacterAtIndex(cfs , startPos + charactersConverted);307 UniChar low = CFStringGetCharacterAtIndex(cfs.get(), startPos + charactersConverted); 308 308 if ((low & 0xFC00) == 0xDC00) { // is low surrogate 309 309 badChar <<= 10; … … 323 323 charactersLeft -= charactersConverted; 324 324 } 325 CFRelease(cfs);326 325 return CString(result.data(), size); 327 326 }
Note:
See TracChangeset
for help on using the changeset viewer.