From f7e9800e930aaa522f1b12cfa0bed531846fa05d Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Tue, 3 May 2016 07:04:21 -0700 Subject: [PATCH] Bug 1268721, part 1 - Use early continue in TransferableToIPCTransferable. r=jimm --- dom/base/nsContentUtils.cpp | 41 +++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 1abfcd9a1a35..8e3869f34334 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -7378,27 +7378,28 @@ nsContentUtils::TransferableToIPCTransferable(nsITransferable* aTransferable, RefPtr surface = image->GetFrame(imgIContainer::FRAME_CURRENT, imgIContainer::FLAG_SYNC_DECODE); - if (surface) { - RefPtr dataSurface = - surface->GetDataSurface(); - size_t length; - int32_t stride; - mozilla::UniquePtr surfaceData = - nsContentUtils::GetSurfaceData(dataSurface, &length, &stride); - - IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement(); - item->flavor() = flavorStr; - // Turn item->data() into an nsCString prior to accessing it. - item->data() = EmptyCString(); - item->data().get_nsCString().Adopt(surfaceData.release(), length); - - IPCDataTransferImage& imageDetails = item->imageDetails(); - mozilla::gfx::IntSize size = dataSurface->GetSize(); - imageDetails.width() = size.width; - imageDetails.height() = size.height; - imageDetails.stride() = stride; - imageDetails.format() = static_cast(dataSurface->GetFormat()); + if (!surface) { + continue; } + RefPtr dataSurface = + surface->GetDataSurface(); + size_t length; + int32_t stride; + mozilla::UniquePtr surfaceData = + nsContentUtils::GetSurfaceData(dataSurface, &length, &stride); + + IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement(); + item->flavor() = flavorStr; + // Turn item->data() into an nsCString prior to accessing it. + item->data() = EmptyCString(); + item->data().get_nsCString().Adopt(surfaceData.release(), length); + + IPCDataTransferImage& imageDetails = item->imageDetails(); + mozilla::gfx::IntSize size = dataSurface->GetSize(); + imageDetails.width() = size.width; + imageDetails.height() = size.height; + imageDetails.stride() = stride; + imageDetails.format() = static_cast(dataSurface->GetFormat()); continue; }