Title: [210181] trunk/Source/WebKit2
Revision
210181
Author
[email protected]
Date
2016-12-27 18:48:19 -0800 (Tue, 27 Dec 2016)

Log Message

reduce PassRefPtr use in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=166452

Patch by Alex Christensen <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (210180 => 210181)


--- trunk/Source/WebKit2/ChangeLog	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/ChangeLog	2016-12-28 02:48:19 UTC (rev 210181)
@@ -1,3 +1,54 @@
+2016-12-27  Alex Christensen  <[email protected]>
+
+        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  <[email protected]>
 
         Ensure NetworkProcess is ready before whitelisting TLS certificates

Modified: trunk/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp (210180 => 210181)


--- trunk/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp	2016-12-28 02:48:19 UTC (rev 210181)
@@ -39,7 +39,7 @@
 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)
@@ -46,7 +46,7 @@
 {
     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);

Modified: trunk/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp (210180 => 210181)


--- trunk/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp	2016-12-28 02:48:19 UTC (rev 210181)
@@ -38,23 +38,21 @@
 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);

Modified: trunk/Source/WebKit2/Shared/ShareableBitmap.cpp (210180 => 210181)


--- trunk/Source/WebKit2/Shared/ShareableBitmap.cpp	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/Shared/ShareableBitmap.cpp	2016-12-28 02:48:19 UTC (rev 210181)
@@ -127,7 +127,7 @@
     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());
 

Modified: trunk/Source/WebKit2/Shared/ShareableBitmap.h (210180 => 210181)


--- trunk/Source/WebKit2/Shared/ShareableBitmap.h	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/Shared/ShareableBitmap.h	2016-12-28 02:48:19 UTC (rev 210181)
@@ -89,7 +89,7 @@
     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();
 

Modified: trunk/Source/WebKit2/Shared/UserData.cpp (210180 => 210181)


--- trunk/Source/WebKit2/Shared/UserData.cpp	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/Shared/UserData.cpp	2016-12-28 02:48:19 UTC (rev 210181)
@@ -217,8 +217,8 @@
         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 @@
         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;
     }
 

Modified: trunk/Source/WebKit2/Shared/WebImage.cpp (210180 => 210181)


--- trunk/Source/WebKit2/Shared/WebImage.cpp	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/Shared/WebImage.cpp	2016-12-28 02:48:19 UTC (rev 210181)
@@ -32,22 +32,28 @@
 
 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()

Modified: trunk/Source/WebKit2/Shared/WebImage.h (210180 => 210181)


--- trunk/Source/WebKit2/Shared/WebImage.h	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/Shared/WebImage.h	2016-12-28 02:48:19 UTC (rev 210181)
@@ -23,15 +23,14 @@
  * 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 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

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (210180 => 210181)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp	2016-12-28 02:48:19 UTC (rev 210181)
@@ -3414,10 +3414,7 @@
         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)

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (210180 => 210181)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-12-28 02:48:19 UTC (rev 210181)
@@ -4434,7 +4434,12 @@
 
 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)

Modified: trunk/Source/WebKit2/UIProcess/mac/WKTextFinderClient.mm (210180 => 210181)


--- trunk/Source/WebKit2/UIProcess/mac/WKTextFinderClient.mm	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/UIProcess/mac/WKTextFinderClient.mm	2016-12-28 02:48:19 UTC (rev 210181)
@@ -248,11 +248,11 @@
     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

Modified: trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp (210180 => 210181)


--- trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp	2016-12-28 02:48:19 UTC (rev 210181)
@@ -534,7 +534,7 @@
 
     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);    
 }

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm (210180 => 210181)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm	2016-12-28 02:48:19 UTC (rev 210181)
@@ -68,10 +68,10 @@
 - (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 @@
 - (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
 

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp (210180 => 210181)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp	2016-12-28 02:48:19 UTC (rev 210181)
@@ -134,7 +134,7 @@
     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();
@@ -141,10 +141,8 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     return WebFrame::fromCoreFrame(*frame);
 }
 
-PassRefPtr<WebFrame> InjectedBundleNodeHandle::htmlFrameElementContentFrame()
+RefPtr<WebFrame> InjectedBundleNodeHandle::htmlFrameElementContentFrame()
 {
     if (!is<HTMLFrameElement>(m_node))
         return nullptr;
@@ -318,7 +316,7 @@
     return WebFrame::fromCoreFrame(*frame);
 }
 
-PassRefPtr<WebFrame> InjectedBundleNodeHandle::htmlIFrameElementContentFrame()
+RefPtr<WebFrame> InjectedBundleNodeHandle::htmlIFrameElementContentFrame()
 {
     if (!is<HTMLIFrameElement>(m_node))
         return nullptr;

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h (210180 => 210181)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h	2016-12-28 02:48:19 UTC (rev 210181)
@@ -23,20 +23,18 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef InjectedBundleNodeHandle_h
-#define InjectedBundleNodeHandle_h
+#pragma once
 
 #include "APIObject.h"
 #include "ImageOptions.h"
 #include <_javascript_Core/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 @@
     // 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 @@
     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 @@
 };
 
 } // namespace WebKit
-
-#endif // InjectedBundleNodeHandle_h

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp (210180 => 210181)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp	2016-12-28 02:48:19 UTC (rev 210181)
@@ -157,7 +157,7 @@
 
     frame->selection().setSelection(oldSelection);
 
-    return WebImage::create(backingStore);
+    return WebImage::create(backingStore.releaseNonNull());
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (210180 => 210181)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-12-28 02:48:19 UTC (rev 210181)
@@ -1859,7 +1859,7 @@
 
     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 @@
     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 @@
     }
 
     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 @@
 #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,7 +4284,7 @@
             m_printContext->spoolRect(*graphicsContext, rect);
         }
 
-        image = WebImage::create(WTFMove(bitmap));
+        image = WebImage::create(bitmap.releaseNonNull());
     }
 #endif
 
@@ -4291,7 +4291,7 @@
     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));
 }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (210180 => 210181)


--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2016-12-28 02:48:19 UTC (rev 210181)
@@ -2335,7 +2335,7 @@
                     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) {

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (210180 => 210181)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2016-12-27 17:57:18 UTC (rev 210180)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2016-12-28 02:48:19 UTC (rev 210181)
@@ -786,7 +786,7 @@
     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 @@
 
     layer->setSize(image->size());
     
-    RetainPtr<CGImageRef> cgImage = image->bitmap()->makeCGImageCopy();
+    RetainPtr<CGImageRef> cgImage = image->bitmap().makeCGImageCopy();
     layer->platformLayer().contents = (id)cgImage.get();
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to