Bug 1141979 - part13 - export to WorkerGlobalScope; r=jrmuizel draft
authorKaku Kuo <tkuo@mozilla.com>
Wed, 27 Apr 2016 11:47:36 +0800
changeset 373852 734d3e9122688d8c9c6f445be0e765c154fd1e54
parent 373851 a74ef02529d7b7c3fa26ebab599b9446ecaffe3d
child 373853 8e2c969b224f0c38828ea943a5ae0879545a450c
push id19853
push usertkuo@mozilla.com
push dateWed, 01 Jun 2016 09:17:41 +0000
reviewersjrmuizel
bugs1141979
milestone49.0a1
Bug 1141979 - part13 - export to WorkerGlobalScope; r=jrmuizel MozReview-Commit-ID: 9AAPwpck23l
dom/workers/WorkerScope.cpp
dom/workers/WorkerScope.h
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -431,16 +431,32 @@ WorkerGlobalScope::CreateImageBitmap(con
   if (aImage.IsArrayBuffer() || aImage.IsArrayBufferView()) {
     aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
     return nullptr;
   }
 
   return ImageBitmap::Create(this, aImage, Some(gfx::IntRect(aSx, aSy, aSw, aSh)), aRv);
 }
 
+already_AddRefed<mozilla::dom::Promise>
+WorkerGlobalScope::CreateImageBitmap(const ImageBitmapSource& aImage,
+                                     int32_t aOffset, int32_t aLength,
+                                     ImageBitmapFormat aFormat,
+                                     const Sequence<ChannelPixelLayout>& aLayout,
+                                     ErrorResult& aRv)
+{
+  if (aImage.IsArrayBuffer() || aImage.IsArrayBufferView()) {
+    return ImageBitmap::Create(this, aImage, aOffset, aLength, aFormat, aLayout,
+                               aRv);
+  } else {
+    aRv.Throw(NS_ERROR_TYPE_ERR);
+    return nullptr;
+  }
+}
+
 DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate)
 : WorkerGlobalScope(aWorkerPrivate)
 {
 }
 
 bool
 DedicatedWorkerGlobalScope::WrapGlobalObject(JSContext* aCx,
                                              JS::MutableHandle<JSObject*> aReflector)
--- a/dom/workers/WorkerScope.h
+++ b/dom/workers/WorkerScope.h
@@ -13,20 +13,22 @@
 #include "mozilla/dom/RequestBinding.h"
 #include "nsWeakReference.h"
 #include "mozilla/dom/ImageBitmapSource.h"
 
 namespace mozilla {
 namespace dom {
 
 class AnyCallback;
+struct ChannelPixelLayout;
 class Console;
 class Crypto;
 class Function;
 class IDBFactory;
+enum class ImageBitmapFormat : uint32_t;
 class Promise;
 class RequestOrUSVString;
 class ServiceWorkerRegistrationWorkerThread;
 class WorkerLocation;
 class WorkerNavigator;
 
 namespace cache {
 
@@ -164,16 +166,23 @@ public:
   already_AddRefed<Promise>
   CreateImageBitmap(const ImageBitmapSource& aImage, ErrorResult& aRv);
 
   already_AddRefed<Promise>
   CreateImageBitmap(const ImageBitmapSource& aImage,
                     int32_t aSx, int32_t aSy, int32_t aSw, int32_t aSh,
                     ErrorResult& aRv);
 
+  already_AddRefed<mozilla::dom::Promise>
+  CreateImageBitmap(const ImageBitmapSource& aImage,
+                    int32_t aOffset, int32_t aLength,
+                    mozilla::dom::ImageBitmapFormat aFormat,
+                    const mozilla::dom::Sequence<mozilla::dom::ChannelPixelLayout>& aLayout,
+                    mozilla::ErrorResult& aRv);
+
   bool
   WindowInteractionAllowed() const
   {
     return mWindowInteractionsAllowed > 0;
   }
 
   void
   AllowWindowInteraction()