reduce PassRefPtr use in WebKit2
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Dec 2016 02:48:19 +0000 (02:48 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Dec 2016 02:48:19 +0000 (02:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166452

Patch by Alex Christensen <achristensen@webkit.org> on 2016-12-27
Reviewed by Yusuke Suzuki.

* Shared/API/c/cg/WKImageCG.cpp:
(WKImageCreateCGImage):
(WKImageCreateFromCGImage):
* Shared/ShareableBitmap.cpp:
(WebKit::ShareableBitmap::createHandle):
* Shared/ShareableBitmap.h:
* Shared/UserData.cpp:
(WebKit::UserData::encode):
(WebKit::UserData::decode):
* Shared/WebImage.cpp:
(WebKit::WebImage::create):
(WebKit::WebImage::WebImage):
* Shared/WebImage.h:
(WebKit::WebImage::bitmap):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didGetImageForFindMatch):
* UIProcess/mac/WKTextFinderClient.mm:
(-[WKTextFinderClient didGetImageForMatchResult:]):
* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::WebAutomationSessionProxy::takeScreenshot):
* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm:
(-[WKWebProcessPlugInNodeHandle renderedImageWithOptions:]):
* WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
(WebKit::imageForRect):
(WebKit::InjectedBundleNodeHandle::renderedImage):
(WebKit::InjectedBundleNodeHandle::visibleRange):
(WebKit::InjectedBundleNodeHandle::htmlTableCellElementCellAbove):
(WebKit::InjectedBundleNodeHandle::documentFrame):
(WebKit::InjectedBundleNodeHandle::htmlFrameElementContentFrame):
(WebKit::InjectedBundleNodeHandle::htmlIFrameElementContentFrame):
* WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:
* WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
(WebKit::InjectedBundleRangeHandle::renderedImage):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::takeSnapshot):
(WebKit::WebPage::snapshotAtSize):
(WebKit::WebPage::snapshotNode):
(WebKit::WebPage::drawRectToImage):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getPositionInformation):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::setTopOverhangImage):
(WebKit::WebPage::setBottomOverhangImage):

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

19 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp
Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp
Source/WebKit2/Shared/ShareableBitmap.cpp
Source/WebKit2/Shared/ShareableBitmap.h
Source/WebKit2/Shared/UserData.cpp
Source/WebKit2/Shared/WebImage.cpp
Source/WebKit2/Shared/WebImage.h
Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/mac/WKTextFinderClient.mm
Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

index d277a1e..5282de6 100644 (file)
@@ -1,3 +1,54 @@
+2016-12-27  Alex Christensen  <achristensen@webkit.org>
+
+        reduce PassRefPtr use in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=166452
+
+        Reviewed by Yusuke Suzuki.
+
+        * Shared/API/c/cg/WKImageCG.cpp:
+        (WKImageCreateCGImage):
+        (WKImageCreateFromCGImage):
+        * Shared/ShareableBitmap.cpp:
+        (WebKit::ShareableBitmap::createHandle):
+        * Shared/ShareableBitmap.h:
+        * Shared/UserData.cpp:
+        (WebKit::UserData::encode):
+        (WebKit::UserData::decode):
+        * Shared/WebImage.cpp:
+        (WebKit::WebImage::create):
+        (WebKit::WebImage::WebImage):
+        * Shared/WebImage.h:
+        (WebKit::WebImage::bitmap):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didGetImageForFindMatch):
+        * UIProcess/mac/WKTextFinderClient.mm:
+        (-[WKTextFinderClient didGetImageForMatchResult:]):
+        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+        (WebKit::WebAutomationSessionProxy::takeScreenshot):
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm:
+        (-[WKWebProcessPlugInNodeHandle renderedImageWithOptions:]):
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
+        (WebKit::imageForRect):
+        (WebKit::InjectedBundleNodeHandle::renderedImage):
+        (WebKit::InjectedBundleNodeHandle::visibleRange):
+        (WebKit::InjectedBundleNodeHandle::htmlTableCellElementCellAbove):
+        (WebKit::InjectedBundleNodeHandle::documentFrame):
+        (WebKit::InjectedBundleNodeHandle::htmlFrameElementContentFrame):
+        (WebKit::InjectedBundleNodeHandle::htmlIFrameElementContentFrame):
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:
+        * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
+        (WebKit::InjectedBundleRangeHandle::renderedImage):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::takeSnapshot):
+        (WebKit::WebPage::snapshotAtSize):
+        (WebKit::WebPage::snapshotNode):
+        (WebKit::WebPage::drawRectToImage):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getPositionInformation):
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::setTopOverhangImage):
+        (WebKit::WebPage::setBottomOverhangImage):
+
 2016-12-27  Emanuele Aina  <emanuele.aina@collabora.com>
 
         Ensure NetworkProcess is ready before whitelisting TLS certificates
index 85b9938..bb2485f 100644 (file)
@@ -39,14 +39,14 @@ using namespace WebCore;
 cairo_surface_t* WKImageCreateCairoSurface(WKImageRef imageRef)
 {
     // We cannot pass a RefPtr through the API here, so we just leak the reference.
-    return toImpl(imageRef)->bitmap()->createCairoSurface().leakRef();
+    return toImpl(imageRef)->bitmap().createCairoSurface().leakRef();
 }
 
 WKImageRef WKImageCreateFromCairoSurface(cairo_surface_t* surface, WKImageOptions options)
 {
     IntSize imageSize(cairo_image_surface_get_width(surface), cairo_image_surface_get_height(surface));
     auto webImage = WebImage::create(imageSize, toImageOptions(options));
-    auto graphicsContext = webImage->bitmap()->createGraphicsContext();
+    auto graphicsContext = webImage->bitmap().createGraphicsContext();
 
     cairo_t* cr = graphicsContext->platformContext()->cr();
     cairo_set_source_surface(cr, surface, 0, 0);
index c62343d..1547e22 100644 (file)
@@ -38,23 +38,21 @@ using namespace WebCore;
 CGImageRef WKImageCreateCGImage(WKImageRef imageRef)
 {
     WebImage* webImage = toImpl(imageRef);
-    if (!webImage || !webImage->bitmap())
-        return 0;
+    if (!webImage)
+        return nullptr;
 
-    return webImage->bitmap()->makeCGImageCopy().leakRef();
+    return webImage->bitmap().makeCGImageCopy().leakRef();
 }
 
 WKImageRef WKImageCreateFromCGImage(CGImageRef imageRef, WKImageOptions options)
 {
     if (!imageRef)
-        return 0;
+        return nullptr;
     
     IntSize imageSize(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef));
     auto webImage = WebImage::create(imageSize, toImageOptions(options));
-    if (!webImage->bitmap())
-        return 0;
 
-    auto graphicsContext = webImage->bitmap()->createGraphicsContext();
+    auto graphicsContext = webImage->bitmap().createGraphicsContext();
     FloatRect rect(FloatPoint(0, 0), imageSize);
     graphicsContext->clearRect(rect);
     graphicsContext->drawNativeImage(imageRef, imageSize, rect, rect);
index bb912ea..9942e7c 100644 (file)
@@ -127,7 +127,7 @@ RefPtr<ShareableBitmap> ShareableBitmap::create(const Handle& handle, SharedMemo
     return create(handle.m_size, handle.m_flags, WTFMove(sharedMemory));
 }
 
-bool ShareableBitmap::createHandle(Handle& handle, SharedMemory::Protection protection)
+bool ShareableBitmap::createHandle(Handle& handle, SharedMemory::Protection protection) const
 {
     ASSERT(isBackedBySharedMemory());
 
index 5b1d433..df6c45c 100644 (file)
@@ -89,7 +89,7 @@ public:
     static RefPtr<ShareableBitmap> create(const Handle&, SharedMemory::Protection = SharedMemory::Protection::ReadWrite);
 
     // Create a handle.
-    bool createHandle(Handle&, SharedMemory::Protection = SharedMemory::Protection::ReadWrite);
+    bool createHandle(Handle&, SharedMemory::Protection = SharedMemory::Protection::ReadWrite) const;
 
     ~ShareableBitmap();
 
index 62e1358..533373c 100644 (file)
@@ -217,8 +217,8 @@ void UserData::encode(IPC::Encoder& encoder, const API::Object& object)
         auto& image = static_cast<const WebImage&>(object);
 
         ShareableBitmap::Handle handle;
-        ASSERT(!image.bitmap() || image.bitmap()->isBackedBySharedMemory());
-        if (!image.bitmap() || !image.bitmap()->isBackedBySharedMemory() || !image.bitmap()->createHandle(handle)) {
+        ASSERT(image.bitmap().isBackedBySharedMemory());
+        if (!image.bitmap().isBackedBySharedMemory() || !image.bitmap().createHandle(handle)) {
             // Initial false indicates no allocated bitmap or is not shareable.
             encoder << false;
             break;
@@ -420,7 +420,11 @@ bool UserData::decode(IPC::Decoder& decoder, RefPtr<API::Object>& result)
         if (!decoder.decode(handle))
             return false;
 
-        result = WebImage::create(ShareableBitmap::create(handle));
+        auto bitmap = ShareableBitmap::create(handle);
+        if (!bitmap)
+            return false;
+
+        result = WebImage::create(bitmap.releaseNonNull());
         break;
     }
 
index b0e4bff..49bc87b 100644 (file)
@@ -32,22 +32,28 @@ using namespace WebCore;
 
 namespace WebKit {
 
-PassRefPtr<WebImage> WebImage::create(const IntSize& size, ImageOptions options)
+RefPtr<WebImage> WebImage::create(const IntSize& size, ImageOptions options)
 {
-    if (options & ImageOptionsShareable)
-        return WebImage::create(ShareableBitmap::createShareable(size, ShareableBitmap::SupportsAlpha));
-    return WebImage::create(ShareableBitmap::create(size, ShareableBitmap::SupportsAlpha));
+    if (options & ImageOptionsShareable) {
+        auto bitmap = ShareableBitmap::createShareable(size, ShareableBitmap::SupportsAlpha);
+        if (!bitmap)
+            return nullptr;
+        return WebImage::create(bitmap.releaseNonNull());
+    }
+    auto bitmap = ShareableBitmap::create(size, ShareableBitmap::SupportsAlpha);
+    if (!bitmap)
+        return nullptr;
+    return WebImage::create(bitmap.releaseNonNull());
 }
 
-PassRefPtr<WebImage> WebImage::create(PassRefPtr<ShareableBitmap> bitmap)
+Ref<WebImage> WebImage::create(Ref<ShareableBitmap>&& bitmap)
 {
-    return adoptRef(new WebImage(bitmap));
+    return adoptRef(*new WebImage(WTFMove(bitmap)));
 }
 
-WebImage::WebImage(PassRefPtr<ShareableBitmap> bitmap)
-    : m_bitmap(bitmap)
+WebImage::WebImage(Ref<ShareableBitmap>&& bitmap)
+    : m_bitmap(WTFMove(bitmap))
 {
-    ASSERT(m_bitmap);
 }
 
 WebImage::~WebImage()
index 4bd07b0..4574c9e 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebImage_h
-#define WebImage_h
+#pragma once
 
 #include "APIObject.h"
 #include "ImageOptions.h"
-#include <wtf/RefPtr.h>
+#include <wtf/Ref.h>
 
 namespace WebCore {
-    class IntSize;
+class IntSize;
 }
 
 namespace WebKit {
@@ -42,20 +41,19 @@ class ShareableBitmap;
 
 class WebImage : public API::ObjectImpl<API::Object::Type::Image> {
 public:
-    static PassRefPtr<WebImage> create(const WebCore::IntSize&, ImageOptions);
-    static PassRefPtr<WebImage> create(PassRefPtr<ShareableBitmap>);
+    static RefPtr<WebImage> create(const WebCore::IntSize&, ImageOptions);
+    static Ref<WebImage> create(Ref<ShareableBitmap>&&);
     ~WebImage();
     
     const WebCore::IntSize& size() const;
 
-    ShareableBitmap* bitmap() const { return m_bitmap.get(); }
+    ShareableBitmap& bitmap() { return m_bitmap.get(); }
+    const ShareableBitmap& bitmap() const { return m_bitmap.get(); }
 
 private:
-    WebImage(PassRefPtr<ShareableBitmap>);
+    WebImage(Ref<ShareableBitmap>&&);
 
-    RefPtr<ShareableBitmap> m_bitmap;
+    Ref<ShareableBitmap> m_bitmap;
 };
 
 } // namespace WebKit
-
-#endif // WebImage_h
index b1d1f7a..2f661ca 100644 (file)
@@ -3414,10 +3414,7 @@ void webKitWebViewDidReceiveSnapshot(WebKitWebView* webView, uint64_t callbackID
         return;
     }
 
-    if (RefPtr<ShareableBitmap> image = webImage->bitmap())
-        g_task_return_pointer(task.get(), image->createCairoSurface().leakRef(), reinterpret_cast<GDestroyNotify>(cairo_surface_destroy));
-    else
-        g_task_return_pointer(task.get(), 0, 0);
+    g_task_return_pointer(task.get(), webImage->bitmap().createCairoSurface().leakRef(), reinterpret_cast<GDestroyNotify>(cairo_surface_destroy));
 }
 
 static inline unsigned webKitSnapshotOptionsToSnapshotOptions(WebKitSnapshotOptions options)
index a3d9bd8..b04470c 100644 (file)
@@ -4434,7 +4434,12 @@ void WebPageProxy::didCountStringMatches(const String& string, uint32_t matchCou
 
 void WebPageProxy::didGetImageForFindMatch(const ShareableBitmap::Handle& contentImageHandle, uint32_t matchIndex)
 {
-    m_findMatchesClient->didGetImageForMatchResult(this, WebImage::create(ShareableBitmap::create(contentImageHandle)).get(), matchIndex);
+    auto bitmap = ShareableBitmap::create(contentImageHandle);
+    if (!bitmap) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+    m_findMatchesClient->didGetImageForMatchResult(this, WebImage::create(bitmap.releaseNonNull()).ptr(), matchIndex);
 }
 
 void WebPageProxy::setTextIndicator(const TextIndicatorData& indicatorData, uint64_t lifetime)
index e319f56..8be1416 100644 (file)
@@ -248,11 +248,11 @@ static RetainPtr<NSArray> arrayFromRects(const Vector<IntRect>& matchRects)
     if (_imageReplyCallbacks.isEmpty())
         return;
 
-    IntSize size = image->bitmap()->size();
+    IntSize size = image->bitmap().size();
     size.scale(1 / _page->deviceScaleFactor());
 
     auto imageCallback = _imageReplyCallbacks.takeFirst();
-    imageCallback(adoptNS([[NSImage alloc] initWithCGImage:image->bitmap()->makeCGImage().get() size:size]).get());
+    imageCallback(adoptNS([[NSImage alloc] initWithCGImage:image->bitmap().makeCGImage().get() size:size]).get());
 }
 
 #pragma mark - WKTextFinderMatch callbacks
index 1f8edf3..4f77cf7 100644 (file)
@@ -534,7 +534,7 @@ void WebAutomationSessionProxy::takeScreenshot(uint64_t pageID, uint64_t callbac
 
     RefPtr<WebImage> image = page->scaledSnapshotWithOptions(snapshotRect, 1, SnapshotOptionsShareable);
     if (image)
-        image->bitmap()->createHandle(handle, SharedMemory::Protection::ReadOnly);
+        image->bitmap().createHandle(handle, SharedMemory::Protection::ReadOnly);
 
     WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidTakeScreenshot(callbackID, handle, String()), 0);    
 }
index 7b287fc..81b02c6 100644 (file)
@@ -68,10 +68,10 @@ using namespace WebKit;
 - (UIImage *)renderedImageWithOptions:(WKSnapshotOptions)options
 {
     RefPtr<WebImage> image = _nodeHandle->renderedImage(options);
-    if (!image || !image->bitmap())
+    if (!image)
         return nil;
 
-    return [[[UIImage alloc] initWithCGImage:image->bitmap()->makeCGImage().get()] autorelease];
+    return [[[UIImage alloc] initWithCGImage:image->bitmap().makeCGImage().get()] autorelease];
 }
 #endif
 
@@ -79,10 +79,10 @@ using namespace WebKit;
 - (NSImage *)renderedImageWithOptions:(WKSnapshotOptions)options
 {
     RefPtr<WebImage> image = _nodeHandle->renderedImage(options);
-    if (!image || !image->bitmap())
+    if (!image)
         return nil;
 
-    return [[[NSImage alloc] initWithCGImage:image->bitmap()->makeCGImage().get() size:NSZeroSize] autorelease];
+    return [[[NSImage alloc] initWithCGImage:image->bitmap().makeCGImage().get() size:NSZeroSize] autorelease];
 }
 #endif
 
index 39cfbf0..2386a37 100644 (file)
@@ -134,17 +134,15 @@ IntRect InjectedBundleNodeHandle::renderRect(bool* isReplaced)
     return m_node->pixelSnappedRenderRect(isReplaced);
 }
 
-static PassRefPtr<WebImage> imageForRect(FrameView* frameView, const IntRect& rect, SnapshotOptions options)
+static RefPtr<WebImage> imageForRect(FrameView* frameView, const IntRect& rect, SnapshotOptions options)
 {
     IntSize bitmapSize = rect.size();
     float scaleFactor = frameView->frame().page()->deviceScaleFactor();
     bitmapSize.scale(scaleFactor);
 
     auto snapshot = WebImage::create(bitmapSize, snapshotOptionsToImageOptions(options));
-    if (!snapshot->bitmap())
-        return 0;
 
-    auto graphicsContext = snapshot->bitmap()->createGraphicsContext();
+    auto graphicsContext = snapshot->bitmap().createGraphicsContext();
     graphicsContext->clearRect(IntRect(IntPoint(), bitmapSize));
     graphicsContext->applyDeviceScaleFactor(scaleFactor);
     graphicsContext->translate(-rect.x(), -rect.y());
@@ -167,7 +165,7 @@ static PassRefPtr<WebImage> imageForRect(FrameView* frameView, const IntRect& re
     return snapshot;
 }
 
-PassRefPtr<WebImage> InjectedBundleNodeHandle::renderedImage(SnapshotOptions options)
+RefPtr<WebImage> InjectedBundleNodeHandle::renderedImage(SnapshotOptions options)
 {
     Frame* frame = m_node->document().frame();
     if (!frame)
@@ -193,7 +191,7 @@ PassRefPtr<WebImage> InjectedBundleNodeHandle::renderedImage(SnapshotOptions opt
     return image;
 }
 
-PassRefPtr<InjectedBundleRangeHandle> InjectedBundleNodeHandle::visibleRange()
+RefPtr<InjectedBundleRangeHandle> InjectedBundleNodeHandle::visibleRange()
 {
     VisiblePosition start = firstPositionInNode(m_node.ptr());
     VisiblePosition end = lastPositionInNode(m_node.ptr());
@@ -286,7 +284,7 @@ bool InjectedBundleNodeHandle::isTextField() const
     return downcast<HTMLInputElement>(m_node.get()).isText();
 }
 
-PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::htmlTableCellElementCellAbove()
+RefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::htmlTableCellElementCellAbove()
 {
     if (!is<HTMLTableCellElement>(m_node))
         return nullptr;
@@ -294,7 +292,7 @@ PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::htmlTableCellElem
     return getOrCreate(downcast<HTMLTableCellElement>(m_node.get()).cellAbove());
 }
 
-PassRefPtr<WebFrame> InjectedBundleNodeHandle::documentFrame()
+RefPtr<WebFrame> InjectedBundleNodeHandle::documentFrame()
 {
     if (!m_node->isDocumentNode())
         return nullptr;
@@ -306,7 +304,7 @@ PassRefPtr<WebFrame> InjectedBundleNodeHandle::documentFrame()
     return WebFrame::fromCoreFrame(*frame);
 }
 
-PassRefPtr<WebFrame> InjectedBundleNodeHandle::htmlFrameElementContentFrame()
+RefPtr<WebFrame> InjectedBundleNodeHandle::htmlFrameElementContentFrame()
 {
     if (!is<HTMLFrameElement>(m_node))
         return nullptr;
@@ -318,7 +316,7 @@ PassRefPtr<WebFrame> InjectedBundleNodeHandle::htmlFrameElementContentFrame()
     return WebFrame::fromCoreFrame(*frame);
 }
 
-PassRefPtr<WebFrame> InjectedBundleNodeHandle::htmlIFrameElementContentFrame()
+RefPtr<WebFrame> InjectedBundleNodeHandle::htmlIFrameElementContentFrame()
 {
     if (!is<HTMLIFrameElement>(m_node))
         return nullptr;
index e0fc172..6d48500 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef InjectedBundleNodeHandle_h
-#define InjectedBundleNodeHandle_h
+#pragma once
 
 #include "APIObject.h"
 #include "ImageOptions.h"
 #include <JavaScriptCore/JSBase.h>
 #include <wtf/Forward.h>
-#include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
-    class IntRect;
-    class Node;
-    enum class AutoFillButtonType : uint8_t;
+class IntRect;
+class Node;
+enum class AutoFillButtonType : uint8_t;
 }
 
 namespace WebKit {
@@ -63,8 +61,8 @@ public:
     // Note: These should only be operations that are not exposed to JavaScript.
     WebCore::IntRect elementBounds();
     WebCore::IntRect renderRect(bool*);
-    PassRefPtr<WebImage> renderedImage(SnapshotOptions);
-    PassRefPtr<InjectedBundleRangeHandle> visibleRange();
+    RefPtr<WebImage> renderedImage(SnapshotOptions);
+    RefPtr<InjectedBundleRangeHandle> visibleRange();
     void setHTMLInputElementValueForUser(const String&);
     void setHTMLInputElementSpellcheckEnabled(bool);
     bool isHTMLInputElementAutoFilled() const;
@@ -76,11 +74,11 @@ public:
     bool htmlTextAreaElementLastChangeWasUserEdit();
     bool isTextField() const;
     
-    PassRefPtr<InjectedBundleNodeHandle> htmlTableCellElementCellAbove();
+    RefPtr<InjectedBundleNodeHandle> htmlTableCellElementCellAbove();
 
-    PassRefPtr<WebFrame> documentFrame();
-    PassRefPtr<WebFrame> htmlFrameElementContentFrame();
-    PassRefPtr<WebFrame> htmlIFrameElementContentFrame();
+    RefPtr<WebFrame> documentFrame();
+    RefPtr<WebFrame> htmlFrameElementContentFrame();
+    RefPtr<WebFrame> htmlIFrameElementContentFrame();
 
 private:
     static Ref<InjectedBundleNodeHandle> create(WebCore::Node&);
@@ -90,5 +88,3 @@ private:
 };
 
 } // namespace WebKit
-
-#endif // InjectedBundleNodeHandle_h
index a8f8f1b..2f2bfa2 100644 (file)
@@ -157,7 +157,7 @@ PassRefPtr<WebImage> InjectedBundleRangeHandle::renderedImage(SnapshotOptions op
 
     frame->selection().setSelection(oldSelection);
 
-    return WebImage::create(backingStore);
+    return WebImage::create(backingStore.releaseNonNull());
 }
 
 } // namespace WebKit
index 67ef2a6..6cc2f73 100644 (file)
@@ -1859,7 +1859,7 @@ void WebPage::takeSnapshot(IntRect snapshotRect, IntSize bitmapSize, uint32_t op
 
     ShareableBitmap::Handle handle;
     if (image)
-        image->bitmap()->createHandle(handle, SharedMemory::Protection::ReadOnly);
+        image->bitmap().createHandle(handle, SharedMemory::Protection::ReadOnly);
 
     send(Messages::WebPageProxy::ImageCallback(handle, callbackID));
 }
@@ -1900,10 +1900,8 @@ PassRefPtr<WebImage> WebPage::snapshotAtSize(const IntRect& rect, const IntSize&
     float scaleFactor = std::max(horizontalScaleFactor, verticalScaleFactor);
 
     auto snapshot = WebImage::create(bitmapSize, snapshotOptionsToImageOptions(options));
-    if (!snapshot->bitmap())
-        return nullptr;
 
-    auto graphicsContext = snapshot->bitmap()->createGraphicsContext();
+    auto graphicsContext = snapshot->bitmap().createGraphicsContext();
 
     if (options & SnapshotOptionsPrinting) {
         PrintContext::spoolAllPagesWithBoundaries(*coreFrame, *graphicsContext, snapshotRect.size());
@@ -1969,10 +1967,8 @@ PassRefPtr<WebImage> WebPage::snapshotNode(WebCore::Node& node, SnapshotOptions
     }
 
     auto snapshot = WebImage::create(snapshotSize, snapshotOptionsToImageOptions(options));
-    if (!snapshot->bitmap())
-        return nullptr;
 
-    auto graphicsContext = snapshot->bitmap()->createGraphicsContext();
+    auto graphicsContext = snapshot->bitmap().createGraphicsContext();
 
     if (!(options & SnapshotOptionsExcludeDeviceScaleFactor)) {
         double deviceScaleFactor = corePage()->deviceScaleFactor();
@@ -4267,6 +4263,10 @@ void WebPage::drawRectToImage(uint64_t frameID, const PrintInfo& printInfo, cons
 #endif
 
         auto bitmap = ShareableBitmap::createShareable(imageSize, ShareableBitmap::SupportsAlpha);
+        if (!bitmap) {
+            ASSERT_NOT_REACHED();
+            return;
+        }
         auto graphicsContext = bitmap->createGraphicsContext();
 
         float printingScale = static_cast<float>(imageSize.width()) / rect.width();
@@ -4284,14 +4284,14 @@ void WebPage::drawRectToImage(uint64_t frameID, const PrintInfo& printInfo, cons
             m_printContext->spoolRect(*graphicsContext, rect);
         }
 
-        image = WebImage::create(WTFMove(bitmap));
+        image = WebImage::create(bitmap.releaseNonNull());
     }
 #endif
 
     ShareableBitmap::Handle handle;
 
     if (image)
-        image->bitmap()->createHandle(handle, SharedMemory::Protection::ReadOnly);
+        image->bitmap().createHandle(handle, SharedMemory::Protection::ReadOnly);
 
     send(Messages::WebPageProxy::ImageCallback(handle, callbackID));
 }
index 18c029d..64f6b8b 100644 (file)
@@ -2335,7 +2335,7 @@ void WebPage::getPositionInformation(const InteractionInformationRequest& reques
                     if (request.includeSnapshot) {
                         // Ensure that the image contains at most 600K pixels, so that it is not too big.
                         if (RefPtr<WebImage> snapshot = snapshotNode(*element, SnapshotOptionsShareable, 600 * 1024))
-                            info.image = snapshot->bitmap();
+                            info.image = &snapshot->bitmap();
                     }
 
                     if (request.includeLinkIndicator) {
index 54bd203..f7eb8d7 100644 (file)
@@ -786,7 +786,7 @@ void WebPage::setTopOverhangImage(PassRefPtr<WebImage> image)
     layer->setSize(image->size());
     layer->setPosition(FloatPoint(0, -image->size().height()));
 
-    RetainPtr<CGImageRef> cgImage = image->bitmap()->makeCGImageCopy();
+    RetainPtr<CGImageRef> cgImage = image->bitmap().makeCGImageCopy();
     layer->platformLayer().contents = (id)cgImage.get();
 }
 
@@ -802,7 +802,7 @@ void WebPage::setBottomOverhangImage(PassRefPtr<WebImage> image)
 
     layer->setSize(image->size());
     
-    RetainPtr<CGImageRef> cgImage = image->bitmap()->makeCGImageCopy();
+    RetainPtr<CGImageRef> cgImage = image->bitmap().makeCGImageCopy();
     layer->platformLayer().contents = (id)cgImage.get();
 }