LCOV - code coverage report
Current view: top level - widget - nsDragServiceProxy.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 35 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  *
       3             :  * This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "nsDragServiceProxy.h"
       8             : #include "nsIDocument.h"
       9             : #include "nsISupportsPrimitives.h"
      10             : #include "mozilla/dom/TabChild.h"
      11             : #include "mozilla/gfx/2D.h"
      12             : #include "mozilla/UniquePtr.h"
      13             : #include "mozilla/Unused.h"
      14             : #include "nsContentUtils.h"
      15             : 
      16             : using mozilla::ipc::Shmem;
      17             : using mozilla::dom::TabChild;
      18             : using mozilla::dom::OptionalShmem;
      19             : 
      20           0 : NS_IMPL_ISUPPORTS_INHERITED0(nsDragServiceProxy, nsBaseDragService)
      21             : 
      22           0 : nsDragServiceProxy::nsDragServiceProxy()
      23             : {
      24           0 : }
      25             : 
      26           0 : nsDragServiceProxy::~nsDragServiceProxy()
      27             : {
      28           0 : }
      29             : 
      30             : nsresult
      31           0 : nsDragServiceProxy::InvokeDragSessionImpl(nsIArray* aArrayTransferables,
      32             :                                           nsIScriptableRegion* aRegion,
      33             :                                           uint32_t aActionType)
      34             : {
      35           0 :   nsCOMPtr<nsIDocument> doc = do_QueryInterface(mSourceDocument);
      36           0 :   NS_ENSURE_STATE(doc->GetDocShell());
      37           0 :   TabChild* child = TabChild::GetFrom(doc->GetDocShell());
      38           0 :   NS_ENSURE_STATE(child);
      39           0 :   nsTArray<mozilla::dom::IPCDataTransfer> dataTransfers;
      40           0 :   nsContentUtils::TransferablesToIPCTransferables(aArrayTransferables,
      41             :                                                   dataTransfers,
      42             :                                                   false,
      43             :                                                   child->Manager(),
      44           0 :                                                   nullptr);
      45             : 
      46           0 :   LayoutDeviceIntRect dragRect;
      47           0 :   if (mHasImage || mSelection) {
      48             :     nsPresContext* pc;
      49           0 :     RefPtr<mozilla::gfx::SourceSurface> surface;
      50           0 :     DrawDrag(mSourceNode, aRegion, mScreenPosition, &dragRect, &surface, &pc);
      51             : 
      52           0 :     if (surface) {
      53             :       RefPtr<mozilla::gfx::DataSourceSurface> dataSurface =
      54           0 :         surface->GetDataSurface();
      55           0 :       if (dataSurface) {
      56             :         size_t length;
      57             :         int32_t stride;
      58             :         Maybe<Shmem> maybeShm = nsContentUtils::GetSurfaceData(dataSurface,
      59             :                                                                &length,
      60             :                                                                &stride,
      61           0 :                                                                child);
      62           0 :         if (maybeShm.isNothing()) {
      63           0 :           return NS_ERROR_FAILURE;
      64             :         }
      65             : 
      66           0 :         auto surfaceData = maybeShm.value();
      67             : 
      68             :         // Save the surface data to shared memory.
      69           0 :         if (!surfaceData.IsReadable() || !surfaceData.get<char>()) {
      70           0 :           NS_WARNING("Failed to create shared memory for drag session.");
      71           0 :           return NS_ERROR_FAILURE;
      72             :         }
      73             : 
      74             :         mozilla::Unused <<
      75           0 :           child->SendInvokeDragSession(dataTransfers, aActionType, surfaceData,
      76           0 :                                        stride, static_cast<uint8_t>(dataSurface->GetFormat()),
      77             :                                        dragRect);
      78           0 :         StartDragSession();
      79           0 :         return NS_OK;
      80             :       }
      81             :     }
      82             :   }
      83             : 
      84           0 :   mozilla::Unused << child->SendInvokeDragSession(dataTransfers, aActionType,
      85           0 :                                                   mozilla::void_t(), 0, 0, dragRect);
      86           0 :   StartDragSession();
      87           0 :   return NS_OK;
      88             : }

Generated by: LCOV version 1.13