Bug 1141979 - part0 - setup preference utilities; r=jrmuizel
MozReview-Commit-ID: GoevPKVNASQ
--- a/dom/canvas/ImageBitmap.cpp
+++ b/dom/canvas/ImageBitmap.cpp
@@ -1390,10 +1390,22 @@ ImageBitmap::WriteStructuredClone(JSStru
true);
}
MOZ_ASSERT(dstDataSurface);
Factory::CopyDataSourceSurface(snapshot, dstDataSurface);
aClonedSurfaces.AppendElement(dstDataSurface);
return true;
}
+/*static*/ bool
+ImageBitmap::ExtensionsEnabled(JSContext* aCx, JSObject*)
+{
+ if (NS_IsMainThread()) {
+ return Preferences::GetBool("canvas.imagebitmap_extensions.enabled");
+ } else {
+ WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
+ MOZ_ASSERT(workerPrivate);
+ return workerPrivate->ImageBitmapExtensionsEnabled();
+ }
+}
+
} // namespace dom
} // namespace mozilla
--- a/dom/canvas/ImageBitmap.h
+++ b/dom/canvas/ImageBitmap.h
@@ -131,16 +131,19 @@ public:
const nsTArray<RefPtr<gfx::DataSourceSurface>>& aClonedSurfaces,
uint32_t aIndex);
static bool
WriteStructuredClone(JSStructuredCloneWriter* aWriter,
nsTArray<RefPtr<gfx::DataSourceSurface>>& aClonedSurfaces,
ImageBitmap* aImageBitmap);
+ // Mozilla Extensions
+ static bool ExtensionsEnabled(JSContext* aCx, JSObject* aObj);
+
friend CreateImageBitmapFromBlob;
friend CreateImageBitmapFromBlobTask;
friend CreateImageBitmapFromBlobWorkerTask;
protected:
/*
* The default value of aIsPremultipliedAlpha is TRUE because that the
--- a/dom/workers/WorkerPrefs.h
+++ b/dom/workers/WorkerPrefs.h
@@ -19,16 +19,17 @@
// WORKER_PREF("foo.bar", UpdaterFunction)
//
// * First argument is the name of the pref.
// * The name of the function that updates the new value of a pref.
#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
WORKER_SIMPLE_PREF("browser.dom.window.dump.enabled", DumpEnabled, DUMP)
#endif
+WORKER_SIMPLE_PREF("canvas.imagebitmap_extensions.enabled", ImageBitmapExtensionsEnabled, IMAGEBITMAP_EXTENSIONS_ENABLED)
WORKER_SIMPLE_PREF("dom.caches.enabled", DOMCachesEnabled, DOM_CACHES)
WORKER_SIMPLE_PREF("dom.caches.testing.enabled", DOMCachesTestingEnabled, DOM_CACHES_TESTING)
WORKER_SIMPLE_PREF("dom.performance.enable_user_timing_logging", PerformanceLoggingEnabled, PERFORMANCE_LOGGING_ENABLED)
WORKER_SIMPLE_PREF("dom.webnotifications.enabled", DOMWorkerNotificationEnabled, DOM_WORKERNOTIFICATION)
WORKER_SIMPLE_PREF("dom.webnotifications.serviceworker.enabled", DOMServiceWorkerNotificationEnabled, DOM_SERVICEWORKERNOTIFICATION)
WORKER_SIMPLE_PREF("dom.serviceWorkers.enabled", ServiceWorkersEnabled, SERVICEWORKERS_ENABLED)
WORKER_SIMPLE_PREF("dom.serviceWorkers.testing.enabled", ServiceWorkersTestingEnabled, SERVICEWORKERS_TESTING_ENABLED)
WORKER_SIMPLE_PREF("dom.serviceWorkers.openWindow.enabled", OpenWindowEnabled, OPEN_WINDOW_ENABLED)
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -785,16 +785,23 @@ pref("ui.scrollToClick", 0);
pref("canvas.focusring.enabled", true);
pref("canvas.customfocusring.enabled", false);
pref("canvas.hitregions.enabled", false);
pref("canvas.filters.enabled", false);
// Add support for canvas path objects
pref("canvas.path.enabled", true);
pref("canvas.capturestream.enabled", true);
+// Disable the ImageBitmap-extensions in the release build.
+#ifdef RELEASE_BUILD
+pref("canvas.imagebitmap_extensions.enabled", false);
+#else
+pref("canvas.imagebitmap_extensions.enabled", true);
+#endif
+
// We want the ability to forcibly disable platform a11y, because
// some non-a11y-related components attempt to bring it up. See bug
// 538530 for details about Windows; we have a pref here that allows it
// to be disabled for performance and testing resons.
// See bug 761589 for the crossplatform aspect.
//
// This pref is checked only once, and the browser needs a restart to
// pick up any changes.