1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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/. */
7 #include "PaintWorkletGlobalScope.h"
9 #include "mozilla/dom/WorkletPrincipals.h"
10 #include "mozilla/dom/PaintWorkletGlobalScopeBinding.h"
11 #include "mozilla/dom/FunctionBinding.h"
12 #include "PaintWorkletImpl.h"
17 PaintWorkletGlobalScope::PaintWorkletGlobalScope(PaintWorkletImpl
* aImpl
)
18 : WorkletGlobalScope(aImpl
->GetAgentClusterId(),
19 aImpl
->IsSharedMemoryAllowed()),
22 bool PaintWorkletGlobalScope::WrapGlobalObject(
23 JSContext
* aCx
, JS::MutableHandle
<JSObject
*> aReflector
) {
24 JS::RealmOptions options
;
26 // The SharedArrayBuffer global constructor property should not be present in
27 // a fresh global object when shared memory objects aren't allowed (because
28 // COOP/COEP support isn't enabled, or because COOP/COEP don't act to isolate
29 // this worker to a separate process).
30 options
.creationOptions().setDefineSharedArrayBufferConstructor(
31 IsSharedMemoryAllowed());
33 JS::AutoHoldPrincipals
principals(aCx
, new WorkletPrincipals(mImpl
));
34 return PaintWorkletGlobalScope_Binding::Wrap(
35 aCx
, this, this, options
, principals
.get(), true, aReflector
);
38 void PaintWorkletGlobalScope::RegisterPaint(const nsAString
& aType
,
39 VoidFunction
& aProcessorCtor
) {
40 // Nothing to do here, yet.
43 WorkletImpl
* PaintWorkletGlobalScope::Impl() const { return mImpl
; }
46 } // namespace mozilla