<https://bugs.webkit.org/show_bug.cgi?id=62666>
[WebKit-https.git] / Source / WebKit2 / WebProcess / WebPage / WebPage.cpp
index 96cea83d0af8465eb964c91407fdc5586c1195ae..f35959bafe1c68814c7b0f4d7fff70a5abc1d971 100644 (file)
@@ -875,6 +875,9 @@ PassRefPtr<WebImage> WebPage::snapshotInViewCoordinates(const IntRect& rect, Ima
     frameView->setPaintBehavior(oldBehavior | PaintBehaviorFlattenCompositingLayers);
 
     RefPtr<WebImage> snapshot = WebImage::create(rect.size(), options);
+    if (!snapshot->bitmap())
+        return 0;
+    
     OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->bitmap()->createGraphicsContext();
 
     graphicsContext->save();
@@ -904,6 +907,9 @@ PassRefPtr<WebImage> WebPage::scaledSnapshotInDocumentCoordinates(const IntRect&
         size = IntSize(ceil(rect.width() * scaleFactor), ceil(rect.height() * scaleFactor));
 
     RefPtr<WebImage> snapshot = WebImage::create(size, options);
+    if (!snapshot->bitmap())
+        return 0;
+    
     OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->bitmap()->createGraphicsContext();
     graphicsContext->save();
     
@@ -929,8 +935,12 @@ void WebPage::createSnapshotOfVisibleContent(ShareableBitmap::Handle& snapshotHa
     FrameView* frameView = m_mainFrame->coreFrame()->view();
     if (!frameView)
         return;
+    
     IntRect contentRect = frameView->visibleContentRect(false);
     RefPtr<WebImage> snapshotImage = scaledSnapshotInDocumentCoordinates(contentRect, 1, ImageOptionsShareable);
+    if (!snapshotImage->bitmap())
+        return;
+    
     snapshotImage->bitmap()->createHandle(snapshotHandle);
 }