Bug 1141979 - part13 - export to WorkerGlobalScope; r=jrmuizel
MozReview-Commit-ID: 9AAPwpck23l
--- 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()