Bug 1489844 - Port DOMPrefs to StaticPrefs - part 1 - canvas_imagebitmap_extensions_enabled, r=ehsan

This commit is contained in:
Andrea Marchesini 2018-09-10 20:36:14 +02:00
Родитель 63cb9a2572
Коммит 84efbc6ccd
8 изменённых файлов: 29 добавлений и 10 удалений

Просмотреть файл

@ -24,12 +24,14 @@ DOMPrefs::Initialize()
#define DOM_PREF(name, pref) DOMPrefs::name(); #define DOM_PREF(name, pref) DOMPrefs::name();
#define DOM_WEBIDL_PREF(name) #define DOM_WEBIDL_PREF(name)
#define DOM_WEBIDL_PREF2(name)
#define DOM_UINT32_PREF(name, pref, defaultValue) DOMPrefs::name(); #define DOM_UINT32_PREF(name, pref, defaultValue) DOMPrefs::name();
#include "DOMPrefsInternal.h" #include "DOMPrefsInternal.h"
#undef DOM_PREF #undef DOM_PREF
#undef DOM_WEBIDL_PREF #undef DOM_WEBIDL_PREF
#undef DOM_WEBIDL_PREF2
#undef DOM_UINT32_PREF #undef DOM_UINT32_PREF
} }
@ -53,6 +55,15 @@ DOMPrefs::Initialize()
return DOMPrefs::name(); \ return DOMPrefs::name(); \
} }
// TODO: this is going to be renamed DOM_WEBIDL_PREF in the last patch.
#define DOM_WEBIDL_PREF2(name) \
/* static */ bool \
DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
{ \
return StaticPrefs::name(); \
}
#define DOM_UINT32_PREF(name, pref, defaultValue) \ #define DOM_UINT32_PREF(name, pref, defaultValue) \
/* static */ uint32_t \ /* static */ uint32_t \
DOMPrefs::name() \ DOMPrefs::name() \
@ -86,6 +97,7 @@ DOMPrefs::SchedulerTimingEnabled()
#undef DOM_PREF #undef DOM_PREF
#undef DOM_WEBIDL_PREF #undef DOM_WEBIDL_PREF
#undef DOM_WEBIDL_PREF2
#undef DOM_UINT32_PREF #undef DOM_UINT32_PREF
} // dom namespace } // dom namespace

Просмотреть файл

@ -24,12 +24,14 @@ public:
#define DOM_PREF(name, pref) static bool name(); #define DOM_PREF(name, pref) static bool name();
#define DOM_WEBIDL_PREF(name) static bool name(JSContext* aCx, JSObject* aObj); #define DOM_WEBIDL_PREF(name) static bool name(JSContext* aCx, JSObject* aObj);
#define DOM_WEBIDL_PREF2(name) static bool name(JSContext* aCx, JSObject* aObj);
#define DOM_UINT32_PREF(name, pref, defaultValue) static uint32_t name(); #define DOM_UINT32_PREF(name, pref, defaultValue) static uint32_t name();
#include "DOMPrefsInternal.h" #include "DOMPrefsInternal.h"
#undef DOM_PREF #undef DOM_PREF
#undef DOM_WEBIDL_PREF #undef DOM_WEBIDL_PREF
#undef DOM_WEBIDL_PREF2
#undef DOM_UINT32_PREF #undef DOM_UINT32_PREF
}; };

Просмотреть файл

@ -19,7 +19,6 @@
// * This defines DOMPrefs::FooBar(JSContext* aCx, JSObject* aObj); // * This defines DOMPrefs::FooBar(JSContext* aCx, JSObject* aObj);
// This is allows the use of DOMPrefs in WebIDL files. // This is allows the use of DOMPrefs in WebIDL files.
DOM_PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
DOM_PREF(DOMCachesEnabled, "dom.caches.enabled") DOM_PREF(DOMCachesEnabled, "dom.caches.enabled")
DOM_PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled") DOM_PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
DOM_PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging") DOM_PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
@ -45,7 +44,7 @@ DOM_PREF(IndexedDBStorageOptionsEnabled, "dom.indexedDB.storageOption.enabled")
DOM_PREF(BinASTEncodingEnabled, "dom.script_loader.binast_encoding.enabled") DOM_PREF(BinASTEncodingEnabled, "dom.script_loader.binast_encoding.enabled")
#endif #endif
DOM_WEBIDL_PREF(ImageBitmapExtensionsEnabled) DOM_WEBIDL_PREF2(canvas_imagebitmap_extensions_enabled)
DOM_WEBIDL_PREF(DOMCachesEnabled) DOM_WEBIDL_PREF(DOMCachesEnabled)
DOM_WEBIDL_PREF(NotificationEnabledInServiceWorkers) DOM_WEBIDL_PREF(NotificationEnabledInServiceWorkers)
DOM_WEBIDL_PREF(NotificationRIEnabled) DOM_WEBIDL_PREF(NotificationRIEnabled)

Просмотреть файл

@ -101,6 +101,7 @@
#include "PostMessageEvent.h" #include "PostMessageEvent.h"
#include "mozilla/dom/DocGroup.h" #include "mozilla/dom/DocGroup.h"
#include "mozilla/dom/TabGroup.h" #include "mozilla/dom/TabGroup.h"
#include "mozilla/StaticPrefs.h"
// Interfaces Needed // Interfaces Needed
#include "nsIFrame.h" #include "nsIFrame.h"
@ -7725,7 +7726,7 @@ nsGlobalWindowInner::CreateImageBitmap(JSContext* aCx,
const Sequence<ChannelPixelLayout>& aLayout, const Sequence<ChannelPixelLayout>& aLayout,
ErrorResult& aRv) ErrorResult& aRv)
{ {
if (!DOMPrefs::ImageBitmapExtensionsEnabled()) { if (!StaticPrefs::canvas_imagebitmap_extensions_enabled()) {
aRv.Throw(NS_ERROR_TYPE_ERR); aRv.Throw(NS_ERROR_TYPE_ERR);
return nullptr; return nullptr;
} }

Просмотреть файл

@ -403,10 +403,10 @@ dictionary ChannelPixelLayout {
typedef sequence<ChannelPixelLayout> ImagePixelLayout; typedef sequence<ChannelPixelLayout> ImagePixelLayout;
partial interface ImageBitmap { partial interface ImageBitmap {
[Throws, Func="mozilla::dom::DOMPrefs::ImageBitmapExtensionsEnabled"] [Throws, Func="mozilla::dom::DOMPrefs::canvas_imagebitmap_extensions_enabled"]
ImageBitmapFormat findOptimalFormat (optional sequence<ImageBitmapFormat> aPossibleFormats); ImageBitmapFormat findOptimalFormat (optional sequence<ImageBitmapFormat> aPossibleFormats);
[Throws, Func="mozilla::dom::DOMPrefs::ImageBitmapExtensionsEnabled"] [Throws, Func="mozilla::dom::DOMPrefs::canvas_imagebitmap_extensions_enabled"]
long mappedDataLength (ImageBitmapFormat aFormat); long mappedDataLength (ImageBitmapFormat aFormat);
[Throws, Func="mozilla::dom::DOMPrefs::ImageBitmapExtensionsEnabled"] [Throws, Func="mozilla::dom::DOMPrefs::canvas_imagebitmap_extensions_enabled"]
Promise<ImagePixelLayout> mapDataInto (ImageBitmapFormat aFormat, BufferSource aBuffer, long aOffset); Promise<ImagePixelLayout> mapDataInto (ImageBitmapFormat aFormat, BufferSource aBuffer, long aOffset);
}; };

Просмотреть файл

@ -32,6 +32,7 @@
#include "mozilla/dom/WorkerNavigator.h" #include "mozilla/dom/WorkerNavigator.h"
#include "mozilla/dom/cache/CacheStorage.h" #include "mozilla/dom/cache/CacheStorage.h"
#include "mozilla/Services.h" #include "mozilla/Services.h"
#include "mozilla/StaticPrefs.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "nsIDocument.h" #include "nsIDocument.h"
@ -504,7 +505,7 @@ WorkerGlobalScope::CreateImageBitmap(JSContext* aCx,
const Sequence<ChannelPixelLayout>& aLayout, const Sequence<ChannelPixelLayout>& aLayout,
ErrorResult& aRv) ErrorResult& aRv)
{ {
if (!DOMPrefs::ImageBitmapExtensionsEnabled()) { if (!StaticPrefs::canvas_imagebitmap_extensions_enabled()) {
aRv.Throw(NS_ERROR_TYPE_ERR); aRv.Throw(NS_ERROR_TYPE_ERR);
return nullptr; return nullptr;
} }

Просмотреть файл

@ -202,6 +202,13 @@ VARCACHE_PREF(
uint32_t, 5000 uint32_t, 5000
) )
// Disable the ImageBitmap-extensions for now.
VARCACHE_PREF(
"canvas.imagebitmap_extensions.enabled",
canvas_imagebitmap_extensions_enabled,
RelaxedAtomicBool, false
)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Clear-Site-Data prefs // Clear-Site-Data prefs
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

Просмотреть файл

@ -968,9 +968,6 @@ pref("canvas.filters.enabled", true);
pref("canvas.path.enabled", true); pref("canvas.path.enabled", true);
pref("canvas.capturestream.enabled", true); pref("canvas.capturestream.enabled", true);
// Disable the ImageBitmap-extensions for now.
pref("canvas.imagebitmap_extensions.enabled", false);
// We want the ability to forcibly disable platform a11y, because // We want the ability to forcibly disable platform a11y, because
// some non-a11y-related components attempt to bring it up. See bug // 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 // 538530 for details about Windows; we have a pref here that allows it