Changeset 88906 in webkit


Ignore:
Timestamp:
Jun 14, 2011 10:29:08 PM (13 years ago)
Author:
weinig@apple.com
Message:

2011-06-14 Sam Weinig <sam@webkit.org>

Reviewed by Simon Fraser.

Follow up for Callers should be robust against WebImage::create() returning an image with a null snapshot
https://bugs.webkit.org/show_bug.cgi?id=62666

  • Shared/API/c/cg/WKImageCG.cpp: (WKImageCreateCGImage): (WKImageCreateFromCGImage): Don't null check the arguments (as per our API design) or the direct result of WebImage::create.
  • Shared/UserMessageCoders.h: (WebKit::UserMessageEncoder::baseEncode): Remove redundant check and make not being able to create a handle the same as not being backed by shareable memory.
Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r88903 r88906  
     12011-06-14  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Follow up for Callers should be robust against WebImage::create() returning an image with a null snapshot
     6        https://bugs.webkit.org/show_bug.cgi?id=62666
     7
     8        * Shared/API/c/cg/WKImageCG.cpp:
     9        (WKImageCreateCGImage):
     10        (WKImageCreateFromCGImage):
     11        Don't null check the arguments (as per our API design) or the direct result of WebImage::create.
     12
     13        * Shared/UserMessageCoders.h:
     14        (WebKit::UserMessageEncoder::baseEncode):
     15        Remove redundant check and make not being able to create a handle the same
     16        as not being backed by shareable memory.
     17
    1182011-06-14  John Sullivan  <sullivan@apple.com>
    219
  • trunk/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp

    r88856 r88906  
    3737CGImageRef WKImageCreateCGImage(WKImageRef imageRef)
    3838{
    39     if (!imageRef)
     39    WebImage* webImage = toImpl(imageRef);
     40    if (!webImage->bitmap())
    4041        return 0;
    41    
    42     WebImage* webImage = toImpl(imageRef);
    43     if (!webImage || !webImage->bitmap())
    44         return 0;
    45    
     42
    4643    return webImage->bitmap()->makeCGImageCopy().leakRef();
    4744}
     
    5451    IntSize imageSize(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef));
    5552    RefPtr<WebImage> webImage = WebImage::create(imageSize, toImageOptions(options));
    56     if (!webImage || !webImage->bitmap())
     53    if (!webImage->bitmap())
    5754        return 0;
    58    
     55
    5956    OwnPtr<GraphicsContext> graphicsContext = webImage->bitmap()->createGraphicsContext();
    6057    CGContextDrawImage(graphicsContext->platformContext(), CGRectMake(0, 0, imageSize.width(), imageSize.height()), imageRef);
  • trunk/Source/WebKit2/Shared/UserMessageCoders.h

    r88870 r88906  
    129129        case APIObject::TypeImage: {
    130130            WebImage* image = static_cast<WebImage*>(m_root);
    131             if (!image->bitmap() || !image->bitmap()->isBackedBySharedMemory()) {
     131
     132            ShareableBitmap::Handle handle;
     133            if (!image->bitmap() || !image->bitmap()->isBackedBySharedMemory() || !image->bitmap()->createHandle(handle)) {
     134                // Initial false indicates no allocated bitmap or is not shareable.
    132135                encoder->encode(false);
    133136                return true;
    134137            }
    135138
    136             ShareableBitmap::Handle handle;
    137             if (!image->bitmap() || !image->bitmap()->createHandle(handle))
    138                 return false;
    139 
     139            // Initial true indicates a bitmap was allocated and is shareable.
    140140            encoder->encode(true);
    141            
     141
    142142            encoder->encode(handle);
    143143            return true;
Note: See TracChangeset for help on using the changeset viewer.