diff --git a/devtools/server/actors/highlighters/utils/canvas.js b/devtools/server/actors/highlighters/utils/canvas.js index 5f4b1dcae36ae..5c96139def524 100644 --- a/devtools/server/actors/highlighters/utils/canvas.js +++ b/devtools/server/actors/highlighters/utils/canvas.js @@ -27,9 +27,8 @@ const { getComputedStyle } = require("./markup"); // // This canvas size value is the safest we can use because most GPUs can handle it. // It's also far from the maximum canvas memory allocation limit (4096x4096x4 is -// 67.108.864 bytes, where the limit is 500.000.000 bytes, see -// MaxAllocSizeDoNotUseDirectly in: -// https://searchfox.org/mozilla-central/source/modules/libpref/init/StaticPrefList.h). +// 67.108.864 bytes, where the limit is 500.000.000 bytes, see: +// http://searchfox.org/mozilla-central/source/gfx/thebes/gfxPrefs.h#401). // // Note: // Once bug 1232491 lands, we could try to refactor this code to use the values from diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index d6256568dba83..9490a951ac15d 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -270,6 +270,7 @@ #include "nsWindowSizes.h" #include "mozilla/dom/Location.h" #include "mozilla/dom/FontFaceSet.h" +#include "gfxPrefs.h" #include "nsISupportsPrimitives.h" #include "mozilla/ServoStyleSet.h" #include "mozilla/StyleSheet.h" @@ -7146,7 +7147,7 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) { // Special behaviour for desktop mode, provided we are not on an about: page nsPIDOMWindowOuter* win = GetWindow(); if (win && win->IsDesktopModeViewport() && !IsAboutPage()) { - CSSCoord viewportWidth = StaticPrefs::DesktopViewportWidth() / fullZoom; + CSSCoord viewportWidth = gfxPrefs::DesktopViewportWidth() / fullZoom; CSSToScreenScale scaleToFit(aDisplaySize.width / viewportWidth); float aspectRatio = (float)aDisplaySize.height / aDisplaySize.width; CSSSize viewportSize(viewportWidth, viewportWidth * aspectRatio); @@ -7240,7 +7241,7 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) { nsViewportInfo::ZoomFlag effectiveZoomFlag = mAllowZoom ? nsViewportInfo::ZoomFlag::AllowZoom : nsViewportInfo::ZoomFlag::DisallowZoom; - if (StaticPrefs::ForceUserScalable()) { + if (gfxPrefs::ForceUserScalable()) { // If the pref to force user-scalable is enabled, we ignore the values // from the meta-viewport tag for these properties and just assume they // allow the page to be scalable. Note in particular that this code is @@ -7353,7 +7354,7 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) { // Divide by fullZoom to stretch CSS pixel size of viewport in order // to keep device pixel size unchanged after full zoom applied. // See bug 974242. - width = StaticPrefs::DesktopViewportWidth() / fullZoom; + width = gfxPrefs::DesktopViewportWidth() / fullZoom; } else { // Some viewport information was provided; follow the spec. width = displaySize.width; diff --git a/dom/base/TextInputProcessor.cpp b/dom/base/TextInputProcessor.cpp index 669b1d3bc4ef9..ca171205e3d49 100644 --- a/dom/base/TextInputProcessor.cpp +++ b/dom/base/TextInputProcessor.cpp @@ -4,6 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "gfxPrefs.h" #include "mozilla/dom/Event.h" #include "mozilla/EventForwards.h" #include "mozilla/Maybe.h" @@ -389,7 +390,7 @@ nsresult TextInputProcessor::BeginInputTransactionInternal( nsresult rv = NS_OK; if (aForTests) { - bool isAPZAware = StaticPrefs::TestEventsAsyncEnabled(); + bool isAPZAware = gfxPrefs::TestEventsAsyncEnabled(); rv = dispatcher->BeginTestInputTransaction(this, isAPZAware); } else { rv = dispatcher->BeginInputTransaction(this); diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index e8f4bc082ace7..418802a85c267 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -30,7 +30,7 @@ // is included in mozAutoDocUpdate.h. #include "nsNPAPIPluginInstance.h" #include "gfxDrawable.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "ImageOps.h" #include "mozAutoDocUpdate.h" #include "mozilla/AntiTrackingCommon.h" @@ -7909,7 +7909,7 @@ nsresult nsContentUtils::SendMouseEvent( } return presShell->HandleEvent(view->GetFrame(), &event, false, &status); } - if (StaticPrefs::TestEventsAsyncEnabled()) { + if (gfxPrefs::TestEventsAsyncEnabled()) { status = widget->DispatchInputEvent(&event); } else { nsresult rv = widget->DispatchEvent(&event, status); diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 35b70a64b652a..017336c39dbbd 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -46,7 +46,6 @@ #include "mozilla/MiscEvents.h" #include "mozilla/MouseEvents.h" #include "mozilla/PresShell.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/TextEvents.h" #include "mozilla/TextEventDispatcher.h" #include "mozilla/TouchEvents.h" @@ -70,6 +69,7 @@ #endif #include "Layers.h" +#include "gfxPrefs.h" #include "mozilla/dom/AudioDeviceInfo.h" #include "mozilla/dom/Element.h" @@ -470,7 +470,7 @@ nsDOMWindowUtils::SetDisplayPortForElement(float aXPx, float aYPx, new DisplayPortPropertyData(displayport, aPriority), nsINode::DeleteProperty); - if (StaticPrefs::LayoutUseContainersForRootFrames()) { + if (gfxPrefs::LayoutUseContainersForRootFrames()) { nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame(); if (rootScrollFrame && aElement == rootScrollFrame->GetContent() && nsLayoutUtils::UsesAsyncScrolling(rootScrollFrame)) { diff --git a/dom/base/nsImageLoadingContent.cpp b/dom/base/nsImageLoadingContent.cpp index d249d667e7d28..3e343b73b53ad 100644 --- a/dom/base/nsImageLoadingContent.cpp +++ b/dom/base/nsImageLoadingContent.cpp @@ -39,6 +39,8 @@ #include "nsIContentPolicy.h" #include "SVGObserverUtils.h" +#include "gfxPrefs.h" + #include "mozAutoDocUpdate.h" #include "mozilla/AsyncEventDispatcher.h" #include "mozilla/AutoRestore.h" @@ -527,7 +529,7 @@ void nsImageLoadingContent::MaybeForceSyncDecoding( // attribute on a timer. TimeStamp now = TimeStamp::Now(); TimeDuration threshold = TimeDuration::FromMilliseconds( - StaticPrefs::ImageInferSrcAnimationThresholdMS()); + gfxPrefs::ImageInferSrcAnimationThresholdMS()); // If the length of time between request changes is less than the threshold, // then force sync decoding to eliminate flicker from the animation. diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index cd8ec8c41718b..6051e9d440d73 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -51,6 +51,7 @@ #include "gfxPlatform.h" #include "gfxFont.h" #include "gfxBlur.h" +#include "gfxPrefs.h" #include "gfxTextRun.h" #include "gfxUtils.h" @@ -92,7 +93,6 @@ #include "mozilla/MathAlgorithms.h" #include "mozilla/Preferences.h" #include "mozilla/ServoBindings.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Telemetry.h" #include "mozilla/TimeStamp.h" #include "mozilla/UniquePtr.h" @@ -1231,8 +1231,8 @@ bool CanvasRenderingContext2D::EnsureTarget(const gfx::Rect* aCoveredRect, } // Check that the dimensions are sane - if (mWidth > StaticPrefs::MaxCanvasSize() || - mHeight > StaticPrefs::MaxCanvasSize() || mWidth < 0 || mHeight < 0) { + if (mWidth > gfxPrefs::MaxCanvasSize() || + mHeight > gfxPrefs::MaxCanvasSize() || mWidth < 0 || mHeight < 0) { SetErrorState(); return false; } diff --git a/dom/canvas/WebGL2Context.cpp b/dom/canvas/WebGL2Context.cpp index 5aabad31f0218..18dbf59eeb198 100644 --- a/dom/canvas/WebGL2Context.cpp +++ b/dom/canvas/WebGL2Context.cpp @@ -5,7 +5,7 @@ #include "WebGL2Context.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "GLContext.h" #include "mozilla/dom/WebGL2RenderingContextBinding.h" #include "mozilla/ArrayUtils.h" @@ -31,7 +31,7 @@ UniquePtr WebGL2Context::CreateFormatUsage( } /*static*/ -bool WebGL2Context::IsSupported() { return StaticPrefs::WebGL2Enabled(); } +bool WebGL2Context::IsSupported() { return gfxPrefs::WebGL2Enabled(); } /*static*/ WebGL2Context* WebGL2Context::Create() { return new WebGL2Context(); } diff --git a/dom/canvas/WebGL2ContextQueries.cpp b/dom/canvas/WebGL2ContextQueries.cpp index d1555a53c3f95..f82cb94d86d83 100644 --- a/dom/canvas/WebGL2ContextQueries.cpp +++ b/dom/canvas/WebGL2ContextQueries.cpp @@ -6,6 +6,7 @@ #include "WebGL2Context.h" #include "GLContext.h" #include "WebGLQuery.h" +#include "gfxPrefs.h" #include "nsThreadUtils.h" namespace mozilla { diff --git a/dom/canvas/WebGL2ContextSync.cpp b/dom/canvas/WebGL2ContextSync.cpp index 8c265166c5660..2db90da0afc12 100644 --- a/dom/canvas/WebGL2ContextSync.cpp +++ b/dom/canvas/WebGL2ContextSync.cpp @@ -67,7 +67,7 @@ GLenum WebGL2Context::ClientWaitSync(const WebGLSync& sync, GLbitfield flags, } const bool canBeAvailable = - (sync.mCanBeAvailable || StaticPrefs::WebGLImmediateQueries()); + (sync.mCanBeAvailable || gfxPrefs::WebGLImmediateQueries()); if (!canBeAvailable) { if (timeout) { GenerateWarning( @@ -118,7 +118,7 @@ void WebGL2Context::GetSyncParameter(JSContext*, const WebGLSync& sync, //// const bool canBeAvailable = - (sync.mCanBeAvailable || StaticPrefs::WebGLImmediateQueries()); + (sync.mCanBeAvailable || gfxPrefs::WebGLImmediateQueries()); if (!canBeAvailable && pname == LOCAL_GL_SYNC_STATUS) { retval.set(JS::Int32Value(LOCAL_GL_UNSIGNALED)); return; diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index 434b65df7afcf..49b05880287c1 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -13,6 +13,7 @@ #include "gfxContext.h" #include "gfxCrashReporterUtils.h" #include "gfxPattern.h" +#include "gfxPrefs.h" #include "gfxUtils.h" #include "MozFramebuffer.h" #include "GLBlitHelper.h" @@ -34,7 +35,6 @@ #include "mozilla/ProcessPriorityManager.h" #include "mozilla/ScopeExit.h" #include "mozilla/Services.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Telemetry.h" #include "nsContentUtils.h" #include "nsDisplayList.h" @@ -97,7 +97,7 @@ using namespace mozilla::layers; WebGLContextOptions::WebGLContextOptions() { // Set default alpha state based on preference. - if (StaticPrefs::WebGLDefaultNoAlpha()) alpha = false; + if (gfxPrefs::WebGLDefaultNoAlpha()) alpha = false; } bool WebGLContextOptions::operator==(const WebGLContextOptions& r) const { @@ -116,18 +116,18 @@ bool WebGLContextOptions::operator==(const WebGLContextOptions& r) const { WebGLContext::WebGLContext() : gl(mGL_OnlyClearInDestroyResourcesAndContext) // const reference , - mMaxPerfWarnings(StaticPrefs::WebGLMaxPerfWarnings()), + mMaxPerfWarnings(gfxPrefs::WebGLMaxPerfWarnings()), mNumPerfWarnings(0), mMaxAcceptableFBStatusInvals( - StaticPrefs::WebGLMaxAcceptableFBStatusInvals()), + gfxPrefs::WebGLMaxAcceptableFBStatusInvals()), mDataAllocGLCallCount(0), mEmptyTFO(0), mContextLossHandler(this), mNeedsFakeNoAlpha(false), mNeedsFakeNoDepth(false), mNeedsFakeNoStencil(false), - mAllowFBInvalidation(StaticPrefs::WebGLFBInvalidation()), - mMsaaSamples((uint8_t)StaticPrefs::WebGLMsaaSamples()) { + mAllowFBInvalidation(gfxPrefs::WebGLFBInvalidation()), + mMsaaSamples((uint8_t)gfxPrefs::WebGLMsaaSamples()) { mGeneration = 0; mInvalidated = false; mCapturedFrameInvalidated = false; @@ -163,7 +163,7 @@ WebGLContext::WebGLContext() mAlreadyWarnedAboutFakeVertexAttrib0 = false; mAlreadyWarnedAboutViewportLargerThanDest = false; - mMaxWarnings = StaticPrefs::WebGLMaxWarningsPerContext(); + mMaxWarnings = gfxPrefs::WebGLMaxWarningsPerContext(); if (mMaxWarnings < -1) { GenerateWarning( "webgl.max-warnings-per-context size is too large (seems like a " @@ -359,11 +359,11 @@ WebGLContext::SetContextOptions(JSContext* cx, JS::Handle options, } // Don't do antialiasing if we've disabled MSAA. - if (!StaticPrefs::MSAALevel()) { + if (!gfxPrefs::MSAALevel()) { newOpts.antialias = false; } - if (!StaticPrefs::WebGLForceMSAA()) { + if (!gfxPrefs::WebGLForceMSAA()) { const nsCOMPtr gfxInfo = services::GetGfxInfo(); nsCString blocklistId; @@ -475,7 +475,7 @@ bool WebGLContext::CreateAndInitGL( if (IsWebGL2()) { flags |= gl::CreateContextFlags::PREFER_ES3; - } else if (!StaticPrefs::WebGL1AllowCoreProfile()) { + } else if (!gfxPrefs::WebGL1AllowCoreProfile()) { flags |= gl::CreateContextFlags::REQUIRE_COMPAT_PROFILE; } @@ -496,7 +496,7 @@ bool WebGLContext::CreateAndInitGL( // - Same origin with root page (try to stem bleeding from WebGL // ads/trackers) default: - if (!StaticPrefs::WebGLDefaultLowPower()) { + if (!gfxPrefs::WebGLDefaultLowPower()) { flags |= gl::CreateContextFlags::HIGH_POWER; } break; @@ -541,11 +541,11 @@ bool WebGLContext::CreateAndInitGL( tryNativeGL = false; tryANGLE = true; - if (StaticPrefs::WebGLDisableWGL()) { + if (gfxPrefs::WebGLDisableWGL()) { tryNativeGL = false; } - if (StaticPrefs::WebGLDisableANGLE() || PR_GetEnv("MOZ_WEBGL_FORCE_OPENGL") || + if (gfxPrefs::WebGLDisableANGLE() || PR_GetEnv("MOZ_WEBGL_FORCE_OPENGL") || useEGL) { tryNativeGL = true; tryANGLE = false; @@ -801,7 +801,7 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight) { // pick up the old generation. ++mGeneration; - bool disabled = StaticPrefs::WebGLDisabled(); + bool disabled = gfxPrefs::WebGLDisabled(); // TODO: When we have software webgl support we should use that instead. disabled |= gfxPlatform::InSafeMode(); @@ -817,7 +817,7 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight) { return NS_ERROR_FAILURE; } - if (StaticPrefs::WebGLDisableFailIfMajorPerformanceCaveat()) { + if (gfxPrefs::WebGLDisableFailIfMajorPerformanceCaveat()) { mOptions.failIfMajorPerformanceCaveat = false; } @@ -834,7 +834,7 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight) { } // Alright, now let's start trying. - bool forceEnabled = StaticPrefs::WebGLForceEnabled(); + bool forceEnabled = gfxPrefs::WebGLForceEnabled(); ScopedGfxFeatureReporter reporter("WebGL", forceEnabled); MOZ_ASSERT(!gl); @@ -966,9 +966,8 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight) { } void WebGLContext::LoseOldestWebGLContextIfLimitExceeded() { - const auto maxWebGLContexts = StaticPrefs::WebGLMaxContexts(); - auto maxWebGLContextsPerPrincipal = - StaticPrefs::WebGLMaxContextsPerPrincipal(); + const auto maxWebGLContexts = gfxPrefs::WebGLMaxContexts(); + auto maxWebGLContextsPerPrincipal = gfxPrefs::WebGLMaxContextsPerPrincipal(); // maxWebGLContextsPerPrincipal must be less than maxWebGLContexts MOZ_ASSERT(maxWebGLContextsPerPrincipal <= maxWebGLContexts); @@ -1330,7 +1329,7 @@ ScopedPrepForResourceClear::~ScopedPrepForResourceClear() { // - void WebGLContext::OnEndOfFrame() const { - if (StaticPrefs::WebGLSpewFrameAllocs()) { + if (gfxPrefs::WebGLSpewFrameAllocs()) { GeneratePerfWarning("[webgl.perf.spew-frame-allocs] %" PRIu64 " data allocations this frame.", mDataAllocGLCallCount); diff --git a/dom/canvas/WebGLContextExtensions.cpp b/dom/canvas/WebGLContextExtensions.cpp index abf304f827133..679bf1707f6d1 100644 --- a/dom/canvas/WebGLContextExtensions.cpp +++ b/dom/canvas/WebGLContextExtensions.cpp @@ -6,6 +6,7 @@ #include "WebGLContext.h" #include "WebGLContextUtils.h" #include "WebGLExtensions.h" +#include "gfxPrefs.h" #include "GLContext.h" #include "nsString.h" @@ -81,7 +82,7 @@ bool WebGLContext::IsExtensionSupported(dom::CallerType callerType, allowPrivilegedExts = true; } - if (StaticPrefs::WebGLPrivilegedExtensionsEnabled()) { + if (gfxPrefs::WebGLPrivilegedExtensionsEnabled()) { allowPrivilegedExts = true; } diff --git a/dom/canvas/WebGLContextValidate.cpp b/dom/canvas/WebGLContextValidate.cpp index 7bded60ec7cb9..4f568dd6029e3 100644 --- a/dom/canvas/WebGLContextValidate.cpp +++ b/dom/canvas/WebGLContextValidate.cpp @@ -8,11 +8,11 @@ #include #include "GLSLANG/ShaderLang.h" #include "CanvasUtils.h" +#include "gfxPrefs.h" #include "GLContext.h" #include "jsfriendapi.h" #include "mozilla/CheckedInt.h" #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include "nsIObserverService.h" #include "nsPrintfCString.h" #include "WebGLActiveInfo.h" @@ -288,10 +288,9 @@ bool WebGLContext::InitAndValidateGL(FailureReason* const out_failReason) { return false; } - mDisableExtensions = StaticPrefs::WebGLDisableExtensions(); - mLoseContextOnMemoryPressure = - StaticPrefs::WebGLLoseContextOnMemoryPressure(); - mCanLoseContextInForeground = StaticPrefs::WebGLCanLoseContextInForeground(); + mDisableExtensions = gfxPrefs::WebGLDisableExtensions(); + mLoseContextOnMemoryPressure = gfxPrefs::WebGLLoseContextOnMemoryPressure(); + mCanLoseContextInForeground = gfxPrefs::WebGLCanLoseContextInForeground(); // These are the default values, see 6.2 State tables in the // OpenGL ES 2.0.25 spec. @@ -488,7 +487,7 @@ bool WebGLContext::InitAndValidateGL(FailureReason* const out_failReason) { // Last resort, just check the global preference nsContentUtils::ShouldResistFingerprinting()); - if (StaticPrefs::WebGLMinCapabilityMode()) { + if (gfxPrefs::WebGLMinCapabilityMode()) { bool ok = true; ok &= RestrictCap(&mGLMaxVertexTextureImageUnits, @@ -665,7 +664,7 @@ bool WebGLContext::InitAndValidateGL(FailureReason* const out_failReason) { mNeedsIndexValidation = !gl->IsSupported(gl::GLFeature::robust_buffer_access_behavior); - switch (StaticPrefs::WebGLForceIndexValidation()) { + switch (gfxPrefs::WebGLForceIndexValidation()) { case -1: mNeedsIndexValidation = false; break; @@ -673,7 +672,7 @@ bool WebGLContext::InitAndValidateGL(FailureReason* const out_failReason) { mNeedsIndexValidation = true; break; default: - MOZ_ASSERT(StaticPrefs::WebGLForceIndexValidation() == 0); + MOZ_ASSERT(gfxPrefs::WebGLForceIndexValidation() == 0); break; } diff --git a/dom/canvas/WebGLExtensionDisjointTimerQuery.cpp b/dom/canvas/WebGLExtensionDisjointTimerQuery.cpp index b069b8de9b30a..d5d70c0683f66 100644 --- a/dom/canvas/WebGLExtensionDisjointTimerQuery.cpp +++ b/dom/canvas/WebGLExtensionDisjointTimerQuery.cpp @@ -6,6 +6,7 @@ #include "WebGLExtensions.h" +#include "gfxPrefs.h" #include "GLContext.h" #include "mozilla/dom/ToJSValue.h" #include "mozilla/dom/WebGLRenderingContextBinding.h" diff --git a/dom/canvas/WebGLExtensions.cpp b/dom/canvas/WebGLExtensions.cpp index f914c3c5ee4ed..805971fbf9e4a 100644 --- a/dom/canvas/WebGLExtensions.cpp +++ b/dom/canvas/WebGLExtensions.cpp @@ -5,9 +5,9 @@ #include "WebGLExtensions.h" +#include "gfxPrefs.h" #include "GLContext.h" #include "mozilla/dom/WebGLRenderingContextBinding.h" -#include "mozilla/StaticPrefs.h" #include "WebGLContext.h" namespace mozilla { @@ -62,7 +62,7 @@ WebGLExtensionFBORenderMipmap::~WebGLExtensionFBORenderMipmap() = default; bool WebGLExtensionFBORenderMipmap::IsSupported( const WebGLContext* const webgl) { if (webgl->IsWebGL2()) return false; - if (!StaticPrefs::WebGLDraftExtensionsEnabled()) return false; + if (!gfxPrefs::WebGLDraftExtensionsEnabled()) return false; const auto& gl = webgl->gl; if (!gl->IsGLES()) return true; @@ -83,7 +83,7 @@ WebGLExtensionMultiview::~WebGLExtensionMultiview() = default; bool WebGLExtensionMultiview::IsSupported(const WebGLContext* const webgl) { if (!webgl->IsWebGL2()) return false; - if (!StaticPrefs::WebGLDraftExtensionsEnabled()) return false; + if (!gfxPrefs::WebGLDraftExtensionsEnabled()) return false; const auto& gl = webgl->gl; return gl->IsSupported(gl::GLFeature::multiview); diff --git a/dom/canvas/WebGLFormats.cpp b/dom/canvas/WebGLFormats.cpp index f2dd2228cd9e3..2fb500e7cf0ad 100644 --- a/dom/canvas/WebGLFormats.cpp +++ b/dom/canvas/WebGLFormats.cpp @@ -5,6 +5,7 @@ #include "WebGLFormats.h" +#include "gfxPrefs.h" #include "GLContext.h" #include "GLDefs.h" #include "mozilla/gfx/Logging.h" diff --git a/dom/canvas/WebGLQuery.cpp b/dom/canvas/WebGLQuery.cpp index 17e5e6d8da0c5..6c89066e9a127 100644 --- a/dom/canvas/WebGLQuery.cpp +++ b/dom/canvas/WebGLQuery.cpp @@ -5,6 +5,7 @@ #include "WebGLQuery.h" +#include "gfxPrefs.h" #include "GLContext.h" #include "mozilla/dom/WebGL2RenderingContextBinding.h" #include "nsContentUtils.h" @@ -116,7 +117,7 @@ void WebGLQuery::GetQueryParameter(GLenum pname, // We must usually wait for an event loop before the query can be available. const bool canBeAvailable = - (mCanBeAvailable || StaticPrefs::WebGLImmediateQueries()); + (mCanBeAvailable || gfxPrefs::WebGLImmediateQueries()); if (!canBeAvailable) { if (pname == LOCAL_GL_QUERY_RESULT_AVAILABLE) { retval.set(JS::BooleanValue(false)); diff --git a/dom/canvas/WebGLShaderValidator.cpp b/dom/canvas/WebGLShaderValidator.cpp index 62f2f7e03beb7..abe99b56fac53 100644 --- a/dom/canvas/WebGLShaderValidator.cpp +++ b/dom/canvas/WebGLShaderValidator.cpp @@ -5,10 +5,10 @@ #include "WebGLShaderValidator.h" +#include "gfxPrefs.h" #include "GLContext.h" #include "mozilla/gfx/Logging.h" #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include "MurmurHash3.h" #include "nsPrintfCString.h" #include @@ -67,7 +67,7 @@ static ShCompileOptions ChooseValidatorCompileOptions( } } - if (StaticPrefs::WebGLAllANGLEOptions()) { + if (gfxPrefs::WebGLAllANGLEOptions()) { options = -1; options ^= SH_INTERMEDIATE_TREE; diff --git a/dom/canvas/WebGLTextureUpload.cpp b/dom/canvas/WebGLTextureUpload.cpp index 512bcd5352d95..40176edbaba19 100644 --- a/dom/canvas/WebGLTextureUpload.cpp +++ b/dom/canvas/WebGLTextureUpload.cpp @@ -8,6 +8,7 @@ #include #include "CanvasUtils.h" +#include "gfxPrefs.h" #include "GLBlitHelper.h" #include "GLContext.h" #include "mozilla/Casting.h" @@ -18,7 +19,6 @@ #include "mozilla/dom/ImageData.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/Scoped.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Unused.h" #include "ScopedGLHelpers.h" #include "TexUnpackBlob.h" @@ -328,7 +328,7 @@ UniquePtr WebGLContext::FromDomElem( uint32_t elemWidth = 0; uint32_t elemHeight = 0; layers::Image* layersImage = nullptr; - if (!StaticPrefs::WebGLDisableDOMBlitUploads() && sfer.mLayersImage) { + if (!gfxPrefs::WebGLDisableDOMBlitUploads() && sfer.mLayersImage) { layersImage = sfer.mLayersImage; elemWidth = layersImage->GetSize().width; elemHeight = layersImage->GetSize().height; diff --git a/dom/html/HTMLCanvasElement.cpp b/dom/html/HTMLCanvasElement.cpp index 46b1a8e28a200..104c2e3141842 100644 --- a/dom/html/HTMLCanvasElement.cpp +++ b/dom/html/HTMLCanvasElement.cpp @@ -6,6 +6,7 @@ #include "mozilla/dom/HTMLCanvasElement.h" +#include "gfxPrefs.h" #include "ImageEncoder.h" #include "jsapi.h" #include "jsfriendapi.h" diff --git a/dom/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp index 255ba80b61afd..fad4e484716c6 100644 --- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -8,6 +8,7 @@ #include "BrowserChild.h" +#include "gfxPrefs.h" #ifdef ACCESSIBILITY # include "mozilla/a11y/DocAccessibleChild.h" #endif @@ -1810,7 +1811,7 @@ mozilla::ipc::IPCResult BrowserChild::RecvRealTouchEvent( if (localEvent.mMessage == eTouchStart && AsyncPanZoomEnabled()) { nsCOMPtr document = GetTopLevelDocument(); - if (StaticPrefs::TouchActionEnabled()) { + if (gfxPrefs::TouchActionEnabled()) { APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification( mPuppetWidget, document, localEvent, aInputBlockId, mSetAllowedTouchBehaviorCallback); diff --git a/dom/ipc/BrowserParent.cpp b/dom/ipc/BrowserParent.cpp index 48f110bd309bb..e2cd3ba8aff9b 100644 --- a/dom/ipc/BrowserParent.cpp +++ b/dom/ipc/BrowserParent.cpp @@ -95,6 +95,7 @@ #include "nsIAuthPromptCallback.h" #include "nsAuthInformationHolder.h" #include "nsICancelable.h" +#include "gfxPrefs.h" #include "gfxUtils.h" #include "nsILoginManagerPrompter.h" #include "nsPIWindowRoot.h" diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index b2b4e997b6b00..e4689246b269e 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -206,6 +206,7 @@ #include "mozilla/net/NeckoMessageUtils.h" #include "gfxPlatform.h" #include "gfxPlatformFontList.h" +#include "gfxPrefs.h" #include "prio.h" #include "private/pprio.h" #include "ContentProcessManager.h" @@ -2956,8 +2957,30 @@ ContentParent::Observe(nsISupports* aSubject, const char* aTopic, if (!strcmp(aTopic, "nsPref:changed")) { // A pref changed. If it's not on the blacklist, inform child processes. - if (!ShouldSyncPreference(aData)) { - return NS_OK; +#define BLACKLIST_ENTRY(s) \ + { s, (sizeof(s) / sizeof(char16_t)) - 1 } + struct BlacklistEntry { + const char16_t* mPrefBranch; + size_t mLen; + }; + // These prefs are not useful in child processes. + static const BlacklistEntry sContentPrefBranchBlacklist[] = { + BLACKLIST_ENTRY(u"app.update.lastUpdateTime."), + BLACKLIST_ENTRY(u"datareporting.policy."), + BLACKLIST_ENTRY(u"browser.safebrowsing.provider."), + BLACKLIST_ENTRY(u"browser.shell."), + BLACKLIST_ENTRY(u"browser.slowstartup."), + BLACKLIST_ENTRY(u"extensions.getAddons.cache."), + BLACKLIST_ENTRY(u"media.gmp-manager."), + BLACKLIST_ENTRY(u"media.gmp-gmpopenh264."), + BLACKLIST_ENTRY(u"privacy.sanitize."), + }; +#undef BLACKLIST_ENTRY + + for (const auto& entry : sContentPrefBranchBlacklist) { + if (NS_strncmp(entry.mPrefBranch, aData, entry.mLen) == 0) { + return NS_OK; + } } // We know prefs are ASCII here. @@ -3105,37 +3128,6 @@ ContentParent::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } -/* static */ -bool ContentParent::ShouldSyncPreference(const char16_t* aData) { -#define BLACKLIST_ENTRY(s) \ - { s, (sizeof(s) / sizeof(char16_t)) - 1 } - struct BlacklistEntry { - const char16_t* mPrefBranch; - size_t mLen; - }; - // These prefs are not useful in child processes. - static const BlacklistEntry sContentPrefBranchBlacklist[] = { - BLACKLIST_ENTRY(u"app.update.lastUpdateTime."), - BLACKLIST_ENTRY(u"datareporting.policy."), - BLACKLIST_ENTRY(u"browser.safebrowsing.provider."), - BLACKLIST_ENTRY(u"browser.shell."), - BLACKLIST_ENTRY(u"browser.slowStartup."), - BLACKLIST_ENTRY(u"browser.startup."), - BLACKLIST_ENTRY(u"extensions.getAddons.cache."), - BLACKLIST_ENTRY(u"media.gmp-manager."), - BLACKLIST_ENTRY(u"media.gmp-gmpopenh264."), - BLACKLIST_ENTRY(u"privacy.sanitize."), - }; -#undef BLACKLIST_ENTRY - - for (const auto& entry : sContentPrefBranchBlacklist) { - if (NS_strncmp(entry.mPrefBranch, aData, entry.mLen) == 0) { - return false; - } - } - return true; -} - void ContentParent::UpdateNetworkLinkType() { nsresult rv; nsCOMPtr nls = diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index e2e5a8de7d2a1..5afd06ddf2828 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -1216,8 +1216,6 @@ class ContentParent final : public PContentParent, void UpdateNetworkLinkType(); - static bool ShouldSyncPreference(const char16_t* aData); - private: // Released in ActorDestroy; deliberately not exposed to the CC. RefPtr mSelfRef; diff --git a/dom/media/AudioStream.cpp b/dom/media/AudioStream.cpp index 786d151800c30..2427897384138 100644 --- a/dom/media/AudioStream.cpp +++ b/dom/media/AudioStream.cpp @@ -18,6 +18,7 @@ #include "mozilla/Telemetry.h" #include "CubebUtils.h" #include "nsPrintfCString.h" +#include "gfxPrefs.h" #include "AudioConverter.h" #if defined(XP_WIN) # include "nsXULAppAPI.h" diff --git a/dom/media/Benchmark.cpp b/dom/media/Benchmark.cpp index b319b2d3ba10e..19f70b7585eca 100644 --- a/dom/media/Benchmark.cpp +++ b/dom/media/Benchmark.cpp @@ -11,6 +11,7 @@ #include "PDMFactory.h" #include "VideoUtils.h" #include "WebMDemuxer.h" +#include "gfxPrefs.h" #include "mozilla/AbstractThread.h" #include "mozilla/Preferences.h" #include "mozilla/SharedThreadPool.h" @@ -167,6 +168,7 @@ void Benchmark::Dispose() { void Benchmark::Init() { MOZ_ASSERT(NS_IsMainThread()); gfxVars::Initialize(); + gfxPrefs::GetSingleton(); } BenchmarkPlayback::BenchmarkPlayback(Benchmark* aGlobalState, diff --git a/dom/media/ipc/PRDD.ipdl b/dom/media/ipc/PRDD.ipdl index 0d008bbbd6e8c..c20a85fd138af 100644 --- a/dom/media/ipc/PRDD.ipdl +++ b/dom/media/ipc/PRDD.ipdl @@ -4,7 +4,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ include MemoryReportTypes; -include PrefsTypes; include protocol PProfiler; include protocol PRemoteDecoderManager; @@ -33,8 +32,6 @@ parent: bool minimizeMemoryUsage, FileDescriptor? DMDFile); - async PreferenceUpdate(Pref pref); - child: // args TBD, sent when init complete. Occurs once, after Init(). async InitComplete(); diff --git a/dom/media/ipc/RDDParent.cpp b/dom/media/ipc/RDDParent.cpp index 77c76801a2114..ec708d18fa171 100644 --- a/dom/media/ipc/RDDParent.cpp +++ b/dom/media/ipc/RDDParent.cpp @@ -175,11 +175,6 @@ mozilla::ipc::IPCResult RDDParent::RecvRequestMemoryReport( return IPC_OK(); } -mozilla::ipc::IPCResult RDDParent::RecvPreferenceUpdate(const Pref& aPref) { - Preferences::SetPreference(aPref); - return IPC_OK(); -} - void RDDParent::ActorDestroy(ActorDestroyReason aWhy) { if (AbnormalShutdown == aWhy) { NS_WARNING("Shutting down RDD process early due to a crash!"); diff --git a/dom/media/ipc/RDDParent.h b/dom/media/ipc/RDDParent.h index e3bb791fdb9d7..e8bf35537dbe4 100644 --- a/dom/media/ipc/RDDParent.h +++ b/dom/media/ipc/RDDParent.h @@ -35,7 +35,6 @@ class RDDParent final : public PRDDParent { const uint32_t& generation, const bool& anonymize, const bool& minimizeMemoryUsage, const Maybe& DMDFile); - mozilla::ipc::IPCResult RecvPreferenceUpdate(const Pref& pref); void ActorDestroy(ActorDestroyReason aWhy) override; diff --git a/dom/media/ipc/RDDProcessHost.cpp b/dom/media/ipc/RDDProcessHost.cpp index 8cce3e1d1a258..089cea09027c0 100644 --- a/dom/media/ipc/RDDProcessHost.cpp +++ b/dom/media/ipc/RDDProcessHost.cpp @@ -67,7 +67,6 @@ bool RDDProcessHost::Launch(StringVector aExtraOpts) { if (!GeckoChildProcessHost::AsyncLaunch(aExtraOpts)) { mLaunchPhase = LaunchPhase::Complete; - mPrefSerializer = nullptr; return false; } return true; diff --git a/dom/media/ipc/RDDProcessManager.cpp b/dom/media/ipc/RDDProcessManager.cpp index 290b66598cbbe..0b970baf5aaff 100644 --- a/dom/media/ipc/RDDProcessManager.cpp +++ b/dom/media/ipc/RDDProcessManager.cpp @@ -8,9 +8,8 @@ #include "mozilla/MemoryReportingProcess.h" #include "mozilla/RemoteDecoderManagerChild.h" #include "mozilla/RemoteDecoderManagerParent.h" -#include "mozilla/Preferences.h" #include "mozilla/StaticPrefs.h" -#include "mozilla/dom/ContentParent.h" + #include "nsAppRunner.h" #include "nsContentUtils.h" #include "RDDChild.h" @@ -41,7 +40,6 @@ RDDProcessManager::RDDProcessManager() mObserver = new Observer(this); nsContentUtils::RegisterShutdownObserver(mObserver); - Preferences::AddStrongObserver(mObserver, ""); } RDDProcessManager::~RDDProcessManager() { @@ -64,8 +62,6 @@ RDDProcessManager::Observer::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) { if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) { mManager->OnXPCOMShutdown(); - } else if (!strcmp(aTopic, "nsPref:changed")) { - mManager->OnPreferenceChange(aData); } return NS_OK; } @@ -73,32 +69,12 @@ RDDProcessManager::Observer::Observe(nsISupports* aSubject, const char* aTopic, void RDDProcessManager::OnXPCOMShutdown() { if (mObserver) { nsContentUtils::UnregisterShutdownObserver(mObserver); - Preferences::RemoveObserver(mObserver, ""); mObserver = nullptr; } CleanShutdown(); } -void RDDProcessManager::OnPreferenceChange(const char16_t* aData) { - // A pref changed. If it's not on the blacklist, inform child processes. - if (!dom::ContentParent::ShouldSyncPreference(aData)) { - return; - } - - // We know prefs are ASCII here. - NS_LossyConvertUTF16toASCII strData(aData); - - mozilla::dom::Pref pref(strData, /* isLocked */ false, Nothing(), Nothing()); - Preferences::GetPreference(&pref); - if (!!mRDDChild) { - MOZ_ASSERT(mQueuedPrefs.IsEmpty()); - mRDDChild->SendPreferenceUpdate(pref); - } else { - mQueuedPrefs.AppendElement(pref); - } -} - void RDDProcessManager::LaunchRDDProcess() { if (mProcess) { return; @@ -153,13 +129,6 @@ void RDDProcessManager::OnProcessLaunchComplete(RDDProcessHost* aHost) { mRDDChild = mProcess->GetActor(); mProcessToken = mProcess->GetProcessToken(); - // Flush any pref updates that happened during launch and weren't - // included in the blobs set up in LaunchRDDProcess. - for (const mozilla::dom::Pref& pref : mQueuedPrefs) { - Unused << NS_WARN_IF(!mRDDChild->SendPreferenceUpdate(pref)); - } - mQueuedPrefs.Clear(); - CrashReporter::AnnotateCrashReport( CrashReporter::Annotation::RDDProcessStatus, NS_LITERAL_CSTRING("Running")); diff --git a/dom/media/ipc/RDDProcessManager.h b/dom/media/ipc/RDDProcessManager.h index bccb285c015e2..684e754f65009 100644 --- a/dom/media/ipc/RDDProcessManager.h +++ b/dom/media/ipc/RDDProcessManager.h @@ -64,7 +64,6 @@ class RDDProcessManager final : public RDDProcessHost::Listener { private: // Called from our xpcom-shutdown observer. void OnXPCOMShutdown(); - void OnPreferenceChange(const char16_t* aData); RDDProcessManager(); @@ -96,10 +95,6 @@ class RDDProcessManager final : public RDDProcessHost::Listener { RDDProcessHost* mProcess; uint64_t mProcessToken; RDDChild* mRDDChild; - // Collects any pref changes that occur during process launch (after - // the initial map is passed in command-line arguments) to be sent - // when the process can receive IPC messages. - nsTArray mQueuedPrefs; }; } // namespace mozilla diff --git a/dom/media/platforms/PDMFactory.cpp b/dom/media/platforms/PDMFactory.cpp index fdf6196428f5b..a3b07b1ca1853 100644 --- a/dom/media/platforms/PDMFactory.cpp +++ b/dom/media/platforms/PDMFactory.cpp @@ -15,7 +15,8 @@ #include "MediaChangeMonitor.h" #include "MediaInfo.h" #include "VPXDecoder.h" -#include "nsIXULRuntime.h" // for BrowserTabsRemoteAutostart +#include "gfxPrefs.h" +#include "nsIXULRuntime.h" // for BrowserTabsRemoteAutostart #include "mozilla/CDMProxy.h" #include "mozilla/ClearOnShutdown.h" #include "mozilla/GpuDecoderModule.h" @@ -173,6 +174,7 @@ void PDMFactory::EnsureInit() { if (!sInstance) { // Ensure that all system variables are initialized. gfx::gfxVars::Initialize(); + gfxPrefs::GetSingleton(); // On the main thread and holding the lock -> Create instance. sInstance = new PDMFactoryImpl(); ClearOnShutdown(&sInstance); diff --git a/dom/media/platforms/wmf/DXVA2Manager.cpp b/dom/media/platforms/wmf/DXVA2Manager.cpp index e52681bb732aa..80a00371bd9f0 100644 --- a/dom/media/platforms/wmf/DXVA2Manager.cpp +++ b/dom/media/platforms/wmf/DXVA2Manager.cpp @@ -15,9 +15,9 @@ #include "VideoUtils.h" #include "WMFUtils.h" #include "gfxCrashReporterUtils.h" +#include "gfxPrefs.h" #include "gfxWindowsPlatform.h" #include "mfapi.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Telemetry.h" #include "mozilla/gfx/DeviceManagerDx.h" #include "mozilla/layers/D3D11ShareHandleImage.h" @@ -416,7 +416,7 @@ D3D9DXVA2Manager::Init(layers::KnowsCompositor* aKnowsCompositor, } if ((adapter.VendorId == 0x1022 || adapter.VendorId == 0x1002) && - !StaticPrefs::PDMWMFSkipBlacklist()) { + !gfxPrefs::PDMWMFSkipBlacklist()) { for (const auto& model : sAMDPreUVD4) { if (adapter.DeviceId == model) { mIsAMDPreUVD4 = true; @@ -506,7 +506,7 @@ DXVA2Manager* DXVA2Manager::CreateD3D9DXVA( // DXVA processing takes up a lot of GPU resources, so limit the number of // videos we use DXVA with at any one time. - uint32_t dxvaLimit = StaticPrefs::PDMWMFMaxDXVAVideos(); + uint32_t dxvaLimit = gfxPrefs::PDMWMFMaxDXVAVideos(); if (sDXVAVideosCount == dxvaLimit) { aFailureReason.AssignLiteral("Too many DXVA videos playing"); @@ -679,8 +679,7 @@ D3D11DXVA2Manager::Init(layers::KnowsCompositor* aKnowsCompositor, layers::ImageBridgeChild::GetSingleton().get(), mDevice, gfx::SurfaceFormat::NV12); - if (ImageBridgeChild::GetSingleton() && - StaticPrefs::PDMWMFUseSyncTexture() && + if (ImageBridgeChild::GetSingleton() && gfxPrefs::PDMWMFUseSyncTexture() && mDevice != DeviceManagerDx::Get()->GetCompositorDevice()) { // We use a syncobject to avoid the cost of the mutex lock when // compositing, and because it allows color conversion ocurring directly @@ -695,7 +694,7 @@ D3D11DXVA2Manager::Init(layers::KnowsCompositor* aKnowsCompositor, } else { mTextureClientAllocator = new D3D11RecycleAllocator( aKnowsCompositor, mDevice, gfx::SurfaceFormat::NV12); - if (StaticPrefs::PDMWMFUseSyncTexture()) { + if (gfxPrefs::PDMWMFUseSyncTexture()) { // We use a syncobject to avoid the cost of the mutex lock when // compositing, and because it allows color conversion ocurring directly // from this texture DXVA does not seem to accept IDXGIKeyedMutex textures @@ -849,7 +848,7 @@ D3D11DXVA2Manager::InitInternal(layers::KnowsCompositor* aKnowsCompositor, } if ((adapterDesc.VendorId == 0x1022 || adapterDesc.VendorId == 0x1002) && - !StaticPrefs::PDMWMFSkipBlacklist()) { + !gfxPrefs::PDMWMFSkipBlacklist()) { for (const auto& model : sAMDPreUVD4) { if (adapterDesc.DeviceId == model) { mIsAMDPreUVD4 = true; @@ -1219,7 +1218,7 @@ DXVA2Manager* DXVA2Manager::CreateD3D11DXVA( ID3D11Device* aDevice) { // DXVA processing takes up a lot of GPU resources, so limit the number of // videos we use DXVA with at any one time. - uint32_t dxvaLimit = StaticPrefs::PDMWMFMaxDXVAVideos(); + uint32_t dxvaLimit = gfxPrefs::PDMWMFMaxDXVAVideos(); if (sDXVAVideosCount == dxvaLimit) { aFailureReason.AssignLiteral("Too many DXVA videos playing"); @@ -1251,7 +1250,7 @@ bool DXVA2Manager::IsUnsupportedResolution(const uint32_t& aWidth, // AMD cards with UVD3 or earlier perform poorly trying to decode 1080p60 in // hardware, so use software instead. Pick 45 as an arbitrary upper bound for // the framerate we can handle. - return !StaticPrefs::PDMWMFAMDHighResEnabled() && mIsAMDPreUVD4 && + return !gfxPrefs::PDMWMFAMDHighResEnabled() && mIsAMDPreUVD4 && (aWidth >= 1920 || aHeight >= 1088) && aFramerate > 45; } diff --git a/dom/media/platforms/wmf/WMFDecoderModule.cpp b/dom/media/platforms/wmf/WMFDecoderModule.cpp index eb8cd536d6412..5620cc4983a7d 100644 --- a/dom/media/platforms/wmf/WMFDecoderModule.cpp +++ b/dom/media/platforms/wmf/WMFDecoderModule.cpp @@ -17,6 +17,7 @@ #include "WMFAudioMFTManager.h" #include "WMFMediaDataDecoder.h" #include "WMFVideoMFTManager.h" +#include "gfxPrefs.h" #include "mozilla/DebugOnly.h" #include "mozilla/Maybe.h" #include "mozilla/StaticMutex.h" @@ -89,7 +90,7 @@ void WMFDecoderModule::Init() { sDXVAEnabled = sDXVAEnabled && gfx::gfxVars::CanUseHardwareVideoDecoding(); testForVPx = testForVPx && gfx::gfxVars::CanUseHardwareVideoDecoding(); - if (testForVPx && StaticPrefs::MediaWmfVp9Enabled()) { + if (testForVPx && gfxPrefs::MediaWmfVp9Enabled()) { gfx::WMFVPXVideoCrashGuard guard; if (!guard.Crashed()) { sUsableVPXMFT = CanCreateMFTDecoder(CLSID_WebmMfVpxDec); diff --git a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp index 8fdad3f781ef6..d6b5a4f381935 100644 --- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp +++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp @@ -22,11 +22,11 @@ #include "WMFDecoderModule.h" #include "WMFUtils.h" #include "gfx2DGlue.h" +#include "gfxPrefs.h" #include "gfxWindowsPlatform.h" #include "mozilla/AbstractThread.h" #include "mozilla/ClearOnShutdown.h" #include "mozilla/Logging.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/SyncRunnable.h" #include "mozilla/Telemetry.h" #include "mozilla/WindowsVersion.h" @@ -443,11 +443,11 @@ class CreateDXVAManagerEvent : public Runnable { NS_ASSERTION(NS_IsMainThread(), "Must be on main thread."); const bool deblacklistingForTelemetry = XRE_IsGPUProcess() && - StaticPrefs::PDMWMFDeblacklistingForTelemetryInGPUProcess(); + gfxPrefs::PDMWMFDeblacklistingForTelemetryInGPUProcess(); nsACString* failureReason = &mFailureReason; nsCString secondFailureReason; if (mBackend == LayersBackend::LAYERS_D3D11 && - StaticPrefs::PDMWMFAllowD3D11() && IsWin8OrLater()) { + gfxPrefs::PDMWMFAllowD3D11() && IsWin8OrLater()) { const nsCString& blacklistedDLL = FindD3D11BlacklistedDLL(); if (!deblacklistingForTelemetry && !blacklistedDLL.IsEmpty()) { failureReason->AppendPrintf("D3D11 blacklisted with DLL %s", @@ -515,7 +515,7 @@ bool WMFVideoMFTManager::InitializeDXVA() { } MediaResult WMFVideoMFTManager::ValidateVideoInfo() { - if (mStreamType != H264 || StaticPrefs::PDMWMFAllowUnsupportedResolutions()) { + if (mStreamType != H264 || gfxPrefs::PDMWMFAllowUnsupportedResolutions()) { return NS_OK; } @@ -586,8 +586,8 @@ MediaResult WMFVideoMFTManager::InitInternal() { attr->SetUINT32(CODECAPI_AVDecNumWorkerThreads, WMFDecoderModule::GetNumDecoderThreads()); bool lowLatency = - (StaticPrefs::PDMWMFLowLatencyEnabled() || IsWin10OrLater()) && - !StaticPrefs::PDMWMFLowLatencyForceDisabled(); + (gfxPrefs::PDMWMFLowLatencyEnabled() || IsWin10OrLater()) && + !gfxPrefs::PDMWMFLowLatencyForceDisabled(); if (mLowLatency || lowLatency) { hr = attr->SetUINT32(CODECAPI_AVLowLatencyMode, TRUE); if (SUCCEEDED(hr)) { @@ -1150,7 +1150,7 @@ nsCString WMFVideoMFTManager::GetDescriptionName() const { bool hw = IsHardwareAccelerated(failureReason); return nsPrintfCString("wmf %s video decoder - %s", hw ? "hardware" : "software", - hw ? StaticPrefs::PDMWMFUseNV12Format() && + hw ? gfxPrefs::PDMWMFUseNV12Format() && gfx::DeviceManagerDx::Get()->CanUseNV12() ? "nv12" : "rgba32" diff --git a/dom/media/systemservices/MediaSystemResourceManager.cpp b/dom/media/systemservices/MediaSystemResourceManager.cpp index 8d0a797c4be29..b203e80af6a5c 100644 --- a/dom/media/systemservices/MediaSystemResourceManager.cpp +++ b/dom/media/systemservices/MediaSystemResourceManager.cpp @@ -6,6 +6,7 @@ #include "mozilla/TaskQueue.h" +#include "gfxPrefs.h" #include "MediaSystemResourceManagerChild.h" #include "mozilla/layers/ImageBridgeChild.h" diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index f912f2b8ae476..4f6e1ca89c40a 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -35,6 +35,7 @@ #include "ImageContainer.h" #include "GLContext.h" #include "GLContextProvider.h" +#include "gfxPrefs.h" #include "LayersLogging.h" #include "mozilla/layers/TextureWrapperImage.h" #include "mozilla/layers/TextureClientRecycleAllocator.h" @@ -313,14 +314,14 @@ PluginInstanceParent::AnswerNPN_GetValue_NPNVdocumentOrigin(nsCString* value, } static inline bool AllowDirectBitmapSurfaceDrawing() { - if (!StaticPrefs::PluginAsyncDrawingEnabled()) { + if (!gfxPrefs::PluginAsyncDrawingEnabled()) { return false; } return gfxPlatform::GetPlatform()->SupportsPluginDirectBitmapDrawing(); } static inline bool AllowDirectDXGISurfaceDrawing() { - if (!StaticPrefs::PluginAsyncDrawingEnabled()) { + if (!gfxPrefs::PluginAsyncDrawingEnabled()) { return false; } #if defined(XP_WIN) diff --git a/dom/vr/VRDisplay.cpp b/dom/vr/VRDisplay.cpp index 950b1ca2ea3dc..a79616d11cf28 100644 --- a/dom/vr/VRDisplay.cpp +++ b/dom/vr/VRDisplay.cpp @@ -14,9 +14,9 @@ #include "mozilla/dom/VRDisplayBinding.h" #include "mozilla/Base64.h" #include "mozilla/EventStateManager.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/gfx/DataSurfaceHelpers.h" #include "Navigator.h" +#include "gfxPrefs.h" #include "gfxUtils.h" #include "gfxVR.h" #include "VRDisplayClient.h" @@ -445,7 +445,7 @@ void VRDisplay::StartHandlingVRNavigationEvent() { mHandlingVRNavigationEventStart = TimeStamp::Now(); ++mVRNavigationEventDepth; TimeDuration timeout = - TimeDuration::FromMilliseconds(StaticPrefs::VRNavigationTimeout()); + TimeDuration::FromMilliseconds(gfxPrefs::VRNavigationTimeout()); // A 0 or negative TimeDuration indicates that content may take // as long as it wishes to respond to the event, as long as // it happens before the event exits. @@ -470,7 +470,7 @@ bool VRDisplay::IsHandlingVRNavigationEvent() { return false; } TimeDuration timeout = - TimeDuration::FromMilliseconds(StaticPrefs::VRNavigationTimeout()); + TimeDuration::FromMilliseconds(gfxPrefs::VRNavigationTimeout()); return timeout.ToMilliseconds() <= 0 || (TimeStamp::Now() - mHandlingVRNavigationEventStart) <= timeout; } @@ -494,7 +494,7 @@ already_AddRefed VRDisplay::RequestPresent( isChromePresentation ? gfx::kVRGroupChrome : gfx::kVRGroupContent; if (!EventStateManager::IsHandlingUserInput() && !isChromePresentation && - !IsHandlingVRNavigationEvent() && StaticPrefs::VRRequireGesture() && + !IsHandlingVRNavigationEvent() && gfxPrefs::VRRequireGesture() && !IsPresenting()) { // The WebVR API states that if called outside of a user gesture, the // promise must be rejected. We allow VR presentations to start within diff --git a/gfx/2d/DrawTargetCairo.cpp b/gfx/2d/DrawTargetCairo.cpp index 09b24d3e68e6f..124d1be02cc84 100644 --- a/gfx/2d/DrawTargetCairo.cpp +++ b/gfx/2d/DrawTargetCairo.cpp @@ -15,7 +15,7 @@ #include "mozilla/Scoped.h" #include "mozilla/UniquePtr.h" #include "mozilla/Vector.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "cairo.h" #include "cairo-tee.h" @@ -1309,7 +1309,7 @@ void DrawTargetCairo::FillGlyphs(ScaledFont* aFont, const GlyphBuffer& aBuffer, } if (!SupportsVariationSettings(mSurface) && aFont->HasVariationSettings() && - StaticPrefs::PrintFontVariationsAsPaths()) { + gfxPrefs::PrintFontVariationsAsPaths()) { cairo_set_fill_rule(mContext, CAIRO_FILL_RULE_WINDING); cairo_new_path(mContext); cairo_glyph_path(mContext, &glyphs[0], aBuffer.mNumGlyphs); diff --git a/gfx/2d/Factory.cpp b/gfx/2d/Factory.cpp index 4c6792d65955b..635e20527ce57 100644 --- a/gfx/2d/Factory.cpp +++ b/gfx/2d/Factory.cpp @@ -67,8 +67,6 @@ # include FT_FREETYPE_H #endif #include "MainThreadUtils.h" -#include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #if defined(MOZ_LOGGING) GFX2D_API mozilla::LogModule* GetGFX2DLog() { @@ -190,9 +188,8 @@ void mozilla_UnlockFTLibrary(FT_Library aFTLibrary) { namespace mozilla { namespace gfx { -// In Gecko, this value is managed by gfx.logging.level and gets updated when -// the pref change. -Atomic LoggingPrefs::sGfxLogLevel(LOG_DEFAULT); +// In Gecko, this value is managed by gfx.logging.level in gfxPrefs. +int32_t LoggingPrefs::sGfxLogLevel = LOG_DEFAULT; #ifdef MOZ_ENABLE_FREETYPE FT_Library Factory::mFTLibrary = nullptr; @@ -217,18 +214,9 @@ DrawEventRecorder* Factory::mRecorder; mozilla::gfx::Config* Factory::sConfig = nullptr; -static void PrefChanged(const char* aPref, void*) { - mozilla::gfx::LoggingPrefs::sGfxLogLevel = - Preferences::GetInt(StaticPrefs::GetGfxLoggingLevelPrefName(), - StaticPrefs::GetGfxLoggingLevelPrefDefault()); -} - void Factory::Init(const Config& aConfig) { MOZ_ASSERT(!sConfig); sConfig = new Config(aConfig); - Preferences::RegisterCallback( - PrefChanged, - nsDependentCString(StaticPrefs::GetGfxLoggingLevelPrefName())); } void Factory::ShutDown() { diff --git a/gfx/2d/HelpersWinFonts.h b/gfx/2d/HelpersWinFonts.h index 48a1569f2dc0f..9904bc45a1906 100644 --- a/gfx/2d/HelpersWinFonts.h +++ b/gfx/2d/HelpersWinFonts.h @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" namespace mozilla { namespace gfx { @@ -15,7 +15,7 @@ static BYTE GetSystemTextQuality() { return sSystemTextQuality; } static AntialiasMode GetSystemDefaultAAMode() { AntialiasMode defaultMode = AntialiasMode::SUBPIXEL; - if (StaticPrefs::DisableAllTextAA()) { + if (gfxPrefs::DisableAllTextAA()) { return AntialiasMode::NONE; } diff --git a/gfx/2d/Logging.h b/gfx/2d/Logging.h index 600e7a67abb1c..3a6e76f446d14 100644 --- a/gfx/2d/Logging.h +++ b/gfx/2d/Logging.h @@ -21,7 +21,6 @@ # include "nsDebug.h" #endif #include "2D.h" -#include "mozilla/Atomics.h" #include "Point.h" #include "BaseRect.h" #include "Matrix.h" @@ -59,7 +58,7 @@ class LoggingPrefs { // 1 just errors, 2 adds warnings and 3 or 4 add debug logging. // In addition to setting the value to 4, you will need to set the // environment variable MOZ_LOG to gfx:4. See mozilla/Logging.h for details. - static Atomic sGfxLogLevel; + static int32_t sGfxLogLevel; }; /// Graphics logging is available in both debug and release builds and is diff --git a/gfx/2d/ScaledFontBase.cpp b/gfx/2d/ScaledFontBase.cpp index b4be4a168b7f9..9bd37d0d3809b 100644 --- a/gfx/2d/ScaledFontBase.cpp +++ b/gfx/2d/ScaledFontBase.cpp @@ -6,7 +6,7 @@ #include "ScaledFontBase.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #ifdef USE_SKIA # include "PathSkia.h" @@ -36,7 +36,7 @@ Atomic ScaledFont::sDeletionCounter(0); ScaledFont::~ScaledFont() { sDeletionCounter++; } AntialiasMode ScaledFont::GetDefaultAAMode() { - if (StaticPrefs::DisableAllTextAA()) { + if (gfxPrefs::DisableAllTextAA()) { return AntialiasMode::NONE; } diff --git a/gfx/2d/unittest/TestBase.h b/gfx/2d/unittest/TestBase.h index f51a53aab973f..701451d0c3217 100644 --- a/gfx/2d/unittest/TestBase.h +++ b/gfx/2d/unittest/TestBase.h @@ -9,9 +9,8 @@ #include #include -#if defined(_MSC_VER) && !defined(__clang__) +#ifdef _MSC_VER // On MSVC otherwise our generic member pointer trick doesn't work. -// JYA: Do we still need this? # pragma pointers_to_members(full_generality, single_inheritance) #endif diff --git a/gfx/config/gfxConfig.h b/gfx/config/gfxConfig.h index a62f98513bd2a..6e6eecb921c4a 100644 --- a/gfx/config/gfxConfig.h +++ b/gfx/config/gfxConfig.h @@ -20,7 +20,7 @@ class FeatureFailure; // Manages the history and state of a graphics feature. The flow of a feature // is: -// - A default value, set by all.js, or gfxPlatform. +// - A default value, set by all.js, gfxPrefs, or gfxPlatform. // - A user value, set by an external value or user pref. // - An environment value, determined by system/hardware factors or // nsIGfxInfo. diff --git a/gfx/config/gfxVars.h b/gfx/config/gfxVars.h index cc3508bbbef23..27388a6e1925d 100644 --- a/gfx/config/gfxVars.h +++ b/gfx/config/gfxVars.h @@ -49,14 +49,13 @@ class gfxVarReceiver; _(ProfDirectory, nsString, nsString()) \ _(UseOMTP, bool, false) \ _(AllowD3D11KeyedMutex, bool, false) \ - _(SystemTextQuality, int32_t, 5 /* CLEARTYPE_QUALITY */) \ - _(LayersWindowRecordingPath, nsCString, nsCString()) + _(SystemTextQuality, int32_t, 5 /* CLEARTYPE_QUALITY */) /* Add new entries above this line. */ // Some graphics settings are computed on the UI process and must be // communicated to content and GPU processes. gfxVars helps facilitate -// this. Its function is similar to StaticPrefs, except rather than hold +// this. Its function is similar to gfxPrefs, except rather than hold // user preferences, it holds dynamically computed values. // // Each variable in GFX_VARS_LIST exposes the following static methods: diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp index c0dd44eb646d2..12a81549f3969 100644 --- a/gfx/gl/GLContext.cpp +++ b/gfx/gl/GLContext.cpp @@ -34,7 +34,7 @@ #include "SharedSurfaceGL.h" #include "GfxTexturesReporter.h" #include "gfx2DGlue.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "mozilla/IntegerPrintfMacros.h" #include "mozilla/gfx/Logging.h" @@ -209,9 +209,9 @@ static const char* const sExtensionNames[] = { "GL_OVR_multiview2"}; static bool ShouldUseTLSIsCurrent(bool useTLSIsCurrent) { - if (StaticPrefs::UseTLSIsCurrent() == 0) return useTLSIsCurrent; + if (gfxPrefs::UseTLSIsCurrent() == 0) return useTLSIsCurrent; - return StaticPrefs::UseTLSIsCurrent() > 0; + return gfxPrefs::UseTLSIsCurrent() > 0; } static bool ParseVersion(const std::string& versionStr, @@ -276,7 +276,7 @@ GLContext::GLContext(CreateContextFlags flags, const SurfaceCaps& caps, mDebugFlags(ChooseDebugFlags(flags)), mSharedContext(sharedContext), mCaps(caps), - mWorkAroundDriverBugs(StaticPrefs::WorkAroundDriverBugs()) { + mWorkAroundDriverBugs(gfxPrefs::WorkAroundDriverBugs()) { mOwningThreadId = PlatformThread::CurrentId(); MOZ_ALWAYS_TRUE(sCurrentContext.init()); sCurrentContext.set(0); @@ -1759,7 +1759,7 @@ GLFormats GLContext::ChooseGLFormats(const SurfaceCaps& caps) const { } } - uint32_t msaaLevel = StaticPrefs::MSAALevel(); + uint32_t msaaLevel = gfxPrefs::MSAALevel(); GLsizei samples = msaaLevel * msaaLevel; samples = std::min(samples, mMaxSamples); diff --git a/gfx/gl/GLContextProviderCGL.mm b/gfx/gl/GLContextProviderCGL.mm index 399cb025c818f..943c09fbb039c 100644 --- a/gfx/gl/GLContextProviderCGL.mm +++ b/gfx/gl/GLContextProviderCGL.mm @@ -9,7 +9,7 @@ #include "nsIWidget.h" #include #include "gfxFailure.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "prenv.h" #include "GeckoProfiler.h" #include "mozilla/gfx/MacIOSurface.h" @@ -98,7 +98,7 @@ bool UseDoubleBufferedWindows() const { // If swapInt is 1, then glSwapBuffers will block and wait for a vblank signal. // When we're iterating as fast as possible, however, we want a non-blocking // glSwapBuffers, which will happen when swapInt==0. - GLint swapInt = StaticPrefs::LayoutFrameRate() == 0 ? 0 : 1; + GLint swapInt = gfxPrefs::LayoutFrameRate() == 0 ? 0 : 1; [mContext setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; } return true; @@ -202,7 +202,7 @@ bool UseDoubleBufferedWindows() const { return nullptr; } - GLint opaque = StaticPrefs::CompositorGLContextOpaque(); + GLint opaque = gfxPrefs::CompositorGLContextOpaque(); [context setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity]; RefPtr glContext = @@ -226,7 +226,7 @@ bool UseDoubleBufferedWindows() const { std::vector attribs; - if (!StaticPrefs::GLAllowHighPower()) { + if (!gfxPrefs::GLAllowHighPower()) { flags &= ~CreateContextFlags::HIGH_POWER; } if (flags & CreateContextFlags::ALLOW_OFFLINE_RENDERER || @@ -236,7 +236,7 @@ bool UseDoubleBufferedWindows() const { attribs.push_back(NSOpenGLPFAAllowOfflineRenderers); } - if (StaticPrefs::RequireHardwareGL()) { + if (gfxPrefs::RequireHardwareGL()) { attribs.push_back(NSOpenGLPFAAccelerated); } @@ -260,7 +260,7 @@ bool UseDoubleBufferedWindows() const { RefPtr glContext = new GLContextCGL(flags, SurfaceCaps::Any(), context, true); - if (StaticPrefs::GLMultithreaded()) { + if (gfxPrefs::GLMultithreaded()) { CGLEnable(glContext->GetCGLContext(), kCGLCEMPEngine); } return glContext.forget(); diff --git a/gfx/gl/GLContextProviderEAGL.mm b/gfx/gl/GLContextProviderEAGL.mm index 593632531efed..2af1ffa61fd87 100644 --- a/gfx/gl/GLContextProviderEAGL.mm +++ b/gfx/gl/GLContextProviderEAGL.mm @@ -7,6 +7,7 @@ #include "GLContextEAGL.h" #include "nsDebug.h" #include "nsIWidget.h" +#include "gfxPrefs.h" #include "gfxFailure.h" #include "prenv.h" #include "mozilla/Preferences.h" diff --git a/gfx/gl/GLContextProviderGLX.cpp b/gfx/gl/GLContextProviderGLX.cpp index edf1282bece65..44208ad26bcb7 100644 --- a/gfx/gl/GLContextProviderGLX.cpp +++ b/gfx/gl/GLContextProviderGLX.cpp @@ -19,7 +19,6 @@ #include "mozilla/layers/CompositorOptions.h" #include "mozilla/Range.h" #include "mozilla/ScopeExit.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/widget/CompositorWidget.h" #include "mozilla/widget/GtkCompositorWidget.h" #include "mozilla/Unused.h" @@ -38,6 +37,7 @@ #include "gfxUtils.h" #include "gfx2DGlue.h" #include "GLScreenBuffer.h" +#include "gfxPrefs.h" #include "gfxCrashReporterUtils.h" @@ -185,7 +185,7 @@ bool GLXLibrary::EnsureInitialized() { if (HasExtension(extensionsStr, "GLX_EXT_texture_from_pixmap") && fnLoadSymbols(symbols_texturefrompixmap)) { - mUseTextureFromPixmap = StaticPrefs::UseGLXTextureFromPixmap(); + mUseTextureFromPixmap = gfxPrefs::UseGLXTextureFromPixmap(); } else { mUseTextureFromPixmap = false; NS_WARNING("Texture from pixmap disabled"); @@ -597,7 +597,7 @@ bool GLContextGLX::MakeCurrentImpl() const { // Many GLX implementations default to blocking until the next // VBlank when calling glXSwapBuffers. We want to run unthrottled // in ASAP mode. See bug 1280744. - const bool isASAP = (StaticPrefs::LayoutFrameRate() == 0); + const bool isASAP = (gfxPrefs::LayoutFrameRate() == 0); mGLX->fSwapInterval(mDisplay, mDrawable, isASAP ? 0 : 1); } return succeeded; diff --git a/gfx/gl/GLContextProviderWGL.cpp b/gfx/gl/GLContextProviderWGL.cpp index 09af4c9f191e8..517e77cc034dc 100644 --- a/gfx/gl/GLContextProviderWGL.cpp +++ b/gfx/gl/GLContextProviderWGL.cpp @@ -9,6 +9,7 @@ #include "nsDebug.h" #include "nsIWidget.h" #include "gfxPlatform.h" +#include "gfxPrefs.h" #include "gfxWindowsSurface.h" #include "gfxCrashReporterUtils.h" @@ -214,8 +215,7 @@ bool WGLLibrary::EnsureInitialized() { // -- bool hasDXInterop2 = HasExtension(extString, "WGL_NV_DX_interop2"); - if (gfxVars::DXInterop2Blocked() && - !StaticPrefs::IgnoreDXInterop2Blacklist()) { + if (gfxVars::DXInterop2Blocked() && !gfxPrefs::IgnoreDXInterop2Blacklist()) { hasDXInterop2 = false; } diff --git a/gfx/gl/GLLibraryEGL.cpp b/gfx/gl/GLLibraryEGL.cpp index 6203f06b77811..0ecd6f67b46f4 100644 --- a/gfx/gl/GLLibraryEGL.cpp +++ b/gfx/gl/GLLibraryEGL.cpp @@ -12,7 +12,6 @@ #include "mozilla/Telemetry.h" #include "mozilla/Tokenizer.h" #include "mozilla/ScopeExit.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Unused.h" #include "mozilla/webrender/RenderThread.h" #include "nsDirectoryServiceDefs.h" @@ -30,6 +29,7 @@ #include "prsystem.h" #include "GLContext.h" #include "GLContextProvider.h" +#include "gfxPrefs.h" #include "ScopedGLHelpers.h" #ifdef MOZ_WIDGET_GTK # include @@ -85,7 +85,8 @@ PRLibrary* LoadApitraceLibrary() { if (!path) return nullptr; // Initialization of gfx prefs here is only needed during the unit tests... - if (!StaticPrefs::UseApitrace()) { + gfxPrefs::GetSingleton(); + if (!gfxPrefs::UseApitrace()) { return nullptr; } @@ -289,11 +290,11 @@ static EGLDisplay GetAndInitDisplayForAccelANGLE( FeatureState& d3d11ANGLE = gfxConfig::GetFeature(Feature::D3D11_HW_ANGLE); - if (!StaticPrefs::WebGLANGLETryD3D11()) + if (!gfxPrefs::WebGLANGLETryD3D11()) d3d11ANGLE.UserDisable("User disabled D3D11 ANGLE by pref", NS_LITERAL_CSTRING("FAILURE_ID_ANGLE_PREF")); - if (StaticPrefs::WebGLANGLEForceD3D11()) + if (gfxPrefs::WebGLANGLEForceD3D11()) d3d11ANGLE.UserForceEnable( "User force-enabled D3D11 ANGLE on disabled hardware"); @@ -741,7 +742,7 @@ EGLDisplay GLLibraryEGL::CreateDisplay(bool forceAccel, bool shouldTryWARP = !forceAccel; // Only if ANGLE not supported or fails // If WARP preferred, will override ANGLE support - if (StaticPrefs::WebGLANGLEForceWARP()) { + if (gfxPrefs::WebGLANGLEForceWARP()) { shouldTryWARP = true; shouldTryAccel = false; if (accelAngleFailureId.IsEmpty()) { diff --git a/gfx/gl/GLScreenBuffer.cpp b/gfx/gl/GLScreenBuffer.cpp index 7a3d5fab02437..d4acdf99ee4d3 100644 --- a/gfx/gl/GLScreenBuffer.cpp +++ b/gfx/gl/GLScreenBuffer.cpp @@ -7,7 +7,7 @@ #include #include "CompositorTypes.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "GLContext.h" #include "GLBlitHelper.h" #include "GLReadTexImageHelper.h" @@ -69,11 +69,11 @@ UniquePtr GLScreenBuffer::CreateFactory( const bool useANGLE = compositorConnection->GetCompositorUseANGLE(); const bool useGl = - !StaticPrefs::WebGLForceLayersReadback() && + !gfxPrefs::WebGLForceLayersReadback() && (backend == layers::LayersBackend::LAYERS_OPENGL || (backend == layers::LayersBackend::LAYERS_WR && !useANGLE)); const bool useD3D = - !StaticPrefs::WebGLForceLayersReadback() && + !gfxPrefs::WebGLForceLayersReadback() && (backend == layers::LayersBackend::LAYERS_D3D11 || (backend == layers::LayersBackend::LAYERS_WR && useANGLE)); @@ -88,7 +88,7 @@ UniquePtr GLScreenBuffer::CreateFactory( factory = MakeUnique(mGLContext, caps, ipcChannel, mFlags); #elif defined(MOZ_WIDGET_ANDROID) - if (XRE_IsParentProcess() && !StaticPrefs::WebGLSurfaceTextureEnabled()) { + if (XRE_IsParentProcess() && !gfxPrefs::WebGLSurfaceTextureEnabled()) { factory = SurfaceFactory_EGLImage::Create(gl, caps, ipcChannel, flags); } else { factory = @@ -117,7 +117,7 @@ UniquePtr GLScreenBuffer::CreateFactory( SurfaceFactory_ANGLEShareHandle::Create(gl, caps, ipcChannel, flags); } - if (!factory && StaticPrefs::WebGLDXGLEnabled()) { + if (!factory && gfxPrefs::WebGLDXGLEnabled()) { factory = SurfaceFactory_D3D11Interop::Create(gl, caps, ipcChannel, flags); } diff --git a/gfx/gl/GfxTexturesReporter.cpp b/gfx/gl/GfxTexturesReporter.cpp index 4b399636e03e4..69c051542a86b 100644 --- a/gfx/gl/GfxTexturesReporter.cpp +++ b/gfx/gl/GfxTexturesReporter.cpp @@ -8,7 +8,7 @@ #include #include "nsExceptionHandler.h" #include "GfxTexturesReporter.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" using namespace mozilla; using namespace mozilla::gl; @@ -59,7 +59,7 @@ void GfxTexturesReporter::UpdateAmount(MemoryUse action, size_t amount) { "GFX: Current texture usage greater than update amount."); sAmount -= amount; - if (StaticPrefs::GfxLoggingTextureUsageEnabled()) { + if (gfxPrefs::GfxLoggingTextureUsageEnabled()) { printf_stderr("Current texture usage: %s\n", FormatBytes(sAmount).c_str()); } @@ -67,7 +67,7 @@ void GfxTexturesReporter::UpdateAmount(MemoryUse action, size_t amount) { sAmount += amount; if (sAmount > sPeakAmount) { sPeakAmount.exchange(sAmount); - if (StaticPrefs::GfxLoggingPeakTextureUsageEnabled()) { + if (gfxPrefs::GfxLoggingPeakTextureUsageEnabled()) { printf_stderr("Peak texture usage: %s\n", FormatBytes(sPeakAmount).c_str()); } diff --git a/gfx/gl/SharedSurfaceD3D11Interop.cpp b/gfx/gl/SharedSurfaceD3D11Interop.cpp index 28fc37be6ebe2..35769de6c5053 100644 --- a/gfx/gl/SharedSurfaceD3D11Interop.cpp +++ b/gfx/gl/SharedSurfaceD3D11Interop.cpp @@ -7,6 +7,7 @@ #include #include +#include "gfxPrefs.h" #include "GLContext.h" #include "WGLLibrary.h" #include "nsPrintfCString.h" @@ -414,7 +415,7 @@ SharedSurface_D3D11Interop::SharedSurface_D3D11Interop( mLockHandle(lockHandle), mTexD3D(texD3D), mDXGIHandle(dxgiHandle), - mNeedsFinish(StaticPrefs::WebGLDXGLNeedsFinish()), + mNeedsFinish(gfxPrefs::WebGLDXGLNeedsFinish()), mLockedForGL(false) { MOZ_ASSERT(bool(mProdTex) == bool(mInteropFB)); } diff --git a/gfx/ipc/GPUChild.cpp b/gfx/ipc/GPUChild.cpp index c4ad576151d05..90a38626b7424 100644 --- a/gfx/ipc/GPUChild.cpp +++ b/gfx/ipc/GPUChild.cpp @@ -5,10 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "GPUChild.h" #include "gfxConfig.h" +#include "gfxPrefs.h" #include "GPUProcessHost.h" #include "GPUProcessManager.h" #include "VRProcessManager.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Telemetry.h" #include "mozilla/TelemetryIPC.h" #include "mozilla/dom/CheckerboardReportService.h" @@ -40,6 +40,22 @@ GPUChild::GPUChild(GPUProcessHost* aHost) : mHost(aHost), mGPUReady(false) { GPUChild::~GPUChild() { MOZ_COUNT_DTOR(GPUChild); } void GPUChild::Init() { + // Build a list of prefs the GPU process will need. Note that because we + // limit the GPU process to prefs contained in gfxPrefs, we can simplify + // the message in two ways: one, we only need to send its index in gfxPrefs + // rather than its name, and two, we only need to send prefs that don't + // have their default value. + nsTArray prefs; + for (auto pref : gfxPrefs::all()) { + if (pref->HasDefaultValue()) { + continue; + } + + GfxPrefValue value; + pref->GetCachedValue(&value); + prefs.AppendElement(GfxPrefSetting(pref->Index(), value)); + } + nsTArray updates = gfxVars::FetchNonDefaultVars(); DevicePrefs devicePrefs; @@ -57,7 +73,7 @@ void GPUChild::Init() { mappings.AppendElement(LayerTreeIdMapping(aLayersId, aProcessId)); }); - SendInit(updates, devicePrefs, mappings); + SendInit(prefs, updates, devicePrefs, mappings); gfxVars::AddReceiver(this); @@ -142,7 +158,7 @@ mozilla::ipc::IPCResult GPUChild::RecvInitCrashReporter( mozilla::ipc::IPCResult GPUChild::RecvCreateVRProcess() { // Make sure create VR process at the main process MOZ_ASSERT(XRE_IsParentProcess()); - if (StaticPrefs::VRProcessEnabled()) { + if (gfxPrefs::VRProcessEnabled()) { VRProcessManager::Initialize(); VRProcessManager* vr = VRProcessManager::Get(); MOZ_ASSERT(vr, "VRProcessManager must be initialized first."); @@ -158,7 +174,7 @@ mozilla::ipc::IPCResult GPUChild::RecvCreateVRProcess() { mozilla::ipc::IPCResult GPUChild::RecvShutdownVRProcess() { // Make sure stopping VR process at the main process MOZ_ASSERT(XRE_IsParentProcess()); - if (StaticPrefs::VRProcessEnabled()) { + if (gfxPrefs::VRProcessEnabled()) { VRProcessManager::Shutdown(); } diff --git a/gfx/ipc/GPUParent.cpp b/gfx/ipc/GPUParent.cpp index 5e22272e1cb17..fb531de91ad51 100644 --- a/gfx/ipc/GPUParent.cpp +++ b/gfx/ipc/GPUParent.cpp @@ -10,11 +10,11 @@ #include "gfxConfig.h" #include "gfxCrashReporterUtils.h" #include "gfxPlatform.h" +#include "gfxPrefs.h" #include "GLContextProvider.h" #include "GPUProcessHost.h" #include "GPUProcessManager.h" #include "mozilla/Assertions.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Telemetry.h" #include "mozilla/TimeStamp.h" #include "mozilla/VideoDecoderManagerChild.h" @@ -109,6 +109,8 @@ bool GPUParent::Init(base::ProcessId aParentPid, const char* aParentBuildID, // Init crash reporter support. CrashReporterClient::InitSingleton(this); + // Ensure gfxPrefs are initialized. + gfxPrefs::GetSingleton(); gfxConfig::Init(); gfxVars::Initialize(); gfxPlatform::InitNullMetadata(); @@ -172,8 +174,13 @@ bool GPUParent::DeallocPAPZInputBridgeParent(PAPZInputBridgeParent* aActor) { } mozilla::ipc::IPCResult GPUParent::RecvInit( - nsTArray&& vars, const DevicePrefs& devicePrefs, - nsTArray&& aMappings) { + nsTArray&& prefs, nsTArray&& vars, + const DevicePrefs& devicePrefs, nsTArray&& aMappings) { + const nsTArray& globalPrefs = gfxPrefs::all(); + for (auto& setting : prefs) { + gfxPrefs::Pref* pref = globalPrefs[setting.index()]; + pref->SetCachedValue(setting.value()); + } for (const auto& var : vars) { gfxVars::ApplyUpdate(var); } @@ -259,7 +266,7 @@ mozilla::ipc::IPCResult GPUParent::RecvInit( } #ifdef XP_WIN else { - if (StaticPrefs::Direct3D11UseDoubleBuffering() && IsWin10OrLater()) { + if (gfxPrefs::Direct3D11UseDoubleBuffering() && IsWin10OrLater()) { // This is needed to avoid freezing the window on a device crash on double // buffering, see bug 1549674. widget::WinCompositorWindowThread::Start(); @@ -323,13 +330,15 @@ mozilla::ipc::IPCResult GPUParent::RecvInitProfiler( return IPC_OK(); } -mozilla::ipc::IPCResult GPUParent::RecvUpdateVar(const GfxVarUpdate& aUpdate) { - gfxVars::ApplyUpdate(aUpdate); +mozilla::ipc::IPCResult GPUParent::RecvUpdatePref( + const GfxPrefSetting& setting) { + gfxPrefs::Pref* pref = gfxPrefs::all()[setting.index()]; + pref->SetCachedValue(setting.value()); return IPC_OK(); } -mozilla::ipc::IPCResult GPUParent::RecvPreferenceUpdate(const Pref& aPref) { - Preferences::SetPreference(aPref); +mozilla::ipc::IPCResult GPUParent::RecvUpdateVar(const GfxVarUpdate& aUpdate) { + gfxVars::ApplyUpdate(aUpdate); return IPC_OK(); } @@ -473,7 +482,7 @@ mozilla::ipc::IPCResult GPUParent::RecvRequestMemoryReport( } mozilla::ipc::IPCResult GPUParent::RecvShutdownVR() { - if (StaticPrefs::VRProcessEnabled()) { + if (gfxPrefs::VRProcessEnabled()) { VRGPUChild::Shutdown(); } return IPC_OK(); @@ -514,7 +523,7 @@ void GPUParent::ActorDestroy(ActorDestroyReason aWhy) { wr::RenderThread::ShutDown(); } #ifdef XP_WIN - else if (StaticPrefs::Direct3D11UseDoubleBuffering() && IsWin10OrLater()) { + else if (gfxPrefs::Direct3D11UseDoubleBuffering() && IsWin10OrLater()) { widget::WinCompositorWindowThread::ShutDown(); } #endif @@ -549,6 +558,7 @@ void GPUParent::ActorDestroy(ActorDestroyReason aWhy) { LayerTreeOwnerTracker::Shutdown(); gfxVars::Shutdown(); gfxConfig::Shutdown(); + gfxPrefs::DestroySingleton(); CrashReporterClient::DestroySingleton(); XRE_ShutdownChildProcess(); } diff --git a/gfx/ipc/GPUParent.h b/gfx/ipc/GPUParent.h index 67695c7782e4e..ed47be459b23a 100644 --- a/gfx/ipc/GPUParent.h +++ b/gfx/ipc/GPUParent.h @@ -37,7 +37,8 @@ class GPUParent final : public PGPUParent { PAPZInputBridgeParent* AllocPAPZInputBridgeParent(const LayersId& aLayersId); bool DeallocPAPZInputBridgeParent(PAPZInputBridgeParent* aActor); - mozilla::ipc::IPCResult RecvInit(nsTArray&& vars, + mozilla::ipc::IPCResult RecvInit(nsTArray&& prefs, + nsTArray&& vars, const DevicePrefs& devicePrefs, nsTArray&& mappings); mozilla::ipc::IPCResult RecvInitCompositorManager( @@ -54,8 +55,8 @@ class GPUParent final : public PGPUParent { Endpoint&& aEndpoint); mozilla::ipc::IPCResult RecvInitProfiler( Endpoint&& aEndpoint); + mozilla::ipc::IPCResult RecvUpdatePref(const GfxPrefSetting& pref); mozilla::ipc::IPCResult RecvUpdateVar(const GfxVarUpdate& pref); - mozilla::ipc::IPCResult RecvPreferenceUpdate(const Pref& pref); mozilla::ipc::IPCResult RecvNewContentCompositorManager( Endpoint&& aEndpoint); mozilla::ipc::IPCResult RecvNewContentImageBridge( diff --git a/gfx/ipc/GPUProcessHost.cpp b/gfx/ipc/GPUProcessHost.cpp index 5cc50d01afbff..d8e17316df156 100644 --- a/gfx/ipc/GPUProcessHost.cpp +++ b/gfx/ipc/GPUProcessHost.cpp @@ -6,12 +6,11 @@ #include "GPUProcessHost.h" #include "chrome/common/process_watcher.h" +#include "gfxPrefs.h" #include "mozilla/gfx/Logging.h" #include "nsITimer.h" #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include "VRGPUChild.h" -#include "ProcessUtils.h" namespace mozilla { namespace gfx { @@ -36,12 +35,6 @@ bool GPUProcessHost::Launch(StringVector aExtraOpts) { MOZ_ASSERT(!mGPUChild); MOZ_ASSERT(!gfxPlatform::IsHeadless()); - mPrefSerializer = MakeUnique(); - if (!mPrefSerializer->SerializeToSharedMemory()) { - return false; - } - mPrefSerializer->AddSharedPrefCmdLineArgs(*this, aExtraOpts); - #if defined(XP_WIN) && defined(MOZ_SANDBOX) mSandboxLevel = Preferences::GetInt("security.sandbox.gpu.level"); #endif @@ -51,7 +44,6 @@ bool GPUProcessHost::Launch(StringVector aExtraOpts) { if (!GeckoChildProcessHost::AsyncLaunch(aExtraOpts)) { mLaunchPhase = LaunchPhase::Complete; - mPrefSerializer = nullptr; return false; } return true; @@ -62,7 +54,7 @@ bool GPUProcessHost::WaitForLaunch() { return !!mGPUChild; } - int32_t timeoutMs = StaticPrefs::GPUProcessTimeoutMs(); + int32_t timeoutMs = gfxPrefs::GPUProcessTimeoutMs(); // If one of the following environment variables are set we can effectively // ignore the timeout - as we can guarantee the compositor process will be @@ -131,7 +123,6 @@ void GPUProcessHost::InitAfterConnect(bool aSucceeded) { MOZ_ASSERT(!mGPUChild); mLaunchPhase = LaunchPhase::Complete; - mPrefSerializer = nullptr; if (aSucceeded) { mProcessToken = ++sProcessTokenCounter; diff --git a/gfx/ipc/GPUProcessHost.h b/gfx/ipc/GPUProcessHost.h index 22f53db0672a9..6118a5453d4ea 100644 --- a/gfx/ipc/GPUProcessHost.h +++ b/gfx/ipc/GPUProcessHost.h @@ -13,11 +13,6 @@ #include "mozilla/ipc/ProtocolUtils.h" #include "mozilla/ipc/TaskFactory.h" -namespace mozilla { -namespace ipc { -class SharedPreferenceSerializer; -} -} // namespace mozilla class nsITimer; namespace mozilla { @@ -127,8 +122,6 @@ class GPUProcessHost final : public mozilla::ipc::GeckoChildProcessHost { UniquePtr mGPUChild; uint64_t mProcessToken; - UniquePtr mPrefSerializer; - bool mShutdownRequested; bool mChannelClosed; diff --git a/gfx/ipc/GPUProcessImpl.cpp b/gfx/ipc/GPUProcessImpl.cpp index 2193169933f10..ad8bae20a6c1b 100644 --- a/gfx/ipc/GPUProcessImpl.cpp +++ b/gfx/ipc/GPUProcessImpl.cpp @@ -6,7 +6,6 @@ #include "GPUProcessImpl.h" #include "mozilla/ipc/IOThreadChild.h" #include "nsXPCOM.h" -#include "ProcessUtils.h" #if defined(OS_WIN) && defined(MOZ_SANDBOX) # include "mozilla/sandboxTarget.h" @@ -27,48 +26,15 @@ bool GPUProcessImpl::Init(int aArgc, char* aArgv[]) { mozilla::SandboxTarget::Instance()->StartSandbox(); #endif char* parentBuildID = nullptr; - char* prefsHandle = nullptr; - char* prefMapHandle = nullptr; - char* prefsLen = nullptr; - char* prefMapSize = nullptr; for (int i = 1; i < aArgc; i++) { if (!aArgv[i]) { continue; } if (strcmp(aArgv[i], "-parentBuildID") == 0) { parentBuildID = aArgv[i + 1]; - -#ifdef XP_WIN - } else if (strcmp(aArgv[i], "-prefsHandle") == 0) { - if (++i == aArgc) { - return false; - } - prefsHandle = aArgv[i]; - } else if (strcmp(aArgv[i], "-prefMapHandle") == 0) { - if (++i == aArgc) { - return false; - } - prefMapHandle = aArgv[i]; -#endif - } else if (strcmp(aArgv[i], "-prefsLen") == 0) { - if (++i == aArgc) { - return false; - } - prefsLen = aArgv[i]; - } else if (strcmp(aArgv[i], "-prefMapSize") == 0) { - if (++i == aArgc) { - return false; - } - prefMapSize = aArgv[i]; } } - SharedPreferenceDeserializer deserializer; - if (!deserializer.DeserializeFromSharedMemory(prefsHandle, prefMapHandle, - prefsLen, prefMapSize)) { - return false; - } - return mGPU.Init(ParentPid(), parentBuildID, IOThreadChild::message_loop(), IOThreadChild::channel()); } diff --git a/gfx/ipc/GPUProcessManager.cpp b/gfx/ipc/GPUProcessManager.cpp index 2e15f9d1062e7..0f52cc97a07c0 100644 --- a/gfx/ipc/GPUProcessManager.cpp +++ b/gfx/ipc/GPUProcessManager.cpp @@ -6,10 +6,10 @@ #include "GPUProcessManager.h" +#include "gfxPrefs.h" #include "GPUProcessHost.h" #include "GPUProcessListener.h" #include "mozilla/MemoryReportingProcess.h" -#include "mozilla/Preferences.h" #include "mozilla/Sprintf.h" #include "mozilla/StaticPtr.h" #include "mozilla/StaticPrefs.h" @@ -84,7 +84,6 @@ GPUProcessManager::GPUProcessManager() mIdNamespace = AllocateNamespace(); mObserver = new Observer(this); nsContentUtils::RegisterShutdownObserver(mObserver); - Preferences::AddStrongObserver(mObserver, ""); mDeviceResetLastTime = TimeStamp::Now(); @@ -113,8 +112,6 @@ GPUProcessManager::Observer::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) { if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) { mManager->OnXPCOMShutdown(); - } else if (!strcmp(aTopic, "nsPref:changed")) { - mManager->OnPreferenceChange(aData); } return NS_OK; } @@ -122,32 +119,12 @@ GPUProcessManager::Observer::Observe(nsISupports* aSubject, const char* aTopic, void GPUProcessManager::OnXPCOMShutdown() { if (mObserver) { nsContentUtils::UnregisterShutdownObserver(mObserver); - Preferences::RemoveObserver(mObserver, ""); mObserver = nullptr; } CleanShutdown(); } -void GPUProcessManager::OnPreferenceChange(const char16_t* aData) { - // A pref changed. If it's not on the blacklist, inform child processes. - if (!dom::ContentParent::ShouldSyncPreference(aData)) { - return; - } - - // We know prefs are ASCII here. - NS_LossyConvertUTF16toASCII strData(aData); - - mozilla::dom::Pref pref(strData, /* isLocked */ false, Nothing(), Nothing()); - Preferences::GetPreference(&pref); - if (!!mGPUChild) { - MOZ_ASSERT(mQueuedPrefs.IsEmpty()); - mGPUChild->SendPreferenceUpdate(pref); - } else { - mQueuedPrefs.AppendElement(pref); - } -} - void GPUProcessManager::LaunchGPUProcess() { if (mProcess) { return; @@ -365,13 +342,6 @@ void GPUProcessManager::OnProcessLaunchComplete(GPUProcessHost* aHost) { std::move(vsyncChild)); mGPUChild->SendInitVsyncBridge(std::move(vsyncParent)); - // Flush any pref updates that happened during launch and weren't - // included in the blobs set up in LaunchGPUProcess. - for (const mozilla::dom::Pref& pref : mQueuedPrefs) { - Unused << NS_WARN_IF(!mGPUChild->SendPreferenceUpdate(pref)); - } - mQueuedPrefs.Clear(); - CrashReporter::AnnotateCrashReport( CrashReporter::Annotation::GPUProcessStatus, NS_LITERAL_CSTRING("Running")); @@ -384,8 +354,8 @@ void GPUProcessManager::OnProcessLaunchComplete(GPUProcessHost* aHost) { static bool ShouldLimitDeviceResets(uint32_t count, int32_t deltaMilliseconds) { // We decide to limit by comparing the amount of resets that have happened // and time since the last reset to two prefs. - int32_t timeLimit = StaticPrefs::DeviceResetThresholdMilliseconds(); - int32_t countLimit = StaticPrefs::DeviceResetLimitCount(); + int32_t timeLimit = gfxPrefs::DeviceResetThresholdMilliseconds(); + int32_t countLimit = gfxPrefs::DeviceResetLimitCount(); bool hasTimeLimit = timeLimit >= 0; bool hasCountLimit = countLimit >= 0; @@ -511,13 +481,13 @@ void GPUProcessManager::OnProcessUnexpectedShutdown(GPUProcessHost* aHost) { CompositorManagerChild::OnGPUProcessLost(aHost->GetProcessToken()); DestroyProcess(); - if (mNumProcessAttempts > uint32_t(StaticPrefs::GPUProcessMaxRestarts())) { + if (mNumProcessAttempts > uint32_t(gfxPrefs::GPUProcessMaxRestarts())) { char disableMessage[64]; SprintfLiteral(disableMessage, "GPU process disabled after %d attempts", mNumProcessAttempts); DisableGPUProcess(disableMessage); } else if (mNumProcessAttempts > - uint32_t(StaticPrefs::GPUProcessMaxRestartsWithDecoder()) && + uint32_t(gfxPrefs::GPUProcessMaxRestartsWithDecoder()) && mDecodeVideoOnGpuProcess) { mDecodeVideoOnGpuProcess = false; Telemetry::Accumulate(Telemetry::GPU_PROCESS_CRASH_FALLBACKS, diff --git a/gfx/ipc/GPUProcessManager.h b/gfx/ipc/GPUProcessManager.h index 3fb47284e9c19..34ad84052a45a 100644 --- a/gfx/ipc/GPUProcessManager.h +++ b/gfx/ipc/GPUProcessManager.h @@ -179,7 +179,6 @@ class GPUProcessManager final : public GPUProcessHost::Listener { private: // Called from our xpcom-shutdown observer. void OnXPCOMShutdown(); - void OnPreferenceChange(const char16_t* aData); bool CreateContentCompositorManager( base::ProcessId aOtherProcess, @@ -278,10 +277,6 @@ class GPUProcessManager final : public GPUProcessHost::Listener { uint64_t mProcessToken; GPUChild* mGPUChild; RefPtr mVsyncBridge; - // Collects any pref changes that occur during process launch (after - // the initial map is passed in command-line arguments) to be sent - // when the process can receive IPC messages. - nsTArray mQueuedPrefs; }; } // namespace gfx diff --git a/gfx/ipc/GraphicsMessages.ipdlh b/gfx/ipc/GraphicsMessages.ipdlh index 411c72468754f..0c20f9bf5fc33 100644 --- a/gfx/ipc/GraphicsMessages.ipdlh +++ b/gfx/ipc/GraphicsMessages.ipdlh @@ -17,6 +17,19 @@ using mozilla::gfx::D3D11Checks::VideoFormatOptionSet from "mozilla/gfx/D3D11Che namespace mozilla { namespace gfx { +union GfxPrefValue { + bool; + int32_t; + uint32_t; + float; + nsCString; +}; + +struct GfxPrefSetting { + int32_t index; + GfxPrefValue value; +}; + struct D3D11DeviceStatus { bool isWARP; diff --git a/gfx/ipc/PGPU.ipdl b/gfx/ipc/PGPU.ipdl index e242210a7f41b..4c06f5a1fe4de 100644 --- a/gfx/ipc/PGPU.ipdl +++ b/gfx/ipc/PGPU.ipdl @@ -6,7 +6,6 @@ include GraphicsMessages; include MemoryReportTypes; include HangTypes; -include PrefsTypes; include protocol PAPZInputBridge; include protocol PCompositorManager; include protocol PImageBridge; @@ -50,7 +49,8 @@ parent: async PAPZInputBridge(LayersId aLayersId); // Sent by the UI process to initiate core settings. - async Init(GfxVarUpdate[] vars, + async Init(GfxPrefSetting[] prefs, + GfxVarUpdate[] vars, DevicePrefs devicePrefs, LayerTreeIdMapping[] mapping); @@ -62,11 +62,10 @@ parent: async InitProfiler(Endpoint endpoint); // Forward GPU process its endpoints to the VR process. async InitVR(Endpoint endpoint); - // Called to update a gfx variable. + // Called to update a gfx preference or variable. + async UpdatePref(GfxPrefSetting pref); async UpdateVar(GfxVarUpdate var); - async PreferenceUpdate(Pref pref); - // Create a new content-process compositor bridge. async NewContentCompositorManager(Endpoint endpoint); async NewContentImageBridge(Endpoint endpoint); diff --git a/gfx/layers/CompositionRecorder.cpp b/gfx/layers/CompositionRecorder.cpp index 2c2791669154c..424bf3c2751e0 100644 --- a/gfx/layers/CompositionRecorder.cpp +++ b/gfx/layers/CompositionRecorder.cpp @@ -7,7 +7,7 @@ #include "CompositionRecorder.h" #include "gfxUtils.h" #include "mozilla/gfx/2D.h" -#include "mozilla/gfx/gfxVars.h" +#include "gfxPrefs.h" #include #include @@ -37,7 +37,7 @@ void CompositionRecorder::WriteCollectedFrames() { std::time_t t = std::time(nullptr); std::tm tm = *std::localtime(&t); std::stringstream str; - str << gfxVars::LayersWindowRecordingPath() << "windowrecording-" + str << gfxPrefs::LayersWindowRecordingPath() << "windowrecording-" << std::put_time(&tm, "%Y%m%d%H%M%S"); #ifdef XP_WIN diff --git a/gfx/layers/D3D11ShareHandleImage.cpp b/gfx/layers/D3D11ShareHandleImage.cpp index ca40d8929b341..c734f78d43c2a 100644 --- a/gfx/layers/D3D11ShareHandleImage.cpp +++ b/gfx/layers/D3D11ShareHandleImage.cpp @@ -10,8 +10,8 @@ #include "WMF.h" #include "d3d11.h" #include "gfxImageSurface.h" +#include "gfxPrefs.h" #include "gfxWindowsPlatform.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/gfx/DeviceManagerDx.h" #include "mozilla/layers/CompositableClient.h" #include "mozilla/layers/CompositableForwarder.h" @@ -223,11 +223,11 @@ D3D11RecycleAllocator::D3D11RecycleAllocator( gfx::SurfaceFormat aPreferredFormat) : TextureClientRecycleAllocator(aAllocator), mDevice(aDevice), - mCanUseNV12(StaticPrefs::PDMWMFUseNV12Format() && + mCanUseNV12(gfxPrefs::PDMWMFUseNV12Format() && gfx::DeviceManagerDx::Get()->CanUseNV12()), - mCanUseP010(StaticPrefs::PDMWMFUseNV12Format() && + mCanUseP010(gfxPrefs::PDMWMFUseNV12Format() && gfx::DeviceManagerDx::Get()->CanUseP010()), - mCanUseP016(StaticPrefs::PDMWMFUseNV12Format() && + mCanUseP016(gfxPrefs::PDMWMFUseNV12Format() && gfx::DeviceManagerDx::Get()->CanUseP016()) { SetPreferredSurfaceFormat(aPreferredFormat); } @@ -256,7 +256,7 @@ already_AddRefed D3D11RecycleAllocator::CreateOrRecycleClient( mImageDevice = device; TextureAllocationFlags allocFlags = TextureAllocationFlags::ALLOC_DEFAULT; - if (StaticPrefs::PDMWMFUseSyncTexture() || + if (gfxPrefs::PDMWMFUseSyncTexture() || mDevice == DeviceManagerDx::Get()->GetCompositorDevice()) { // If our device is the compositor device, we don't need any synchronization // in practice. diff --git a/gfx/layers/FrameMetrics.cpp b/gfx/layers/FrameMetrics.cpp index f5fc646b2d96d..14bb9df0953e6 100644 --- a/gfx/layers/FrameMetrics.cpp +++ b/gfx/layers/FrameMetrics.cpp @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "FrameMetrics.h" - +#include "gfxPrefs.h" #include "nsStyleConsts.h" #include "nsStyleStruct.h" #include "mozilla/WritingModes.h" diff --git a/gfx/layers/FrameMetrics.h b/gfx/layers/FrameMetrics.h index 1f41fead19cfd..803c335ca9abb 100644 --- a/gfx/layers/FrameMetrics.h +++ b/gfx/layers/FrameMetrics.h @@ -987,7 +987,7 @@ struct ScrollMetadata { mIsAutoDirRootContentRTL = aValue; } bool IsAutoDirRootContentRTL() const { return mIsAutoDirRootContentRTL; } - // Implemented out of line because the implementation needs StaticPrefs.h + // Implemented out of line because the implementation needs gfxPrefs.h // and we don't want to include that from FrameMetrics.h. void SetUsesContainerScrolling(bool aValue); bool UsesContainerScrolling() const { return mUsesContainerScrolling; } diff --git a/gfx/layers/LayerScope.cpp b/gfx/layers/LayerScope.cpp index c78b237801b54..f76bb9a0ae037 100644 --- a/gfx/layers/LayerScope.cpp +++ b/gfx/layers/LayerScope.cpp @@ -21,7 +21,7 @@ #include "gfxContext.h" #include "gfxUtils.h" - +#include "gfxPrefs.h" #include "nsIWidget.h" #include "GLContext.h" @@ -1420,7 +1420,7 @@ LayerScopeWebSocketManager::LayerScopeWebSocketManager() NS_NewNamedThread("LayerScope", getter_AddRefs(mDebugSenderThread)); mServerSocket = do_CreateInstance(NS_SERVERSOCKET_CONTRACTID); - int port = StaticPrefs::LayerScopePort(); + int port = gfxPrefs::LayerScopePort(); mServerSocket->Init(port, false, -1); mServerSocket->AsyncListen(new SocketListener); } @@ -1465,7 +1465,7 @@ NS_IMETHODIMP LayerScopeWebSocketManager::SocketListener::OnSocketAccepted( // ---------------------------------------------- /*static*/ void LayerScope::Init() { - if (!StaticPrefs::LayerScopeEnabled() || XRE_IsGPUProcess()) { + if (!gfxPrefs::LayerScopeEnabled() || XRE_IsGPUProcess()) { return; } @@ -1563,7 +1563,7 @@ bool LayerScope::CheckSendable() { // Only compositor threads check LayerScope status MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread() || gIsGtest); - if (!StaticPrefs::LayerScopeEnabled()) { + if (!gfxPrefs::LayerScopeEnabled()) { return false; } if (!gLayerScopeManager.GetSocketManager()) { diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index 6d56e1347d14b..7dff51dfb456d 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -17,11 +17,11 @@ #include "UnitTransforms.h" // for ViewAs #include "gfxEnv.h" #include "gfxPlatform.h" // for gfxPlatform +#include "gfxPrefs.h" #include "gfxUtils.h" // for gfxUtils, etc #include "gfx2DGlue.h" #include "mozilla/DebugOnly.h" // for DebugOnly #include "mozilla/IntegerPrintfMacros.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Telemetry.h" // for Accumulate #include "mozilla/ToString.h" #include "mozilla/gfx/2D.h" // for DrawTarget @@ -139,7 +139,7 @@ already_AddRefed LayerManager::CreateImageContainer( } bool LayerManager::AreComponentAlphaLayersEnabled() { - return StaticPrefs::ComponentAlphaEnabled(); + return gfxPrefs::ComponentAlphaEnabled(); } /*static*/ diff --git a/gfx/layers/PaintThread.cpp b/gfx/layers/PaintThread.cpp index fafbe83eaa646..3ee7c86760eac 100644 --- a/gfx/layers/PaintThread.cpp +++ b/gfx/layers/PaintThread.cpp @@ -10,13 +10,13 @@ #include "base/task.h" #include "gfxPlatform.h" +#include "gfxPrefs.h" #include "GeckoProfiler.h" #include "mozilla/layers/CompositorBridgeChild.h" #include "mozilla/layers/ShadowLayers.h" #include "mozilla/layers/SyncObject.h" #include "mozilla/gfx/2D.h" #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/SharedThreadPool.h" #include "mozilla/SyncRunnable.h" #include "nsIPropertyBag2.h" @@ -48,7 +48,7 @@ void PaintThread::AddRef() {} /* static */ int32_t PaintThread::CalculatePaintWorkerCount() { int32_t cpuCores = PR_GetNumberOfProcessors(); - int32_t workerCount = StaticPrefs::LayersOMTPPaintWorkers(); + int32_t workerCount = gfxPrefs::LayersOMTPPaintWorkers(); // If not manually specified, default to (cpuCores * 3) / 4, and clamp // between 1 and 4. If a user wants more, they can manually specify it @@ -162,7 +162,7 @@ void PaintThread::QueuePaintTask(UniquePtr&& aTask) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aTask); - if (StaticPrefs::LayersOMTPDumpCapture() && aTask->mCapture) { + if (gfxPrefs::LayersOMTPDumpCapture() && aTask->mCapture) { aTask->mCapture->Dump(); } @@ -207,7 +207,7 @@ void PaintThread::AsyncPaintTask(CompositorBridgeChild* aBridge, target->Flush(); } - if (StaticPrefs::LayersOMTPReleaseCaptureOnMainThread()) { + if (gfxPrefs::LayersOMTPReleaseCaptureOnMainThread()) { // This should ensure the capture drawtarget, which may hold on to // UnscaledFont objects, gets destroyed on the main thread (See bug // 1404742). This assumes (unflushed) target DrawTargets do not themselves diff --git a/gfx/layers/RotatedBuffer.cpp b/gfx/layers/RotatedBuffer.cpp index 74a54ece8fa0f..8059029f5d8ea 100644 --- a/gfx/layers/RotatedBuffer.cpp +++ b/gfx/layers/RotatedBuffer.cpp @@ -12,6 +12,7 @@ #include "GeckoProfiler.h" // for AUTO_PROFILER_LABEL #include "Layers.h" // for PaintedLayer, Layer, etc #include "gfxPlatform.h" // for gfxPlatform +#include "gfxPrefs.h" // for gfxPrefs #include "gfxUtils.h" // for gfxUtils #include "mozilla/ArrayUtils.h" // for ArrayLength #include "mozilla/gfx/BasePoint.h" // for BasePoint @@ -24,7 +25,6 @@ #include "mozilla/layers/ShadowLayers.h" // for ShadowableLayer #include "mozilla/layers/TextureClient.h" // for TextureClient #include "mozilla/Move.h" // for Move -#include "mozilla/StaticPrefs.h" // for StaticPrefs #include "mozilla/gfx/Point.h" // for IntSize #include "gfx2DGlue.h" #include "nsLayoutUtils.h" // for invalidation debugging @@ -76,7 +76,7 @@ void RotatedBuffer::BeginCapture() { MOZ_ASSERT(!mCapture); MOZ_ASSERT(target); mCapture = Factory::CreateCaptureDrawTargetForTarget( - target, StaticPrefs::LayersOMTPCaptureLimit()); + target, gfxPrefs::LayersOMTPCaptureLimit()); } RefPtr RotatedBuffer::EndCapture() { diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index bc7168d47e6ec..45bf8bf2c1503 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -10,6 +10,7 @@ #include "AsyncPanZoomController.h" #include "Compositor.h" // for Compositor #include "DragTracker.h" // for DragTracker +#include "gfxPrefs.h" // for gfxPrefs #include "GenericFlingAnimation.h" // for FLING_LOG #include "HitTestingTreeNode.h" // for HitTestingTreeNode #include "InputBlockState.h" // for InputBlockState @@ -36,9 +37,8 @@ #include "mozilla/layers/WebRenderScrollDataWrapper.h" #include "mozilla/MouseEvents.h" #include "mozilla/mozalloc.h" // for operator new -#include "mozilla/Preferences.h" // for Preferences -#include "mozilla/StaticPrefs.h" // for StaticPrefs #include "mozilla/TouchEvents.h" +#include "mozilla/Preferences.h" // for Preferences #include "mozilla/EventStateManager.h" // for WheelPrefs #include "mozilla/webrender/WebRenderAPI.h" #include "nsDebug.h" // for NS_WARNING @@ -272,7 +272,7 @@ APZCTreeManager::APZCTreeManager(LayersId aRootLayersId) "layers::APZCTreeManager::APZCTreeManager", [self] { self->mFlushObserver = new CheckerboardFlushObserver(self); })); AsyncPanZoomController::InitializeGlobalState(); - mApzcTreeLog.ConditionOnPrefFunction(StaticPrefs::APZPrintTree); + mApzcTreeLog.ConditionOnPrefFunction(gfxPrefs::APZPrintTree); #if defined(MOZ_WIDGET_ANDROID) if (jni::IsFennec()) { mToolbarAnimator = new AndroidDynamicToolbarAnimator(this); @@ -369,7 +369,7 @@ APZCTreeManager::UpdateHitTestingTreeImpl(LayersId aRootLayerTreeId, // For testing purposes, we log some data to the APZTestData associated with // the layers id that originated this update. APZTestData* testData = nullptr; - if (StaticPrefs::APZTestLoggingEnabled()) { + if (gfxPrefs::APZTestLoggingEnabled()) { MutexAutoLock lock(mTestDataLock); UniquePtr ptr = MakeUnique(); auto result = mTestData.insert( @@ -604,7 +604,7 @@ void APZCTreeManager::UpdateFocusState(LayersId aRootLayerTreeId, const FocusTarget& aFocusTarget) { AssertOnUpdaterThread(); - if (!StaticPrefs::APZKeyboardEnabled()) { + if (!gfxPrefs::APZKeyboardEnabled()) { return; } @@ -1306,7 +1306,7 @@ nsEventStatus APZCTreeManager::ReceiveInputEvent( } if (apzc) { - if (StaticPrefs::APZTestLoggingEnabled() && + if (gfxPrefs::APZTestLoggingEnabled() && mouseInput.mType == MouseInput::MOUSE_HITTEST) { ScrollableLayerGuid guid = apzc->GetGuid(); @@ -1318,7 +1318,7 @@ nsEventStatus APZCTreeManager::ReceiveInputEvent( } TargetConfirmationFlags confFlags{hitResult}; - bool apzDragEnabled = StaticPrefs::APZDragEnabled(); + bool apzDragEnabled = gfxPrefs::APZDragEnabled(); if (apzDragEnabled && hitScrollbar) { // If scrollbar dragging is enabled and we hit a scrollbar, wait // for the main-thread confirmation because it contains drag metrics @@ -1543,8 +1543,8 @@ nsEventStatus APZCTreeManager::ReceiveInputEvent( case KEYBOARD_INPUT: { // Disable async keyboard scrolling when accessibility.browsewithcaret is // enabled - if (!StaticPrefs::APZKeyboardEnabled() || - StaticPrefs::AccessibilityBrowseWithCaret()) { + if (!gfxPrefs::APZKeyboardEnabled() || + gfxPrefs::AccessibilityBrowseWithCaret()) { APZ_KEY_LOG("Skipping key input from invalid prefs\n"); return result; } @@ -1740,7 +1740,7 @@ nsEventStatus APZCTreeManager::ProcessTouchInput( // checked are similar to the ones we check for MOUSE_INPUT starting // a scrollbar mouse-drag. mInScrollbarTouchDrag = - StaticPrefs::APZDragEnabled() && StaticPrefs::APZTouchDragEnabled() && + gfxPrefs::APZDragEnabled() && gfxPrefs::APZTouchDragEnabled() && hitScrollbarNode && hitScrollbarNode->IsScrollThumbNode() && hitScrollbarNode->GetScrollbarData().mThumbIsAsyncDraggable; @@ -1923,7 +1923,7 @@ void APZCTreeManager::SetupScrollbarDrag( // Under some conditions, we can confirm the drag block right away. // Otherwise, we have to wait for a main-thread confirmation. - if (StaticPrefs::APZDragInitiationEnabled() && + if (gfxPrefs::APZDragInitiationEnabled() && // check that the scrollbar's target scroll frame is layerized aScrollThumbNode->GetScrollTargetId() == aApzc->GetGuid().mScrollId && !aApzc->IsScrollInfoLayer()) { @@ -2387,7 +2387,7 @@ ParentLayerPoint APZCTreeManager::DispatchFling( AsyncPanZoomController* aPrev, const FlingHandoffState& aHandoffState) { // If immediate handoff is disallowed, do not allow handoff beyond the // single APZC that's scrolled by the input block that triggered this fling. - if (aHandoffState.mIsHandoff && !StaticPrefs::APZAllowImmediateHandoff() && + if (aHandoffState.mIsHandoff && !gfxPrefs::APZAllowImmediateHandoff() && aHandoffState.mScrolledApzc == aPrev) { FLING_LOG("APZCTM dropping handoff due to disallowed immediate handoff\n"); return aHandoffState.mVelocity; @@ -3294,8 +3294,7 @@ LayerToParentLayerMatrix4x4 APZCTreeManager::ComputeTransformForScrollThumb( // With container scrolling, the RCD-RSF scrollbars are subject to the // content resolution, which requires some special handling. bool scrollbarSubjectToResolution = - aMetrics.IsRootContent() && - StaticPrefs::LayoutUseContainersForRootFrames(); + aMetrics.IsRootContent() && gfxPrefs::LayoutUseContainersForRootFrames(); // |asyncTransform| represents the amount by which we have scrolled and // zoomed since the last paint. Because the scrollbar was sized and positioned diff --git a/gfx/layers/apz/src/APZInputBridge.cpp b/gfx/layers/apz/src/APZInputBridge.cpp index dc2f2202c3ce5..7b6c14c855fab 100644 --- a/gfx/layers/apz/src/APZInputBridge.cpp +++ b/gfx/layers/apz/src/APZInputBridge.cpp @@ -6,6 +6,7 @@ #include "mozilla/layers/APZInputBridge.h" +#include "gfxPrefs.h" // for gfxPrefs #include "InputData.h" // for MouseInput, etc #include "mozilla/dom/WheelEventBinding.h" // for WheelEvent constants #include "mozilla/EventStateManager.h" // for EventStateManager @@ -22,7 +23,7 @@ namespace layers { static bool WillHandleMouseEvent(const WidgetMouseEventBase& aEvent) { return aEvent.mMessage == eMouseMove || aEvent.mMessage == eMouseDown || aEvent.mMessage == eMouseUp || aEvent.mMessage == eDragEnd || - (StaticPrefs::TestEventsAsyncEnabled() && + (gfxPrefs::TestEventsAsyncEnabled() && aEvent.mMessage == eMouseHitTest); } @@ -65,7 +66,7 @@ nsEventStatus APZInputBridge::ReceiveInputEvent( // hit testing in a zoomed-in or zoomed-out state. // FIXME: bug 1525793 -- this may need to handle zooming or not on a // per-document basis. - if (StaticPrefs::APZAllowZooming()) { + if (gfxPrefs::APZAllowZooming()) { mouseEvent.mIgnoreRootScrollFrame = true; } @@ -115,13 +116,13 @@ nsEventStatus APZInputBridge::ReceiveInputEvent( if (Maybe action = ActionForWheelEvent(&wheelEvent)) { ScrollWheelInput::ScrollMode scrollMode = ScrollWheelInput::SCROLLMODE_INSTANT; - if (StaticPrefs::SmoothScrollEnabled() && + if (gfxPrefs::SmoothScrollEnabled() && ((wheelEvent.mDeltaMode == dom::WheelEvent_Binding::DOM_DELTA_LINE && - StaticPrefs::WheelSmoothScrollEnabled()) || + gfxPrefs::WheelSmoothScrollEnabled()) || (wheelEvent.mDeltaMode == dom::WheelEvent_Binding::DOM_DELTA_PAGE && - StaticPrefs::PageSmoothScrollEnabled()))) { + gfxPrefs::PageSmoothScrollEnabled()))) { scrollMode = ScrollWheelInput::SCROLLMODE_SMOOTH; } diff --git a/gfx/layers/apz/src/AndroidAPZ.cpp b/gfx/layers/apz/src/AndroidAPZ.cpp index f47e8ea9d2176..23823ff41a23b 100644 --- a/gfx/layers/apz/src/AndroidAPZ.cpp +++ b/gfx/layers/apz/src/AndroidAPZ.cpp @@ -11,10 +11,10 @@ #include "AsyncPanZoomController.h" #include "GeneratedJNIWrappers.h" #include "GenericFlingAnimation.h" +#include "gfxPrefs.h" #include "OverscrollHandoffState.h" #include "SimpleVelocityTracker.h" #include "ViewConfiguration.h" -#include "mozilla/StaticPrefs.h" #define ANDROID_APZ_LOG(...) // #define ANDROID_APZ_LOG(...) printf_stderr("ANDROID_APZ: " __VA_ARGS__) @@ -55,7 +55,7 @@ AndroidSpecificState::AndroidSpecificState() { AsyncPanZoomAnimation* AndroidSpecificState::CreateFlingAnimation( AsyncPanZoomController& aApzc, const FlingHandoffState& aHandoffState, float aPLPPI) { - if (StaticPrefs::APZUseChromeFlingPhysics()) { + if (gfxPrefs::APZUseChromeFlingPhysics()) { return new GenericFlingAnimation( aApzc, aHandoffState.mChain, aHandoffState.mIsHandoff, aHandoffState.mScrolledApzc, aPLPPI); @@ -68,7 +68,7 @@ AsyncPanZoomAnimation* AndroidSpecificState::CreateFlingAnimation( UniquePtr AndroidSpecificState::CreateVelocityTracker( Axis* aAxis) { - if (StaticPrefs::APZUseChromeFlingPhysics()) { + if (gfxPrefs::APZUseChromeFlingPhysics()) { return MakeUnique(); } return MakeUnique(aAxis); @@ -76,7 +76,7 @@ UniquePtr AndroidSpecificState::CreateVelocityTracker( /* static */ void AndroidSpecificState::InitializeGlobalState() { - // Not conditioned on StaticPrefs::APZUseChromeFlingPhysics() because + // Not conditioned on gfxPrefs::APZUseChromeFlingPhysics() because // the pref is live. AndroidFlingPhysics::InitializeGlobalState(); } @@ -167,8 +167,8 @@ StackScrollerFlingAnimation::StackScrollerFlingAnimation( // flywheel to kick in, then we need to update the timestamp on the // StackScroller because otherwise it might use a stale velocity. TimeDuration flingDuration = TimeStamp::Now() - state->mLastFling; - if (flingDuration.ToMilliseconds() < StaticPrefs::APZFlingAccelInterval() && - velocity.Length() >= StaticPrefs::APZFlingAccelMinVelocity()) { + if (flingDuration.ToMilliseconds() < gfxPrefs::APZFlingAccelInterval() && + velocity.Length() >= gfxPrefs::APZFlingAccelMinVelocity()) { bool unused = false; mOverScroller->ComputeScrollOffset(flingDuration.ToMilliseconds(), &unused); @@ -242,9 +242,8 @@ bool StackScrollerFlingAnimation::DoSample(FrameMetrics& aFrameMetrics, float speed = velocity.Length(); - // StaticPrefs::APZFlingStoppedThreshold is only used in tests. - if (!shouldContinueFling || - (speed < StaticPrefs::APZFlingStoppedThreshold())) { + // gfxPrefs::APZFlingStoppedThreshold is only used in tests. + if (!shouldContinueFling || (speed < gfxPrefs::APZFlingStoppedThreshold())) { if (shouldContinueFling) { // The OverScroller thinks it should continue but the speed is below // the stopping threshold so abort the animation. diff --git a/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp b/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp index ce6a61d662f37..8794b9f164944 100644 --- a/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp +++ b/gfx/layers/apz/src/AndroidDynamicToolbarAnimator.cpp @@ -10,6 +10,7 @@ #include "APZCTreeManager.h" #include "FrameMetrics.h" +#include "gfxPrefs.h" #include "mozilla/EventForwards.h" #include "mozilla/FloatingPoint.h" #include "mozilla/gfx/2D.h" @@ -23,7 +24,6 @@ #include "mozilla/layers/UiCompositorControllerParent.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/Move.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Unused.h" namespace { @@ -200,10 +200,10 @@ nsEventStatus AndroidDynamicToolbarAnimator::ReceiveInputEvent( } mControllerLastDragDirection = direction; } - // NOTE: StaticPrefs::ToolbarScrollThreshold() returns a percentage as - // an int32_t. So multiply it by 0.01f to convert. + // NOTE: gfxPrefs::ToolbarScrollThreshold() returns a percentage as an + // int32_t. So multiply it by 0.01f to convert. const uint32_t dragThreshold = - Abs(std::lround(0.01f * StaticPrefs::ToolbarScrollThreshold() * + Abs(std::lround(0.01f * gfxPrefs::ToolbarScrollThreshold() * mControllerCompositionHeight)); if ((Abs(mControllerTotalDistance.value) > dragThreshold) && (delta != 0)) { diff --git a/gfx/layers/apz/src/AndroidFlingPhysics.cpp b/gfx/layers/apz/src/AndroidFlingPhysics.cpp index 67e47d2934200..3db453dda7ef3 100644 --- a/gfx/layers/apz/src/AndroidFlingPhysics.cpp +++ b/gfx/layers/apz/src/AndroidFlingPhysics.cpp @@ -9,7 +9,6 @@ #include #include "mozilla/ClearOnShutdown.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/StaticPtr.h" namespace mozilla { @@ -33,7 +32,7 @@ const float kDecelerationRate = 2.3582018f; // Default friction constant in android.view.ViewConfiguration. static float GetFlingFriction() { - return StaticPrefs::APZChromeFlingPhysicsFriction(); + return gfxPrefs::APZChromeFlingPhysicsFriction(); } // Tension lines cross at (GetInflexion(), 1). @@ -41,7 +40,7 @@ static float GetInflexion() { // Clamp the inflexion to the range [0,1]. Values outside of this range // do not make sense in the physics model, and for negative values the // approximation used to compute the spline curve does not converge. - const float inflexion = StaticPrefs::APZChromeFlingPhysicsInflexion(); + const float inflexion = gfxPrefs::APZChromeFlingPhysicsInflexion(); if (inflexion < 0.0f) { return 0.0f; } @@ -54,7 +53,7 @@ static float GetInflexion() { // Fling scroll is stopped when the scroll position is |kThresholdForFlingEnd| // pixels or closer from the end. static float GetThresholdForFlingEnd() { - return StaticPrefs::APZChromeFlingPhysicsStopThreshold(); + return gfxPrefs::APZChromeFlingPhysicsStopThreshold(); } static double ComputeSplineDeceleration(ParentLayerCoord aVelocity, diff --git a/gfx/layers/apz/src/AndroidFlingPhysics.h b/gfx/layers/apz/src/AndroidFlingPhysics.h index 68fb53e8047fe..0f6157b1c4c86 100644 --- a/gfx/layers/apz/src/AndroidFlingPhysics.h +++ b/gfx/layers/apz/src/AndroidFlingPhysics.h @@ -9,6 +9,7 @@ #include "AsyncPanZoomController.h" #include "Units.h" +#include "gfxPrefs.h" #include "mozilla/Assertions.h" namespace mozilla { diff --git a/gfx/layers/apz/src/AndroidVelocityTracker.cpp b/gfx/layers/apz/src/AndroidVelocityTracker.cpp index 2fb082d4d8d83..5e6737edc0361 100644 --- a/gfx/layers/apz/src/AndroidVelocityTracker.cpp +++ b/gfx/layers/apz/src/AndroidVelocityTracker.cpp @@ -6,7 +6,7 @@ #include "AndroidVelocityTracker.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" namespace mozilla { namespace layers { @@ -251,7 +251,7 @@ Maybe AndroidVelocityTracker::ComputeVelocity(uint32_t aTimestampMs) { float time[kHistorySize]; uint32_t m = 0; int index = mHistory.Length() - 1; - const uint32_t horizon = StaticPrefs::APZVelocityRelevanceTime(); + const uint32_t horizon = gfxPrefs::APZVelocityRelevanceTime(); const auto& newest_movement = mHistory[index]; do { diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index b3df8cc56141c..cd9f6995b9926 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -33,7 +33,7 @@ #include "UnitTransforms.h" // for TransformTo #include "base/message_loop.h" // for MessageLoop #include "base/task.h" // for NewRunnableMethod, etc -#include "mozilla/StaticPrefs.h" // for StaticPrefs +#include "gfxPrefs.h" // for gfxPrefs #include "gfxTypes.h" // for gfxFloat #include "LayersLogging.h" // for print_stderr #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc @@ -46,7 +46,6 @@ #include "mozilla/Preferences.h" // for Preferences #include "mozilla/RecursiveMutex.h" // for RecursiveMutexAutoLock, etc #include "mozilla/RefPtr.h" // for RefPtr -#include "mozilla/StaticPrefs.h" // for StaticPrefs #include "mozilla/StaticPtr.h" // for StaticAutoPtr #include "mozilla/Telemetry.h" // for Telemetry #include "mozilla/TimeStamp.h" // for TimeDuration, TimeStamp @@ -132,7 +131,7 @@ typedef PlatformSpecificStateBase * \page APZCPrefs APZ preferences * * The following prefs are used to control the behaviour of the APZC. - * The default values are provided in StaticPrefs.h. + * The default values are provided in gfxPrefs.h. * * \li\b apz.allow_double_tap_zooming * Pref that allows or disallows double tap to zoom @@ -615,7 +614,7 @@ class ZoomAnimation : public AsyncPanZoomAnimation { const CSSToParentLayerScale2D& aEndZoom) : mApzc(aApzc), mTotalDuration(TimeDuration::FromMilliseconds( - StaticPrefs::APZZoomAnimationDuration())), + gfxPrefs::APZZoomAnimationDuration())), mStartOffset(aStartOffset), mStartZoom(aStartZoom), mEndOffset(aEndOffset), @@ -816,8 +815,8 @@ void AsyncPanZoomController::InitializeGlobalState() { new ComputedTimingFunction(nsTimingFunction(StyleTimingKeyword::Ease)); ClearOnShutdown(&gZoomAnimationFunction); gVelocityCurveFunction = new ComputedTimingFunction(nsTimingFunction( - StaticPrefs::APZCurveFunctionX1(), StaticPrefs::APZCurveFunctionY1(), - StaticPrefs::APZCurveFunctionX2(), StaticPrefs::APZCurveFunctionY2())); + gfxPrefs::APZCurveFunctionX1(), gfxPrefs::APZCurveFunctionY1(), + gfxPrefs::APZCurveFunctionX2(), gfxPrefs::APZCurveFunctionY2())); ClearOnShutdown(&gVelocityCurveFunction); uint64_t sysmem = PR_GetPhysicalMemorySize(); @@ -844,8 +843,8 @@ AsyncPanZoomController::AsyncPanZoomController( mY(this), mPanDirRestricted(false), mPinchLocked(false), - mPinchEventBuffer(TimeDuration::FromMilliseconds( - StaticPrefs::APZPinchLockBufferMaxAge())), + mPinchEventBuffer( + TimeDuration::FromMilliseconds(gfxPrefs::APZPinchLockBufferMaxAge())), mZoomConstraints(false, false, mScrollMetadata.GetMetrics().GetDevPixelsPerCSSPixel() * kViewportMinScale / ParentLayerToScreenScale(1), @@ -938,25 +937,25 @@ float AsyncPanZoomController::GetDPI() const { } ScreenCoord AsyncPanZoomController::GetTouchStartTolerance() const { - return (StaticPrefs::APZTouchStartTolerance() * GetDPI()); + return (gfxPrefs::APZTouchStartTolerance() * GetDPI()); } ScreenCoord AsyncPanZoomController::GetTouchMoveTolerance() const { - return (StaticPrefs::APZTouchMoveTolerance() * GetDPI()); + return (gfxPrefs::APZTouchMoveTolerance() * GetDPI()); } ScreenCoord AsyncPanZoomController::GetSecondTapTolerance() const { - return (StaticPrefs::APZSecondTapTolerance() * GetDPI()); + return (gfxPrefs::APZSecondTapTolerance() * GetDPI()); } /* static */ AsyncPanZoomController::AxisLockMode AsyncPanZoomController::GetAxisLockMode() { - return static_cast(StaticPrefs::APZAxisLockMode()); + return static_cast(gfxPrefs::APZAxisLockMode()); } /* static */ AsyncPanZoomController::PinchLockMode AsyncPanZoomController::GetPinchLockMode() { - return static_cast(StaticPrefs::APZPinchLockMode()); + return static_cast(gfxPrefs::APZPinchLockMode()); } bool AsyncPanZoomController::ArePointerEventsConsumable( @@ -1012,7 +1011,7 @@ bool AsyncPanZoomController::ArePointerEventsConsumable( nsEventStatus AsyncPanZoomController::HandleDragEvent( const MouseInput& aEvent, const AsyncDragMetrics& aDragMetrics, CSSCoord aInitialThumbPos) { - if (!StaticPrefs::APZDragEnabled()) { + if (!gfxPrefs::APZDragEnabled()) { return nsEventStatus_eIgnore; } @@ -1052,7 +1051,7 @@ nsEventStatus AsyncPanZoomController::HandleDragEvent( ScrollDirection direction = *scrollbarData.mDirection; bool isMouseAwayFromThumb = false; - if (int snapMultiplier = StaticPrefs::SliderSnapMultiplier()) { + if (int snapMultiplier = gfxPrefs::SliderSnapMultiplier()) { // It's fine to ignore the async component of the thumb's transform, // because any async transform of the thumb will be in the direction of // scrolling, but here we're interested in the other direction. @@ -1405,7 +1404,7 @@ nsEventStatus AsyncPanZoomController::OnTouchMove( } MOZ_ASSERT(GetCurrentTouchBlock()); - if (StaticPrefs::TouchActionEnabled() && + if (gfxPrefs::TouchActionEnabled() && GetCurrentTouchBlock()->TouchActionAllowsPanningXY()) { // User tries to trigger a touch behavior. If allowed touch behavior is // vertical pan @@ -1566,7 +1565,7 @@ nsEventStatus AsyncPanZoomController::OnScaleBegin( // content controller, it may want to do something else with this gesture. // FIXME: bug 1525793 -- this may need to handle zooming or not on a // per-document basis. - if (!StaticPrefs::APZAllowZooming()) { + if (!gfxPrefs::APZAllowZooming()) { if (RefPtr controller = GetGeckoContentController()) { controller->NotifyPinchGesture(aEvent.mType, GetGuid(), 0, @@ -1613,7 +1612,7 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) { // FIXME: bug 1525793 -- this may need to handle zooming or not on a // per-document basis. - if (!StaticPrefs::APZAllowZooming()) { + if (!gfxPrefs::APZAllowZooming()) { if (RefPtr controller = GetGeckoContentController()) { controller->NotifyPinchGesture( @@ -1703,7 +1702,7 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) { // We don't want to redraw on every scale, so throttle it. if (!mPinchPaintTimerSet) { - const int delay = StaticPrefs::APZScaleRepaintDelay(); + const int delay = gfxPrefs::APZScaleRepaintDelay(); if (delay >= 0) { if (RefPtr controller = GetGeckoContentController()) { @@ -1747,7 +1746,7 @@ nsEventStatus AsyncPanZoomController::OnScaleEnd( // FIXME: bug 1525793 -- this may need to handle zooming or not on a // per-document basis. - if (!StaticPrefs::APZAllowZooming()) { + if (!gfxPrefs::APZAllowZooming()) { if (RefPtr controller = GetGeckoContentController()) { controller->NotifyPinchGesture(aEvent.mType, GetGuid(), 0, @@ -1840,9 +1839,9 @@ nsEventStatus AsyncPanZoomController::HandleEndOfPan() { APZC_LOG("%p starting a fling animation if %f >= %f\n", this, flingVelocity.Length().value, - StaticPrefs::APZFlingMinVelocityThreshold()); + gfxPrefs::APZFlingMinVelocityThreshold()); - if (flingVelocity.Length() < StaticPrefs::APZFlingMinVelocityThreshold()) { + if (flingVelocity.Length() < gfxPrefs::APZFlingMinVelocityThreshold()) { // Relieve overscroll now if needed, since we will not transition to a fling // animation and then an overscroll animation, and relieve it then. GetCurrentInputBlock() @@ -1961,7 +1960,7 @@ ParentLayerPoint AsyncPanZoomController::GetScrollWheelDelta( // EventStateManager::DeltaAccumulator::ComputeScrollAmountForDefaultAction // and WheelTransaction::OverrideSystemScrollSpeed. Note that we do *not* // restrict this to the root content, see bug 1217715 for discussion on this. - if (StaticPrefs::MouseWheelHasRootScrollDeltaOverride() && + if (gfxPrefs::MouseWheelHasRootScrollDeltaOverride() && !aEvent.IsCustomizedByUserPrefs() && aEvent.mDeltaType == ScrollWheelInput::SCROLLDELTA_LINE && aEvent.mAllowToOverrideSystemScrollSpeed) { @@ -1973,9 +1972,9 @@ ParentLayerPoint AsyncPanZoomController::GetScrollWheelDelta( // it might need extra acceleration. See WheelHandlingHelper.cpp. if (aEvent.mDeltaType == ScrollWheelInput::SCROLLDELTA_LINE && aEvent.mScrollSeriesNumber > 0) { - int32_t start = StaticPrefs::MouseWheelAccelerationStart(); + int32_t start = gfxPrefs::MouseWheelAccelerationStart(); if (start >= 0 && aEvent.mScrollSeriesNumber >= uint32_t(start)) { - int32_t factor = StaticPrefs::MouseWheelAccelerationFactor(); + int32_t factor = gfxPrefs::MouseWheelAccelerationFactor(); if (factor > 0) { delta.x = ComputeAcceleratedWheelDelta( delta.x, aEvent.mScrollSeriesNumber, factor); @@ -2009,7 +2008,7 @@ nsEventStatus AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent) { MaybeAdjustDestinationForScrollSnapping(aEvent, destination); // If smooth scrolling is disabled, then scroll immediately to the destination - if (!StaticPrefs::SmoothScrollEnabled()) { + if (!gfxPrefs::SmoothScrollEnabled()) { CancelAnimation(); // CallDispatchScroll interprets the start and end points as the start and @@ -2109,7 +2108,7 @@ CSSPoint AsyncPanZoomController::GetKeyboardDestination( switch (aAction.mType) { case KeyboardScrollAction::eScrollCharacter: { - int32_t scrollDistance = StaticPrefs::ToolkitHorizontalScrollDistance(); + int32_t scrollDistance = gfxPrefs::ToolkitHorizontalScrollDistance(); if (aAction.mForward) { scrollDestination.x += scrollDistance * lineScrollSize.width; @@ -2119,7 +2118,7 @@ CSSPoint AsyncPanZoomController::GetKeyboardDestination( break; } case KeyboardScrollAction::eScrollLine: { - int32_t scrollDistance = StaticPrefs::ToolkitVerticalScrollDistance(); + int32_t scrollDistance = gfxPrefs::ToolkitVerticalScrollDistance(); if (aAction.mForward) { scrollDestination.y += scrollDistance * lineScrollSize.height; @@ -2254,7 +2253,7 @@ bool AsyncPanZoomController::IsContentOfHonouredTargetRightToLeft( bool AsyncPanZoomController::AllowScrollHandoffInCurrentBlock() const { bool result = mInputQueue->AllowScrollHandoff(); - if (!StaticPrefs::APZAllowImmediateHandoff()) { + if (!gfxPrefs::APZAllowImmediateHandoff()) { if (InputBlockState* currentBlock = GetCurrentInputBlock()) { // Do not allow handoff beyond the first APZC to scroll. if (currentBlock->GetScrolledApzc() == this) { @@ -2339,7 +2338,7 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel( } else if ((delta.x || delta.y) && !CanScrollWithWheel(delta)) { // We can't scroll this apz anymore, so we simply drop the event. if (mInputQueue->GetActiveWheelTransaction() && - StaticPrefs::MouseScrollTestingEnabled()) { + gfxPrefs::MouseScrollTestingEnabled()) { if (RefPtr controller = GetGeckoContentController()) { controller->NotifyMozMouseScrollEvent( @@ -2930,11 +2929,10 @@ void AsyncPanZoomController::HandlePanningWithTouchAction(double aAngle) { this, ScrollDirection::eVertical); if (GetCurrentTouchBlock()->TouchActionAllowsPanningXY()) { if (canScrollHorizontal && canScrollVertical) { - if (apz::IsCloseToHorizontal(aAngle, StaticPrefs::APZAxisLockAngle())) { + if (apz::IsCloseToHorizontal(aAngle, gfxPrefs::APZAxisLockAngle())) { mY.SetAxisLocked(true); SetState(PANNING_LOCKED_X); - } else if (apz::IsCloseToVertical(aAngle, - StaticPrefs::APZAxisLockAngle())) { + } else if (apz::IsCloseToVertical(aAngle, gfxPrefs::APZAxisLockAngle())) { mX.SetAxisLocked(true); SetState(PANNING_LOCKED_Y); } else { @@ -2949,7 +2947,7 @@ void AsyncPanZoomController::HandlePanningWithTouchAction(double aAngle) { // Using bigger angle for panning to keep behavior consistent // with IE. if (apz::IsCloseToHorizontal(aAngle, - StaticPrefs::APZAllowedDirectPanAngle())) { + gfxPrefs::APZAllowedDirectPanAngle())) { mY.SetAxisLocked(true); SetState(PANNING_LOCKED_X); mPanDirRestricted = true; @@ -2959,8 +2957,7 @@ void AsyncPanZoomController::HandlePanningWithTouchAction(double aAngle) { SetState(NOTHING); } } else if (GetCurrentTouchBlock()->TouchActionAllowsPanningY()) { - if (apz::IsCloseToVertical(aAngle, - StaticPrefs::APZAllowedDirectPanAngle())) { + if (apz::IsCloseToVertical(aAngle, gfxPrefs::APZAllowedDirectPanAngle())) { mX.SetAxisLocked(true); SetState(PANNING_LOCKED_Y); mPanDirRestricted = true; @@ -2993,13 +2990,12 @@ void AsyncPanZoomController::HandlePanning(double aAngle) { if (!canScrollHorizontal || !canScrollVertical) { SetState(PANNING); - } else if (apz::IsCloseToHorizontal(aAngle, - StaticPrefs::APZAxisLockAngle())) { + } else if (apz::IsCloseToHorizontal(aAngle, gfxPrefs::APZAxisLockAngle())) { mY.SetAxisLocked(true); if (canScrollHorizontal) { SetState(PANNING_LOCKED_X); } - } else if (apz::IsCloseToVertical(aAngle, StaticPrefs::APZAxisLockAngle())) { + } else if (apz::IsCloseToVertical(aAngle, gfxPrefs::APZAxisLockAngle())) { mX.SetAxisLocked(true); if (canScrollVertical) { SetState(PANNING_LOCKED_Y); @@ -3019,19 +3015,18 @@ void AsyncPanZoomController::HandlePanningUpdate( double angle = atan2(vector.y, vector.x); // range [-pi, pi] angle = fabs(angle); // range [0, pi] - float breakThreshold = StaticPrefs::APZAxisBreakoutThreshold() * GetDPI(); + float breakThreshold = gfxPrefs::APZAxisBreakoutThreshold() * GetDPI(); if (fabs(aPanDistance.x) > breakThreshold || fabs(aPanDistance.y) > breakThreshold) { if (mState == PANNING_LOCKED_X) { if (!apz::IsCloseToHorizontal(angle, - StaticPrefs::APZAxisBreakoutAngle())) { + gfxPrefs::APZAxisBreakoutAngle())) { mY.SetAxisLocked(false); SetState(PANNING); } } else if (mState == PANNING_LOCKED_Y) { - if (!apz::IsCloseToVertical(angle, - StaticPrefs::APZAxisBreakoutAngle())) { + if (!apz::IsCloseToVertical(angle, gfxPrefs::APZAxisBreakoutAngle())) { mX.SetAxisLocked(false); SetState(PANNING); } @@ -3075,15 +3070,15 @@ void AsyncPanZoomController::HandlePinchLocking() { if (mPinchLocked) { if (GetPinchLockMode() == PINCH_STICKY) { ScreenCoord spanBreakoutThreshold = - StaticPrefs::APZPinchLockSpanBreakoutThreshold() * GetDPI(); + gfxPrefs::APZPinchLockSpanBreakoutThreshold() * GetDPI(); mPinchLocked = !(spanDistance > spanBreakoutThreshold); } } else { if (GetPinchLockMode() != PINCH_FREE) { ScreenCoord spanLockThreshold = - StaticPrefs::APZPinchLockSpanLockThreshold() * GetDPI(); + gfxPrefs::APZPinchLockSpanLockThreshold() * GetDPI(); ScreenCoord scrollLockThreshold = - StaticPrefs::APZPinchLockScrollLockThreshold() * GetDPI(); + gfxPrefs::APZPinchLockScrollLockThreshold() * GetDPI(); if (spanDistance < spanLockThreshold && focusChange.Length() > scrollLockThreshold) { @@ -3101,7 +3096,7 @@ nsEventStatus AsyncPanZoomController::StartPanning( angle = fabs(angle); // range [0, pi] RecursiveMutexAutoLock lock(mRecursiveMutex); - if (StaticPrefs::TouchActionEnabled()) { + if (gfxPrefs::TouchActionEnabled()) { HandlePanningWithTouchAction(angle); } else { if (GetAxisLockMode() == FREE) { @@ -3256,12 +3251,10 @@ void AsyncPanZoomController::OverscrollForPanning( // that axis is greater than the pan distance along the other axis by a // configurable factor. If we are already overscrolled, don't check this. if (!IsOverscrolled()) { - if (aPanDistance.x < - StaticPrefs::APZMinPanDistanceRatio() * aPanDistance.y) { + if (aPanDistance.x < gfxPrefs::APZMinPanDistanceRatio() * aPanDistance.y) { aOverscroll.x = 0; } - if (aPanDistance.y < - StaticPrefs::APZMinPanDistanceRatio() * aPanDistance.x) { + if (aPanDistance.y < gfxPrefs::APZMinPanDistanceRatio() * aPanDistance.x) { aOverscroll.y = 0; } } @@ -3270,7 +3263,7 @@ void AsyncPanZoomController::OverscrollForPanning( } void AsyncPanZoomController::OverscrollBy(ParentLayerPoint& aOverscroll) { - if (!StaticPrefs::APZOverscrollEnabled()) { + if (!gfxPrefs::APZOverscrollEnabled()) { return; } @@ -3337,7 +3330,7 @@ ParentLayerPoint AsyncPanZoomController::AttemptFling( // that generate events faster than the clock resolution. ParentLayerPoint velocity = GetVelocityVector(); if (!velocity.IsFinite() || - velocity.Length() < StaticPrefs::APZFlingMinVelocityThreshold()) { + velocity.Length() < gfxPrefs::APZFlingMinVelocityThreshold()) { // Relieve overscroll now if needed, since we will not transition to a fling // animation and then an overscroll animation, and relieve it then. aHandoffState.mChain->SnapBackOverscrolledApzc(this); @@ -3408,7 +3401,7 @@ void AsyncPanZoomController::HandleFlingOverscroll( FLING_LOG("APZC %p left with residual velocity %s\n", this, Stringify(residualVelocity).c_str()); if (!IsZero(residualVelocity) && IsPannable() && - StaticPrefs::APZOverscrollEnabled()) { + gfxPrefs::APZOverscrollEnabled()) { // Obey overscroll-behavior. RecursiveMutexAutoLock lock(mRecursiveMutex); if (!mX.OverscrollBehaviorAllowsOverscrollEffect()) { @@ -3453,8 +3446,8 @@ void AsyncPanZoomController::SmoothScrollTo(const CSSPoint& aDestination) { StartAnimation(new SmoothScrollAnimation( *this, initialPosition, initialVelocity, destination, - StaticPrefs::ScrollBehaviorSpringConstant(), - StaticPrefs::ScrollBehaviorDampingRatio())); + gfxPrefs::ScrollBehaviorSpringConstant(), + gfxPrefs::ScrollBehaviorDampingRatio())); } } @@ -3665,23 +3658,21 @@ void AsyncPanZoomController::ScaleWithFocus(float aScale, */ static CSSSize CalculateDisplayPortSize(const CSSSize& aCompositionSize, const CSSPoint& aVelocity) { - bool xIsStationarySpeed = - fabsf(aVelocity.x) < StaticPrefs::APZMinSkateSpeed(); - bool yIsStationarySpeed = - fabsf(aVelocity.y) < StaticPrefs::APZMinSkateSpeed(); + bool xIsStationarySpeed = fabsf(aVelocity.x) < gfxPrefs::APZMinSkateSpeed(); + bool yIsStationarySpeed = fabsf(aVelocity.y) < gfxPrefs::APZMinSkateSpeed(); float xMultiplier = xIsStationarySpeed - ? StaticPrefs::APZXStationarySizeMultiplier() - : StaticPrefs::APZXSkateSizeMultiplier(); + ? gfxPrefs::APZXStationarySizeMultiplier() + : gfxPrefs::APZXSkateSizeMultiplier(); float yMultiplier = yIsStationarySpeed - ? StaticPrefs::APZYStationarySizeMultiplier() - : StaticPrefs::APZYSkateSizeMultiplier(); + ? gfxPrefs::APZYStationarySizeMultiplier() + : gfxPrefs::APZYSkateSizeMultiplier(); if (IsHighMemSystem() && !xIsStationarySpeed) { - xMultiplier += StaticPrefs::APZXSkateHighMemAdjust(); + xMultiplier += gfxPrefs::APZXSkateHighMemAdjust(); } if (IsHighMemSystem() && !yIsStationarySpeed) { - yMultiplier += StaticPrefs::APZYSkateHighMemAdjust(); + yMultiplier += gfxPrefs::APZYSkateHighMemAdjust(); } return aCompositionSize * CSSSize(xMultiplier, yMultiplier); @@ -3698,9 +3689,9 @@ static CSSSize ExpandDisplayPortToDangerZone( CSSSize dangerZone(0.0f, 0.0f); if (aFrameMetrics.LayersPixelsPerCSSPixel().xScale != 0 && aFrameMetrics.LayersPixelsPerCSSPixel().yScale != 0) { - dangerZone = LayerSize(StaticPrefs::APZDangerZoneX(), - StaticPrefs::APZDangerZoneY()) / - aFrameMetrics.LayersPixelsPerCSSPixel(); + dangerZone = + LayerSize(gfxPrefs::APZDangerZoneX(), gfxPrefs::APZDangerZoneY()) / + aFrameMetrics.LayersPixelsPerCSSPixel(); } const CSSSize compositionSize = aFrameMetrics.CalculateBoundedCompositedSizeInCssPixels(); @@ -3759,7 +3750,7 @@ const ScreenMargin AsyncPanZoomController::CalculatePendingDisplayPort( displayPortSize = ExpandDisplayPortToDangerZone(displayPortSize, aFrameMetrics); - if (StaticPrefs::APZEnlargeDisplayPortWhenClipped()) { + if (gfxPrefs::APZEnlargeDisplayPortWhenClipped()) { RedistributeDisplayPortExcess(displayPortSize, scrollableRect); } @@ -3778,7 +3769,7 @@ const ScreenMargin AsyncPanZoomController::CalculatePendingDisplayPort( // Offset the displayport, depending on how fast we're moving and the // estimated time it takes to paint, to try to minimise checkerboarding. float paintFactor = kDefaultEstimatedPaintDurationMs; - displayPort.MoveBy(velocity * paintFactor * StaticPrefs::APZVelocityBias()); + displayPort.MoveBy(velocity * paintFactor * gfxPrefs::APZVelocityBias()); APZC_LOG_FM( aFrameMetrics, @@ -3842,8 +3833,8 @@ bool AsyncPanZoomController::SnapBackIfOverscrolled() { bool AsyncPanZoomController::IsFlingingFast() const { RecursiveMutexAutoLock lock(mRecursiveMutex); - if (mState == FLING && GetVelocityVector().Length() > - StaticPrefs::APZFlingStopOnTapThreshold()) { + if (mState == FLING && + GetVelocityVector().Length() > gfxPrefs::APZFlingStopOnTapThreshold()) { APZC_LOG("%p is moving fast\n", this); return true; } @@ -4197,7 +4188,7 @@ AsyncPanZoomController::GetCurrentAsyncTransformForFixedAdjustment( // with apz.allow_zooming enabled). // FIXME: bug 1525793 -- this may need to handle zooming or not on a // per-document basis. - return (StaticPrefs::APZAllowZooming() && Metrics().IsRootContent() && + return (gfxPrefs::APZAllowZooming() && Metrics().IsRootContent() && Metrics().GetVisualViewport().Size() <= Metrics().GetLayoutViewport().Size()) ? GetCurrentAsyncViewportTransform(aMode) @@ -4225,7 +4216,7 @@ LayoutDeviceToParentLayerScale AsyncPanZoomController::GetCurrentPinchZoomScale( CSSRect AsyncPanZoomController::GetEffectiveLayoutViewport( AsyncTransformConsumer aMode) const { - if (StaticPrefs::APZFrameDelayEnabled() && aMode == eForCompositing) { + if (gfxPrefs::APZFrameDelayEnabled() && aMode == eForCompositing) { return mCompositedLayoutViewport; } return Metrics().GetLayoutViewport(); @@ -4233,7 +4224,7 @@ CSSRect AsyncPanZoomController::GetEffectiveLayoutViewport( CSSPoint AsyncPanZoomController::GetEffectiveScrollOffset( AsyncTransformConsumer aMode) const { - if (StaticPrefs::APZFrameDelayEnabled() && aMode == eForCompositing) { + if (gfxPrefs::APZFrameDelayEnabled() && aMode == eForCompositing) { return mCompositedScrollOffset; } return Metrics().GetScrollOffset(); @@ -4241,7 +4232,7 @@ CSSPoint AsyncPanZoomController::GetEffectiveScrollOffset( CSSToParentLayerScale2D AsyncPanZoomController::GetEffectiveZoom( AsyncTransformConsumer aMode) const { - if (StaticPrefs::APZFrameDelayEnabled() && aMode == eForCompositing) { + if (gfxPrefs::APZFrameDelayEnabled() && aMode == eForCompositing) { return mCompositedZoom; } return Metrics().GetZoom(); @@ -4337,7 +4328,7 @@ void AsyncPanZoomController::ReportCheckerboard(const TimeStamp& aSampleTime) { } mLastCheckerboardReport = aSampleTime; - bool recordTrace = StaticPrefs::APZRecordCheckerboarding(); + bool recordTrace = gfxPrefs::APZRecordCheckerboarding(); bool forTelemetry = Telemetry::CanRecordExtended(); uint32_t magnitude = GetCheckerboardMagnitude(); @@ -4366,7 +4357,7 @@ void AsyncPanZoomController::UpdateCheckerboardEvent( mPotentialCheckerboardTracker.CheckerboardDone(); - if (StaticPrefs::APZRecordCheckerboarding()) { + if (gfxPrefs::APZRecordCheckerboarding()) { // if the pref is enabled, also send it to the storage class. it may be // chosen for public display on about:checkerboard, the hall of fame for // checkerboard events. @@ -4671,7 +4662,7 @@ void AsyncPanZoomController::NotifyLayersUpdated( // this we need to update mExpectedGeckoMetrics to be the last thing we // know was painted by Gecko. Maybe relativeDelta; - if (StaticPrefs::APZRelativeUpdate() && aLayerMetrics.IsRelative()) { + if (gfxPrefs::APZRelativeUpdate() && aLayerMetrics.IsRelative()) { APZC_LOG("%p relative updating scroll offset from %s by %s\n", this, ToString(Metrics().GetScrollOffset()).c_str(), ToString(aLayerMetrics.GetScrollOffset() - @@ -4746,7 +4737,7 @@ void AsyncPanZoomController::NotifyLayersUpdated( // See comment on the similar code in the |if (scrollOffsetUpdated)| block // above. - if (StaticPrefs::APZRelativeUpdate() && aLayerMetrics.IsRelative()) { + if (gfxPrefs::APZRelativeUpdate() && aLayerMetrics.IsRelative()) { Metrics().ApplyRelativeSmoothScrollUpdateFrom(aLayerMetrics); } else { Metrics().ApplySmoothScrollUpdateFrom(aLayerMetrics); @@ -5067,7 +5058,7 @@ void AsyncPanZoomController::DispatchStateChangeNotification( #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) // Let the compositor know about scroll state changes so it can manage // windowed plugins. - if (StaticPrefs::HidePluginsForScroll() && mCompositorController) { + if (gfxPrefs::HidePluginsForScroll() && mCompositorController) { mCompositorController->ScheduleHideAllPluginWindows(); } #endif @@ -5089,7 +5080,7 @@ void AsyncPanZoomController::DispatchStateChangeNotification( controller->NotifyAPZStateChange(GetGuid(), APZStateChange::eTransformEnd); #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) - if (StaticPrefs::HidePluginsForScroll() && mCompositorController) { + if (gfxPrefs::HidePluginsForScroll() && mCompositorController) { mCompositorController->ScheduleShowAllPluginWindows(); } #endif @@ -5181,7 +5172,7 @@ void AsyncPanZoomController::UpdateSharedCompositorFrameMetrics() { ? static_cast(mSharedFrameMetricsBuffer->memory()) : nullptr; - if (frame && mSharedLock && StaticPrefs::ProgressivePaint()) { + if (frame && mSharedLock && gfxPrefs::ProgressivePaint()) { mSharedLock->Lock(); *frame = Metrics(); mSharedLock->Unlock(); @@ -5195,7 +5186,7 @@ void AsyncPanZoomController::ShareCompositorFrameMetrics() { // we are using progressive tile painting, and we have a // controller to pass the shared memory back to the content process/thread. if (!mSharedFrameMetricsBuffer && mMetricsSharingController && - StaticPrefs::ProgressivePaint()) { + gfxPrefs::ProgressivePaint()) { // Create shared memory and initialize it with the current FrameMetrics // value mSharedFrameMetricsBuffer = new ipc::SharedMemoryBasic; @@ -5283,7 +5274,7 @@ void AsyncPanZoomController::ScrollSnap() { void AsyncPanZoomController::ScrollSnapToDestination() { RecursiveMutexAutoLock lock(mRecursiveMutex); - float friction = StaticPrefs::APZFlingFriction(); + float friction = gfxPrefs::APZFlingFriction(); ParentLayerPoint velocity(mX.GetVelocity(), mY.GetVelocity()); ParentLayerPoint predictedDelta; // "-velocity / log(1.0 - friction)" is the integral of the deceleration diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h index ca7f9a7eceb6c..01872c0eef54d 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -1162,7 +1162,7 @@ class AsyncPanZoomController { * Returns true if the newly sampled value is different from the previously * sampled value. * - * (This is only relevant when |StaticPrefs::APZFrameDelayEnabled() == true|. + * (This is only relevant when |gfxPrefs::APZFrameDelayEnabled() == true|. * Otherwise, GetCurrentAsyncTransform() always reflects what's stored in * |Metrics()| immediately, without any delay.) */ diff --git a/gfx/layers/apz/src/Axis.cpp b/gfx/layers/apz/src/Axis.cpp index 8a5be662be7d5..75bd6a283dc5c 100644 --- a/gfx/layers/apz/src/Axis.cpp +++ b/gfx/layers/apz/src/Axis.cpp @@ -23,6 +23,7 @@ #include "nsPrintfCString.h" // for nsPrintfCString #include "nsThreadUtils.h" // for NS_DispatchToMainThread, etc #include "nscore.h" // for NS_IMETHOD +#include "gfxPrefs.h" // for the preferences #define AXIS_LOG(...) // #define AXIS_LOG(...) printf_stderr("AXIS: " __VA_ARGS__) diff --git a/gfx/layers/apz/src/DesktopFlingPhysics.h b/gfx/layers/apz/src/DesktopFlingPhysics.h index d4567a5bab72f..ae1dd68542683 100644 --- a/gfx/layers/apz/src/DesktopFlingPhysics.h +++ b/gfx/layers/apz/src/DesktopFlingPhysics.h @@ -9,6 +9,7 @@ #include "AsyncPanZoomController.h" #include "Units.h" +#include "gfxPrefs.h" #include "mozilla/Assertions.h" #define FLING_PHYS_LOG(...) @@ -25,8 +26,8 @@ class DesktopFlingPhysics { } void Sample(const TimeDuration& aDelta, ParentLayerPoint* aOutVelocity, ParentLayerPoint* aOutOffset) { - float friction = StaticPrefs::APZFlingFriction(); - float threshold = StaticPrefs::APZFlingStoppedThreshold(); + float friction = gfxPrefs::APZFlingFriction(); + float threshold = gfxPrefs::APZFlingStoppedThreshold(); mVelocity = ParentLayerPoint( ApplyFrictionOrCancel(mVelocity.x, aDelta, friction, threshold), diff --git a/gfx/layers/apz/src/FocusTarget.cpp b/gfx/layers/apz/src/FocusTarget.cpp index bbc5cfa156e40..53b36322d1a94 100644 --- a/gfx/layers/apz/src/FocusTarget.cpp +++ b/gfx/layers/apz/src/FocusTarget.cpp @@ -139,7 +139,7 @@ FocusTarget::FocusTarget(PresShell* aRootPresShell, // Check if there are key event listeners that could prevent default or change // the focus or selection of the page. - if (StaticPrefs::APZKeyboardPassiveListeners()) { + if (gfxPrefs::APZKeyboardPassiveListeners()) { mFocusHasKeyEventListeners = HasListenersForNonPassiveKeyEvents(keyEventTarget.get()); } else { diff --git a/gfx/layers/apz/src/GenericFlingAnimation.h b/gfx/layers/apz/src/GenericFlingAnimation.h index 5e5fb4209b615..52beb8e5cecbf 100644 --- a/gfx/layers/apz/src/GenericFlingAnimation.h +++ b/gfx/layers/apz/src/GenericFlingAnimation.h @@ -15,6 +15,7 @@ #include "LayersLogging.h" #include "Units.h" #include "OverscrollHandoffState.h" +#include "gfxPrefs.h" #include "mozilla/Assertions.h" #include "mozilla/Monitor.h" #include "mozilla/RefPtr.h" @@ -94,8 +95,8 @@ class GenericFlingAnimation : public AsyncPanZoomAnimation, bool applyAcceleration = !aFlingIsHandedOff; if (applyAcceleration && !mApzc.mLastFlingTime.IsNull() && (now - mApzc.mLastFlingTime).ToMilliseconds() < - StaticPrefs::APZFlingAccelInterval() && - velocity.Length() >= StaticPrefs::APZFlingAccelMinVelocity()) { + gfxPrefs::APZFlingAccelInterval() && + velocity.Length() >= gfxPrefs::APZFlingAccelMinVelocity()) { if (velocity.x != 0 && SameDirection(velocity.x, mApzc.mLastFlingVelocity.x)) { velocity.x = Accelerate(velocity.x, mApzc.mLastFlingVelocity.x); @@ -220,8 +221,8 @@ class GenericFlingAnimation : public AsyncPanZoomAnimation, } static float Accelerate(float aBase, float aSupplemental) { - return (aBase * StaticPrefs::APZFlingAccelBaseMultiplier()) + - (aSupplemental * StaticPrefs::APZFlingAccelSupplementalMultiplier()); + return (aBase * gfxPrefs::APZFlingAccelBaseMultiplier()) + + (aSupplemental * gfxPrefs::APZFlingAccelSupplementalMultiplier()); } AsyncPanZoomController& mApzc; diff --git a/gfx/layers/apz/src/GenericScrollAnimation.cpp b/gfx/layers/apz/src/GenericScrollAnimation.cpp index 7a4081087f9db..e8c63b16d360b 100644 --- a/gfx/layers/apz/src/GenericScrollAnimation.cpp +++ b/gfx/layers/apz/src/GenericScrollAnimation.cpp @@ -8,6 +8,7 @@ #include "AsyncPanZoomController.h" #include "FrameMetrics.h" +#include "gfxPrefs.h" #include "nsPoint.h" #include "ScrollAnimationPhysics.h" #include "ScrollAnimationBezierPhysics.h" @@ -20,7 +21,7 @@ GenericScrollAnimation::GenericScrollAnimation( AsyncPanZoomController& aApzc, const nsPoint& aInitialPosition, const ScrollAnimationBezierPhysicsSettings& aSettings) : mApzc(aApzc), mFinalDestination(aInitialPosition) { - if (StaticPrefs::SmoothScrollMSDPhysicsEnabled()) { + if (gfxPrefs::SmoothScrollMSDPhysicsEnabled()) { mAnimationPhysics = MakeUnique(aInitialPosition); } else { mAnimationPhysics = diff --git a/gfx/layers/apz/src/GestureEventListener.cpp b/gfx/layers/apz/src/GestureEventListener.cpp index ad86a7d49cbab..9ddffa849dfa8 100644 --- a/gfx/layers/apz/src/GestureEventListener.cpp +++ b/gfx/layers/apz/src/GestureEventListener.cpp @@ -10,8 +10,8 @@ #include "AsyncPanZoomController.h" // for AsyncPanZoomController #include "InputBlockState.h" // for TouchBlockState #include "base/task.h" // for CancelableTask, etc +#include "gfxPrefs.h" // for gfxPrefs #include "InputBlockState.h" // for TouchBlockState -#include "mozilla/StaticPrefs.h" // for StaticPrefs #include "nsDebug.h" // for NS_WARNING #include "nsMathUtils.h" // for NS_hypot @@ -291,13 +291,13 @@ nsEventStatus GestureEventListener::HandleInputTouchMove() { // The user has performed a double tap, but not lifted her finger. case GESTURE_SECOND_SINGLE_TOUCH_DOWN: { - // If touch has moved noticeably (within StaticPrefs::APZMaxTapTime()), + // If touch has moved noticeably (within gfxPrefs::APZMaxTapTime()), // change state. if (MoveDistanceIsLarge()) { CancelLongTapTimeoutTask(); CancelMaxTapTimeoutTask(); mSingleTapSent = Nothing(); - if (!StaticPrefs::APZOneTouchPinchEnabled()) { + if (!gfxPrefs::APZOneTouchPinchEnabled()) { // If the one-touch-pinch feature is disabled, bail out of the double- // tap gesture instead. SetState(GESTURE_NONE); @@ -601,7 +601,7 @@ void GestureEventListener::CreateLongTapTimeoutTask() { mLongTapTimeoutTask = task; mAsyncPanZoomController->PostDelayedTask( - task.forget(), StaticPrefs::UiClickHoldContextMenusDelay()); + task.forget(), gfxPrefs::UiClickHoldContextMenusDelay()); } void GestureEventListener::CancelMaxTapTimeoutTask() { @@ -629,7 +629,7 @@ void GestureEventListener::CreateMaxTapTimeoutTask() { mMaxTapTimeoutTask = task; mAsyncPanZoomController->PostDelayedTask(task.forget(), - StaticPrefs::APZMaxTapTime()); + gfxPrefs::APZMaxTapTime()); } } // namespace layers diff --git a/gfx/layers/apz/src/GestureEventListener.h b/gfx/layers/apz/src/GestureEventListener.h index b55e2c85459ef..72bee7dac850d 100644 --- a/gfx/layers/apz/src/GestureEventListener.h +++ b/gfx/layers/apz/src/GestureEventListener.h @@ -84,7 +84,7 @@ class GestureEventListener final { // A touch start with a single touch point has just happened. // After having gotten into this state we start timers for MAX_TAP_TIME and - // StaticPrefs::UiClickHoldContextMenusDelay(). + // gfxPrefs::UiClickHoldContextMenusDelay(). // Allowed next states: GESTURE_MULTI_TOUCH_DOWN, GESTURE_NONE, // GESTURE_FIRST_SINGLE_TOUCH_UP, // GESTURE_LONG_TOUCH_DOWN, @@ -93,8 +93,8 @@ class GestureEventListener final { // While in GESTURE_FIRST_SINGLE_TOUCH_DOWN state a MAX_TAP_TIME timer got // triggered. Now we'll trigger either a single tap if a user lifts her - // finger or a long tap if StaticPrefs::UiClickHoldContextMenusDelay() - // happens first. + // finger or a long tap if gfxPrefs::UiClickHoldContextMenusDelay() happens + // first. // Allowed next states: GESTURE_MULTI_TOUCH_DOWN, GESTURE_NONE, // GESTURE_LONG_TOUCH_DOWN. GESTURE_FIRST_SINGLE_TOUCH_MAX_TAP_DOWN, diff --git a/gfx/layers/apz/src/HitTestingTreeNode.cpp b/gfx/layers/apz/src/HitTestingTreeNode.cpp index 572b6920fcca6..ddefba087d0ba 100644 --- a/gfx/layers/apz/src/HitTestingTreeNode.cpp +++ b/gfx/layers/apz/src/HitTestingTreeNode.cpp @@ -5,6 +5,7 @@ #include "HitTestingTreeNode.h" #include "AsyncPanZoomController.h" // for AsyncPanZoomController +#include "gfxPrefs.h" #include "LayersLogging.h" // for Stringify #include "mozilla/gfx/Point.h" // for Point4D #include "mozilla/layers/APZUtils.h" // for CompleteAsyncTransform @@ -272,7 +273,7 @@ CompositorHitTestInfo HitTestingTreeNode::HitTest( if (mEventRegions.mDTCRequiresTargetConfirmation) { result += CompositorHitTestFlags::eRequiresTargetConfirmation; } - } else if (StaticPrefs::TouchActionEnabled()) { + } else if (gfxPrefs::TouchActionEnabled()) { if (mEventRegions.mNoActionRegion.Contains(point.x, point.y)) { // set all the touch-action flags as disabled result += CompositorHitTestTouchActionMask; diff --git a/gfx/layers/apz/src/InputBlockState.cpp b/gfx/layers/apz/src/InputBlockState.cpp index 3ce5184dade3c..a5afeb4a7c207 100644 --- a/gfx/layers/apz/src/InputBlockState.cpp +++ b/gfx/layers/apz/src/InputBlockState.cpp @@ -9,7 +9,7 @@ #include "APZUtils.h" #include "AsyncPanZoomController.h" // for AsyncPanZoomController #include "ScrollAnimationPhysics.h" // for kScrollSeriesTimeoutMs - +#include "gfxPrefs.h" // for gfxPrefs #include "mozilla/MouseEvents.h" #include "mozilla/Telemetry.h" // for Telemetry #include "mozilla/layers/IAPZCTreeManager.h" // for AllowedTouchBehavior @@ -149,7 +149,7 @@ bool InputBlockState::IsDownchainOf(AsyncPanZoomController* aA, void InputBlockState::SetScrolledApzc(AsyncPanZoomController* aApzc) { // An input block should only have one scrolled APZC. - MOZ_ASSERT(!mScrolledApzc || (StaticPrefs::APZAllowImmediateHandoff() + MOZ_ASSERT(!mScrolledApzc || (gfxPrefs::APZAllowImmediateHandoff() ? IsDownchainOf(mScrolledApzc, aApzc) : mScrolledApzc == aApzc)); @@ -404,8 +404,7 @@ bool WheelBlockState::MaybeTimeout(const ScrollWheelInput& aEvent) { // If there's a recent mouse movement, we can time out the transaction // early. TimeDuration duration = TimeStamp::Now() - mLastMouseMove; - if (duration.ToMilliseconds() >= - StaticPrefs::MouseWheelIgnoreMoveDelayMs()) { + if (duration.ToMilliseconds() >= gfxPrefs::MouseWheelIgnoreMoveDelayMs()) { TBS_LOG("%p wheel transaction timed out after mouse move\n", this); EndTransaction(); return true; @@ -421,14 +420,13 @@ bool WheelBlockState::MaybeTimeout(const TimeStamp& aTimeStamp) { // End the transaction if the event occurred > 1.5s after the most recently // seen wheel event. TimeDuration duration = aTimeStamp - mLastEventTime; - if (duration.ToMilliseconds() < - StaticPrefs::MouseWheelTransactionTimeoutMs()) { + if (duration.ToMilliseconds() < gfxPrefs::MouseWheelTransactionTimeoutMs()) { return false; } TBS_LOG("%p wheel transaction timed out\n", this); - if (StaticPrefs::MouseScrollTestingEnabled()) { + if (gfxPrefs::MouseScrollTestingEnabled()) { RefPtr apzc = GetTargetApzc(); apzc->NotifyMozMouseScrollEvent( NS_LITERAL_STRING("MozMouseScrollTransactionTimeout")); @@ -452,8 +450,7 @@ void WheelBlockState::OnMouseMove(const ScreenIntPoint& aPoint) { // this as the most recent mouse movement. TimeStamp now = TimeStamp::Now(); TimeDuration duration = now - mLastEventTime; - if (duration.ToMilliseconds() >= - StaticPrefs::MouseWheelIgnoreMoveDelayMs()) { + if (duration.ToMilliseconds() >= gfxPrefs::MouseWheelIgnoreMoveDelayMs()) { mLastMouseMove = now; } } @@ -584,7 +581,7 @@ TouchBlockState::TouchBlockState( mInSlop(false), mTouchCounter(aCounter) { TBS_LOG("Creating %p\n", this); - if (!StaticPrefs::TouchActionEnabled()) { + if (!gfxPrefs::TouchActionEnabled()) { mAllowedTouchBehaviorSet = true; } } @@ -616,7 +613,7 @@ bool TouchBlockState::HasAllowedTouchBehaviors() const { void TouchBlockState::CopyPropertiesFrom(const TouchBlockState& aOther) { TBS_LOG("%p copying properties from %p\n", this, &aOther); - if (StaticPrefs::TouchActionEnabled()) { + if (gfxPrefs::TouchActionEnabled()) { MOZ_ASSERT(aOther.mAllowedTouchBehaviorSet || aOther.IsContentResponseTimerExpired()); SetAllowedTouchBehaviors(aOther.mAllowedTouchBehaviors); @@ -627,7 +624,7 @@ void TouchBlockState::CopyPropertiesFrom(const TouchBlockState& aOther) { bool TouchBlockState::HasReceivedAllContentNotifications() const { return CancelableBlockState::HasReceivedAllContentNotifications() // See comment in TouchBlockState::IsReadyforHandling() - && (!StaticPrefs::TouchActionEnabled() || mAllowedTouchBehaviorSet); + && (!gfxPrefs::TouchActionEnabled() || mAllowedTouchBehaviorSet); } bool TouchBlockState::IsReadyForHandling() const { @@ -635,7 +632,7 @@ bool TouchBlockState::IsReadyForHandling() const { return false; } - if (!StaticPrefs::TouchActionEnabled()) { + if (!gfxPrefs::TouchActionEnabled()) { // If TouchActionEnabled() was false when this block was created, then // mAllowedTouchBehaviorSet is guaranteed to the true. However, the pref // may have been flipped to false after the block was created. In that case, @@ -673,7 +670,7 @@ void TouchBlockState::DispatchEvent(const InputData& aEvent) const { } bool TouchBlockState::TouchActionAllowsPinchZoom() const { - if (!StaticPrefs::TouchActionEnabled()) { + if (!gfxPrefs::TouchActionEnabled()) { return true; } // Pointer events specification requires that all touch points allow zoom. @@ -686,7 +683,7 @@ bool TouchBlockState::TouchActionAllowsPinchZoom() const { } bool TouchBlockState::TouchActionAllowsDoubleTapZoom() const { - if (!StaticPrefs::TouchActionEnabled()) { + if (!gfxPrefs::TouchActionEnabled()) { return true; } for (size_t i = 0; i < mAllowedTouchBehaviors.Length(); i++) { @@ -698,7 +695,7 @@ bool TouchBlockState::TouchActionAllowsDoubleTapZoom() const { } bool TouchBlockState::TouchActionAllowsPanningX() const { - if (!StaticPrefs::TouchActionEnabled()) { + if (!gfxPrefs::TouchActionEnabled()) { return true; } if (mAllowedTouchBehaviors.IsEmpty()) { @@ -710,7 +707,7 @@ bool TouchBlockState::TouchActionAllowsPanningX() const { } bool TouchBlockState::TouchActionAllowsPanningY() const { - if (!StaticPrefs::TouchActionEnabled()) { + if (!gfxPrefs::TouchActionEnabled()) { return true; } if (mAllowedTouchBehaviors.IsEmpty()) { @@ -722,7 +719,7 @@ bool TouchBlockState::TouchActionAllowsPanningY() const { } bool TouchBlockState::TouchActionAllowsPanningXY() const { - if (!StaticPrefs::TouchActionEnabled()) { + if (!gfxPrefs::TouchActionEnabled()) { return true; } if (mAllowedTouchBehaviors.IsEmpty()) { @@ -780,8 +777,8 @@ Maybe TouchBlockState::GetBestGuessPanDirection( angle = fabs(angle); // range [0, pi] double angleThreshold = TouchActionAllowsPanningXY() - ? StaticPrefs::APZAxisLockAngle() - : StaticPrefs::APZAllowedDirectPanAngle(); + ? gfxPrefs::APZAxisLockAngle() + : gfxPrefs::APZAllowedDirectPanAngle(); if (apz::IsCloseToHorizontal(angle, angleThreshold)) { return Some(ScrollDirection::eHorizontal); } diff --git a/gfx/layers/apz/src/InputBlockState.h b/gfx/layers/apz/src/InputBlockState.h index 24504f1229817..98b3ccbc1ba5b 100644 --- a/gfx/layers/apz/src/InputBlockState.h +++ b/gfx/layers/apz/src/InputBlockState.h @@ -107,9 +107,9 @@ class InputBlockState : public RefCounted { // The APZC that was actually scrolled by events in this input block. // This is used in configurations where a single input block is only - // allowed to scroll a single APZC (configurations where - // StaticPrefs::APZAllowImmediateHandoff() is false). Set the first time an - // input event in this block scrolls an APZC. + // allowed to scroll a single APZC (configurations where gfxPrefs:: + // APZAllowImmediateHandoff() is false). + // Set the first time an input event in this block scrolls an APZC. RefPtr mScrolledApzc; protected: diff --git a/gfx/layers/apz/src/InputQueue.cpp b/gfx/layers/apz/src/InputQueue.cpp index dfbf62f7631b9..6505456785cbb 100644 --- a/gfx/layers/apz/src/InputQueue.cpp +++ b/gfx/layers/apz/src/InputQueue.cpp @@ -7,7 +7,7 @@ #include "InputQueue.h" #include "AsyncPanZoomController.h" - +#include "gfxPrefs.h" #include "InputBlockState.h" #include "LayersLogging.h" #include "mozilla/layers/APZThreadUtils.h" @@ -82,7 +82,7 @@ nsEventStatus InputQueue::ReceiveTouchInput( if (aEvent.mType == MultiTouchInput::MULTITOUCH_START) { nsTArray currentBehaviors; bool haveBehaviors = false; - if (!StaticPrefs::TouchActionEnabled()) { + if (!gfxPrefs::TouchActionEnabled()) { haveBehaviors = true; } else if (mActiveTouchBlock) { haveBehaviors = @@ -114,7 +114,7 @@ nsEventStatus InputQueue::ReceiveTouchInput( aTarget, InputBlockState::TargetConfirmationState::eConfirmed, nullptr /* the block was just created so it has no events */, false /* not a scrollbar drag */); - if (StaticPrefs::TouchActionEnabled()) { + if (gfxPrefs::TouchActionEnabled()) { block->SetAllowedTouchBehaviors(currentBehaviors); } INPQ_LOG("block %p tagged as fast-motion\n", block); @@ -318,7 +318,7 @@ nsEventStatus InputQueue::ReceiveKeyboardInput( // If APZ is allowing passive listeners then we must dispatch the event to // content, otherwise we can consume the event. - return StaticPrefs::APZKeyboardPassiveListeners() + return gfxPrefs::APZKeyboardPassiveListeners() ? nsEventStatus_eConsumeDoDefault : nsEventStatus_eConsumeNoDefault; } @@ -551,7 +551,7 @@ void InputQueue::ScheduleMainThreadTimeout( RefPtr timeoutTask = NewRunnableMethod( "layers::InputQueue::MainThreadTimeout", this, &InputQueue::MainThreadTimeout, aBlock->GetBlockId()); - int32_t timeout = StaticPrefs::APZContentResponseTimeout(); + int32_t timeout = gfxPrefs::APZContentResponseTimeout(); if (timeout == 0) { // If the timeout is zero, treat it as a request to ignore any main // thread confirmation and unconditionally use fallback behaviour for diff --git a/gfx/layers/apz/src/KeyboardScrollAnimation.cpp b/gfx/layers/apz/src/KeyboardScrollAnimation.cpp index 18fc5af20f039..ba30227793a84 100644 --- a/gfx/layers/apz/src/KeyboardScrollAnimation.cpp +++ b/gfx/layers/apz/src/KeyboardScrollAnimation.cpp @@ -7,6 +7,8 @@ #include "KeyboardScrollAnimation.h" #include "ScrollAnimationBezierPhysics.h" +#include "gfxPrefs.h" + namespace mozilla { namespace layers { @@ -18,25 +20,25 @@ static ScrollAnimationBezierPhysicsSettings SettingsForType( switch (aType) { case KeyboardScrollAction::eScrollCharacter: case KeyboardScrollAction::eScrollLine: { - maxMS = clamped(StaticPrefs::LineSmoothScrollMaxDurationMs(), 0, 10000); - minMS = clamped(StaticPrefs::LineSmoothScrollMinDurationMs(), 0, maxMS); + maxMS = clamped(gfxPrefs::LineSmoothScrollMaxDurationMs(), 0, 10000); + minMS = clamped(gfxPrefs::LineSmoothScrollMinDurationMs(), 0, maxMS); break; } case KeyboardScrollAction::eScrollPage: { - maxMS = clamped(StaticPrefs::PageSmoothScrollMaxDurationMs(), 0, 10000); - minMS = clamped(StaticPrefs::PageSmoothScrollMinDurationMs(), 0, maxMS); + maxMS = clamped(gfxPrefs::PageSmoothScrollMaxDurationMs(), 0, 10000); + minMS = clamped(gfxPrefs::PageSmoothScrollMinDurationMs(), 0, maxMS); break; } case KeyboardScrollAction::eScrollComplete: { - maxMS = clamped(StaticPrefs::OtherSmoothScrollMaxDurationMs(), 0, 10000); - minMS = clamped(StaticPrefs::OtherSmoothScrollMinDurationMs(), 0, maxMS); + maxMS = clamped(gfxPrefs::OtherSmoothScrollMaxDurationMs(), 0, 10000); + minMS = clamped(gfxPrefs::OtherSmoothScrollMinDurationMs(), 0, maxMS); break; } } // The pref is 100-based int percentage, while mIntervalRatio is 1-based ratio double intervalRatio = - ((double)StaticPrefs::SmoothScrollDurationToIntervalRatio()) / 100.0; + ((double)gfxPrefs::SmoothScrollDurationToIntervalRatio()) / 100.0; intervalRatio = std::max(1.0, intervalRatio); return ScrollAnimationBezierPhysicsSettings{minMS, maxMS, intervalRatio}; } diff --git a/gfx/layers/apz/src/SimpleVelocityTracker.cpp b/gfx/layers/apz/src/SimpleVelocityTracker.cpp index 092da539e49a6..92c188b9ddc34 100644 --- a/gfx/layers/apz/src/SimpleVelocityTracker.cpp +++ b/gfx/layers/apz/src/SimpleVelocityTracker.cpp @@ -6,8 +6,8 @@ #include "SimpleVelocityTracker.h" +#include "gfxPrefs.h" #include "mozilla/ComputedTimingFunction.h" // for ComputedTimingFunction -#include "mozilla/StaticPrefs.h" #include "mozilla/StaticPtr.h" // for StaticAutoPtr #define SVT_LOG(...) @@ -86,7 +86,7 @@ Maybe SimpleVelocityTracker::ComputeVelocity(uint32_t aTimestampMs) { int count = 0; for (const auto& e : mVelocityQueue) { uint32_t timeDelta = (aTimestampMs - e.first); - if (timeDelta < StaticPrefs::APZVelocityRelevanceTime()) { + if (timeDelta < gfxPrefs::APZVelocityRelevanceTime()) { count++; velocity += e.second; } @@ -103,24 +103,24 @@ void SimpleVelocityTracker::Clear() { mVelocityQueue.Clear(); } void SimpleVelocityTracker::AddVelocityToQueue(uint32_t aTimestampMs, float aVelocity) { mVelocityQueue.AppendElement(std::make_pair(aTimestampMs, aVelocity)); - if (mVelocityQueue.Length() > StaticPrefs::APZMaxVelocityQueueSize()) { + if (mVelocityQueue.Length() > gfxPrefs::APZMaxVelocityQueueSize()) { mVelocityQueue.RemoveElementAt(0); } } float SimpleVelocityTracker::ApplyFlingCurveToVelocity(float aVelocity) const { float newVelocity = aVelocity; - if (StaticPrefs::APZMaxVelocity() > 0.0f) { + if (gfxPrefs::APZMaxVelocity() > 0.0f) { bool velocityIsNegative = (newVelocity < 0); newVelocity = fabs(newVelocity); - float maxVelocity = mAxis->ToLocalVelocity(StaticPrefs::APZMaxVelocity()); + float maxVelocity = mAxis->ToLocalVelocity(gfxPrefs::APZMaxVelocity()); newVelocity = std::min(newVelocity, maxVelocity); - if (StaticPrefs::APZCurveThreshold() > 0.0f && - StaticPrefs::APZCurveThreshold() < StaticPrefs::APZMaxVelocity()) { + if (gfxPrefs::APZCurveThreshold() > 0.0f && + gfxPrefs::APZCurveThreshold() < gfxPrefs::APZMaxVelocity()) { float curveThreshold = - mAxis->ToLocalVelocity(StaticPrefs::APZCurveThreshold()); + mAxis->ToLocalVelocity(gfxPrefs::APZCurveThreshold()); if (newVelocity > curveThreshold) { // here, 0 < curveThreshold < newVelocity <= maxVelocity, so we apply // the curve diff --git a/gfx/layers/apz/src/WheelScrollAnimation.cpp b/gfx/layers/apz/src/WheelScrollAnimation.cpp index 67f5a6da5f117..6263fc1acff61 100644 --- a/gfx/layers/apz/src/WheelScrollAnimation.cpp +++ b/gfx/layers/apz/src/WheelScrollAnimation.cpp @@ -8,7 +8,7 @@ #include "ScrollAnimationBezierPhysics.h" #include "AsyncPanZoomController.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "nsPoint.h" namespace mozilla { @@ -21,22 +21,22 @@ static ScrollAnimationBezierPhysicsSettings SettingsForDeltaType( switch (aDeltaType) { case ScrollWheelInput::SCROLLDELTA_PAGE: - maxMS = clamped(StaticPrefs::PageSmoothScrollMaxDurationMs(), 0, 10000); - minMS = clamped(StaticPrefs::PageSmoothScrollMinDurationMs(), 0, maxMS); + maxMS = clamped(gfxPrefs::PageSmoothScrollMaxDurationMs(), 0, 10000); + minMS = clamped(gfxPrefs::PageSmoothScrollMinDurationMs(), 0, maxMS); break; case ScrollWheelInput::SCROLLDELTA_PIXEL: - maxMS = clamped(StaticPrefs::PixelSmoothScrollMaxDurationMs(), 0, 10000); - minMS = clamped(StaticPrefs::PixelSmoothScrollMinDurationMs(), 0, maxMS); + maxMS = clamped(gfxPrefs::PixelSmoothScrollMaxDurationMs(), 0, 10000); + minMS = clamped(gfxPrefs::PixelSmoothScrollMinDurationMs(), 0, maxMS); break; case ScrollWheelInput::SCROLLDELTA_LINE: - maxMS = clamped(StaticPrefs::WheelSmoothScrollMaxDurationMs(), 0, 10000); - minMS = clamped(StaticPrefs::WheelSmoothScrollMinDurationMs(), 0, maxMS); + maxMS = clamped(gfxPrefs::WheelSmoothScrollMaxDurationMs(), 0, 10000); + minMS = clamped(gfxPrefs::WheelSmoothScrollMinDurationMs(), 0, maxMS); break; } // The pref is 100-based int percentage, while mIntervalRatio is 1-based ratio double intervalRatio = - ((double)StaticPrefs::SmoothScrollDurationToIntervalRatio()) / 100.0; + ((double)gfxPrefs::SmoothScrollDurationToIntervalRatio()) / 100.0; intervalRatio = std::max(1.0, intervalRatio); return ScrollAnimationBezierPhysicsSettings{minMS, maxMS, intervalRatio}; } diff --git a/gfx/layers/apz/test/gtest/APZCBasicTester.h b/gfx/layers/apz/test/gtest/APZCBasicTester.h index add054a958ea7..215e54cd76fd3 100644 --- a/gfx/layers/apz/test/gtest/APZCBasicTester.h +++ b/gfx/layers/apz/test/gtest/APZCBasicTester.h @@ -12,7 +12,7 @@ */ #include "APZTestCommon.h" - +#include "gfxPrefs.h" #include "mozilla/layers/APZSampler.h" #include "mozilla/layers/APZUpdater.h" @@ -25,6 +25,7 @@ class APZCBasicTester : public APZCTesterBase { protected: virtual void SetUp() { + gfxPrefs::GetSingleton(); APZThreadUtils::SetThreadAssertionsEnabled(false); APZThreadUtils::SetControllerThread(MessageLoop::current()); diff --git a/gfx/layers/apz/test/gtest/APZCTreeManagerTester.h b/gfx/layers/apz/test/gtest/APZCTreeManagerTester.h index 0a7d2ca6267cb..ac06a60e924cb 100644 --- a/gfx/layers/apz/test/gtest/APZCTreeManagerTester.h +++ b/gfx/layers/apz/test/gtest/APZCTreeManagerTester.h @@ -14,13 +14,14 @@ #include "APZTestCommon.h" #include "gfxPlatform.h" - +#include "gfxPrefs.h" #include "mozilla/layers/APZSampler.h" #include "mozilla/layers/APZUpdater.h" class APZCTreeManagerTester : public APZCTesterBase { protected: virtual void SetUp() { + gfxPrefs::GetSingleton(); gfxPlatform::GetPlatform(); APZThreadUtils::SetThreadAssertionsEnabled(false); APZThreadUtils::SetControllerThread(MessageLoop::current()); diff --git a/gfx/layers/apz/test/gtest/APZTestCommon.h b/gfx/layers/apz/test/gtest/APZTestCommon.h index 0853cde45fe8d..4743882f14ca1 100644 --- a/gfx/layers/apz/test/gtest/APZTestCommon.h +++ b/gfx/layers/apz/test/gtest/APZTestCommon.h @@ -23,7 +23,6 @@ #include "mozilla/layers/LayerMetricsWrapper.h" #include "mozilla/layers/APZThreadUtils.h" #include "mozilla/layers/MatrixMessage.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/TypedEnumBits.h" #include "mozilla/UniquePtr.h" #include "apz/src/APZCTreeManager.h" @@ -33,6 +32,7 @@ #include "Layers.h" #include "TestLayers.h" #include "UnitTransforms.h" +#include "gfxPrefs.h" using namespace mozilla; using namespace mozilla::gfx; @@ -91,7 +91,7 @@ class ScopedGfxSetting { #define SCOPED_GFX_PREF(prefBase, prefType, prefValue) \ ScopedGfxSetting pref_##prefBase( \ - &(StaticPrefs::prefBase), &(StaticPrefs::Set##prefBase), prefValue) + &(gfxPrefs::prefBase), &(gfxPrefs::Set##prefBase), prefValue) #define SCOPED_GFX_VAR(varBase, varType, varValue) \ ScopedGfxSetting var_##varBase( \ @@ -520,7 +520,7 @@ void APZCTesterBase::Tap(const RefPtr& aTarget, // If touch-action is enabled then simulate the allowed touch behaviour // notification that the main thread is supposed to deliver. - if (StaticPrefs::TouchActionEnabled() && + if (gfxPrefs::TouchActionEnabled() && status != nsEventStatus_eConsumeNoDefault) { SetDefaultAllowedTouchBehavior(aTarget, *aOutInputBlockId); } @@ -552,8 +552,8 @@ void APZCTesterBase::Pan(const RefPtr& aTarget, // We can't use a scoped pref because this value might be read at some later // time when the events are actually processed, rather than when we deliver // them. - StaticPrefs::SetAPZTouchStartTolerance(1.0f / 1000.0f); - StaticPrefs::SetAPZTouchMoveTolerance(0.0f); + gfxPrefs::SetAPZTouchStartTolerance(1.0f / 1000.0f); + gfxPrefs::SetAPZTouchMoveTolerance(0.0f); int overcomeTouchToleranceX = 0; int overcomeTouchToleranceY = 0; if (!(aOptions & PanOptions::ExactCoordinates)) { @@ -596,7 +596,7 @@ void APZCTesterBase::Pan(const RefPtr& aTarget, EXPECT_EQ(1UL, aAllowedTouchBehaviors->Length()); aTarget->SetAllowedTouchBehavior(*aOutInputBlockId, *aAllowedTouchBehaviors); - } else if (StaticPrefs::TouchActionEnabled()) { + } else if (gfxPrefs::TouchActionEnabled()) { SetDefaultAllowedTouchBehavior(aTarget, *aOutInputBlockId); } } @@ -681,7 +681,7 @@ void APZCTesterBase::DoubleTap(const RefPtr& aTarget, // If touch-action is enabled then simulate the allowed touch behaviour // notification that the main thread is supposed to deliver. - if (StaticPrefs::TouchActionEnabled() && + if (gfxPrefs::TouchActionEnabled() && status != nsEventStatus_eConsumeNoDefault) { SetDefaultAllowedTouchBehavior(aTarget, blockId); } @@ -700,7 +700,7 @@ void APZCTesterBase::DoubleTap(const RefPtr& aTarget, } mcc->AdvanceByMillis(10); - if (StaticPrefs::TouchActionEnabled() && + if (gfxPrefs::TouchActionEnabled() && status != nsEventStatus_eConsumeNoDefault) { SetDefaultAllowedTouchBehavior(aTarget, blockId); } @@ -773,7 +773,7 @@ void APZCTesterBase::PinchWithTouchInput( EXPECT_EQ(2UL, aAllowedTouchBehaviors->Length()); aTarget->SetAllowedTouchBehavior(*aOutInputBlockId, *aAllowedTouchBehaviors); - } else if (StaticPrefs::TouchActionEnabled()) { + } else if (gfxPrefs::TouchActionEnabled()) { SetDefaultAllowedTouchBehavior(aTarget, *aOutInputBlockId, 2); } diff --git a/gfx/layers/apz/test/gtest/InputUtils.h b/gfx/layers/apz/test/gtest/InputUtils.h index 0f360569ba2e4..6298ae809333e 100644 --- a/gfx/layers/apz/test/gtest/InputUtils.h +++ b/gfx/layers/apz/test/gtest/InputUtils.h @@ -13,6 +13,7 @@ */ #include "APZTestCommon.h" +#include "gfxPrefs.h" /* The InputReceiver template parameter used in the helper functions below needs * to be a class that implements functions with the signatures: diff --git a/gfx/layers/apz/test/gtest/TestBasic.cpp b/gfx/layers/apz/test/gtest/TestBasic.cpp index 6d76045de7721..3a3b6fd566dfc 100644 --- a/gfx/layers/apz/test/gtest/TestBasic.cpp +++ b/gfx/layers/apz/test/gtest/TestBasic.cpp @@ -6,7 +6,7 @@ #include "APZCBasicTester.h" #include "APZTestCommon.h" - +#include "gfxPrefs.h" #include "InputUtils.h" TEST_F(APZCBasicTester, Overzoom) { @@ -348,7 +348,7 @@ TEST_F(APZCBasicTester, OverScroll_Bug1152051b) { uint64_t blockId; nsEventStatus status = TouchDown(apzc, ScreenIntPoint(10, 10), mcc->Time(), &blockId); - if (StaticPrefs::TouchActionEnabled() && + if (gfxPrefs::TouchActionEnabled() && status != nsEventStatus_eConsumeNoDefault) { SetDefaultAllowedTouchBehavior(apzc, blockId); } diff --git a/gfx/layers/apz/test/gtest/TestGestureDetector.cpp b/gfx/layers/apz/test/gtest/TestGestureDetector.cpp index 7dd7f4d8b6d50..86d7c21d16dc0 100644 --- a/gfx/layers/apz/test/gtest/TestGestureDetector.cpp +++ b/gfx/layers/apz/test/gtest/TestGestureDetector.cpp @@ -6,6 +6,7 @@ #include "APZCBasicTester.h" #include "APZTestCommon.h" +#include "gfxPrefs.h" class APZCGestureDetectorTester : public APZCBasicTester { public: @@ -392,7 +393,7 @@ class APZCLongPressTester : public APZCGestureDetectorTester { TouchDown(apzc, ScreenIntPoint(10, 10), mcc->Time(), &blockId); EXPECT_EQ(nsEventStatus_eConsumeDoDefault, status); - if (StaticPrefs::TouchActionEnabled() && + if (gfxPrefs::TouchActionEnabled() && status != nsEventStatus_eConsumeNoDefault) { // SetAllowedTouchBehavior() must be called after sending touch-start. nsTArray allowedTouchBehaviors; @@ -458,7 +459,7 @@ class APZCLongPressTester : public APZCGestureDetectorTester { mcc->Time(), &blockId); EXPECT_EQ(nsEventStatus_eConsumeDoDefault, status); - if (StaticPrefs::TouchActionEnabled() && + if (gfxPrefs::TouchActionEnabled() && status != nsEventStatus_eConsumeNoDefault) { // SetAllowedTouchBehavior() must be called after sending touch-start. nsTArray allowedTouchBehaviors; @@ -706,7 +707,7 @@ TEST_F(APZCGestureDetectorTester, LongPressInterruptedByWheel) { uint64_t wheelBlockId = 0; nsEventStatus status = TouchDown(apzc, ScreenIntPoint(10, 10), mcc->Time(), &touchBlockId); - if (StaticPrefs::TouchActionEnabled() && + if (gfxPrefs::TouchActionEnabled() && status != nsEventStatus_eConsumeNoDefault) { SetDefaultAllowedTouchBehavior(apzc, touchBlockId); } diff --git a/gfx/layers/apz/test/gtest/TestHitTesting.cpp b/gfx/layers/apz/test/gtest/TestHitTesting.cpp index 002d044857e3c..b3f376a6276d3 100644 --- a/gfx/layers/apz/test/gtest/TestHitTesting.cpp +++ b/gfx/layers/apz/test/gtest/TestHitTesting.cpp @@ -6,7 +6,7 @@ #include "APZCTreeManagerTester.h" #include "APZTestCommon.h" - +#include "gfxPrefs.h" #include "InputUtils.h" class APZHitTestingTester : public APZCTreeManagerTester { @@ -637,7 +637,7 @@ TEST_F(APZHitTestingTester, Bug1148350) { uint64_t blockId; TouchDown(manager, ScreenIntPoint(100, 100), mcc->Time(), &blockId); - if (StaticPrefs::TouchActionEnabled()) { + if (gfxPrefs::TouchActionEnabled()) { SetDefaultAllowedTouchBehavior(manager, blockId); } mcc->AdvanceByMillis(100); diff --git a/gfx/layers/apz/test/gtest/TestPinching.cpp b/gfx/layers/apz/test/gtest/TestPinching.cpp index 6c9b2d850f570..2cde136daa253 100644 --- a/gfx/layers/apz/test/gtest/TestPinching.cpp +++ b/gfx/layers/apz/test/gtest/TestPinching.cpp @@ -161,7 +161,7 @@ class APZCPinchLockingTester : public APZCPinchTester { void twoFingerPan() { ScreenCoord panDistance = - StaticPrefs::APZPinchLockScrollLockThreshold() * 1.2 * tm->GetDPI(); + gfxPrefs::APZPinchLockScrollLockThreshold() * 1.2 * tm->GetDPI(); mFocus = ScreenIntPoint((int)(mFocus.x + panDistance), (int)(mFocus.y)); @@ -174,7 +174,7 @@ class APZCPinchLockingTester : public APZCPinchTester { void twoFingerZoom() { float pinchDistance = - StaticPrefs::APZPinchLockSpanBreakoutThreshold() * 1.2 * tm->GetDPI(); + gfxPrefs::APZPinchLockSpanBreakoutThreshold() * 1.2 * tm->GetDPI(); float newSpan = mSpan + pinchDistance; @@ -191,7 +191,7 @@ class APZCPinchLockingTester : public APZCPinchTester { // Send a small scale input to the APZC float pinchDistance = - StaticPrefs::APZPinchLockSpanBreakoutThreshold() * 0.8 * tm->GetDPI(); + gfxPrefs::APZPinchLockSpanBreakoutThreshold() * 0.8 * tm->GetDPI(); apzc->ReceiveInputEvent( CreatePinchGestureInput(PinchGestureInput::PINCHGESTURE_SCALE, mFocus, mSpan + pinchDistance, mSpan, mcc->Time()), diff --git a/gfx/layers/apz/test/gtest/TestSnapping.cpp b/gfx/layers/apz/test/gtest/TestSnapping.cpp index 4e2cbd582f858..f8eec04953484 100644 --- a/gfx/layers/apz/test/gtest/TestSnapping.cpp +++ b/gfx/layers/apz/test/gtest/TestSnapping.cpp @@ -6,7 +6,7 @@ #include "APZCTreeManagerTester.h" #include "APZTestCommon.h" - +#include "gfxPrefs.h" #include "InputUtils.h" #include "mozilla/StaticPrefs.h" @@ -65,7 +65,7 @@ TEST_F(APZCSnappingTester, Bug1265510) { // inner frame; we verify that it does by checking the inner scroll position. TimeStamp newTransactionTime = now + TimeDuration::FromMilliseconds( - StaticPrefs::MouseWheelTransactionTimeoutMs() + 100); + gfxPrefs::MouseWheelTransactionTimeoutMs() + 100); SmoothWheel(manager, ScreenIntPoint(50, 80), ScreenPoint(0, 6), newTransactionTime); inner->AdvanceAnimationsUntilEnd(); diff --git a/gfx/layers/apz/testutil/APZTestData.h b/gfx/layers/apz/testutil/APZTestData.h index 67cfde3ccac19..2fe1edc3e98bc 100644 --- a/gfx/layers/apz/testutil/APZTestData.h +++ b/gfx/layers/apz/testutil/APZTestData.h @@ -9,12 +9,12 @@ #include +#include "gfxPrefs.h" #include "nsDebug.h" // for NS_WARNING #include "nsTArray.h" #include "mozilla/Assertions.h" // for MOZ_ASSERT #include "mozilla/DebugOnly.h" // for DebugOnly #include "mozilla/GfxMessageUtils.h" // for ParamTraits specializations -#include "mozilla/StaticPrefs.h" #include "mozilla/ToString.h" // for ToString #include "mozilla/gfx/CompositorHitTestInfo.h" #include "mozilla/layers/ScrollableLayerGuid.h" @@ -130,7 +130,7 @@ class APZPaintLogHelper { public: APZPaintLogHelper(APZTestData* aTestData, SequenceNumber aPaintSequenceNumber) : mTestData(aTestData), mPaintSequenceNumber(aPaintSequenceNumber) { - MOZ_ASSERT(!aTestData || StaticPrefs::APZTestLoggingEnabled(), + MOZ_ASSERT(!aTestData || gfxPrefs::APZTestLoggingEnabled(), "don't call me"); } diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp index b38f7e6372b53..96920c0051404 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.cpp +++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -8,7 +8,7 @@ #include "TouchActionHelper.h" #include "gfxPlatform.h" // For gfxPlatform::UseTiling - +#include "gfxPrefs.h" #include "LayersLogging.h" // For Stringify #include "mozilla/dom/Element.h" #include "mozilla/dom/MouseEventBinding.h" diff --git a/gfx/layers/apz/util/APZEventState.cpp b/gfx/layers/apz/util/APZEventState.cpp index add47a278b3ad..8bce559b37947 100644 --- a/gfx/layers/apz/util/APZEventState.cpp +++ b/gfx/layers/apz/util/APZEventState.cpp @@ -8,7 +8,7 @@ #include "ActiveElementManager.h" #include "APZCCallbackHelper.h" - +#include "gfxPrefs.h" #include "LayersLogging.h" #include "mozilla/BasicEvents.h" #include "mozilla/dom/MouseEventBinding.h" @@ -396,7 +396,7 @@ void APZEventState::ProcessTouchEvent(const WidgetTouchEvent& aEvent, if (sentContentResponse && !isTouchPrevented && aApzResponse == nsEventStatus_eConsumeDoDefault && - StaticPrefs::PointerEventsEnabled()) { + gfxPrefs::PointerEventsEnabled()) { WidgetTouchEvent cancelEvent(aEvent); cancelEvent.mMessage = eTouchPointerCancel; cancelEvent.mFlags.mCancelable = false; // mMessage != eTouchCancel; diff --git a/gfx/layers/apz/util/CheckerboardReportService.cpp b/gfx/layers/apz/util/CheckerboardReportService.cpp index 1991104717100..cd1f649ff891e 100644 --- a/gfx/layers/apz/util/CheckerboardReportService.cpp +++ b/gfx/layers/apz/util/CheckerboardReportService.cpp @@ -6,6 +6,7 @@ #include "CheckerboardReportService.h" +#include "gfxPrefs.h" // for gfxPrefs #include "jsapi.h" // for JS_Now #include "MainThreadUtils.h" // for NS_IsMainThread #include "mozilla/Assertions.h" // for MOZ_ASSERT @@ -191,11 +192,11 @@ void CheckerboardReportService::GetReports( } bool CheckerboardReportService::IsRecordingEnabled() const { - return StaticPrefs::APZRecordCheckerboarding(); + return gfxPrefs::APZRecordCheckerboarding(); } void CheckerboardReportService::SetRecordingEnabled(bool aEnabled) { - StaticPrefs::SetAPZRecordCheckerboarding(aEnabled); + gfxPrefs::SetAPZRecordCheckerboarding(aEnabled); } void CheckerboardReportService::FlushActiveReports() { diff --git a/gfx/layers/basic/BasicCompositor.cpp b/gfx/layers/basic/BasicCompositor.cpp index f97ea381b8531..783b05a23ab18 100644 --- a/gfx/layers/basic/BasicCompositor.cpp +++ b/gfx/layers/basic/BasicCompositor.cpp @@ -24,6 +24,7 @@ #include "YCbCrUtils.h" #include #include "ImageContainer.h" +#include "gfxPrefs.h" namespace mozilla { using namespace mozilla::gfx; @@ -367,7 +368,7 @@ bool BasicCompositor::SupportsEffect(EffectTypes aEffect) { } bool BasicCompositor::SupportsLayerGeometry() const { - return StaticPrefs::BasicLayerGeometry(); + return gfxPrefs::BasicLayerGeometry(); } static RefPtr BuildPathFromPolygon(const RefPtr& aDT, @@ -1023,7 +1024,7 @@ void BasicCompositor::EndFrame() { // Pop aClipRectIn/bounds rect mRenderTarget->mDrawTarget->PopClip(); - if (StaticPrefs::WidgetUpdateFlashing()) { + if (gfxPrefs::WidgetUpdateFlashing()) { float r = float(rand()) / RAND_MAX; float g = float(rand()) / RAND_MAX; float b = float(rand()) / RAND_MAX; diff --git a/gfx/layers/basic/BasicLayerManager.cpp b/gfx/layers/basic/BasicLayerManager.cpp index 84c020b3a9ab2..54e5c3b406bd8 100644 --- a/gfx/layers/basic/BasicLayerManager.cpp +++ b/gfx/layers/basic/BasicLayerManager.cpp @@ -23,7 +23,7 @@ #include "gfxImageSurface.h" // for gfxImageSurface #include "gfxMatrix.h" // for gfxMatrix #include "gfxPlatform.h" // for gfxPlatform - +#include "gfxPrefs.h" // for gfxPrefs #include "gfxPoint.h" // for IntSize, gfxPoint #include "gfxRect.h" // for gfxRect #include "gfxUtils.h" // for gfxUtils @@ -661,7 +661,7 @@ bool BasicLayerManager::EndTransactionInternal( } void BasicLayerManager::FlashWidgetUpdateArea(gfxContext* aContext) { - if (StaticPrefs::WidgetUpdateFlashing()) { + if (gfxPrefs::WidgetUpdateFlashing()) { float r = float(rand()) / RAND_MAX; float g = float(rand()) / RAND_MAX; float b = float(rand()) / RAND_MAX; diff --git a/gfx/layers/client/ClientLayerManager.cpp b/gfx/layers/client/ClientLayerManager.cpp index b415d409f79d9..2d3040895e8e1 100644 --- a/gfx/layers/client/ClientLayerManager.cpp +++ b/gfx/layers/client/ClientLayerManager.cpp @@ -7,9 +7,9 @@ #include "ClientLayerManager.h" #include "GeckoProfiler.h" // for AUTO_PROFILER_LABEL #include "gfxEnv.h" // for gfxEnv +#include "gfxPrefs.h" // for gfxPrefs::LayersTile... #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc #include "mozilla/Hal.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/dom/BrowserChild.h" // for BrowserChild #include "mozilla/dom/TabGroup.h" // for TabGroup #include "mozilla/hal_sandbox/PHal.h" // for ScreenConfiguration @@ -244,7 +244,7 @@ bool ClientLayerManager::BeginTransactionWithTarget(gfxContext* aTarget, // enabled in this process; it may be enabled in the parent process, // and the parent process expects unique sequence numbers. ++mPaintSequenceNumber; - if (StaticPrefs::APZTestLoggingEnabled()) { + if (gfxPrefs::APZTestLoggingEnabled()) { mApzTestData.StartNewPaint(mPaintSequenceNumber); } } @@ -280,7 +280,7 @@ bool ClientLayerManager::EndTransactionInternal( AUTO_PROFILER_TRACING("Paint", "Rasterize", GRAPHICS); Maybe startTime; - if (StaticPrefs::LayersDrawFPS()) { + if (gfxPrefs::LayersDrawFPS()) { startTime = Some(TimeStamp::Now()); } @@ -310,7 +310,7 @@ bool ClientLayerManager::EndTransactionInternal( // Skip the painting if the device is in device-reset status. if (!gfxPlatform::GetPlatform()->DidRenderingDeviceReset()) { - if (StaticPrefs::AlwaysPaint() && XRE_IsContentProcess()) { + if (gfxPrefs::AlwaysPaint() && XRE_IsContentProcess()) { TimeStamp start = TimeStamp::Now(); root->RenderLayer(); mLastPaintTime = TimeStamp::Now() - start; @@ -545,7 +545,7 @@ float ClientLayerManager::RequestProperty(const nsAString& aProperty) { void ClientLayerManager::StartNewRepaintRequest( SequenceNumber aSequenceNumber) { - if (StaticPrefs::APZTestLoggingEnabled()) { + if (gfxPrefs::APZTestLoggingEnabled()) { mApzTestData.StartNewRepaintRequest(aSequenceNumber); } } @@ -615,7 +615,7 @@ void ClientLayerManager::FlushRendering() { if (mWidget) { if (CompositorBridgeChild* remoteRenderer = mWidget->GetRemoteRenderer()) { if (mWidget->SynchronouslyRepaintOnResize() || - StaticPrefs::LayersForceSynchronousResize()) { + gfxPrefs::LayersForceSynchronousResize()) { remoteRenderer->SendFlushRendering(); } else { remoteRenderer->SendFlushRenderingAsync(); @@ -696,7 +696,7 @@ void ClientLayerManager::ForwardTransaction(bool aScheduleComposite) { refreshStart = mTransactionStart; } - if (StaticPrefs::AlwaysPaint() && XRE_IsContentProcess()) { + if (gfxPrefs::AlwaysPaint() && XRE_IsContentProcess()) { mForwarder->SendPaintTime(mLatestTransactionId, mLastPaintTime); } @@ -863,7 +863,7 @@ ClientLayerManager::CreatePersistentBufferProvider(const gfx::IntSize& aSize, // instead of being sent to the compositor, in which case rendering into // shared memory is wasteful. if (IsCompositingCheap() && - StaticPrefs::PersistentBufferProviderSharedEnabled()) { + gfxPrefs::PersistentBufferProviderSharedEnabled()) { RefPtr provider = PersistentBufferProviderShared::Create(aSize, aFormat, AsShadowForwarder()); diff --git a/gfx/layers/client/ClientLayerManager.h b/gfx/layers/client/ClientLayerManager.h index 393a96992a497..891a55156b956 100644 --- a/gfx/layers/client/ClientLayerManager.h +++ b/gfx/layers/client/ClientLayerManager.h @@ -10,9 +10,9 @@ #include // for int32_t #include "Layers.h" #include "gfxContext.h" // for gfxContext +#include "gfxPrefs.h" #include "mozilla/Attributes.h" // for override -#include "mozilla/LinkedList.h" // for LinkedList -#include "mozilla/StaticPrefs.h" // for StaticPrefs +#include "mozilla/LinkedList.h" // For LinkedList #include "mozilla/WidgetUtils.h" // for ScreenRotation #include "mozilla/gfx/Rect.h" // for Rect #include "mozilla/layers/CompositorTypes.h" @@ -202,7 +202,7 @@ class ClientLayerManager final : public LayerManager, void LogTestDataForCurrentPaint(ScrollableLayerGuid::ViewID aScrollId, const std::string& aKey, const std::string& aValue) { - MOZ_ASSERT(StaticPrefs::APZTestLoggingEnabled(), "don't call me"); + MOZ_ASSERT(gfxPrefs::APZTestLoggingEnabled(), "don't call me"); mApzTestData.LogTestDataForPaint(mPaintSequenceNumber, aScrollId, aKey, aValue); } @@ -215,18 +215,18 @@ class ClientLayerManager final : public LayerManager, // TODO(botond): When we start using this and write a wrapper similar to // nsLayoutUtils::LogTestDataForPaint(), make sure that wrapper checks - // StaticPrefs::APZTestLoggingEnabled(). + // gfxPrefs::APZTestLoggingEnabled(). void LogTestDataForRepaintRequest(SequenceNumber aSequenceNumber, ScrollableLayerGuid::ViewID aScrollId, const std::string& aKey, const std::string& aValue) { - MOZ_ASSERT(StaticPrefs::APZTestLoggingEnabled(), "don't call me"); + MOZ_ASSERT(gfxPrefs::APZTestLoggingEnabled(), "don't call me"); mApzTestData.LogTestDataForRepaintRequest(aSequenceNumber, aScrollId, aKey, aValue); } void LogAdditionalTestData(const std::string& aKey, const std::string& aValue) { - MOZ_ASSERT(StaticPrefs::APZTestLoggingEnabled(), "don't call me"); + MOZ_ASSERT(gfxPrefs::APZTestLoggingEnabled(), "don't call me"); mApzTestData.RecordAdditionalData(aKey, aValue); } diff --git a/gfx/layers/client/ClientPaintedLayer.cpp b/gfx/layers/client/ClientPaintedLayer.cpp index 3f29084ebc5cb..615f122daf8bb 100644 --- a/gfx/layers/client/ClientPaintedLayer.cpp +++ b/gfx/layers/client/ClientPaintedLayer.cpp @@ -13,7 +13,7 @@ #include "gfx2DGlue.h" #include "gfxEnv.h" // for gfxEnv #include "gfxRect.h" // for gfxRect - +#include "gfxPrefs.h" // for gfxPrefs #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc #include "mozilla/gfx/2D.h" // for DrawTarget #include "mozilla/gfx/DrawEventRecorder.h" diff --git a/gfx/layers/client/ClientTiledPaintedLayer.cpp b/gfx/layers/client/ClientTiledPaintedLayer.cpp index b5ac24e8c323f..f73fe715fd0cc 100644 --- a/gfx/layers/client/ClientTiledPaintedLayer.cpp +++ b/gfx/layers/client/ClientTiledPaintedLayer.cpp @@ -10,9 +10,9 @@ #include "UnitTransforms.h" // for TransformTo #include "ClientLayerManager.h" // for ClientLayerManager, etc #include "gfxPlatform.h" // for gfxPlatform +#include "gfxPrefs.h" // for gfxPrefs #include "gfxRect.h" // for gfxRect #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc -#include "mozilla/StaticPrefs.h" // for StaticPrefs #include "mozilla/gfx/BaseSize.h" // for BaseSize #include "mozilla/gfx/gfxVars.h" #include "mozilla/gfx/Rect.h" // for Rect, RectTyped @@ -85,7 +85,7 @@ static LayerToParentLayerMatrix4x4 GetTransformToAncestorsParentLayer( iter = iter.GetParent()) { transform = transform * iter.GetTransform(); - if (StaticPrefs::LayoutUseContainersForRootFrames()) { + if (gfxPrefs::LayoutUseContainersForRootFrames()) { // When scrolling containers, layout adds a post-scale into the transform // of the displayport-ancestor (which we pick up in GetTransform() above) // to cancel out the pres shell resolution (for historical reasons). The @@ -267,7 +267,7 @@ bool ClientTiledPaintedLayer::IsScrollingOnCompositor( } bool ClientTiledPaintedLayer::UseProgressiveDraw() { - if (!StaticPrefs::ProgressivePaint()) { + if (!gfxPrefs::ProgressivePaint()) { // pref is disabled, so never do progressive return false; } @@ -479,7 +479,7 @@ void ClientTiledPaintedLayer::RenderLayer() { isHalfTileWidthOrHeight) && SingleTiledContentClient::ClientSupportsLayerSize(layerSize, ClientManager()) && - StaticPrefs::LayersSingleTileEnabled(); + gfxPrefs::LayersSingleTileEnabled(); if (mContentClient && mHaveSingleTiledContentClient && !wantSingleTiledContentClient) { diff --git a/gfx/layers/client/ContentClient.cpp b/gfx/layers/client/ContentClient.cpp index 084a87ab6e6fe..63c5d31400db8 100644 --- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -9,7 +9,7 @@ #include "gfxContext.h" // for gfxContext, etc #include "gfxPlatform.h" // for gfxPlatform #include "gfxEnv.h" // for gfxEnv - +#include "gfxPrefs.h" // for gfxPrefs #include "gfxPoint.h" // for IntSize, gfxPoint #include "gfxUtils.h" // for gfxUtils #include "ipc/ShadowLayers.h" // for ShadowLayerForwarder diff --git a/gfx/layers/client/MultiTiledContentClient.cpp b/gfx/layers/client/MultiTiledContentClient.cpp index ba3c78ebace7c..003c5da02cf7a 100644 --- a/gfx/layers/client/MultiTiledContentClient.cpp +++ b/gfx/layers/client/MultiTiledContentClient.cpp @@ -7,7 +7,6 @@ #include "mozilla/layers/MultiTiledContentClient.h" #include "ClientTiledPaintedLayer.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/layers/LayerMetricsWrapper.h" namespace mozilla { @@ -23,8 +22,8 @@ MultiTiledContentClient::MultiTiledContentClient( mLowPrecisionTiledBuffer(aPaintedLayer, *this, aManager, &mSharedFrameMetricsHelper) { MOZ_COUNT_CTOR(MultiTiledContentClient); - mLowPrecisionTiledBuffer.SetResolution(StaticPrefs::LowPrecisionResolution()); - mHasLowPrecision = StaticPrefs::UseLowPrecisionBuffer(); + mLowPrecisionTiledBuffer.SetResolution(gfxPrefs::LowPrecisionResolution()); + mHasLowPrecision = gfxPrefs::UseLowPrecisionBuffer(); } void MultiTiledContentClient::ClearCachedResources() { @@ -265,7 +264,7 @@ void ClientMultiTiledLayerBuffer::Update(const nsIntRegion& newValidRegion, ctx = nullptr; // Edge padding allows us to avoid resampling artifacts - if (StaticPrefs::TileEdgePaddingEnabled() && mResolution == 1) { + if (gfxPrefs::TileEdgePaddingEnabled() && mResolution == 1) { drawTarget->PadEdges(newValidRegion.MovedBy(-mTilingOrigin)); } diff --git a/gfx/layers/client/SingleTiledContentClient.h b/gfx/layers/client/SingleTiledContentClient.h index 70cb37c147617..a4562aa40b1b8 100644 --- a/gfx/layers/client/SingleTiledContentClient.h +++ b/gfx/layers/client/SingleTiledContentClient.h @@ -20,7 +20,7 @@ class ClientLayerManager; * This buffer provides an implementation of ValidateTile using a * thebes callback and can support painting using a single paint buffer. * Whether a single paint buffer is used is controlled by - * StaticPrefs::PerTileDrawing(). + * gfxPrefs::PerTileDrawing(). */ class ClientSingleTiledLayerBuffer : public ClientTiledLayerBuffer, public TextureClientAllocator { diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index db4b98fe5470b..8e57a57c5dde3 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -10,7 +10,6 @@ #include "gfx2DGlue.h" #include "gfxPlatform.h" // for gfxPlatform #include "mozilla/Atomics.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/SystemGroup.h" #include "mozilla/ipc/SharedMemory.h" // for SharedMemory, etc #include "mozilla/layers/CompositableForwarder.h" @@ -33,6 +32,7 @@ #include "gfxUtils.h" // for gfxUtils::GetAsLZ4Base64Str #include "IPDLActor.h" #include "BufferTexture.h" +#include "gfxPrefs.h" #include "mozilla/layers/ShadowLayers.h" #include "mozilla/ipc/CrossProcessSemaphore.h" @@ -1080,13 +1080,13 @@ already_AddRefed TextureClient::CreateForDrawing( #endif #ifdef XP_MACOSX - if (!data && StaticPrefs::UseIOSurfaceTextures()) { + if (!data && gfxPrefs::UseIOSurfaceTextures()) { data = MacIOSurfaceTextureData::Create(aSize, aFormat, moz2DBackend); } #endif #ifdef MOZ_WIDGET_ANDROID - if (!data && StaticPrefs::UseSurfaceTextureTextures()) { + if (!data && gfxPrefs::UseSurfaceTextureTextures()) { data = AndroidNativeWindowTextureData::Create(aSize, aFormat); } #endif @@ -1347,7 +1347,7 @@ void TextureClient::PrintInfo(std::stringstream& aStream, const char* aPrefix) { AppendToString(aStream, mFlags, " [flags=", "]"); #ifdef MOZ_DUMP_PAINTING - if (StaticPrefs::LayersDumpTexture()) { + if (gfxPrefs::LayersDumpTexture()) { nsAutoCString pfx(aPrefix); pfx += " "; diff --git a/gfx/layers/client/TextureClientPool.cpp b/gfx/layers/client/TextureClientPool.cpp index 081c4ab2bfc3a..48b00739f95a7 100644 --- a/gfx/layers/client/TextureClientPool.cpp +++ b/gfx/layers/client/TextureClientPool.cpp @@ -9,7 +9,8 @@ #include "mozilla/layers/CompositableForwarder.h" #include "mozilla/layers/TextureForwarder.h" #include "mozilla/layers/TiledContentClient.h" -#include "mozilla/StaticPrefs.h" + +#include "gfxPrefs.h" #include "nsComponentManagerUtils.h" @@ -141,7 +142,7 @@ void TextureClientPool::AllocateTextureClient() { } RefPtr newClient; - if (StaticPrefs::ForceShmemTiles()) { + if (gfxPrefs::ForceShmemTiles()) { // gfx::BackendType::NONE means use the content backend newClient = TextureClient::CreateForRawBufferAccess( mSurfaceAllocator, mFormat, mSize, gfx::BackendType::NONE, mBackend, diff --git a/gfx/layers/client/TiledContentClient.cpp b/gfx/layers/client/TiledContentClient.cpp index 03b6a227cfa81..861fd4ae6246f 100644 --- a/gfx/layers/client/TiledContentClient.cpp +++ b/gfx/layers/client/TiledContentClient.cpp @@ -12,6 +12,7 @@ #include "ClientLayerManager.h" // for ClientLayerManager #include "gfxContext.h" // for gfxContext, etc #include "gfxPlatform.h" // for gfxPlatform +#include "gfxPrefs.h" // for gfxPrefs #include "gfxRect.h" // for gfxRect #include "mozilla/MathAlgorithms.h" // for Abs #include "mozilla/gfx/Point.h" // for IntSize @@ -28,7 +29,6 @@ #include "nsMathUtils.h" // for NS_lroundf #include "LayersLogging.h" #include "UnitTransforms.h" // for TransformTo -#include "mozilla/StaticPrefs.h" #include "mozilla/UniquePtr.h" #ifdef GFX_TILEDLAYER_DEBUG_OVERLAY @@ -230,7 +230,7 @@ bool SharedFrameMetricsHelper::AboutToCheckerboard( CSSRect(aCompositorMetrics.GetScrollOffset(), aCompositorMetrics.CalculateBoundedCompositedSizeInCssPixels()); showing.Inflate( - LayerSize(StaticPrefs::APZDangerZoneX(), StaticPrefs::APZDangerZoneY()) / + LayerSize(gfxPrefs::APZDangerZoneX(), gfxPrefs::APZDangerZoneY()) / aCompositorMetrics.LayersPixelsPerCSSPixel()); // Clamp both rects to the scrollable rect, because having either of those @@ -600,7 +600,7 @@ Maybe TileClient::AcquireBackBuffer( // later (copying pixels and texture upload). But this could increase // our memory usage and lead to OOM more frequently from spikes in usage, // so we have this behavior behind a pref. - if (!StaticPrefs::LayersTileRetainBackBuffer()) { + if (!gfxPrefs::LayersTileRetainBackBuffer()) { DiscardBackBuffer(); } Flip(); @@ -678,7 +678,7 @@ Maybe TileClient::AcquireBackBuffer( RefPtr capture; if (aFlags & TilePaintFlags::Async) { capture = Factory::CreateCaptureDrawTargetForTarget( - target, StaticPrefs::LayersOMTPCaptureLimit()); + target, gfxPrefs::LayersOMTPCaptureLimit()); target = capture; } diff --git a/gfx/layers/client/TiledContentClient.h b/gfx/layers/client/TiledContentClient.h index 3e3c037c4a4d0..8accb64e3d918 100644 --- a/gfx/layers/client/TiledContentClient.h +++ b/gfx/layers/client/TiledContentClient.h @@ -315,7 +315,7 @@ class SharedFrameMetricsHelper { * This buffer provides an implementation of ValidateTile using a * thebes callback and can support painting using a single paint buffer. * Whether a single paint buffer is used is controlled by - * StaticPrefs::PerTileDrawing(). + * gfxPrefs::PerTileDrawing(). */ class ClientTiledLayerBuffer { public: diff --git a/gfx/layers/composite/AsyncCompositionManager.cpp b/gfx/layers/composite/AsyncCompositionManager.cpp index 86b46153018e7..bd27fb5359152 100644 --- a/gfx/layers/composite/AsyncCompositionManager.cpp +++ b/gfx/layers/composite/AsyncCompositionManager.cpp @@ -9,8 +9,8 @@ #include "LayerManagerComposite.h" // for LayerManagerComposite, etc #include "Layers.h" // for Layer, ContainerLayer, etc #include "gfxPoint.h" // for gfxPoint, gfxSize +#include "gfxPrefs.h" // for gfxPrefs #include "mozilla/ServoBindings.h" // for Servo_AnimationValue_GetOpacity, etc -#include "mozilla/StaticPrefs.h" // for StaticPrefs #include "mozilla/WidgetUtils.h" // for ComputeTransformForRotation #include "mozilla/gfx/BaseRect.h" // for BaseRect #include "mozilla/gfx/Point.h" // for RoundedToInt, PointTyped @@ -35,6 +35,7 @@ #include "nsTArray.h" // for nsTArray, nsTArray_Impl, etc #include "nsTArrayForwardDeclare.h" // for InfallibleTArray #include "UnitTransforms.h" // for TransformTo +#include "gfxPrefs.h" #if defined(MOZ_WIDGET_ANDROID) # include # include "mozilla/layers/UiCompositorControllerParent.h" @@ -789,7 +790,7 @@ static bool SampleAnimations(Layer* aLayer, } void AsyncCompositionManager::RecordShadowTransforms(Layer* aLayer) { - MOZ_ASSERT(StaticPrefs::CollectScrollTransforms()); + MOZ_ASSERT(gfxPrefs::CollectScrollTransforms()); MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); ForEachNodePostOrder(aLayer, [this](Layer* layer) { @@ -1472,7 +1473,7 @@ bool AsyncCompositionManager::TransformShadowTree( trans *= gfx::Matrix4x4::From2D(mWorldTransform); rootComposite->SetShadowBaseTransform(trans); - if (StaticPrefs::CollectScrollTransforms()) { + if (gfxPrefs::CollectScrollTransforms()) { RecordShadowTransforms(root); } @@ -1487,9 +1488,9 @@ void AsyncCompositionManager::SetFixedLayerMargins(ScreenIntCoord aTop, } ScreenMargin AsyncCompositionManager::GetFixedLayerMargins() const { ScreenMargin result = mFixedLayerMargins; - if (StaticPrefs::APZFixedMarginOverrideEnabled()) { - result.top = StaticPrefs::APZFixedMarginOverrideTop(); - result.bottom = StaticPrefs::APZFixedMarginOverrideBottom(); + if (gfxPrefs::APZFixedMarginOverrideEnabled()) { + result.top = gfxPrefs::APZFixedMarginOverrideTop(); + result.bottom = gfxPrefs::APZFixedMarginOverrideBottom(); } return result; } diff --git a/gfx/layers/composite/ContainerLayerComposite.cpp b/gfx/layers/composite/ContainerLayerComposite.cpp index 67fc44e476b78..e4314b20c6cba 100644 --- a/gfx/layers/composite/ContainerLayerComposite.cpp +++ b/gfx/layers/composite/ContainerLayerComposite.cpp @@ -10,9 +10,9 @@ #include "Units.h" // for LayerRect, LayerPixel, etc #include "CompositableHost.h" // for CompositableHost #include "gfxEnv.h" // for gfxEnv +#include "gfxPrefs.h" // for gfxPrefs #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc #include "mozilla/RefPtr.h" // for RefPtr -#include "mozilla/StaticPrefs.h" // for StaticPrefs #include "mozilla/UniquePtr.h" // for UniquePtr #include "mozilla/gfx/BaseRect.h" // for BaseRect #include "mozilla/gfx/Matrix.h" // for Matrix4x4 @@ -432,7 +432,7 @@ void RenderLayers(ContainerT* aContainer, LayerManagerComposite* aManager, continue; } - if (StaticPrefs::LayersDrawFPS()) { + if (gfxPrefs::LayersDrawFPS()) { for (const auto& metadata : layer->GetAllScrollMetadata()) { if (metadata.IsApzForceDisabled()) { aManager->DisabledApzWarning(); @@ -473,11 +473,11 @@ void RenderLayers(ContainerT* aContainer, LayerManagerComposite* aManager, layerToRender->RenderLayer(clipRect, geometry); } - if (StaticPrefs::UniformityInfo()) { + if (gfxPrefs::UniformityInfo()) { PrintUniformityInfo(layer); } - if (StaticPrefs::DrawLayerInfo()) { + if (gfxPrefs::DrawLayerInfo()) { DrawLayerInfo(preparedData.mClipRect, aManager, layer); } @@ -509,7 +509,7 @@ void RenderLayers(ContainerT* aContainer, LayerManagerComposite* aManager, } } - if (StaticPrefs::APZMinimap()) { + if (gfxPrefs::APZMinimap()) { RenderMinimap(aContainer, sampler, aManager, aClipRect, layer); } } @@ -650,8 +650,7 @@ void ContainerRender(ContainerT* aContainer, LayerManagerComposite* aManager, // APZCs attached to it has a nonempty async transform, then that transform is // not applied to any visible content. Display a warning box (conditioned on // the FPS display being enabled). - if (StaticPrefs::LayersDrawFPS() && - aContainer->IsScrollableWithoutContent()) { + if (gfxPrefs::LayersDrawFPS() && aContainer->IsScrollableWithoutContent()) { RefPtr sampler = aManager->GetCompositor()->GetCompositorBridgeParent()->GetAPZSampler(); // Since aContainer doesn't have any children we can just iterate from the diff --git a/gfx/layers/composite/Diagnostics.h b/gfx/layers/composite/Diagnostics.h index 17ebabf623e46..522ab55ac1a57 100644 --- a/gfx/layers/composite/Diagnostics.h +++ b/gfx/layers/composite/Diagnostics.h @@ -8,8 +8,8 @@ #define mozilla_gfx_layers_composite_Diagnostics_h #include "FPSCounter.h" +#include "gfxPrefs.h" #include "mozilla/Maybe.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/TimeStamp.h" #include #include @@ -66,7 +66,7 @@ class Diagnostics { class Record { public: explicit Record(TimeStamp aStart = TimeStamp()) { - if (StaticPrefs::LayersDrawFPS()) { + if (gfxPrefs::LayersDrawFPS()) { mStart = aStart.IsNull() ? TimeStamp::Now() : aStart; } } diff --git a/gfx/layers/composite/FPSCounter.cpp b/gfx/layers/composite/FPSCounter.cpp index 820ab23b3c291..2543dbd11f3e7 100644 --- a/gfx/layers/composite/FPSCounter.cpp +++ b/gfx/layers/composite/FPSCounter.cpp @@ -7,13 +7,13 @@ #include // for size_t #include "Units.h" // for ScreenIntRect #include "gfxRect.h" // for gfxRect +#include "gfxPrefs.h" // for gfxPrefs #include "mozilla/gfx/Point.h" // for IntSize, Point #include "mozilla/gfx/Rect.h" // for Rect #include "mozilla/gfx/Types.h" // for Color, SurfaceFormat #include "mozilla/layers/Compositor.h" // for Compositor #include "mozilla/layers/CompositorTypes.h" #include "mozilla/layers/Effects.h" // for Effect, EffectChain, etc -#include "mozilla/StaticPrefs.h" // for StaticPrefs #include "mozilla/TimeStamp.h" // for TimeStamp, TimeDuration #include "nsPoint.h" // for nsIntPoint #include "nsRect.h" // for mozilla::gfx::IntRect @@ -259,7 +259,7 @@ double FPSCounter::GetStdDev(std::map aHistogram) { } void FPSCounter::PrintFPS() { - if (!StaticPrefs::FPSPrintHistogram()) { + if (!gfxPrefs::FPSPrintHistogram()) { return; } @@ -308,7 +308,7 @@ void FPSCounter::PrintHistogram(std::map& aHistogram) { // Write FPS timestamp data to a file only if // draw-fps.write-to-file is true nsresult FPSCounter::WriteFrameTimeStamps() { - if (!StaticPrefs::WriteFPSToFile()) { + if (!gfxPrefs::WriteFPSToFile()) { return NS_OK; } diff --git a/gfx/layers/composite/LayerManagerComposite.cpp b/gfx/layers/composite/LayerManagerComposite.cpp index aed6f2e49aec9..48e1b7e7406d0 100644 --- a/gfx/layers/composite/LayerManagerComposite.cpp +++ b/gfx/layers/composite/LayerManagerComposite.cpp @@ -25,7 +25,7 @@ #include "UnitTransforms.h" // for ViewAs #include "apz/src/AsyncPanZoomController.h" // for AsyncPanZoomController #include "gfxEnv.h" // for gfxEnv - +#include "gfxPrefs.h" // for gfxPrefs #ifdef XP_MACOSX # include "gfxPlatformMac.h" #endif @@ -622,8 +622,8 @@ LayerComposite* LayerManagerComposite::RootLayer() const { void LayerManagerComposite::InvalidateDebugOverlay(nsIntRegion& aInvalidRegion, const IntRect& aBounds) { - bool drawFps = StaticPrefs::LayersDrawFPS(); - bool drawFrameColorBars = StaticPrefs::CompositorDrawColorBars(); + bool drawFps = gfxPrefs::LayersDrawFPS(); + bool drawFrameColorBars = gfxPrefs::CompositorDrawColorBars(); if (drawFps) { aInvalidRegion.Or(aInvalidRegion, nsIntRect(0, 0, 650, 400)); @@ -633,7 +633,7 @@ void LayerManagerComposite::InvalidateDebugOverlay(nsIntRegion& aInvalidRegion, } #ifdef USE_SKIA - bool drawPaintTimes = StaticPrefs::AlwaysPaint(); + bool drawPaintTimes = gfxPrefs::AlwaysPaint(); if (drawPaintTimes) { aInvalidRegion.Or(aInvalidRegion, nsIntRect(PaintCounter::GetPaintRect())); } @@ -653,8 +653,8 @@ void LayerManagerComposite::DrawPaintTimes(Compositor* aCompositor) { static uint16_t sFrameCount = 0; void LayerManagerComposite::RenderDebugOverlay(const IntRect& aBounds) { - bool drawFps = StaticPrefs::LayersDrawFPS(); - bool drawFrameColorBars = StaticPrefs::CompositorDrawColorBars(); + bool drawFps = gfxPrefs::LayersDrawFPS(); + bool drawFrameColorBars = gfxPrefs::CompositorDrawColorBars(); // Don't draw diagnostic overlays if we want to snapshot the output. if (mTarget) { @@ -764,7 +764,7 @@ void LayerManagerComposite::RenderDebugOverlay(const IntRect& aBounds) { } #ifdef USE_SKIA - bool drawPaintTimes = StaticPrefs::AlwaysPaint(); + bool drawPaintTimes = gfxPrefs::AlwaysPaint(); if (drawPaintTimes) { DrawPaintTimes(mCompositor); } @@ -775,9 +775,9 @@ RefPtr LayerManagerComposite::PushGroupForLayerEffects() { // This is currently true, so just making sure that any new use of this // method is flagged for investigation - MOZ_ASSERT(StaticPrefs::LayersEffectInvert() || - StaticPrefs::LayersEffectGrayscale() || - StaticPrefs::LayersEffectContrast() != 0.0); + MOZ_ASSERT(gfxPrefs::LayersEffectInvert() || + gfxPrefs::LayersEffectGrayscale() || + gfxPrefs::LayersEffectContrast() != 0.0); RefPtr previousTarget = mCompositor->GetCurrentRenderTarget(); @@ -905,16 +905,16 @@ void LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion, // permutations. However, may as well just get the values onces and // then use them, just in case the consistency becomes important in // the future. - bool invertVal = StaticPrefs::LayersEffectInvert(); - bool grayscaleVal = StaticPrefs::LayersEffectGrayscale(); - float contrastVal = StaticPrefs::LayersEffectContrast(); + bool invertVal = gfxPrefs::LayersEffectInvert(); + bool grayscaleVal = gfxPrefs::LayersEffectGrayscale(); + float contrastVal = gfxPrefs::LayersEffectContrast(); bool haveLayerEffects = (invertVal || grayscaleVal || contrastVal != 0.0); // Set LayerScope begin/end frame LayerScopeAutoFrame frame(PR_Now()); // Dump to console - if (StaticPrefs::LayersDump()) { + if (gfxPrefs::LayersDump()) { this->Dump(/* aSorted= */ true); } @@ -1425,7 +1425,7 @@ bool LayerManagerComposite::CanUseCanvasLayerForSize(const IntSize& aSize) { } void LayerManagerComposite::NotifyShadowTreeTransaction() { - if (StaticPrefs::LayersDrawFPS()) { + if (gfxPrefs::LayersDrawFPS()) { mDiagnostics->AddTxnFrame(); } } diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index ec50de2ec4ae5..811f5a6e16466 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -36,7 +36,7 @@ #include "mozilla/Unused.h" #include #include "../opengl/CompositorOGL.h" - +#include "gfxPrefs.h" #include "gfxUtils.h" #include "IPDLActor.h" @@ -429,7 +429,7 @@ void TextureHost::PrintInfo(std::stringstream& aStream, const char* aPrefix) { } AppendToString(aStream, mFlags, " [flags=", "]"); #ifdef MOZ_DUMP_PAINTING - if (StaticPrefs::LayersDumpTexture()) { + if (gfxPrefs::LayersDumpTexture()) { nsAutoCString pfx(aPrefix); pfx += " "; diff --git a/gfx/layers/composite/TiledContentHost.cpp b/gfx/layers/composite/TiledContentHost.cpp index 5531efc4150a2..915682ff4c94d 100644 --- a/gfx/layers/composite/TiledContentHost.cpp +++ b/gfx/layers/composite/TiledContentHost.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "TiledContentHost.h" +#include "gfxPrefs.h" // for gfxPrefs #include "PaintedLayerComposite.h" // for PaintedLayerComposite #include "mozilla/gfx/BaseSize.h" // for BaseSize #include "mozilla/gfx/Matrix.h" // for Matrix4x4 @@ -24,7 +25,6 @@ #include "nsPoint.h" // for IntPoint #include "nsPrintfCString.h" // for nsPrintfCString #include "nsRect.h" // for IntRect -#include "mozilla/StaticPrefs.h" #include "mozilla/layers/TextureClient.h" namespace mozilla { @@ -35,12 +35,12 @@ class Layer; float TileHost::GetFadeInOpacity(float aOpacity) { TimeStamp now = TimeStamp::Now(); - if (!StaticPrefs::LayerTileFadeInEnabled() || mFadeStart.IsNull() || + if (!gfxPrefs::LayerTileFadeInEnabled() || mFadeStart.IsNull() || now < mFadeStart) { return aOpacity; } - float duration = StaticPrefs::LayerTileFadeInDuration(); + float duration = gfxPrefs::LayerTileFadeInDuration(); float elapsed = (now - mFadeStart).ToMilliseconds(); if (elapsed > duration) { mFadeStart = TimeStamp(); @@ -338,8 +338,8 @@ bool TiledLayerBufferComposite::UseTiles(const SurfaceDescriptorTiles& aTiles, tile.mFadeStart = TimeStamp::Now(); aLayerManager->CompositeUntil( - tile.mFadeStart + TimeDuration::FromMilliseconds( - StaticPrefs::LayerTileFadeInDuration())); + tile.mFadeStart + + TimeDuration::FromMilliseconds(gfxPrefs::LayerTileFadeInDuration())); } } @@ -422,7 +422,7 @@ void TiledContentHost::Composite( // we end up changing the expected overall transparency of the content, // and it just looks wrong. Color backgroundColor; - if (aOpacity == 1.0f && StaticPrefs::LowPrecisionOpacity() < 1.0f) { + if (aOpacity == 1.0f && gfxPrefs::LowPrecisionOpacity() < 1.0f) { // Background colors are only stored on scrollable layers. Grab // the one from the nearest scrollable ancestor layer. for (LayerMetricsWrapper ancestor(GetLayer(), @@ -436,7 +436,7 @@ void TiledContentHost::Composite( } float lowPrecisionOpacityReduction = (aOpacity == 1.0f && backgroundColor.a == 1.0f) - ? StaticPrefs::LowPrecisionOpacity() + ? gfxPrefs::LowPrecisionOpacity() : 1.0f; nsIntRegion tmpRegion; @@ -631,7 +631,7 @@ void TiledContentHost::PrintInfo(std::stringstream& aStream, aStream << nsPrintfCString("TiledContentHost (0x%p)", this).get(); #if defined(MOZ_DUMP_PAINTING) - if (StaticPrefs::LayersDumpTexture()) { + if (gfxPrefs::LayersDumpTexture()) { nsAutoCString pfx(aPrefix); pfx += " "; diff --git a/gfx/layers/d3d11/CompositorD3D11.cpp b/gfx/layers/d3d11/CompositorD3D11.cpp index ccd3aa7df5127..7487e2b193327 100644 --- a/gfx/layers/d3d11/CompositorD3D11.cpp +++ b/gfx/layers/d3d11/CompositorD3D11.cpp @@ -21,6 +21,7 @@ #include "mozilla/layers/Effects.h" #include "mozilla/layers/HelpersD3D11.h" #include "nsWindowsHelpers.h" +#include "gfxPrefs.h" #include "gfxConfig.h" #include "gfxCrashReporterUtils.h" #include "gfxUtils.h" @@ -28,7 +29,6 @@ #include "mozilla/widget/WinCompositorWidget.h" #include "mozilla/EnumeratedArray.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Telemetry.h" #include "BlendShaderConstants.h" @@ -109,7 +109,7 @@ CompositorD3D11::CompositorD3D11(CompositorBridgeParent* aParent, mIsDoubleBuffered(false), mVerifyBuffersFailed(false), mUseMutexOnPresent(false) { - mUseMutexOnPresent = StaticPrefs::UseMutexOnPresent(); + mUseMutexOnPresent = gfxPrefs::UseMutexOnPresent(); } CompositorD3D11::~CompositorD3D11() {} @@ -122,7 +122,7 @@ void CompositorD3D11::SetVertexBuffer(ID3D11Buffer* aBuffer) { } bool CompositorD3D11::SupportsLayerGeometry() const { - return StaticPrefs::D3D11LayerGeometry(); + return gfxPrefs::D3D11LayerGeometry(); } bool CompositorD3D11::UpdateDynamicVertexBuffer( @@ -201,7 +201,7 @@ bool CompositorD3D11::Initialize(nsCString* const out_failureReason) { (IDXGIFactory2**)getter_AddRefs(dxgiFactory2)); #if (_WIN32_WINDOWS_MAXVER >= 0x0A00) - if (StaticPrefs::Direct3D11UseDoubleBuffering() && SUCCEEDED(hr) && + if (gfxPrefs::Direct3D11UseDoubleBuffering() && SUCCEEDED(hr) && dxgiFactory2 && IsWindows10OrGreater()) { // DXGI_SCALING_NONE is not available on Windows 7 with Platform Update. // This looks awful for things like the awesome bar and browser window @@ -290,10 +290,10 @@ bool CompositorD3D11::Initialize(nsCString* const out_failureReason) { } bool CanUsePartialPresents(ID3D11Device* aDevice) { - if (StaticPrefs::PartialPresent() > 0) { + if (gfxPrefs::PartialPresent() > 0) { return true; } - if (StaticPrefs::PartialPresent() < 0) { + if (gfxPrefs::PartialPresent() < 0) { return false; } if (DeviceManagerDx::Get()->IsWARP()) { @@ -1048,7 +1048,7 @@ void CompositorD3D11::DrawGeometry(const Geometry& aGeometry, mContext->PSSetShaderResources(TexSlot::Y, 3, srViews); } break; case EffectTypes::COMPONENT_ALPHA: { - MOZ_ASSERT(StaticPrefs::ComponentAlphaEnabled()); + MOZ_ASSERT(gfxPrefs::ComponentAlphaEnabled()); MOZ_ASSERT(mAttachments->mComponentBlendState); EffectComponentAlpha* effectComponentAlpha = static_cast(aEffectChain.mPrimaryEffect.get()); @@ -1200,7 +1200,7 @@ void CompositorD3D11::BeginFrame(const nsIntRegion& aInvalidRegion, } } - if (StaticPrefs::LayersDrawFPS()) { + if (gfxPrefs::LayersDrawFPS()) { uint32_t pixelsPerFrame = 0; for (auto iter = mBackBufferInvalid.RectIter(); !iter.Done(); iter.Next()) { pixelsPerFrame += iter.Get().Width() * iter.Get().Height(); @@ -1245,7 +1245,7 @@ void CompositorD3D11::EndFrame() { if (oldSize == mSize) { Present(); - if (StaticPrefs::CompositorClearState()) { + if (gfxPrefs::CompositorClearState()) { mContext->ClearState(); } } else { diff --git a/gfx/layers/d3d11/DeviceAttachmentsD3D11.cpp b/gfx/layers/d3d11/DeviceAttachmentsD3D11.cpp index 9835cac7a9f21..c2bc1a6475263 100644 --- a/gfx/layers/d3d11/DeviceAttachmentsD3D11.cpp +++ b/gfx/layers/d3d11/DeviceAttachmentsD3D11.cpp @@ -5,10 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "DeviceAttachmentsD3D11.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Telemetry.h" #include "mozilla/layers/Compositor.h" #include "CompositorD3D11Shaders.h" +#include "gfxPrefs.h" #include "ShaderDefinitionsD3D11.h" namespace mozilla { @@ -179,7 +179,7 @@ bool DeviceAttachmentsD3D11::Initialize() { return false; } - if (StaticPrefs::ComponentAlphaEnabled()) { + if (gfxPrefs::ComponentAlphaEnabled()) { D3D11_RENDER_TARGET_BLEND_DESC rtBlendComponent = { TRUE, D3D11_BLEND_ONE, @@ -275,7 +275,7 @@ bool DeviceAttachmentsD3D11::CreateShaders() { InitPixelShader(sYCbCrShaderMask, mYCbCrShader, MaskType::Mask); InitPixelShader(sNV12Shader, mNV12Shader, MaskType::MaskNone); InitPixelShader(sNV12ShaderMask, mNV12Shader, MaskType::Mask); - if (StaticPrefs::ComponentAlphaEnabled()) { + if (gfxPrefs::ComponentAlphaEnabled()) { InitPixelShader(sComponentAlphaShader, mComponentAlphaShader, MaskType::MaskNone); InitPixelShader(sComponentAlphaShaderMask, mComponentAlphaShader, diff --git a/gfx/layers/d3d11/MLGDeviceD3D11.cpp b/gfx/layers/d3d11/MLGDeviceD3D11.cpp index f6cb764b64a31..2c268088e35b2 100644 --- a/gfx/layers/d3d11/MLGDeviceD3D11.cpp +++ b/gfx/layers/d3d11/MLGDeviceD3D11.cpp @@ -20,7 +20,7 @@ #include "MLGShaders.h" #include "TextureD3D11.h" #include "gfxConfig.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" namespace mozilla { namespace layers { @@ -232,7 +232,7 @@ bool MLGSwapChainD3D11::Initialize(CompositorWidget* aWidget) { } RefPtr dxgiFactory2; - if (StaticPrefs::Direct3D11UseDoubleBuffering() && + if (gfxPrefs::Direct3D11UseDoubleBuffering() && SUCCEEDED(dxgiFactory->QueryInterface(dxgiFactory2.StartAssignment())) && dxgiFactory2 && IsWin10OrLater() && XRE_IsGPUProcess()) { // DXGI_SCALING_NONE is not available on Windows 7 with the Platform Update: @@ -321,7 +321,7 @@ RefPtr MLGSwapChainD3D11::AcquireBackBuffer() { if (!mRT) { MLGRenderTargetFlags flags = MLGRenderTargetFlags::Default; - if (StaticPrefs::AdvancedLayersEnableDepthBuffer()) { + if (gfxPrefs::AdvancedLayersEnableDepthBuffer()) { flags |= MLGRenderTargetFlags::ZBuffer; } diff --git a/gfx/layers/d3d11/TextureD3D11.cpp b/gfx/layers/d3d11/TextureD3D11.cpp index c75f4e5aba18c..792ce62b00a12 100644 --- a/gfx/layers/d3d11/TextureD3D11.cpp +++ b/gfx/layers/d3d11/TextureD3D11.cpp @@ -11,7 +11,7 @@ #include "ReadbackManagerD3D11.h" #include "gfx2DGlue.h" #include "gfxContext.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "gfxWindowsPlatform.h" #include "mozilla/gfx/DataSurfaceHelpers.h" #include "mozilla/gfx/DeviceManagerDx.h" @@ -286,7 +286,7 @@ static void DestroyDrawTarget(RefPtr& aDT, D3D11TextureData::~D3D11TextureData() { if (mDrawTarget) { - if (PaintThread::Get() && StaticPrefs::Direct2DDestroyDTOnPaintThread()) { + if (PaintThread::Get() && gfxPrefs::Direct2DDestroyDTOnPaintThread()) { RefPtr dt = mDrawTarget; RefPtr tex = mTexture; RefPtr task = NS_NewRunnableFunction( diff --git a/gfx/layers/ipc/CompositorBench.cpp b/gfx/layers/ipc/CompositorBench.cpp index d98f405ca7e32..a9b9c6dcf10a5 100644 --- a/gfx/layers/ipc/CompositorBench.cpp +++ b/gfx/layers/ipc/CompositorBench.cpp @@ -10,8 +10,8 @@ # include "mozilla/gfx/2D.h" # include "mozilla/layers/Compositor.h" # include "mozilla/layers/Effects.h" -# include "mozilla/StaticPrefs.h" # include "mozilla/TimeStamp.h" +# include "gfxPrefs.h" # include # include "GeckoProfiler.h" @@ -335,7 +335,7 @@ static void RunCompositorBench(Compositor* aCompositor, void CompositorBench(Compositor* aCompositor, const gfx::IntRect& aScreenRect) { static bool sRanBenchmark = false; - bool wantBenchmark = StaticPrefs::LayersBenchEnabled(); + bool wantBenchmark = gfxPrefs::LayersBenchEnabled(); if (wantBenchmark && !sRanBenchmark) { RunCompositorBench(aCompositor, aScreenRect); } diff --git a/gfx/layers/ipc/CompositorBridgeChild.cpp b/gfx/layers/ipc/CompositorBridgeChild.cpp index 1c3ffe21c8f08..55fd46d54a737 100644 --- a/gfx/layers/ipc/CompositorBridgeChild.cpp +++ b/gfx/layers/ipc/CompositorBridgeChild.cpp @@ -11,7 +11,7 @@ #include "ClientLayerManager.h" // for ClientLayerManager #include "base/message_loop.h" // for MessageLoop #include "base/task.h" // for NewRunnableMethod, etc -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "mozilla/dom/TabGroup.h" #include "mozilla/layers/CompositorManagerChild.h" #include "mozilla/layers/ImageBridgeChild.h" @@ -870,10 +870,10 @@ TextureClientPool* CompositorBridgeChild::GetTexturePool( aAllocator->GetCompositorBackendType(), aAllocator->SupportsTextureDirectMapping(), aAllocator->GetMaxTextureSize(), aFormat, gfx::gfxVars::TileSize(), - aFlags, StaticPrefs::LayersTilePoolShrinkTimeout(), - StaticPrefs::LayersTilePoolClearTimeout(), - StaticPrefs::LayersTileInitialPoolSize(), - StaticPrefs::LayersTilePoolUnusedSize(), this)); + aFlags, gfxPrefs::LayersTilePoolShrinkTimeout(), + gfxPrefs::LayersTilePoolClearTimeout(), + gfxPrefs::LayersTileInitialPoolSize(), + gfxPrefs::LayersTilePoolUnusedSize(), this)); return mTexturePools.LastElement(); } diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index c8964f4be451e..350af63836fbd 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -24,12 +24,13 @@ #ifdef MOZ_WIDGET_GTK # include "gfxPlatformGtk.h" // for gfxPlatform #endif +#include "gfxPrefs.h" // for gfxPrefs #include "mozilla/AutoRestore.h" // for AutoRestore #include "mozilla/ClearOnShutdown.h" // for ClearOnShutdown #include "mozilla/DebugOnly.h" // for DebugOnly -#include "mozilla/StaticPrefs.h" // for StaticPrefs #include "mozilla/dom/BrowserParent.h" #include "mozilla/gfx/2D.h" // for DrawTarget +#include "mozilla/gfx/GPUChild.h" // for GfxPrefValue #include "mozilla/gfx/Point.h" // for IntSize #include "mozilla/gfx/Rect.h" // for IntSize #include "mozilla/gfx/gfxVars.h" // for gfxVars @@ -293,10 +294,10 @@ static int32_t CalculateCompositionFrameRate() { // DEFAULT_FRAME_RATE in nsRefreshDriver.cpp. // TODO: This should actually return the vsync rate. const int32_t defaultFrameRate = 60; - int32_t compositionFrameRatePref = StaticPrefs::LayersCompositionFrameRate(); + int32_t compositionFrameRatePref = gfxPrefs::LayersCompositionFrameRate(); if (compositionFrameRatePref < 0) { // Use the same frame rate for composition as for layout. - int32_t layoutFrameRatePref = StaticPrefs::LayoutFrameRate(); + int32_t layoutFrameRatePref = gfxPrefs::LayoutFrameRate(); if (layoutFrameRatePref < 0) { // TODO: The main thread frame scheduling code consults the actual // monitor refresh rate in this case. We should do the same. @@ -1003,7 +1004,7 @@ void CompositorBridgeParent::CompositeToTarget(VsyncId aId, DrawTarget* aTarget, RenderTraceLayers(mLayerManager->GetRoot(), "0000"); #ifdef MOZ_DUMP_PAINTING - if (StaticPrefs::DumpHostLayers()) { + if (gfxPrefs::DumpHostLayers()) { printf_stderr("Painting --- compositing layer tree:\n"); mLayerManager->Dump(/* aSorted = */ true); } @@ -1043,7 +1044,7 @@ void CompositorBridgeParent::CompositeToTarget(VsyncId aId, DrawTarget* aTarget, #endif // 0 -> Full-tilt composite - if (StaticPrefs::LayersCompositionFrameRate() == 0 || + if (gfxPrefs::LayersCompositionFrameRate() == 0 || mLayerManager->AlwaysScheduleComposite()) { // Special full-tilt composite mode for performance testing ScheduleComposition(); @@ -1215,7 +1216,7 @@ void CompositorBridgeParent::ScheduleRotationOnCompositorThread( "layers::CompositorBridgeParent::ForceComposition", this, &CompositorBridgeParent::ForceComposition); mForceCompositionTask = task; - ScheduleTask(task.forget(), StaticPrefs::OrientationSyncMillis()); + ScheduleTask(task.forget(), gfxPrefs::OrientationSyncMillis()); } } @@ -1553,7 +1554,7 @@ PLayerTransactionParent* CompositorBridgeParent::AllocPLayerTransactionParent( #ifdef XP_WIN // This is needed to avoid freezing the window on a device crash on double // buffering, see bug 1549674. - if (StaticPrefs::Direct3D11UseDoubleBuffering() && IsWin10OrLater() && + if (gfxPrefs::Direct3D11UseDoubleBuffering() && IsWin10OrLater() && XRE_IsGPUProcess()) { mWidget->AsWindows()->EnsureCompositorWindow(); } @@ -1792,7 +1793,7 @@ PWebRenderBridgeParent* CompositorBridgeParent::AllocPWebRenderBridgeParent( return mWrBridge; } - if (StaticPrefs::WebRenderSplitRenderRoots()) { + if (gfxPrefs::WebRenderSplitRenderRoots()) { apis.AppendElement( apis[0]->CreateDocument(aSize, 1, wr::RenderRoot::Content)); } diff --git a/gfx/layers/ipc/CompositorManagerChild.cpp b/gfx/layers/ipc/CompositorManagerChild.cpp index 7ed2c51573d7f..33a94a36341b3 100644 --- a/gfx/layers/ipc/CompositorManagerChild.cpp +++ b/gfx/layers/ipc/CompositorManagerChild.cpp @@ -6,7 +6,7 @@ #include "mozilla/layers/CompositorManagerChild.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "mozilla/layers/CompositorBridgeChild.h" #include "mozilla/layers/CompositorManagerParent.h" #include "mozilla/layers/CompositorThread.h" @@ -269,7 +269,7 @@ void CompositorManagerChild::SetReplyTimeout() { #ifndef DEBUG // Add a timeout for release builds to kill GPU process when it hangs. if (XRE_IsParentProcess() && GPUProcessManager::Get()->GetGPUChild()) { - int32_t timeout = StaticPrefs::GPUProcessIPCReplyTimeoutMs(); + int32_t timeout = gfxPrefs::GPUProcessIPCReplyTimeoutMs(); SetReplyTimeoutMs(timeout); } #endif diff --git a/gfx/layers/ipc/CompositorVsyncScheduler.cpp b/gfx/layers/ipc/CompositorVsyncScheduler.cpp index 079b72fb066b2..ea0523a4095db 100644 --- a/gfx/layers/ipc/CompositorVsyncScheduler.cpp +++ b/gfx/layers/ipc/CompositorVsyncScheduler.cpp @@ -14,9 +14,9 @@ #ifdef MOZ_WIDGET_GTK # include "gfxPlatformGtk.h" // for gfxPlatform #endif +#include "gfxPrefs.h" // for gfxPrefs #include "mozilla/AutoRestore.h" // for AutoRestore #include "mozilla/DebugOnly.h" // for DebugOnly -#include "mozilla/StaticPrefs.h" // for StaticPrefs #include "mozilla/gfx/2D.h" // for DrawTarget #include "mozilla/gfx/Point.h" // for IntSize #include "mozilla/gfx/Rect.h" // for IntSize @@ -78,7 +78,7 @@ CompositorVsyncScheduler::CompositorVsyncScheduler( // mAsapScheduling is set on the main thread during init, // but is only accessed after on the compositor thread. - mAsapScheduling = StaticPrefs::LayersCompositionFrameRate() == 0 || + mAsapScheduling = gfxPrefs::LayersCompositionFrameRate() == 0 || gfxPlatform::IsInLayoutAsapMode() || recordreplay::IsRecordingOrReplaying(); } @@ -255,7 +255,7 @@ void CompositorVsyncScheduler::Composite(VsyncId aId, mozilla::Telemetry::COMPOSITE_FRAME_ROUNDTRIP_TIME, compositeFrameTotal.ToMilliseconds()); } else if (mVsyncNotificationsSkipped++ > - StaticPrefs::CompositorUnobserveCount()) { + gfxPrefs::CompositorUnobserveCount()) { UnobserveVsync(); } } diff --git a/gfx/layers/ipc/ISurfaceAllocator.cpp b/gfx/layers/ipc/ISurfaceAllocator.cpp index a96503844cb2a..719c2812915f7 100644 --- a/gfx/layers/ipc/ISurfaceAllocator.cpp +++ b/gfx/layers/ipc/ISurfaceAllocator.cpp @@ -6,6 +6,7 @@ #include "ISurfaceAllocator.h" +#include "gfxPrefs.h" #include "mozilla/layers/ImageBridgeParent.h" // for ImageBridgeParent #include "mozilla/layers/TextureHost.h" // for TextureHost #include "mozilla/layers/TextureForwarder.h" diff --git a/gfx/layers/ipc/LayerTransactionParent.cpp b/gfx/layers/ipc/LayerTransactionParent.cpp index 227a0cb70faa4..d86788843465f 100644 --- a/gfx/layers/ipc/LayerTransactionParent.cpp +++ b/gfx/layers/ipc/LayerTransactionParent.cpp @@ -11,6 +11,7 @@ #include "Layers.h" // for Layer, ContainerLayer, etc #include "CompositableTransactionParent.h" // for EditReplyVector #include "CompositorBridgeParent.h" +#include "gfxPrefs.h" #include "mozilla/gfx/BasePoint3D.h" // for BasePoint3D #include "mozilla/layers/AnimationHelper.h" // for GetAnimatedPropValue #include "mozilla/layers/CanvasLayerComposite.h" @@ -25,7 +26,6 @@ #include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL #include "mozilla/layers/PaintedLayerComposite.h" #include "mozilla/mozalloc.h" // for operator delete, etc -#include "mozilla/StaticPrefs.h" #include "mozilla/Telemetry.h" #include "mozilla/Unused.h" #include "nsCoord.h" // for NSAppUnitsToFloatPixels @@ -472,9 +472,9 @@ mozilla::ipc::IPCResult LayerTransactionParent::RecvUpdate( #endif // Enable visual warning for long transaction when draw FPS option is enabled - bool drawFps = StaticPrefs::LayersDrawFPS(); + bool drawFps = gfxPrefs::LayersDrawFPS(); if (drawFps) { - uint32_t visualWarningTrigger = StaticPrefs::LayerTransactionWarning(); + uint32_t visualWarningTrigger = gfxPrefs::LayerTransactionWarning(); // The default theshold is 200ms to trigger, hit red when it take 4 times // longer TimeDuration latency = TimeStamp::Now() - aInfo.transactionStart(); @@ -751,7 +751,7 @@ mozilla::ipc::IPCResult LayerTransactionParent::RecvGetTransform( // containers are enabled, then the APZ transform might not be on |layer| but // instead would be on the parent of |layer|, if that is the root scrollable // metrics. So we special-case that behaviour. - if (StaticPrefs::LayoutUseContainersForRootFrames() && + if (gfxPrefs::LayoutUseContainersForRootFrames() && !layer->HasScrollableFrameMetrics() && layer->GetParent() && layer->GetParent()->HasRootScrollableFrameMetrics()) { transform *= layer->GetParent()->AsHostLayer()->GetShadowBaseTransform(); diff --git a/gfx/layers/ipc/ShadowLayers.cpp b/gfx/layers/ipc/ShadowLayers.cpp index 636411078ffa2..ea1305e32e3fd 100644 --- a/gfx/layers/ipc/ShadowLayers.cpp +++ b/gfx/layers/ipc/ShadowLayers.cpp @@ -14,7 +14,7 @@ #include "RenderTrace.h" // for RenderTraceScope #include "gfx2DGlue.h" // for Moz2D transition helpers #include "gfxPlatform.h" // for gfxImageFormat, gfxPlatform - +#include "gfxPrefs.h" //#include "gfxSharedImageSurface.h" // for gfxSharedImageSurface #include "ipc/IPCMessageUtils.h" // for gfxContentType, null_t #include "IPDLActor.h" @@ -546,7 +546,7 @@ bool ShadowLayerForwarder::EndTransaction( } Maybe startTime; - if (StaticPrefs::LayersDrawFPS()) { + if (gfxPrefs::LayersDrawFPS()) { startTime = Some(TimeStamp::Now()); } diff --git a/gfx/layers/mlgpu/ContainerLayerMLGPU.cpp b/gfx/layers/mlgpu/ContainerLayerMLGPU.cpp index a7057b6774910..73f4e40987d67 100644 --- a/gfx/layers/mlgpu/ContainerLayerMLGPU.cpp +++ b/gfx/layers/mlgpu/ContainerLayerMLGPU.cpp @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "ContainerLayerMLGPU.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "LayersLogging.h" #include "LayerManagerMLGPU.h" #include "MLGDevice.h" @@ -63,7 +63,7 @@ bool ContainerLayerMLGPU::OnPrepareToRender(FrameBuilder* aBuilder) { mSurfaceCopyNeeded = surfaceCopyNeeded; gfx::IntRect viewport(gfx::IntPoint(0, 0), mTargetSize); - if (!mRenderTarget || !StaticPrefs::AdvancedLayersUseInvalidation() || + if (!mRenderTarget || !gfxPrefs::AdvancedLayersUseInvalidation() || mInvalidateEntireSurface) { // Fine-grained invalidation is disabled, invalidate everything. mInvalidRect = viewport; diff --git a/gfx/layers/mlgpu/LayerManagerMLGPU.cpp b/gfx/layers/mlgpu/LayerManagerMLGPU.cpp index 976d136b3ce8c..fe3fc7e0f4d52 100644 --- a/gfx/layers/mlgpu/LayerManagerMLGPU.cpp +++ b/gfx/layers/mlgpu/LayerManagerMLGPU.cpp @@ -25,7 +25,6 @@ #include "CompositionRecorder.h" #include "mozilla/layers/Diagnostics.h" #include "mozilla/layers/TextRenderer.h" -#include "mozilla/StaticPrefs.h" #ifdef XP_WIN # include "mozilla/widget/WinCompositorWidget.h" @@ -263,8 +262,8 @@ void LayerManagerMLGPU::EndTransaction(const TimeStamp& aTimeStamp, } // Don't draw the diagnostic overlay if we want to snapshot the output. - mDrawDiagnostics = StaticPrefs::LayersDrawFPS() && !mTarget; - mUsingInvalidation = StaticPrefs::AdvancedLayersUseInvalidation(); + mDrawDiagnostics = gfxPrefs::LayersDrawFPS() && !mTarget; + mUsingInvalidation = gfxPrefs::AdvancedLayersUseInvalidation(); mDebugFrameNumber++; AL_LOG("--- Compositing frame %d ---\n", mDebugFrameNumber); @@ -551,7 +550,7 @@ void LayerManagerMLGPU::ClearCachedResources(Layer* aSubtree) { } void LayerManagerMLGPU::NotifyShadowTreeTransaction() { - if (StaticPrefs::LayersDrawFPS()) { + if (gfxPrefs::LayersDrawFPS()) { mDiagnostics->AddTxnFrame(); } } diff --git a/gfx/layers/mlgpu/MLGDevice.cpp b/gfx/layers/mlgpu/MLGDevice.cpp index e2fe6205c07df..90a0887083c5e 100644 --- a/gfx/layers/mlgpu/MLGDevice.cpp +++ b/gfx/layers/mlgpu/MLGDevice.cpp @@ -9,7 +9,7 @@ #include "BufferCache.h" #include "ClearRegionHelper.h" #include "gfxConfig.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "gfxUtils.h" #include "LayersLogging.h" #include "ShaderDefinitionsMLGPU.h" @@ -85,7 +85,7 @@ bool MLGDevice::Initialize() { // We allow this to be pref'd off for testing. Switching it off enables // Direct3D 11.0/Windows 7/OpenGL-style buffer code paths. - if (!StaticPrefs::AdvancedLayersEnableBufferSharing()) { + if (!gfxPrefs::AdvancedLayersEnableBufferSharing()) { gfxConfig::EnableFallback(Fallback::NO_CONSTANT_BUFFER_OFFSETTING, "Disabled by pref"); mCanUseConstantBufferOffsetBinding = false; @@ -99,7 +99,7 @@ bool MLGDevice::Initialize() { // We allow this to be pref'd off for testing. Disabling it turns on // ID3D11DeviceContext1::ClearView support, which is present on // newer Windows 8+ drivers. - if (!StaticPrefs::AdvancedLayersEnableClearView()) { + if (!gfxPrefs::AdvancedLayersEnableClearView()) { mCanUseClearView = false; } @@ -127,7 +127,7 @@ bool MLGDevice::Initialize() { "Failed to allocate a shared shader buffer"); } - if (StaticPrefs::AdvancedLayersEnableBufferCache()) { + if (gfxPrefs::AdvancedLayersEnableBufferCache()) { mConstantBufferCache = MakeUnique(this); } diff --git a/gfx/layers/mlgpu/RenderViewMLGPU.cpp b/gfx/layers/mlgpu/RenderViewMLGPU.cpp index 3f28780a6a6d7..4b666607f2e06 100644 --- a/gfx/layers/mlgpu/RenderViewMLGPU.cpp +++ b/gfx/layers/mlgpu/RenderViewMLGPU.cpp @@ -7,7 +7,7 @@ #include "RenderViewMLGPU.h" #include "ContainerLayerMLGPU.h" #include "FrameBuilder.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "LayersHelpers.h" #include "LayersLogging.h" #include "MLGDevice.h" @@ -74,7 +74,7 @@ RenderViewMLGPU::RenderViewMLGPU(FrameBuilder* aBuilder, mCurrentMaskRectBufferIndex(kInvalidResourceIndex), mCurrentDepthMode(MLGDepthTestMode::Disabled), mNextSortIndex(1), - mUseDepthBuffer(StaticPrefs::AdvancedLayersEnableDepthBuffer()), + mUseDepthBuffer(gfxPrefs::AdvancedLayersEnableDepthBuffer()), mDepthBufferNeedsClear(false) { if (aParent) { aParent->AddChild(this); @@ -188,7 +188,7 @@ bool RenderViewMLGPU::UpdateVisibleRegion(ItemInfo& aItem) { // CPU-based occlusion culling as well, since the GPU will do most of our // culling work for us. if (mUseDepthBuffer || !aItem.translation || - !StaticPrefs::AdvancedLayersEnableCPUOcclusion()) { + !gfxPrefs::AdvancedLayersEnableCPUOcclusion()) { // Update the render region even if we won't compute visibility, since some // layer types (like Canvas and Image) need to have the visible region // clamped. diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index d431936b95d59..3f12effebe565 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -16,11 +16,11 @@ #include "gfxCrashReporterUtils.h" // for ScopedGfxFeatureReporter #include "gfxEnv.h" // for gfxEnv #include "gfxPlatform.h" // for gfxPlatform +#include "gfxPrefs.h" // for gfxPrefs #include "gfxRect.h" // for gfxRect #include "gfxUtils.h" // for gfxUtils, etc #include "mozilla/ArrayUtils.h" // for ArrayLength #include "mozilla/Preferences.h" // for Preferences -#include "mozilla/StaticPrefs.h" // for StaticPrefs #include "mozilla/gfx/BasePoint.h" // for BasePoint #include "mozilla/gfx/Matrix.h" // for Matrix4x4, Matrix #include "mozilla/gfx/Triangle.h" // for Triangle @@ -805,10 +805,10 @@ void CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion, #if defined(MOZ_WIDGET_ANDROID) if ((mSurfaceOrigin.x > 0) || (mSurfaceOrigin.y > 0)) { - mGLContext->fClearColor(StaticPrefs::CompositorOverrideClearColorR(), - StaticPrefs::CompositorOverrideClearColorG(), - StaticPrefs::CompositorOverrideClearColorB(), - StaticPrefs::CompositorOverrideClearColorA()); + mGLContext->fClearColor(gfxPrefs::CompositorOverrideClearColorR(), + gfxPrefs::CompositorOverrideClearColorG(), + gfxPrefs::CompositorOverrideClearColorB(), + gfxPrefs::CompositorOverrideClearColorA()); } else { mGLContext->fClearColor(mClearColor.r, mClearColor.g, mClearColor.b, mClearColor.a); @@ -1233,7 +1233,7 @@ void CompositorOGL::DrawGeometry(const Geometry& aGeometry, // Only apply DEAA to quads that have been transformed such that aliasing // could be visible bool bEnableAA = - StaticPrefs::LayersDEAAEnabled() && !aTransform.Is2DIntegerTranslation(); + gfxPrefs::LayersDEAAEnabled() && !aTransform.Is2DIntegerTranslation(); bool colorMatrix = aEffectChain.mSecondaryEffects[EffectTypes::COLOR_MATRIX]; ShaderConfigOGL config = @@ -1548,7 +1548,7 @@ void CompositorOGL::DrawGeometry(const Geometry& aGeometry, BindAndDrawGeometry(program, aGeometry); } break; case EffectTypes::COMPONENT_ALPHA: { - MOZ_ASSERT(StaticPrefs::ComponentAlphaEnabled()); + MOZ_ASSERT(gfxPrefs::ComponentAlphaEnabled()); MOZ_ASSERT(blendMode == gfx::CompositionOp::OP_OVER, "Can't support blend modes with component alpha!"); EffectComponentAlpha* effectComponentAlpha = @@ -1972,7 +1972,7 @@ GLuint CompositorOGL::GetTemporaryTexture(GLenum aTarget, GLenum aUnit) { } bool CompositorOGL::SupportsTextureDirectMapping() { - if (!StaticPrefs::AllowTextureDirectMapping()) { + if (!gfxPrefs::AllowTextureDirectMapping()) { return false; } @@ -2026,7 +2026,7 @@ void PerUnitTexturePoolOGL::DestroyTextures() { } bool CompositorOGL::SupportsLayerGeometry() const { - return StaticPrefs::OGLLayerGeometry(); + return gfxPrefs::OGLLayerGeometry(); } void CompositorOGL::RegisterTextureSource(TextureSource* aTextureSource) { diff --git a/gfx/layers/wr/WebRenderBridgeChild.cpp b/gfx/layers/wr/WebRenderBridgeChild.cpp index 92a9a73d2ccc1..cbf7f740c48eb 100644 --- a/gfx/layers/wr/WebRenderBridgeChild.cpp +++ b/gfx/layers/wr/WebRenderBridgeChild.cpp @@ -7,7 +7,6 @@ #include "mozilla/layers/WebRenderBridgeChild.h" #include "gfxPlatform.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/dom/TabGroup.h" #include "mozilla/layers/CompositableClient.h" #include "mozilla/layers/CompositorBridgeChild.h" @@ -73,9 +72,8 @@ void WebRenderBridgeChild::DoDestroy() { void WebRenderBridgeChild::AddWebRenderParentCommand( const WebRenderParentCommand& aCmd, wr::RenderRoot aRenderRoot) { - MOZ_ASSERT( - aRenderRoot == wr::RenderRoot::Default || - (XRE_IsParentProcess() && StaticPrefs::WebRenderSplitRenderRoots())); + MOZ_ASSERT(aRenderRoot == wr::RenderRoot::Default || + (XRE_IsParentProcess() && gfxPrefs::WebRenderSplitRenderRoots())); mParentCommands[aRenderRoot].AppendElement(aCmd); } @@ -120,7 +118,7 @@ void WebRenderBridgeChild::EndTransaction( for (auto& renderRoot : aRenderRoots) { MOZ_ASSERT( renderRoot.mRenderRoot == wr::RenderRoot::Default || - (XRE_IsParentProcess() && StaticPrefs::WebRenderSplitRenderRoots())); + (XRE_IsParentProcess() && gfxPrefs::WebRenderSplitRenderRoots())); renderRoot.mCommands = std::move(mParentCommands[renderRoot.mRenderRoot]); } @@ -152,7 +150,7 @@ void WebRenderBridgeChild::EndEmptyTransaction( for (auto& update : aRenderRootUpdates) { MOZ_ASSERT( update.mRenderRoot == wr::RenderRoot::Default || - (XRE_IsParentProcess() && StaticPrefs::WebRenderSplitRenderRoots())); + (XRE_IsParentProcess() && gfxPrefs::WebRenderSplitRenderRoots())); update.mCommands = std::move(mParentCommands[update.mRenderRoot]); } @@ -176,7 +174,7 @@ void WebRenderBridgeChild::ProcessWebRenderParentCommands() { for (auto renderRoot : wr::kRenderRoots) { if (!mParentCommands[renderRoot].IsEmpty()) { MOZ_ASSERT(renderRoot == wr::RenderRoot::Default || - StaticPrefs::WebRenderSplitRenderRoots()); + gfxPrefs::WebRenderSplitRenderRoots()); this->SendParentCommands(mParentCommands[renderRoot], renderRoot); mParentCommands[renderRoot].Clear(); } diff --git a/gfx/layers/wr/WebRenderBridgeParent.cpp b/gfx/layers/wr/WebRenderBridgeParent.cpp index 8375a5a032747..44db7826fa611 100644 --- a/gfx/layers/wr/WebRenderBridgeParent.cpp +++ b/gfx/layers/wr/WebRenderBridgeParent.cpp @@ -8,13 +8,13 @@ #include "CompositableHost.h" #include "gfxEnv.h" +#include "gfxPrefs.h" #include "gfxEnv.h" #include "GeckoProfiler.h" #include "GLContext.h" #include "GLContextProvider.h" #include "nsExceptionHandler.h" #include "mozilla/Range.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/UniquePtr.h" #include "mozilla/layers/AnimationHelper.h" #include "mozilla/layers/APZSampler.h" @@ -326,8 +326,7 @@ WebRenderBridgeParent::WebRenderBridgeParent( mCompositorScheduler = new CompositorVsyncScheduler(this, mWidget); } - if (!IsRootWebRenderBridgeParent() && - StaticPrefs::WebRenderSplitRenderRoots()) { + if (!IsRootWebRenderBridgeParent() && gfxPrefs::WebRenderSplitRenderRoots()) { mRenderRoot = wr::RenderRoot::Content; } @@ -922,7 +921,7 @@ bool WebRenderBridgeParent::SetDisplayList( } LayoutDeviceIntSize widgetSize = mWidget->GetClientSize(); LayoutDeviceIntRect rect; - if (StaticPrefs::WebRenderSplitRenderRoots()) { + if (gfxPrefs::WebRenderSplitRenderRoots()) { rect = RoundedToInt(aRect); rect.SetWidth( std::max(0, std::min(widgetSize.width - rect.X(), rect.Width()))); @@ -1609,7 +1608,7 @@ mozilla::ipc::IPCResult WebRenderBridgeParent::RecvClearCachedResources() { for (auto renderRoot : wr::kRenderRoots) { if (renderRoot == wr::RenderRoot::Default || (IsRootWebRenderBridgeParent() && - StaticPrefs::WebRenderSplitRenderRoots())) { + gfxPrefs::WebRenderSplitRenderRoots())) { // Clear resources wr::TransactionBuilder txn; txn.SetLowPriority(true); @@ -1697,7 +1696,7 @@ void WebRenderBridgeParent::ScheduleForcedGenerateFrame() { for (auto renderRoot : wr::kRenderRoots) { if (renderRoot == wr::RenderRoot::Default || (IsRootWebRenderBridgeParent() && - StaticPrefs::WebRenderSplitRenderRoots())) { + gfxPrefs::WebRenderSplitRenderRoots())) { wr::TransactionBuilder fastTxn(/* aUseSceneBuilderThread */ false); fastTxn.InvalidateRenderedFrame(); Api(renderRoot)->SendTransaction(fastTxn); @@ -1734,7 +1733,7 @@ mozilla::ipc::IPCResult WebRenderBridgeParent::RecvSetConfirmedTargetAPZC( for (size_t i = 0; i < aTargets.Length(); i++) { // Guard against bad data from hijacked child processes if (aTargets[i].mRenderRoot > wr::kHighestRenderRoot || - (!StaticPrefs::WebRenderSplitRenderRoots() && + (!gfxPrefs::WebRenderSplitRenderRoots() && aTargets[i].mRenderRoot != wr::RenderRoot::Default)) { NS_ERROR( "Unexpected render root in RecvSetConfirmedTargetAPZC; dropping " @@ -2100,7 +2099,7 @@ void WebRenderBridgeParent::NotifyDidSceneBuild( if (lastVsyncId == VsyncId() || !mMostRecentComposite || mMostRecentComposite >= lastVsync || ((TimeStamp::Now() - lastVsync).ToMilliseconds() > - StaticPrefs::WebRenderLateSceneBuildThreshold())) { + gfxPrefs::WebRenderLateSceneBuildThreshold())) { mCompositorScheduler->ScheduleComposition(); return; } diff --git a/gfx/layers/wr/WebRenderCommandBuilder.cpp b/gfx/layers/wr/WebRenderCommandBuilder.cpp index b015923703dc5..5519a4c1c91f5 100644 --- a/gfx/layers/wr/WebRenderCommandBuilder.cpp +++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp @@ -1618,8 +1618,8 @@ void WebRenderCommandBuilder::BuildWebRenderCommands( bool WebRenderCommandBuilder::ShouldDumpDisplayList( nsDisplayListBuilder* aBuilder) { return aBuilder != nullptr && aBuilder->IsInActiveDocShell() && - ((XRE_IsParentProcess() && StaticPrefs::WebRenderDLDumpParent()) || - (XRE_IsContentProcess() && StaticPrefs::WebRenderDLDumpContent())); + ((XRE_IsParentProcess() && gfxPrefs::WebRenderDLDumpParent()) || + (XRE_IsContentProcess() && gfxPrefs::WebRenderDLDumpContent())); } void WebRenderCommandBuilder::CreateWebRenderCommandsFromDisplayList( @@ -2090,9 +2090,9 @@ WebRenderCommandBuilder::GenerateFallbackData( wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, nsDisplayListBuilder* aDisplayListBuilder, LayoutDeviceRect& aImageRect) { bool useBlobImage = - StaticPrefs::WebRenderBlobImages() && !aItem->MustPaintOnContentSide(); + gfxPrefs::WebRenderBlobImages() && !aItem->MustPaintOnContentSide(); Maybe highlight = Nothing(); - if (StaticPrefs::WebRenderHighlightPaintedLayers()) { + if (gfxPrefs::WebRenderHighlightPaintedLayers()) { highlight = Some(useBlobImage ? gfx::Color(1.0, 0.0, 0.0, 0.5) : gfx::Color(1.0, 1.0, 0.0, 0.5)); } diff --git a/gfx/layers/wr/WebRenderLayerManager.cpp b/gfx/layers/wr/WebRenderLayerManager.cpp index 2b2cc937c1eb9..b73a70d474b4a 100644 --- a/gfx/layers/wr/WebRenderLayerManager.cpp +++ b/gfx/layers/wr/WebRenderLayerManager.cpp @@ -7,7 +7,7 @@ #include "WebRenderLayerManager.h" #include "BasicLayers.h" - +#include "gfxPrefs.h" #include "GeckoProfiler.h" #include "LayersLogging.h" #include "mozilla/dom/BrowserChild.h" @@ -171,7 +171,7 @@ bool WebRenderLayerManager::BeginTransaction(const nsCString& aURL) { // enabled in this process; it may be enabled in the parent process, // and the parent process expects unique sequence numbers. ++mPaintSequenceNumber; - if (StaticPrefs::APZTestLoggingEnabled()) { + if (gfxPrefs::APZTestLoggingEnabled()) { mApzTestData.StartNewPaint(mPaintSequenceNumber); } return true; @@ -692,7 +692,7 @@ void WebRenderLayerManager::FlushRendering() { if (WrBridge()->GetCompositorUseDComp() && !resizing) { cBridge->SendFlushRenderingAsync(); } else if (mWidget->SynchronouslyRepaintOnResize() || - StaticPrefs::LayersForceSynchronousResize()) { + gfxPrefs::LayersForceSynchronousResize()) { cBridge->SendFlushRendering(); } else { cBridge->SendFlushRenderingAsync(); @@ -726,7 +726,7 @@ WebRenderLayerManager::CreatePersistentBufferProvider( // initialized with WebRender to reduce memory usage. gfxPlatform::GetPlatform()->EnsureDevicesInitialized(); - if (StaticPrefs::PersistentBufferProviderSharedEnabled()) { + if (gfxPrefs::PersistentBufferProviderSharedEnabled()) { RefPtr provider = PersistentBufferProviderShared::Create(aSize, aFormat, AsKnowsCompositor()); diff --git a/gfx/layers/wr/WebRenderLayerManager.h b/gfx/layers/wr/WebRenderLayerManager.h index 3496f2acb07a0..3f42acc58cdee 100644 --- a/gfx/layers/wr/WebRenderLayerManager.h +++ b/gfx/layers/wr/WebRenderLayerManager.h @@ -11,10 +11,10 @@ #include #include +#include "gfxPrefs.h" #include "Layers.h" #include "mozilla/Maybe.h" #include "mozilla/MozPromise.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/layers/APZTestData.h" #include "mozilla/layers/FocusTarget.h" #include "mozilla/layers/IpcResourceUpdateQueue.h" @@ -154,13 +154,13 @@ class WebRenderLayerManager final : public LayerManager { void LogTestDataForCurrentPaint(ScrollableLayerGuid::ViewID aScrollId, const std::string& aKey, const std::string& aValue) { - MOZ_ASSERT(StaticPrefs::APZTestLoggingEnabled(), "don't call me"); + MOZ_ASSERT(gfxPrefs::APZTestLoggingEnabled(), "don't call me"); mApzTestData.LogTestDataForPaint(mPaintSequenceNumber, aScrollId, aKey, aValue); } void LogAdditionalTestData(const std::string& aKey, const std::string& aValue) { - MOZ_ASSERT(StaticPrefs::APZTestLoggingEnabled(), "don't call me"); + MOZ_ASSERT(gfxPrefs::APZTestLoggingEnabled(), "don't call me"); mApzTestData.RecordAdditionalData(aKey, aValue); } diff --git a/gfx/src/DriverCrashGuard.cpp b/gfx/src/DriverCrashGuard.cpp index 6f2dbb923eb84..b8bd86f21c494 100644 --- a/gfx/src/DriverCrashGuard.cpp +++ b/gfx/src/DriverCrashGuard.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "DriverCrashGuard.h" #include "gfxEnv.h" +#include "gfxPrefs.h" #include "gfxConfig.h" #include "nsAppDirectoryServiceDefs.h" #include "nsDirectoryServiceUtils.h" @@ -13,7 +14,6 @@ #include "nsString.h" #include "nsXULAppAPI.h" #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Telemetry.h" #include "mozilla/Services.h" #include "mozilla/gfx/Logging.h" @@ -406,8 +406,8 @@ bool D3D11LayersCrashGuard::UpdateEnvironment() { bool changed = false; // Feature status. #if defined(XP_WIN) - bool d2dEnabled = StaticPrefs::Direct2DForceEnabled() || - (!StaticPrefs::Direct2DDisabled() && + bool d2dEnabled = gfxPrefs::Direct2DForceEnabled() || + (!gfxPrefs::Direct2DDisabled() && FeatureEnabled(nsIGfxInfo::FEATURE_DIRECT2D)); changed |= CheckAndUpdateBoolPref("feature-d2d", d2dEnabled); @@ -509,11 +509,11 @@ bool GLContextCrashGuard::UpdateEnvironment() { #if defined(XP_WIN) changed |= CheckAndUpdateBoolPref("gfx.driver-init.webgl-angle-force-d3d11", - StaticPrefs::WebGLANGLEForceD3D11()); + gfxPrefs::WebGLANGLEForceD3D11()); changed |= CheckAndUpdateBoolPref("gfx.driver-init.webgl-angle-try-d3d11", - StaticPrefs::WebGLANGLETryD3D11()); + gfxPrefs::WebGLANGLETryD3D11()); changed |= CheckAndUpdateBoolPref("gfx.driver-init.webgl-angle-force-warp", - StaticPrefs::WebGLANGLEForceWARP()); + gfxPrefs::WebGLANGLEForceWARP()); changed |= CheckAndUpdateBoolPref( "gfx.driver-init.webgl-angle", FeatureEnabled(nsIGfxInfo::FEATURE_WEBGL_ANGLE, false)); diff --git a/gfx/tests/gtest/TestCompositor.cpp b/gfx/tests/gtest/TestCompositor.cpp index e4ce3b6d50c11..167630ec555a6 100644 --- a/gfx/tests/gtest/TestCompositor.cpp +++ b/gfx/tests/gtest/TestCompositor.cpp @@ -3,6 +3,7 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ +#include "gfxPrefs.h" #include "gfxUtils.h" #include "gtest/gtest.h" #include "TestLayers.h" diff --git a/gfx/tests/gtest/TestGfxPrefs.cpp b/gfx/tests/gtest/TestGfxPrefs.cpp new file mode 100644 index 0000000000000..124e23df7dd53 --- /dev/null +++ b/gfx/tests/gtest/TestGfxPrefs.cpp @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "gtest/gtest.h" + +#include "gfxPrefs.h" +#ifdef GFX_DECL_PREF +# error "This is not supposed to be defined outside of gfxPrefs.h" +#endif + +// If the default values for any of these preferences change, +// just modify the test to match. We are only testing against +// a particular value to make sure we receive the correct +// result through this API. + +TEST(GfxPrefs, Singleton) +{ + gfxPrefs::GetSingleton(); + ASSERT_TRUE(gfxPrefs::SingletonExists()); +} + +TEST(GfxPrefs, LiveValues) +{ + gfxPrefs::GetSingleton(); + ASSERT_TRUE(gfxPrefs::SingletonExists()); + + // Live boolean, default false + ASSERT_FALSE(gfxPrefs::LayersDumpTexture()); + + // Live int32_t, default 23456 + ASSERT_TRUE(gfxPrefs::LayerScopePort() == 23456); + + // Live uint32_t, default 2 + ASSERT_TRUE(gfxPrefs::MSAALevel() == 2); +} + +TEST(GfxPrefs, OnceValues) +{ + gfxPrefs::GetSingleton(); + ASSERT_TRUE(gfxPrefs::SingletonExists()); + + // Once boolean, default true + ASSERT_TRUE(gfxPrefs::WorkAroundDriverBugs()); + + // Once boolean, default false + ASSERT_FALSE(gfxPrefs::LayersDump()); + + // Once uint32_t, default 5 + ASSERT_TRUE(gfxPrefs::APZMaxVelocityQueueSize() == 5); + + // Once float, default -1 (should be OK with ==) + ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == -1.0f); +} + +TEST(GfxPrefs, Set) +{ + gfxPrefs::GetSingleton(); + ASSERT_TRUE(gfxPrefs::SingletonExists()); + + // Once boolean, default false + ASSERT_FALSE(gfxPrefs::LayersDump()); + gfxPrefs::SetLayersDump(true); + ASSERT_TRUE(gfxPrefs::LayersDump()); + gfxPrefs::SetLayersDump(false); + ASSERT_FALSE(gfxPrefs::LayersDump()); + + // Live boolean, default false + ASSERT_FALSE(gfxPrefs::LayersDumpTexture()); + gfxPrefs::SetLayersDumpTexture(true); + ASSERT_TRUE(gfxPrefs::LayersDumpTexture()); + gfxPrefs::SetLayersDumpTexture(false); + ASSERT_FALSE(gfxPrefs::LayersDumpTexture()); + + // Once float, default -1 + ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == -1.0f); + gfxPrefs::SetAPZMaxVelocity(1.75f); + ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == 1.75f); + gfxPrefs::SetAPZMaxVelocity(-1.0f); + ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == -1.0f); +} + +// Randomly test the function we use in nsExceptionHandler.cpp here: +extern bool SimpleNoCLibDtoA(double aValue, char* aBuffer, int aBufferLength); +TEST(GfxPrefs, StringUtility) +{ + char testBuffer[64]; + double testVal[] = { + 13.4, + 3324243.42, + 0.332424342, + 864.0, + 86400 * 100000000.0 * 10000000000.0 * 10000000000.0 * 100.0, + 86400.0 * 366.0 * 100.0 + 14243.44332}; + for (size_t i = 0; i < mozilla::ArrayLength(testVal); i++) { + ASSERT_TRUE(SimpleNoCLibDtoA(testVal[i], testBuffer, sizeof(testBuffer))); + ASSERT_TRUE(fabs(1.0 - atof(testBuffer) / testVal[i]) < 0.0001); + } + + // We do not like negative numbers (random limitation) + ASSERT_FALSE(SimpleNoCLibDtoA(-864.0, testBuffer, sizeof(testBuffer))); + + // It won't fit into 32: + ASSERT_FALSE( + SimpleNoCLibDtoA(testVal[4], testBuffer, sizeof(testBuffer) / 2)); +} diff --git a/gfx/tests/gtest/TestRect.cpp b/gfx/tests/gtest/TestRect.cpp index 2b6bdecb70e2e..f3884577e1567 100644 --- a/gfx/tests/gtest/TestRect.cpp +++ b/gfx/tests/gtest/TestRect.cpp @@ -517,18 +517,18 @@ static void TestIntersectionLogicalHelper(nscoord x1, nscoord y1, nscoord w1, mozilla::LogicalRect r2(mozilla::WritingMode(), rect2.X(), rect2.Y(), rect2.Width(), rect2.Height()); EXPECT_TRUE(isNonEmpty == r1.IntersectRect(r1, r2)); - EXPECT_TRUE(rectDebug.IsEqualEdges(nsRect( - r1.IStart(mozilla::WritingMode()), r1.BStart(mozilla::WritingMode()), - r1.ISize(mozilla::WritingMode()), r1.BSize(mozilla::WritingMode())))); + EXPECT_TRUE(rectDebug.IsEqualEdges( + nsRect(r1.IStart(WritingMode()), r1.BStart(WritingMode()), + r1.ISize(WritingMode()), r1.BSize(WritingMode())))); mozilla::LogicalRect r3(mozilla::WritingMode(), rect1.X(), rect1.Y(), rect1.Width(), rect1.Height()); mozilla::LogicalRect r4(mozilla::WritingMode(), rect2.X(), rect2.Y(), rect2.Width(), rect2.Height()); EXPECT_TRUE(isNonEmpty == r4.IntersectRect(r3, r4)); - EXPECT_TRUE(rectDebug.IsEqualEdges(nsRect( - r4.IStart(mozilla::WritingMode()), r4.BStart(mozilla::WritingMode()), - r4.ISize(mozilla::WritingMode()), r4.BSize(mozilla::WritingMode())))); + EXPECT_TRUE(rectDebug.IsEqualEdges( + nsRect(r4.IStart(WritingMode()), r4.BStart(WritingMode()), + r4.ISize(WritingMode()), r4.BSize(WritingMode())))); mozilla::LogicalRect r5(mozilla::WritingMode(), rect1.X(), rect1.Y(), rect1.Width(), rect1.Height()); @@ -536,9 +536,9 @@ static void TestIntersectionLogicalHelper(nscoord x1, nscoord y1, nscoord w1, rect2.Width(), rect2.Height()); mozilla::LogicalRect r7(mozilla::WritingMode(), 0, 0, 1, 1); EXPECT_TRUE(isNonEmpty == r7.IntersectRect(r5, r6)); - EXPECT_TRUE(rectDebug.IsEqualEdges(nsRect( - r7.IStart(mozilla::WritingMode()), r7.BStart(mozilla::WritingMode()), - r7.ISize(mozilla::WritingMode()), r7.BSize(mozilla::WritingMode())))); + EXPECT_TRUE(rectDebug.IsEqualEdges( + nsRect(r7.IStart(WritingMode()), r7.BStart(WritingMode()), + r7.ISize(WritingMode()), r7.BSize(WritingMode())))); } static void TestIntersectionLogical(nscoord x1, nscoord y1, nscoord w1, diff --git a/gfx/tests/gtest/TestTextureCompatibility.cpp b/gfx/tests/gtest/TestTextureCompatibility.cpp index 2e5236614dd3f..ba152dfe8488f 100644 --- a/gfx/tests/gtest/TestTextureCompatibility.cpp +++ b/gfx/tests/gtest/TestTextureCompatibility.cpp @@ -22,7 +22,6 @@ using mozilla::gfx::gfxConfig; using mozilla::layers::BasicCompositor; using mozilla::layers::Compositor; using mozilla::layers::CompositorOptions; -using mozilla::layers::ISurfaceAllocator; using mozilla::layers::LayersBackend; using mozilla::layers::TestSurfaceAllocator; using mozilla::layers::TextureClient; diff --git a/gfx/tests/gtest/TestVsync.cpp b/gfx/tests/gtest/TestVsync.cpp index 776d7f21e8b19..fd19cc55a6c1d 100644 --- a/gfx/tests/gtest/TestVsync.cpp +++ b/gfx/tests/gtest/TestVsync.cpp @@ -6,7 +6,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include "gfxPlatform.h" - +#include "gfxPrefs.h" #include "MainThreadUtils.h" #include "nsIThread.h" #include "mozilla/RefPtr.h" @@ -70,6 +70,7 @@ class VsyncTester : public ::testing::Test { protected: explicit VsyncTester() { gfxPlatform::GetPlatform(); + gfxPrefs::GetSingleton(); mVsyncSource = gfxPlatform::GetPlatform()->GetHardwareVsync(); MOZ_RELEASE_ASSERT(mVsyncSource, "GFX: Vsync source not found."); } diff --git a/gfx/tests/gtest/moz.build b/gfx/tests/gtest/moz.build index 9a2120a96dbd6..17a02fcd26c1e 100644 --- a/gfx/tests/gtest/moz.build +++ b/gfx/tests/gtest/moz.build @@ -35,6 +35,7 @@ if not(CONFIG['OS_TARGET'] == 'WINNT' and CONFIG['CPU_ARCH'] == 'aarch64'): if CONFIG['OS_TARGET'] != 'Android': UNIFIED_SOURCES += [ 'TestCompositor.cpp', + 'TestGfxPrefs.cpp', 'TestRect.cpp', 'TestTextureCompatibility.cpp', ] diff --git a/gfx/tests/marionette/test_pref_rollout_workaround.py b/gfx/tests/marionette/test_pref_rollout_workaround.py index 65baeb1bf3547..7207d41df1585 100644 --- a/gfx/tests/marionette/test_pref_rollout_workaround.py +++ b/gfx/tests/marionette/test_pref_rollout_workaround.py @@ -24,7 +24,7 @@ class WrPrefRolloutWorkAroundTestCase(MarionetteTestCase): ''' def test_wr_rollout_workaround_on_non_qualifying_hw(self): - # Override the StaticPrefs so that WR is not enabled, as it would be before a rollout. + # Override the gfxPref so that WR is not enabled, as it would be before a rollout. self.marionette.set_pref(pref=gfx_rollout_override, value=False) # Set HW override so we behave as if we on non-qualifying hardware. self.marionette.set_pref(pref=hw_qualified_override, value=False) diff --git a/gfx/thebes/D3D11Checks.cpp b/gfx/thebes/D3D11Checks.cpp index 9ce97f6391ea4..95ad78bc41e34 100644 --- a/gfx/thebes/D3D11Checks.cpp +++ b/gfx/thebes/D3D11Checks.cpp @@ -7,9 +7,9 @@ #include "DXVA2Manager.h" #include "gfxConfig.h" #include "GfxDriverInfo.h" +#include "gfxPrefs.h" #include "gfxWindowsPlatform.h" #include "mozilla/RefPtr.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/gfx/gfxVars.h" #include "mozilla/gfx/Logging.h" #include "mozilla/layers/TextureD3D11.h" @@ -139,7 +139,7 @@ bool D3D11Checks::DoesDeviceWork() { if (checked) return result; checked = true; - if (StaticPrefs::Direct2DForceEnabled() || + if (gfxPrefs::Direct2DForceEnabled() || gfxConfig::IsForcedOnByUser(Feature::HW_COMPOSITING)) { result = true; return true; @@ -200,7 +200,7 @@ static bool DoesTextureSharingWorkInternal(ID3D11Device* device, return false; } - if (StaticPrefs::Direct2DForceEnabled() || + if (gfxPrefs::Direct2DForceEnabled() || gfxConfig::IsForcedOnByUser(Feature::HW_COMPOSITING)) { return true; } @@ -212,7 +212,7 @@ static bool DoesTextureSharingWorkInternal(ID3D11Device* device, gfxInfo->GetAdapterVendorID(vendorID); gfxInfo->GetAdapterVendorID2(vendorID2); if (vendorID.EqualsLiteral("0x8086") && vendorID2.IsEmpty()) { - if (!StaticPrefs::LayersAMDSwitchableGfxEnabled()) { + if (!gfxPrefs::LayersAMDSwitchableGfxEnabled()) { return false; } gfxCriticalError(CriticalLog::DefaultOptions(false)) @@ -448,8 +448,7 @@ bool D3D11Checks::DoesRemotePresentWork(IDXGIAdapter* adapter) { }; auto doesP010Work = [&]() { - if (gfxVars::DXP010Blocked() && - !StaticPrefs::PDMWMFForceAllowP010Format()) { + if (gfxVars::DXP010Blocked() && !gfxPrefs::PDMWMFForceAllowP010Format()) { return false; } UINT formatSupport; @@ -458,8 +457,7 @@ bool D3D11Checks::DoesRemotePresentWork(IDXGIAdapter* adapter) { }; auto doesP016Work = [&]() { - if (gfxVars::DXP016Blocked() && - !StaticPrefs::PDMWMFForceAllowP010Format()) { + if (gfxVars::DXP016Blocked() && !gfxPrefs::PDMWMFForceAllowP010Format()) { return false; } UINT formatSupport; diff --git a/gfx/thebes/DeviceManagerDx.cpp b/gfx/thebes/DeviceManagerDx.cpp index 6f7b284a7dc93..fa84297549394 100644 --- a/gfx/thebes/DeviceManagerDx.cpp +++ b/gfx/thebes/DeviceManagerDx.cpp @@ -7,9 +7,9 @@ #include "D3D11Checks.h" #include "gfxConfig.h" #include "GfxDriverInfo.h" +#include "gfxPrefs.h" #include "gfxWindowsPlatform.h" #include "mozilla/D3DMessageUtils.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Telemetry.h" #include "mozilla/WindowsVersion.h" #include "mozilla/gfx/GPUParent.h" @@ -183,7 +183,7 @@ bool DeviceManagerDx::CreateCompositorDevices() { FeatureState& d3d11 = gfxConfig::GetFeature(Feature::D3D11_COMPOSITING); MOZ_ASSERT(d3d11.IsEnabled()); - if (int32_t sleepSec = StaticPrefs::Direct3D11SleepOnCreateDevice()) { + if (int32_t sleepSec = gfxPrefs::Direct3D11SleepOnCreateDevice()) { printf_stderr("Attach to PID: %d\n", GetCurrentProcessId()); Sleep(sleepSec * 1000); } @@ -404,7 +404,7 @@ bool DeviceManagerDx::CreateCompositorDeviceHelper( FeatureState& aD3d11, IDXGIAdapter1* aAdapter, bool aAttemptVideoSupport, RefPtr& aOutDevice) { // Check if a failure was injected for testing. - if (StaticPrefs::DeviceFailForTesting()) { + if (gfxPrefs::DeviceFailForTesting()) { aD3d11.SetFailed(FeatureStatus::Failed, "Direct3D11 device failure simulated by preference", NS_LITERAL_CSTRING("FEATURE_FAILURE_D3D11_SIM")); @@ -463,7 +463,7 @@ static inline int32_t GetNextDeviceCounter() { } void DeviceManagerDx::CreateCompositorDevice(FeatureState& d3d11) { - if (StaticPrefs::LayersD3D11ForceWARP()) { + if (gfxPrefs::LayersD3D11ForceWARP()) { CreateWARPCompositorDevice(); return; } @@ -533,8 +533,8 @@ bool DeviceManagerDx::CreateDevice(IDXGIAdapter* aAdapter, D3D_DRIVER_TYPE aDriverType, UINT aFlags, HRESULT& aResOut, RefPtr& aOutDevice) { - if (StaticPrefs::Direct3D11EnableDebugLayer() || - StaticPrefs::Direct3D11BreakOnError()) { + if (gfxPrefs::Direct3D11EnableDebugLayer() || + gfxPrefs::Direct3D11BreakOnError()) { aFlags |= D3D11_CREATE_DEVICE_DEBUG; } @@ -546,7 +546,7 @@ bool DeviceManagerDx::CreateDevice(IDXGIAdapter* aAdapter, } MOZ_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { return false; } - if (StaticPrefs::Direct3D11BreakOnError()) { + if (gfxPrefs::Direct3D11BreakOnError()) { do { if (!aOutDevice) break; @@ -582,7 +582,7 @@ bool DeviceManagerDx::CreateDevice(IDXGIAdapter* aAdapter, void DeviceManagerDx::CreateWARPCompositorDevice() { ScopedGfxFeatureReporter reporterWARP("D3D11-WARP", - StaticPrefs::LayersD3D11ForceWARP()); + gfxPrefs::LayersD3D11ForceWARP()); FeatureState& d3d11 = gfxConfig::GetFeature(Feature::D3D11_COMPOSITING); HRESULT hr; @@ -707,13 +707,13 @@ RefPtr DeviceManagerDx::CreateDecoderDevice() { } bool reuseDevice = false; - if (StaticPrefs::Direct3D11ReuseDecoderDevice() < 0) { + if (gfxPrefs::Direct3D11ReuseDecoderDevice() < 0) { // Use the default logic, which is to allow reuse of devices on AMD, but // create separate devices everywhere else. if (isAMD) { reuseDevice = true; } - } else if (StaticPrefs::Direct3D11ReuseDecoderDevice() > 0) { + } else if (gfxPrefs::Direct3D11ReuseDecoderDevice() > 0) { reuseDevice = true; } @@ -991,8 +991,8 @@ bool DeviceManagerDx::GetAnyDeviceRemovedReason(DeviceResetReason* aOutReason) { } if (XRE_IsParentProcess() && NS_IsMainThread() && - StaticPrefs::DeviceResetForTesting()) { - StaticPrefs::SetDeviceResetForTesting(0); + gfxPrefs::DeviceResetForTesting()) { + gfxPrefs::SetDeviceResetForTesting(0); *aOutReason = DeviceResetReason::FORCED_RESET; return true; } @@ -1091,7 +1091,7 @@ bool DeviceManagerDx::TextureSharingWorks() { bool DeviceManagerDx::CanInitializeKeyedMutexTextures() { MutexAutoLock lock(mDeviceLock); - return mDeviceStatus && StaticPrefs::Direct3D11AllowKeyedMutex() && + return mDeviceStatus && gfxPrefs::Direct3D11AllowKeyedMutex() && gfxVars::AllowD3D11KeyedMutex(); } diff --git a/gfx/thebes/gfxAndroidPlatform.cpp b/gfx/thebes/gfxAndroidPlatform.cpp index 2edd4beb8806e..cd74131d95f11 100644 --- a/gfx/thebes/gfxAndroidPlatform.cpp +++ b/gfx/thebes/gfxAndroidPlatform.cpp @@ -12,7 +12,6 @@ #include "mozilla/intl/LocaleService.h" #include "mozilla/intl/OSPreferences.h" #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include "gfx2DGlue.h" #include "gfxFT2FontList.h" @@ -23,6 +22,7 @@ #include "nsIScreenManager.h" #include "nsServiceManagerUtils.h" #include "nsUnicodeProperties.h" +#include "gfxPrefs.h" #include "cairo.h" #include "VsyncSource.h" @@ -93,7 +93,7 @@ gfxAndroidPlatform::gfxAndroidPlatform() { mOffscreenFormat = GetScreenDepth() == 16 ? SurfaceFormat::R5G6B5_UINT16 : SurfaceFormat::X8R8G8B8_UINT32; - if (StaticPrefs::AndroidRGB16Force()) { + if (gfxPrefs::AndroidRGB16Force()) { mOffscreenFormat = SurfaceFormat::R5G6B5_UINT16; } } diff --git a/gfx/thebes/gfxContext.cpp b/gfx/thebes/gfxContext.cpp index 083a8764df549..84ee2df3d2ddb 100644 --- a/gfx/thebes/gfxContext.cpp +++ b/gfx/thebes/gfxContext.cpp @@ -17,7 +17,7 @@ #include "gfxASurface.h" #include "gfxPattern.h" #include "gfxPlatform.h" - +#include "gfxPrefs.h" #include "GeckoProfiler.h" #include "gfx2DGlue.h" #include "mozilla/gfx/PathHelpers.h" diff --git a/gfx/thebes/gfxMacFont.cpp b/gfx/thebes/gfxMacFont.cpp index caadc8c2f2785..60b869af14c34 100644 --- a/gfx/thebes/gfxMacFont.cpp +++ b/gfx/thebes/gfxMacFont.cpp @@ -16,8 +16,10 @@ #include "gfxFontUtils.h" #include "gfxMacPlatformFontList.h" #include "gfxFontConstants.h" +#include "gfxPrefs.h" #include "gfxTextRun.h" #include "nsCocoaFeatures.h" + #include "cairo-quartz.h" using namespace mozilla; @@ -199,7 +201,7 @@ bool gfxMacFont::ShapeText(DrawTarget* aDrawTarget, const char16_t* aText, // so we ignore RequiresAATLayout if vertical is requested. auto macFontEntry = static_cast(GetFontEntry()); if (macFontEntry->RequiresAATLayout() && !aVertical && - StaticPrefs::CoreTextEnabled()) { + gfxPrefs::CoreTextEnabled()) { if (!mCoreTextShaper) { mCoreTextShaper = MakeUnique(this); } diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index 57a714f1b513e..9b12248306dc7 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -755,7 +755,7 @@ explicit gfxMacFontFamily(const nsACString& aName, double aSizeHint) // It's unsafe to call HasOtherFamilyNames off the main thread because // it entrains FindStyleVariations, which calls GetWeightOverride, which // retrieves prefs. And the pref names can change (via user overrides), - // so we can't use StaticPrefs to access them. + // so we can't use gfxPrefs to access them. if (NS_IsMainThread() && !HasOtherFamilyNames()) { aLocalizedName = mName; return; diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index cff2c5dcb53ef..4c41eb66ab05c 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -20,7 +20,6 @@ #include "mozilla/gfx/GPUProcessManager.h" #include "mozilla/gfx/GraphicsMessages.h" #include "mozilla/ClearOnShutdown.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Telemetry.h" #include "mozilla/TimeStamp.h" #include "mozilla/Unused.h" @@ -32,7 +31,7 @@ #include "gfxCrashReporterUtils.h" #include "gfxPlatform.h" - +#include "gfxPrefs.h" #include "gfxEnv.h" #include "gfxTextRun.h" #include "gfxUserFontSet.h" @@ -600,7 +599,7 @@ static uint32_t GetSkiaGlyphCacheSize() { // We don't need to change the font cache count since we usually // cache thrash due to asian character sets in talos. // Only increase memory on the content process - uint32_t cacheSize = StaticPrefs::SkiaContentFontCacheSize() * 1024 * 1024; + uint32_t cacheSize = gfxPrefs::SkiaContentFontCacheSize() * 1024 * 1024; if (mozilla::BrowserTabsRemoteAutostart()) { return XRE_IsContentProcess() ? cacheSize : kDefaultGlyphCacheSize; } @@ -750,10 +749,8 @@ WebRenderMemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport, #undef REPORT_DATA_STORE static const char* const WR_ROLLOUT_PREF = "gfx.webrender.all.qualified"; -static const bool WR_ROLLOUT_PREF_DEFAULTVALUE = true; -static const char* const WR_ROLLOUT_DEFAULT_PREF = +static const char* const WR_ROLLOUT_PREF_DEFAULT = "gfx.webrender.all.qualified.default"; -static const bool WR_ROLLOUT_DEFAULT_PREF_DEFAULTVALUE = false; static const char* const WR_ROLLOUT_PREF_OVERRIDE = "gfx.webrender.all.qualified.gfxPref-default-override"; static const char* const WR_ROLLOUT_HW_QUALIFIED_OVERRIDE = @@ -821,20 +818,10 @@ class WrRolloutPrefShutdownSaver : public nsIObserver { bool defaultValue = Preferences::GetBool(WR_ROLLOUT_PREF, false, PrefValueKind::Default); - Preferences::SetBool(WR_ROLLOUT_DEFAULT_PREF, defaultValue); + Preferences::SetBool(WR_ROLLOUT_PREF_DEFAULT, defaultValue); } }; -static void FrameRatePrefChanged(const char* aPref, void*) { - int32_t newRate = gfxPlatform::ForceSoftwareVsync() - ? gfxPlatform::GetSoftwareVsyncRate() - : -1; - if (newRate != gLastUsedFrameRate) { - gLastUsedFrameRate = newRate; - gfxPlatform::ReInitFrameRate(); - } -} - NS_IMPL_ISUPPORTS(WrRolloutPrefShutdownSaver, nsIObserver) void gfxPlatform::Init() { @@ -847,6 +834,8 @@ void gfxPlatform::Init() { } gEverInitialized = true; + // Initialize the preferences by creating the singleton. + gfxPrefs::GetSingleton(); gfxVars::Initialize(); gfxConfig::Init(); @@ -893,10 +882,6 @@ void gfxPlatform::Init() { } gfxUtils::RemoveShaderCacheFromDiskIfNecessary(); - - nsAutoCString path; - Preferences::GetCString("layers.windowrecording.path", path); - gfxVars::SetLayersWindowRecordingPath(path); } // Drop a note in the crash report if we end up forcing an option that could @@ -906,25 +891,25 @@ void gfxPlatform::Init() { { nsAutoCString forcedPrefs; // D2D prefs - forcedPrefs.AppendPrintf("FP(D%d%d", StaticPrefs::Direct2DDisabled(), - StaticPrefs::Direct2DForceEnabled()); + forcedPrefs.AppendPrintf("FP(D%d%d", gfxPrefs::Direct2DDisabled(), + gfxPrefs::Direct2DForceEnabled()); // Layers prefs forcedPrefs.AppendPrintf( - "-L%d%d%d%d", StaticPrefs::LayersAMDSwitchableGfxEnabled(), - StaticPrefs::LayersAccelerationDisabledDoNotUseDirectly(), - StaticPrefs::LayersAccelerationForceEnabledDoNotUseDirectly(), - StaticPrefs::LayersD3D11ForceWARP()); + "-L%d%d%d%d", gfxPrefs::LayersAMDSwitchableGfxEnabled(), + gfxPrefs::LayersAccelerationDisabledDoNotUseDirectly(), + gfxPrefs::LayersAccelerationForceEnabledDoNotUseDirectly(), + gfxPrefs::LayersD3D11ForceWARP()); // WebGL prefs forcedPrefs.AppendPrintf( - "-W%d%d%d%d%d%d%d%d", StaticPrefs::WebGLANGLEForceD3D11(), - StaticPrefs::WebGLANGLEForceWARP(), StaticPrefs::WebGLDisabled(), - StaticPrefs::WebGLDisableANGLE(), StaticPrefs::WebGLDXGLEnabled(), - StaticPrefs::WebGLForceEnabled(), - StaticPrefs::WebGLForceLayersReadback(), StaticPrefs::WebGLForceMSAA()); + "-W%d%d%d%d%d%d%d%d", gfxPrefs::WebGLANGLEForceD3D11(), + gfxPrefs::WebGLANGLEForceWARP(), gfxPrefs::WebGLDisabled(), + gfxPrefs::WebGLDisableANGLE(), gfxPrefs::WebGLDXGLEnabled(), + gfxPrefs::WebGLForceEnabled(), gfxPrefs::WebGLForceLayersReadback(), + gfxPrefs::WebGLForceMSAA()); // Prefs that don't fit into any of the other sections - forcedPrefs.AppendPrintf("-T%d%d%d) ", StaticPrefs::AndroidRGB16Force(), + forcedPrefs.AppendPrintf("-T%d%d%d) ", gfxPrefs::AndroidRGB16Force(), 0, // SkiaGL canvas no longer supported - StaticPrefs::ForceShmemTiles()); + gfxPrefs::ForceShmemTiles()); ScopedGfxFeatureReporter::AppNote(forcedPrefs); } @@ -965,12 +950,11 @@ void gfxPlatform::Init() { gPlatform->PopulateScreenInfo(); gPlatform->InitAcceleration(); gPlatform->InitWebRenderConfig(); - // When using WebRender, we defer initialization of the D3D11 devices until // the (rare) cases where they're used. Note that the GPU process where // WebRender runs doesn't initialize gfxPlatform and performs explicit // initialization of the bits it needs. - if (!UseWebRender()) { + if (!gfxVars::UseWebRender()) { gPlatform->EnsureDevicesInitialized(); } gPlatform->InitOMTPConfig(); @@ -981,9 +965,14 @@ void gfxPlatform::Init() { } gLastUsedFrameRate = ForceSoftwareVsync() ? GetSoftwareVsyncRate() : -1; - Preferences::RegisterCallback( - FrameRatePrefChanged, - nsDependentCString(StaticPrefs::GetLayoutFrameRatePrefName())); + auto updateFrameRateCallback = [](const GfxPrefValue& aValue) -> void { + int32_t newRate = ForceSoftwareVsync() ? GetSoftwareVsyncRate() : -1; + if (newRate != gLastUsedFrameRate) { + gLastUsedFrameRate = newRate; + ReInitFrameRate(); + } + }; + gfxPrefs::SetLayoutFrameRateChangeCallback(updateFrameRateCallback); // Set up the vsync source for the parent process. ReInitFrameRate(); @@ -1059,7 +1048,7 @@ void gfxPlatform::Init() { } RegisterStrongMemoryReporter(new GfxMemoryImageReporter()); - if (XRE_IsParentProcess() && UseWebRender()) { + if (XRE_IsParentProcess() && gfxVars::UseWebRender()) { RegisterStrongAsyncMemoryReporter(new WebRenderMemoryReporter()); } @@ -1128,7 +1117,7 @@ int32_t gfxPlatform::MaxTextureSize() { // Make sure we don't completely break rendering because of a typo in the // pref or whatnot. const int32_t kMinSizePref = 2048; - return std::max(kMinSizePref, StaticPrefs::MaxTextureSizeDoNotUseDirectly()); + return std::max(kMinSizePref, gfxPrefs::MaxTextureSizeDoNotUseDirectly()); } /* static */ @@ -1136,14 +1125,14 @@ int32_t gfxPlatform::MaxAllocSize() { // Make sure we don't completely break rendering because of a typo in the // pref or whatnot. const int32_t kMinAllocPref = 10000000; - return std::max(kMinAllocPref, StaticPrefs::MaxAllocSizeDoNotUseDirectly()); + return std::max(kMinAllocPref, gfxPrefs::MaxAllocSizeDoNotUseDirectly()); } /* static */ void gfxPlatform::InitMoz2DLogging() { auto fwd = new CrashStatsLogForwarder( CrashReporter::Annotation::GraphicsCriticalError); - fwd->SetCircularBufferSize(StaticPrefs::GfxLoggingCrashLength()); + fwd->SetCircularBufferSize(gfxPrefs::GfxLoggingCrashLength()); mozilla::gfx::Config cfg; cfg.mLogForwarder = fwd; @@ -1164,9 +1153,6 @@ bool gfxPlatform::IsHeadless() { return headless; } -/* static */ -bool gfxPlatform::UseWebRender() { return gfx::gfxVars::UseWebRender(); } - static bool sLayersIPCIsUp = false; /* static */ @@ -1243,6 +1229,7 @@ void gfxPlatform::Shutdown() { delete gGfxPlatformPrefsLock; gfxVars::Shutdown(); + gfxPrefs::DestroySingleton(); gfxFont::DestroySingletons(); gfxConfig::Shutdown(); @@ -1267,7 +1254,8 @@ void gfxPlatform::InitLayersIPC() { } if (XRE_IsParentProcess() || recordreplay::IsRecordingOrReplaying()) { - if (!gfxConfig::IsEnabled(Feature::GPU_PROCESS) && UseWebRender()) { + if (!gfxConfig::IsEnabled(Feature::GPU_PROCESS) && + gfxVars::UseWebRender()) { wr::RenderThread::Start(); image::ImageMemoryReporter::InitForWebRender(); } @@ -1286,7 +1274,7 @@ void gfxPlatform::ShutdownLayersIPC() { if (XRE_IsContentProcess()) { gfx::VRManagerChild::ShutDown(); // cf bug 1215265. - if (StaticPrefs::ChildProcessShutdown()) { + if (gfxPrefs::ChildProcessShutdown()) { layers::CompositorManagerChild::Shutdown(); layers::ImageBridgeChild::ShutDown(); } @@ -1304,7 +1292,7 @@ void gfxPlatform::ShutdownLayersIPC() { // This has to happen after shutting down the child protocols. layers::CompositorThreadHolder::Shutdown(); image::ImageMemoryReporter::ShutdownForWebRender(); - // There is a case that RenderThread exists when UseWebRender() is + // There is a case that RenderThread exists when gfxVars::UseWebRender() is // false. This could happen when WebRender was fallbacked to compositor. if (wr::RenderThread::Get()) { wr::RenderThread::ShutDown(); @@ -1547,10 +1535,10 @@ void gfxPlatform::ComputeTileSize() { return; } - int32_t w = StaticPrefs::LayersTileWidth(); - int32_t h = StaticPrefs::LayersTileHeight(); + int32_t w = gfxPrefs::LayersTileWidth(); + int32_t h = gfxPrefs::LayersTileHeight(); - if (StaticPrefs::LayersTilesAdjust()) { + if (gfxPrefs::LayersTilesAdjust()) { gfx::IntSize screenSize = GetScreenSize(); if (screenSize.width > 0) { // Choose a size so that there are between 2 and 4 tiles per screen width. @@ -1852,16 +1840,16 @@ gfxFontEntry* gfxPlatform::MakePlatformFont(const nsACString& aFontName, mozilla::layers::DiagnosticTypes gfxPlatform::GetLayerDiagnosticTypes() { mozilla::layers::DiagnosticTypes type = DiagnosticTypes::NO_DIAGNOSTIC; - if (StaticPrefs::DrawLayerBorders()) { + if (gfxPrefs::DrawLayerBorders()) { type |= mozilla::layers::DiagnosticTypes::LAYER_BORDERS; } - if (StaticPrefs::DrawTileBorders()) { + if (gfxPrefs::DrawTileBorders()) { type |= mozilla::layers::DiagnosticTypes::TILE_BORDERS; } - if (StaticPrefs::DrawBigImageBorders()) { + if (gfxPrefs::DrawBigImageBorders()) { type |= mozilla::layers::DiagnosticTypes::BIGIMAGE_BORDERS; } - if (StaticPrefs::FlashLayerBorders()) { + if (gfxPrefs::FlashLayerBorders()) { type |= mozilla::layers::DiagnosticTypes::FLASH_BORDERS; } return type; @@ -1975,12 +1963,12 @@ bool gfxPlatform::OffMainThreadCompositingEnabled() { eCMSMode gfxPlatform::GetCMSMode() { if (!gCMSInitialized) { - int32_t mode = StaticPrefs::CMSMode(); + int32_t mode = gfxPrefs::CMSMode(); if (mode >= 0 && mode < eCMSMode_AllCount) { gCMSMode = static_cast(mode); } - bool enableV4 = StaticPrefs::CMSEnableV4(); + bool enableV4 = gfxPrefs::CMSEnableV4(); if (enableV4) { qcms_enable_iccv4(); } @@ -1990,14 +1978,14 @@ eCMSMode gfxPlatform::GetCMSMode() { } int gfxPlatform::GetRenderingIntent() { - // StaticPrefs.h is using 0 as the default for the rendering + // gfxPrefs.h is using 0 as the default for the rendering // intent preference, based on that being the value for // QCMS_INTENT_DEFAULT. Assert here to catch if that ever // changes and we can then figure out what to do about it. MOZ_ASSERT(QCMS_INTENT_DEFAULT == 0); /* Try to query the pref system for a rendering intent. */ - int32_t pIntent = StaticPrefs::CMSRenderingIntent(); + int32_t pIntent = gfxPrefs::CMSRenderingIntent(); if ((pIntent < QCMS_INTENT_MIN) || (pIntent > QCMS_INTENT_MAX)) { /* If the pref is out of range, use embedded profile. */ pIntent = -1; @@ -2357,6 +2345,8 @@ void gfxPlatform::InitAcceleration() { // explicit. MOZ_ASSERT(NS_IsMainThread(), "can only initialize prefs on the main thread"); + gfxPrefs::GetSingleton(); + nsCOMPtr gfxInfo = services::GetGfxInfo(); nsCString discardFailureId; int32_t status; @@ -2388,7 +2378,7 @@ void gfxPlatform::InitAcceleration() { gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING, discardFailureId, &status))) { if (status == nsIGfxInfo::FEATURE_STATUS_OK || - StaticPrefs::HardwareVideoDecodingForceEnabled()) { + gfxPrefs::HardwareVideoDecodingForceEnabled()) { sLayersSupportsHardwareVideoDecoding = true; } } @@ -2406,8 +2396,7 @@ void gfxPlatform::InitAcceleration() { void gfxPlatform::InitGPUProcessPrefs() { // We want to hide this from about:support, so only set a default if the // pref is known to be true. - if (!StaticPrefs::GPUProcessEnabled() && - !StaticPrefs::GPUProcessForceEnabled()) { + if (!gfxPrefs::GPUProcessEnabled() && !gfxPrefs::GPUProcessForceEnabled()) { return; } @@ -2421,12 +2410,11 @@ void gfxPlatform::InitGPUProcessPrefs() { "Multi-process mode is not enabled", NS_LITERAL_CSTRING("FEATURE_FAILURE_NO_E10S")); } else { - gpuProc.SetDefaultFromPref(StaticPrefs::GetGPUProcessEnabledPrefName(), - true, - StaticPrefs::GetGPUProcessEnabledPrefDefault()); + gpuProc.SetDefaultFromPref(gfxPrefs::GetGPUProcessEnabledPrefName(), true, + gfxPrefs::GetGPUProcessEnabledPrefDefault()); } - if (StaticPrefs::GPUProcessForceEnabled()) { + if (gfxPrefs::GPUProcessForceEnabled()) { gpuProc.UserForceEnable("User force-enabled via pref"); } @@ -2440,7 +2428,7 @@ void gfxPlatform::InitGPUProcessPrefs() { NS_LITERAL_CSTRING("FEATURE_FAILURE_SAFE_MODE")); return; } - if (StaticPrefs::LayerScopeEnabled()) { + if (gfxPrefs::LayerScopeEnabled()) { gpuProc.ForceDisable(FeatureStatus::Blocked, "LayerScope does not work in the GPU process", NS_LITERAL_CSTRING("FEATURE_FAILURE_LAYERSCOPE")); @@ -2456,7 +2444,7 @@ void gfxPlatform::InitCompositorAccelerationPrefs() { // Base value - does the platform allow acceleration? if (feature.SetDefault(AccelerateLayersByDefault(), FeatureStatus::Blocked, "Acceleration blocked by platform")) { - if (StaticPrefs::LayersAccelerationDisabledDoNotUseDirectly()) { + if (gfxPrefs::LayersAccelerationDisabledDoNotUseDirectly()) { feature.UserDisable("Disabled by pref", NS_LITERAL_CSTRING("FEATURE_FAILURE_COMP_PREF")); } else if (acceleratedEnv && *acceleratedEnv == '0') { @@ -2470,7 +2458,7 @@ void gfxPlatform::InitCompositorAccelerationPrefs() { } // This has specific meaning elsewhere, so we always record it. - if (StaticPrefs::LayersAccelerationForceEnabledDoNotUseDirectly()) { + if (gfxPrefs::LayersAccelerationForceEnabledDoNotUseDirectly()) { feature.UserForceEnable("Force-enabled by pref"); } @@ -2494,8 +2482,8 @@ void gfxPlatform::InitCompositorAccelerationPrefs() { /*static*/ bool gfxPlatform::WebRenderPrefEnabled() { - return StaticPrefs::WebRenderAll() || - StaticPrefs::WebRenderEnabledDoNotUseDirectly(); + return gfxPrefs::WebRenderAll() || + gfxPrefs::WebRenderEnabledDoNotUseDirectly(); } /*static*/ @@ -2522,41 +2510,28 @@ static bool CalculateWrQualifiedPrefValue() { // Clear the mirror of the default value of the rollout pref on scope exit, // if we have one. This ensures the user doesn't mess with the pref. // If we need it again, we'll re-create it on shutdown. - Preferences::ClearUser(WR_ROLLOUT_DEFAULT_PREF); + Preferences::ClearUser(WR_ROLLOUT_PREF_DEFAULT); }); if (!Preferences::HasUserValue(WR_ROLLOUT_PREF) && - Preferences::HasUserValue(WR_ROLLOUT_DEFAULT_PREF)) { + Preferences::HasUserValue(WR_ROLLOUT_PREF_DEFAULT)) { // The user has not set a user pref, and we have a default value set by the - // shutdown observer. Let's use this as it should be the value Normandy set - // before startup. WR_ROLLOUT_DEFAULT_PREF should only be set on shutdown by - // the shutdown observer. - // Normandy runs *during* startup, but *after* this code here runs (hence - // the need for the workaround). - // To have a value stored in the WR_ROLLOUT_DEFAULT_PREF pref here, during - // the previous run Normandy must have set a default value on the in-memory - // pref, and on shutdown we stored the default value in this - // WR_ROLLOUT_DEFAULT_PREF user pref. Then once the user restarts, we - // observe this pref. Normandy is the only way a default (not user) value - // can be set for this pref. - return Preferences::GetBool(WR_ROLLOUT_DEFAULT_PREF, - WR_ROLLOUT_DEFAULT_PREF_DEFAULTVALUE); + // shutdown observer. We should use that instead of the gfxPref's default, + // as if Normandy had a chance to set it before startup, that is the value + // gfxPrefs would return, rather than the default set by DECL_GFX_PREF. + return gfxPrefs::WebRenderAllQualifiedDefault(); } // We don't have a user value for the rollout pref, and we don't have the // value of the rollout pref at last shutdown stored. So we should fallback - // to using the default. *But* if we're running + // to using whatever default is stored in the gfxPref. *But* if we're running // under the Marionette pref rollout work-around test, we may want to override // the default value expressed here, so we can test the "default disabled; // rollout pref enabled" case. - // Note that those preferences can't be defined in all.js nor - // StaticPrefsList.h as they would create the pref, leading SaveRolloutPref() - // above to abort early as the pref would have a valid type. - // We also don't want those prefs to appear in about:config. if (Preferences::HasUserValue(WR_ROLLOUT_PREF_OVERRIDE)) { return Preferences::GetBool(WR_ROLLOUT_PREF_OVERRIDE); } - return Preferences::GetBool(WR_ROLLOUT_PREF, WR_ROLLOUT_PREF_DEFAULTVALUE); + return gfxPrefs::WebRenderAllQualified(); } static FeatureState& WebRenderHardwareQualificationStatus( @@ -2794,7 +2769,7 @@ void gfxPlatform::InitWebRenderConfig() { // The parent process runs through all the real decision-making code // later in this function. For other processes we still want to report // the state of the feature for crash reports. - if (UseWebRender()) { + if (gfxVars::UseWebRender()) { reporter.SetSuccessful(); } return; @@ -2827,7 +2802,7 @@ void gfxPlatform::InitWebRenderConfig() { // If the user set the pref to force-disable, let's do that. This will // override all the other enabling prefs (gfx.webrender.enabled, // gfx.webrender.all, and gfx.webrender.all.qualified). - if (StaticPrefs::WebRenderForceDisabled() || WebRenderEnvvarDisabled()) { + if (gfxPrefs::WebRenderForceDisabled() || WebRenderEnvvarDisabled()) { featureWebRender.UserDisable( "User force-disabled WR", NS_LITERAL_CSTRING("FEATURE_FAILURE_USER_FORCE_DISABLED")); @@ -2913,7 +2888,8 @@ void gfxPlatform::InitWebRenderConfig() { #ifdef XP_WIN if (Preferences::GetBool("gfx.webrender.dcomp-win.enabled", false)) { // XXX relax win version to windows 8. - if (IsWin10OrLater() && UseWebRender() && gfxVars::UseWebRenderANGLE()) { + if (IsWin10OrLater() && gfxVars::UseWebRender() && + gfxVars::UseWebRenderANGLE()) { gfxVars::SetUseWebRenderDCompWin(true); } } @@ -2989,7 +2965,7 @@ bool gfxPlatform::AccelerateLayersByDefault() { bool gfxPlatform::BufferRotationEnabled() { MutexAutoLock autoLock(*gGfxPlatformPrefsLock); - return sBufferRotationCheckPref && StaticPrefs::BufferRotationEnabled(); + return sBufferRotationCheckPref && gfxPrefs::BufferRotationEnabled(); } void gfxPlatform::DisableBufferRotation() { @@ -3010,10 +2986,10 @@ bool gfxPlatform::UsesOffMainThreadCompositing() { if (firstTime) { MOZ_ASSERT(sLayersAccelerationPrefsInitialized); result = gfxVars::BrowserTabsRemoteAutostart() || - !StaticPrefs::LayersOffMainThreadCompositionForceDisabled(); + !gfxPrefs::LayersOffMainThreadCompositionForceDisabled(); #if defined(MOZ_WIDGET_GTK) // Linux users who chose OpenGL are being grandfathered in to OMTC - result |= StaticPrefs::LayersAccelerationForceEnabledDoNotUseDirectly(); + result |= gfxPrefs::LayersAccelerationForceEnabledDoNotUseDirectly(); #endif firstTime = false; @@ -3029,12 +3005,11 @@ bool gfxPlatform::UsesTiling() const { // this function is used when initializing the PaintThread. So instead we // check the conditions that enable OMTP with parallel painting. bool usesPOMTP = XRE_IsContentProcess() && gfxVars::UseOMTP() && - (StaticPrefs::LayersOMTPPaintWorkers() == -1 || - StaticPrefs::LayersOMTPPaintWorkers() > 1); + (gfxPrefs::LayersOMTPPaintWorkers() == -1 || + gfxPrefs::LayersOMTPPaintWorkers() > 1); - return StaticPrefs::LayersTilesEnabled() || - (StaticPrefs::LayersTilesEnabledIfSkiaPOMTP() && usesSkia && - usesPOMTP); + return gfxPrefs::LayersTilesEnabled() || + (gfxPrefs::LayersTilesEnabledIfSkiaPOMTP() && usesSkia && usesPOMTP); } bool gfxPlatform::ContentUsesTiling() const { @@ -3046,11 +3021,11 @@ bool gfxPlatform::ContentUsesTiling() const { bool contentUsesSkia = contentBackend == BackendType::SKIA; bool contentUsesPOMTP = - gfxVars::UseOMTP() && (StaticPrefs::LayersOMTPPaintWorkers() == -1 || - StaticPrefs::LayersOMTPPaintWorkers() > 1); + gfxVars::UseOMTP() && (gfxPrefs::LayersOMTPPaintWorkers() == -1 || + gfxPrefs::LayersOMTPPaintWorkers() > 1); - return StaticPrefs::LayersTilesEnabled() || - (StaticPrefs::LayersTilesEnabledIfSkiaPOMTP() && contentUsesSkia && + return gfxPrefs::LayersTilesEnabled() || + (gfxPrefs::LayersTilesEnabledIfSkiaPOMTP() && contentUsesSkia && contentUsesPOMTP); } @@ -3075,18 +3050,18 @@ bool gfxPlatform::IsInLayoutAsapMode() { // the second is that the compositor goes ASAP and the refresh driver // goes at whatever the configurated rate is. This only checks the version // talos uses, which is the refresh driver and compositor are in lockstep. - return StaticPrefs::LayoutFrameRate() == 0; + return gfxPrefs::LayoutFrameRate() == 0; } /* static */ bool gfxPlatform::ForceSoftwareVsync() { - return StaticPrefs::LayoutFrameRate() > 0 || + return gfxPrefs::LayoutFrameRate() > 0 || recordreplay::IsRecordingOrReplaying(); } /* static */ int gfxPlatform::GetSoftwareVsyncRate() { - int preferenceRate = StaticPrefs::LayoutFrameRate(); + int preferenceRate = gfxPrefs::LayoutFrameRate(); if (preferenceRate <= 0) { return gfxPlatform::GetDefaultFrameRate(); } @@ -3163,8 +3138,7 @@ void gfxPlatform::GetApzSupportInfo(mozilla::widget::InfoObject& aObj) { aObj.DefineProperty("ApzDragInput", 1); } - if (SupportsApzKeyboardInput() && - !StaticPrefs::AccessibilityBrowseWithCaret()) { + if (SupportsApzKeyboardInput() && !gfxPrefs::AccessibilityBrowseWithCaret()) { aObj.DefineProperty("ApzKeyboardInput", 1); } @@ -3174,7 +3148,7 @@ void gfxPlatform::GetApzSupportInfo(mozilla::widget::InfoObject& aObj) { } void gfxPlatform::GetTilesSupportInfo(mozilla::widget::InfoObject& aObj) { - if (!StaticPrefs::LayersTilesEnabled()) { + if (!gfxPrefs::LayersTilesEnabled()) { return; } @@ -3222,7 +3196,7 @@ class FrameStatsComparator { }; void gfxPlatform::NotifyFrameStats(nsTArray&& aFrameStats) { - if (!StaticPrefs::LoggingSlowFramesEnabled()) { + if (!gfxPrefs::LoggingSlowFramesEnabled()) { return; } @@ -3258,12 +3232,17 @@ bool gfxPlatform::AsyncPanZoomEnabled() { #ifdef MOZ_WIDGET_ANDROID return true; #else - return StaticPrefs::AsyncPanZoomEnabledDoNotUseDirectly(); + if (!gfxPrefs::SingletonExists()) { + // Make sure the gfxPrefs has been initialized before reading from it. + MOZ_ASSERT(NS_IsMainThread()); + gfxPrefs::GetSingleton(); + } + return gfxPrefs::AsyncPanZoomEnabledDoNotUseDirectly(); #endif } /*static*/ -bool gfxPlatform::PerfWarnings() { return StaticPrefs::PerfWarnings(); } +bool gfxPlatform::PerfWarnings() { return gfxPrefs::PerfWarnings(); } void gfxPlatform::GetAcceleratedCompositorBackends( nsTArray& aBackends) { @@ -3375,15 +3354,15 @@ bool gfxPlatform::SupportsApzTouchInput() const { } bool gfxPlatform::SupportsApzDragInput() const { - return StaticPrefs::APZDragEnabled(); + return gfxPrefs::APZDragEnabled(); } bool gfxPlatform::SupportsApzKeyboardInput() const { - return StaticPrefs::APZKeyboardEnabled(); + return gfxPrefs::APZKeyboardEnabled(); } bool gfxPlatform::SupportsApzAutoscrolling() const { - return StaticPrefs::APZAutoscrollEnabled(); + return gfxPrefs::APZAutoscrollEnabled(); } void gfxPlatform::InitOpenGLConfig() { @@ -3408,15 +3387,15 @@ void gfxPlatform::InitOpenGLConfig() { #ifdef XP_WIN openGLFeature.SetDefaultFromPref( - StaticPrefs::GetLayersPreferOpenGLPrefName(), true, - StaticPrefs::GetLayersPreferOpenGLPrefDefault()); + gfxPrefs::GetLayersPreferOpenGLPrefName(), true, + gfxPrefs::GetLayersPreferOpenGLPrefDefault()); #else openGLFeature.EnableByDefault(); #endif // When layers acceleration is force-enabled, enable it even for blacklisted // devices. - if (StaticPrefs::LayersAccelerationForceEnabledDoNotUseDirectly()) { + if (gfxPrefs::LayersAccelerationForceEnabledDoNotUseDirectly()) { openGLFeature.UserForceEnable("Force-enabled by pref"); return; } diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 0a2200346f164..896dff0452ff8 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -203,8 +203,6 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener { static bool IsHeadless(); - static bool UseWebRender(); - /** * Create an offscreen surface of the given dimensions * and image format. @@ -669,8 +667,8 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener { mozilla::gfx::SurfaceFormat aFormat); /** - * Wrapper around StaticPrefs::PerfWarnings(). - * Extracted into a function to avoid including StaticPrefs.h from this file. + * Wrapper around gfxPrefs::PerfWarnings(). + * Extracted into a function to avoid including gfxPrefs.h from this file. */ static bool PerfWarnings(); diff --git a/gfx/thebes/gfxPlatformFontList.cpp b/gfx/thebes/gfxPlatformFontList.cpp index d3e120cf027fb..50b122fb1ac22 100644 --- a/gfx/thebes/gfxPlatformFontList.cpp +++ b/gfx/thebes/gfxPlatformFontList.cpp @@ -9,6 +9,7 @@ #include "mozilla/intl/OSPreferences.h" #include "gfxPlatformFontList.h" +#include "gfxPrefs.h" #include "gfxTextRun.h" #include "gfxUserFontSet.h" #include "SharedFontList-impl.h" @@ -25,7 +26,6 @@ #include "mozilla/MemoryReporting.h" #include "mozilla/Mutex.h" #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Telemetry.h" #include "mozilla/TimeStamp.h" #include "mozilla/dom/BlobImpl.h" @@ -419,7 +419,7 @@ nsresult gfxPlatformFontList::InitFontList() { // Try to initialize the cross-process shared font list if enabled by prefs, // but not if we're running in Safe Mode. - if (StaticPrefs::SharedFontList() && !gfxPlatform::InSafeMode()) { + if (gfxPrefs::SharedFontList() && !gfxPlatform::InSafeMode()) { for (auto i = mFontEntries.Iter(); !i.Done(); i.Next()) { i.Data()->mShmemCharacterMap = nullptr; i.Data()->mShmemFace = nullptr; diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index 207a3894b62c4..d67d020d1e97e 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -18,11 +18,11 @@ #include "gfxUserFontSet.h" #include "gfxUtils.h" #include "gfxFT2FontBase.h" +#include "gfxPrefs.h" #include "gfxTextRun.h" #include "VsyncSource.h" #include "mozilla/Atomics.h" #include "mozilla/Monitor.h" -#include "mozilla/StaticPrefs.h" #include "base/task.h" #include "base/thread.h" #include "base/message_loop.h" @@ -291,7 +291,7 @@ double gfxPlatformGtk::GetFontScaleFactor() { bool gfxPlatformGtk::UseImageOffscreenSurfaces() { return GetDefaultContentBackend() != mozilla::gfx::BackendType::CAIRO || - StaticPrefs::UseImageOffscreenSurfaces(); + gfxPrefs::UseImageOffscreenSurfaces(); } gfxImageFormat gfxPlatformGtk::GetOffscreenFormat() { diff --git a/gfx/thebes/gfxPrefs.cpp b/gfx/thebes/gfxPrefs.cpp new file mode 100644 index 0000000000000..6b194455ae78d --- /dev/null +++ b/gfx/thebes/gfxPrefs.cpp @@ -0,0 +1,296 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "gfxPrefs.h" + +#include "MainThreadUtils.h" +#include "nsXULAppAPI.h" +#include "mozilla/Preferences.h" +#include "mozilla/Unused.h" +#include "mozilla/gfx/gfxVars.h" +#include "mozilla/gfx/Logging.h" +#include "mozilla/gfx/GPUChild.h" +#include "mozilla/gfx/GPUProcessManager.h" +#include "VRProcessManager.h" +#include "VRChild.h" + +using namespace mozilla; + +nsTArray* gfxPrefs::sGfxPrefList = nullptr; +gfxPrefs* gfxPrefs::sInstance = nullptr; +bool gfxPrefs::sInstanceHasBeenDestroyed = false; + +gfxPrefs& gfxPrefs::CreateAndInitializeSingleton() { + MOZ_ASSERT(!sInstanceHasBeenDestroyed, + "Should never recreate a gfxPrefs instance!"); + sGfxPrefList = new nsTArray(); + sInstance = new gfxPrefs; + sInstance->Init(); + MOZ_ASSERT(SingletonExists()); + return *sInstance; +} + +void gfxPrefs::DestroySingleton() { + if (sInstance) { + delete sInstance; + sInstance = nullptr; + sInstanceHasBeenDestroyed = true; + } + MOZ_ASSERT(!SingletonExists()); +} + +bool gfxPrefs::SingletonExists() { return sInstance != nullptr; } + +gfxPrefs::gfxPrefs() { + // UI, content, and plugin processes use XPCOM and should have prefs + // ready by the time we initialize gfxPrefs. + MOZ_ASSERT_IF(XRE_IsContentProcess() || XRE_IsParentProcess() || + XRE_GetProcessType() == GeckoProcessType_Plugin, + Preferences::IsServiceAvailable()); + + gfxPrefs::AssertMainThread(); +} + +void gfxPrefs::Init() { + // Set up Moz2D prefs. + SetGfxLoggingLevelChangeCallback([](const GfxPrefValue& aValue) -> void { + mozilla::gfx::LoggingPrefs::sGfxLogLevel = aValue.get_int32_t(); + }); +} + +gfxPrefs::~gfxPrefs() { + gfxPrefs::AssertMainThread(); + SetGfxLoggingLevelChangeCallback(nullptr); + delete sGfxPrefList; + sGfxPrefList = nullptr; +} + +void gfxPrefs::AssertMainThread() { + MOZ_ASSERT(NS_IsMainThread(), "this code must be run on the main thread"); +} + +void gfxPrefs::Pref::OnChange() { + if (auto gpm = gfx::GPUProcessManager::Get()) { + if (gfx::GPUChild* gpu = gpm->GetGPUChild()) { + GfxPrefValue value; + GetLiveValue(&value); + Unused << gpu->SendUpdatePref(gfx::GfxPrefSetting(mIndex, value)); + } + } + if (auto vpm = gfx::VRProcessManager::Get()) { + if (gfx::VRChild* vr = vpm->GetVRChild()) { + GfxPrefValue value; + GetLiveValue(&value); + Unused << vr->SendUpdatePref(gfx::GfxPrefSetting(mIndex, value)); + } + } + FireChangeCallback(); +} + +void gfxPrefs::Pref::FireChangeCallback() { + if (mChangeCallback) { + GfxPrefValue value; + GetLiveValue(&value); + mChangeCallback(value); + } +} + +void gfxPrefs::Pref::SetChangeCallback(ChangeCallback aCallback) { + mChangeCallback = aCallback; + + if (!IsParentProcess() && IsPrefsServiceAvailable()) { + // If we're in the parent process, we watch prefs by default so we can + // send changes over to the GPU process. Otherwise, we need to add or + // remove a watch for the pref now. + if (aCallback) { + WatchChanges(Name(), this); + } else { + UnwatchChanges(Name(), this); + } + } + + // Fire the callback once to make initialization easier for the caller. + FireChangeCallback(); +} + +// On lightweight processes such as for GMP and GPU, XPCOM is not initialized, +// and therefore we don't have access to Preferences. When XPCOM is not +// available we rely on manual synchronization of gfxPrefs values over IPC. +/* static */ +bool gfxPrefs::IsPrefsServiceAvailable() { + return Preferences::IsServiceAvailable(); +} + +/* static */ +bool gfxPrefs::IsParentProcess() { return XRE_IsParentProcess(); } + +void gfxPrefs::PrefAddVarCache(bool* aVariable, const nsACString& aPref, + bool aDefault) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + Preferences::AddBoolVarCache(aVariable, aPref, aDefault); +} + +void gfxPrefs::PrefAddVarCache(int32_t* aVariable, const nsACString& aPref, + int32_t aDefault) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + Preferences::AddIntVarCache(aVariable, aPref, aDefault); +} + +void gfxPrefs::PrefAddVarCache(uint32_t* aVariable, const nsACString& aPref, + uint32_t aDefault) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + Preferences::AddUintVarCache(aVariable, aPref, aDefault); +} + +void gfxPrefs::PrefAddVarCache(float* aVariable, const nsACString& aPref, + float aDefault) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + Preferences::AddFloatVarCache(aVariable, aPref, aDefault); +} + +void gfxPrefs::PrefAddVarCache(std::string* aVariable, const nsCString& aPref, + std::string aDefault) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + Preferences::SetCString(aPref.get(), aVariable->c_str()); +} + +void gfxPrefs::PrefAddVarCache(AtomicBool* aVariable, const nsACString& aPref, + bool aDefault) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + Preferences::AddAtomicBoolVarCache(aVariable, aPref, aDefault); +} + +void gfxPrefs::PrefAddVarCache(AtomicInt32* aVariable, const nsACString& aPref, + int32_t aDefault) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + Preferences::AddAtomicIntVarCache(aVariable, aPref, aDefault); +} + +void gfxPrefs::PrefAddVarCache(AtomicUint32* aVariable, const nsACString& aPref, + uint32_t aDefault) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + Preferences::AddAtomicUintVarCache(aVariable, aPref, aDefault); +} + +bool gfxPrefs::PrefGet(const char* aPref, bool aDefault) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + return Preferences::GetBool(aPref, aDefault); +} + +int32_t gfxPrefs::PrefGet(const char* aPref, int32_t aDefault) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + return Preferences::GetInt(aPref, aDefault); +} + +uint32_t gfxPrefs::PrefGet(const char* aPref, uint32_t aDefault) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + return Preferences::GetUint(aPref, aDefault); +} + +float gfxPrefs::PrefGet(const char* aPref, float aDefault) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + return Preferences::GetFloat(aPref, aDefault); +} + +std::string gfxPrefs::PrefGet(const char* aPref, std::string aDefault) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + + nsAutoCString result; + Preferences::GetCString(aPref, result); + + if (result.IsEmpty()) { + return aDefault; + } + + return result.get(); +} + +void gfxPrefs::PrefSet(const char* aPref, bool aValue) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + Preferences::SetBool(aPref, aValue); +} + +void gfxPrefs::PrefSet(const char* aPref, int32_t aValue) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + Preferences::SetInt(aPref, aValue); +} + +void gfxPrefs::PrefSet(const char* aPref, uint32_t aValue) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + Preferences::SetUint(aPref, aValue); +} + +void gfxPrefs::PrefSet(const char* aPref, float aValue) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + Preferences::SetFloat(aPref, aValue); +} + +void gfxPrefs::PrefSet(const char* aPref, std::string aValue) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + Preferences::SetCString(aPref, aValue.c_str()); +} + +static void OnGfxPrefChanged(const char* aPrefname, gfxPrefs::Pref* aPref) { + aPref->OnChange(); +} + +void gfxPrefs::WatchChanges(const char* aPrefname, Pref* aPref) { + MOZ_ASSERT(IsPrefsServiceAvailable()); + nsCString name; + name.AssignLiteral(aPrefname, strlen(aPrefname)); + Preferences::RegisterCallback(OnGfxPrefChanged, name, aPref); +} + +void gfxPrefs::UnwatchChanges(const char* aPrefname, Pref* aPref) { + // The Preferences service can go offline before gfxPrefs is destroyed. + if (IsPrefsServiceAvailable()) { + Preferences::UnregisterCallback(OnGfxPrefChanged, + nsDependentCString(aPrefname), aPref); + } +} + +void gfxPrefs::CopyPrefValue(const bool* aValue, GfxPrefValue* aOutValue) { + *aOutValue = *aValue; +} + +void gfxPrefs::CopyPrefValue(const int32_t* aValue, GfxPrefValue* aOutValue) { + *aOutValue = *aValue; +} + +void gfxPrefs::CopyPrefValue(const uint32_t* aValue, GfxPrefValue* aOutValue) { + *aOutValue = *aValue; +} + +void gfxPrefs::CopyPrefValue(const float* aValue, GfxPrefValue* aOutValue) { + *aOutValue = *aValue; +} + +void gfxPrefs::CopyPrefValue(const std::string* aValue, + GfxPrefValue* aOutValue) { + *aOutValue = nsCString(aValue->c_str()); +} + +void gfxPrefs::CopyPrefValue(const GfxPrefValue* aValue, bool* aOutValue) { + *aOutValue = aValue->get_bool(); +} + +void gfxPrefs::CopyPrefValue(const GfxPrefValue* aValue, int32_t* aOutValue) { + *aOutValue = aValue->get_int32_t(); +} + +void gfxPrefs::CopyPrefValue(const GfxPrefValue* aValue, uint32_t* aOutValue) { + *aOutValue = aValue->get_uint32_t(); +} + +void gfxPrefs::CopyPrefValue(const GfxPrefValue* aValue, float* aOutValue) { + *aOutValue = aValue->get_float(); +} + +void gfxPrefs::CopyPrefValue(const GfxPrefValue* aValue, + std::string* aOutValue) { + *aOutValue = aValue->get_nsCString().get(); +} + +bool gfxPrefs::OverrideBase_WebRender() { return gfx::gfxVars::UseWebRender(); } diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h new file mode 100644 index 0000000000000..9eae349a199ba --- /dev/null +++ b/gfx/thebes/gfxPrefs.h @@ -0,0 +1,908 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef GFX_PREFS_H +#define GFX_PREFS_H + +#include // for M_PI +#include +#include +#include "mozilla/Assertions.h" +#include "mozilla/Atomics.h" +#include "mozilla/gfx/LoggingConstants.h" +#include "nsTArray.h" +#include "nsString.h" + +// First time gfxPrefs::GetSingleton() needs to be called on the main thread, +// before any of the methods accessing the values are used, but after +// the Preferences system has been initialized. + +// The static methods to access the preference value are safe to call +// from any thread after that first call. + +// To register a preference, you need to add a line in this file using +// the DECL_GFX_PREF macro. +// +// Update argument controls whether we read the preference value and save it +// or connect with a callback. See UpdatePolicy enum below. +// Pref is the string with the preference name. +// Name argument is the name of the static function to create. +// Type is the type of the preference - bool, int32_t, uint32_t. +// Default is the default value for the preference. +// +// For example this line in the .h: +// DECL_GFX_PREF(Once,"layers.dump",LayersDump,bool,false); +// means that you can call +// bool var = gfxPrefs::LayersDump(); +// from any thread, but that you will only get the preference value of +// "layers.dump" as it was set at the start of the session (subject to +// note 2 below). If the value was not set, the default would be false. +// +// In another example, this line in the .h: +// DECL_GFX_PREF(Live,"gl.msaa-level",MSAALevel,uint32_t,2); +// means that every time you call +// uint32_t var = gfxPrefs::MSAALevel(); +// from any thread, you will get the most up to date preference value of +// "gl.msaa-level". If the value is not set, the default would be 2. + +// Note 1: Changing a preference from Live to Once is now as simple +// as changing the Update argument. If your code worked before, it will +// keep working, and behave as if the user never changes the preference. +// Things are a bit more complicated and perhaps even dangerous when +// going from Once to Live, or indeed setting a preference to be Live +// in the first place, so be careful. You need to be ready for the +// values changing mid execution, and if you're using those preferences +// in any setup and initialization, you may need to do extra work. + +// Note 2: Prefs can be set by using the corresponding Set method. For +// example, if the accessor is Foo() then calling SetFoo(...) will update +// the preference and also change the return value of subsequent Foo() calls. +// This is true even for 'Once' prefs which otherwise do not change if the +// pref is updated after initialization. Changing gfxPrefs values in content +// processes will not affect the result in other processes. Changing gfxPrefs +// values in the GPU process is not supported at all. + +#define DECL_GFX_PREF(Update, Prefname, Name, Type, Default) \ + public: \ + static Type Name() { \ + MOZ_ASSERT(SingletonExists()); \ + return GetSingleton().mPref##Name.mValue; \ + } \ + static void Set##Name(Type aVal) { \ + MOZ_ASSERT(SingletonExists()); \ + GetSingleton().mPref##Name.Set(UpdatePolicy::Update, \ + Get##Name##PrefName(), aVal); \ + } \ + static const char* Get##Name##PrefName() { return Prefname; } \ + static Type Get##Name##PrefDefault() { return Default; } \ + static void Set##Name##ChangeCallback(Pref::ChangeCallback aCallback) { \ + MOZ_ASSERT(SingletonExists()); \ + GetSingleton().mPref##Name.SetChangeCallback(aCallback); \ + } \ + \ + private: \ + PrefTemplate \ + mPref##Name + +// This declares an "override" pref, which is exposed as a "bool" pref by the +// API, but is internally stored as a tri-state int pref with three possible +// values: +// - A value of 0 means that it has been force-disabled, and is exposed as a +// false-valued bool. +// - A value of 1 means that it has been force-enabled, and is exposed as a +// true-valued bool. +// - A value of 2 (the default) means that it returns the provided BaseValue +// as a boolean. The BaseValue may be a constant expression or a function. +// If the prefs defined with this macro are listed in prefs files (e.g. all.js), +// then they must be listed with an int value (default to 2, but you can use 0 +// or 1 if you want to force it on or off). +#define DECL_OVERRIDE_PREF(Update, Prefname, Name, BaseValue) \ + public: \ + static bool Name() { \ + MOZ_ASSERT(SingletonExists()); \ + int32_t val = GetSingleton().mPref##Name.mValue; \ + return val == 2 ? !!(BaseValue) : !!val; \ + } \ + static void Set##Name(bool aVal) { \ + MOZ_ASSERT(SingletonExists()); \ + GetSingleton().mPref##Name.Set(UpdatePolicy::Update, \ + Get##Name##PrefName(), aVal ? 1 : 0); \ + } \ + static const char* Get##Name##PrefName() { return Prefname; } \ + static int32_t Get##Name##PrefDefault() { return 2; } \ + static void Set##Name##ChangeCallback(Pref::ChangeCallback aCallback) { \ + MOZ_ASSERT(SingletonExists()); \ + GetSingleton().mPref##Name.SetChangeCallback(aCallback); \ + } \ + \ + private: \ + PrefTemplate \ + mPref##Name + +namespace mozilla { +namespace gfx { +class GfxPrefValue; // defined in PGPU.ipdl +} // namespace gfx +} // namespace mozilla + +class gfxPrefs; +class gfxPrefs final { + typedef mozilla::gfx::GfxPrefValue GfxPrefValue; + + typedef mozilla::Atomic AtomicBool; + typedef mozilla::Atomic AtomicInt32; + typedef mozilla::Atomic AtomicUint32; + + private: + // Enums for the update policy. + enum class UpdatePolicy { + Skip, // Set the value to default, skip any Preferences calls + Once, // Evaluate the preference once, unchanged during the session + Live // Evaluate the preference and set callback so it stays current/live + }; + + public: + class Pref { + public: + Pref() : mChangeCallback(nullptr) { + mIndex = sGfxPrefList->Length(); + sGfxPrefList->AppendElement(this); + } + + size_t Index() const { return mIndex; } + void OnChange(); + + typedef void (*ChangeCallback)(const GfxPrefValue&); + void SetChangeCallback(ChangeCallback aCallback); + + virtual const char* Name() const = 0; + + // Returns true if the value is default, false if changed. + virtual bool HasDefaultValue() const = 0; + + // Returns the pref value as a discriminated union. + virtual void GetLiveValue(GfxPrefValue* aOutValue) const = 0; + + // Returns the pref value as a discriminated union. + virtual void GetCachedValue(GfxPrefValue* aOutValue) const = 0; + + // Change the cached value. GfxPrefValue must be a compatible type. + virtual void SetCachedValue(const GfxPrefValue& aOutValue) = 0; + + protected: + void FireChangeCallback(); + + private: + size_t mIndex; + ChangeCallback mChangeCallback; + }; + + static const nsTArray& all() { return *sGfxPrefList; } + + private: + // We split out a base class to reduce the number of virtual function + // instantiations that we do, which saves code size. + template + class TypedPref : public Pref { + public: + explicit TypedPref(T aValue) : mValue(aValue) {} + + void GetCachedValue(GfxPrefValue* aOutValue) const override { + CopyPrefValue(&mValue, aOutValue); + } + void SetCachedValue(const GfxPrefValue& aOutValue) override { + // This is only used in non-XPCOM processes. + MOZ_ASSERT(!IsPrefsServiceAvailable()); + + T newValue; + CopyPrefValue(&aOutValue, &newValue); + + if (mValue != newValue) { + mValue = newValue; + FireChangeCallback(); + } + } + + protected: + T GetLiveValueByName(const char* aPrefName) const { + if (IsPrefsServiceAvailable()) { + return PrefGet(aPrefName, mValue); + } + return mValue; + } + + public: + T mValue; + }; + + // Since we cannot use const char*, use a function that returns it. + template + class PrefTemplate final : public TypedPref { + typedef TypedPref BaseClass; + + public: + PrefTemplate() : BaseClass(Default()) { + // If not using the Preferences service, values are synced over IPC, so + // there's no need to register us as a Preferences observer. + if (IsPrefsServiceAvailable()) { + Register(Update, Prefname()); + } + // By default we only watch changes in the parent process, to communicate + // changes to the GPU process. + if (IsParentProcess() && Update == UpdatePolicy::Live) { + WatchChanges(Prefname(), this); + } + } + ~PrefTemplate() { + if (IsParentProcess() && Update == UpdatePolicy::Live) { + UnwatchChanges(Prefname(), this); + } + } + void Register(UpdatePolicy aUpdate, const char* aPreference) { + AssertMainThread(); + switch (aUpdate) { + case UpdatePolicy::Skip: + break; + case UpdatePolicy::Once: + this->mValue = PrefGet(aPreference, this->mValue); + break; + case UpdatePolicy::Live: { + nsCString pref; + pref.AssignLiteral(aPreference, strlen(aPreference)); + PrefAddVarCache(&this->mValue, pref, this->mValue); + } break; + default: + MOZ_CRASH("Incomplete switch"); + } + } + void Set(UpdatePolicy aUpdate, const char* aPref, T aValue) { + AssertMainThread(); + PrefSet(aPref, aValue); + switch (aUpdate) { + case UpdatePolicy::Skip: + case UpdatePolicy::Live: + break; + case UpdatePolicy::Once: + this->mValue = PrefGet(aPref, this->mValue); + break; + default: + MOZ_CRASH("Incomplete switch"); + } + } + const char* Name() const override { return Prefname(); } + void GetLiveValue(GfxPrefValue* aOutValue) const override { + T value = GetLiveValue(); + CopyPrefValue(&value, aOutValue); + } + // When using the Preferences service, the change callback can be triggered + // *before* our cached value is updated, so we expose a method to grab the + // true live value. + T GetLiveValue() const { return BaseClass::GetLiveValueByName(Prefname()); } + bool HasDefaultValue() const override { return this->mValue == Default(); } + }; + + // clang-format off + + // This is where DECL_GFX_PREF for each of the preferences should go. We + // will keep these in an alphabetical order to make it easier to see if a + // method accessing a pref already exists. Just add yours in the list. + + DECL_GFX_PREF(Live, "accessibility.browsewithcaret", AccessibilityBrowseWithCaret, bool, false); + + // The apz prefs are explained in AsyncPanZoomController.cpp + DECL_GFX_PREF(Live, "apz.allow_double_tap_zooming", APZAllowDoubleTapZooming, bool, true); + DECL_GFX_PREF(Live, "apz.allow_immediate_handoff", APZAllowImmediateHandoff, bool, true); + DECL_GFX_PREF(Live, "apz.allow_zooming", APZAllowZooming, bool, false); + DECL_GFX_PREF(Live, "apz.android.chrome_fling_physics.enabled", APZUseChromeFlingPhysics, bool, false); + DECL_GFX_PREF(Live, "apz.android.chrome_fling_physics.friction", APZChromeFlingPhysicsFriction, float, 0.015f); + DECL_GFX_PREF(Live, "apz.android.chrome_fling_physics.inflexion", APZChromeFlingPhysicsInflexion, float, 0.35f); + DECL_GFX_PREF(Live, "apz.android.chrome_fling_physics.stop_threshold", APZChromeFlingPhysicsStopThreshold, float, 0.1f); + DECL_GFX_PREF(Live, "apz.autoscroll.enabled", APZAutoscrollEnabled, bool, false); + DECL_GFX_PREF(Live, "apz.axis_lock.breakout_angle", APZAxisBreakoutAngle, float, float(M_PI / 8.0) /* 22.5 degrees */); + DECL_GFX_PREF(Live, "apz.axis_lock.breakout_threshold", APZAxisBreakoutThreshold, float, 1.0f / 32.0f); + DECL_GFX_PREF(Live, "apz.axis_lock.direct_pan_angle", APZAllowedDirectPanAngle, float, float(M_PI / 3.0) /* 60 degrees */); + DECL_GFX_PREF(Live, "apz.axis_lock.lock_angle", APZAxisLockAngle, float, float(M_PI / 6.0) /* 30 degrees */); + DECL_GFX_PREF(Live, "apz.axis_lock.mode", APZAxisLockMode, int32_t, 0); + DECL_GFX_PREF(Live, "apz.content_response_timeout", APZContentResponseTimeout, int32_t, 400); + DECL_GFX_PREF(Live, "apz.danger_zone_x", APZDangerZoneX, int32_t, 50); + DECL_GFX_PREF(Live, "apz.danger_zone_y", APZDangerZoneY, int32_t, 100); + DECL_GFX_PREF(Live, "apz.disable_for_scroll_linked_effects", APZDisableForScrollLinkedEffects, bool, false); + DECL_GFX_PREF(Live, "apz.displayport_expiry_ms", APZDisplayPortExpiryTime, uint32_t, 15000); + DECL_GFX_PREF(Live, "apz.drag.enabled", APZDragEnabled, bool, false); + DECL_GFX_PREF(Live, "apz.drag.initial.enabled", APZDragInitiationEnabled, bool, false); + DECL_GFX_PREF(Live, "apz.drag.touch.enabled", APZTouchDragEnabled, bool, false); + DECL_GFX_PREF(Live, "apz.enlarge_displayport_when_clipped", APZEnlargeDisplayPortWhenClipped, bool, false); + DECL_GFX_PREF(Live, "apz.fixed-margin-override.enabled", APZFixedMarginOverrideEnabled, bool, false); + DECL_GFX_PREF(Live, "apz.fixed-margin-override.bottom", APZFixedMarginOverrideBottom, int32_t, 0); + DECL_GFX_PREF(Live, "apz.fixed-margin-override.top", APZFixedMarginOverrideTop, int32_t, 0); + DECL_GFX_PREF(Live, "apz.fling_accel_base_mult", APZFlingAccelBaseMultiplier, float, 1.0f); + DECL_GFX_PREF(Live, "apz.fling_accel_interval_ms", APZFlingAccelInterval, int32_t, 500); + DECL_GFX_PREF(Live, "apz.fling_accel_supplemental_mult", APZFlingAccelSupplementalMultiplier, float, 1.0f); + DECL_GFX_PREF(Live, "apz.fling_accel_min_velocity", APZFlingAccelMinVelocity, float, 1.5f); + DECL_GFX_PREF(Once, "apz.fling_curve_function_x1", APZCurveFunctionX1, float, 0.0f); + DECL_GFX_PREF(Once, "apz.fling_curve_function_x2", APZCurveFunctionX2, float, 1.0f); + DECL_GFX_PREF(Once, "apz.fling_curve_function_y1", APZCurveFunctionY1, float, 0.0f); + DECL_GFX_PREF(Once, "apz.fling_curve_function_y2", APZCurveFunctionY2, float, 1.0f); + DECL_GFX_PREF(Live, "apz.fling_curve_threshold_inches_per_ms", APZCurveThreshold, float, -1.0f); + DECL_GFX_PREF(Live, "apz.fling_friction", APZFlingFriction, float, 0.002f); + DECL_GFX_PREF(Live, "apz.fling_min_velocity_threshold", APZFlingMinVelocityThreshold, float, 0.5f); + DECL_GFX_PREF(Live, "apz.fling_stop_on_tap_threshold", APZFlingStopOnTapThreshold, float, 0.05f); + DECL_GFX_PREF(Live, "apz.fling_stopped_threshold", APZFlingStoppedThreshold, float, 0.01f); + DECL_GFX_PREF(Live, "apz.frame_delay.enabled", APZFrameDelayEnabled, bool, false); + DECL_GFX_PREF(Once, "apz.keyboard.enabled", APZKeyboardEnabled, bool, false); + DECL_GFX_PREF(Live, "apz.keyboard.passive-listeners", APZKeyboardPassiveListeners, bool, false); + DECL_GFX_PREF(Live, "apz.max_tap_time", APZMaxTapTime, int32_t, 300); + DECL_GFX_PREF(Live, "apz.max_velocity_inches_per_ms", APZMaxVelocity, float, -1.0f); + DECL_GFX_PREF(Once, "apz.max_velocity_queue_size", APZMaxVelocityQueueSize, uint32_t, 5); + DECL_GFX_PREF(Live, "apz.min_skate_speed", APZMinSkateSpeed, float, 1.0f); + DECL_GFX_PREF(Live, "apz.minimap.enabled", APZMinimap, bool, false); + DECL_GFX_PREF(Live, "apz.one_touch_pinch.enabled", APZOneTouchPinchEnabled, bool, true); + DECL_GFX_PREF(Live, "apz.overscroll.enabled", APZOverscrollEnabled, bool, false); + DECL_GFX_PREF(Live, "apz.overscroll.min_pan_distance_ratio", APZMinPanDistanceRatio, float, 1.0f); + DECL_GFX_PREF(Live, "apz.overscroll.spring_stiffness", APZOverscrollSpringStiffness, float, 0.001f); + DECL_GFX_PREF(Live, "apz.overscroll.stop_distance_threshold", APZOverscrollStopDistanceThreshold, float, 5.0f); + DECL_GFX_PREF(Live, "apz.paint_skipping.enabled", APZPaintSkipping, bool, true); + DECL_GFX_PREF(Live, "apz.peek_messages.enabled", APZPeekMessages, bool, true); + DECL_GFX_PREF(Live, "apz.pinch_lock.mode", APZPinchLockMode, int32_t, 1); + DECL_GFX_PREF(Live, "apz.pinch_lock.scroll_lock_threshold", APZPinchLockScrollLockThreshold, float, 1.0f / 32.0f); + DECL_GFX_PREF(Live, "apz.pinch_lock.span_breakout_threshold", APZPinchLockSpanBreakoutThreshold, float, 1.0f / 32.0f); + DECL_GFX_PREF(Live, "apz.pinch_lock.span_lock_threshold", APZPinchLockSpanLockThreshold, float, 1.0f / 32.0f); + DECL_GFX_PREF(Once, "apz.pinch_lock.buffer_max_age", APZPinchLockBufferMaxAge, int32_t, 50); + DECL_GFX_PREF(Live, "apz.popups.enabled", APZPopupsEnabled, bool, false); + DECL_GFX_PREF(Live, "apz.printtree", APZPrintTree, bool, false); + DECL_GFX_PREF(Live, "apz.record_checkerboarding", APZRecordCheckerboarding, bool, false); + DECL_GFX_PREF(Live, "apz.second_tap_tolerance", APZSecondTapTolerance, float, 0.5f); + DECL_GFX_PREF(Live, "apz.test.fails_with_native_injection", APZTestFailsWithNativeInjection, bool, false); + DECL_GFX_PREF(Live, "apz.test.logging_enabled", APZTestLoggingEnabled, bool, false); + DECL_GFX_PREF(Live, "apz.touch_move_tolerance", APZTouchMoveTolerance, float, 0.1f); + DECL_GFX_PREF(Live, "apz.touch_start_tolerance", APZTouchStartTolerance, float, 1.0f/4.5f); + DECL_GFX_PREF(Live, "apz.velocity_bias", APZVelocityBias, float, 0.0f); + DECL_GFX_PREF(Live, "apz.velocity_relevance_time_ms", APZVelocityRelevanceTime, uint32_t, 150); + DECL_GFX_PREF(Live, "apz.x_skate_highmem_adjust", APZXSkateHighMemAdjust, float, 0.0f); + DECL_GFX_PREF(Live, "apz.x_skate_size_multiplier", APZXSkateSizeMultiplier, float, 1.5f); + DECL_GFX_PREF(Live, "apz.x_stationary_size_multiplier", APZXStationarySizeMultiplier, float, 3.0f); + DECL_GFX_PREF(Live, "apz.y_skate_highmem_adjust", APZYSkateHighMemAdjust, float, 0.0f); + DECL_GFX_PREF(Live, "apz.y_skate_size_multiplier", APZYSkateSizeMultiplier, float, 2.5f); + DECL_GFX_PREF(Live, "apz.y_stationary_size_multiplier", APZYStationarySizeMultiplier, float, 3.5f); + DECL_GFX_PREF(Live, "apz.zoom_animation_duration_ms", APZZoomAnimationDuration, int32_t, 250); + DECL_GFX_PREF(Live, "apz.scale_repaint_delay_ms", APZScaleRepaintDelay, int32_t, 500); + DECL_GFX_PREF(Live, "apz.relative-update.enabled", APZRelativeUpdate, bool, false); + + DECL_GFX_PREF(Live, "browser.ui.scroll-toolbar-threshold", ToolbarScrollThreshold, int32_t, 10); + DECL_GFX_PREF(Live, "browser.ui.zoom.force-user-scalable", ForceUserScalable, bool, false); + DECL_GFX_PREF(Live, "browser.viewport.desktopWidth", DesktopViewportWidth, int32_t, 980); + + DECL_GFX_PREF(Live, "dom.ipc.plugins.asyncdrawing.enabled", PluginAsyncDrawingEnabled, bool, false); + DECL_GFX_PREF(Live, "dom.meta-viewport.enabled", MetaViewportEnabled, bool, false); + DECL_GFX_PREF(Once, "dom.vr.enabled", VREnabled, bool, false); + DECL_GFX_PREF(Live, "dom.vr.autoactivate.enabled", VRAutoActivateEnabled, bool, false); + DECL_GFX_PREF(Live, "dom.vr.controller_trigger_threshold", VRControllerTriggerThreshold, float, 0.1f); + DECL_GFX_PREF(Once, "dom.vr.external.enabled", VRExternalEnabled, bool, false); + DECL_GFX_PREF(Live, "dom.vr.external.notdetected.timeout", VRExternalNotDetectedTimeout, int32_t, 60000); + DECL_GFX_PREF(Live, "dom.vr.external.quit.timeout", VRExternalQuitTimeout, int32_t, 10000); + DECL_GFX_PREF(Live, "dom.vr.navigation.timeout", VRNavigationTimeout, int32_t, 1000); + DECL_GFX_PREF(Once, "dom.vr.oculus.enabled", VROculusEnabled, bool, true); + DECL_GFX_PREF(Live, "dom.vr.oculus.invisible.enabled", VROculusInvisibleEnabled, bool, true); + DECL_GFX_PREF(Live, "dom.vr.oculus.present.timeout", VROculusPresentTimeout, int32_t, 500); + DECL_GFX_PREF(Live, "dom.vr.oculus.quit.timeout", VROculusQuitTimeout, int32_t, 10000); + DECL_GFX_PREF(Once, "dom.vr.openvr.enabled", VROpenVREnabled, bool, false); + DECL_GFX_PREF(Once, "dom.vr.openvr.action_input", VROpenVRActionInputEnabled, bool, true); + DECL_GFX_PREF(Once, "dom.vr.osvr.enabled", VROSVREnabled, bool, false); + DECL_GFX_PREF(Live, "dom.vr.controller.enumerate.interval", VRControllerEnumerateInterval, int32_t, 1000); + DECL_GFX_PREF(Live, "dom.vr.display.enumerate.interval", VRDisplayEnumerateInterval, int32_t, 5000); + DECL_GFX_PREF(Live, "dom.vr.inactive.timeout", VRInactiveTimeout, int32_t, 5000); + DECL_GFX_PREF(Live, "dom.vr.poseprediction.enabled", VRPosePredictionEnabled, bool, true); + DECL_GFX_PREF(Live, "dom.vr.require-gesture", VRRequireGesture, bool, true); + DECL_GFX_PREF(Live, "dom.vr.puppet.enabled", VRPuppetEnabled, bool, false); + DECL_GFX_PREF(Live, "dom.vr.puppet.submitframe", VRPuppetSubmitFrame, uint32_t, 0); + DECL_GFX_PREF(Live, "dom.vr.display.rafMaxDuration", VRDisplayRafMaxDuration, uint32_t, 50); + DECL_GFX_PREF(Once, "dom.vr.process.enabled", VRProcessEnabled, bool, false); + DECL_GFX_PREF(Once, "dom.vr.process.startup_timeout_ms", VRProcessTimeoutMs, int32_t, 5000); + DECL_GFX_PREF(Once, "dom.vr.service.enabled", VRServiceEnabled, bool, true); + DECL_GFX_PREF(Live, "dom.w3c_pointer_events.enabled", PointerEventsEnabled, bool, false); + + DECL_GFX_PREF(Live, "general.smoothScroll", SmoothScrollEnabled, bool, true); + DECL_GFX_PREF(Live, "general.smoothScroll.currentVelocityWeighting", + SmoothScrollCurrentVelocityWeighting, float, 0.25); + DECL_GFX_PREF(Live, "general.smoothScroll.durationToIntervalRatio", + SmoothScrollDurationToIntervalRatio, int32_t, 200); + DECL_GFX_PREF(Live, "general.smoothScroll.lines.durationMaxMS", + LineSmoothScrollMaxDurationMs, int32_t, 150); + DECL_GFX_PREF(Live, "general.smoothScroll.lines.durationMinMS", + LineSmoothScrollMinDurationMs, int32_t, 150); + DECL_GFX_PREF(Live, "general.smoothScroll.mouseWheel", WheelSmoothScrollEnabled, bool, true); + DECL_GFX_PREF(Live, "general.smoothScroll.mouseWheel.durationMaxMS", + WheelSmoothScrollMaxDurationMs, int32_t, 400); + DECL_GFX_PREF(Live, "general.smoothScroll.mouseWheel.durationMinMS", + WheelSmoothScrollMinDurationMs, int32_t, 200); + DECL_GFX_PREF(Live, "general.smoothScroll.other.durationMaxMS", + OtherSmoothScrollMaxDurationMs, int32_t, 150); + DECL_GFX_PREF(Live, "general.smoothScroll.other.durationMinMS", + OtherSmoothScrollMinDurationMs, int32_t, 150); + DECL_GFX_PREF(Live, "general.smoothScroll.pages", PageSmoothScrollEnabled, bool, true); + DECL_GFX_PREF(Live, "general.smoothScroll.pages.durationMaxMS", + PageSmoothScrollMaxDurationMs, int32_t, 150); + DECL_GFX_PREF(Live, "general.smoothScroll.pages.durationMinMS", + PageSmoothScrollMinDurationMs, int32_t, 150); + DECL_GFX_PREF(Live, "general.smoothScroll.pixels.durationMaxMS", + PixelSmoothScrollMaxDurationMs, int32_t, 150); + DECL_GFX_PREF(Live, "general.smoothScroll.pixels.durationMinMS", + PixelSmoothScrollMinDurationMs, int32_t, 150); + DECL_GFX_PREF(Live, "general.smoothScroll.stopDecelerationWeighting", + SmoothScrollStopDecelerationWeighting, float, 0.4f); + + DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.enabled", + SmoothScrollMSDPhysicsEnabled, bool, false); + DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.continuousMotionMaxDeltaMS", + SmoothScrollMSDPhysicsContinuousMotionMaxDeltaMS, int32_t, 120); + DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.motionBeginSpringConstant", + SmoothScrollMSDPhysicsMotionBeginSpringConstant, int32_t, 1250); + DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.slowdownMinDeltaMS", + SmoothScrollMSDPhysicsSlowdownMinDeltaMS, int32_t, 12); + DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.slowdownMinDeltaRatio", + SmoothScrollMSDPhysicsSlowdownMinDeltaRatio, float, 1.3f); + DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.slowdownSpringConstant", + SmoothScrollMSDPhysicsSlowdownSpringConstant, int32_t, 2000); + DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.regularSpringConstant", + SmoothScrollMSDPhysicsRegularSpringConstant, int32_t, 1000); + + DECL_GFX_PREF(Once, "gfx.android.rgb16.force", AndroidRGB16Force, bool, false); + DECL_GFX_PREF(Once, "gfx.apitrace.enabled", UseApitrace, bool, false); +#if defined(RELEASE_OR_BETA) + // "Skip" means this is locked to the default value in beta and release. + DECL_GFX_PREF(Skip, "gfx.blocklist.all", BlocklistAll, int32_t, 0); +#else + DECL_GFX_PREF(Once, "gfx.blocklist.all", BlocklistAll, int32_t, 0); +#endif +#if defined(MOZ_WIDGET_ANDROID) + // Overrides the glClear color used when the surface origin is not (0, 0) + // Used for drawing a border around the content. + DECL_GFX_PREF(Live, "gfx.compositor.override.clear-color.r", CompositorOverrideClearColorR, float, 0.0f); + DECL_GFX_PREF(Live, "gfx.compositor.override.clear-color.g", CompositorOverrideClearColorG, float, 0.0f); + DECL_GFX_PREF(Live, "gfx.compositor.override.clear-color.b", CompositorOverrideClearColorB, float, 0.0f); + DECL_GFX_PREF(Live, "gfx.compositor.override.clear-color.a", CompositorOverrideClearColorA, float, 0.0f); +#endif // defined(MOZ_WIDGET_ANDROID) + DECL_GFX_PREF(Live, "gfx.compositor.clearstate", CompositorClearState, bool, false); + DECL_GFX_PREF(Live, "gfx.compositor.glcontext.opaque", CompositorGLContextOpaque, bool, false); + // 0x7fff is the maximum supported xlib surface size and is more than enough for canvases. + DECL_GFX_PREF(Live, "gfx.canvas.max-size", MaxCanvasSize, int32_t, 0x7fff); + + DECL_GFX_PREF(Live, "gfx.color_management.enablev4", CMSEnableV4, bool, false); + DECL_GFX_PREF(Live, "gfx.color_management.mode", CMSMode, int32_t,-1); + // The zero default here should match QCMS_INTENT_DEFAULT from qcms.h + DECL_GFX_PREF(Live, "gfx.color_management.rendering_intent", CMSRenderingIntent, int32_t, 0); + DECL_GFX_PREF(Live, "gfx.content.always-paint", AlwaysPaint, bool, false); + // Size in megabytes + DECL_GFX_PREF(Once, "gfx.content.skia-font-cache-size", SkiaContentFontCacheSize, int32_t, 5); + + DECL_GFX_PREF(Once, "gfx.device-reset.limit", DeviceResetLimitCount, int32_t, 10); + DECL_GFX_PREF(Once, "gfx.device-reset.threshold-ms", DeviceResetThresholdMilliseconds, int32_t, -1); + + DECL_GFX_PREF(Once, "gfx.direct2d.disabled", Direct2DDisabled, bool, false); + DECL_GFX_PREF(Once, "gfx.direct2d.force-enabled", Direct2DForceEnabled, bool, false); + DECL_GFX_PREF(Live, "gfx.direct2d.destroy-dt-on-paintthread",Direct2DDestroyDTOnPaintThread, bool, true); + DECL_GFX_PREF(Live, "gfx.direct3d11.reuse-decoder-device", Direct3D11ReuseDecoderDevice, int32_t, -1); + DECL_GFX_PREF(Live, "gfx.direct3d11.allow-keyed-mutex", Direct3D11AllowKeyedMutex, bool, true); + DECL_GFX_PREF(Live, "gfx.direct3d11.use-double-buffering", Direct3D11UseDoubleBuffering, bool, false); + DECL_GFX_PREF(Once, "gfx.direct3d11.enable-debug-layer", Direct3D11EnableDebugLayer, bool, false); + DECL_GFX_PREF(Once, "gfx.direct3d11.break-on-error", Direct3D11BreakOnError, bool, false); + DECL_GFX_PREF(Once, "gfx.direct3d11.sleep-on-create-device", Direct3D11SleepOnCreateDevice, int32_t, 0); + DECL_GFX_PREF(Live, "gfx.downloadable_fonts.keep_color_bitmaps", KeepColorBitmaps, bool, false); + DECL_GFX_PREF(Live, "gfx.downloadable_fonts.validate_variation_tables", ValidateVariationTables, bool, true); + DECL_GFX_PREF(Live, "gfx.downloadable_fonts.otl_validation", ValidateOTLTables, bool, true); + DECL_GFX_PREF(Live, "gfx.draw-color-bars", CompositorDrawColorBars, bool, false); + DECL_GFX_PREF(Once, "gfx.e10s.hide-plugins-for-scroll", HidePluginsForScroll, bool, true); + DECL_GFX_PREF(Once, "gfx.e10s.font-list.shared", SharedFontList, bool, false); +#if defined(XP_MACOSX) + DECL_GFX_PREF(Live, "gfx.font_rendering.coretext.enabled", CoreTextEnabled, bool, false); +#endif + DECL_GFX_PREF(Live, "gfx.layerscope.enabled", LayerScopeEnabled, bool, false); + DECL_GFX_PREF(Live, "gfx.layerscope.port", LayerScopePort, int32_t, 23456); + // Note that "gfx.logging.level" is defined in Logging.h. + DECL_GFX_PREF(Live, "gfx.logging.level", GfxLoggingLevel, int32_t, mozilla::gfx::LOG_DEFAULT); + DECL_GFX_PREF(Once, "gfx.logging.crash.length", GfxLoggingCrashLength, uint32_t, 16); + DECL_GFX_PREF(Live, "gfx.logging.painted-pixel-count.enabled",GfxLoggingPaintedPixelCountEnabled, bool, false); + // The maximums here are quite conservative, we can tighten them if problems show up. + DECL_GFX_PREF(Once, "gfx.logging.texture-usage.enabled", GfxLoggingTextureUsageEnabled, bool, false); + DECL_GFX_PREF(Once, "gfx.logging.peak-texture-usage.enabled",GfxLoggingPeakTextureUsageEnabled, bool, false); + DECL_GFX_PREF(Once, "gfx.logging.slow-frames.enabled", LoggingSlowFramesEnabled, bool, false); + // Use gfxPlatform::MaxAllocSize instead of the pref directly + DECL_GFX_PREF(Once, "gfx.max-alloc-size", MaxAllocSizeDoNotUseDirectly, int32_t, (int32_t)500000000); + // Use gfxPlatform::MaxTextureSize instead of the pref directly + DECL_GFX_PREF(Once, "gfx.max-texture-size", MaxTextureSizeDoNotUseDirectly, int32_t, (int32_t)32767); + DECL_GFX_PREF(Live, "gfx.partialpresent.force", PartialPresent, int32_t, 0); + DECL_GFX_PREF(Live, "gfx.perf-warnings.enabled", PerfWarnings, bool, false); + DECL_GFX_PREF(Live, "gfx.testing.device-reset", DeviceResetForTesting, int32_t, 0); + DECL_GFX_PREF(Live, "gfx.testing.device-fail", DeviceFailForTesting, bool, false); + DECL_GFX_PREF(Once, "gfx.text.disable-aa", DisableAllTextAA, bool, false); + DECL_GFX_PREF(Live, "gfx.ycbcr.accurate-conversion", YCbCrAccurateConversion, bool, false); + + // Disable surface sharing due to issues with compatible FBConfigs on + // NVIDIA drivers as described in bug 1193015. + DECL_GFX_PREF(Live, "gfx.use-glx-texture-from-pixmap", UseGLXTextureFromPixmap, bool, false); + DECL_GFX_PREF(Once, "gfx.use-iosurface-textures", UseIOSurfaceTextures, bool, false); + DECL_GFX_PREF(Once, "gfx.use-mutex-on-present", UseMutexOnPresent, bool, false); + DECL_GFX_PREF(Once, "gfx.use-surfacetexture-textures", UseSurfaceTextureTextures, bool, false); + DECL_GFX_PREF(Once, "gfx.allow-texture-direct-mapping", AllowTextureDirectMapping, bool, true); + DECL_GFX_PREF(Live, "gfx.vsync.collect-scroll-transforms", CollectScrollTransforms, bool, false); + DECL_GFX_PREF(Once, "gfx.vsync.compositor.unobserve-count", CompositorUnobserveCount, int32_t, 10); + + DECL_GFX_PREF(Once, "gfx.webrender.all", WebRenderAll, bool, false); + DECL_GFX_PREF(Once, "gfx.webrender.all.qualified", WebRenderAllQualified, bool, true); + DECL_GFX_PREF(Once, + "gfx.webrender.all.qualified.default", + WebRenderAllQualifiedDefault, + bool, + false); + DECL_GFX_PREF(Live, "gfx.webrender.blob-images", WebRenderBlobImages, bool, true); + DECL_GFX_PREF(Live, "gfx.webrender.blob.invalidation", WebRenderBlobInvalidation, bool, false); + DECL_GFX_PREF(Live, "gfx.webrender.blob.paint-flashing", WebRenderBlobPaintFlashing, bool, false); + DECL_GFX_PREF(Live, "gfx.webrender.dl.dump-parent", WebRenderDLDumpParent, bool, false); + DECL_GFX_PREF(Live, "gfx.webrender.dl.dump-content", WebRenderDLDumpContent, bool, false); + DECL_GFX_PREF(Once, "gfx.webrender.enabled", WebRenderEnabledDoNotUseDirectly, bool, false); + DECL_GFX_PREF(Once, "gfx.webrender.force-disabled", WebRenderForceDisabled, bool, false); + DECL_GFX_PREF(Live, "gfx.webrender.highlight-painted-layers",WebRenderHighlightPaintedLayers, bool, false); + DECL_GFX_PREF(Live, "gfx.webrender.late-scenebuild-threshold", WebRenderLateSceneBuildThreshold, int32_t, 4); + DECL_GFX_PREF(Live, "gfx.webrender.max-filter-ops-per-chain", WebRenderMaxFilterOpsPerChain, uint32_t, 64); + DECL_GFX_PREF(Live, "gfx.webrender.picture-caching", WebRenderPictureCaching, bool, false); + DECL_GFX_PREF(Once, "gfx.webrender.split-render-roots", WebRenderSplitRenderRoots, bool, false); + DECL_GFX_PREF(Live, "gfx.webrender.start-debug-server", WebRenderStartDebugServer, bool, false); + + // Use vsync events generated by hardware + DECL_GFX_PREF(Once, "gfx.work-around-driver-bugs", WorkAroundDriverBugs, bool, true); + + DECL_GFX_PREF(Live, "gl.allow-high-power", GLAllowHighPower, bool, true); + DECL_GFX_PREF(Live, "gl.ignore-dx-interop2-blacklist", IgnoreDXInterop2Blacklist, bool, false); + DECL_GFX_PREF(Live, "gl.msaa-level", MSAALevel, uint32_t, 2); +#if defined(XP_MACOSX) + DECL_GFX_PREF(Live, "gl.multithreaded", GLMultithreaded, bool, false); +#endif + DECL_GFX_PREF(Live, "gl.require-hardware", RequireHardwareGL, bool, false); + DECL_GFX_PREF(Live, "gl.use-tls-is-current", UseTLSIsCurrent, int32_t, 0); + + DECL_GFX_PREF(Live, "image.animated.decode-on-demand.threshold-kb", ImageAnimatedDecodeOnDemandThresholdKB, uint32_t, 20480); + DECL_GFX_PREF(Live, "image.animated.decode-on-demand.batch-size", ImageAnimatedDecodeOnDemandBatchSize, uint32_t, 6); + DECL_GFX_PREF(Live, "image.animated.decode-on-demand.recycle", ImageAnimatedDecodeOnDemandRecycle, bool, false); + DECL_GFX_PREF(Live, "image.animated.resume-from-last-displayed", ImageAnimatedResumeFromLastDisplayed, bool, false); + DECL_GFX_PREF(Live, "image.cache.factor2.threshold-surfaces", ImageCacheFactor2ThresholdSurfaces, int32_t, -1); + DECL_GFX_PREF(Live, "image.cache.max-rasterized-svg-threshold-kb", ImageCacheMaxRasterizedSVGThresholdKB, int32_t, 90*1024); + DECL_GFX_PREF(Once, "image.cache.size", ImageCacheSize, int32_t, 5*1024*1024); + DECL_GFX_PREF(Once, "image.cache.timeweight", ImageCacheTimeWeight, int32_t, 500); + DECL_GFX_PREF(Live, "image.decode-immediately.enabled", ImageDecodeImmediatelyEnabled, bool, false); + DECL_GFX_PREF(Live, "image.downscale-during-decode.enabled", ImageDownscaleDuringDecodeEnabled, bool, true); + DECL_GFX_PREF(Live, "image.infer-src-animation.threshold-ms", ImageInferSrcAnimationThresholdMS, uint32_t, 2000); + DECL_GFX_PREF(Live, "image.layout_network_priority", ImageLayoutNetworkPriority, bool, true); + DECL_GFX_PREF(Once, "image.mem.decode_bytes_at_a_time", ImageMemDecodeBytesAtATime, uint32_t, 200000); + DECL_GFX_PREF(Live, "image.mem.discardable", ImageMemDiscardable, bool, false); + DECL_GFX_PREF(Once, "image.mem.animated.discardable", ImageMemAnimatedDiscardable, bool, false); + DECL_GFX_PREF(Live, "image.mem.animated.use_heap", ImageMemAnimatedUseHeap, bool, false); + DECL_GFX_PREF(Live, "image.mem.debug-reporting", ImageMemDebugReporting, bool, false); + DECL_GFX_PREF(Live, "image.mem.shared", ImageMemShared, bool, true); + DECL_GFX_PREF(Once, "image.mem.surfacecache.discard_factor", ImageMemSurfaceCacheDiscardFactor, uint32_t, 1); + DECL_GFX_PREF(Once, "image.mem.surfacecache.max_size_kb", ImageMemSurfaceCacheMaxSizeKB, uint32_t, 100 * 1024); + DECL_GFX_PREF(Once, "image.mem.surfacecache.min_expiration_ms", ImageMemSurfaceCacheMinExpirationMS, uint32_t, 60*1000); + DECL_GFX_PREF(Once, "image.mem.surfacecache.size_factor", ImageMemSurfaceCacheSizeFactor, uint32_t, 64); + DECL_GFX_PREF(Live, "image.mem.volatile.min_threshold_kb", ImageMemVolatileMinThresholdKB, int32_t, -1); + DECL_GFX_PREF(Once, "image.multithreaded_decoding.limit", ImageMTDecodingLimit, int32_t, -1); + DECL_GFX_PREF(Once, "image.multithreaded_decoding.idle_timeout", ImageMTDecodingIdleTimeout, int32_t, -1); + DECL_GFX_PREF(Live, "image.webp.enabled", ImageWebPEnabled, bool, false); + + DECL_GFX_PREF(Once, "layers.acceleration.disabled", LayersAccelerationDisabledDoNotUseDirectly, bool, false); + // Instead, use gfxConfig::IsEnabled(Feature::HW_COMPOSITING). + + DECL_GFX_PREF(Live, "layers.acceleration.draw-fps", LayersDrawFPS, bool, false); + DECL_GFX_PREF(Live, "layers.acceleration.draw-fps.print-histogram", FPSPrintHistogram, bool, false); + DECL_GFX_PREF(Live, "layers.acceleration.draw-fps.write-to-file", WriteFPSToFile, bool, false); + DECL_GFX_PREF(Once, "layers.acceleration.force-enabled", LayersAccelerationForceEnabledDoNotUseDirectly, bool, false); + DECL_GFX_PREF(Live, "layers.advanced.basic-layer.enabled", LayersAdvancedBasicLayerEnabled, bool, false); + DECL_GFX_PREF(Once, "layers.amd-switchable-gfx.enabled", LayersAMDSwitchableGfxEnabled, bool, false); + DECL_GFX_PREF(Once, "layers.async-pan-zoom.enabled", AsyncPanZoomEnabledDoNotUseDirectly, bool, true); + DECL_GFX_PREF(Live, "layers.bench.enabled", LayersBenchEnabled, bool, false); + DECL_GFX_PREF(Once, "layers.bufferrotation.enabled", BufferRotationEnabled, bool, true); + DECL_GFX_PREF(Live, "layers.child-process-shutdown", ChildProcessShutdown, bool, true); +#ifdef MOZ_GFX_OPTIMIZE_MOBILE + // If MOZ_GFX_OPTIMIZE_MOBILE is defined, we force component alpha off + // and ignore the preference. + DECL_GFX_PREF(Skip, "layers.componentalpha.enabled", ComponentAlphaEnabled, bool, false); +#else + // If MOZ_GFX_OPTIMIZE_MOBILE is not defined, we actually take the + // preference value, defaulting to true. + DECL_GFX_PREF(Once, "layers.componentalpha.enabled", ComponentAlphaEnabled, bool, true); +#endif + DECL_GFX_PREF(Once, "layers.d3d11.force-warp", LayersD3D11ForceWARP, bool, false); + DECL_GFX_PREF(Live, "layers.deaa.enabled", LayersDEAAEnabled, bool, false); + DECL_GFX_PREF(Live, "layers.draw-bigimage-borders", DrawBigImageBorders, bool, false); + DECL_GFX_PREF(Live, "layers.draw-borders", DrawLayerBorders, bool, false); + DECL_GFX_PREF(Live, "layers.draw-tile-borders", DrawTileBorders, bool, false); + DECL_GFX_PREF(Live, "layers.draw-layer-info", DrawLayerInfo, bool, false); + DECL_GFX_PREF(Live, "layers.dump", LayersDump, bool, false); + DECL_GFX_PREF(Live, "layers.dump-texture", LayersDumpTexture, bool, false); +#ifdef MOZ_DUMP_PAINTING + DECL_GFX_PREF(Live, "layers.dump-client-layers", DumpClientLayers, bool, false); + DECL_GFX_PREF(Live, "layers.dump-decision", LayersDumpDecision, bool, false); + DECL_GFX_PREF(Live, "layers.dump-host-layers", DumpHostLayers, bool, false); +#endif + + // 0 is "no change" for contrast, positive values increase it, negative values + // decrease it until we hit mid gray at -1 contrast, after that it gets weird. + DECL_GFX_PREF(Live, "layers.effect.contrast", LayersEffectContrast, float, 0.0f); + DECL_GFX_PREF(Live, "layers.effect.grayscale", LayersEffectGrayscale, bool, false); + DECL_GFX_PREF(Live, "layers.effect.invert", LayersEffectInvert, bool, false); + DECL_GFX_PREF(Once, "layers.enable-tiles", LayersTilesEnabled, bool, false); + DECL_GFX_PREF(Once, "layers.enable-tiles-if-skia-pomtp", LayersTilesEnabledIfSkiaPOMTP, bool, false); + DECL_GFX_PREF(Live, "layers.flash-borders", FlashLayerBorders, bool, false); + DECL_GFX_PREF(Once, "layers.force-shmem-tiles", ForceShmemTiles, bool, false); + DECL_GFX_PREF(Once, "layers.gpu-process.allow-software", GPUProcessAllowSoftware, bool, false); + DECL_GFX_PREF(Once, "layers.gpu-process.enabled", GPUProcessEnabled, bool, false); + DECL_GFX_PREF(Once, "layers.gpu-process.force-enabled", GPUProcessForceEnabled, bool, false); + DECL_GFX_PREF(Once, "layers.gpu-process.ipc_reply_timeout_ms", GPUProcessIPCReplyTimeoutMs, int32_t, 10000); + DECL_GFX_PREF(Live, "layers.gpu-process.max_restarts", GPUProcessMaxRestarts, int32_t, 1); + // Note: This pref will only be used if it is less than layers.gpu-process.max_restarts. + DECL_GFX_PREF(Live, "layers.gpu-process.max_restarts_with_decoder", GPUProcessMaxRestartsWithDecoder, int32_t, 0); + DECL_GFX_PREF(Once, "layers.gpu-process.startup_timeout_ms", GPUProcessTimeoutMs, int32_t, 5000); + DECL_GFX_PREF(Live, "layers.low-precision-buffer", UseLowPrecisionBuffer, bool, false); + DECL_GFX_PREF(Live, "layers.low-precision-opacity", LowPrecisionOpacity, float, 1.0f); + DECL_GFX_PREF(Live, "layers.low-precision-resolution", LowPrecisionResolution, float, 0.25f); + DECL_GFX_PREF(Live, "layers.max-active", MaxActiveLayers, int32_t, -1); + DECL_GFX_PREF(Once, "layers.mlgpu.enabled", AdvancedLayersEnabledDoNotUseDirectly, bool, false); + DECL_GFX_PREF(Once, "layers.mlgpu.enable-buffer-cache", AdvancedLayersEnableBufferCache, bool, true); + DECL_GFX_PREF(Once, "layers.mlgpu.enable-buffer-sharing", AdvancedLayersEnableBufferSharing, bool, true); + DECL_GFX_PREF(Once, "layers.mlgpu.enable-clear-view", AdvancedLayersEnableClearView, bool, true); + DECL_GFX_PREF(Once, "layers.mlgpu.enable-cpu-occlusion", AdvancedLayersEnableCPUOcclusion, bool, true); + DECL_GFX_PREF(Once, "layers.mlgpu.enable-depth-buffer", AdvancedLayersEnableDepthBuffer, bool, false); + DECL_GFX_PREF(Live, "layers.mlgpu.enable-invalidation", AdvancedLayersUseInvalidation, bool, true); + DECL_GFX_PREF(Once, "layers.mlgpu.enable-on-windows7", AdvancedLayersEnableOnWindows7, bool, false); + DECL_GFX_PREF(Once, "layers.mlgpu.enable-container-resizing", AdvancedLayersEnableContainerResizing, bool, true); + DECL_GFX_PREF(Once, "layers.offmainthreadcomposition.force-disabled", LayersOffMainThreadCompositionForceDisabled, bool, false); + DECL_GFX_PREF(Live, "layers.offmainthreadcomposition.frame-rate", LayersCompositionFrameRate, int32_t,-1); + DECL_GFX_PREF(Once, "layers.omtp.capture-limit", LayersOMTPCaptureLimit, uint32_t, 25 * 1024 * 1024); + DECL_GFX_PREF(Live, "layers.omtp.dump-capture", LayersOMTPDumpCapture, bool, false); + DECL_GFX_PREF(Once, "layers.omtp.paint-workers", LayersOMTPPaintWorkers, int32_t, 1); + DECL_GFX_PREF(Live, "layers.omtp.release-capture-on-main-thread", LayersOMTPReleaseCaptureOnMainThread, bool, false); + DECL_GFX_PREF(Live, "layers.orientation.sync.timeout", OrientationSyncMillis, uint32_t, (uint32_t)0); + DECL_GFX_PREF(Once, "layers.prefer-opengl", LayersPreferOpenGL, bool, false); + DECL_GFX_PREF(Live, "layers.progressive-paint", ProgressivePaint, bool, false); + DECL_GFX_PREF(Live, "layers.shared-buffer-provider.enabled", PersistentBufferProviderSharedEnabled, bool, false); + DECL_GFX_PREF(Live, "layers.single-tile.enabled", LayersSingleTileEnabled, bool, true); + DECL_GFX_PREF(Live, "layers.force-synchronous-resize", LayersForceSynchronousResize, bool, true); + DECL_GFX_PREF(Once, "layers.windowrecording.path", LayersWindowRecordingPath, std::string, std::string()); + + // We allow for configurable and rectangular tile size to avoid wasting memory on devices whose + // screen size does not align nicely to the default tile size. Although layers can be any size, + // they are often the same size as the screen, especially for width. + DECL_GFX_PREF(Once, "layers.tile-width", LayersTileWidth, int32_t, 256); + DECL_GFX_PREF(Once, "layers.tile-height", LayersTileHeight, int32_t, 256); + DECL_GFX_PREF(Once, "layers.tile-initial-pool-size", LayersTileInitialPoolSize, uint32_t, (uint32_t)50); + DECL_GFX_PREF(Once, "layers.tile-pool-unused-size", LayersTilePoolUnusedSize, uint32_t, (uint32_t)10); + DECL_GFX_PREF(Once, "layers.tile-pool-shrink-timeout", LayersTilePoolShrinkTimeout, uint32_t, (uint32_t)50); + DECL_GFX_PREF(Once, "layers.tile-pool-clear-timeout", LayersTilePoolClearTimeout, uint32_t, (uint32_t)5000); + DECL_GFX_PREF(Once, "layers.tiles.adjust", LayersTilesAdjust, bool, true); + DECL_GFX_PREF(Live, "layers.tiles.retain-back-buffer", LayersTileRetainBackBuffer, bool, true); + DECL_GFX_PREF(Once, "layers.tiles.edge-padding", TileEdgePaddingEnabled, bool, false); + DECL_GFX_PREF(Live, "layers.tiles.fade-in.enabled", LayerTileFadeInEnabled, bool, false); + DECL_GFX_PREF(Live, "layers.tiles.fade-in.duration-ms", LayerTileFadeInDuration, uint32_t, 250); + DECL_GFX_PREF(Live, "layers.transaction.warning-ms", LayerTransactionWarning, uint32_t, 200); + DECL_GFX_PREF(Once, "layers.uniformity-info", UniformityInfo, bool, false); + DECL_GFX_PREF(Once, "layers.use-image-offscreen-surfaces", UseImageOffscreenSurfaces, bool, true); + DECL_GFX_PREF(Live, "layers.draw-mask-debug", DrawMaskLayer, bool, false); + + DECL_GFX_PREF(Live, "layers.geometry.opengl.enabled", OGLLayerGeometry, bool, false); + DECL_GFX_PREF(Live, "layers.geometry.basic.enabled", BasicLayerGeometry, bool, false); + DECL_GFX_PREF(Live, "layers.geometry.d3d11.enabled", D3D11LayerGeometry, bool, false); + + DECL_GFX_PREF(Live, "layout.animation.prerender.partial", PartiallyPrerenderAnimatedContent, bool, false); + DECL_GFX_PREF(Live, "layout.animation.prerender.viewport-ratio-limit-x", AnimationPrerenderViewportRatioLimitX, float, 1.125f); + DECL_GFX_PREF(Live, "layout.animation.prerender.viewport-ratio-limit-y", AnimationPrerenderViewportRatioLimitY, float, 1.125f); + DECL_GFX_PREF(Live, "layout.animation.prerender.absolute-limit-x", AnimationPrerenderAbsoluteLimitX, uint32_t, 4096); + DECL_GFX_PREF(Live, "layout.animation.prerender.absolute-limit-y", AnimationPrerenderAbsoluteLimitY, uint32_t, 4096); + + DECL_GFX_PREF(Live, "layout.css.paint-order.enabled", PaintOrderEnabled, bool, false); + DECL_GFX_PREF(Live, "layout.css.scroll-behavior.damping-ratio", ScrollBehaviorDampingRatio, float, 1.0f); + DECL_GFX_PREF(Live, "layout.css.scroll-behavior.enabled", ScrollBehaviorEnabled, bool, true); + DECL_GFX_PREF(Live, "layout.css.scroll-behavior.spring-constant", ScrollBehaviorSpringConstant, float, 250.0f); + DECL_GFX_PREF(Live, "layout.css.scroll-snap.prediction-max-velocity", ScrollSnapPredictionMaxVelocity, int32_t, 2000); + DECL_GFX_PREF(Live, "layout.css.scroll-snap.prediction-sensitivity", ScrollSnapPredictionSensitivity, float, 0.750f); + DECL_GFX_PREF(Live, "layout.css.scroll-snap.proximity-threshold", ScrollSnapProximityThreshold, int32_t, 200); + DECL_GFX_PREF(Live, "layout.css.touch_action.enabled", TouchActionEnabled, bool, false); + + DECL_GFX_PREF(Live, "layout.display-list.build-twice", LayoutDisplayListBuildTwice, bool, false); + DECL_GFX_PREF(Live, "layout.display-list.retain", LayoutRetainDisplayList, bool, true); + DECL_GFX_PREF(Live, "layout.display-list.retain.chrome", LayoutRetainDisplayListChrome, bool, false); + DECL_GFX_PREF(Live, "layout.display-list.retain.verify", LayoutVerifyRetainDisplayList, bool, false); + DECL_GFX_PREF(Live, "layout.display-list.retain.verify.order", LayoutVerifyRetainDisplayListOrder, bool, false); + DECL_GFX_PREF(Live, "layout.display-list.rebuild-frame-limit", LayoutRebuildFrameLimit, uint32_t, 500); + DECL_GFX_PREF(Live, "layout.display-list.dump", LayoutDumpDisplayList, bool, false); + DECL_GFX_PREF(Live, "layout.display-list.dump-content", LayoutDumpDisplayListContent, bool, false); + DECL_GFX_PREF(Live, "layout.display-list.dump-parent", LayoutDumpDisplayListParent, bool, false); + DECL_GFX_PREF(Live, "layout.display-list.show-rebuild-area", LayoutDisplayListShowArea, bool, false); + DECL_GFX_PREF(Live, "layout.display-list.flatten-transform", LayoutFlattenTransform, bool, true); + + DECL_GFX_PREF(Live, "layout.frame_rate", LayoutFrameRate, int32_t, -1); + DECL_GFX_PREF(Live, "layout.min-active-layer-size", LayoutMinActiveLayerSize, int, 64); + DECL_GFX_PREF(Once, "layout.paint_rects_separately", LayoutPaintRectsSeparately, bool, true); + + // This and code dependent on it should be removed once containerless scrolling looks stable. + DECL_GFX_PREF(Live, "layout.scroll.root-frame-containers", LayoutUseContainersForRootFrames, bool, false); + // This pref is to be set by test code only. + DECL_GFX_PREF(Live, "layout.scrollbars.always-layerize-track", AlwaysLayerizeScrollbarTrackTestOnly, bool, false); + DECL_GFX_PREF(Live, "layout.smaller-painted-layers", LayoutSmallerPaintedLayers, bool, false); + + DECL_GFX_PREF(Once, "media.hardware-video-decoding.force-enabled", + HardwareVideoDecodingForceEnabled, bool, false); +#ifdef XP_WIN + DECL_GFX_PREF(Live, "media.wmf.dxva.d3d11.enabled", PDMWMFAllowD3D11, bool, true); + DECL_GFX_PREF(Live, "media.wmf.dxva.max-videos", PDMWMFMaxDXVAVideos, uint32_t, 8); + DECL_GFX_PREF(Live, "media.wmf.use-nv12-format", PDMWMFUseNV12Format, bool, true); + DECL_GFX_PREF(Live, "media.wmf.force.allow-p010-format", PDMWMFForceAllowP010Format, bool, false); + DECL_GFX_PREF(Once, "media.wmf.use-sync-texture", PDMWMFUseSyncTexture, bool, true); + DECL_GFX_PREF(Live, "media.wmf.low-latency.enabled", PDMWMFLowLatencyEnabled, bool, false); + DECL_GFX_PREF(Live, "media.wmf.low-latency.force-disabled", PDMWMFLowLatencyForceDisabled, bool, false); + DECL_GFX_PREF(Live, "media.wmf.skip-blacklist", PDMWMFSkipBlacklist, bool, false); + DECL_GFX_PREF(Live, "media.wmf.deblacklisting-for-telemetry-in-gpu-process", PDMWMFDeblacklistingForTelemetryInGPUProcess, bool, false); + DECL_GFX_PREF(Live, "media.wmf.amd.highres.enabled", PDMWMFAMDHighResEnabled, bool, true); + DECL_GFX_PREF(Live, "media.wmf.allow-unsupported-resolutions", PDMWMFAllowUnsupportedResolutions, bool, false); + DECL_GFX_PREF(Once, "media.wmf.vp9.enabled", MediaWmfVp9Enabled, bool, true); +#endif + + // These affect how line scrolls from wheel events will be accelerated. + DECL_GFX_PREF(Live, "mousewheel.acceleration.factor", MouseWheelAccelerationFactor, int32_t, -1); + DECL_GFX_PREF(Live, "mousewheel.acceleration.start", MouseWheelAccelerationStart, int32_t, -1); + + // This affects whether events will be routed through APZ or not. + DECL_GFX_PREF(Live, "mousewheel.system_scroll_override_on_root_content.enabled", + MouseWheelHasRootScrollDeltaOverride, bool, false); + DECL_GFX_PREF(Live, "mousewheel.system_scroll_override_on_root_content.horizontal.factor", + MouseWheelRootScrollHorizontalFactor, int32_t, 0); + DECL_GFX_PREF(Live, "mousewheel.system_scroll_override_on_root_content.vertical.factor", + MouseWheelRootScrollVerticalFactor, int32_t, 0); + DECL_GFX_PREF(Live, "mousewheel.transaction.ignoremovedelay",MouseWheelIgnoreMoveDelayMs, int32_t, (int32_t)100); + DECL_GFX_PREF(Live, "mousewheel.transaction.timeout", MouseWheelTransactionTimeoutMs, int32_t, (int32_t)1500); + + DECL_GFX_PREF(Live, "nglayout.debug.widget_update_flashing", WidgetUpdateFlashing, bool, false); + + DECL_GFX_PREF(Live, "print.font-variations-as-paths", PrintFontVariationsAsPaths, bool, true); + + DECL_GFX_PREF(Live, "privacy.resistFingerprinting", ResistFingerprinting, bool, false); + + DECL_GFX_PREF(Once, "slider.snapMultiplier", SliderSnapMultiplier, int32_t, 0); + + DECL_GFX_PREF(Live, "test.events.async.enabled", TestEventsAsyncEnabled, bool, false); + DECL_GFX_PREF(Live, "test.mousescroll", MouseScrollTestingEnabled, bool, false); + + DECL_GFX_PREF(Live, "toolkit.scrollbox.horizontalScrollDistance", ToolkitHorizontalScrollDistance, int32_t, 5); + DECL_GFX_PREF(Live, "toolkit.scrollbox.verticalScrollDistance", ToolkitVerticalScrollDistance, int32_t, 3); + + DECL_GFX_PREF(Live, "ui.click_hold_context_menus.delay", UiClickHoldContextMenusDelay, int32_t, 500); + + // WebGL (for pref access from Worker threads) + DECL_GFX_PREF(Live, "webgl.1.allow-core-profiles", WebGL1AllowCoreProfile, bool, false); + + DECL_GFX_PREF(Live, "webgl.all-angle-options", WebGLAllANGLEOptions, bool, false); + DECL_GFX_PREF(Live, "webgl.angle.force-d3d11", WebGLANGLEForceD3D11, bool, false); + DECL_GFX_PREF(Live, "webgl.angle.try-d3d11", WebGLANGLETryD3D11, bool, false); + DECL_GFX_PREF(Live, "webgl.angle.force-warp", WebGLANGLEForceWARP, bool, false); + DECL_GFX_PREF(Live, "webgl.can-lose-context-in-foreground", WebGLCanLoseContextInForeground, bool, true); + DECL_GFX_PREF(Live, "webgl.default-low-power", WebGLDefaultLowPower, bool, false); + DECL_GFX_PREF(Live, "webgl.default-no-alpha", WebGLDefaultNoAlpha, bool, false); + DECL_GFX_PREF(Live, "webgl.disable-angle", WebGLDisableANGLE, bool, false); + DECL_GFX_PREF(Live, "webgl.disable-wgl", WebGLDisableWGL, bool, false); + DECL_GFX_PREF(Live, "webgl.disable-extensions", WebGLDisableExtensions, bool, false); + DECL_GFX_PREF(Live, "webgl.dxgl.enabled", WebGLDXGLEnabled, bool, false); + DECL_GFX_PREF(Live, "webgl.dxgl.needs-finish", WebGLDXGLNeedsFinish, bool, false); + + DECL_GFX_PREF(Live, "webgl.disable-fail-if-major-performance-caveat", + WebGLDisableFailIfMajorPerformanceCaveat, bool, false); + DECL_GFX_PREF(Live, "webgl.disable-DOM-blit-uploads", + WebGLDisableDOMBlitUploads, bool, false); + + DECL_GFX_PREF(Live, "webgl.disabled", WebGLDisabled, bool, false); + + DECL_GFX_PREF(Live, "webgl.enable-draft-extensions", WebGLDraftExtensionsEnabled, bool, false); + DECL_GFX_PREF(Live, "webgl.enable-privileged-extensions", WebGLPrivilegedExtensionsEnabled, bool, false); + DECL_GFX_PREF(Live, "webgl.enable-surface-texture", WebGLSurfaceTextureEnabled, bool, false); + DECL_GFX_PREF(Live, "webgl.enable-webgl2", WebGL2Enabled, bool, true); + DECL_GFX_PREF(Live, "webgl.force-enabled", WebGLForceEnabled, bool, false); + DECL_GFX_PREF(Once, "webgl.force-layers-readback", WebGLForceLayersReadback, bool, false); + DECL_GFX_PREF(Live, "webgl.force-index-validation", WebGLForceIndexValidation, int32_t, 0); + DECL_GFX_PREF(Live, "webgl.lose-context-on-memory-pressure", WebGLLoseContextOnMemoryPressure, bool, false); + DECL_GFX_PREF(Live, "webgl.max-contexts", WebGLMaxContexts, uint32_t, 32); + DECL_GFX_PREF(Live, "webgl.max-contexts-per-principal", WebGLMaxContextsPerPrincipal, uint32_t, 16); + DECL_GFX_PREF(Live, "webgl.max-warnings-per-context", WebGLMaxWarningsPerContext, uint32_t, 32); + DECL_GFX_PREF(Live, "webgl.min_capability_mode", WebGLMinCapabilityMode, bool, false); + DECL_GFX_PREF(Live, "webgl.msaa-force", WebGLForceMSAA, bool, false); + DECL_GFX_PREF(Live, "webgl.msaa-samples", WebGLMsaaSamples, uint32_t, 4); + DECL_GFX_PREF(Live, "webgl.prefer-16bpp", WebGLPrefer16bpp, bool, false); + DECL_GFX_PREF(Live, "webgl.allow-immediate-queries", WebGLImmediateQueries, bool, false); + DECL_GFX_PREF(Live, "webgl.allow-fb-invalidation", WebGLFBInvalidation, bool, false); + + DECL_GFX_PREF(Live, "webgl.perf.max-warnings", WebGLMaxPerfWarnings, int32_t, 0); + DECL_GFX_PREF(Live, "webgl.perf.max-acceptable-fb-status-invals", WebGLMaxAcceptableFBStatusInvals, int32_t, 0); + DECL_GFX_PREF(Live, "webgl.perf.spew-frame-allocs", WebGLSpewFrameAllocs, bool, true); + + + DECL_GFX_PREF(Live, "widget.window-transforms.disabled", WindowTransformsDisabled, bool, false); + + // WARNING: + // Please make sure that you've added your new preference to the list above + // in alphabetical order. + // Please do not just append it to the end of the list. + + // clang-format on + + public: + // Manage the singleton: + static gfxPrefs& GetSingleton() { + return sInstance ? *sInstance : CreateAndInitializeSingleton(); + } + static void DestroySingleton(); + static bool SingletonExists(); + + private: + static gfxPrefs& CreateAndInitializeSingleton(); + + static gfxPrefs* sInstance; + static bool sInstanceHasBeenDestroyed; + static nsTArray* sGfxPrefList; + + private: + // The constructor cannot access GetSingleton(), since sInstance (necessarily) + // has not been assigned yet. Follow-up initialization that needs + // GetSingleton() must be added to Init(). + void Init(); + + static bool IsPrefsServiceAvailable(); + static bool IsParentProcess(); + // Creating these to avoid having to include Preferences.h in the .h + static void PrefAddVarCache(bool*, const nsACString&, bool); + static void PrefAddVarCache(int32_t*, const nsACString&, int32_t); + static void PrefAddVarCache(uint32_t*, const nsACString&, uint32_t); + static void PrefAddVarCache(float*, const nsACString&, float); + static void PrefAddVarCache(std::string*, const nsCString&, std::string); + static void PrefAddVarCache(AtomicBool*, const nsACString&, bool); + static void PrefAddVarCache(AtomicInt32*, const nsACString&, int32_t); + static void PrefAddVarCache(AtomicUint32*, const nsACString&, uint32_t); + static bool PrefGet(const char*, bool); + static int32_t PrefGet(const char*, int32_t); + static uint32_t PrefGet(const char*, uint32_t); + static float PrefGet(const char*, float); + static std::string PrefGet(const char*, std::string); + static void PrefSet(const char* aPref, bool aValue); + static void PrefSet(const char* aPref, int32_t aValue); + static void PrefSet(const char* aPref, uint32_t aValue); + static void PrefSet(const char* aPref, float aValue); + static void PrefSet(const char* aPref, std::string aValue); + static void WatchChanges(const char* aPrefname, Pref* aPref); + static void UnwatchChanges(const char* aPrefname, Pref* aPref); + // Creating these to avoid having to include PGPU.h in the .h + static void CopyPrefValue(const bool* aValue, GfxPrefValue* aOutValue); + static void CopyPrefValue(const int32_t* aValue, GfxPrefValue* aOutValue); + static void CopyPrefValue(const uint32_t* aValue, GfxPrefValue* aOutValue); + static void CopyPrefValue(const float* aValue, GfxPrefValue* aOutValue); + static void CopyPrefValue(const std::string* aValue, GfxPrefValue* aOutValue); + static void CopyPrefValue(const GfxPrefValue* aValue, bool* aOutValue); + static void CopyPrefValue(const GfxPrefValue* aValue, int32_t* aOutValue); + static void CopyPrefValue(const GfxPrefValue* aValue, uint32_t* aOutValue); + static void CopyPrefValue(const GfxPrefValue* aValue, float* aOutValue); + static void CopyPrefValue(const GfxPrefValue* aValue, std::string* aOutValue); + + static void AssertMainThread(); + + // Some wrapper functions for the DECL_OVERRIDE_PREF prefs' base values, so + // that we don't to include all sorts of header files into this gfxPrefs.h + // file. + static bool OverrideBase_WebRender(); + + gfxPrefs(); + ~gfxPrefs(); + gfxPrefs(const gfxPrefs&) = delete; + gfxPrefs& operator=(const gfxPrefs&) = delete; +}; + +#undef DECL_GFX_PREF /* Don't need it outside of this file */ + +#endif /* GFX_PREFS_H */ diff --git a/gfx/thebes/gfxUserFontSet.cpp b/gfx/thebes/gfxUserFontSet.cpp index ac44b3ca22d73..42eaa9b8dd3dc 100644 --- a/gfx/thebes/gfxUserFontSet.cpp +++ b/gfx/thebes/gfxUserFontSet.cpp @@ -7,12 +7,12 @@ #include "gfxUserFontSet.h" #include "gfxPlatform.h" +#include "gfxPrefs.h" #include "nsIProtocolHandler.h" #include "gfxFontConstants.h" #include "mozilla/FontPropertyTypes.h" #include "mozilla/Preferences.h" #include "mozilla/Services.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Telemetry.h" #include "mozilla/gfx/2D.h" #include "gfxPlatformFontList.h" @@ -186,11 +186,11 @@ class MOZ_STACK_CLASS gfxOTSContext : public ots::OTSContext { explicit gfxOTSContext(gfxUserFontEntry* aUserFontEntry) : mUserFontEntry(aUserFontEntry) { // Whether to apply OTS validation to OpenType Layout tables - mCheckOTLTables = StaticPrefs::ValidateOTLTables(); + mCheckOTLTables = gfxPrefs::ValidateOTLTables(); // Whether to preserve Variation tables in downloaded fonts - mCheckVariationTables = StaticPrefs::ValidateVariationTables(); + mCheckVariationTables = gfxPrefs::ValidateVariationTables(); // Whether to preserve color bitmap glyphs - mKeepColorBitmaps = StaticPrefs::KeepColorBitmaps(); + mKeepColorBitmaps = gfxPrefs::KeepColorBitmaps(); } virtual ots::TableAction GetTableAction(uint32_t aTag) override { diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index b4e15b0c841af..c9debcc497bc1 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -29,7 +29,6 @@ #include "mozilla/image/nsPNGEncoder.h" #include "mozilla/Maybe.h" #include "mozilla/RefPtr.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/UniquePtrExtensions.h" #include "mozilla/Unused.h" #include "mozilla/Vector.h" @@ -47,6 +46,7 @@ #include "ImageContainer.h" #include "ImageRegion.h" #include "gfx2DGlue.h" +#include "gfxPrefs.h" #ifdef XP_WIN # include "gfxWindowsPlatform.h" @@ -1461,23 +1461,20 @@ void gfxUtils::RemoveShaderCacheFromDiskIfNecessary() { /* static */ bool gfxUtils::DumpDisplayList() { - return StaticPrefs::LayoutDumpDisplayList() || - (StaticPrefs::LayoutDumpDisplayListParent() && - XRE_IsParentProcess()) || - (StaticPrefs::LayoutDumpDisplayListContent() && - XRE_IsContentProcess()); + return gfxPrefs::LayoutDumpDisplayList() || + (gfxPrefs::LayoutDumpDisplayListParent() && XRE_IsParentProcess()) || + (gfxPrefs::LayoutDumpDisplayListContent() && XRE_IsContentProcess()); } wr::RenderRoot gfxUtils::GetContentRenderRoot() { - if (gfx::gfxVars::UseWebRender() && - StaticPrefs::WebRenderSplitRenderRoots()) { + if (gfx::gfxVars::UseWebRender() && gfxPrefs::WebRenderSplitRenderRoots()) { return wr::RenderRoot::Content; } return wr::RenderRoot::Default; } Maybe gfxUtils::GetRenderRootForFrame(const nsIFrame* aFrame) { - if (!gfxVars::UseWebRender() || !StaticPrefs::WebRenderSplitRenderRoots()) { + if (!gfxVars::UseWebRender() || !gfxPrefs::WebRenderSplitRenderRoots()) { return Nothing(); } if (!aFrame->GetContent()) { @@ -1491,7 +1488,7 @@ Maybe gfxUtils::GetRenderRootForElement( if (!aElement) { return Nothing(); } - if (!gfxVars::UseWebRender() || !StaticPrefs::WebRenderSplitRenderRoots()) { + if (!gfxVars::UseWebRender() || !gfxPrefs::WebRenderSplitRenderRoots()) { return Nothing(); } if (!aElement->IsXULElement()) { @@ -1506,7 +1503,7 @@ Maybe gfxUtils::GetRenderRootForElement( wr::RenderRoot gfxUtils::RecursivelyGetRenderRootForFrame( const nsIFrame* aFrame) { - if (!gfxVars::UseWebRender() || !StaticPrefs::WebRenderSplitRenderRoots()) { + if (!gfxVars::UseWebRender() || !gfxPrefs::WebRenderSplitRenderRoots()) { return wr::RenderRoot::Default; } @@ -1523,7 +1520,7 @@ wr::RenderRoot gfxUtils::RecursivelyGetRenderRootForFrame( wr::RenderRoot gfxUtils::RecursivelyGetRenderRootForElement( const dom::Element* aElement) { - if (!gfxVars::UseWebRender() || !StaticPrefs::WebRenderSplitRenderRoots()) { + if (!gfxVars::UseWebRender() || !gfxPrefs::WebRenderSplitRenderRoots()) { return wr::RenderRoot::Default; } diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index e21c5453d3528..3fddf36c8078a 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -74,7 +74,7 @@ #include "d3dkmtQueryStatistics.h" #include "base/thread.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "gfxConfig.h" #include "VsyncSource.h" #include "DriverCrashGuard.h" @@ -1354,7 +1354,7 @@ void gfxWindowsPlatform::InitializeD3D11Config() { d3d11.Disable(FeatureStatus::Blacklisted, "Blacklisted, see bug 1351349", NS_LITERAL_CSTRING("FEATURE_FAILURE_BUG_1351349")); #else - StaticPrefs::SetCompositorClearState(true); + gfxPrefs::SetCompositorClearState(true); #endif } } @@ -1367,7 +1367,7 @@ void gfxWindowsPlatform::InitializeD3D11Config() { } // Check if the user really, really wants WARP. - if (StaticPrefs::LayersD3D11ForceWARP()) { + if (gfxPrefs::LayersD3D11ForceWARP()) { // Force D3D11 on even if we disabled it. d3d11.UserForceEnable("User force-enabled WARP"); } @@ -1384,14 +1384,14 @@ void gfxWindowsPlatform::InitializeAdvancedLayersConfig() { FeatureState& al = gfxConfig::GetFeature(Feature::ADVANCED_LAYERS); al.SetDefaultFromPref( - StaticPrefs::GetAdvancedLayersEnabledDoNotUseDirectlyPrefName(), + gfxPrefs::GetAdvancedLayersEnabledDoNotUseDirectlyPrefName(), true /* aIsEnablePref */, - StaticPrefs::GetAdvancedLayersEnabledDoNotUseDirectlyPrefDefault()); + gfxPrefs::GetAdvancedLayersEnabledDoNotUseDirectlyPrefDefault()); // Windows 7 has an extra pref since it uses totally different buffer paths // that haven't been performance tested yet. if (al.IsEnabled() && !IsWin8OrLater()) { - if (StaticPrefs::AdvancedLayersEnableOnWindows7()) { + if (gfxPrefs::AdvancedLayersEnableOnWindows7()) { al.UserEnable("Enabled for Windows 7 via user-preference"); } else { al.Disable(FeatureStatus::Disabled, @@ -1543,8 +1543,8 @@ void gfxWindowsPlatform::InitializeD2DConfig() { return; } - d2d1.SetDefaultFromPref(StaticPrefs::GetDirect2DDisabledPrefName(), false, - StaticPrefs::GetDirect2DDisabledPrefDefault()); + d2d1.SetDefaultFromPref(gfxPrefs::GetDirect2DDisabledPrefName(), false, + gfxPrefs::GetDirect2DDisabledPrefDefault()); nsCString message; nsCString failureId; @@ -1553,7 +1553,7 @@ void gfxWindowsPlatform::InitializeD2DConfig() { d2d1.Disable(FeatureStatus::Blacklisted, message.get(), failureId); } - if (!d2d1.IsEnabled() && StaticPrefs::Direct2DForceEnabled()) { + if (!d2d1.IsEnabled() && gfxPrefs::Direct2DForceEnabled()) { d2d1.UserForceEnable("Force-enabled via user-preference"); } } @@ -1637,7 +1637,7 @@ bool gfxWindowsPlatform::InitGPUProcessSupport() { if (!gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) { // Don't use the GPU process if not using D3D11, unless software // compositor is allowed - if (StaticPrefs::GPUProcessAllowSoftware()) { + if (gfxPrefs::GPUProcessAllowSoftware()) { return gpuProc.IsEnabled(); } gpuProc.Disable(FeatureStatus::Unavailable, @@ -1944,7 +1944,7 @@ gfxWindowsPlatform::CreateHardwareVsyncSource() { void gfxWindowsPlatform::GetAcceleratedCompositorBackends( nsTArray& aBackends) { if (gfxConfig::IsEnabled(Feature::OPENGL_COMPOSITING) && - StaticPrefs::LayersPreferOpenGL()) { + gfxPrefs::LayersPreferOpenGL()) { aBackends.AppendElement(LayersBackend::LAYERS_OPENGL); } diff --git a/gfx/thebes/moz.build b/gfx/thebes/moz.build index 19cfb2fde0e4e..ea589f041553a 100644 --- a/gfx/thebes/moz.build +++ b/gfx/thebes/moz.build @@ -42,6 +42,7 @@ EXPORTS += [ 'gfxPlatform.h', 'gfxPlatformFontList.h', 'gfxPoint.h', + 'gfxPrefs.h', 'gfxQuad.h', 'gfxQuaternion.h', 'gfxRect.h', @@ -179,6 +180,7 @@ SOURCES += [ # gfxFontUtils.cpp and gfxPlatform.cpp include mac system header conflicting with point/size 'gfxFontUtils.cpp', 'gfxPlatform.cpp', + 'gfxPrefs.cpp', 'PrintTarget.cpp', 'PrintTargetThebes.cpp', ] diff --git a/gfx/vr/VRDisplayClient.cpp b/gfx/vr/VRDisplayClient.cpp index 7cdbf42b228ef..1e7f77425c83f 100644 --- a/gfx/vr/VRDisplayClient.cpp +++ b/gfx/vr/VRDisplayClient.cpp @@ -8,7 +8,7 @@ #include "prlink.h" #include "prenv.h" - +#include "gfxPrefs.h" #include "nsIGlobalObject.h" #include "nsRefPtrHashtable.h" #include "nsString.h" @@ -96,7 +96,7 @@ void VRDisplayClient::FireEvents() { // Check if we need to trigger onvrdisplayactivate event if (!bLastEventWasMounted && mDisplayInfo.mDisplayState.isMounted) { bLastEventWasMounted = true; - if (StaticPrefs::VRAutoActivateEnabled()) { + if (gfxPrefs::VRAutoActivateEnabled()) { vm->FireDOMVRDisplayMountedEvent(mDisplayInfo.mDisplayID); } } @@ -104,7 +104,7 @@ void VRDisplayClient::FireEvents() { // Check if we need to trigger onvrdisplaydeactivate event if (bLastEventWasMounted && !mDisplayInfo.mDisplayState.isMounted) { bLastEventWasMounted = false; - if (StaticPrefs::VRAutoActivateEnabled()) { + if (gfxPrefs::VRAutoActivateEnabled()) { vm->FireDOMVRDisplayUnmountedEvent(mDisplayInfo.mDisplayID); } } diff --git a/gfx/vr/VRDisplayHost.cpp b/gfx/vr/VRDisplayHost.cpp index 962e96f71be54..4556ee08954c9 100644 --- a/gfx/vr/VRDisplayHost.cpp +++ b/gfx/vr/VRDisplayHost.cpp @@ -5,13 +5,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "VRDisplayHost.h" -#include "VRThread.h" +#include "gfxPrefs.h" #include "gfxVR.h" #include "ipc/VRLayerParent.h" -#include "mozilla/StaticPrefs.h" -#include "mozilla/dom/GamepadBinding.h" // For GamepadMappingType #include "mozilla/layers/CompositorThread.h" // for CompositorThreadHolder #include "mozilla/layers/TextureHost.h" +#include "mozilla/dom/GamepadBinding.h" // For GamepadMappingType +#include "VRThread.h" #if defined(XP_WIN) @@ -268,7 +268,7 @@ void VRDisplayHost::CheckWatchDog() { bShouldStartFrame = true; } else { TimeDuration duration = TimeStamp::Now() - lastFrameStart; - if (duration.ToMilliseconds() > StaticPrefs::VRDisplayRafMaxDuration()) { + if (duration.ToMilliseconds() > gfxPrefs::VRDisplayRafMaxDuration()) { bShouldStartFrame = true; } } diff --git a/gfx/vr/VRDisplayLocal.cpp b/gfx/vr/VRDisplayLocal.cpp index 2f73c2616ff09..351bd2cbad7a3 100644 --- a/gfx/vr/VRDisplayLocal.cpp +++ b/gfx/vr/VRDisplayLocal.cpp @@ -6,7 +6,7 @@ #include "VRDisplayLocal.h" #include "VRThread.h" - +#include "gfxPrefs.h" #include "gfxVR.h" #include "ipc/VRLayerParent.h" #include "mozilla/dom/GamepadBinding.h" // For GamepadMappingType diff --git a/gfx/vr/VRManager.cpp b/gfx/vr/VRManager.cpp index be11406c5f3aa..04844850bd4d0 100644 --- a/gfx/vr/VRManager.cpp +++ b/gfx/vr/VRManager.cpp @@ -13,9 +13,9 @@ #include "mozilla/dom/GamepadEventTypes.h" #include "mozilla/layers/TextureHost.h" #include "mozilla/layers/CompositorThread.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Unused.h" +#include "gfxPrefs.h" #include "gfxVR.h" #include "gfxVRExternal.h" @@ -79,7 +79,7 @@ VRManager::VRManager() #if !defined(MOZ_WIDGET_ANDROID) // The VR Service accesses all hardware from a separate process // and replaces the other VRSystemManager when enabled. - if (!StaticPrefs::VRProcessEnabled() || !XRE_IsGPUProcess()) { + if (!gfxPrefs::VRProcessEnabled() || !XRE_IsGPUProcess()) { VRServiceManager::Get().CreateService(); } if (VRServiceManager::Get().IsServiceValid()) { @@ -100,7 +100,7 @@ VRManager::VRManager() // Enable gamepad extensions while VR is enabled. // Preference only can be set at the Parent process. - if (XRE_IsParentProcess() && StaticPrefs::VREnabled()) { + if (XRE_IsParentProcess() && gfxPrefs::VREnabled()) { Preferences::SetBool("dom.gamepad.extensions.enabled", true); } } @@ -144,8 +144,7 @@ void VRManager::Shutdown() { } // XRE_IsGPUProcess() is helping us to check some platforms like // Win 7 try which are not using GPU process but VR process is enabled. - if (XRE_IsGPUProcess() && StaticPrefs::VRProcessEnabled() && - mVRServiceStarted) { + if (XRE_IsGPUProcess() && gfxPrefs::VRProcessEnabled() && mVRServiceStarted) { RefPtr task = NS_NewRunnableFunction( "VRServiceManager::ShutdownVRProcess", []() -> void { VRServiceManager::Get().ShutdownVRProcess(); }); @@ -388,7 +387,7 @@ void VRManager::CheckForInactiveTimeout() { Shutdown(); } else { TimeDuration duration = TimeStamp::Now() - mLastActiveTime; - if (duration.ToMilliseconds() > StaticPrefs::VRInactiveTimeout()) { + if (duration.ToMilliseconds() > gfxPrefs::VRInactiveTimeout()) { Shutdown(); // We must not throttle the next enumeration request // after an idle timeout, as it may result in the @@ -423,7 +422,7 @@ void VRManager::EnumerateVRDisplays() { */ if (!mLastDisplayEnumerationTime.IsNull()) { TimeDuration duration = TimeStamp::Now() - mLastDisplayEnumerationTime; - if (duration.ToMilliseconds() < StaticPrefs::VRDisplayEnumerateInterval()) { + if (duration.ToMilliseconds() < gfxPrefs::VRDisplayEnumerateInterval()) { return; } } @@ -456,7 +455,7 @@ void VRManager::EnumerateVRDisplays() { */ #if !defined(MOZ_WIDGET_ANDROID) if (!mVRServiceStarted) { - if (XRE_IsGPUProcess() && StaticPrefs::VRProcessEnabled()) { + if (XRE_IsGPUProcess() && gfxPrefs::VRProcessEnabled()) { VRServiceManager::Get().CreateVRProcess(); mVRServiceStarted = true; } else { @@ -698,8 +697,7 @@ void VRManager::ScanForControllers() { // have enumerated recently if (!mLastControllerEnumerationTime.IsNull()) { TimeDuration duration = TimeStamp::Now() - mLastControllerEnumerationTime; - if (duration.ToMilliseconds() < - StaticPrefs::VRControllerEnumerateInterval()) { + if (duration.ToMilliseconds() < gfxPrefs::VRControllerEnumerateInterval()) { return; } } diff --git a/gfx/vr/gfxVRExternal.cpp b/gfx/vr/gfxVRExternal.cpp index 2a594f5738cf3..15981545ad9cf 100644 --- a/gfx/vr/gfxVRExternal.cpp +++ b/gfx/vr/gfxVRExternal.cpp @@ -8,8 +8,8 @@ #include "prlink.h" #include "prenv.h" +#include "gfxPrefs.h" #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/gfx/Quaternion.h" @@ -526,7 +526,7 @@ void VRSystemManagerExternal::OpenShmem() { #elif defined(XP_WIN) if (mShmemFile == NULL) { - if (StaticPrefs::VRProcessEnabled()) { + if (gfxPrefs::VRProcessEnabled()) { mShmemFile = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(VRExternalShmem), kShmemName); @@ -624,11 +624,11 @@ already_AddRefed VRSystemManagerExternal::Create( VRExternalShmem* aAPIShmem /* = nullptr*/) { MOZ_ASSERT(NS_IsMainThread()); - if (!StaticPrefs::VREnabled()) { + if (!gfxPrefs::VREnabled()) { return nullptr; } - if ((!StaticPrefs::VRExternalEnabled() && aAPIShmem == nullptr) + if ((!gfxPrefs::VRExternalEnabled() && aAPIShmem == nullptr) #if defined(XP_WIN) || !XRE_IsGPUProcess() #endif diff --git a/gfx/vr/gfxVRPuppet.cpp b/gfx/vr/gfxVRPuppet.cpp index a2b776f331174..238723ab0187c 100644 --- a/gfx/vr/gfxVRPuppet.cpp +++ b/gfx/vr/gfxVRPuppet.cpp @@ -13,9 +13,9 @@ #endif #include "mozilla/Base64.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/gfx/DataSurfaceHelpers.h" #include "mozilla/layers/CompositorThread.h" // for CompositorThreadHolder +#include "gfxPrefs.h" #include "gfxUtils.h" #include "gfxVRPuppet.h" #include "VRManager.h" @@ -289,7 +289,7 @@ bool VRDisplayPuppet::SubmitFrame(ID3D11Texture2D* aSource, VRManager* vm = VRManager::Get(); MOZ_ASSERT(vm); - switch (StaticPrefs::VRPuppetSubmitFrame()) { + switch (gfxPrefs::VRPuppetSubmitFrame()) { case 0: // The VR frame is not displayed. break; @@ -479,7 +479,7 @@ bool VRDisplayPuppet::SubmitFrame(MacIOSurface* aMacIOSurface, VRManager* vm = VRManager::Get(); MOZ_ASSERT(vm); - switch (StaticPrefs::VRPuppetSubmitFrame()) { + switch (gfxPrefs::VRPuppetSubmitFrame()) { case 0: // The VR frame is not displayed. break; @@ -640,7 +640,7 @@ VRSystemManagerPuppet::VRSystemManagerPuppet() /*static*/ already_AddRefed VRSystemManagerPuppet::Create() { - if (!StaticPrefs::VREnabled() || !StaticPrefs::VRPuppetEnabled()) { + if (!gfxPrefs::VREnabled() || !gfxPrefs::VRPuppetEnabled()) { return nullptr; } diff --git a/gfx/vr/ipc/PVR.ipdl b/gfx/vr/ipc/PVR.ipdl index f886e998086dc..e81a2851d64cd 100644 --- a/gfx/vr/ipc/PVR.ipdl +++ b/gfx/vr/ipc/PVR.ipdl @@ -10,7 +10,6 @@ include "VRMessageUtils.h"; include GraphicsMessages; include MemoryReportTypes; -include PrefsTypes; include protocol PVRGPU; include "VRMessageUtils.h"; @@ -22,11 +21,11 @@ async protocol PVR { parent: async NewGPUVRManager(Endpoint endpoint); - async Init(GfxVarUpdate[] vars, DevicePrefs devicePrefs); + async Init(GfxPrefSetting[] prefs, GfxVarUpdate[] vars, DevicePrefs devicePrefs); async NotifyVsync(TimeStamp vsyncTimestamp); + async UpdatePref(GfxPrefSetting pref); async UpdateVar(GfxVarUpdate var); - async PreferenceUpdate(Pref pref); async OpenVRControllerActionPathToVR(nsCString aPath); async OpenVRControllerManifestPathToVR(OpenVRControllerType aType, nsCString aPath); async RequestMemoryReport(uint32_t generation, diff --git a/gfx/vr/ipc/VRChild.cpp b/gfx/vr/ipc/VRChild.cpp index 020ef7fc047e5..1b5227f2fce01 100644 --- a/gfx/vr/ipc/VRChild.cpp +++ b/gfx/vr/ipc/VRChild.cpp @@ -105,6 +105,23 @@ void VRChild::ActorDestroy(ActorDestroyReason aWhy) { } void VRChild::Init() { + // Build a list of prefs the VR process will need. Note that because we + // limit the VR process to prefs contained in gfxPrefs, we can simplify + // the message in two ways: one, we only need to send its index in gfxPrefs + // rather than its name, and two, we only need to send prefs that don't + // have their default value. + // Todo: Consider to make our own vrPrefs that we are interested in VR + // process. + nsTArray prefs; + for (auto pref : gfxPrefs::all()) { + if (pref->HasDefaultValue()) { + continue; + } + + GfxPrefValue value; + pref->GetCachedValue(&value); + prefs.AppendElement(GfxPrefSetting(pref->Index(), value)); + } nsTArray updates = gfxVars::FetchNonDefaultVars(); DevicePrefs devicePrefs; @@ -116,7 +133,7 @@ void VRChild::Init() { devicePrefs.advancedLayers() = gfxConfig::GetValue(Feature::ADVANCED_LAYERS); devicePrefs.useD2D1() = gfxConfig::GetValue(Feature::DIRECT2D); - SendInit(updates, devicePrefs); + SendInit(prefs, updates, devicePrefs); if (!sOpenVRControllerManifestManager) { sOpenVRControllerManifestManager = new OpenVRControllerManifestManager(); diff --git a/gfx/vr/ipc/VRParent.cpp b/gfx/vr/ipc/VRParent.cpp index ef4b73ce64c5e..1401b94abd559 100644 --- a/gfx/vr/ipc/VRParent.cpp +++ b/gfx/vr/ipc/VRParent.cpp @@ -38,10 +38,16 @@ IPCResult VRParent::RecvNewGPUVRManager(Endpoint&& aEndpoint) { return IPC_OK(); } -IPCResult VRParent::RecvInit(nsTArray&& vars, +IPCResult VRParent::RecvInit(nsTArray&& prefs, + nsTArray&& vars, const DevicePrefs& devicePrefs) { Unused << SendInitComplete(); + const nsTArray& globalPrefs = gfxPrefs::all(); + for (auto& setting : prefs) { + gfxPrefs::Pref* pref = globalPrefs[setting.index()]; + pref->SetCachedValue(setting.value()); + } for (const auto& var : vars) { gfxVars::ApplyUpdate(var); } @@ -68,13 +74,14 @@ IPCResult VRParent::RecvNotifyVsync(const TimeStamp& vsyncTimestamp) { return IPC_OK(); } -IPCResult VRParent::RecvUpdateVar(const GfxVarUpdate& aUpdate) { - gfxVars::ApplyUpdate(aUpdate); +IPCResult VRParent::RecvUpdatePref(const GfxPrefSetting& setting) { + gfxPrefs::Pref* pref = gfxPrefs::all()[setting.index()]; + pref->SetCachedValue(setting.value()); return IPC_OK(); } -mozilla::ipc::IPCResult VRParent::RecvPreferenceUpdate(const Pref& aPref) { - Preferences::SetPreference(aPref); +IPCResult VRParent::RecvUpdateVar(const GfxVarUpdate& aUpdate) { + gfxVars::ApplyUpdate(aUpdate); return IPC_OK(); } @@ -128,6 +135,7 @@ void VRParent::ActorDestroy(ActorDestroyReason aWhy) { #endif gfxVars::Shutdown(); gfxConfig::Shutdown(); + gfxPrefs::DestroySingleton(); CrashReporterClient::DestroySingleton(); // Only calling XRE_ShutdownChildProcess() at the child process // instead of the main process. Otherwise, it will close all child processes @@ -163,6 +171,8 @@ bool VRParent::Init(base::ProcessId aParentPid, const char* aParentBuildID, // Init crash reporter support. CrashReporterClient::InitSingleton(this); + // Ensure gfxPrefs are initialized. + gfxPrefs::GetSingleton(); gfxConfig::Init(); gfxVars::Initialize(); #if defined(XP_WIN) diff --git a/gfx/vr/ipc/VRParent.h b/gfx/vr/ipc/VRParent.h index 03a382d21e3c6..fe88a6630e259 100644 --- a/gfx/vr/ipc/VRParent.h +++ b/gfx/vr/ipc/VRParent.h @@ -36,11 +36,12 @@ class VRParent final : public PVRParent { mozilla::ipc::IPCResult RecvNewGPUVRManager( Endpoint&& aEndpoint); - mozilla::ipc::IPCResult RecvInit(nsTArray&& vars, + mozilla::ipc::IPCResult RecvInit(nsTArray&& prefs, + nsTArray&& vars, const DevicePrefs& devicePrefs); mozilla::ipc::IPCResult RecvNotifyVsync(const TimeStamp& vsyncTimestamp); + mozilla::ipc::IPCResult RecvUpdatePref(const GfxPrefSetting& setting); mozilla::ipc::IPCResult RecvUpdateVar(const GfxVarUpdate& pref); - mozilla::ipc::IPCResult RecvPreferenceUpdate(const Pref& pref); mozilla::ipc::IPCResult RecvOpenVRControllerActionPathToVR( const nsCString& aPath); mozilla::ipc::IPCResult RecvOpenVRControllerManifestPathToVR( diff --git a/gfx/vr/ipc/VRProcessChild.cpp b/gfx/vr/ipc/VRProcessChild.cpp index 4a1e5d34b2f25..4c39bd744ccc8 100644 --- a/gfx/vr/ipc/VRProcessChild.cpp +++ b/gfx/vr/ipc/VRProcessChild.cpp @@ -8,7 +8,6 @@ #include "mozilla/BackgroundHangMonitor.h" #include "mozilla/ipc/IOThreadChild.h" -#include "ProcessUtils.h" using namespace mozilla; using namespace mozilla::gfx; @@ -29,48 +28,15 @@ VRParent* VRProcessChild::GetVRParent() { bool VRProcessChild::Init(int aArgc, char* aArgv[]) { char* parentBuildID = nullptr; - char* prefsHandle = nullptr; - char* prefMapHandle = nullptr; - char* prefsLen = nullptr; - char* prefMapSize = nullptr; for (int i = 1; i < aArgc; i++) { if (!aArgv[i]) { continue; } if (strcmp(aArgv[i], "-parentBuildID") == 0) { parentBuildID = aArgv[i + 1]; - -#ifdef XP_WIN - } else if (strcmp(aArgv[i], "-prefsHandle") == 0) { - if (++i == aArgc) { - return false; - } - prefsHandle = aArgv[i]; - } else if (strcmp(aArgv[i], "-prefMapHandle") == 0) { - if (++i == aArgc) { - return false; - } - prefMapHandle = aArgv[i]; -#endif - } else if (strcmp(aArgv[i], "-prefsLen") == 0) { - if (++i == aArgc) { - return false; - } - prefsLen = aArgv[i]; - } else if (strcmp(aArgv[i], "-prefMapSize") == 0) { - if (++i == aArgc) { - return false; - } - prefMapSize = aArgv[i]; } } - SharedPreferenceDeserializer deserializer; - if (!deserializer.DeserializeFromSharedMemory(prefsHandle, prefMapHandle, - prefsLen, prefMapSize)) { - return false; - } - sVRParent = new VRParent(); sVRParent->Init(ParentPid(), parentBuildID, IOThreadChild::message_loop(), IOThreadChild::channel()); diff --git a/gfx/vr/ipc/VRProcessManager.cpp b/gfx/vr/ipc/VRProcessManager.cpp index 8923c859197ad..fd3ac1d0f2ced 100644 --- a/gfx/vr/ipc/VRProcessManager.cpp +++ b/gfx/vr/ipc/VRProcessManager.cpp @@ -10,9 +10,7 @@ #include "VRChild.h" #include "VRGPUChild.h" #include "VRGPUParent.h" -#include "mozilla/dom/ContentParent.h" #include "mozilla/MemoryReportingProcess.h" -#include "mozilla/Preferences.h" namespace mozilla { namespace gfx { @@ -38,7 +36,6 @@ VRProcessManager::VRProcessManager() : mProcess(nullptr), mVRChild(nullptr) { mObserver = new Observer(this); nsContentUtils::RegisterShutdownObserver(mObserver); - Preferences::AddStrongObserver(mObserver, ""); } VRProcessManager::~VRProcessManager() { @@ -69,7 +66,7 @@ void VRProcessManager::LaunchVRProcess() { } void VRProcessManager::DisableVRProcess(const char* aMessage) { - if (!StaticPrefs::VRProcessEnabled()) { + if (!gfxPrefs::VRProcessEnabled()) { return; } @@ -125,13 +122,6 @@ void VRProcessManager::OnProcessLaunchComplete(VRProcessParent* aParent) { return; } - // Flush any pref updates that happened during launch and weren't - // included in the blobs set up in LaunchGPUProcess. - for (const mozilla::dom::Pref& pref : mQueuedPrefs) { - Unused << NS_WARN_IF(!mVRChild->SendPreferenceUpdate(pref)); - } - mQueuedPrefs.Clear(); - CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::VRProcessStatus, NS_LITERAL_CSTRING("Running")); } @@ -187,8 +177,6 @@ VRProcessManager::Observer::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) { if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) { mManager->OnXPCOMShutdown(); - } else if (!strcmp(aTopic, "nsPref:changed")) { - mManager->OnPreferenceChange(aData); } return NS_OK; } @@ -200,32 +188,12 @@ void VRProcessManager::CleanShutdown() { DestroyProcess(); } void VRProcessManager::OnXPCOMShutdown() { if (mObserver) { nsContentUtils::UnregisterShutdownObserver(mObserver); - Preferences::RemoveObserver(mObserver, ""); mObserver = nullptr; } CleanShutdown(); } -void VRProcessManager::OnPreferenceChange(const char16_t* aData) { - // A pref changed. If it's not on the blacklist, inform child processes. - if (!dom::ContentParent::ShouldSyncPreference(aData)) { - return; - } - - // We know prefs are ASCII here. - NS_LossyConvertUTF16toASCII strData(aData); - - mozilla::dom::Pref pref(strData, /* isLocked */ false, Nothing(), Nothing()); - Preferences::GetPreference(&pref); - if (!!mVRChild) { - MOZ_ASSERT(mQueuedPrefs.IsEmpty()); - mVRChild->SendPreferenceUpdate(pref); - } else { - mQueuedPrefs.AppendElement(pref); - } -} - VRChild* VRProcessManager::GetVRChild() { return mProcess->GetActor(); } class VRMemoryReporter : public MemoryReportingProcess { diff --git a/gfx/vr/ipc/VRProcessManager.h b/gfx/vr/ipc/VRProcessManager.h index a09d2c69b568d..0640ebee6fbe4 100644 --- a/gfx/vr/ipc/VRProcessManager.h +++ b/gfx/vr/ipc/VRProcessManager.h @@ -53,7 +53,6 @@ class VRProcessManager final : public VRProcessParent::Listener { bool CreateGPUVRManager(base::ProcessId aOtherProcess, mozilla::ipc::Endpoint* aOutEndpoint); void OnXPCOMShutdown(); - void OnPreferenceChange(const char16_t* aData); void CleanShutdown(); void DestroyProcess(); @@ -77,10 +76,6 @@ class VRProcessManager final : public VRProcessParent::Listener { RefPtr mObserver; VRProcessParent* mProcess; VRChild* mVRChild; - // Collects any pref changes that occur during process launch (after - // the initial map is passed in command-line arguments) to be sent - // when the process can receive IPC messages. - nsTArray mQueuedPrefs; }; } // namespace gfx diff --git a/gfx/vr/ipc/VRProcessParent.cpp b/gfx/vr/ipc/VRProcessParent.cpp index 4db4288bdf296..af09cc911b150 100644 --- a/gfx/vr/ipc/VRProcessParent.cpp +++ b/gfx/vr/ipc/VRProcessParent.cpp @@ -11,10 +11,8 @@ #include "mozilla/gfx/GPUChild.h" #include "mozilla/ipc/ProtocolTypes.h" #include "mozilla/ipc/ProtocolUtils.h" // for IToplevelProtocol -#include "mozilla/StaticPrefs.h" #include "mozilla/TimeStamp.h" // for TimeStamp #include "mozilla/Unused.h" -#include "ProcessUtils.h" #include "VRChild.h" #include "VRManager.h" #include "VRThread.h" @@ -63,15 +61,8 @@ bool VRProcessParent::Launch() { extraArgs.push_back("-parentBuildID"); extraArgs.push_back(parentBuildID.get()); - mPrefSerializer = MakeUnique(); - if (!mPrefSerializer->SerializeToSharedMemory()) { - return false; - } - mPrefSerializer->AddSharedPrefCmdLineArgs(*this, extraArgs); - if (!GeckoChildProcessHost::AsyncLaunch(extraArgs)) { mLaunchPhase = LaunchPhase::Complete; - mPrefSerializer = nullptr; return false; } return true; @@ -82,7 +73,7 @@ bool VRProcessParent::WaitForLaunch() { return !!mVRChild; } - int32_t timeoutMs = StaticPrefs::VRProcessTimeoutMs(); + int32_t timeoutMs = gfxPrefs::VRProcessTimeoutMs(); // If one of the following environment variables are set we can effectively // ignore the timeout - as we can guarantee the compositor process will be @@ -143,8 +134,6 @@ void VRProcessParent::InitAfterConnect(bool aSucceeded) { MOZ_ASSERT(!mVRChild); mLaunchPhase = LaunchPhase::Complete; - mPrefSerializer = nullptr; - if (aSucceeded) { mVRChild = MakeUnique(this); diff --git a/gfx/vr/ipc/VRProcessParent.h b/gfx/vr/ipc/VRProcessParent.h index 0be7f45d777c8..22d3c7339766f 100644 --- a/gfx/vr/ipc/VRProcessParent.h +++ b/gfx/vr/ipc/VRProcessParent.h @@ -13,9 +13,6 @@ #include "mozilla/ipc/TaskFactory.h" namespace mozilla { -namespace ipc { -class SharedPreferenceSerializer; -} namespace gfx { class VRChild; @@ -34,10 +31,6 @@ class VRProcessParent final : public mozilla::ipc::GeckoChildProcessHost { explicit VRProcessParent(Listener* aListener); - // Launch the subprocess asynchronously. On failure, false is returned. - // Otherwise, true is returned, and the OnProcessLaunchComplete listener - // callback will be invoked either when a connection has been established, or - // if a connection could not be established due to an asynchronous error. bool Launch(); // If the process is being launched, block until it has launched and // connected. If a launch task is pending, it will fire immediately. @@ -78,7 +71,6 @@ class VRProcessParent final : public mozilla::ipc::GeckoChildProcessHost { LaunchPhase mLaunchPhase; bool mChannelClosed; bool mShutdownRequested; - UniquePtr mPrefSerializer; }; } // namespace gfx diff --git a/gfx/vr/service/OSVRSession.cpp b/gfx/vr/service/OSVRSession.cpp index bb125966dec32..e67dbcd02eaa2 100644 --- a/gfx/vr/service/OSVRSession.cpp +++ b/gfx/vr/service/OSVRSession.cpp @@ -6,9 +6,9 @@ #include "OSVRSession.h" #include "prenv.h" +#include "gfxPrefs.h" #include "nsString.h" #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/SharedLibrary.h" #include "mozilla/gfx/Quaternion.h" @@ -209,7 +209,7 @@ OSVRSession::OSVRSession() OSVRSession::~OSVRSession() { Shutdown(); } bool OSVRSession::Initialize(mozilla::gfx::VRSystemState& aSystemState) { - if (!StaticPrefs::VREnabled() || !StaticPrefs::VROSVREnabled()) { + if (!gfxPrefs::VREnabled() || !gfxPrefs::VROSVREnabled()) { return false; } if (mOSVRInitialized) { diff --git a/gfx/vr/service/OculusSession.cpp b/gfx/vr/service/OculusSession.cpp index 7da345e969361..e3f05808bf5b3 100644 --- a/gfx/vr/service/OculusSession.cpp +++ b/gfx/vr/service/OculusSession.cpp @@ -11,7 +11,7 @@ #include #include -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "mozilla/dom/GamepadEventTypes.h" #include "mozilla/dom/GamepadBinding.h" #include "mozilla/gfx/DeviceManagerDx.h" @@ -206,7 +206,7 @@ OculusSession::OculusSession() OculusSession::~OculusSession() { Shutdown(); } bool OculusSession::Initialize(mozilla::gfx::VRSystemState& aSystemState) { - if (!StaticPrefs::VREnabled() || !StaticPrefs::VROculusEnabled()) { + if (!gfxPrefs::VREnabled() || !gfxPrefs::VROculusEnabled()) { return false; } @@ -257,7 +257,7 @@ void OculusSession::UpdateVisibility() { TimeDuration duration = TimeStamp::Now() - mLastPresentationEnd; TimeDuration timeout = - TimeDuration::FromMilliseconds(StaticPrefs::VROculusPresentTimeout()); + TimeDuration::FromMilliseconds(gfxPrefs::VROculusPresentTimeout()); if (timeout <= TimeDuration(0) || duration >= timeout) { if (!ChangeVisibility(false)) { gfxWarning() << "OculusSession::ChangeVisibility(false) failed"; @@ -293,7 +293,7 @@ void OculusSession::CoverTransitions() { bool OculusSession::ChangeVisibility(bool bVisible) { ovrInitFlags flags = (ovrInitFlags)(ovrInit_RequestVersion | ovrInit_MixedRendering); - if (StaticPrefs::VROculusInvisibleEnabled() && !bVisible) { + if (gfxPrefs::VROculusInvisibleEnabled() && !bVisible) { flags = (ovrInitFlags)(flags | ovrInit_Invisible); } if (mInitFlags == flags) { @@ -1153,7 +1153,7 @@ void OculusSession::UpdateHeadsetPose(VRSystemState& aState) { return; } double predictedFrameTime = 0.0f; - if (StaticPrefs::VRPosePredictionEnabled()) { + if (gfxPrefs::VRPosePredictionEnabled()) { // XXX We might need to call ovr_GetPredictedDisplayTime even if we don't // use the result. If we don't call it, the Oculus driver will spew out many // warnings... @@ -1324,7 +1324,7 @@ void OculusSession::EnumerateControllers(VRSystemState& aState, void OculusSession::UpdateControllerInputs(VRSystemState& aState, const ovrInputState& aInputState) { - const float triggerThreshold = StaticPrefs::VRControllerTriggerThreshold(); + const float triggerThreshold = gfxPrefs::VRControllerTriggerThreshold(); for (uint32_t handIdx = 0; handIdx < 2; handIdx++) { // Left Touch Controller will always be at index 0 and diff --git a/gfx/vr/service/OpenVRSession.cpp b/gfx/vr/service/OpenVRSession.cpp index 688afb8d3550d..6acfb2f9fa444 100644 --- a/gfx/vr/service/OpenVRSession.cpp +++ b/gfx/vr/service/OpenVRSession.cpp @@ -10,7 +10,7 @@ #include "nsString.h" #include "OpenVRSession.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #if defined(XP_WIN) # include @@ -250,7 +250,7 @@ OpenVRSession::~OpenVRSession() { } bool OpenVRSession::Initialize(mozilla::gfx::VRSystemState& aSystemState) { - if (!StaticPrefs::VREnabled() || !StaticPrefs::VROpenVREnabled()) { + if (!gfxPrefs::VREnabled() || !gfxPrefs::VROpenVREnabled()) { return false; } if (mVRSystem != nullptr) { @@ -306,7 +306,7 @@ bool OpenVRSession::Initialize(mozilla::gfx::VRSystemState& aSystemState) { return false; } - if (StaticPrefs::VROpenVRActionInputEnabled() && !SetupContollerActions()) { + if (gfxPrefs::VROpenVRActionInputEnabled() && !SetupContollerActions()) { return false; } @@ -326,7 +326,7 @@ bool OpenVRSession::SetupContollerActions() { nsCString knucklesManifest; // Getting / Generating manifest file paths. - if (StaticPrefs::VRProcessEnabled()) { + if (gfxPrefs::VRProcessEnabled()) { VRParent* vrParent = VRProcessChild::GetVRParent(); nsCString output; @@ -769,7 +769,7 @@ bool OpenVRSession::SetupContollerActions() { // End of setup controller actions. // Notify the parent process these manifest files are already been recorded. - if (StaticPrefs::VRProcessEnabled()) { + if (gfxPrefs::VRProcessEnabled()) { NS_DispatchToMainThread(NS_NewRunnableFunction( "SendOpenVRControllerActionPathToParent", [controllerAction, viveManifest, WMRManifest, knucklesManifest]() { @@ -1307,7 +1307,7 @@ void OpenVRSession::UpdateControllerButtons(VRSystemState& aState) { // value. In order to not affect the current VR content, we add a workaround // for yAxis. const float yAxisInvert = (mIsWindowsMR) ? -1.0f : 1.0f; - const float triggerThreshold = StaticPrefs::VRControllerTriggerThreshold(); + const float triggerThreshold = gfxPrefs::VRControllerTriggerThreshold(); for (uint32_t stateIndex = 0; stateIndex < kVRControllerMaxCount; ++stateIndex) { @@ -1633,7 +1633,7 @@ void OpenVRSession::UpdateControllerButtonsObsolete(VRSystemState& aState) { // value. In order to not affect the current VR content, we add a workaround // for yAxis. const float yAxisInvert = (mIsWindowsMR) ? -1.0f : 1.0f; - const float triggerThreshold = StaticPrefs::VRControllerTriggerThreshold(); + const float triggerThreshold = gfxPrefs::VRControllerTriggerThreshold(); for (uint32_t stateIndex = 0; stateIndex < kVRControllerMaxCount; stateIndex++) { @@ -1935,7 +1935,7 @@ void OpenVRSession::StartFrame(mozilla::gfx::VRSystemState& aSystemState) { UpdateHeadsetPose(aSystemState); UpdateEyeParameters(aSystemState); - if (StaticPrefs::VROpenVRActionInputEnabled()) { + if (gfxPrefs::VROpenVRActionInputEnabled()) { EnumerateControllers(aSystemState); vr::VRActiveActionSet_t actionSet = {0}; @@ -2147,7 +2147,7 @@ void OpenVRSession::HapticTimerCallback(nsITimer* aTimer, void* aClosure) { */ OpenVRSession* self = static_cast(aClosure); - if (StaticPrefs::VROpenVRActionInputEnabled()) { + if (gfxPrefs::VROpenVRActionInputEnabled()) { self->UpdateHaptics(); } else { self->UpdateHapticsObsolete(); diff --git a/gfx/vr/service/VRService.cpp b/gfx/vr/service/VRService.cpp index be49a84b2d062..351c73b174441 100644 --- a/gfx/vr/service/VRService.cpp +++ b/gfx/vr/service/VRService.cpp @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "VRService.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "../gfxVRMutex.h" #include "base/thread.h" // for Thread #include // for memcmp @@ -52,7 +52,7 @@ bool IsImmersiveContentActive(const mozilla::gfx::VRBrowserState& aState) { already_AddRefed VRService::Create() { MOZ_ASSERT(NS_IsMainThread()); - if (!StaticPrefs::VRServiceEnabled()) { + if (!gfxPrefs::VRServiceEnabled()) { return nullptr; } @@ -73,7 +73,7 @@ VRService::VRService() #if defined(XP_WIN) mMutex(NULL), #endif - mVRProcessEnabled(StaticPrefs::VRProcessEnabled()) { + mVRProcessEnabled(gfxPrefs::VRProcessEnabled()) { // When we have the VR process, we map the memory // of mAPIShmem from GPU process. // If we don't have the VR process, we will instantiate @@ -292,7 +292,7 @@ void VRService::ServiceInitialize() { memset(&mSystemState, 0, sizeof(mSystemState)); mSystemState.enumerationCompleted = true; mSystemState.displayState.minRestartInterval = - StaticPrefs::VRExternalNotDetectedTimeout(); + gfxPrefs::VRExternalNotDetectedTimeout(); mSystemState.displayState.shutdown = true; PushState(mSystemState); } @@ -309,7 +309,7 @@ void VRService::ServiceShutdown() { mSystemState.displayState.shutdown = true; if (mSession && mSession->ShouldQuit()) { mSystemState.displayState.minRestartInterval = - StaticPrefs::VRExternalQuitTimeout(); + gfxPrefs::VRExternalQuitTimeout(); } PushState(mSystemState); mSession = nullptr; diff --git a/gfx/vr/service/VRService.h b/gfx/vr/service/VRService.h index 9c543beb780da..37f7559fe5e92 100644 --- a/gfx/vr/service/VRService.h +++ b/gfx/vr/service/VRService.h @@ -66,7 +66,10 @@ class VRService { #if defined(XP_WIN) HANDLE mMutex; #endif - // We store the value of StaticPrefs::VRProcessEnabled() in mVRProcessEnabled. + // We store the value of gfxPrefs::VRProcessEnabled() in mVRProcessEnabled. + // This allows us to read the value in the VRService destructor, after + // gfxPrefs has been shut down. We should investigate why gfxPrefs + // is shutting down earlier - See bug xxx bool mVRProcessEnabled; bool IsInServiceThread(); diff --git a/gfx/vr/service/VRServiceManager.cpp b/gfx/vr/service/VRServiceManager.cpp index 276d7576e4fe0..8f38e4fc1b6ee 100644 --- a/gfx/vr/service/VRServiceManager.cpp +++ b/gfx/vr/service/VRServiceManager.cpp @@ -7,7 +7,6 @@ #include "VRServiceManager.h" #include "VRGPUChild.h" #include "mozilla/gfx/GPUParent.h" -#include "mozilla/StaticPrefs.h" namespace mozilla { namespace gfx { @@ -46,7 +45,7 @@ void VRServiceManager::ShutdownVRProcess() { } VRGPUChild::Shutdown(); } - if (StaticPrefs::VRProcessEnabled()) { + if (gfxPrefs::VRProcessEnabled()) { // Using PGPU channel to tell the main process // to shutdown VR process. gfx::GPUParent* gpu = GPUParent::GetSingleton(); @@ -56,7 +55,7 @@ void VRServiceManager::ShutdownVRProcess() { } void VRServiceManager::CreateService() { - if (!StaticPrefs::VRProcessEnabled()) { + if (!gfxPrefs::VRProcessEnabled()) { mVRService = VRService::Create(); } } diff --git a/gfx/webrender_bindings/Moz2DImageRenderer.cpp b/gfx/webrender_bindings/Moz2DImageRenderer.cpp index 5dce10963cbd6..923cf70653587 100644 --- a/gfx/webrender_bindings/Moz2DImageRenderer.cpp +++ b/gfx/webrender_bindings/Moz2DImageRenderer.cpp @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "gfxUtils.h" #include "mozilla/Mutex.h" #include "mozilla/Range.h" @@ -437,7 +437,7 @@ static bool Moz2DRenderCallback(const Range aBlob, offset = extra_end; } - if (StaticPrefs::WebRenderBlobPaintFlashing()) { + if (gfxPrefs::WebRenderBlobPaintFlashing()) { dt->SetTransform(gfx::Matrix()); float r = float(rand()) / RAND_MAX; float g = float(rand()) / RAND_MAX; diff --git a/gfx/webrender_bindings/WebRenderAPI.cpp b/gfx/webrender_bindings/WebRenderAPI.cpp index 7783f6040852d..758ddf1403ad7 100644 --- a/gfx/webrender_bindings/WebRenderAPI.cpp +++ b/gfx/webrender_bindings/WebRenderAPI.cpp @@ -6,7 +6,7 @@ #include "WebRenderAPI.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "LayersLogging.h" #include "mozilla/ipc/ByteBuf.h" #include "mozilla/webrender/RendererOGL.h" @@ -77,8 +77,8 @@ class NewRenderer : public RendererEvent { if (!wr_window_new( aWindowId, mSize.width, mSize.height, supportLowPriorityTransactions, - StaticPrefs::WebRenderPictureCaching() && supportPictureCaching, - StaticPrefs::WebRenderStartDebugServer(), compositor->gl(), + gfxPrefs::WebRenderPictureCaching() && supportPictureCaching, + gfxPrefs::WebRenderStartDebugServer(), compositor->gl(), aRenderThread.GetProgramCache() ? aRenderThread.GetProgramCache()->Raw() : nullptr, diff --git a/gfx/ycbcr/yuv_convert.cpp b/gfx/ycbcr/yuv_convert.cpp index 189a893b73533..62191960bf87b 100644 --- a/gfx/ycbcr/yuv_convert.cpp +++ b/gfx/ycbcr/yuv_convert.cpp @@ -18,7 +18,7 @@ #include "yuv_convert.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "libyuv.h" #include "scale_yuv_argb.h" // Header for low level row functions. @@ -77,7 +77,7 @@ void ConvertYCbCrToRGB32(const uint8* y_buf, const uint8* u_buf, // // The function is still fast on some old intel chips. // See Bug 1256475. - bool use_deprecated = StaticPrefs::YCbCrAccurateConversion() || + bool use_deprecated = gfxPrefs::YCbCrAccurateConversion() || (supports_mmx() && supports_sse() && !supports_sse3() && yuv_color_space == YUVColorSpace::BT601); // The deprecated function only support BT601. @@ -292,8 +292,7 @@ void ScaleYCbCrToRGB32(const uint8* y_buf, YUVColorSpace yuv_color_space, ScaleFilter filter) { - bool use_deprecated = - StaticPrefs::YCbCrAccurateConversion() || + bool use_deprecated = gfxPrefs::YCbCrAccurateConversion() || #if defined(XP_WIN) && defined(_M_X64) // libyuv does not support SIMD scaling on win 64bit. See Bug 1295927. supports_sse3() || diff --git a/image/AnimationSurfaceProvider.cpp b/image/AnimationSurfaceProvider.cpp index 91ded7fd6e030..24ee4543d7f9f 100644 --- a/image/AnimationSurfaceProvider.cpp +++ b/image/AnimationSurfaceProvider.cpp @@ -5,7 +5,7 @@ #include "AnimationSurfaceProvider.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "mozilla/gfx/gfxVars.h" #include "nsProxyRelease.h" @@ -35,9 +35,9 @@ AnimationSurfaceProvider::AnimationSurfaceProvider( // enter decode-on-demand mode. IntSize frameSize = aSurfaceKey.Size(); size_t threshold = - (size_t(StaticPrefs::ImageAnimatedDecodeOnDemandThresholdKB()) * 1024) / + (size_t(gfxPrefs::ImageAnimatedDecodeOnDemandThresholdKB()) * 1024) / (sizeof(uint32_t) * frameSize.width * frameSize.height); - size_t batch = StaticPrefs::ImageAnimatedDecodeOnDemandBatchSize(); + size_t batch = gfxPrefs::ImageAnimatedDecodeOnDemandBatchSize(); mFrames.reset( new AnimationFrameRetainedBuffer(threshold, batch, aCurrentFrame)); @@ -407,7 +407,7 @@ void AnimationSurfaceProvider::RequestFrameDiscarding() { static_cast(mFrames.get()); MOZ_ASSERT(!mDecoder->GetFrameRecycler()); - if (StaticPrefs::ImageAnimatedDecodeOnDemandRecycle()) { + if (gfxPrefs::ImageAnimatedDecodeOnDemandRecycle()) { mFrames.reset(new AnimationFrameRecyclingQueue(std::move(*oldFrameQueue))); mDecoder->SetFrameRecycler(this); } else { @@ -464,7 +464,7 @@ bool AnimationSurfaceProvider::ShouldPreferSyncRun() const { MutexAutoLock lock(mDecodingMutex); MOZ_ASSERT(mDecoder); - return mDecoder->ShouldSyncDecode(StaticPrefs::ImageMemDecodeBytesAtATime()); + return mDecoder->ShouldSyncDecode(gfxPrefs::ImageMemDecodeBytesAtATime()); } RawAccessFrameRef AnimationSurfaceProvider::RecycleFrame( diff --git a/image/DecodePool.cpp b/image/DecodePool.cpp index f33df41f72667..d2cf7bcc506e0 100644 --- a/image/DecodePool.cpp +++ b/image/DecodePool.cpp @@ -10,7 +10,6 @@ #include "mozilla/ClearOnShutdown.h" #include "mozilla/DebugOnly.h" #include "mozilla/Monitor.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/TimeStamp.h" #include "nsCOMPtr.h" #include "nsIObserverService.h" @@ -21,6 +20,8 @@ #include "prsystem.h" #include "nsIXULRuntime.h" +#include "gfxPrefs.h" + #include "Decoder.h" #include "IDecodingTask.h" #include "RasterImage.h" @@ -353,7 +354,7 @@ class IOThreadIniter final : public Runnable { DecodePool::DecodePool() : mMutex("image::IOThread") { // Determine the number of threads we want. - int32_t prefLimit = StaticPrefs::ImageMTDecodingLimit(); + int32_t prefLimit = gfxPrefs::ImageMTDecodingLimit(); uint32_t limit; if (prefLimit <= 0) { int32_t numCores = NumberOfCores(); @@ -383,7 +384,7 @@ DecodePool::DecodePool() : mMutex("image::IOThread") { uint32_t idleLimit; // The timeout period before shutting down idle threads. - int32_t prefIdleTimeout = StaticPrefs::ImageMTDecodingIdleTimeout(); + int32_t prefIdleTimeout = gfxPrefs::ImageMTDecodingIdleTimeout(); TimeDuration idleTimeout; if (prefIdleTimeout <= 0) { idleTimeout = TimeDuration::Forever(); diff --git a/image/DecodedSurfaceProvider.cpp b/image/DecodedSurfaceProvider.cpp index a2410e91892d5..710d3016c6bec 100644 --- a/image/DecodedSurfaceProvider.cpp +++ b/image/DecodedSurfaceProvider.cpp @@ -5,7 +5,7 @@ #include "DecodedSurfaceProvider.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "nsProxyRelease.h" #include "Decoder.h" @@ -200,7 +200,7 @@ void DecodedSurfaceProvider::FinishDecoding() { } bool DecodedSurfaceProvider::ShouldPreferSyncRun() const { - return mDecoder->ShouldSyncDecode(StaticPrefs::ImageMemDecodeBytesAtATime()); + return mDecoder->ShouldSyncDecode(gfxPrefs::ImageMemDecodeBytesAtATime()); } } // namespace image diff --git a/image/DecoderFactory.cpp b/image/DecoderFactory.cpp index 83bb69e2eacbc..7ad0f39b8654b 100644 --- a/image/DecoderFactory.cpp +++ b/image/DecoderFactory.cpp @@ -5,6 +5,7 @@ #include "DecoderFactory.h" +#include "gfxPrefs.h" #include "nsMimeTypes.h" #include "mozilla/RefPtr.h" @@ -73,8 +74,7 @@ DecoderType DecoderFactory::GetDecoderType(const char* aMimeType) { type = DecoderType::ICON; // WebP - } else if (!strcmp(aMimeType, IMAGE_WEBP) && - StaticPrefs::ImageWebPEnabled()) { + } else if (!strcmp(aMimeType, IMAGE_WEBP) && gfxPrefs::ImageWebPEnabled()) { type = DecoderType::WEBP; } diff --git a/image/Downscaler.cpp b/image/Downscaler.cpp index 17a7351fc0460..448e23075281c 100644 --- a/image/Downscaler.cpp +++ b/image/Downscaler.cpp @@ -8,7 +8,7 @@ #include #include - +#include "gfxPrefs.h" #include "mozilla/gfx/2D.h" using std::max; diff --git a/image/DownscalingFilter.h b/image/DownscalingFilter.h index 6a2b93c69d5b5..428798302d124 100644 --- a/image/DownscalingFilter.h +++ b/image/DownscalingFilter.h @@ -23,6 +23,7 @@ #include "mozilla/Maybe.h" #include "mozilla/UniquePtr.h" #include "mozilla/gfx/2D.h" +#include "gfxPrefs.h" #ifdef MOZ_ENABLE_SKIA # include "mozilla/gfx/ConvolutionFilter.h" diff --git a/image/FrameAnimator.cpp b/image/FrameAnimator.cpp index 679eb5538baed..ff34fefc7c415 100644 --- a/image/FrameAnimator.cpp +++ b/image/FrameAnimator.cpp @@ -7,10 +7,10 @@ #include "mozilla/Move.h" #include "mozilla/CheckedInt.h" -#include "mozilla/StaticPrefs.h" #include "imgIContainer.h" #include "LookupResult.h" #include "RasterImage.h" +#include "gfxPrefs.h" namespace mozilla { @@ -86,7 +86,7 @@ const gfx::IntRect AnimationState::UpdateStateInternal( } else if (aResult.Type() == MatchType::NOT_FOUND || aResult.Type() == MatchType::PENDING) { if (mHasRequestedDecode) { - MOZ_ASSERT(StaticPrefs::ImageMemAnimatedDiscardable()); + MOZ_ASSERT(gfxPrefs::ImageMemAnimatedDiscardable()); mCompositedFrameInvalid = true; } } @@ -138,7 +138,7 @@ void AnimationState::SetAnimationFrameTime(const TimeStamp& aTime) { } bool AnimationState::MaybeAdvanceAnimationFrameTime(const TimeStamp& aTime) { - if (!StaticPrefs::ImageAnimatedResumeFromLastDisplayed() || + if (!gfxPrefs::ImageAnimatedResumeFromLastDisplayed() || mCurrentAnimationFrameTime >= aTime) { return false; } @@ -379,7 +379,7 @@ RefreshResult FrameAnimator::RequestRefresh(AnimationState& aState, // only advance the frame if the current time is greater than or // equal to the current frame's end time. if (!currentFrame) { - MOZ_ASSERT(StaticPrefs::ImageMemAnimatedDiscardable()); + MOZ_ASSERT(gfxPrefs::ImageMemAnimatedDiscardable()); MOZ_ASSERT(aState.GetHasRequestedDecode() && !aState.GetIsCurrentlyDecoded()); MOZ_ASSERT(aState.mCompositedFrameInvalid); @@ -451,7 +451,7 @@ LookupResult FrameAnimator::GetCompositedFrame(AnimationState& aState, aMarkUsed); if (aState.mCompositedFrameInvalid) { - MOZ_ASSERT(StaticPrefs::ImageMemAnimatedDiscardable()); + MOZ_ASSERT(gfxPrefs::ImageMemAnimatedDiscardable()); MOZ_ASSERT(aState.GetHasRequestedDecode()); MOZ_ASSERT(!aState.GetIsCurrentlyDecoded()); if (result.Type() == MatchType::NOT_FOUND) { diff --git a/image/FrameAnimator.h b/image/FrameAnimator.h index 3c1379801d8dc..649024837fcb1 100644 --- a/image/FrameAnimator.h +++ b/image/FrameAnimator.h @@ -8,13 +8,13 @@ #define mozilla_image_FrameAnimator_h #include "mozilla/Maybe.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/TimeStamp.h" #include "gfxTypes.h" #include "imgFrame.h" #include "nsCOMPtr.h" #include "nsRect.h" #include "SurfaceCache.h" +#include "gfxPrefs.h" namespace mozilla { namespace image { @@ -80,7 +80,7 @@ class AnimationState { * Sets the composited frame as valid or invalid. */ void SetCompositedFrameInvalid(bool aInvalid) { - MOZ_ASSERT(!aInvalid || StaticPrefs::ImageMemAnimatedDiscardable()); + MOZ_ASSERT(!aInvalid || gfxPrefs::ImageMemAnimatedDiscardable()); mCompositedFrameInvalid = aInvalid; } diff --git a/image/IDecodingTask.cpp b/image/IDecodingTask.cpp index aba407d59263e..2b8f641bcdf4d 100644 --- a/image/IDecodingTask.cpp +++ b/image/IDecodingTask.cpp @@ -5,6 +5,7 @@ #include "IDecodingTask.h" +#include "gfxPrefs.h" #include "nsThreadUtils.h" #include "Decoder.h" diff --git a/image/Image.cpp b/image/Image.cpp index 9136fc2884073..06ebeb874ebde 100644 --- a/image/Image.cpp +++ b/image/Image.cpp @@ -4,7 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "Image.h" - +#include "gfxPrefs.h" #include "Layers.h" // for LayerManager #include "nsRefreshDriver.h" #include "nsContentUtils.h" diff --git a/image/ImageFactory.cpp b/image/ImageFactory.cpp index 27f0db4a273a9..dfda640e1dd89 100644 --- a/image/ImageFactory.cpp +++ b/image/ImageFactory.cpp @@ -24,7 +24,7 @@ #include "nsContentUtils.h" #include "nsIScriptSecurityManager.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" namespace mozilla { namespace image { @@ -37,8 +37,8 @@ static uint32_t ComputeImageFlags(nsIURI* uri, const nsCString& aMimeType, nsresult rv; // We default to the static globals. - bool isDiscardable = StaticPrefs::ImageMemDiscardable(); - bool doDecodeImmediately = StaticPrefs::ImageDecodeImmediatelyEnabled(); + bool isDiscardable = gfxPrefs::ImageMemDiscardable(); + bool doDecodeImmediately = gfxPrefs::ImageDecodeImmediatelyEnabled(); // We want UI to be as snappy as possible and not to flicker. Disable // discarding for chrome URLS. @@ -110,6 +110,9 @@ already_AddRefed ImageFactory::CreateImage( nsIRequest* aRequest, ProgressTracker* aProgressTracker, const nsCString& aMimeType, nsIURI* aURI, bool aIsMultiPart, uint32_t aInnerWindowId) { + MOZ_ASSERT(gfxPrefs::SingletonExists(), + "Pref observers should have been initialized already"); + // Compute the image's initialization flags. uint32_t imageFlags = ComputeImageFlags(aURI, aMimeType, aIsMultiPart); diff --git a/image/ImageMemoryReporter.cpp b/image/ImageMemoryReporter.cpp index 1d4ea80307f7e..5792b0cee5ca3 100644 --- a/image/ImageMemoryReporter.cpp +++ b/image/ImageMemoryReporter.cpp @@ -7,7 +7,6 @@ #include "ImageMemoryReporter.h" #include "Image.h" #include "mozilla/layers/SharedSurfacesParent.h" -#include "mozilla/StaticPrefs.h" #include "nsIMemoryReporter.h" #include "nsISupportsImpl.h" @@ -97,7 +96,7 @@ void ImageMemoryReporter::ReportSharedSurface( path.AppendLiteral("/"); } - if (StaticPrefs::ImageMemDebugReporting()) { + if (gfxPrefs::ImageMemDebugReporting()) { path.AppendInt(aExternalId, 16); path.AppendLiteral("/"); } @@ -137,7 +136,7 @@ void ImageMemoryReporter::AppendSharedSurfacePrefix( if (extId) { auto gpuEntry = aSharedSurfaces.mSurfaces.find(extId); - if (StaticPrefs::ImageMemDebugReporting()) { + if (gfxPrefs::ImageMemDebugReporting()) { aPathPrefix.AppendLiteral(", external_id:"); aPathPrefix.AppendInt(extId, 16); if (gpuEntry != aSharedSurfaces.mSurfaces.end()) { diff --git a/image/RasterImage.cpp b/image/RasterImage.cpp index d6ed3713fcbbb..ce362218dd216 100644 --- a/image/RasterImage.cpp +++ b/image/RasterImage.cpp @@ -39,7 +39,6 @@ #include "mozilla/Move.h" #include "mozilla/MemoryReporting.h" #include "mozilla/SizeOfState.h" -#include "mozilla/StaticPrefs.h" #include #include "mozilla/Telemetry.h" #include "mozilla/TimeStamp.h" @@ -49,6 +48,7 @@ #include "GeckoProfiler.h" #include "gfx2DGlue.h" +#include "gfxPrefs.h" #include "nsProperties.h" #include @@ -347,7 +347,7 @@ LookupResult RasterImage::LookupFrame(const IntSize& aSize, uint32_t aFlags, // one. (Or we're sync decoding and the existing decoder hasn't even started // yet.) Trigger decoding so it'll be available next time. MOZ_ASSERT(aPlaybackType != PlaybackType::eAnimated || - StaticPrefs::ImageMemAnimatedDiscardable() || + gfxPrefs::ImageMemAnimatedDiscardable() || !mAnimationState || mAnimationState->KnownFrameCount() < 1, "Animated frames should be locked"); @@ -415,7 +415,7 @@ RasterImage::WillDrawOpaqueNow() { } if (mAnimationState) { - if (!StaticPrefs::ImageMemAnimatedDiscardable()) { + if (!gfxPrefs::ImageMemAnimatedDiscardable()) { // We never discard frames of animated images. return true; } else { @@ -471,7 +471,7 @@ void RasterImage::OnSurfaceDiscardedInternal(bool aAnimatedFramesDiscarded) { MOZ_ASSERT(NS_IsMainThread()); if (aAnimatedFramesDiscarded && mAnimationState) { - MOZ_ASSERT(StaticPrefs::ImageMemAnimatedDiscardable()); + MOZ_ASSERT(gfxPrefs::ImageMemAnimatedDiscardable()); ReleaseImageContainer(); gfx::IntRect rect = mAnimationState->UpdateState(mAnimationFinished, this, mSize); @@ -716,7 +716,7 @@ bool RasterImage::SetMetadata(const ImageMetadata& aMetadata, mAnimationState.emplace(mAnimationMode); mFrameAnimator = MakeUnique(this, mSize); - if (!StaticPrefs::ImageMemAnimatedDiscardable()) { + if (!gfxPrefs::ImageMemAnimatedDiscardable()) { // We don't support discarding animated images (See bug 414259). // Lock the image and throw away the key. LockImage(); @@ -1020,7 +1020,7 @@ RasterImage::GetKeys(nsTArray& keys) { void RasterImage::Discard() { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(CanDiscard(), "Asked to discard but can't"); - MOZ_ASSERT(!mAnimationState || StaticPrefs::ImageMemAnimatedDiscardable(), + MOZ_ASSERT(!mAnimationState || gfxPrefs::ImageMemAnimatedDiscardable(), "Asked to discard for animated image"); // Delete all the decoded frames. @@ -1042,7 +1042,7 @@ void RasterImage::Discard() { bool RasterImage::CanDiscard() { return mAllSourceData && // Can discard animated images if the pref is set - (!mAnimationState || StaticPrefs::ImageMemAnimatedDiscardable()); + (!mAnimationState || gfxPrefs::ImageMemAnimatedDiscardable()); } NS_IMETHODIMP @@ -1320,7 +1320,7 @@ bool RasterImage::CanDownscaleDuringDecode(const IntSize& aSize, // available, this image isn't transient, we have all the source data and know // our size, and the flags allow us to do it. if (!mHasSize || mTransient || !HaveSkia() || - !StaticPrefs::ImageDownscaleDuringDecodeEnabled() || + !gfxPrefs::ImageDownscaleDuringDecodeEnabled() || !(aFlags & imgIContainer::FLAG_HIGH_QUALITY_SCALING)) { return false; } diff --git a/image/SurfaceCache.cpp b/image/SurfaceCache.cpp index 2b928cfa5da61..2cd37b1b4a981 100644 --- a/image/SurfaceCache.cpp +++ b/image/SurfaceCache.cpp @@ -19,12 +19,12 @@ #include "mozilla/Pair.h" #include "mozilla/RefPtr.h" #include "mozilla/StaticMutex.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/StaticPtr.h" #include "mozilla/Tuple.h" #include "nsIMemoryReporter.h" #include "gfx2DGlue.h" #include "gfxPlatform.h" +#include "gfxPrefs.h" #include "imgFrame.h" #include "Image.h" #include "ISurfaceProvider.h" @@ -409,8 +409,7 @@ class ImageSurfaceCache { // Typically an image cache will not have too many size-varying surfaces, so // if we exceed the given threshold, we should consider using a subset. - int32_t thresholdSurfaces = - StaticPrefs::ImageCacheFactor2ThresholdSurfaces(); + int32_t thresholdSurfaces = gfxPrefs::ImageCacheFactor2ThresholdSurfaces(); if (thresholdSurfaces < 0 || mSurfaces.Count() <= static_cast(thresholdSurfaces)) { return; @@ -1056,7 +1055,7 @@ class SurfaceCacheImpl final : public nsIMemoryReporter { // difference between this and UnlockImage.) DoUnlockSurfaces( WrapNotNull(cache), - /* aStaticOnly = */ !StaticPrefs::ImageMemAnimatedDiscardable(), + /* aStaticOnly = */ !gfxPrefs::ImageMemAnimatedDiscardable(), aAutoLock); } @@ -1373,22 +1372,22 @@ void SurfaceCache::Initialize() { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(!sInstance, "Shouldn't initialize more than once"); - // See StaticPrefs for the default values of these preferences. + // See gfxPrefs for the default values of these preferences. // Length of time before an unused surface is removed from the cache, in // milliseconds. uint32_t surfaceCacheExpirationTimeMS = - StaticPrefs::ImageMemSurfaceCacheMinExpirationMS(); + gfxPrefs::ImageMemSurfaceCacheMinExpirationMS(); // What fraction of the memory used by the surface cache we should discard // when we get a memory pressure notification. This value is interpreted as // 1/N, so 1 means to discard everything, 2 means to discard about half of the // memory we're using, and so forth. We clamp it to avoid division by zero. uint32_t surfaceCacheDiscardFactor = - max(StaticPrefs::ImageMemSurfaceCacheDiscardFactor(), 1u); + max(gfxPrefs::ImageMemSurfaceCacheDiscardFactor(), 1u); // Maximum size of the surface cache, in kilobytes. - uint64_t surfaceCacheMaxSizeKB = StaticPrefs::ImageMemSurfaceCacheMaxSizeKB(); + uint64_t surfaceCacheMaxSizeKB = gfxPrefs::ImageMemSurfaceCacheMaxSizeKB(); // A knob determining the actual size of the surface cache. Currently the // cache is (size of main memory) / (surface cache size factor) KB @@ -1399,7 +1398,7 @@ void SurfaceCache::Initialize() { // of memory, which would yield a 64MB cache on this setting. // We clamp this value to avoid division by zero. uint32_t surfaceCacheSizeFactor = - max(StaticPrefs::ImageMemSurfaceCacheSizeFactor(), 1u); + max(gfxPrefs::ImageMemSurfaceCacheSizeFactor(), 1u); // Compute the size of the surface cache. uint64_t memorySize = PR_GetPhysicalMemorySize(); @@ -1637,7 +1636,7 @@ IntSize SurfaceCache::ClampVectorSize(const IntSize& aSize) { // It shouldn't get here if it is significantly larger because // VectorImage::UseSurfaceCacheForSize should prevent us from requesting // a rasterized version of a surface greater than 4x the maximum. - int32_t maxSizeKB = StaticPrefs::ImageCacheMaxRasterizedSVGThresholdKB(); + int32_t maxSizeKB = gfxPrefs::ImageCacheMaxRasterizedSVGThresholdKB(); if (maxSizeKB <= 0) { return aSize; } diff --git a/image/build/nsImageModule.cpp b/image/build/nsImageModule.cpp index 6e5c8103aebf7..a7e0fefabd7ad 100644 --- a/image/build/nsImageModule.cpp +++ b/image/build/nsImageModule.cpp @@ -13,6 +13,7 @@ #include "ShutdownTracker.h" #include "SurfaceCache.h" +#include "gfxPrefs.h" #include "imgLoader.h" using namespace mozilla::image; @@ -25,6 +26,9 @@ nsresult mozilla::image::EnsureModuleInitialized() { return NS_OK; } + // Make sure the preferences are initialized + gfxPrefs::GetSingleton(); + mozilla::image::ShutdownTracker::Initialize(); mozilla::image::ImageFactory::Initialize(); mozilla::image::DecodePool::Initialize(); diff --git a/image/imgFrame.cpp b/image/imgFrame.cpp index 06e6f7856357e..a487024a5df10 100644 --- a/image/imgFrame.cpp +++ b/image/imgFrame.cpp @@ -13,7 +13,7 @@ #include "gfx2DGlue.h" #include "gfxPlatform.h" - +#include "gfxPrefs.h" #include "gfxUtils.h" #include "GeckoProfiler.h" @@ -81,14 +81,14 @@ static bool ShouldUseHeap(const IntSize& aSize, int32_t aStride, // For as long as an animated image is retained, its frames will never be // released to let the OS purge volatile buffers. - if (aIsAnimated && StaticPrefs::ImageMemAnimatedUseHeap()) { + if (aIsAnimated && gfxPrefs::ImageMemAnimatedUseHeap()) { return true; } // Lets us avoid too many small images consuming all of the handles. The // actual allocation checks for overflow. int32_t bufferSize = (aStride * aSize.width) / 1024; - if (bufferSize < StaticPrefs::ImageMemVolatileMinThresholdKB()) { + if (bufferSize < gfxPrefs::ImageMemVolatileMinThresholdKB()) { return true; } @@ -99,7 +99,7 @@ static already_AddRefed AllocateBufferForImage( const IntSize& size, SurfaceFormat format, bool aIsAnimated = false) { int32_t stride = VolatileSurfaceStride(size, format); - if (gfxVars::GetUseWebRenderOrDefault() && StaticPrefs::ImageMemShared()) { + if (gfxVars::GetUseWebRenderOrDefault() && gfxPrefs::ImageMemShared()) { RefPtr newSurf = new SourceSurfaceSharedData(); if (newSurf->Init(size, stride, format)) { return newSurf.forget(); diff --git a/image/imgLoader.cpp b/image/imgLoader.cpp index 2257a23f5df07..f4ef90e971417 100644 --- a/image/imgLoader.cpp +++ b/image/imgLoader.cpp @@ -15,7 +15,6 @@ #include "mozilla/Move.h" #include "mozilla/NullPrincipal.h" #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/ChaosMode.h" #include "mozilla/LoadInfo.h" #include "mozilla/StaticPrefs.h" @@ -56,6 +55,7 @@ #include "nsIMemoryReporter.h" #include "DecoderFactory.h" #include "Image.h" +#include "gfxPrefs.h" #include "prtime.h" #include "ReferrerInfo.h" @@ -86,7 +86,7 @@ class imgMemoryReporter final : public nsIMemoryReporter { layers::CompositorManagerChild* manager = CompositorManagerChild::GetInstance(); - if (!manager || !StaticPrefs::ImageMemDebugReporting()) { + if (!manager || !gfxPrefs::ImageMemDebugReporting()) { layers::SharedSurfacesMemoryReport sharedSurfaces; FinishCollectReports(aHandleReport, aData, aAnonymize, sharedSurfaces); return NS_OK; @@ -263,7 +263,7 @@ class imgMemoryReporter final : public nsIMemoryReporter { summaryTotal += counter; - if (counter.IsNotable() || StaticPrefs::ImageMemDebugReporting()) { + if (counter.IsNotable() || gfxPrefs::ImageMemDebugReporting()) { ReportImage(aHandleReport, aData, aPathPrefix, counter, aSharedSurfaces); } else { @@ -344,7 +344,7 @@ class imgMemoryReporter final : public nsIMemoryReporter { if (counter.Type() == SurfaceMemoryCounterType::NORMAL) { PlaybackType playback = counter.Key().Playback(); if (playback == PlaybackType::eAnimated) { - if (StaticPrefs::ImageMemDebugReporting()) { + if (gfxPrefs::ImageMemDebugReporting()) { surfacePathPrefix.AppendPrintf( " (animation %4u)", uint32_t(counter.Values().FrameIndex())); } else { @@ -1251,8 +1251,8 @@ imgCacheQueue& imgLoader::GetCacheQueue(const ImageCacheKey& aKey) { } void imgLoader::GlobalInit() { - sCacheTimeWeight = StaticPrefs::ImageCacheTimeWeight() / 1000.0; - int32_t cachesize = StaticPrefs::ImageCacheSize(); + sCacheTimeWeight = gfxPrefs::ImageCacheTimeWeight() / 1000.0; + int32_t cachesize = gfxPrefs::ImageCacheSize(); sCacheMaxSize = cachesize > 0 ? cachesize : 0; sMemReporter = new imgMemoryReporter(); diff --git a/image/imgRequest.cpp b/image/imgRequest.cpp index fa9928824a66b..bdb5f463d8cce 100644 --- a/image/imgRequest.cpp +++ b/image/imgRequest.cpp @@ -469,7 +469,7 @@ void imgRequest::AdjustPriorityInternal(int32_t aDelta) { } void imgRequest::BoostPriority(uint32_t aCategory) { - if (!StaticPrefs::ImageLayoutNetworkPriority()) { + if (!gfxPrefs::ImageLayoutNetworkPriority()) { return; } diff --git a/image/test/gtest/Common.cpp b/image/test/gtest/Common.cpp index e79f87dee8c81..b0ef2bdd3fc2f 100644 --- a/image/test/gtest/Common.cpp +++ b/image/test/gtest/Common.cpp @@ -8,7 +8,7 @@ #include #include "gfxPlatform.h" - +#include "gfxPrefs.h" #include "nsDirectoryServiceDefs.h" #include "nsIDirectoryService.h" #include "nsIFile.h" @@ -281,6 +281,7 @@ bool RowHasPixels(SourceSurface* aSurface, int32_t aRow, /////////////////////////////////////////////////////////////////////////////// already_AddRefed CreateTrivialDecoder() { + gfxPrefs::GetSingleton(); DecoderType decoderType = DecoderFactory::GetDecoderType("image/gif"); auto sourceBuffer = MakeNotNull>(); RefPtr decoder = DecoderFactory::CreateAnonymousDecoder( diff --git a/image/test/gtest/TestBlendAnimationFilter.cpp b/image/test/gtest/TestBlendAnimationFilter.cpp index f47fb32001046..3106a38664a7c 100644 --- a/image/test/gtest/TestBlendAnimationFilter.cpp +++ b/image/test/gtest/TestBlendAnimationFilter.cpp @@ -20,6 +20,7 @@ using namespace mozilla::gfx; using namespace mozilla::image; static already_AddRefed CreateTrivialBlendingDecoder() { + gfxPrefs::GetSingleton(); DecoderType decoderType = DecoderFactory::GetDecoderType("image/gif"); DecoderFlags decoderFlags = DefaultDecoderFlags(); SurfaceFlags surfaceFlags = DefaultSurfaceFlags(); diff --git a/image/test/gtest/TestSurfaceCache.cpp b/image/test/gtest/TestSurfaceCache.cpp index 002eaf9fc4d91..8de34894a7000 100644 --- a/image/test/gtest/TestSurfaceCache.cpp +++ b/image/test/gtest/TestSurfaceCache.cpp @@ -11,7 +11,6 @@ #include "ImageFactory.h" #include "mozilla/gfx/2D.h" #include "mozilla/RefPtr.h" -#include "mozilla/StaticPrefs.h" #include "nsIInputStream.h" #include "nsString.h" #include "ProgressTracker.h" @@ -44,7 +43,7 @@ TEST_F(ImageSurfaceCache, Factor2) { // Ensures we meet the threshold for FLAG_SYNC_DECODE_IF_FAST to do sync // decoding without the implications of FLAG_SYNC_DECODE. ASSERT_LT(length, - static_cast(StaticPrefs::ImageMemDecodeBytesAtATime())); + static_cast(gfxPrefs::ImageMemDecodeBytesAtATime())); // Write the data into the image. rv = image->OnImageDataAvailable(nullptr, nullptr, inputStream, 0, @@ -73,7 +72,7 @@ TEST_F(ImageSurfaceCache, Factor2) { // We need the default threshold to be enabled (otherwise we should disable // this test). - int32_t threshold = StaticPrefs::ImageCacheFactor2ThresholdSurfaces(); + int32_t threshold = gfxPrefs::ImageCacheFactor2ThresholdSurfaces(); ASSERT_TRUE(threshold >= 0); // We need to know what the native sizes are, otherwise factor of 2 mode will diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index fbd27e5a177d5..e584d879e01dc 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -39,7 +39,7 @@ #include "nsIScriptSecurityManager.h" #include "nsIPrincipal.h" #include "nsJSUtils.h" - +#include "gfxPrefs.h" #include "nsIXULRuntime.h" #include "GeckoProfiler.h" @@ -1327,6 +1327,8 @@ int XRE_XPCShellMain(int argc, char** argv, char** envp, return 1; } + // Initialize graphics prefs on the main thread, if not already done + gfxPrefs::GetSingleton(); // Initialize e10s check on the main thread, if not already done BrowserTabsRemoteAutostart(); #ifdef XP_WIN diff --git a/layout/base/AccessibleCaretEventHub.cpp b/layout/base/AccessibleCaretEventHub.cpp index a785b8327c115..8decc59b73a5e 100644 --- a/layout/base/AccessibleCaretEventHub.cpp +++ b/layout/base/AccessibleCaretEventHub.cpp @@ -9,7 +9,7 @@ #include "AccessibleCaretLogger.h" #include "AccessibleCaretManager.h" #include "Layers.h" - +#include "gfxPrefs.h" #include "mozilla/AutoRestore.h" #include "mozilla/MouseEvents.h" #include "mozilla/PresShell.h" @@ -563,7 +563,7 @@ void AccessibleCaretEventHub::LaunchLongTapInjector() { return; } - int32_t longTapDelay = StaticPrefs::UiClickHoldContextMenusDelay(); + int32_t longTapDelay = gfxPrefs::UiClickHoldContextMenusDelay(); mLongTapInjectorTimer->InitWithNamedFuncCallback( FireLongTap, this, longTapDelay, nsITimer::TYPE_ONE_SHOT, "AccessibleCaretEventHub::LaunchLongTapInjector"); diff --git a/layout/base/MobileViewportManager.cpp b/layout/base/MobileViewportManager.cpp index f85c72f8b2da1..8fc3cab153f62 100644 --- a/layout/base/MobileViewportManager.cpp +++ b/layout/base/MobileViewportManager.cpp @@ -6,6 +6,7 @@ #include "MobileViewportManager.h" +#include "gfxPrefs.h" #include "LayersLogging.h" #include "mozilla/PresShell.h" #include "mozilla/dom/Document.h" diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index fb4d8f8feef37..296b68cca3d99 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -39,6 +39,7 @@ #endif #include "gfxContext.h" +#include "gfxPrefs.h" #include "gfxUserFontSet.h" #include "nsContentList.h" #include "nsPresContext.h" @@ -3396,7 +3397,7 @@ static void ScrollToShowRect(PresShell* aPresShell, bool smoothScroll = (aScrollFlags & ScrollFlags::ScrollSmooth) || ((aScrollFlags & ScrollFlags::ScrollSmoothAuto) && autoBehaviorIsSmooth); - if (StaticPrefs::ScrollBehaviorEnabled() && smoothScroll) { + if (gfxPrefs::ScrollBehaviorEnabled() && smoothScroll) { scrollMode = ScrollMode::SmoothMsd; } nsIFrame* frame = do_QueryFrame(aFrameAsScrollable); @@ -5105,7 +5106,7 @@ void PresShell::AddCanvasBackgroundColorItem( bool forceUnscrolledItem = nsLayoutUtils::UsesAsyncScrolling(aFrame) && NS_GET_A(bgcolor) == 255; if ((aFlags & AddCanvasBackgroundColorFlags::AddForSubDocument) && - StaticPrefs::LayoutUseContainersForRootFrames()) { + gfxPrefs::LayoutUseContainersForRootFrames()) { // If we're using ContainerLayers for a subdoc, then any items we add here // will still be scrolled (since we're inside the container at this point), // so don't bother and we will do it manually later. @@ -6018,7 +6019,7 @@ void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion, return; } - if (StaticPrefs::APZKeyboardEnabled()) { + if (gfxPrefs::APZKeyboardEnabled()) { // Update the focus target for async keyboard scrolling. This will be // forwarded to APZ by nsDisplayList::PaintRoot. We need to to do this // before we enter the paint phase because dispatching eVoid events can diff --git a/layout/base/TouchManager.cpp b/layout/base/TouchManager.cpp index 2b79b9537848e..209489a64b686 100644 --- a/layout/base/TouchManager.cpp +++ b/layout/base/TouchManager.cpp @@ -7,6 +7,7 @@ #include "TouchManager.h" +#include "gfxPrefs.h" #include "mozilla/dom/EventTarget.h" #include "mozilla/PresShell.h" #include "nsIFrame.h" diff --git a/layout/base/ZoomConstraintsClient.cpp b/layout/base/ZoomConstraintsClient.cpp index ab3affc571420..40073162fc20d 100644 --- a/layout/base/ZoomConstraintsClient.cpp +++ b/layout/base/ZoomConstraintsClient.cpp @@ -7,13 +7,13 @@ #include "ZoomConstraintsClient.h" #include +#include "gfxPrefs.h" #include "LayersLogging.h" #include "mozilla/layers/APZCCallbackHelper.h" #include "mozilla/layers/ScrollableLayerGuid.h" #include "mozilla/layers/ZoomConstraints.h" #include "mozilla/Preferences.h" #include "mozilla/PresShell.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/dom/Document.h" #include "mozilla/dom/Event.h" #include "nsIFrame.h" @@ -151,8 +151,8 @@ ZoomConstraintsClient::Observe(nsISupports* aSubject, const char* aTopic, } else if (NS_PREF_CHANGED.EqualsASCII(aTopic)) { ZCC_LOG("Got a pref-change event in %p\n", this); // We need to run this later because all the pref change listeners need - // to execute before we can be guaranteed that - // StaticPrefs::ForceUserScalable() returns the updated value. + // to execute before we can be guaranteed that gfxPrefs::ForceUserScalable() + // returns the updated value. RefPtr> event = NewRunnableMethod("ZoomConstraintsClient::RefreshZoomConstraints", this, @@ -173,7 +173,7 @@ static mozilla::layers::ZoomConstraints ComputeZoomConstraintsFromViewportInfo( constraints.mAllowZoom = aViewportInfo.IsZoomAllowed() && nsLayoutUtils::AllowZoomingForDocument(aDocument); constraints.mAllowDoubleTapZoom = - constraints.mAllowZoom && StaticPrefs::APZAllowDoubleTapZooming(); + constraints.mAllowZoom && gfxPrefs::APZAllowDoubleTapZooming(); if (constraints.mAllowZoom) { constraints.mMinZoom.scale = aViewportInfo.GetMinZoom().scale; constraints.mMaxZoom.scale = aViewportInfo.GetMaxZoom().scale; diff --git a/layout/base/gtest/TestAccessibleCaretEventHub.cpp b/layout/base/gtest/TestAccessibleCaretEventHub.cpp index b4859b3235a73..750bf988ef4f5 100644 --- a/layout/base/gtest/TestAccessibleCaretEventHub.cpp +++ b/layout/base/gtest/TestAccessibleCaretEventHub.cpp @@ -11,7 +11,7 @@ #include #include "AccessibleCaretManager.h" - +#include "gfxPrefs.h" #include "mozilla/AccessibleCaretEventHub.h" #include "mozilla/BasicEvents.h" #include "mozilla/MouseEvents.h" diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 3c0f3ca7ea43b..396450f5bbe10 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -63,6 +63,7 @@ #include "nsIDocShell.h" #include "nsIWidget.h" #include "gfxMatrix.h" +#include "gfxPrefs.h" #include "gfxTypes.h" #include "nsTArray.h" #include "mozilla/dom/HTMLCanvasElement.h" @@ -114,7 +115,6 @@ #include "nsIContentViewer.h" #include "LayersLogging.h" #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include "nsFrameSelection.h" #include "FrameLayerBuilder.h" #include "mozilla/layers/APZUtils.h" // for apz::CalculatePendingDisplayPort @@ -541,14 +541,14 @@ bool nsLayoutUtils::IsAnimationLoggingEnabled() { bool nsLayoutUtils::AreRetainedDisplayListsEnabled() { #ifdef MOZ_WIDGET_ANDROID - return StaticPrefs::LayoutRetainDisplayList(); + return gfxPrefs::LayoutRetainDisplayList(); #else if (XRE_IsContentProcess()) { - return StaticPrefs::LayoutRetainDisplayList(); + return gfxPrefs::LayoutRetainDisplayList(); } if (XRE_IsE10sParentProcess()) { - return StaticPrefs::LayoutRetainDisplayListChrome(); + return gfxPrefs::LayoutRetainDisplayListChrome(); } // Retained display lists require e10s. @@ -756,7 +756,7 @@ bool nsLayoutUtils::AllowZoomingForDocument( // True if we allow zooming for all documents on this platform, or if we are // in RDM and handling meta viewports, which force zoom under some // circumstances. - return StaticPrefs::APZAllowZooming() || + return gfxPrefs::APZAllowZooming() || (aDocument && aDocument->InRDMPane() && nsLayoutUtils::ShouldHandleMetaViewport(aDocument)); } @@ -769,7 +769,7 @@ float nsLayoutUtils::GetCurrentAPZResolutionScale(PresShell* aPresShell) { // supported texture size. The result is in app units. static nscoord GetMaxDisplayPortSize(nsIContent* aContent, nsPresContext* aFallbackPrescontext) { - MOZ_ASSERT(!StaticPrefs::LayersTilesEnabled(), + MOZ_ASSERT(!gfxPrefs::LayersTilesEnabled(), "Do not clamp displayports if tiling is enabled"); // Pick a safe maximum displayport size for sanity purposes. This is the @@ -906,7 +906,7 @@ static nsRect GetDisplayPortFromMarginsData( if (presShell->IsDisplayportSuppressed()) { alignment = ScreenSize(1, 1); - } else if (StaticPrefs::LayersTilesEnabled()) { + } else if (gfxPrefs::LayersTilesEnabled()) { // Don't align to tiles if they are too large, because we could expand // the displayport by a lot which can take more paint time. It's a tradeoff // though because if we don't align to tiles we have more waste on upload. @@ -928,7 +928,7 @@ static nsRect GetDisplayPortFromMarginsData( alignment.height = 128; } - if (StaticPrefs::LayersTilesEnabled()) { + if (gfxPrefs::LayersTilesEnabled()) { // Expand the rect by the margins screenRect.Inflate(aMarginsData->mMargins); } else { @@ -1048,7 +1048,7 @@ bool nsLayoutUtils::ShouldDisableApzForElement(nsIContent* aContent) { if (!doc) { return false; } - return StaticPrefs::APZDisableForScrollLinkedEffects() && + return gfxPrefs::APZDisableForScrollLinkedEffects() && doc->HasScrollLinkedEffect(); } @@ -1140,7 +1140,7 @@ static bool GetDisplayPortImpl( result = GetDisplayPortFromMarginsData(aContent, marginsData, aMultiplier); } - if (!StaticPrefs::LayersTilesEnabled()) { + if (!gfxPrefs::LayersTilesEnabled()) { // Perform the desired error handling if the displayport dimensions // exceeds the maximum allowed size nscoord maxSize = GetMaxDisplayPortSize(aContent, nullptr); @@ -1173,8 +1173,8 @@ static void TranslateFromScrollPortToScrollFrame(nsIContent* aContent, bool nsLayoutUtils::GetDisplayPort( nsIContent* aContent, nsRect* aResult, RelativeTo aRelativeTo /* = RelativeTo::ScrollPort */) { - float multiplier = StaticPrefs::UseLowPrecisionBuffer() - ? 1.0f / StaticPrefs::LowPrecisionResolution() + float multiplier = gfxPrefs::UseLowPrecisionBuffer() + ? 1.0f / gfxPrefs::LowPrecisionResolution() : 1.0f; bool usingDisplayPort = GetDisplayPortImpl(aContent, aResult, multiplier); if (aResult && usingDisplayPort && aRelativeTo == RelativeTo::ScrollFrame) { @@ -1290,7 +1290,7 @@ bool nsLayoutUtils::SetDisplayPortMargins(nsIContent* aContent, GetHighResolutionDisplayPort(aContent, &newDisplayPort); MOZ_ASSERT(hasDisplayPort); - if (StaticPrefs::LayoutUseContainersForRootFrames()) { + if (gfxPrefs::LayoutUseContainersForRootFrames()) { nsIFrame* rootScrollFrame = aPresShell->GetRootScrollFrame(); if (rootScrollFrame && aContent == rootScrollFrame->GetContent() && nsLayoutUtils::UsesAsyncScrolling(rootScrollFrame)) { @@ -1366,7 +1366,7 @@ void nsLayoutUtils::SetDisplayPortBaseIfNotSet(nsIContent* aContent, bool nsLayoutUtils::GetCriticalDisplayPort(nsIContent* aContent, nsRect* aResult) { - if (StaticPrefs::UseLowPrecisionBuffer()) { + if (gfxPrefs::UseLowPrecisionBuffer()) { return GetDisplayPortImpl(aContent, aResult, 1.0f); } return false; @@ -1378,7 +1378,7 @@ bool nsLayoutUtils::HasCriticalDisplayPort(nsIContent* aContent) { bool nsLayoutUtils::GetHighResolutionDisplayPort(nsIContent* aContent, nsRect* aResult) { - if (StaticPrefs::UseLowPrecisionBuffer()) { + if (gfxPrefs::UseLowPrecisionBuffer()) { return GetCriticalDisplayPort(aContent, aResult); } return GetDisplayPort(aContent, aResult); @@ -3806,7 +3806,7 @@ nsresult nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext, // This calls BuildDisplayListForStacking context on a subset of the // viewport. if (shouldAttemptPartialUpdate) { - if (StaticPrefs::LayoutVerifyRetainDisplayList()) { + if (gfxPrefs::LayoutVerifyRetainDisplayList()) { beforeMergeChecker.Set(&list, "BM"); } updateState = retainedBuilder->AttemptPartialUpdate( @@ -3818,9 +3818,9 @@ nsresult nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext, } if ((updateState != PartialUpdateResult::Failed) && - (StaticPrefs::LayoutDisplayListBuildTwice() || afterMergeChecker)) { + (gfxPrefs::LayoutDisplayListBuildTwice() || afterMergeChecker)) { updateState = PartialUpdateResult::Failed; - if (StaticPrefs::LayersDrawFPS()) { + if (gfxPrefs::LayersDrawFPS()) { if (RefPtr lm = builder.GetWidgetLayerManager()) { if (PaintTiming* pt = ClientLayerManager::MaybeGetPaintTiming(lm)) { pt->dl2Ms() = (TimeStamp::Now() - dlStart).ToMilliseconds(); @@ -3872,7 +3872,7 @@ nsresult nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext, builder.SetIsBuilding(false); builder.IncrementPresShellPaintCount(presShell); - if (StaticPrefs::LayersDrawFPS()) { + if (gfxPrefs::LayersDrawFPS()) { if (RefPtr lm = builder.GetWidgetLayerManager()) { if (PaintTiming* pt = ClientLayerManager::MaybeGetPaintTiming(lm)) { pt->dlMs() = (TimeStamp::Now() - dlStart).ToMilliseconds(); @@ -3980,7 +3980,7 @@ nsresult nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext, presShell->EndPaint(); builder.Check(); - if (StaticPrefs::GfxLoggingPaintedPixelCountEnabled()) { + if (gfxPrefs::GfxLoggingPaintedPixelCountEnabled()) { TimeStamp now = TimeStamp::Now(); float rasterizeTime = (now - paintStart).ToMilliseconds(); uint32_t pixelCount = layerManager->GetAndClearPaintedPixelCount(); @@ -4036,7 +4036,7 @@ nsresult nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext, } #ifdef MOZ_DUMP_PAINTING - if (StaticPrefs::DumpClientLayers()) { + if (gfxPrefs::DumpClientLayers()) { std::stringstream ss; FrameLayerBuilder::DumpRetainedLayerTree(layerManager, ss, false); print_stderr(ss); @@ -8602,7 +8602,7 @@ void nsLayoutUtils::LogAdditionalTestData(nsDisplayListBuilder* aBuilder, /* static */ bool nsLayoutUtils::IsAPZTestLoggingEnabled() { - return StaticPrefs::APZTestLoggingEnabled(); + return gfxPrefs::APZTestLoggingEnabled(); } //////////////////////////////////////// @@ -8885,7 +8885,7 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata( // or the critical displayport) for test purposes. if (IsAPZTestLoggingEnabled()) { LogTestDataForPaint(aLayerManager, scrollId, "displayport", - StaticPrefs::UseLowPrecisionBuffer() + gfxPrefs::UseLowPrecisionBuffer() ? metrics.GetCriticalDisplayPort() : metrics.GetDisplayPort()); } @@ -9140,7 +9140,7 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata( aScrollFrame ? aScrollFrame : aForFrame, isRootContentDocRootScrollFrame, metrics)); - if (StaticPrefs::APZPrintTree() || StaticPrefs::APZTestLoggingEnabled()) { + if (gfxPrefs::APZPrintTree() || gfxPrefs::APZTestLoggingEnabled()) { if (nsIContent* content = frameForCompositionBoundsCalculation->GetContent()) { nsAutoString contentDescription; @@ -9206,15 +9206,15 @@ Maybe nsLayoutUtils::GetRootMetadata( // want the root container layer to have metrics. If the parent process is // using XUL windows, there is no root scrollframe, and without explicitly // creating metrics there will be no guaranteed top-level APZC. - bool addMetrics = StaticPrefs::LayoutUseContainersForRootFrames() || + bool addMetrics = gfxPrefs::LayoutUseContainersForRootFrames() || (XRE_IsParentProcess() && !presShell->GetRootScrollFrame()); // Add metrics if there are none in the layer tree with the id (create an id // if there isn't one already) of the root scroll frame/root content. - bool ensureMetricsForRootId = - nsLayoutUtils::AsyncPanZoomEnabled(frame) && - !StaticPrefs::LayoutUseContainersForRootFrames() && - aBuilder->IsPaintingToWindow() && !presContext->GetParentPresContext(); + bool ensureMetricsForRootId = nsLayoutUtils::AsyncPanZoomEnabled(frame) && + !gfxPrefs::LayoutUseContainersForRootFrames() && + aBuilder->IsPaintingToWindow() && + !presContext->GetParentPresContext(); nsIContent* content = nullptr; nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame(); @@ -9894,8 +9894,8 @@ bool nsLayoutUtils::ShouldHandleMetaViewport(const Document* aDocument) { MOZ_ASSERT(metaViewportOverride == nsIDocShell::META_VIEWPORT_OVERRIDE_NONE); // The META_VIEWPORT_OVERRIDE_NONE case means that there is no override - // and we rely solely on the StaticPrefs. - return StaticPrefs::MetaViewportEnabled(); + // and we rely solely on the gfxPrefs. + return gfxPrefs::MetaViewportEnabled(); } } diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 7d044a7d03bbe..6f188341e5ff1 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -66,7 +66,7 @@ #include "LayerUserData.h" #include "ClientLayerManager.h" #include "mozilla/dom/NotifyPaintEvent.h" - +#include "gfxPrefs.h" #include "nsIDOMChromeWindow.h" #include "nsFrameLoader.h" #include "nsContentUtils.h" @@ -339,6 +339,10 @@ bool nsPresContext::IsChromeOriginImage() const { } void nsPresContext::GetDocumentColorPreferences() { + // Make sure the preferences are initialized. In the normal run, + // they would already be, because gfxPlatform would have been created, + // but in some reference tests, that is not the case. + gfxPrefs::GetSingleton(); PreferenceSheet::EnsureInitialized(); } diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 7eed0b35aebc4..a826b25386886 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -64,7 +64,7 @@ #include "nsISimpleEnumerator.h" #include "nsJSEnvironment.h" #include "mozilla/Telemetry.h" - +#include "gfxPrefs.h" #include "BackgroundChild.h" #include "mozilla/ipc/PBackgroundChild.h" #include "mozilla/layout/VsyncChild.h" @@ -990,6 +990,9 @@ static void CreateVsyncRefreshTimer() { MOZ_ASSERT(NS_IsMainThread()); PodArrayZero(sJankLevels); + // Sometimes, gfxPrefs is not initialized here. Make sure the gfxPrefs is + // ready. + gfxPrefs::GetSingleton(); if (gfxPlatform::IsInLayoutAsapMode()) { return; @@ -1859,7 +1862,7 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) { // We want to process any pending APZ metrics ahead of their positions // in the queue. This will prevent us from spending precious time // painting a stale displayport. - if (StaticPrefs::APZPeekMessages()) { + if (gfxPrefs::APZPeekMessages()) { nsLayoutUtils::UpdateDisplayPortMarginsFromPendingMessages(); } @@ -2134,7 +2137,7 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) { NS_ASSERTION(mInRefresh, "Still in refresh"); if (mPresContext->IsRoot() && XRE_IsContentProcess() && - StaticPrefs::AlwaysPaint()) { + gfxPrefs::AlwaysPaint()) { ScheduleViewManagerFlush(); } diff --git a/layout/forms/nsButtonFrameRenderer.cpp b/layout/forms/nsButtonFrameRenderer.cpp index 8fec7d6d8ac3c..91f7b75f0f3b1 100644 --- a/layout/forms/nsButtonFrameRenderer.cpp +++ b/layout/forms/nsButtonFrameRenderer.cpp @@ -18,7 +18,7 @@ #include "mozilla/EventStates.h" #include "mozilla/dom/Element.h" #include "Layers.h" - +#include "gfxPrefs.h" #include "gfxUtils.h" #include "mozilla/layers/RenderRootStateManager.h" diff --git a/layout/generic/ScrollAnimationBezierPhysics.cpp b/layout/generic/ScrollAnimationBezierPhysics.cpp index cfc0fa41de4bf..474929e22de1f 100644 --- a/layout/generic/ScrollAnimationBezierPhysics.cpp +++ b/layout/generic/ScrollAnimationBezierPhysics.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "ScrollAnimationBezierPhysics.h" +#include "gfxPrefs.h" using namespace mozilla; @@ -92,9 +93,9 @@ void ScrollAnimationBezierPhysics::InitTimingFunction( SMILKeySpline& aTimingFunction, nscoord aCurrentPos, nscoord aCurrentVelocity, nscoord aDestination) { if (aDestination == aCurrentPos || - StaticPrefs::SmoothScrollCurrentVelocityWeighting() == 0) { + gfxPrefs::SmoothScrollCurrentVelocityWeighting() == 0) { aTimingFunction.Init( - 0, 0, 1 - StaticPrefs::SmoothScrollStopDecelerationWeighting(), 1); + 0, 0, 1 - gfxPrefs::SmoothScrollStopDecelerationWeighting(), 1); return; } @@ -103,11 +104,11 @@ void ScrollAnimationBezierPhysics::InitTimingFunction( aCurrentVelocity * (mDuration / oneSecond) / (aDestination - aCurrentPos); double normalization = sqrt(1.0 + slope * slope); double dt = - 1.0 / normalization * StaticPrefs::SmoothScrollCurrentVelocityWeighting(); - double dxy = slope / normalization * - StaticPrefs::SmoothScrollCurrentVelocityWeighting(); + 1.0 / normalization * gfxPrefs::SmoothScrollCurrentVelocityWeighting(); + double dxy = + slope / normalization * gfxPrefs::SmoothScrollCurrentVelocityWeighting(); aTimingFunction.Init( - dt, dxy, 1 - StaticPrefs::SmoothScrollStopDecelerationWeighting(), 1); + dt, dxy, 1 - gfxPrefs::SmoothScrollStopDecelerationWeighting(), 1); } nsPoint ScrollAnimationBezierPhysics::PositionAt(const TimeStamp& aTime) { diff --git a/layout/generic/ScrollAnimationMSDPhysics.cpp b/layout/generic/ScrollAnimationMSDPhysics.cpp index 9da4af1984f1e..470c940efbd5e 100644 --- a/layout/generic/ScrollAnimationMSDPhysics.cpp +++ b/layout/generic/ScrollAnimationMSDPhysics.cpp @@ -5,15 +5,16 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "ScrollAnimationMSDPhysics.h" +#include "gfxPrefs.h" using namespace mozilla; ScrollAnimationMSDPhysics::ScrollAnimationMSDPhysics(const nsPoint& aStartPos) : mStartPos(aStartPos), - mModelX(0, 0, 0, - StaticPrefs::SmoothScrollMSDPhysicsRegularSpringConstant(), 1), - mModelY(0, 0, 0, - StaticPrefs::SmoothScrollMSDPhysicsRegularSpringConstant(), 1), + mModelX(0, 0, 0, gfxPrefs::SmoothScrollMSDPhysicsRegularSpringConstant(), + 1), + mModelY(0, 0, 0, gfxPrefs::SmoothScrollMSDPhysicsRegularSpringConstant(), + 1), mIsFirstIteration(true) {} void ScrollAnimationMSDPhysics::Update(const TimeStamp& aTime, @@ -56,7 +57,7 @@ double ScrollAnimationMSDPhysics::ComputeSpringConstant( if (!mPreviousEventTime) { mPreviousEventTime = aTime; mPreviousDelta = TimeDuration(); - return StaticPrefs::SmoothScrollMSDPhysicsMotionBeginSpringConstant(); + return gfxPrefs::SmoothScrollMSDPhysicsMotionBeginSpringConstant(); } TimeDuration delta = aTime - mPreviousEventTime; @@ -66,24 +67,22 @@ double ScrollAnimationMSDPhysics::ComputeSpringConstant( mPreviousDelta = delta; double deltaMS = delta.ToMilliseconds(); - if (deltaMS >= - StaticPrefs::SmoothScrollMSDPhysicsContinuousMotionMaxDeltaMS()) { - return StaticPrefs::SmoothScrollMSDPhysicsMotionBeginSpringConstant(); + if (deltaMS >= gfxPrefs::SmoothScrollMSDPhysicsContinuousMotionMaxDeltaMS()) { + return gfxPrefs::SmoothScrollMSDPhysicsMotionBeginSpringConstant(); } if (previousDelta && - deltaMS >= StaticPrefs::SmoothScrollMSDPhysicsSlowdownMinDeltaMS() && - deltaMS >= - previousDelta.ToMilliseconds() * - StaticPrefs::SmoothScrollMSDPhysicsSlowdownMinDeltaRatio()) { + deltaMS >= gfxPrefs::SmoothScrollMSDPhysicsSlowdownMinDeltaMS() && + deltaMS >= previousDelta.ToMilliseconds() * + gfxPrefs::SmoothScrollMSDPhysicsSlowdownMinDeltaRatio()) { // The rate of events has slowed (the time delta between events has // increased) enough that we think that the current scroll motion is coming // to a stop. Use a stiffer spring in order to reach the destination more // quickly. - return StaticPrefs::SmoothScrollMSDPhysicsSlowdownSpringConstant(); + return gfxPrefs::SmoothScrollMSDPhysicsSlowdownSpringConstant(); } - return StaticPrefs::SmoothScrollMSDPhysicsRegularSpringConstant(); + return gfxPrefs::SmoothScrollMSDPhysicsRegularSpringConstant(); } void ScrollAnimationMSDPhysics::SimulateUntil(const TimeStamp& aTime) { diff --git a/layout/generic/ScrollSnap.cpp b/layout/generic/ScrollSnap.cpp index df70bc8785f1c..e80c4d9b77605 100644 --- a/layout/generic/ScrollSnap.cpp +++ b/layout/generic/ScrollSnap.cpp @@ -7,7 +7,7 @@ #include "ScrollSnap.h" #include "FrameMetrics.h" - +#include "gfxPrefs.h" #include "mozilla/Maybe.h" #include "mozilla/Preferences.h" #include "nsLineLayout.h" @@ -333,7 +333,7 @@ Maybe ScrollSnapUtils::GetSnapPointForDestination( bool snapped = false; nsPoint finalPos = calcSnapPoints.GetBestEdge(); - nscoord proximityThreshold = StaticPrefs::ScrollSnapProximityThreshold(); + nscoord proximityThreshold = gfxPrefs::ScrollSnapProximityThreshold(); proximityThreshold = nsPresContext::CSSPixelsToAppUnits(proximityThreshold); if (aSnapInfo.mScrollSnapStrictnessY == StyleScrollSnapStrictness::Proximity && diff --git a/layout/generic/ScrollVelocityQueue.cpp b/layout/generic/ScrollVelocityQueue.cpp index b5a75fc437e15..b3d07744c13a7 100644 --- a/layout/generic/ScrollVelocityQueue.cpp +++ b/layout/generic/ScrollVelocityQueue.cpp @@ -6,7 +6,7 @@ #include "ScrollVelocityQueue.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "nsPresContext.h" #include "nsRefreshDriver.h" @@ -14,8 +14,8 @@ namespace mozilla { namespace layout { void ScrollVelocityQueue::Sample(const nsPoint& aScrollPosition) { - float flingSensitivity = StaticPrefs::ScrollSnapPredictionSensitivity(); - int maxVelocity = StaticPrefs::ScrollSnapPredictionMaxVelocity(); + float flingSensitivity = gfxPrefs::ScrollSnapPredictionSensitivity(); + int maxVelocity = gfxPrefs::ScrollSnapPredictionMaxVelocity(); maxVelocity = nsPresContext::CSSPixelsToAppUnits(maxVelocity); int maxOffset = maxVelocity * flingSensitivity; TimeStamp currentRefreshTime = @@ -24,7 +24,7 @@ void ScrollVelocityQueue::Sample(const nsPoint& aScrollPosition) { mAccumulator = nsPoint(); } else { uint32_t durationMs = (currentRefreshTime - mSampleTime).ToMilliseconds(); - if (durationMs > StaticPrefs::APZVelocityRelevanceTime()) { + if (durationMs > gfxPrefs::APZVelocityRelevanceTime()) { mAccumulator = nsPoint(); mQueue.Clear(); } else if (durationMs == 0) { @@ -54,7 +54,7 @@ void ScrollVelocityQueue::TrimQueue() { uint32_t timeDelta = (currentRefreshTime - mSampleTime).ToMilliseconds(); for (int i = mQueue.Length() - 1; i >= 0; i--) { timeDelta += mQueue[i].first; - if (timeDelta >= StaticPrefs::APZVelocityRelevanceTime()) { + if (timeDelta >= gfxPrefs::APZVelocityRelevanceTime()) { // The rest of the samples have expired and should be dropped for (; i >= 0; i--) { mQueue.RemoveElementAt(0); diff --git a/layout/generic/nsBulletFrame.cpp b/layout/generic/nsBulletFrame.cpp index f95490197cff5..6f9b88caf0dfa 100644 --- a/layout/generic/nsBulletFrame.cpp +++ b/layout/generic/nsBulletFrame.cpp @@ -10,7 +10,7 @@ #include "gfx2DGlue.h" #include "gfxContext.h" - +#include "gfxPrefs.h" #include "gfxUtils.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/PathHelpers.h" diff --git a/layout/generic/nsCanvasFrame.h b/layout/generic/nsCanvasFrame.h index 6f023d269584e..d84994fcbb758 100644 --- a/layout/generic/nsCanvasFrame.h +++ b/layout/generic/nsCanvasFrame.h @@ -16,6 +16,7 @@ #include "nsIPopupContainer.h" #include "nsDisplayList.h" #include "nsIAnonymousContentCreator.h" +#include "gfxPrefs.h" class nsPresContext; class gfxContext; diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index a994738ba16f9..c76e025aa823f 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -90,6 +90,7 @@ #include "RetainedDisplayListBuilder.h" #include "gfxContext.h" +#include "gfxPrefs.h" #include "nsAbsoluteContainingBlock.h" #include "StickyScrollContainer.h" #include "nsFontInflationData.h" @@ -1084,7 +1085,7 @@ void nsIFrame::MarkNeedsDisplayItemRebuild() { RetainedDisplayListData* data = GetOrSetRetainedDisplayListData(rootFrame); - if (data->ModifiedFramesCount() > StaticPrefs::LayoutRebuildFrameLimit()) { + if (data->ModifiedFramesCount() > gfxPrefs::LayoutRebuildFrameLimit()) { // If the modified frames count is above the rebuild limit, mark the root // frame modified, and stop marking additional frames modified. data->AddModifiedFrame(rootFrame); @@ -3254,7 +3255,7 @@ void nsIFrame::BuildDisplayListForStackingContext( set.Outlines()->DeleteAll(aBuilder); } - if (hasOverrideDirtyRect && StaticPrefs::LayoutDisplayListShowArea()) { + if (hasOverrideDirtyRect && gfxPrefs::LayoutDisplayListShowArea()) { nsDisplaySolidColor* color = MakeDisplayItem( aBuilder, this, dirtyRect + aBuilder->GetCurrentFrameOffsetToReferenceFrame(), diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index a0e125429c3ee..20cb5be0600f5 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -61,7 +61,7 @@ #include "nsIFrameInlines.h" #include "nsILayoutHistoryState.h" #include "gfxPlatform.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "ScrollAnimationPhysics.h" #include "ScrollAnimationBezierPhysics.h" #include "ScrollAnimationMSDPhysics.h" @@ -1639,12 +1639,12 @@ class ScrollFrameHelper::AsyncSmoothMSDScroll final nsPresContext* aPresContext) : mXAxisModel(aInitialPosition.x, aInitialDestination.x, aInitialVelocity.width, - StaticPrefs::ScrollBehaviorSpringConstant(), - StaticPrefs::ScrollBehaviorDampingRatio()), + gfxPrefs::ScrollBehaviorSpringConstant(), + gfxPrefs::ScrollBehaviorDampingRatio()), mYAxisModel(aInitialPosition.y, aInitialDestination.y, aInitialVelocity.height, - StaticPrefs::ScrollBehaviorSpringConstant(), - StaticPrefs::ScrollBehaviorDampingRatio()), + gfxPrefs::ScrollBehaviorSpringConstant(), + gfxPrefs::ScrollBehaviorDampingRatio()), mRange(aRange), mLastRefreshTime(aStartTime), mCallee(nullptr), @@ -1928,7 +1928,7 @@ void ScrollFrameHelper::AsyncScroll::InitSmoothScroll( // Read preferences only on first iteration or for a different event origin. if (!mAnimationPhysics || aOrigin != mOrigin) { mOrigin = aOrigin; - if (StaticPrefs::SmoothScrollMSDPhysicsEnabled()) { + if (gfxPrefs::SmoothScrollMSDPhysicsEnabled()) { mAnimationPhysics = MakeUnique(aInitialPosition); } else { @@ -2037,7 +2037,7 @@ ScrollFrameHelper::ScrollFrameHelper(nsContainerFrame* aOuter, bool aIsRoot) EnsureFrameVisPrefsCached(); - if (IsAlwaysActive() && StaticPrefs::LayersTilesEnabled() && + if (IsAlwaysActive() && gfxPrefs::LayersTilesEnabled() && !nsLayoutUtils::UsesAsyncScrolling(mOuter) && mOuter->GetContent()) { // If we have tiling but no APZ, then set a 0-margin display port on // active scroll containers so that we paint by whole tile increments @@ -2269,7 +2269,7 @@ void ScrollFrameHelper::ScrollToWithOrigin( nsSize currentVelocity(0, 0); - if (StaticPrefs::ScrollBehaviorEnabled()) { + if (gfxPrefs::ScrollBehaviorEnabled()) { if (aMode == ScrollMode::SmoothMsd) { mIgnoreMomentumScroll = true; if (!mAsyncSmoothMSDScroll) { @@ -2466,8 +2466,8 @@ void ScrollFrameHelper::MarkRecentlyScrolled() { void ScrollFrameHelper::ResetDisplayPortExpiryTimer() { if (mDisplayPortExpiryTimer) { mDisplayPortExpiryTimer->InitWithNamedFuncCallback( - RemoveDisplayPortCallback, this, - StaticPrefs::APZDisplayPortExpiryTime(), nsITimer::TYPE_ONE_SHOT, + RemoveDisplayPortCallback, this, gfxPrefs::APZDisplayPortExpiryTime(), + nsITimer::TYPE_ONE_SHOT, "ScrollFrameHelper::ResetDisplayPortExpiryTimer"); } } @@ -2487,7 +2487,7 @@ void ScrollFrameHelper::TriggerDisplayPortExpiration() { return; } - if (!StaticPrefs::APZDisplayPortExpiryTime()) { + if (!gfxPrefs::APZDisplayPortExpiryTime()) { // a zero time disables the expiry return; } @@ -2803,7 +2803,7 @@ void ScrollFrameHelper::ScrollToImpl(nsPoint aPt, const nsRect& aRange, bool schedulePaint = true; if (nsLayoutUtils::AsyncPanZoomEnabled(mOuter) && !nsLayoutUtils::ShouldDisableApzForElement(content) && - StaticPrefs::APZPaintSkipping()) { + gfxPrefs::APZPaintSkipping()) { // If APZ is enabled with paint-skipping, there are certain conditions in // which we can skip paints: // 1) If APZ triggered this scroll, and the tile-aligned displayport is @@ -2838,7 +2838,7 @@ void ScrollFrameHelper::ScrollToImpl(nsPoint aPt, const nsRect& aRange, bool haveScrollLinkedEffects = content->GetComposedDoc()->HasScrollLinkedEffect(); bool apzDisabled = haveScrollLinkedEffects && - StaticPrefs::APZDisableForScrollLinkedEffects(); + gfxPrefs::APZDisableForScrollLinkedEffects(); if (!apzDisabled && !HasPluginFrames()) { if (LastScrollOrigin() == nsGkAtoms::apz) { schedulePaint = false; @@ -3080,7 +3080,7 @@ void ScrollFrameHelper::AppendScrollPartsTo(nsDisplayListBuilder* aBuilder, if (mIsRoot) { nsRect scrollPartsClip = mOuter->GetRectRelativeToSelf() + aBuilder->ToReferenceFrame(mOuter); - if (!StaticPrefs::LayoutUseContainersForRootFrames() && + if (!gfxPrefs::LayoutUseContainersForRootFrames() && mOuter->PresContext()->IsRootContentDocument()) { // With containerless scrolling, the resolution does not apply to the // scroll parts. We need to apply it to their clip manually to avoid it @@ -3128,9 +3128,8 @@ void ScrollFrameHelper::AppendScrollPartsTo(nsDisplayListBuilder* aBuilder, // giant layer covering the whole scrollport if both scrollbars are visible. const bool isOverlayScrollbar = scrollDirection.isSome() && overlayScrollbars; - const bool createLayer = - aCreateLayer || isOverlayScrollbar || - StaticPrefs::AlwaysLayerizeScrollbarTrackTestOnly(); + const bool createLayer = aCreateLayer || isOverlayScrollbar || + gfxPrefs::AlwaysLayerizeScrollbarTrackTestOnly(); nsDisplayListCollection partList(aBuilder); { @@ -3386,7 +3385,7 @@ void ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, nsDisplayListBuilder::AutoCurrentActiveScrolledRootSetter asrSetter( aBuilder); if (aBuilder->IsPaintingToWindow() && - StaticPrefs::LayoutUseContainersForRootFrames() && mIsRoot) { + gfxPrefs::LayoutUseContainersForRootFrames() && mIsRoot) { asrSetter.EnterScrollFrame(sf); if (isRcdRsf) { aBuilder->SetActiveScrolledRootForRootScrollframe( @@ -3434,7 +3433,7 @@ void ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, // scroll frame for the display root, then we don't need a scroll // info layer. nsDisplayList::PaintForFrame already calls // ComputeFrameMetrics for us. - (!(StaticPrefs::LayoutUseContainersForRootFrames() && mIsRoot) || + (!(gfxPrefs::LayoutUseContainersForRootFrames() && mIsRoot) || (aBuilder->RootReferenceFrame()->PresContext() != mOuter->PresContext())); } @@ -3524,7 +3523,7 @@ void ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, bool haveRadii = mOuter->GetPaddingBoxBorderRadii(radii); if (mIsRoot) { clipRect.SizeTo(nsLayoutUtils::CalculateCompositionSizeForFrame(mOuter)); - if ((StaticPrefs::LayoutUseContainersForRootFrames() || + if ((gfxPrefs::LayoutUseContainersForRootFrames() || !aBuilder->IsPaintingToWindow()) && mOuter->PresContext()->IsRootContentDocument()) { double res = mOuter->PresShell()->GetResolution(); @@ -3636,8 +3635,7 @@ void ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, mOuter->BuildDisplayListForChild(aBuilder, mScrolledFrame, set); - if (dirtyRectHasBeenOverriden && - StaticPrefs::LayoutDisplayListShowArea()) { + if (dirtyRectHasBeenOverriden && gfxPrefs::LayoutDisplayListShowArea()) { nsDisplaySolidColor* color = MakeDisplayItem( aBuilder, mOuter, dirtyRect + aBuilder->GetCurrentFrameOffsetToReferenceFrame(), @@ -3662,7 +3660,7 @@ void ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder, mIsScrollParent = idSetter.ShouldForceLayerForScrollParent(); } if (idSetter.ShouldForceLayerForScrollParent() && - !StaticPrefs::LayoutUseContainersForRootFrames()) { + !gfxPrefs::LayoutUseContainersForRootFrames()) { // Note that forcing layerization of scroll parents follows the scroll // handoff chain which is subject to the out-of-flow-frames caveat noted // above (where the idSetter variable is created). @@ -3967,7 +3965,7 @@ bool ScrollFrameHelper::DecideScrollableLayer( } mIsScrollableLayerInRootContainer = - StaticPrefs::LayoutUseContainersForRootFrames() && + gfxPrefs::LayoutUseContainersForRootFrames() && mWillBuildScrollableLayer && mIsRoot; return mWillBuildScrollableLayer; } @@ -4014,7 +4012,7 @@ void ScrollFrameHelper::ClipLayerToDisplayPort( if (!nsLayoutUtils::UsesAsyncScrolling(mOuter)) { Maybe parentLayerClip; // For containerful frames, the clip is on the container layer. - if (aClip && (!StaticPrefs::LayoutUseContainersForRootFrames() || + if (aClip && (!gfxPrefs::LayoutUseContainersForRootFrames() || mAddClipRectToLayer)) { parentLayerClip = Some(aClip->GetClipRect()); } @@ -4330,8 +4328,8 @@ void ScrollFrameHelper::ScrollByCSSPixels( } void ScrollFrameHelper::ScrollSnap(ScrollMode aMode) { - float flingSensitivity = StaticPrefs::ScrollSnapPredictionSensitivity(); - int maxVelocity = StaticPrefs::ScrollSnapPredictionMaxVelocity(); + float flingSensitivity = gfxPrefs::ScrollSnapPredictionSensitivity(); + int maxVelocity = gfxPrefs::ScrollSnapPredictionMaxVelocity(); maxVelocity = nsPresContext::CSSPixelsToAppUnits(maxVelocity); int maxOffset = maxVelocity * flingSensitivity; nsPoint velocity = mVelocityQueue.GetVelocity(); @@ -6872,7 +6870,7 @@ bool ScrollFrameHelper::GetSnapPointForDestination( } bool ScrollFrameHelper::UsesContainerScrolling() const { - if (StaticPrefs::LayoutUseContainersForRootFrames()) { + if (gfxPrefs::LayoutUseContainersForRootFrames()) { return mIsRoot; } return false; @@ -7032,7 +7030,7 @@ void ScrollFrameHelper::ApzSmoothScrollTo(const nsPoint& aDestination, bool ScrollFrameHelper::SmoothScrollVisual( const nsPoint& aVisualViewportOffset, FrameMetrics::ScrollOffsetUpdateType aUpdateType) { - bool canDoApzSmoothScroll = StaticPrefs::ScrollBehaviorEnabled() && + bool canDoApzSmoothScroll = gfxPrefs::ScrollBehaviorEnabled() && nsLayoutUtils::AsyncPanZoomEnabled(mOuter) && WantAsyncScroll(); if (!canDoApzSmoothScroll) { diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index c3fccc2e1dd21..5d0826ed86bca 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -11,9 +11,10 @@ #include "nsSubDocumentFrame.h" +#include "gfxPrefs.h" + #include "mozilla/Preferences.h" #include "mozilla/PresShell.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/dom/Document.h" #include "mozilla/dom/HTMLFrameElement.h" #include "mozilla/layout/RenderFrame.h" @@ -426,7 +427,7 @@ void nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, aBuilder, ©OfVisible, ©OfDirty, /* aSetBase = */ true); - if (!StaticPrefs::LayoutUseContainersForRootFrames() || + if (!gfxPrefs::LayoutUseContainersForRootFrames() || !aBuilder->IsPaintingToWindow()) { haveDisplayPort = false; } @@ -607,7 +608,7 @@ void nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, // unscrolled color item for overscroll. Try again now that we're // outside the scrolled ContainerLayer. if (!aBuilder->IsForEventDelivery() && - StaticPrefs::LayoutUseContainersForRootFrames() && + gfxPrefs::LayoutUseContainersForRootFrames() && !nsLayoutUtils::NeedsPrintPreviewBackground(presContext)) { nsRect bounds = GetContentRectRelativeToSelf() + aBuilder->ToReferenceFrame(this); diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index a7b1a1adf477d..948f027a6fe85 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -9,7 +9,7 @@ #include "nsTextFrame.h" #include "gfx2DGlue.h" - +#include "gfxPrefs.h" #include "gfxUtils.h" #include "mozilla/Attributes.h" #include "mozilla/ComputedStyle.h" @@ -6692,7 +6692,7 @@ static void DrawTextRun(const gfxTextRun* aTextRun, return; } params.drawMode |= DrawMode::GLYPH_STROKE; - if (StaticPrefs::PaintOrderEnabled()) { + if (gfxPrefs::PaintOrderEnabled()) { // Check the paint-order property; if we find stroke before fill, // then change mode to GLYPH_STROKE_UNDERNEATH. uint32_t paintOrder = aFrame->StyleSVG()->mPaintOrder; diff --git a/layout/painting/DisplayListChecker.cpp b/layout/painting/DisplayListChecker.cpp index b7c52ef40e02e..363d6154549c7 100644 --- a/layout/painting/DisplayListChecker.cpp +++ b/layout/painting/DisplayListChecker.cpp @@ -6,6 +6,7 @@ #include "DisplayListChecker.h" +#include "gfxPrefs.h" #include "nsDisplayList.h" namespace mozilla { @@ -81,7 +82,7 @@ class DisplayListBlueprint { unsigned& aIndex); std::vector mItems; - const bool mVerifyOrder = StaticPrefs::LayoutVerifyRetainDisplayListOrder(); + const bool mVerifyOrder = gfxPrefs::LayoutVerifyRetainDisplayListOrder(); }; // Object representing one display item, with just enough information to diff --git a/layout/painting/FrameLayerBuilder.cpp b/layout/painting/FrameLayerBuilder.cpp index df695f08ce844..1e141a4400c7d 100644 --- a/layout/painting/FrameLayerBuilder.cpp +++ b/layout/painting/FrameLayerBuilder.cpp @@ -54,7 +54,7 @@ #include "mozilla/Unused.h" #include "GeckoProfiler.h" #include "LayersLogging.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include #include @@ -577,7 +577,7 @@ class PaintedLayerData { nsCString mLog; # define FLB_LOG_PAINTED_LAYER_DECISION(pld, ...) \ - if (StaticPrefs::LayersDumpDecision()) { \ + if (gfxPrefs::LayersDumpDecision()) { \ pld->mLog.AppendPrintf("\t\t\t\t"); \ pld->mLog.AppendPrintf(__VA_ARGS__); \ } @@ -3037,7 +3037,7 @@ PaintedLayerData* PaintedLayerDataNode::FindPaintedLayerFor( break; } - if (StaticPrefs::LayoutSmallerPaintedLayers()) { + if (gfxPrefs::LayoutSmallerPaintedLayers()) { lowestUsableLayer = nullptr; } } @@ -4384,7 +4384,7 @@ void ContainerState::ProcessDisplayItems(nsDisplayList* aList) { nsPoint topLeft(0, 0); - int32_t maxLayers = StaticPrefs::MaxActiveLayers(); + int32_t maxLayers = gfxPrefs::MaxActiveLayers(); int layerCount = 0; if (!mManager->IsWidgetLayerManager()) { @@ -4969,7 +4969,7 @@ void ContainerState::ProcessDisplayItems(nsDisplayList* aList) { } else if ((itemType == DisplayItemType::TYPE_SUBDOCUMENT || itemType == DisplayItemType::TYPE_ZOOM || itemType == DisplayItemType::TYPE_RESOLUTION) && - StaticPrefs::LayoutUseContainersForRootFrames()) { + gfxPrefs::LayoutUseContainersForRootFrames()) { newLayerEntry->mBaseScrollMetadata = static_cast(item)->ComputeScrollMetadata( ownLayer->Manager(), mParameters); @@ -5889,9 +5889,9 @@ void ContainerState::Finish(uint32_t* aTextContentFlags, nsDisplayList* aChildItems) { mPaintedLayerDataTree.Finish(); - if (!StaticPrefs::LayoutUseContainersForRootFrames()) { + if (!gfxPrefs::LayoutUseContainersForRootFrames()) { // Bug 1336544 tracks re-enabling this assertion in the - // StaticPrefs::LayoutUseContainersForRootFrames() case. + // gfxPrefs::LayoutUseContainersForRootFrames() case. NS_ASSERTION(mContainerBounds.IsEqualInterior(mAccumulatedChildBounds), "Bounds computation mismatch"); } @@ -6129,7 +6129,7 @@ static bool ChooseScaleAndSetTransform( // tiling, that's not a problem, since we'll automatically choose a tiled // layer for layers of that size. If not, we need to apply clamping to // prevent this. - if (aTransform && !StaticPrefs::LayersTilesEnabled()) { + if (aTransform && !gfxPrefs::LayersTilesEnabled()) { RestrictScaleToMaxLayerSize(scale, aVisibleRect, aContainerFrame, aLayer); } @@ -6228,7 +6228,7 @@ already_AddRefed FrameLayerBuilder::BuildContainerLayerFor( aParameters.mScrollMetadataASR; const ActiveScrolledRoot* containerCompositorASR = aParameters.mCompositorASR; - if (!aContainerItem && StaticPrefs::LayoutUseContainersForRootFrames()) { + if (!aContainerItem && gfxPrefs::LayoutUseContainersForRootFrames()) { containerASR = aBuilder->ActiveScrolledRootForRootScrollframe(); containerScrollMetadataASR = containerASR; containerCompositorASR = containerASR; @@ -7077,7 +7077,7 @@ void FrameLayerBuilder::PaintItems(std::vector& aItems, */ static bool ShouldDrawRectsSeparately(DrawTarget* aDrawTarget, DrawRegionClip aClip) { - if (!StaticPrefs::LayoutPaintRectsSeparately() || + if (!gfxPrefs::LayoutPaintRectsSeparately() || aClip == DrawRegionClip::NONE) { return false; } @@ -7205,7 +7205,7 @@ void FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer, layerBuilder->PaintItems(userData->mItems, iterRect, aContext, builder, presContext, offset, userData->mXScale, userData->mYScale); - if (StaticPrefs::GfxLoggingPaintedPixelCountEnabled()) { + if (gfxPrefs::GfxLoggingPaintedPixelCountEnabled()) { aLayer->Manager()->AddPaintedPixelCount(iterRect.Area()); } } @@ -7222,7 +7222,7 @@ void FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer, layerBuilder->PaintItems(userData->mItems, aRegionToDraw.GetBounds(), aContext, builder, presContext, offset, userData->mXScale, userData->mYScale); - if (StaticPrefs::GfxLoggingPaintedPixelCountEnabled()) { + if (gfxPrefs::GfxLoggingPaintedPixelCountEnabled()) { aLayer->Manager()->AddPaintedPixelCount(aRegionToDraw.GetBounds().Area()); } } diff --git a/layout/painting/RetainedDisplayListBuilder.cpp b/layout/painting/RetainedDisplayListBuilder.cpp index fcc1aa625227f..19f8b257aacec 100644 --- a/layout/painting/RetainedDisplayListBuilder.cpp +++ b/layout/painting/RetainedDisplayListBuilder.cpp @@ -8,7 +8,7 @@ #include "RetainedDisplayListBuilder.h" #include "DisplayListChecker.h" -#include "mozilla/StaticPrefs.h" +#include "gfxPrefs.h" #include "nsPlaceholderFrame.h" #include "nsSubDocumentFrame.h" #include "nsViewManager.h" @@ -1278,7 +1278,7 @@ bool RetainedDisplayListBuilder::ComputeRebuildRegion( * A simple early exit heuristic to avoid slow partial display list rebuilds. */ static bool ShouldBuildPartial(nsTArray& aModifiedFrames) { - if (aModifiedFrames.Length() > StaticPrefs::LayoutRebuildFrameLimit()) { + if (aModifiedFrames.Length() > gfxPrefs::LayoutRebuildFrameLimit()) { return false; } diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 9e03060d34fc0..bb2e8b743b2b0 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -30,7 +30,6 @@ #include "mozilla/layers/PLayerTransaction.h" #include "mozilla/PresShell.h" #include "mozilla/ShapeUtils.h" -#include "mozilla/StaticPrefs.h" #include "nsCSSRendering.h" #include "nsCSSRenderingGradients.h" #include "nsISelectionController.h" @@ -39,6 +38,7 @@ #include "nsStyleTransformMatrix.h" #include "nsTransitionManager.h" #include "gfxMatrix.h" +#include "gfxPrefs.h" #include "nsSVGIntegrationUtils.h" #include "nsSVGUtils.h" #include "nsLayoutUtils.h" @@ -73,7 +73,6 @@ #include "mozilla/OperatorNewExtensions.h" #include "mozilla/PendingAnimationTracker.h" #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/StyleAnimationValue.h" #include "mozilla/ServoBindings.h" #include "mozilla/Telemetry.h" @@ -1069,7 +1068,7 @@ nsRect nsDisplayListBuilder::OutOfFlowDisplayData::ComputeVisibleRectForFrame( nsRect visible = aVisibleRect; nsRect dirtyRectRelativeToDirtyFrame = aDirtyRect; - if (StaticPrefs::APZAllowZooming() && + if (gfxPrefs::APZAllowZooming() && nsLayoutUtils::IsFixedPosFrameInDisplayPort(aFrame) && aBuilder->IsPaintingToWindow()) { dirtyRectRelativeToDirtyFrame = @@ -1101,7 +1100,7 @@ nsRect nsDisplayListBuilder::OutOfFlowDisplayData::ComputeVisibleRectForFrame( } } visible = dirtyRectRelativeToDirtyFrame; - if (StaticPrefs::APZTestLoggingEnabled() && + if (gfxPrefs::APZTestLoggingEnabled() && presShell->GetDocument()->IsContentDocument()) { nsLayoutUtils::LogAdditionalTestData( aBuilder, "fixedPosDisplayport", @@ -1349,7 +1348,7 @@ AnimatedGeometryRoot* nsDisplayListBuilder::FindAnimatedGeometryRootFor( void nsDisplayListBuilder::UpdateShouldBuildAsyncZoomContainer() { Document* document = mReferenceFrame->PresContext()->Document(); mBuildAsyncZoomContainer = nsLayoutUtils::AllowZoomingForDocument(document) && - !StaticPrefs::LayoutUseContainersForRootFrames(); + !gfxPrefs::LayoutUseContainersForRootFrames(); } bool nsDisplayListBuilder::MarkOutOfFlowFrameForDisplay(nsIFrame* aDirtyFrame, @@ -2474,7 +2473,7 @@ bool nsDisplayList::ComputeVisibilityForRoot(nsDisplayListBuilder* aBuilder, nsRegion r; const ActiveScrolledRoot* rootASR = nullptr; - if (StaticPrefs::LayoutUseContainersForRootFrames()) { + if (gfxPrefs::LayoutUseContainersForRootFrames()) { rootASR = aBuilder->ActiveScrolledRootForRootScrollframe(); } r.And(*aVisibleRegion, GetClippedBoundsWithRespectToASR(aBuilder, rootASR)); @@ -2623,7 +2622,7 @@ FrameLayerBuilder* nsDisplayList::BuildLayers(nsDisplayListBuilder* aBuilder, docShell); #endif - if (XRE_IsContentProcess() && StaticPrefs::AlwaysPaint()) { + if (XRE_IsContentProcess() && gfxPrefs::AlwaysPaint()) { FrameLayerBuilder::InvalidateAllLayers(aLayerManager); } @@ -2638,7 +2637,7 @@ FrameLayerBuilder* nsDisplayList::BuildLayers(nsDisplayListBuilder* aBuilder, rootLayer->SetScrollMetadata(nsTArray()); } - float rootLayerResolution = StaticPrefs::LayoutUseContainersForRootFrames() + float rootLayerResolution = gfxPrefs::LayoutUseContainersForRootFrames() ? presShell->GetResolution() : 1.0f; ContainerLayerParameters containerParameters(rootLayerResolution, @@ -2651,7 +2650,7 @@ FrameLayerBuilder* nsDisplayList::BuildLayers(nsDisplayListBuilder* aBuilder, frame, nullptr, this, containerParameters, nullptr); - if (!record.GetStart().IsNull() && StaticPrefs::LayersDrawFPS()) { + if (!record.GetStart().IsNull() && gfxPrefs::LayersDrawFPS()) { if (PaintTiming* pt = ClientLayerManager::MaybeGetPaintTiming(aLayerManager)) { pt->flbMs() = (TimeStamp::Now() - record.GetStart()).ToMilliseconds(); @@ -2662,7 +2661,7 @@ FrameLayerBuilder* nsDisplayList::BuildLayers(nsDisplayListBuilder* aBuilder, if (!root) { return nullptr; } - if (StaticPrefs::LayoutUseContainersForRootFrames()) { + if (gfxPrefs::LayoutUseContainersForRootFrames()) { // Root is being scaled up by the X/Y resolution. Scale it back down. root->SetPostScale(1.0f / containerParameters.mXScale, 1.0f / containerParameters.mYScale); @@ -3324,7 +3323,7 @@ Maybe nsDisplayItem::GetClipWithRespectToASR( return Some(clip->GetClipRect()); } #ifdef DEBUG - if (!StaticPrefs::LayoutUseContainersForRootFrames()) { + if (!gfxPrefs::LayoutUseContainersForRootFrames()) { MOZ_ASSERT(false, "item should have finite clip with respect to aASR"); } #endif @@ -3348,7 +3347,7 @@ bool nsDisplayItem::ShouldUseAdvancedLayer(LayerManager* aManager, } bool nsDisplayItem::CanUseAdvancedLayer(LayerManager* aManager) const { - return StaticPrefs::LayersAdvancedBasicLayerEnabled() || !aManager || + return gfxPrefs::LayersAdvancedBasicLayerEnabled() || !aManager || aManager->GetBackendType() == layers::LayersBackend::LAYERS_WR; } @@ -6104,8 +6103,8 @@ static bool IsItemTooSmallForActiveLayer(nsIFrame* aFrame) { aFrame->GetVisualOverflowRectRelativeToSelf().ToOutsidePixels( aFrame->PresContext()->AppUnitsPerDevPixel()); return visibleDevPixels.Size() < - nsIntSize(StaticPrefs::LayoutMinActiveLayerSize(), - StaticPrefs::LayoutMinActiveLayerSize()); + nsIntSize(gfxPrefs::LayoutMinActiveLayerSize(), + gfxPrefs::LayoutMinActiveLayerSize()); } /* static */ @@ -6694,7 +6693,7 @@ nsDisplayRenderRoot::nsDisplayRenderRoot( mRenderRoot(aRenderRoot), mBuiltWRCommands(false) { MOZ_ASSERT(aRenderRoot != wr::RenderRoot::Default); - MOZ_ASSERT(StaticPrefs::WebRenderSplitRenderRoots()); + MOZ_ASSERT(gfxPrefs::WebRenderSplitRenderRoots()); ExpandDisplayListBuilderRenderRootRect(aBuilder); MOZ_COUNT_CTOR(nsDisplayRenderRoot); } @@ -6981,7 +6980,7 @@ already_AddRefed nsDisplayResolution::BuildLayer( nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aContainerParameters) { PresShell* presShell = mFrame->PresShell(); - float rootLayerResolution = StaticPrefs::LayoutUseContainersForRootFrames() + float rootLayerResolution = gfxPrefs::LayoutUseContainersForRootFrames() ? presShell->GetResolution() : 1.0f; ContainerLayerParameters containerParameters( @@ -6991,7 +6990,7 @@ already_AddRefed nsDisplayResolution::BuildLayer( RefPtr layer = nsDisplaySubDocument::BuildLayer(aBuilder, aManager, containerParameters); - if (StaticPrefs::LayoutUseContainersForRootFrames()) { + if (gfxPrefs::LayoutUseContainersForRootFrames()) { layer->SetPostScale(1.0f / presShell->GetResolution(), 1.0f / presShell->GetResolution()); layer->AsContainerLayer()->SetScaleToResolution(presShell->GetResolution()); @@ -7722,7 +7721,7 @@ void nsDisplayTransform::Init(nsDisplayListBuilder* aBuilder, } bool nsDisplayTransform::ShouldFlattenAway(nsDisplayListBuilder* aBuilder) { - if (gfxVars::UseWebRender() || !StaticPrefs::LayoutFlattenTransform()) { + if (gfxVars::UseWebRender() || !gfxPrefs::LayoutFlattenTransform()) { return false; } @@ -8088,10 +8087,10 @@ auto nsDisplayTransform::ShouldPrerenderTransformedContent( return FullPrerender; } - float viewportRatioX = StaticPrefs::AnimationPrerenderViewportRatioLimitX(); - float viewportRatioY = StaticPrefs::AnimationPrerenderViewportRatioLimitY(); - uint32_t absoluteLimitX = StaticPrefs::AnimationPrerenderAbsoluteLimitX(); - uint32_t absoluteLimitY = StaticPrefs::AnimationPrerenderAbsoluteLimitY(); + float viewportRatioX = gfxPrefs::AnimationPrerenderViewportRatioLimitX(); + float viewportRatioY = gfxPrefs::AnimationPrerenderViewportRatioLimitY(); + uint32_t absoluteLimitX = gfxPrefs::AnimationPrerenderAbsoluteLimitX(); + uint32_t absoluteLimitY = gfxPrefs::AnimationPrerenderAbsoluteLimitY(); nsSize refSize = aBuilder->RootReferenceFrame()->GetSize(); // Only prerender if the transformed frame's size is <= a multiple of the // reference frame size (~viewport), and less than an absolute limit. @@ -8118,7 +8117,7 @@ auto nsDisplayTransform::ShouldPrerenderTransformedContent( return FullPrerender; } - if (StaticPrefs::PartiallyPrerenderAnimatedContent()) { + if (gfxPrefs::PartiallyPrerenderAnimatedContent()) { *aDirtyRect = nsLayoutUtils::ComputePartialPrerenderArea(*aDirtyRect, overflow, maxSize); return PartialPrerender; @@ -9565,7 +9564,7 @@ bool nsDisplayMasksAndClipPaths::CanPaintOnMaskLayer(LayerManager* aManager) { return false; } - if (StaticPrefs::DrawMaskLayer()) { + if (gfxPrefs::DrawMaskLayer()) { return false; } @@ -9840,7 +9839,7 @@ Maybe nsDisplayMasksAndClipPaths::GetClipWithRespectToASR( return Some(childList->GetClippedBoundsWithRespectToASR(aBuilder, aASR)); } #ifdef DEBUG - if (!StaticPrefs::LayoutUseContainersForRootFrames()) { + if (!gfxPrefs::LayoutUseContainersForRootFrames()) { MOZ_ASSERT(false, "item should have finite clip with respect to aASR"); } #endif @@ -9988,7 +9987,7 @@ bool nsDisplayFilters::CreateWebRenderCSSFilters(WrFiltersHolder& wrFilters) { // If there are too many filters to render, then just pretend that we // succeeded, and don't render any of them. - if (filters.Length() > StaticPrefs::WebRenderMaxFilterOpsPerChain()) { + if (filters.Length() > gfxPrefs::WebRenderMaxFilterOpsPerChain()) { return true; } wrFilters.filters.SetCapacity(filters.Length()); @@ -10193,7 +10192,7 @@ bool nsDisplaySVGWrapper::CreateWebRenderCommands( const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) { - if (StaticPrefs::WebRenderBlobInvalidation()) { + if (gfxPrefs::WebRenderBlobInvalidation()) { return nsDisplayWrapList::CreateWebRenderCommands( aBuilder, aResources, aSc, aManager, aDisplayListBuilder); } @@ -10254,7 +10253,7 @@ bool nsDisplayForeignObject::CreateWebRenderCommands( const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) { - if (StaticPrefs::WebRenderBlobInvalidation()) { + if (gfxPrefs::WebRenderBlobInvalidation()) { AutoRestore restoreDoGrouping(aManager->CommandBuilder().mDoGrouping); aManager->CommandBuilder().mDoGrouping = false; return nsDisplayWrapList::CreateWebRenderCommands( diff --git a/layout/svg/nsFilterInstance.cpp b/layout/svg/nsFilterInstance.cpp index 57401319a4dbb..baa6de215a1d6 100644 --- a/layout/svg/nsFilterInstance.cpp +++ b/layout/svg/nsFilterInstance.cpp @@ -17,7 +17,7 @@ #include "gfx2DGlue.h" #include "gfxContext.h" #include "gfxPlatform.h" - +#include "gfxPrefs.h" #include "gfxUtils.h" #include "mozilla/Unused.h" #include "mozilla/gfx/Filters.h" @@ -146,7 +146,7 @@ bool nsFilterInstance::BuildWebRenderFilters(nsIFrame* aFilteredFrame, // If there are too many filters to render, then just pretend that we // succeeded, and don't render any of them. if (instance.mFilterDescription.mPrimitives.Length() > - StaticPrefs::WebRenderMaxFilterOpsPerChain()) { + gfxPrefs::WebRenderMaxFilterOpsPerChain()) { return true; } diff --git a/layout/svg/nsSVGIntegrationUtils.cpp b/layout/svg/nsSVGIntegrationUtils.cpp index de285089fa263..858cc29fa7a61 100644 --- a/layout/svg/nsSVGIntegrationUtils.cpp +++ b/layout/svg/nsSVGIntegrationUtils.cpp @@ -9,7 +9,7 @@ // Keep others in (case-insensitive) order: #include "gfxDrawable.h" - +#include "gfxPrefs.h" #include "nsCSSAnonBoxes.h" #include "nsCSSClipPathInstance.h" #include "nsDisplayList.h" @@ -1005,7 +1005,7 @@ void PaintMaskAndClipPathInternal(const PaintFramesParams& aParams, context.SetMatrix(matrixAutoSaveRestore.Matrix()); aPaintChild(); - if (StaticPrefs::DrawMaskLayer()) { + if (gfxPrefs::DrawMaskLayer()) { gfxContextAutoSaveRestore saver(&context); context.NewPath(); diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 01cc11e512908..550b01973b9ab 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -50,6 +50,7 @@ #include "nsStyleChangeList.h" #include +#include "gfxPrefs.h" #include "mozilla/layers/StackingContextHelper.h" #include "mozilla/layers/RenderRootStateManager.h" diff --git a/layout/xul/nsBoxFrame.cpp b/layout/xul/nsBoxFrame.cpp index 96dd27bbef0bd..41a3506449413 100644 --- a/layout/xul/nsBoxFrame.cpp +++ b/layout/xul/nsBoxFrame.cpp @@ -42,6 +42,7 @@ #include "nsBoxFrame.h" +#include "gfxPrefs.h" #include "gfxUtils.h" #include "mozilla/gfx/2D.h" #include "nsBoxLayoutState.h" diff --git a/layout/xul/nsSliderFrame.cpp b/layout/xul/nsSliderFrame.cpp index d1ca8c6cb89dc..97d473696a32d 100644 --- a/layout/xul/nsSliderFrame.cpp +++ b/layout/xul/nsSliderFrame.cpp @@ -13,6 +13,7 @@ #include "nsSliderFrame.h" +#include "gfxPrefs.h" #include "mozilla/ComputedStyle.h" #include "nsPresContext.h" #include "nsIContent.h" diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index 56582099f82aa..739c2864a4170 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -3064,48 +3064,15 @@ class PWRunnable : public Runnable { }; struct CacheData { - CacheData(void* aCacheLocation, bool aValue) - : mCacheLocation(aCacheLocation), mDefaultValueBool(aValue) {} - CacheData(void* aCacheLocation, int32_t aValue) - : mCacheLocation(aCacheLocation), mDefaultValueInt(aValue) {} - CacheData(void* aCacheLocation, uint32_t aValue) - : mCacheLocation(aCacheLocation), mDefaultValueUint(aValue) {} - CacheData(void* aCacheLocation, float aValue) - : mCacheLocation(aCacheLocation), mDefaultValueFloat(aValue) {} - - template - T GetDefault() const; - - void* const mCacheLocation; - - private: + void* mCacheLocation; union { - const bool mDefaultValueBool; - const int32_t mDefaultValueInt; - const uint32_t mDefaultValueUint; - const float mDefaultValueFloat; + bool mDefaultValueBool; + int32_t mDefaultValueInt; + uint32_t mDefaultValueUint; + float mDefaultValueFloat; }; }; -// We specialise the CacheData::GetDefault() here, as somehow you can't do it -// inline within CacheData definition. -template <> -bool CacheData::GetDefault() const { - return mDefaultValueBool; -} -template <> -int32_t CacheData::GetDefault() const { - return mDefaultValueInt; -} -template <> -uint32_t CacheData::GetDefault() const { - return mDefaultValueUint; -} -template <> -float CacheData::GetDefault() const { - return mDefaultValueFloat; -} - // gCacheDataDesc holds information about prefs startup. It's being used for // diagnosing prefs startup problems in bug 1276488. static const char* gCacheDataDesc = "untouched"; @@ -3717,23 +3684,11 @@ void Preferences::InitializeUserPrefs() { sPreferences->NotifyServiceObservers(NS_PREFSERVICE_READ_TOPIC_ID); - RefreshStaticPrefsValues(); - // At this point all the prefs files have been read and telemetry has been // initialized. Send all the file load measurements to telemetry. SendTelemetryLoadData(); } -/* static */ -void Preferences::RefreshStaticPrefsValues() { - MOZ_ASSERT(XRE_IsParentProcess()); - - // Ensure that StaticPref of type Once are properly set to the underlying - // Preference value as they may have been updated with a user-set or - // enterprise policies value. - StaticPrefs::InitOncePrefs(); -} - NS_IMETHODIMP Preferences::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* someData) { @@ -4364,22 +4319,24 @@ template static T GetPref(const char* aName, T aDefaultValue); template <> -bool MOZ_MAYBE_UNUSED GetPref(const char* aName, bool aDefaultValue) { +bool MOZ_MAYBE_UNUSED GetPref(const char* aName, bool aDefaultValue) { return Preferences::GetBool(aName, aDefaultValue); } template <> -int32_t MOZ_MAYBE_UNUSED GetPref(const char* aName, int32_t aDefaultValue) { +int32_t MOZ_MAYBE_UNUSED GetPref(const char* aName, + int32_t aDefaultValue) { return Preferences::GetInt(aName, aDefaultValue); } template <> -uint32_t MOZ_MAYBE_UNUSED GetPref(const char* aName, uint32_t aDefaultValue) { +uint32_t MOZ_MAYBE_UNUSED GetPref(const char* aName, + uint32_t aDefaultValue) { return Preferences::GetInt(aName, aDefaultValue); } template <> -float MOZ_MAYBE_UNUSED GetPref(const char* aName, float aDefaultValue) { +float MOZ_MAYBE_UNUSED GetPref(const char* aName, float aDefaultValue) { return Preferences::GetFloat(aName, aDefaultValue); } @@ -4433,24 +4390,16 @@ static nsresult pref_ReadDefaultPrefs(const RefPtr jarReader, } } - if (aIsStartup) { - StaticPrefs::InitOncePrefs(); - } - #ifdef DEBUG // Check that all varcache preferences match their current values. This // can currently fail if the default value of a static varcache preference // is changed in a preference file or at runtime, rather than in // StaticPrefList.h. - // StaticPrefs with a Skip policy aren't updated with an overridden value, - // and shouldn't be checked. # define PREF(name, cpp_type, value) -# define VARCACHE_PREF(policy, name, id, cpp_type, value) \ - MOZ_ASSERT( \ - StaticPrefs::UpdatePolicy::policy == \ - StaticPrefs::UpdatePolicy::Skip || \ - GetPref>(name, value) == StaticPrefs::id(), \ +# define VARCACHE_PREF(name, id, cpp_type, value) \ + MOZ_ASSERT( \ + GetPref>(name, value) == StaticPrefs::id(), \ "Incorrect cached value for " name); # include "mozilla/StaticPrefList.h" # undef PREF @@ -4633,12 +4582,6 @@ static nsresult pref_ReadDefaultPrefs(const RefPtr jarReader, } } - if (aIsStartup) { - // Ensure that StaticPref of type Once are properly set to the underlying - // Preference value. - StaticPrefs::InitOncePrefs(); - } - if (XRE_IsParentProcess()) { SetupTelemetryPref(); } @@ -5141,42 +5084,34 @@ static void CacheDataAppendElement(CacheData* aData) { gCacheData->AppendElement(aData); } -template -static void VarChanged(const char* aPref, void* aClosure) { +static void BoolVarChanged(const char* aPref, void* aClosure) { CacheData* cache = static_cast(aClosure); - *static_cast(cache->mCacheLocation) = - GetPref(aPref, cache->GetDefault>()); + *static_cast(cache->mCacheLocation) = + Preferences::GetBool(aPref, cache->mDefaultValueBool); } -// We define this method in a struct which is made friend of Preferences in -// order to access private members. -struct RegisterCallbacksInternal { - template - static nsresult RegisterCallback(CacheData* aCacheData, - const nsACString& aPref) { - return Preferences::RegisterCallback(VarChanged, aPref, aCacheData, - Preferences::ExactMatch, - /* isPriority */ true); - } -}; - -template -static nsresult AddVarCache(T* aCache, const nsACString& aPref, - StripAtomic aDefault, bool aSkipAssignment) { +/* static */ +nsresult Preferences::AddBoolVarCache(bool* aCache, const nsACString& aPref, + bool aDefault, bool aSkipAssignment) { + AssertNotAlreadyCached("bool", aPref, aCache); if (!aSkipAssignment) { - *aCache = GetPref(PromiseFlatCString(aPref).get(), aDefault); + *aCache = GetBool(PromiseFlatCString(aPref).get(), aDefault); } - CacheData* data = new CacheData(aCache, aDefault); + CacheData* data = new CacheData(); + data->mCacheLocation = aCache; + data->mDefaultValueBool = aDefault; CacheDataAppendElement(data); - RegisterCallbacksInternal::RegisterCallback(data, aPref); + Preferences::RegisterCallback(BoolVarChanged, aPref, data, + Preferences::ExactMatch, + /* isPriority */ true); return NS_OK; } -/* static */ -nsresult Preferences::AddBoolVarCache(bool* aCache, const nsACString& aPref, - bool aDefault, bool aSkipAssignment) { - AssertNotAlreadyCached("bool", aPref, aCache); - return AddVarCache(aCache, aPref, aDefault, aSkipAssignment); +template +static void AtomicBoolVarChanged(const char* aPref, void* aClosure) { + CacheData* cache = static_cast(aClosure); + *static_cast*>(cache->mCacheLocation) = + Preferences::GetBool(aPref, cache->mDefaultValueBool); } template @@ -5186,14 +5121,46 @@ nsresult Preferences::AddAtomicBoolVarCache(Atomic* aCache, bool aDefault, bool aSkipAssignment) { AssertNotAlreadyCached("bool", aPref, aCache); - return AddVarCache(aCache, aPref, aDefault, aSkipAssignment); + if (!aSkipAssignment) { + *aCache = GetBool(PromiseFlatCString(aPref).get(), aDefault); + } + CacheData* data = new CacheData(); + data->mCacheLocation = aCache; + data->mDefaultValueBool = aDefault; + CacheDataAppendElement(data); + Preferences::RegisterCallback(AtomicBoolVarChanged, aPref, data, + Preferences::ExactMatch, + /* isPriority */ true); + return NS_OK; +} + +static void IntVarChanged(const char* aPref, void* aClosure) { + CacheData* cache = static_cast(aClosure); + *static_cast(cache->mCacheLocation) = + Preferences::GetInt(aPref, cache->mDefaultValueInt); } /* static */ nsresult Preferences::AddIntVarCache(int32_t* aCache, const nsACString& aPref, int32_t aDefault, bool aSkipAssignment) { AssertNotAlreadyCached("int", aPref, aCache); - return AddVarCache(aCache, aPref, aDefault, aSkipAssignment); + if (!aSkipAssignment) { + *aCache = GetInt(PromiseFlatCString(aPref).get(), aDefault); + } + CacheData* data = new CacheData(); + data->mCacheLocation = aCache; + data->mDefaultValueInt = aDefault; + CacheDataAppendElement(data); + Preferences::RegisterCallback(IntVarChanged, aPref, data, + Preferences::ExactMatch, /* isPriority */ true); + return NS_OK; +} + +template +static void AtomicIntVarChanged(const char* aPref, void* aClosure) { + CacheData* cache = static_cast(aClosure); + *static_cast*>(cache->mCacheLocation) = + Preferences::GetInt(aPref, cache->mDefaultValueUint); } template @@ -5203,14 +5170,47 @@ nsresult Preferences::AddAtomicIntVarCache(Atomic* aCache, int32_t aDefault, bool aSkipAssignment) { AssertNotAlreadyCached("int", aPref, aCache); - return AddVarCache(aCache, aPref, aDefault, aSkipAssignment); + if (!aSkipAssignment) { + *aCache = GetInt(PromiseFlatCString(aPref).get(), aDefault); + } + CacheData* data = new CacheData(); + data->mCacheLocation = aCache; + data->mDefaultValueUint = aDefault; + CacheDataAppendElement(data); + Preferences::RegisterCallback(AtomicIntVarChanged, aPref, data, + Preferences::ExactMatch, + /* isPriority */ true); + return NS_OK; +} + +static void UintVarChanged(const char* aPref, void* aClosure) { + CacheData* cache = static_cast(aClosure); + *static_cast(cache->mCacheLocation) = + Preferences::GetUint(aPref, cache->mDefaultValueUint); } /* static */ nsresult Preferences::AddUintVarCache(uint32_t* aCache, const nsACString& aPref, uint32_t aDefault, bool aSkipAssignment) { AssertNotAlreadyCached("uint", aPref, aCache); - return AddVarCache(aCache, aPref, aDefault, aSkipAssignment); + if (!aSkipAssignment) { + *aCache = GetUint(PromiseFlatCString(aPref).get(), aDefault); + } + CacheData* data = new CacheData(); + data->mCacheLocation = aCache; + data->mDefaultValueUint = aDefault; + CacheDataAppendElement(data); + Preferences::RegisterCallback(UintVarChanged, aPref, data, + Preferences::ExactMatch, + /* isPriority */ true); + return NS_OK; +} + +template +static void AtomicUintVarChanged(const char* aPref, void* aClosure) { + CacheData* cache = static_cast(aClosure); + *static_cast*>(cache->mCacheLocation) = + Preferences::GetUint(aPref, cache->mDefaultValueUint); } template @@ -5220,7 +5220,17 @@ nsresult Preferences::AddAtomicUintVarCache(Atomic* aCache, uint32_t aDefault, bool aSkipAssignment) { AssertNotAlreadyCached("uint", aPref, aCache); - return AddVarCache(aCache, aPref, aDefault, aSkipAssignment); + if (!aSkipAssignment) { + *aCache = GetUint(PromiseFlatCString(aPref).get(), aDefault); + } + CacheData* data = new CacheData(); + data->mCacheLocation = aCache; + data->mDefaultValueUint = aDefault; + CacheDataAppendElement(data); + Preferences::RegisterCallback(AtomicUintVarChanged, aPref, data, + Preferences::ExactMatch, + /* isPriority */ true); + return NS_OK; } // Since the definition of template functions is not in a header file, we @@ -5251,21 +5261,43 @@ template nsresult Preferences::AddAtomicUintVarCache( Atomic*, const nsACString&, uint32_t, bool); +static void FloatVarChanged(const char* aPref, void* aClosure) { + CacheData* cache = static_cast(aClosure); + *static_cast(cache->mCacheLocation) = + Preferences::GetFloat(aPref, cache->mDefaultValueFloat); +} + /* static */ nsresult Preferences::AddFloatVarCache(float* aCache, const nsACString& aPref, float aDefault, bool aSkipAssignment) { AssertNotAlreadyCached("float", aPref, aCache); - return AddVarCache(aCache, aPref, aDefault, aSkipAssignment); + if (!aSkipAssignment) { + *aCache = GetFloat(PromiseFlatCString(aPref).get(), aDefault); + } + CacheData* data = new CacheData(); + data->mCacheLocation = aCache; + data->mDefaultValueFloat = aDefault; + CacheDataAppendElement(data); + Preferences::RegisterCallback(FloatVarChanged, aPref, data, + Preferences::ExactMatch, + /* isPriority */ true); + return NS_OK; } -/* static */ -nsresult Preferences::AddAtomicFloatVarCache(std::atomic* aCache, - const nsACString& aPref, - float aDefault, - bool aSkipAssignment) { - AssertNotAlreadyCached("float", aPref, aCache); - return AddVarCache(aCache, aPref, aDefault, aSkipAssignment); -} +// For a VarCache pref like this: +// +// VARCACHE_PREF("my.varcache", my_varcache, int32_t, 99) +// +// we generate a static variable definition: +// +// int32_t StaticPrefs::sVarCache_my_varcache(99); +// +#define PREF(name, cpp_type, value) +#define VARCACHE_PREF(name, id, cpp_type, value) \ + cpp_type StaticPrefs::sVarCache_##id(value); +#include "mozilla/StaticPrefList.h" +#undef PREF +#undef VARCACHE_PREF // The SetPref_*() functions below end in a `_` suffix because they are // used by the PREF macro definition in InitAll() below. @@ -5311,87 +5343,112 @@ MOZ_MAYBE_UNUSED static void SetPref_String(const char* aName, /* fromInit */ true); } -static void SetPref(const char* aName, bool aDefaultValue) { - SetPref_bool(aName, aDefaultValue); -} -static void SetPref(const char* aName, int32_t aDefaultValue) { - SetPref_int32_t(aName, aDefaultValue); -} -static void SetPref(const char* aName, uint32_t aDefaultValue) { - SetPref_int32_t(aName, int32_t(aDefaultValue)); +static void InitVarCachePref(const nsACString& aName, bool* aCache, + bool aDefaultValue, bool aIsStartup, + bool aSetValue) { + if (aSetValue) { + SetPref_bool(PromiseFlatCString(aName).get(), aDefaultValue); + } + *aCache = aDefaultValue; + if (aIsStartup) { + Preferences::AddBoolVarCache(aCache, aName, aDefaultValue, true); + } } -static void SetPref(const char* aName, float aDefaultValue) { - SetPref_float(aName, aDefaultValue); + +template +static void InitVarCachePref(const nsACString& aName, + Atomic* aCache, bool aDefaultValue, + bool aIsStartup, bool aSetValue) { + if (aSetValue) { + SetPref_bool(PromiseFlatCString(aName).get(), aDefaultValue); + } + *aCache = aDefaultValue; + if (aIsStartup) { + Preferences::AddAtomicBoolVarCache(aCache, aName, aDefaultValue, true); + } } -MOZ_MAYBE_UNUSED static void SetPref(const char* aName, - const char* aDefaultValue) { - SetPref_String(aName, aDefaultValue); + +// XXX: this will eventually become used +MOZ_MAYBE_UNUSED static void InitVarCachePref(const nsACString& aName, + int32_t* aCache, + int32_t aDefaultValue, + bool aIsStartup, bool aSetValue) { + if (aSetValue) { + SetPref_int32_t(PromiseFlatCString(aName).get(), aDefaultValue); + } + *aCache = aDefaultValue; + if (aIsStartup) { + Preferences::AddIntVarCache(aCache, aName, aDefaultValue, true); + } } -template -static void InitVarCachePref(StaticPrefs::UpdatePolicy aPolicy, - const nsACString& aName, T* aCache, - StripAtomic aDefaultValue, bool aIsStartup, +template +static void InitVarCachePref(const nsACString& aName, + Atomic* aCache, + int32_t aDefaultValue, bool aIsStartup, bool aSetValue) { if (aSetValue) { - SetPref(PromiseFlatCString(aName).get(), aDefaultValue); + SetPref_int32_t(PromiseFlatCString(aName).get(), aDefaultValue); } + *aCache = aDefaultValue; + if (aIsStartup) { + Preferences::AddAtomicIntVarCache(aCache, aName, aDefaultValue, true); + } +} +static void InitVarCachePref(const nsACString& aName, uint32_t* aCache, + uint32_t aDefaultValue, bool aIsStartup, + bool aSetValue) { + if (aSetValue) { + SetPref_int32_t(PromiseFlatCString(aName).get(), + static_cast(aDefaultValue)); + } *aCache = aDefaultValue; - if (MOZ_LIKELY(aIsStartup) && - MOZ_LIKELY(aPolicy == StaticPrefs::UpdatePolicy::Live)) { - AddVarCache(aCache, aName, aDefaultValue, true); + if (aIsStartup) { + Preferences::AddUintVarCache(aCache, aName, aDefaultValue, true); } } -// For a VarCache pref like this: -// -// VARCACHE_PREF(Once, "my.varcache", my_varcache, int32_t, 99) -// -// we generate a static variable definition and a setter like: -// -// int32_t StaticPrefs::sVarCache_my_varcache(99); -// void StaticPrefs::Setmy_varcache(int32_t aValue) { -// SetPref(Getmy_varcachePrefName(), aValue); -// if (UpdatePolicy::policy == UpdatePolicy::Once) { -// sVarCache_my_varcache = -// GetPref(Getmy_varcachePrefName(), sVarCache_my_varcache); -// } -// return; -// } +template +static void InitVarCachePref(const nsACString& aName, + Atomic* aCache, + uint32_t aDefaultValue, bool aIsStartup, + bool aSetValue) { + if (aSetValue) { + SetPref_int32_t(PromiseFlatCString(aName).get(), + static_cast(aDefaultValue)); + } + *aCache = aDefaultValue; + if (aIsStartup) { + Preferences::AddAtomicUintVarCache(aCache, aName, aDefaultValue, true); + } +} -#define PREF(name, cpp_type, value) -#define VARCACHE_PREF(policy, name, id, cpp_type, value) \ - cpp_type StaticPrefs::sVarCache_##id(value); \ - void StaticPrefs::Set##id(StripAtomic aValue) { \ - MOZ_DIAGNOSTIC_ASSERT(NS_IsMainThread() && XRE_IsParentProcess(), \ - "pref '" name "' being set outside parent process"); \ - SetPref(Get##id##PrefName(), aValue); \ - if (UpdatePolicy::policy == UpdatePolicy::Once) { \ - sVarCache_##id = \ - GetPref(Get##id##PrefName(), StripAtomic(sVarCache_##id)); \ - } \ - /* The StaticPrefs storage will be updated by the registered callback */ \ - return; \ +static void InitVarCachePref(const nsACString& aName, float* aCache, + float aDefaultValue, bool aIsStartup, + bool aSetValue) { + if (aSetValue) { + SetPref_float(PromiseFlatCString(aName).get(), aDefaultValue); } -#include "mozilla/StaticPrefList.h" -#undef PREF -#undef VARCACHE_PREF + *aCache = aDefaultValue; + if (aIsStartup) { + Preferences::AddFloatVarCache(aCache, aName, aDefaultValue, true); + } +} /* static */ void StaticPrefs::InitAll(bool aIsStartup) { // For prefs like these: // // PREF("foo.bar.baz", bool, true) - // VARCACHE_PREF(Live, "my.varcache", my_varcache, int32_t, 99) + // VARCACHE_PREF("my.varcache", my_varcache, int32_t, 99) // // we generate registration calls: // // if (isParent) // SetPref_bool("foo.bar.baz", true); - // InitVarCachePref(StaticPrefs::UpdatePolicy::Live, "my.varcache", - // &StaticPrefs::sVarCache_my_varcache, 99, aIsStartup, - // isParent); + // InitVarCachePref("my.varcache", &StaticPrefs::sVarCache_my_varcache, 99, + // aIsStartup); // // The SetPref_*() functions have a type suffix to avoid ambiguity between // prefs having int32_t and float default values. That suffix is not needed @@ -5403,40 +5460,14 @@ void StaticPrefs::InitAll(bool aIsStartup) { bool isParent = XRE_IsParentProcess(); #define PREF(name, cpp_type, value) \ if (isParent) SetPref_##cpp_type(name, value); -#define VARCACHE_PREF(policy, name, id, cpp_type, value) \ - InitVarCachePref(StaticPrefs::UpdatePolicy::policy, \ - NS_LITERAL_CSTRING(name), &StaticPrefs::sVarCache_##id, \ +#define VARCACHE_PREF(name, id, cpp_type, value) \ + InitVarCachePref(NS_LITERAL_CSTRING(name), &StaticPrefs::sVarCache_##id, \ value, aIsStartup, isParent); #include "mozilla/StaticPrefList.h" #undef PREF #undef VARCACHE_PREF } -/* static */ -void StaticPrefs::InitOncePrefs() { - // For prefs like these: - // - // VARCACHE_PREF(Skip, "my.varcache", my_varcache, int32_t, 99) - // - // we generate registration calls: - // - // if (UpdatePolicy::Skip == UpdatePolicy::Once) { - // StaticPrefs::sVarCache_my_varcache = - // GetPref("my.varcache", StripAtomic(99)); - // } - // - // This is done to get the potentially updated Preference value as we didn't - // register a callback method for the Once policy. -#define PREF(name, cpp_type, value) -#define VARCACHE_PREF(policy, name, id, cpp_type, value) \ - if (UpdatePolicy::policy == UpdatePolicy::Once) { \ - StaticPrefs::sVarCache_##id = GetPref(name, StripAtomic(value)); \ - } -#include "mozilla/StaticPrefList.h" -#undef PREF -#undef VARCACHE_PREF -} - } // namespace mozilla #undef ENSURE_PARENT_PROCESS diff --git a/modules/libpref/Preferences.h b/modules/libpref/Preferences.h index 149e58de55dc1..14e0b95b314d4 100644 --- a/modules/libpref/Preferences.h +++ b/modules/libpref/Preferences.h @@ -22,7 +22,6 @@ #include "nsString.h" #include "nsTArray.h" #include "nsWeakReference.h" -#include class nsIFile; @@ -34,8 +33,6 @@ class nsPrefBranch; namespace mozilla { -struct RegisterCallbacksInternal; - void UnloadPrefsModule(); // A typesafe version of PrefChangeFunc, with its data argument type deduced @@ -177,8 +174,6 @@ class Preferences final : public nsIPrefService, // Initialize user prefs from prefs.js/user.js static void InitializeUserPrefs(); - static void RefreshStaticPrefsValues(); - // Returns the singleton instance which is addreffed. static already_AddRefed GetInstanceForService(); @@ -510,11 +505,6 @@ class Preferences final : public nsIPrefService, float aDefault = 0.0f, bool aSkipAssignment = false); - static nsresult AddAtomicFloatVarCache(std::atomic* aVariable, - const nsACString& aPref, - float aDefault = 0.0f, - bool aSkipAssignment = false); - template static nsresult AddBoolVarCache(bool* aVariable, const char (&aPref)[N], bool aDefault = false, @@ -568,15 +558,6 @@ class Preferences final : public nsIPrefService, aSkipAssignment); } - template - static nsresult AddAtomicFloatVarCache(std::atomic* aVariable, - const char (&aPref)[N], - float aDefault = 0.0f, - bool aSkipAssignment = false) { - return AddAtomicFloatVarCache(aVariable, nsLiteralCString(aPref), aDefault, - aSkipAssignment); - } - // When a content process is created these methods are used to pass changed // prefs in bulk from the parent process, via shared memory. static void SerializePreferences(nsCString& aStr); @@ -644,7 +625,6 @@ class Preferences final : public nsIPrefService, static mozilla::Result InitInitialObjects( bool aIsStartup); - friend struct RegisterCallbacksInternal; static nsresult RegisterCallback(PrefChangedFunc aCallback, const nsACString& aPref, void* aClosure, MatchKind aMatchKind, diff --git a/modules/libpref/StaticPrefs.h b/modules/libpref/StaticPrefs.h index 5cc49dd4e5082..0a39e0137b59a 100644 --- a/modules/libpref/StaticPrefs.h +++ b/modules/libpref/StaticPrefs.h @@ -7,14 +7,10 @@ #ifndef mozilla_StaticPrefs_h #define mozilla_StaticPrefs_h -#include "gfxPlatform.h" #include "mozilla/Assertions.h" #include "mozilla/Atomics.h" #include "mozilla/TypeTraits.h" -#include "mozilla/gfx/LoggingConstants.h" #include "MainThreadUtils.h" -#include -#include // for M_PI namespace mozilla { @@ -36,10 +32,6 @@ typedef Atomic ReleaseAcquireAtomicUint32; typedef Atomic SequentiallyConsistentAtomicUint32; -// Atomic currently doesn't work (see bug 1552086), once this tast has -// been completed we will be able to use Atomic instead. -typedef std::atomic AtomicFloat; - template struct StripAtomicImpl { typedef T Type; @@ -50,11 +42,6 @@ struct StripAtomicImpl> { typedef T Type; }; -template -struct StripAtomicImpl> { - typedef T Type; -}; - template using StripAtomic = typename StripAtomicImpl::Type; @@ -64,61 +51,36 @@ struct IsAtomic : FalseType {}; template struct IsAtomic> : TrueType {}; -template -struct IsAtomic> : TrueType {}; - class StaticPrefs { - // For a VarCache pref like this: - // - // VARCACHE_PREF("my.varcache", my_varcache, int32_t, 99) - // - // we generate a static variable declaration, a getter and a setter - // definition. A StaticPref can be set by using the corresponding Set method. - // For example, if the accessor is Foo() then calling SetFoo(...) will update - // the preference and also change the return value of subsequent Foo() calls. - // Changing StaticPrefs is only allowed on the parent process' main thread. - // - // private: - // static int32_t sVarCache_my_varcache; - // public: - // static int32_t my_varcache() { return sVarCache_my_varcache; } - // static void Setmy_varcache(int32_t aValue); - // static const char* Getmy_varcachePrefName() { return "my.varcache"; } - // static int32_t Getmy_varcachePrefDefault() { return 99; } - // - - public: - // Enums for the update policy. - enum class UpdatePolicy { - Skip, // Set the value to default, skip any Preferences calls. - Once, // Evaluate the preference once, unchanged during the session. - Live // Evaluate the preference and set callback so it stays current/live. - }; - +// For a VarCache pref like this: +// +// VARCACHE_PREF("my.varcache", my_varcache, int32_t, 99) +// +// we generate a static variable declaration and a getter definition: +// +// private: +// static int32_t sVarCache_my_varcache; +// public: +// static int32_t my_varcache() { return sVarCache_my_varcache; } +// #define PREF(str, cpp_type, default_value) -#define VARCACHE_PREF(policy, str, id, cpp_type, default_value) \ - private: \ - static cpp_type sVarCache_##id; \ - \ - public: \ - static StripAtomic id() { \ - MOZ_DIAGNOSTIC_ASSERT(UpdatePolicy::policy != UpdatePolicy::Live || \ - IsAtomic::value || NS_IsMainThread(), \ - "Non-atomic static pref '" str \ - "' being accessed on background thread by getter"); \ - return sVarCache_##id; \ - } \ - static void Set##id(StripAtomic aValue); \ - static const char* Get##id##PrefName() { return str; } \ - static StripAtomic Get##id##PrefDefault() { return default_value; } - +#define VARCACHE_PREF(str, id, cpp_type, default_value) \ + private: \ + static cpp_type sVarCache_##id; \ + \ + public: \ + static StripAtomic id() { \ + MOZ_ASSERT(IsAtomic::value || NS_IsMainThread(), \ + "Non-atomic static pref '" str \ + "' being accessed on background thread"); \ + return sVarCache_##id; \ + } #include "mozilla/StaticPrefList.h" #undef PREF #undef VARCACHE_PREF public: static void InitAll(bool aIsStartup); - static void InitOncePrefs(); }; } // namespace mozilla diff --git a/modules/libpref/components.conf b/modules/libpref/components.conf index 95930bd39f043..6f08e4e50e5e0 100644 --- a/modules/libpref/components.conf +++ b/modules/libpref/components.conf @@ -18,7 +18,7 @@ Classes = [ 'type': 'mozilla::Preferences', 'headers': ['mozilla/Preferences.h'], 'constructor': 'mozilla::Preferences::GetInstanceForService', - 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_AND_SOCKET_PROCESS, + 'processes': ProcessSelector.ALLOW_IN_RDD_AND_SOCKET_PROCESS, }, { 'cid': '{064d9cee-1dd2-11b2-83e3-d25ab0193c26}', diff --git a/modules/libpref/init/StaticPrefList.h b/modules/libpref/init/StaticPrefList.h index f8550a8d7b748..fc5cea83505f7 100644 --- a/modules/libpref/init/StaticPrefList.h +++ b/modules/libpref/init/StaticPrefList.h @@ -14,10 +14,8 @@ // // The file is separated into sections, where the sections are determined by // the first segment of the prefnames within (e.g. "network.predictor.enabled" -// is within the "Network" section). Sections must be kept in alphabetical +// is within the "Network" section). Sections should be kept in alphabetical // order, but prefs within sections need not be. -// Please follow the existing naming convention when considering adding a new -// pref and whether you need a new section. // // Normal prefs // ------------ @@ -53,21 +51,11 @@ // Definitions of VarCache prefs in this file has the following form. // // VARCACHE_PREF( -// , // , // , // , // ) // -// - is one of the following: Skip, Once, Live -// Skip: Set the value to , skip any Preferences calls. -// This policy should be rarely used and its use is discouraged. -// Once: Evaluate the pref once, and unchanged during the session once -// enterprisepolicies have been loaded. -// This is useful for features where you want to ignore any pref -// changes until the start of the next browser session. -// Live: Evaluate the pref and set callback so it stays current/live. -// // - is the same as for normal prefs. // // - is the name of the static getter function generated within @@ -81,10 +69,6 @@ // of one of those. The C++ preprocessor doesn't like template syntax in a // macro argument, so use the typedefs defines in StaticPrefs.h; for example, // use `ReleaseAcquireAtomicBool` instead of `Atomic`. -// Pref with a Skip or Once policy can be non-atomic as they are only ever -// written to once during the parent process startup. -// Pref with a Live policy must be made Atomic if ever accessed outside the -// main thread; assertions are in place to prevent incorrect usage. // // - is the same as for normal prefs. // @@ -94,3625 +78,894 @@ // clang-format off //--------------------------------------------------------------------------- -// Prefs starting with "accessibility." +// Accessibility prefs //--------------------------------------------------------------------------- VARCACHE_PREF( - Live, "accessibility.monoaudio.enable", - accessibility_monoaudio_enable, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "accessibility.browsewithcaret", - AccessibilityBrowseWithCaret, + accessibility_monoaudio_enable, RelaxedAtomicBool, false ) //--------------------------------------------------------------------------- -// Prefs starting with "apz." -// The apz prefs are explained in AsyncPanZoomController.cpp +// Fuzzing prefs. It's important that these can only be checked in fuzzing +// builds (when FUZZING is defined), otherwise you could enable the fuzzing +// stuff on your regular build which would be bad :) //--------------------------------------------------------------------------- +#ifdef FUZZING VARCACHE_PREF( - Live, - "apz.allow_double_tap_zooming", - APZAllowDoubleTapZooming, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "apz.allow_immediate_handoff", - APZAllowImmediateHandoff, - RelaxedAtomicBool, true + "fuzzing.enabled", + fuzzing_enabled, + bool, false ) VARCACHE_PREF( - Live, - "apz.allow_zooming", - APZAllowZooming, + "fuzzing.necko.enabled", + fuzzing_necko_enabled, RelaxedAtomicBool, false ) +#endif -VARCACHE_PREF( - Live, - "apz.android.chrome_fling_physics.enabled", - APZUseChromeFlingPhysics, - RelaxedAtomicBool, false -) +//--------------------------------------------------------------------------- +// Clipboard prefs +//--------------------------------------------------------------------------- +#if !defined(ANDROID) && !defined(XP_MACOSX) && defined(XP_UNIX) +# define PREF_VALUE true +#else +# define PREF_VALUE false +#endif VARCACHE_PREF( - Live, - "apz.android.chrome_fling_physics.friction", - APZChromeFlingPhysicsFriction, - AtomicFloat, 0.015f + "clipboard.autocopy", + clipboard_autocopy, + bool, PREF_VALUE ) +#undef PREF_VALUE -VARCACHE_PREF( - Live, - "apz.android.chrome_fling_physics.inflexion", - APZChromeFlingPhysicsInflexion, - AtomicFloat, 0.35f -) +//--------------------------------------------------------------------------- +// DOM prefs +//--------------------------------------------------------------------------- +// Is support for automatically removing replaced filling animations enabled? +#ifdef RELEASE_OR_BETA +# define PREF_VALUE false +#else +# define PREF_VALUE true +#endif VARCACHE_PREF( - Live, - "apz.android.chrome_fling_physics.stop_threshold", - APZChromeFlingPhysicsStopThreshold, - AtomicFloat, 0.1f + "dom.animations-api.autoremove.enabled", + dom_animations_api_autoremove_enabled, + bool, PREF_VALUE ) +#undef PREF_VALUE +// Is support for composite operations from the Web Animations API enabled? +#ifdef RELEASE_OR_BETA +# define PREF_VALUE false +#else +# define PREF_VALUE true +#endif VARCACHE_PREF( - Live, - "apz.autoscroll.enabled", - APZAutoscrollEnabled, - RelaxedAtomicBool, false + "dom.animations-api.compositing.enabled", + dom_animations_api_compositing_enabled, + bool, PREF_VALUE ) +#undef PREF_VALUE +// Is support for the core interfaces of Web Animations API enabled? VARCACHE_PREF( - Live, - "apz.axis_lock.breakout_angle", - APZAxisBreakoutAngle, - AtomicFloat, float(M_PI / 8.0) /* 22.5 degrees */ + "dom.animations-api.core.enabled", + dom_animations_api_core_enabled, + bool, true ) +// Is support for Document.getAnimations() and Element.getAnimations() +// supported? +// +// Before enabling this by default, make sure also CSSPseudoElement interface +// has been spec'ed properly, or we should add a separate pref for +// CSSPseudoElement interface. See Bug 1174575 for further details. +#ifdef RELEASE_OR_BETA +# define PREF_VALUE false +#else +# define PREF_VALUE true +#endif VARCACHE_PREF( - Live, - "apz.axis_lock.breakout_threshold", - APZAxisBreakoutThreshold, - AtomicFloat, 1.0f / 32.0f + "dom.animations-api.getAnimations.enabled", + dom_animations_api_getAnimations_enabled, + bool, PREF_VALUE ) +#undef PREF_VALUE +// Is support for animations from the Web Animations API without 0%/100% +// keyframes enabled? +#ifdef RELEASE_OR_BETA +# define PREF_VALUE false +#else +# define PREF_VALUE true +#endif VARCACHE_PREF( - Live, - "apz.axis_lock.direct_pan_angle", - APZAllowedDirectPanAngle, - AtomicFloat, float(M_PI / 3.0) /* 60 degrees */ + "dom.animations-api.implicit-keyframes.enabled", + dom_animations_api_implicit_keyframes_enabled, + bool, PREF_VALUE ) +#undef PREF_VALUE +// Is support for timelines from the Web Animations API enabled? +#ifdef RELEASE_OR_BETA +# define PREF_VALUE false +#else +# define PREF_VALUE true +#endif VARCACHE_PREF( - Live, - "apz.axis_lock.lock_angle", - APZAxisLockAngle, - AtomicFloat, float(M_PI / 6.0) /* 30 degrees */ + "dom.animations-api.timelines.enabled", + dom_animations_api_timelines_enabled, + bool, PREF_VALUE ) +#undef PREF_VALUE +// Whether Mozilla specific "text" event should be dispatched only in the +// system group or not in content. VARCACHE_PREF( - Live, - "apz.axis_lock.mode", - APZAxisLockMode, - RelaxedAtomicInt32, 0 + "dom.compositionevent.text.dispatch_only_system_group_in_content", + dom_compositionevent_text_dispatch_only_system_group_in_content, + bool, true ) +// How long a content process can take before closing its IPC channel +// after shutdown is initiated. If the process exceeds the timeout, +// we fear the worst and kill it. +#if !defined(DEBUG) && !defined(MOZ_ASAN) && !defined(MOZ_VALGRIND) && \ + !defined(MOZ_TSAN) +# define PREF_VALUE 5 +#else +# define PREF_VALUE 0 +#endif VARCACHE_PREF( - Live, - "apz.content_response_timeout", - APZContentResponseTimeout, - RelaxedAtomicInt32, 400 + "dom.ipc.tabs.shutdownTimeoutSecs", + dom_ipc_tabs_shutdownTimeoutSecs, + RelaxedAtomicUint32, PREF_VALUE ) +#undef PREF_VALUE +// If this is true, it's allowed to fire "cut", "copy" and "paste" events. +// Additionally, "input" events may expose clipboard content when inputType +// is "insertFromPaste" or something. VARCACHE_PREF( - Live, - "apz.danger_zone_x", - APZDangerZoneX, - RelaxedAtomicInt32, 50 + "dom.event.clipboardevents.enabled", + dom_event_clipboardevents_enabled, + bool, true ) +// If this is true, "keypress" event's keyCode value and charCode value always +// become same if the event is not created/initialized by JS. VARCACHE_PREF( - Live, - "apz.danger_zone_y", - APZDangerZoneY, - RelaxedAtomicInt32, 100 + "dom.keyboardevent.keypress.set_keycode_and_charcode_to_same_value", + dom_keyboardevent_keypress_set_keycode_and_charcode_to_same_value, + bool, true ) +// Whether we conform to Input Events Level 1 or Input Events Level 2. +// true: conforming to Level 1 +// false: conforming to Level 2 VARCACHE_PREF( - Live, - "apz.disable_for_scroll_linked_effects", - APZDisableForScrollLinkedEffects, - RelaxedAtomicBool, false + "dom.input_events.conform_to_level_1", + dom_input_events_conform_to_level_1, + bool, true ) +// Enable not moving the cursor to end when a text input or textarea has .value +// set to the value it already has. By default, enabled. VARCACHE_PREF( - Live, - "apz.displayport_expiry_ms", - APZDisplayPortExpiryTime, - RelaxedAtomicUint32, 15000 + "dom.input.skip_cursor_move_for_same_value_set", + dom_input_skip_cursor_move_for_same_value_set, + bool, true ) +// NOTE: This preference is used in unit tests. If it is removed or its default +// value changes, please update test_sharedMap_var_caches.js accordingly. VARCACHE_PREF( - Live, - "apz.drag.enabled", - APZDragEnabled, - RelaxedAtomicBool, false + "dom.webcomponents.shadowdom.report_usage", + dom_webcomponents_shadowdom_report_usage, + bool, false ) +// Whether we disable triggering mutation events for changes to style +// attribute via CSSOM. +// NOTE: This preference is used in unit tests. If it is removed or its default +// value changes, please update test_sharedMap_var_caches.js accordingly. VARCACHE_PREF( - Live, - "apz.drag.initial.enabled", - APZDragInitiationEnabled, - RelaxedAtomicBool, false + "dom.mutation-events.cssom.disabled", + dom_mutation_events_cssom_disabled, + bool, true ) +// Whether the disabled attribute in HTMLLinkElement disables the sheet loading +// altogether, or forwards to the inner stylesheet method without attribute +// reflection. +// +// Historical behavior is the second, the first is being discussed at: +// https://github.com/whatwg/html/issues/3840 VARCACHE_PREF( - Live, - "apz.drag.touch.enabled", - APZTouchDragEnabled, - RelaxedAtomicBool, false + "dom.link.disabled_attribute.enabled", + dom_link_disabled_attribute_enabled, + bool, true ) +// Should we defer timeouts and intervals while loading a page. Released +// on Idle or when the page is loaded. VARCACHE_PREF( - Live, - "apz.enlarge_displayport_when_clipped", - APZEnlargeDisplayPortWhenClipped, - RelaxedAtomicBool, false + "dom.timeout.defer_during_load", + dom_timeout_defer_during_load, + bool, true ) +// Maximum deferral time for setTimeout/Interval in milliseconds VARCACHE_PREF( - Live, - "apz.fixed-margin-override.enabled", - APZFixedMarginOverrideEnabled, - RelaxedAtomicBool, false + "dom.timeout.max_idle_defer_ms", + dom_timeout_max_idle_defer_ms, + uint32_t, 10*1000 ) VARCACHE_PREF( - Live, - "apz.fixed-margin-override.bottom", - APZFixedMarginOverrideBottom, - RelaxedAtomicInt32, 0 + "dom.performance.children_results_ipc_timeout", + dom_performance_children_results_ipc_timeout, + uint32_t, 1000 ) -VARCACHE_PREF( - Live, - "apz.fixed-margin-override.top", - APZFixedMarginOverrideTop, - RelaxedAtomicInt32, 0 -) +// If true. then the service worker interception and the ServiceWorkerManager +// will live in the parent process. This only takes effect on browser start. +// Note, this is not currently safe to use for normal browsing yet. +PREF("dom.serviceWorkers.parent_intercept", bool, false) +// Enable/disable the PaymentRequest API VARCACHE_PREF( - Live, - "apz.fling_accel_base_mult", - APZFlingAccelBaseMultiplier, - AtomicFloat, 1.0f + "dom.payments.request.enabled", + dom_payments_request_enabled, + bool, false ) +// Whether a user gesture is required to call PaymentRequest.prototype.show(). VARCACHE_PREF( - Live, - "apz.fling_accel_interval_ms", - APZFlingAccelInterval, - RelaxedAtomicInt32, 500 + "dom.payments.request.user_interaction_required", + dom_payments_request_user_interaction_required, + bool, true ) +// Time in milliseconds for PaymentResponse to wait for +// the Web page to call complete(). VARCACHE_PREF( - Live, - "apz.fling_accel_supplemental_mult", - APZFlingAccelSupplementalMultiplier, - AtomicFloat, 1.0f + "dom.payments.response.timeout", + dom_payments_response_timeout, + uint32_t, 5000 ) +// SW Cache API VARCACHE_PREF( - Live, - "apz.fling_accel_min_velocity", - APZFlingAccelMinVelocity, - AtomicFloat, 1.5f + "dom.caches.enabled", + dom_caches_enabled, + RelaxedAtomicBool, true ) VARCACHE_PREF( - Once, - "apz.fling_curve_function_x1", - APZCurveFunctionX1, - float, 0.0f + "dom.caches.testing.enabled", + dom_caches_testing_enabled, + RelaxedAtomicBool, false ) +// Enable printing performance marks/measures to log VARCACHE_PREF( - Once, - "apz.fling_curve_function_x2", - APZCurveFunctionX2, - float, 1.0f + "dom.performance.enable_user_timing_logging", + dom_performance_enable_user_timing_logging, + RelaxedAtomicBool, false ) VARCACHE_PREF( - Once, - "apz.fling_curve_function_y1", - APZCurveFunctionY1, - float, 0.0f + "dom.webnotifications.enabled", + dom_webnotifications_enabled, + RelaxedAtomicBool, true ) VARCACHE_PREF( - Once, - "apz.fling_curve_function_y2", - APZCurveFunctionY2, - float, 1.0f + "dom.webnotifications.allowinsecure", + dom_webnotifications_allowinsecure, + RelaxedAtomicBool, false ) +#ifdef EARLY_BETA_OR_EARLIER +# define PREF_VALUE true +#else +# define PREF_VALUE false +#endif VARCACHE_PREF( - Live, - "apz.fling_curve_threshold_inches_per_ms", - APZCurveThreshold, - AtomicFloat, -1.0f + "dom.webnotifications.requireuserinteraction", + dom_webnotifications_requireuserinteraction, + RelaxedAtomicBool, PREF_VALUE ) +#undef PREF_VALUE VARCACHE_PREF( - Live, - "apz.fling_friction", - APZFlingFriction, - AtomicFloat, 0.002f + "dom.webnotifications.serviceworker.enabled", + dom_webnotifications_serviceworker_enabled, + RelaxedAtomicBool, true ) +#ifdef NIGHTLY_BUILD +# define PREF_VALUE true +#else +# define PREF_VALUE false +#endif VARCACHE_PREF( - Live, - "apz.fling_min_velocity_threshold", - APZFlingMinVelocityThreshold, - AtomicFloat, 0.5f + "dom.webnotifications.requireinteraction.enabled", + dom_webnotifications_requireinteraction_enabled, + RelaxedAtomicBool, PREF_VALUE ) +#undef PREF_VALUE VARCACHE_PREF( - Live, - "apz.fling_stop_on_tap_threshold", - APZFlingStopOnTapThreshold, - AtomicFloat, 0.05f + "dom.serviceWorkers.enabled", + dom_serviceWorkers_enabled, + RelaxedAtomicBool, false ) VARCACHE_PREF( - Live, - "apz.fling_stopped_threshold", - APZFlingStoppedThreshold, - AtomicFloat, 0.01f + "dom.serviceWorkers.testing.enabled", + dom_serviceWorkers_testing_enabled, + RelaxedAtomicBool, false ) VARCACHE_PREF( - Live, - "apz.frame_delay.enabled", - APZFrameDelayEnabled, + "dom.testing.structuredclonetester.enabled", + dom_testing_structuredclonetester_enabled, RelaxedAtomicBool, false ) +// Enable Storage API for all platforms except Android. +#if !defined(MOZ_WIDGET_ANDROID) +# define PREF_VALUE true +#else +# define PREF_VALUE false +#endif VARCACHE_PREF( - Once, - "apz.keyboard.enabled", - APZKeyboardEnabled, - bool, false + "dom.storageManager.enabled", + dom_storageManager_enabled, + RelaxedAtomicBool, PREF_VALUE ) +#undef PREF_VALUE +// WHATWG promise rejection events. See +// https://html.spec.whatwg.org/multipage/webappapis.html#promiserejectionevent +// TODO: Enable the event interface once actually firing it (bug 1362272). VARCACHE_PREF( - Live, - "apz.keyboard.passive-listeners", - APZKeyboardPassiveListeners, + "dom.promise_rejection_events.enabled", + dom_promise_rejection_events_enabled, RelaxedAtomicBool, false ) +// Push VARCACHE_PREF( - Live, - "apz.max_tap_time", - APZMaxTapTime, - RelaxedAtomicInt32, 300 -) - -VARCACHE_PREF( - Live, - "apz.max_velocity_inches_per_ms", - APZMaxVelocity, - AtomicFloat, -1.0f + "dom.push.enabled", + dom_push_enabled, + RelaxedAtomicBool, false ) +#if !defined(MOZ_WIDGET_ANDROID) +# define PREF_VALUE true +#else +# define PREF_VALUE false +#endif VARCACHE_PREF( - Once, - "apz.max_velocity_queue_size", - APZMaxVelocityQueueSize, - uint32_t, 5 + "dom.webkitBlink.dirPicker.enabled", + dom_webkitBlink_dirPicker_enabled, + RelaxedAtomicBool, PREF_VALUE ) +#undef PREF_VALUE +// Network Information API +#if defined(MOZ_WIDGET_ANDROID) +# define PREF_VALUE true +#else +# define PREF_VALUE false +#endif VARCACHE_PREF( - Live, - "apz.min_skate_speed", - APZMinSkateSpeed, - AtomicFloat, 1.0f + "dom.netinfo.enabled", + dom_netinfo_enabled, + RelaxedAtomicBool, PREF_VALUE ) +#undef PREF_VALUE VARCACHE_PREF( - Live, - "apz.minimap.enabled", - APZMinimap, + "dom.fetchObserver.enabled", + dom_fetchObserver_enabled, RelaxedAtomicBool, false ) +// Enable Performance API +// Whether nonzero values can be returned from performance.timing.* VARCACHE_PREF( - Live, - "apz.one_touch_pinch.enabled", - APZOneTouchPinchEnabled, + "dom.enable_performance", + dom_enable_performance, RelaxedAtomicBool, true ) +// Enable Performance Observer API VARCACHE_PREF( - Live, - "apz.overscroll.enabled", - APZOverscrollEnabled, - RelaxedAtomicBool, false + "dom.enable_performance_observer", + dom_enable_performance_observer, + RelaxedAtomicBool, true ) +// Whether resource timing will be gathered and returned by performance.GetEntries* VARCACHE_PREF( - Live, - "apz.overscroll.min_pan_distance_ratio", - APZMinPanDistanceRatio, - AtomicFloat, 1.0f + "dom.enable_resource_timing", + dom_enable_resource_timing, + bool, true ) +// Whether performance.GetEntries* will contain an entry for the active document VARCACHE_PREF( - Live, - "apz.overscroll.spring_stiffness", - APZOverscrollSpringStiffness, - AtomicFloat, 0.001f + "dom.enable_performance_navigation_timing", + dom_enable_performance_navigation_timing, + bool, true ) +// Enable notification of performance timing VARCACHE_PREF( - Live, - "apz.overscroll.stop_distance_threshold", - APZOverscrollStopDistanceThreshold, - AtomicFloat, 5.0f + "dom.performance.enable_notify_performance_timing", + dom_performance_enable_notify_performance_timing, + bool, false ) +// Render animations and videos as a solid color VARCACHE_PREF( - Live, - "apz.paint_skipping.enabled", - APZPaintSkipping, - RelaxedAtomicBool, true + "browser.measurement.render_anims_and_video_solid", + browser_measurement_render_anims_and_video_solid, + RelaxedAtomicBool, false ) +// Enable passing the "storage" option to indexedDB.open. VARCACHE_PREF( - Live, - "apz.peek_messages.enabled", - APZPeekMessages, - RelaxedAtomicBool, true + "dom.indexedDB.storageOption.enabled", + dom_indexedDB_storageOption_enabled, + RelaxedAtomicBool, false ) +#ifdef JS_BUILD_BINAST VARCACHE_PREF( - Live, - "apz.pinch_lock.mode", - APZPinchLockMode, - RelaxedAtomicInt32, 1 + "dom.script_loader.binast_encoding.enabled", + dom_script_loader_binast_encoding_enabled, + RelaxedAtomicBool, false ) VARCACHE_PREF( - Live, - "apz.pinch_lock.scroll_lock_threshold", - APZPinchLockScrollLockThreshold, - AtomicFloat, 1.0f / 32.0f + "dom.script_loader.binast_encoding.domain.restrict", + dom_script_loader_binast_encoding_domain_restrict, + bool, true ) +#endif +// Whether to enable the JavaScript start-up cache. This causes one of the first +// execution to record the bytecode of the JavaScript function used, and save it +// in the existing cache entry. On the following loads of the same script, the +// bytecode would be loaded from the cache instead of being generated once more. VARCACHE_PREF( - Live, - "apz.pinch_lock.span_breakout_threshold", - APZPinchLockSpanBreakoutThreshold, - AtomicFloat, 1.0f / 32.0f + "dom.script_loader.bytecode_cache.enabled", + dom_script_loader_bytecode_cache_enabled, + bool, true ) +// Ignore the heuristics of the bytecode cache, and always record on the first +// visit. (used for testing purposes). + +// Choose one strategy to use to decide when the bytecode should be encoded and +// saved. The following strategies are available right now: +// * -2 : (reader mode) The bytecode cache would be read, but it would never +// be saved. +// * -1 : (eager mode) The bytecode would be saved as soon as the script is +// seen for the first time, independently of the size or last access +// time. +// * 0 : (default) The bytecode would be saved in order to minimize the +// page-load time. +// +// Other values might lead to experimental strategies. For more details, have a +// look at: ScriptLoader::ShouldCacheBytecode function. VARCACHE_PREF( - Live, - "apz.pinch_lock.span_lock_threshold", - APZPinchLockSpanLockThreshold, - AtomicFloat, 1.0f / 32.0f + "dom.script_loader.bytecode_cache.strategy", + dom_script_loader_bytecode_cache_strategy, + int32_t, 0 ) +// Is support for compiling DOM worker scripts directly from UTF-8 (without ever +// inflating to UTF-16) enabled? +#ifdef RELEASE_OR_BETA +# define PREF_VALUE false +#else +# define PREF_VALUE true +#endif VARCACHE_PREF( - Once, - "apz.pinch_lock.buffer_max_age", - APZPinchLockBufferMaxAge, - int32_t, 50 + "dom.worker.script_loader.utf8_parsing.enabled", + dom_worker_script_loader_utf8_parsing_enabled, + RelaxedAtomicBool, PREF_VALUE ) +#undef PREF_VALUE VARCACHE_PREF( - Live, - "apz.popups.enabled", - APZPopupsEnabled, - RelaxedAtomicBool, false + "dom.worker.canceling.timeoutMilliseconds", + dom_worker_canceling_timeoutMilliseconds, + RelaxedAtomicUint32, 30000 /* 30 seconds */ ) VARCACHE_PREF( - Live, - "apz.printtree", - APZPrintTree, - RelaxedAtomicBool, false + "dom.worker.use_medium_high_event_queue", + dom_worker_use_medium_high_event_queue, + RelaxedAtomicBool, true ) +// IMPORTANT: Keep this condition in sync with all.js. The value of +// MOZILLA_OFFICIAL is different between full and artifact builds, so without +// it being specified there, dump is disabled in artifact builds. See +// bug 1490412. +#ifdef MOZILLA_OFFICIAL +# define PREF_VALUE false +#else +# define PREF_VALUE true +#endif VARCACHE_PREF( - Live, - "apz.record_checkerboarding", - APZRecordCheckerboarding, - RelaxedAtomicBool, false + "browser.dom.window.dump.enabled", + browser_dom_window_dump_enabled, + RelaxedAtomicBool, PREF_VALUE +) +#undef PREF_VALUE + +// Enable content type normalization of XHR uploads via MIME Sniffing standard +VARCACHE_PREF( + "dom.xhr.standard_content_type_normalization", + dom_xhr_standard_content_type_normalization, + RelaxedAtomicBool, true ) +// Block multiple external protocol URLs in iframes per single event. VARCACHE_PREF( - Live, - "apz.second_tap_tolerance", - APZSecondTapTolerance, - AtomicFloat, 0.5f + "dom.block_external_protocol_in_iframes", + dom_block_external_protocol_in_iframes, + bool, true ) +// Any how many seconds we allow external protocol URLs in iframe when not in +// single events VARCACHE_PREF( - Live, - "apz.test.fails_with_native_injection", - APZTestFailsWithNativeInjection, - RelaxedAtomicBool, false + "dom.delay.block_external_protocol_in_iframes", + dom_delay_block_external_protocol_in_iframes, + uint32_t, 10 // in seconds ) +// Block multiple window.open() per single event. VARCACHE_PREF( - Live, - "apz.test.logging_enabled", - APZTestLoggingEnabled, - RelaxedAtomicBool, false + "dom.block_multiple_popups", + dom_block_multiple_popups, + bool, true ) +// For area and anchor elements with target=_blank and no rel set to +// opener/noopener. +#ifdef EARLY_BETA_OR_EARLIER +#define PREF_VALUE true +#else +#define PREF_VALUE false +#endif +VARCACHE_PREF( + "dom.targetBlankNoOpener.enabled", + dom_targetBlankNoOpener_enabled, + bool, PREF_VALUE +) +#undef PREF_VALUE + VARCACHE_PREF( - Live, - "apz.touch_move_tolerance", - APZTouchMoveTolerance, - AtomicFloat, 0.1f + "dom.disable_open_during_load", + dom_disable_open_during_load, + bool, false ) +// Storage-access API. VARCACHE_PREF( - Live, - "apz.touch_start_tolerance", - APZTouchStartTolerance, - AtomicFloat, 1.0f/4.5f + "dom.storage_access.enabled", + dom_storage_access_enabled, + bool, false ) +// This currently only affects XHTML. For XUL the cache is always allowed. VARCACHE_PREF( - Live, - "apz.velocity_bias", - APZVelocityBias, - AtomicFloat, 0.0f + "dom.prototype_document_cache.enabled", + dom_prototype_document_cache_enabled, + bool, true ) VARCACHE_PREF( - Live, - "apz.velocity_relevance_time_ms", - APZVelocityRelevanceTime, - RelaxedAtomicUint32, 150 + "dom.storage_access.auto_grants.delayed", + dom_storage_access_auto_grants_delayed, + bool, true ) +// Enable the "noreferrer" feature argument for window.open() VARCACHE_PREF( - Live, - "apz.x_skate_highmem_adjust", - APZXSkateHighMemAdjust, - AtomicFloat, 0.0f + "dom.window.open.noreferrer.enabled", + dom_window_open_noreferrer_enabled, + bool, true ) +// Allow the content process to create a File from a path. This is allowed just +// on parent process, on 'file' Content process, or for testing. VARCACHE_PREF( - Live, - "apz.x_skate_size_multiplier", - APZXSkateSizeMultiplier, - AtomicFloat, 1.5f + "dom.file.createInChild", + dom_file_createInChild, + RelaxedAtomicBool, false ) +// Allow cut/copy VARCACHE_PREF( - Live, - "apz.x_stationary_size_multiplier", - APZXStationarySizeMultiplier, - AtomicFloat, 3.0f + "dom.allow_cut_copy", + dom_allow_cut_copy, + bool, true ) +// Support @autocomplete values for form autofill feature. VARCACHE_PREF( - Live, - "apz.y_skate_highmem_adjust", - APZYSkateHighMemAdjust, - AtomicFloat, 0.0f + "dom.forms.autocomplete.formautofill", + dom_forms_autocomplete_formautofill, + bool, false ) +// Enable requestIdleCallback API VARCACHE_PREF( - Live, - "apz.y_skate_size_multiplier", - APZYSkateSizeMultiplier, - AtomicFloat, 2.5f + "dom.requestIdleCallback.enabled", + dom_requestIdleCallback_enabled, + bool, true ) +// Whether we should show the placeholder when the element is focused but empty. VARCACHE_PREF( - Live, - "apz.y_stationary_size_multiplier", - APZYStationarySizeMultiplier, - AtomicFloat, 3.5f + "dom.placeholder.show_on_focus", + dom_placeholder_show_on_focus, + bool, true ) VARCACHE_PREF( - Live, - "apz.zoom_animation_duration_ms", - APZZoomAnimationDuration, - RelaxedAtomicInt32, 250 + "dom.presentation.testing.simulate-receiver", + dom_presentation_testing_simulate_receiver, + bool, false ) VARCACHE_PREF( - Live, - "apz.scale_repaint_delay_ms", - APZScaleRepaintDelay, - RelaxedAtomicInt32, 500 + "dom.largeAllocation.forceEnable", + dom_largeAllocation_forceEnable, + bool, false ) VARCACHE_PREF( - Live, - "apz.relative-update.enabled", - APZRelativeUpdate, - RelaxedAtomicBool, false + "dom.metaElement.setCookie.allowed", + dom_metaElement_setCookie_allowed, + bool, false ) VARCACHE_PREF( - Live, - "full-screen-api.mouse-event-allow-left-button-only", - full_screen_api_mouse_event_allow_left_button_only, + "dom.separate_event_queue_for_post_message.enabled", + dom_separate_event_queue_for_post_message_enabled, bool, true ) //--------------------------------------------------------------------------- -// Prefs starting with "browser." +// Extension prefs //--------------------------------------------------------------------------- -PREF("browser.active_color", String, "") -PREF("browser.anchor_color", String, "") +#ifdef ANDROID +// Private browsing opt-in is only supported on Firefox desktop. +# define PREF_VALUE true +#else +# define PREF_VALUE false +#endif +VARCACHE_PREF( + "extensions.allowPrivateBrowsingByDefault", + extensions_allowPrivateBrowsingByDefault, + bool, PREF_VALUE +) +#undef PREF_VALUE -// See http://dev.w3.org/html5/spec/forms.html#attr-fe-autofocus +// This pref should be set to true only in case of regression related to the +// changes applied in Bug 152591 (to be removed as part of Bug 1537753). VARCACHE_PREF( - Live, - "browser.autofocus", - browser_autofocus, - bool, true + "extensions.cookiesBehavior.overrideOnTopLevel", + extensions_cookiesBehavior_overrideOnTopLevel, + bool, false ) -// Whether Content Blocking Third-Party Cookies UI has been enabled. +//--------------------------------------------------------------------------- +// Full-screen prefs +//--------------------------------------------------------------------------- + VARCACHE_PREF( - Live, - "browser.contentblocking.allowlist.storage.enabled", - browser_contentblocking_allowlist_storage_enabled, + "full-screen-api.enabled", + full_screen_api_enabled, bool, false ) VARCACHE_PREF( - Live, - "browser.contentblocking.allowlist.annotations.enabled", - browser_contentblocking_allowlist_annotations_enabled, + "full-screen-api.unprefix.enabled", + full_screen_api_unprefix_enabled, bool, true ) -// How many recent block/unblock actions per origins we remember in the -// Content Blocking log for each top-level window. VARCACHE_PREF( - Live, - "browser.contentblocking.originlog.length", - browser_contentblocking_originlog_length, - uint32_t, 32 + "full-screen-api.allow-trusted-requests-only", + full_screen_api_allow_trusted_requests_only, + bool, true ) VARCACHE_PREF( - Live, - "browser.contentblocking.rejecttrackers.control-center.ui.enabled", - browser_contentblocking_rejecttrackers_control_center_ui_enabled, + "full-screen-api.mouse-event-allow-left-button-only", + full_screen_api_mouse_event_allow_left_button_only, + bool, true +) + +//--------------------------------------------------------------------------- +// Preference stylesheet prefs. +//--------------------------------------------------------------------------- + +VARCACHE_PREF( + "browser.display.focus_ring_on_anything", + browser_display_focus_ring_on_anything, bool, false ) -PREF("browser.display.background_color", String, "") +VARCACHE_PREF( + "browser.display.focus_ring_width", + browser_display_focus_ring_width, + uint32_t, 1 +) + +// 0=solid, 1=dotted +VARCACHE_PREF( + "browser.display.focus_ring_style", + browser_display_focus_ring_style, + uint32_t, 1 +) + +VARCACHE_PREF( + "browser.display.use_system_colors", + browser_display_use_system_colors, + bool, true +) // 0 = default: always, except in high contrast mode // 1 = always // 2 = never VARCACHE_PREF( - Live, "browser.display.document_color_use", - browser_display_document_color_use, + browser_display_document_color_use, uint32_t, 0 ) - VARCACHE_PREF( - Live, - "browser.display.focus_ring_on_anything", - browser_display_focus_ring_on_anything, + "browser.display.use_focus_colors", + browser_display_use_focus_colors, bool, false ) VARCACHE_PREF( - Live, - "browser.display.focus_ring_width", - browser_display_focus_ring_width, - uint32_t, 1 + "browser.underline_anchors", + browser_underline_anchors, + bool, true ) -PREF("browser.display.focus_background_color", String, "") - -// 0=solid, 1=dotted +// See http://dev.w3.org/html5/spec/forms.html#attr-fe-autofocus VARCACHE_PREF( - Live, - "browser.display.focus_ring_style", - browser_display_focus_ring_style, - uint32_t, 1 + "browser.autofocus", + browser_autofocus, + bool, true ) -PREF("browser.display.focus_text_color", String, "") PREF("browser.display.foreground_color", String, "") +PREF("browser.display.background_color", String, "") +PREF("browser.display.focus_background_color", String, "") +PREF("browser.display.focus_text_color", String, "") +PREF("browser.anchor_color", String, "") +PREF("browser.active_color", String, "") +PREF("browser.visited_color", String, "") + +//--------------------------------------------------------------------------- +// Graphics prefs +//--------------------------------------------------------------------------- // In theory: 0 = never, 1 = quick, 2 = always, though we always just use it as // a bool! VARCACHE_PREF( - Live, "browser.display.use_document_fonts", - browser_display_use_document_fonts, + browser_display_use_document_fonts, RelaxedAtomicInt32, 1 ) VARCACHE_PREF( - Live, - "browser.display.use_focus_colors", - browser_display_use_focus_colors, - bool, false + "gfx.font_rendering.opentype_svg.enabled", + gfx_font_rendering_opentype_svg_enabled, + bool, true ) VARCACHE_PREF( - Live, - "browser.display.use_system_colors", - browser_display_use_system_colors, - bool, true + "gfx.offscreencanvas.enabled", + gfx_offscreencanvas_enabled, + RelaxedAtomicBool, false ) -// IMPORTANT: Keep this in condition in sync with all.js. The value -// of MOZILLA_OFFICIAL is different between full and artifact builds, so without -// it being specified there, dump is disabled in artifact builds (see Bug 1490412). -#ifdef MOZILLA_OFFICIAL +VARCACHE_PREF( + "gfx.font_ahem_antialias_none", + gfx_font_ahem_antialias_none, + RelaxedAtomicBool, false +) + +#ifdef RELEASE_OR_BETA # define PREF_VALUE false #else # define PREF_VALUE true #endif VARCACHE_PREF( - Live, - "browser.dom.window.dump.enabled", - browser_dom_window_dump_enabled, - RelaxedAtomicBool, PREF_VALUE + "gfx.omta.background-color", + gfx_omta_background_color, + bool, PREF_VALUE ) #undef PREF_VALUE -// Render animations and videos as a solid color -VARCACHE_PREF( - Live, - "browser.measurement.render_anims_and_video_solid", - browser_measurement_render_anims_and_video_solid, - RelaxedAtomicBool, false -) - -// Blocked plugin content -VARCACHE_PREF( - Live, - "browser.safebrowsing.blockedURIs.enabled", - browser_safebrowsing_blockedURIs_enabled, - bool, true -) - -// Malware protection -VARCACHE_PREF( - Live, - "browser.safebrowsing.malware.enabled", - browser_safebrowsing_malware_enabled, - bool, true -) - -// Password protection -VARCACHE_PREF( - Live, - "browser.safebrowsing.passwords.enabled", - browser_safebrowsing_passwords_enabled, - bool, false -) - -// Phishing protection -VARCACHE_PREF( - Live, - "browser.safebrowsing.phishing.enabled", - browser_safebrowsing_phishing_enabled, - bool, true -) - -// Maximum size for an array to store the safebrowsing prefixset. -VARCACHE_PREF( - Live, - "browser.safebrowsing.prefixset_max_array_size", - browser_safebrowsing_prefixset_max_array_size, - RelaxedAtomicUint32, 512*1024 -) - -// ContentSessionStore prefs -// Maximum number of bytes of DOMSessionStorage data we collect per origin. -VARCACHE_PREF( - Live, - "browser.sessionstore.dom_storage_limit", - browser_sessionstore_dom_storage_limit, - uint32_t, 2048 -) - -// When this pref is enabled document loads with a mismatched -// Cross-Origin header will fail to load -VARCACHE_PREF( - Live, - "browser.tabs.remote.useCrossOriginPolicy", - browser_tabs_remote_useCrossOriginPolicy, - bool, false -) - -VARCACHE_PREF( - Live, - "browser.ui.scroll-toolbar-threshold", - ToolbarScrollThreshold, - RelaxedAtomicInt32, 10 -) - -VARCACHE_PREF( - Live, - "browser.ui.zoom.force-user-scalable", - ForceUserScalable, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "browser.underline_anchors", - browser_underline_anchors, - bool, true -) - -VARCACHE_PREF( - Live, - "browser.viewport.desktopWidth", - DesktopViewportWidth, - RelaxedAtomicInt32, 980 -) - -PREF("browser.visited_color", String, "") - -//--------------------------------------------------------------------------- -// Prefs starting with "channelclassifier." -//--------------------------------------------------------------------------- - -VARCACHE_PREF( - Live, - "channelclassifier.allowlist_example", - channelclassifier_allowlist_example, - bool, false -) - -//--------------------------------------------------------------------------- -// Prefs starting with "Clipboard." -//--------------------------------------------------------------------------- - -#if !defined(ANDROID) && !defined(XP_MACOSX) && defined(XP_UNIX) -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "clipboard.autocopy", - clipboard_autocopy, - bool, PREF_VALUE -) -#undef PREF_VALUE - -//--------------------------------------------------------------------------- -// Prefs starting with "devtools." -//--------------------------------------------------------------------------- - -VARCACHE_PREF( - Live, - "devtools.enabled", - devtools_enabled, - RelaxedAtomicBool, false -) - -#ifdef MOZILLA_OFFICIAL -# define PREF_VALUE false -#else -# define PREF_VALUE true -#endif -VARCACHE_PREF( - Live, - "devtools.console.stdout.chrome", - devtools_console_stdout_chrome, - RelaxedAtomicBool, PREF_VALUE -) -#undef PREF_VALUE - -VARCACHE_PREF( - Live, - "devtools.console.stdout.content", - devtools_console_stdout_content, - RelaxedAtomicBool, false -) - -//--------------------------------------------------------------------------- -// Prefs starting with "dom." -//--------------------------------------------------------------------------- - -// Allow cut/copy -VARCACHE_PREF( - Live, - "dom.allow_cut_copy", - dom_allow_cut_copy, - bool, true -) - -// Is support for automatically removing replaced filling animations enabled? -#ifdef RELEASE_OR_BETA -# define PREF_VALUE false -#else -# define PREF_VALUE true -#endif -VARCACHE_PREF( - Live, - "dom.animations-api.autoremove.enabled", - dom_animations_api_autoremove_enabled, - bool, PREF_VALUE -) -#undef PREF_VALUE - -// Is support for composite operations from the Web Animations API enabled? -#ifdef RELEASE_OR_BETA -# define PREF_VALUE false -#else -# define PREF_VALUE true -#endif -VARCACHE_PREF( - Live, - "dom.animations-api.compositing.enabled", - dom_animations_api_compositing_enabled, - bool, PREF_VALUE -) -#undef PREF_VALUE - -// Is support for the core interfaces of Web Animations API enabled? -VARCACHE_PREF( - Live, - "dom.animations-api.core.enabled", - dom_animations_api_core_enabled, - bool, true -) - -// Is support for Document.getAnimations() and Element.getAnimations() -// supported? -// -// Before enabling this by default, make sure also CSSPseudoElement interface -// has been spec'ed properly, or we should add a separate pref for -// CSSPseudoElement interface. See Bug 1174575 for further details. -#ifdef RELEASE_OR_BETA -# define PREF_VALUE false -#else -# define PREF_VALUE true -#endif -VARCACHE_PREF( - Live, - "dom.animations-api.getAnimations.enabled", - dom_animations_api_getAnimations_enabled, - bool, PREF_VALUE -) -#undef PREF_VALUE - -// Is support for animations from the Web Animations API without 0%/100% -// keyframes enabled? -#ifdef RELEASE_OR_BETA -# define PREF_VALUE false -#else -# define PREF_VALUE true -#endif -VARCACHE_PREF( - Live, - "dom.animations-api.implicit-keyframes.enabled", - dom_animations_api_implicit_keyframes_enabled, - bool, PREF_VALUE -) -#undef PREF_VALUE - -// Is support for timelines from the Web Animations API enabled? -#ifdef RELEASE_OR_BETA -# define PREF_VALUE false -#else -# define PREF_VALUE true -#endif -VARCACHE_PREF( - Live, - "dom.animations-api.timelines.enabled", - dom_animations_api_timelines_enabled, - bool, PREF_VALUE -) -#undef PREF_VALUE - -// Block multiple external protocol URLs in iframes per single event. -VARCACHE_PREF( - Live, - "dom.block_external_protocol_in_iframes", - dom_block_external_protocol_in_iframes, - bool, true -) - -// Block multiple window.open() per single event. -VARCACHE_PREF( - Live, - "dom.block_multiple_popups", - dom_block_multiple_popups, - bool, true -) - -// SW Cache API -VARCACHE_PREF( - Live, - "dom.caches.enabled", - dom_caches_enabled, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "dom.caches.testing.enabled", - dom_caches_testing_enabled, - RelaxedAtomicBool, false -) - -// Whether Mozilla specific "text" event should be dispatched only in the -// system group or not in content. -VARCACHE_PREF( - Live, - "dom.compositionevent.text.dispatch_only_system_group_in_content", - dom_compositionevent_text_dispatch_only_system_group_in_content, - bool, true -) - -// Any how many seconds we allow external protocol URLs in iframe when not in -// single events -VARCACHE_PREF( - Live, - "dom.delay.block_external_protocol_in_iframes", - dom_delay_block_external_protocol_in_iframes, - uint32_t, 10 // in seconds -) - -VARCACHE_PREF( - Live, - "dom.disable_open_during_load", - dom_disable_open_during_load, - bool, false -) - -// Enable Performance API -// Whether nonzero values can be returned from performance.timing.* -VARCACHE_PREF( - Live, - "dom.enable_performance", - dom_enable_performance, - RelaxedAtomicBool, true -) - -// Enable Performance Observer API -VARCACHE_PREF( - Live, - "dom.enable_performance_observer", - dom_enable_performance_observer, - RelaxedAtomicBool, true -) - -// Whether resource timing will be gathered and returned by performance.GetEntries* -VARCACHE_PREF( - Live, - "dom.enable_resource_timing", - dom_enable_resource_timing, - bool, true -) - -// Whether performance.GetEntries* will contain an entry for the active document -VARCACHE_PREF( - Live, - "dom.enable_performance_navigation_timing", - dom_enable_performance_navigation_timing, - bool, true -) - -// If this is true, it's allowed to fire "cut", "copy" and "paste" events. -// Additionally, "input" events may expose clipboard content when inputType -// is "insertFromPaste" or something. -VARCACHE_PREF( - Live, - "dom.event.clipboardevents.enabled", - dom_event_clipboardevents_enabled, - bool, true -) - -// Time limit, in milliseconds, for EventStateManager::IsHandlingUserInput(). -// Used to detect long running handlers of user-generated events. -VARCACHE_PREF( - Live, - "dom.event.handling-user-input-time-limit", - dom_event_handling_user_input_time_limit, - uint32_t, 1000 -) - -VARCACHE_PREF( - Live, - "dom.fetchObserver.enabled", - dom_fetchObserver_enabled, - RelaxedAtomicBool, false -) - -// Allow the content process to create a File from a path. This is allowed just -// on parent process, on 'file' Content process, or for testing. -VARCACHE_PREF( - Live, - "dom.file.createInChild", - dom_file_createInChild, - RelaxedAtomicBool, false -) - -// Support @autocomplete values for form autofill feature. -VARCACHE_PREF( - Live, - "dom.forms.autocomplete.formautofill", - dom_forms_autocomplete_formautofill, - bool, false -) - -// Enable passing the "storage" option to indexedDB.open. -VARCACHE_PREF( - Live, - "dom.indexedDB.storageOption.enabled", - dom_indexedDB_storageOption_enabled, - RelaxedAtomicBool, false -) - -// Whether we conform to Input Events Level 1 or Input Events Level 2. -// true: conforming to Level 1 -// false: conforming to Level 2 -VARCACHE_PREF( - Live, - "dom.input_events.conform_to_level_1", - dom_input_events_conform_to_level_1, - bool, true -) - -// Enable not moving the cursor to end when a text input or textarea has .value -// set to the value it already has. By default, enabled. -VARCACHE_PREF( - Live, - "dom.input.skip_cursor_move_for_same_value_set", - dom_input_skip_cursor_move_for_same_value_set, - bool, true -) - -#ifdef NIGHTLY_BUILD -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "dom.ipc.cancel_content_js_when_navigating", - dom_ipc_cancel_content_js_when_navigating, - bool, PREF_VALUE -) -#undef PREF_VALUE - -VARCACHE_PREF( - Live, - "dom.ipc.plugins.asyncdrawing.enabled", - PluginAsyncDrawingEnabled, - RelaxedAtomicBool, false -) - -// How long a content process can take before closing its IPC channel -// after shutdown is initiated. If the process exceeds the timeout, -// we fear the worst and kill it. -#if !defined(DEBUG) && !defined(MOZ_ASAN) && !defined(MOZ_VALGRIND) && \ - !defined(MOZ_TSAN) -# define PREF_VALUE 5 -#else -# define PREF_VALUE 0 -#endif -VARCACHE_PREF( - Live, - "dom.ipc.tabs.shutdownTimeoutSecs", - dom_ipc_tabs_shutdownTimeoutSecs, - RelaxedAtomicUint32, PREF_VALUE -) -#undef PREF_VALUE - -// If this is true, "keypress" event's keyCode value and charCode value always -// become same if the event is not created/initialized by JS. -VARCACHE_PREF( - Live, - "dom.keyboardevent.keypress.set_keycode_and_charcode_to_same_value", - dom_keyboardevent_keypress_set_keycode_and_charcode_to_same_value, - bool, true -) - -VARCACHE_PREF( - Live, - "dom.largeAllocation.forceEnable", - dom_largeAllocation_forceEnable, - bool, false -) - -// Whether the disabled attribute in HTMLLinkElement disables the sheet loading -// altogether, or forwards to the inner stylesheet method without attribute -// reflection. -// -// Historical behavior is the second, the first is being discussed at: -// https://github.com/whatwg/html/issues/3840 -VARCACHE_PREF( - Live, - "dom.link.disabled_attribute.enabled", - dom_link_disabled_attribute_enabled, - bool, true -) - -VARCACHE_PREF( - Live, - "dom.meta-viewport.enabled", - MetaViewportEnabled, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "dom.metaElement.setCookie.allowed", - dom_metaElement_setCookie_allowed, - bool, false -) - -// Whether we disable triggering mutation events for changes to style -// attribute via CSSOM. -// NOTE: This preference is used in unit tests. If it is removed or its default -// value changes, please update test_sharedMap_var_caches.js accordingly. -VARCACHE_PREF( - Live, - "dom.mutation-events.cssom.disabled", - dom_mutation_events_cssom_disabled, - bool, true -) - -// Network Information API -#if defined(MOZ_WIDGET_ANDROID) -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "dom.netinfo.enabled", - dom_netinfo_enabled, - RelaxedAtomicBool, PREF_VALUE -) -#undef PREF_VALUE - -// Enable/disable the PaymentRequest API -VARCACHE_PREF( - Live, - "dom.payments.request.enabled", - dom_payments_request_enabled, - bool, false -) - -// Whether a user gesture is required to call PaymentRequest.prototype.show(). -VARCACHE_PREF( - Live, - "dom.payments.request.user_interaction_required", - dom_payments_request_user_interaction_required, - bool, true -) - -// Time in milliseconds for PaymentResponse to wait for -// the Web page to call complete(). -VARCACHE_PREF( - Live, - "dom.payments.response.timeout", - dom_payments_response_timeout, - uint32_t, 5000 -) - -// Enable printing performance marks/measures to log -VARCACHE_PREF( - Live, - "dom.performance.enable_user_timing_logging", - dom_performance_enable_user_timing_logging, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "dom.performance.children_results_ipc_timeout", - dom_performance_children_results_ipc_timeout, - uint32_t, 1000 -) -#undef PREF_VALUE - -// Enable notification of performance timing -VARCACHE_PREF( - Live, - "dom.performance.enable_notify_performance_timing", - dom_performance_enable_notify_performance_timing, - bool, false -) - -// Whether we should show the placeholder when the element is focused but empty. -VARCACHE_PREF( - Live, - "dom.placeholder.show_on_focus", - dom_placeholder_show_on_focus, - bool, true -) - -VARCACHE_PREF( - Live, - "dom.presentation.testing.simulate-receiver", - dom_presentation_testing_simulate_receiver, - bool, false -) - -// WHATWG promise rejection events. See -// https://html.spec.whatwg.org/multipage/webappapis.html#promiserejectionevent -// TODO: Enable the event interface once actually firing it (bug 1362272). -VARCACHE_PREF( - Live, - "dom.promise_rejection_events.enabled", - dom_promise_rejection_events_enabled, - RelaxedAtomicBool, false -) - -// This currently only affects XHTML. For XUL the cache is always allowed. -VARCACHE_PREF( - Live, - "dom.prototype_document_cache.enabled", - dom_prototype_document_cache_enabled, - bool, true -) - -// Push -VARCACHE_PREF( - Live, - "dom.push.enabled", - dom_push_enabled, - RelaxedAtomicBool, false -) - -// Reporting API. -#ifdef NIGHTLY_BUILD -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "dom.reporting.enabled", - dom_reporting_enabled, - RelaxedAtomicBool, PREF_VALUE -) -#undef PREF_VALUE - -VARCACHE_PREF( - Live, - "dom.reporting.testing.enabled", - dom_reporting_testing_enabled, - RelaxedAtomicBool, false -) - -#ifdef NIGHTLY_BUILD -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "dom.reporting.featurePolicy.enabled", - dom_reporting_featurePolicy_enabled, - RelaxedAtomicBool, PREF_VALUE -) -#undef PREF_VALUE - -VARCACHE_PREF( - Live, - "dom.reporting.header.enabled", - dom_reporting_header_enabled, - RelaxedAtomicBool, false -) - -// In seconds. The timeout to remove not-active report-to endpoints. -VARCACHE_PREF( - Live, - "dom.reporting.cleanup.timeout", - dom_reporting_cleanup_timeout, - uint32_t, 3600 -) - -// Any X seconds the reports are dispatched to endpoints. -VARCACHE_PREF( - Live, - "dom.reporting.delivering.timeout", - dom_reporting_delivering_timeout, - uint32_t, 5 -) - -// How many times the delivering of a report should be tried. -VARCACHE_PREF( - Live, - "dom.reporting.delivering.maxFailures", - dom_reporting_delivering_maxFailures, - uint32_t, 3 -) - -// How many reports should be stored in the report queue before being delivered. -VARCACHE_PREF( - Live, - "dom.reporting.delivering.maxReports", - dom_reporting_delivering_maxReports, - uint32_t, 100 -) - -// Enable requestIdleCallback API -VARCACHE_PREF( - Live, - "dom.requestIdleCallback.enabled", - dom_requestIdleCallback_enabled, - bool, true -) - -#ifdef JS_BUILD_BINAST -VARCACHE_PREF( - Live, - "dom.script_loader.binast_encoding.domain.restrict", - dom_script_loader_binast_encoding_domain_restrict, - bool, true -) - -VARCACHE_PREF( - Live, - "dom.script_loader.binast_encoding.enabled", - dom_script_loader_binast_encoding_enabled, - RelaxedAtomicBool, false -) -#endif - -// Whether to enable the JavaScript start-up cache. This causes one of the first -// execution to record the bytecode of the JavaScript function used, and save it -// in the existing cache entry. On the following loads of the same script, the -// bytecode would be loaded from the cache instead of being generated once more. -VARCACHE_PREF( - Live, - "dom.script_loader.bytecode_cache.enabled", - dom_script_loader_bytecode_cache_enabled, - bool, true -) - -// Ignore the heuristics of the bytecode cache, and always record on the first -// visit. (used for testing purposes). - -// Choose one strategy to use to decide when the bytecode should be encoded and -// saved. The following strategies are available right now: -// * -2 : (reader mode) The bytecode cache would be read, but it would never -// be saved. -// * -1 : (eager mode) The bytecode would be saved as soon as the script is -// seen for the first time, independently of the size or last access -// time. -// * 0 : (default) The bytecode would be saved in order to minimize the -// page-load time. -// -// Other values might lead to experimental strategies. For more details, have a -// look at: ScriptLoader::ShouldCacheBytecode function. -VARCACHE_PREF( - Live, - "dom.script_loader.bytecode_cache.strategy", - dom_script_loader_bytecode_cache_strategy, - int32_t, 0 -) - -#ifdef NIGHTLY_BUILD -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif -// This pref enables FeaturePolicy logic and the parsing of 'allow' attribute in -// HTMLIFrameElement objects. -VARCACHE_PREF( - Live, - "dom.security.featurePolicy.enabled", - dom_security_featurePolicy_enabled, - bool, PREF_VALUE -) - -// This pref enables the featurePolicy header support. -VARCACHE_PREF( - Live, - "dom.security.featurePolicy.header.enabled", - dom_security_featurePolicy_header_enabled, - bool, PREF_VALUE -) - -// Expose the 'policy' attribute in document and HTMLIFrameElement -VARCACHE_PREF( - Live, - "dom.security.featurePolicy.webidl.enabled", - dom_security_featurePolicy_webidl_enabled, - bool, PREF_VALUE -) -#undef PREF_VALUE - -VARCACHE_PREF( - Live, - "dom.separate_event_queue_for_post_message.enabled", - dom_separate_event_queue_for_post_message_enabled, - bool, true -) - -VARCACHE_PREF( - Live, - "dom.serviceWorkers.enabled", - dom_serviceWorkers_enabled, - RelaxedAtomicBool, false -) - -// If true. then the service worker interception and the ServiceWorkerManager -// will live in the parent process. This only takes effect on browser start. -// Note, this is not currently safe to use for normal browsing yet. -PREF("dom.serviceWorkers.parent_intercept", bool, false) - -VARCACHE_PREF( - Live, - "dom.serviceWorkers.testing.enabled", - dom_serviceWorkers_testing_enabled, - RelaxedAtomicBool, false -) - -// Are shared memory User Agent style sheets enabled? -VARCACHE_PREF( - Live, - "dom.storage_access.auto_grants.delayed", - dom_storage_access_auto_grants_delayed, - bool, true -) - -// Storage-access API. -VARCACHE_PREF( - Live, - "dom.storage_access.enabled", - dom_storage_access_enabled, - bool, false -) - -// Enable Storage API for all platforms except Android. -#if !defined(MOZ_WIDGET_ANDROID) -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "dom.storageManager.enabled", - dom_storageManager_enabled, - RelaxedAtomicBool, PREF_VALUE -) -#undef PREF_VALUE - -// For area and anchor elements with target=_blank and no rel set to -// opener/noopener. -#ifdef EARLY_BETA_OR_EARLIER -#define PREF_VALUE true -#else -#define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "dom.targetBlankNoOpener.enabled", - dom_targetBlankNoOpener_enabled, - bool, PREF_VALUE -) -#undef PREF_VALUE - -VARCACHE_PREF( - Live, - "dom.testing.structuredclonetester.enabled", - dom_testing_structuredclonetester_enabled, - RelaxedAtomicBool, false -) - -// Should we defer timeouts and intervals while loading a page. Released -// on Idle or when the page is loaded. -VARCACHE_PREF( - Live, - "dom.timeout.defer_during_load", - dom_timeout_defer_during_load, - bool, true -) - -// Maximum deferral time for setTimeout/Interval in milliseconds -VARCACHE_PREF( - Live, - "dom.timeout.max_idle_defer_ms", - dom_timeout_max_idle_defer_ms, - uint32_t, 10*1000 -) - -VARCACHE_PREF( - Once, - "dom.vr.enabled", - VREnabled, - bool, false -) - -VARCACHE_PREF( - Live, - "dom.vr.autoactivate.enabled", - VRAutoActivateEnabled, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "dom.vr.controller.enumerate.interval", - VRControllerEnumerateInterval, - RelaxedAtomicInt32, 1000 -) - -VARCACHE_PREF( - Live, - "dom.vr.controller_trigger_threshold", - VRControllerTriggerThreshold, - AtomicFloat, 0.1f -) - -VARCACHE_PREF( - Live, - "dom.vr.display.enumerate.interval", - VRDisplayEnumerateInterval, - RelaxedAtomicInt32, 5000 -) - -VARCACHE_PREF( - Live, - "dom.vr.display.rafMaxDuration", - VRDisplayRafMaxDuration, - RelaxedAtomicUint32, 50 -) - -VARCACHE_PREF( - Once, - "dom.vr.external.enabled", - VRExternalEnabled, - bool, false -) - -VARCACHE_PREF( - Live, - "dom.vr.external.notdetected.timeout", - VRExternalNotDetectedTimeout, - RelaxedAtomicInt32, 60000 -) - -VARCACHE_PREF( - Live, - "dom.vr.external.quit.timeout", - VRExternalQuitTimeout, - RelaxedAtomicInt32, 10000 -) - -VARCACHE_PREF( - Live, - "dom.vr.inactive.timeout", - VRInactiveTimeout, - RelaxedAtomicInt32, 5000 -) - -VARCACHE_PREF( - Live, - "dom.vr.navigation.timeout", - VRNavigationTimeout, - RelaxedAtomicInt32, 1000 -) - -VARCACHE_PREF( - Once, - "dom.vr.oculus.enabled", - VROculusEnabled, - bool, true -) - -VARCACHE_PREF( - Live, - "dom.vr.oculus.invisible.enabled", - VROculusInvisibleEnabled, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "dom.vr.oculus.present.timeout", - VROculusPresentTimeout, - RelaxedAtomicInt32, 500 -) - -VARCACHE_PREF( - Live, - "dom.vr.oculus.quit.timeout", - VROculusQuitTimeout, - RelaxedAtomicInt32, 10000 -) - -VARCACHE_PREF( - Once, - "dom.vr.openvr.enabled", - VROpenVREnabled, - bool, false -) - -VARCACHE_PREF( - Once, - "dom.vr.openvr.action_input", - VROpenVRActionInputEnabled, - bool, true -) - -VARCACHE_PREF( - Once, - "dom.vr.osvr.enabled", - VROSVREnabled, - bool, false -) - -VARCACHE_PREF( - Live, - "dom.vr.poseprediction.enabled", - VRPosePredictionEnabled, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Once, - "dom.vr.process.enabled", - VRProcessEnabled, - bool, false -) - -VARCACHE_PREF( - Once, - "dom.vr.process.startup_timeout_ms", - VRProcessTimeoutMs, - int32_t, 5000 -) - -VARCACHE_PREF( - Live, - "dom.vr.puppet.enabled", - VRPuppetEnabled, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "dom.vr.puppet.submitframe", - VRPuppetSubmitFrame, - RelaxedAtomicUint32, 0 -) - -VARCACHE_PREF( - Live, - "dom.vr.require-gesture", - VRRequireGesture, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Once, - "dom.vr.service.enabled", - VRServiceEnabled, - bool, true -) - -VARCACHE_PREF( - Live, - "dom.w3c_pointer_events.enabled", - PointerEventsEnabled, - RelaxedAtomicBool, false -) - -// In case Touch API is enabled, this pref controls whether to support -// ontouch* event handlers, document.createTouch, document.createTouchList and -// document.createEvent("TouchEvent"). -#ifdef ANDROID -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "dom.w3c_touch_events.legacy_apis.enabled", - dom_w3c_touch_events_legacy_apis_enabled, - bool, PREF_VALUE -) -#undef PREF_VALUE - -#if !defined(MOZ_WIDGET_ANDROID) -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "dom.webkitBlink.dirPicker.enabled", - dom_webkitBlink_dirPicker_enabled, - RelaxedAtomicBool, PREF_VALUE -) -#undef PREF_VALUE - -// NOTE: This preference is used in unit tests. If it is removed or its default -// value changes, please update test_sharedMap_var_caches.js accordingly. -VARCACHE_PREF( - Live, - "dom.webcomponents.shadowdom.report_usage", - dom_webcomponents_shadowdom_report_usage, - bool, false -) - -VARCACHE_PREF( - Live, - "dom.webnotifications.allowinsecure", - dom_webnotifications_allowinsecure, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "dom.webnotifications.enabled", - dom_webnotifications_enabled, - RelaxedAtomicBool, true -) - -#ifdef EARLY_BETA_OR_EARLIER -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "dom.webnotifications.requireuserinteraction", - dom_webnotifications_requireuserinteraction, - RelaxedAtomicBool, PREF_VALUE -) -#undef PREF_VALUE - -#ifdef NIGHTLY_BUILD -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "dom.webnotifications.requireinteraction.enabled", - dom_webnotifications_requireinteraction_enabled, - RelaxedAtomicBool, PREF_VALUE -) -#undef PREF_VALUE - -VARCACHE_PREF( - Live, - "dom.webnotifications.serviceworker.enabled", - dom_webnotifications_serviceworker_enabled, - RelaxedAtomicBool, true -) - -// Enable the "noreferrer" feature argument for window.open() -VARCACHE_PREF( - Live, - "dom.window.open.noreferrer.enabled", - dom_window_open_noreferrer_enabled, - bool, true -) - -VARCACHE_PREF( - Live, - "dom.worker.canceling.timeoutMilliseconds", - dom_worker_canceling_timeoutMilliseconds, - RelaxedAtomicUint32, 30000 /* 30 seconds */ -) - -// Is support for compiling DOM worker scripts directly from UTF-8 (without ever -// inflating to UTF-16) enabled? -#ifdef RELEASE_OR_BETA -# define PREF_VALUE false -#else -# define PREF_VALUE true -#endif -VARCACHE_PREF( - Live, - "dom.worker.script_loader.utf8_parsing.enabled", - dom_worker_script_loader_utf8_parsing_enabled, - RelaxedAtomicBool, PREF_VALUE -) -#undef PREF_VALUE - -VARCACHE_PREF( - Live, - "dom.worker.use_medium_high_event_queue", - dom_worker_use_medium_high_event_queue, - RelaxedAtomicBool, true -) - -// Enable content type normalization of XHR uploads via MIME Sniffing standard -VARCACHE_PREF( - Live, - "dom.xhr.standard_content_type_normalization", - dom_xhr_standard_content_type_normalization, - RelaxedAtomicBool, true -) - -//--------------------------------------------------------------------------- -// Prefs starting with "extensions." -//--------------------------------------------------------------------------- - -#ifdef ANDROID -// Private browsing opt-in is only supported on Firefox desktop. -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "extensions.allowPrivateBrowsingByDefault", - extensions_allowPrivateBrowsingByDefault, - bool, PREF_VALUE -) -#undef PREF_VALUE - -// This pref should be set to true only in case of regression related to the -// changes applied in Bug 152591 (to be removed as part of Bug 1537753). -VARCACHE_PREF( - Live, - "extensions.cookiesBehavior.overrideOnTopLevel", - extensions_cookiesBehavior_overrideOnTopLevel, - bool, false -) - -//--------------------------------------------------------------------------- -// Full-screen prefs -//--------------------------------------------------------------------------- - -VARCACHE_PREF( - Live, - "full-screen-api.enabled", - full_screen_api_enabled, - bool, false -) - -VARCACHE_PREF( - Live, - "full-screen-api.unprefix.enabled", - full_screen_api_unprefix_enabled, - bool, true -) - -VARCACHE_PREF( - Live, - "full-screen-api.allow-trusted-requests-only", - full_screen_api_allow_trusted_requests_only, - bool, true -) - -//--------------------------------------------------------------------------- -// Prefs starting with "Fuzzing.". It's important that these can only be checked in fuzzing -// builds (when FUZZING is defined), otherwise you could enable the fuzzing -// stuff on your regular build which would be bad :) -//--------------------------------------------------------------------------- - -#ifdef FUZZING -VARCACHE_PREF( - Live, - "fuzzing.enabled", - fuzzing_enabled, - bool, false -) - -VARCACHE_PREF( - Live, - "fuzzing.necko.enabled", - fuzzing_necko_enabled, - RelaxedAtomicBool, false -) -#endif - -//--------------------------------------------------------------------------- -// Prefs starting with "general." -//--------------------------------------------------------------------------- - -VARCACHE_PREF( - Live, - "general.smoothScroll", - SmoothScrollEnabled, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.currentVelocityWeighting", - SmoothScrollCurrentVelocityWeighting, - AtomicFloat, 0.25 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.durationToIntervalRatio", - SmoothScrollDurationToIntervalRatio, - RelaxedAtomicInt32, 200 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.lines.durationMaxMS", - LineSmoothScrollMaxDurationMs, - RelaxedAtomicInt32, 150 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.lines.durationMinMS", - LineSmoothScrollMinDurationMs, - RelaxedAtomicInt32, 150 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.mouseWheel", - WheelSmoothScrollEnabled, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.mouseWheel.durationMaxMS", - WheelSmoothScrollMaxDurationMs, - RelaxedAtomicInt32, 400 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.mouseWheel.durationMinMS", - WheelSmoothScrollMinDurationMs, - RelaxedAtomicInt32, 200 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.other.durationMaxMS", - OtherSmoothScrollMaxDurationMs, - RelaxedAtomicInt32, 150 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.other.durationMinMS", - OtherSmoothScrollMinDurationMs, - RelaxedAtomicInt32, 150 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.pages", - PageSmoothScrollEnabled, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.pages.durationMaxMS", - PageSmoothScrollMaxDurationMs, - RelaxedAtomicInt32, 150 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.pages.durationMinMS", - PageSmoothScrollMinDurationMs, - RelaxedAtomicInt32, 150 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.pixels.durationMaxMS", - PixelSmoothScrollMaxDurationMs, - RelaxedAtomicInt32, 150 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.pixels.durationMinMS", - PixelSmoothScrollMinDurationMs, - RelaxedAtomicInt32, 150 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.stopDecelerationWeighting", - SmoothScrollStopDecelerationWeighting, - AtomicFloat, 0.4f -) - - -VARCACHE_PREF( - Live, - "general.smoothScroll.msdPhysics.enabled", - SmoothScrollMSDPhysicsEnabled, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.msdPhysics.continuousMotionMaxDeltaMS", - SmoothScrollMSDPhysicsContinuousMotionMaxDeltaMS, - RelaxedAtomicInt32, 120 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.msdPhysics.motionBeginSpringConstant", - SmoothScrollMSDPhysicsMotionBeginSpringConstant, - RelaxedAtomicInt32, 1250 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.msdPhysics.slowdownMinDeltaMS", - SmoothScrollMSDPhysicsSlowdownMinDeltaMS, - RelaxedAtomicInt32, 12 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.msdPhysics.slowdownMinDeltaRatio", - SmoothScrollMSDPhysicsSlowdownMinDeltaRatio, - AtomicFloat, 1.3f -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.msdPhysics.slowdownSpringConstant", - SmoothScrollMSDPhysicsSlowdownSpringConstant, - RelaxedAtomicInt32, 2000 -) - -VARCACHE_PREF( - Live, - "general.smoothScroll.msdPhysics.regularSpringConstant", - SmoothScrollMSDPhysicsRegularSpringConstant, - RelaxedAtomicInt32, 1000 -) - -//--------------------------------------------------------------------------- -// Prefs starting with "gl." (OpenGL) -//--------------------------------------------------------------------------- - -VARCACHE_PREF( - Live, - "gl.allow-high-power", - GLAllowHighPower, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "gl.ignore-dx-interop2-blacklist", - IgnoreDXInterop2Blacklist, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "gl.msaa-level", - MSAALevel, - RelaxedAtomicUint32, 2 -) - -#if defined(XP_MACOSX) -VARCACHE_PREF( - Live, - "gl.multithreaded", - GLMultithreaded, - RelaxedAtomicBool, false -) - -#endif -VARCACHE_PREF( - Live, - "gl.require-hardware", - RequireHardwareGL, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "gl.use-tls-is-current", - UseTLSIsCurrent, - RelaxedAtomicInt32, 0 -) - -//--------------------------------------------------------------------------- -// Prefs starting with "Graphics." -//--------------------------------------------------------------------------- - -VARCACHE_PREF( - Once, - "gfx.allow-texture-direct-mapping", - AllowTextureDirectMapping, - bool, true -) - -VARCACHE_PREF( - Once, - "gfx.android.rgb16.force", - AndroidRGB16Force, - bool, false -) - -VARCACHE_PREF( - Once, - "gfx.apitrace.enabled", - UseApitrace, - bool, false -) - -#if defined(RELEASE_OR_BETA) -// "Skip" means this is locked to the default value in beta and release. -VARCACHE_PREF( - Skip, - "gfx.blocklist.all", - BlocklistAll, - int32_t, 0 -) -#else -VARCACHE_PREF( - Once, - "gfx.blocklist.all", - BlocklistAll, - int32_t, 0 -) -#endif - -// 0x7fff is the maximum supported xlib surface size and is more than enough for canvases. -VARCACHE_PREF( - Live, - "gfx.canvas.max-size", - MaxCanvasSize, - RelaxedAtomicInt32, 0x7fff -) - -VARCACHE_PREF( - Live, - "gfx.color_management.enablev4", - CMSEnableV4, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "gfx.color_management.mode", - CMSMode, - RelaxedAtomicInt32, -1 -) - -// The zero default here should match QCMS_INTENT_DEFAULT from qcms.h -VARCACHE_PREF( - Live, - "gfx.color_management.rendering_intent", - CMSRenderingIntent, - RelaxedAtomicInt32, 0 -) - -VARCACHE_PREF( - Live, - "gfx.compositor.clearstate", - CompositorClearState, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "gfx.compositor.glcontext.opaque", - CompositorGLContextOpaque, - RelaxedAtomicBool, false -) - -#if defined(MOZ_WIDGET_ANDROID) -// Overrides the glClear color used when the surface origin is not (0, 0) -// Used for drawing a border around the content. -VARCACHE_PREF( - Live, - "gfx.compositor.override.clear-color.r", - CompositorOverrideClearColorR, - AtomicFloat, 0.0f -) - -VARCACHE_PREF( - Live, - "gfx.compositor.override.clear-color.g", - CompositorOverrideClearColorG, - AtomicFloat, 0.0f -) - -VARCACHE_PREF( - Live, - "gfx.compositor.override.clear-color.b", - CompositorOverrideClearColorB, - AtomicFloat, 0.0f -) - -VARCACHE_PREF( - Live, - "gfx.compositor.override.clear-color.a", - CompositorOverrideClearColorA, - AtomicFloat, 0.0f -) -#endif // defined(MOZ_WIDGET_ANDROID) - -VARCACHE_PREF( - Live, - "gfx.content.always-paint", - AlwaysPaint, - RelaxedAtomicBool, false -) - -// Size in megabytes -VARCACHE_PREF( - Once, - "gfx.content.skia-font-cache-size", - SkiaContentFontCacheSize, - int32_t, 5 -) - -VARCACHE_PREF( - Once, - "gfx.device-reset.limit", - DeviceResetLimitCount, - int32_t, 10 -) - -VARCACHE_PREF( - Once, - "gfx.device-reset.threshold-ms", - DeviceResetThresholdMilliseconds, - int32_t, -1 -) - - -VARCACHE_PREF( - Once, - "gfx.direct2d.disabled", - Direct2DDisabled, - bool, false -) - -VARCACHE_PREF( - Once, - "gfx.direct2d.force-enabled", - Direct2DForceEnabled, - bool, false -) - -VARCACHE_PREF( - Live, - "gfx.direct2d.destroy-dt-on-paintthread", - Direct2DDestroyDTOnPaintThread, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "gfx.direct3d11.reuse-decoder-device", - Direct3D11ReuseDecoderDevice, - RelaxedAtomicInt32, -1 -) - -VARCACHE_PREF( - Live, - "gfx.direct3d11.allow-keyed-mutex", - Direct3D11AllowKeyedMutex, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "gfx.direct3d11.use-double-buffering", - Direct3D11UseDoubleBuffering, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "gfx.direct3d11.enable-debug-layer", - Direct3D11EnableDebugLayer, - bool, false -) - -VARCACHE_PREF( - Once, - "gfx.direct3d11.break-on-error", - Direct3D11BreakOnError, - bool, false -) - -VARCACHE_PREF( - Once, - "gfx.direct3d11.sleep-on-create-device", - Direct3D11SleepOnCreateDevice, - int32_t, 0 -) - -VARCACHE_PREF( - Live, - "gfx.downloadable_fonts.keep_color_bitmaps", - KeepColorBitmaps, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "gfx.downloadable_fonts.validate_variation_tables", - ValidateVariationTables, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "gfx.downloadable_fonts.otl_validation", - ValidateOTLTables, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "gfx.draw-color-bars", - CompositorDrawColorBars, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "gfx.e10s.hide-plugins-for-scroll", - HidePluginsForScroll, - bool, true -) - -VARCACHE_PREF( - Once, - "gfx.e10s.font-list.shared", - SharedFontList, - bool, false -) - -VARCACHE_PREF( - Live, - "gfx.font_ahem_antialias_none", - gfx_font_ahem_antialias_none, - RelaxedAtomicBool, false -) - -#if defined(XP_MACOSX) -VARCACHE_PREF( - Live, - "gfx.font_rendering.coretext.enabled", - CoreTextEnabled, - RelaxedAtomicBool, false -) -#endif - -VARCACHE_PREF( - Live, - "gfx.font_rendering.opentype_svg.enabled", - gfx_font_rendering_opentype_svg_enabled, - bool, true -) - -VARCACHE_PREF( - Live, - "gfx.layerscope.enabled", - LayerScopeEnabled, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "gfx.layerscope.port", - LayerScopePort, - RelaxedAtomicInt32, 23456 -) - -// Note that "gfx.logging.level" is defined in Logging.h. -VARCACHE_PREF( - Live, - "gfx.logging.level", - GfxLoggingLevel, - RelaxedAtomicInt32, mozilla::gfx::LOG_DEFAULT -) - -VARCACHE_PREF( - Once, - "gfx.logging.crash.length", - GfxLoggingCrashLength, - uint32_t, 16 -) - -VARCACHE_PREF( - Live, - "gfx.logging.painted-pixel-count.enabled", - GfxLoggingPaintedPixelCountEnabled, - RelaxedAtomicBool, false -) - -// The maximums here are quite conservative, we can tighten them if problems show up. -VARCACHE_PREF( - Once, - "gfx.logging.texture-usage.enabled", - GfxLoggingTextureUsageEnabled, - bool, false -) - -VARCACHE_PREF( - Once, - "gfx.logging.peak-texture-usage.enabled", - GfxLoggingPeakTextureUsageEnabled, - bool, false -) - -VARCACHE_PREF( - Once, - "gfx.logging.slow-frames.enabled", - LoggingSlowFramesEnabled, - bool, false -) - -// Use gfxPlatform::MaxAllocSize instead of the pref directly -VARCACHE_PREF( - Once, - "gfx.max-alloc-size", - MaxAllocSizeDoNotUseDirectly, - int32_t, (int32_t)500000000 -) - -// Use gfxPlatform::MaxTextureSize instead of the pref directly -VARCACHE_PREF( - Once, - "gfx.max-texture-size", - MaxTextureSizeDoNotUseDirectly, - int32_t, (int32_t)32767 -) - -VARCACHE_PREF( - Live, - "gfx.offscreencanvas.enabled", - gfx_offscreencanvas_enabled, - RelaxedAtomicBool, false -) - -#ifdef RELEASE_OR_BETA -# define PREF_VALUE false -#else -# define PREF_VALUE true -#endif -VARCACHE_PREF( - Live, - "gfx.omta.background-color", - gfx_omta_background_color, - bool, PREF_VALUE -) -#undef PREF_VALUE - -VARCACHE_PREF( - Live, - "gfx.partialpresent.force", - PartialPresent, - RelaxedAtomicInt32, 0 -) - -VARCACHE_PREF( - Live, - "gfx.perf-warnings.enabled", - PerfWarnings, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "gfx.testing.device-fail", - DeviceFailForTesting, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "gfx.testing.device-reset", - DeviceResetForTesting, - RelaxedAtomicInt32, 0 -) - -VARCACHE_PREF( - Once, - "gfx.text.disable-aa", - DisableAllTextAA, - bool, false -) - -// Disable surface sharing due to issues with compatible FBConfigs on -// NVIDIA drivers as described in bug 1193015. -VARCACHE_PREF( - Live, - "gfx.use-glx-texture-from-pixmap", - UseGLXTextureFromPixmap, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "gfx.use-iosurface-textures", - UseIOSurfaceTextures, - bool, false -) - -VARCACHE_PREF( - Once, - "gfx.use-mutex-on-present", - UseMutexOnPresent, - bool, false -) - -VARCACHE_PREF( - Once, - "gfx.use-surfacetexture-textures", - UseSurfaceTextureTextures, - bool, false -) - -VARCACHE_PREF( - Live, - "gfx.vsync.collect-scroll-transforms", - CollectScrollTransforms, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "gfx.vsync.compositor.unobserve-count", - CompositorUnobserveCount, - int32_t, 10 -) - -VARCACHE_PREF( - Once, - "gfx.webrender.all", - WebRenderAll, - bool, false -) - -VARCACHE_PREF( - Live, - "gfx.webrender.blob-images", - WebRenderBlobImages, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "gfx.webrender.blob.invalidation", - WebRenderBlobInvalidation, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "gfx.webrender.blob.paint-flashing", - WebRenderBlobPaintFlashing, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "gfx.webrender.dl.dump-parent", - WebRenderDLDumpParent, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "gfx.webrender.dl.dump-content", - WebRenderDLDumpContent, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "gfx.webrender.enabled", - WebRenderEnabledDoNotUseDirectly, - bool, false -) - -VARCACHE_PREF( - Once, - "gfx.webrender.force-disabled", - WebRenderForceDisabled, - bool, false -) - -VARCACHE_PREF( - Live, - "gfx.webrender.highlight-painted-layers", - WebRenderHighlightPaintedLayers, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "gfx.webrender.late-scenebuild-threshold", - WebRenderLateSceneBuildThreshold, - RelaxedAtomicInt32, 4 -) - -VARCACHE_PREF( - Live, - "gfx.webrender.max-filter-ops-per-chain", - WebRenderMaxFilterOpsPerChain, - RelaxedAtomicUint32, 64 -) - -VARCACHE_PREF( - Live, - "gfx.webrender.picture-caching", - WebRenderPictureCaching, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "gfx.webrender.split-render-roots", - WebRenderSplitRenderRoots, - bool, false -) - -VARCACHE_PREF( - Live, - "gfx.webrender.start-debug-server", - WebRenderStartDebugServer, - RelaxedAtomicBool, false -) - -// Use vsync events generated by hardware -VARCACHE_PREF( - Once, - "gfx.work-around-driver-bugs", - WorkAroundDriverBugs, - bool, true -) - -VARCACHE_PREF( - Live, - "gfx.ycbcr.accurate-conversion", - YCbCrAccurateConversion, - RelaxedAtomicBool, false -) - -//--------------------------------------------------------------------------- -// HTML5 parser prefs -//--------------------------------------------------------------------------- - -// Toggle which thread the HTML5 parser uses for stream parsing. -VARCACHE_PREF( - Live, - "html5.offmainthread", - html5_offmainthread, - bool, true -) - -// Time in milliseconds between the time a network buffer is seen and the timer -// firing when the timer hasn't fired previously in this parse in the -// off-the-main-thread HTML5 parser. -VARCACHE_PREF( - Live, - "html5.flushtimer.initialdelay", - html5_flushtimer_initialdelay, - RelaxedAtomicInt32, 16 -) - -// Time in milliseconds between the time a network buffer is seen and the timer -// firing when the timer has already fired previously in this parse. -VARCACHE_PREF( - Live, - "html5.flushtimer.subsequentdelay", - html5_flushtimer_subsequentdelay, - RelaxedAtomicInt32, 16 -) - -//--------------------------------------------------------------------------- -// Prefs starting with "Image." -//--------------------------------------------------------------------------- - -VARCACHE_PREF( - Live, - "image.animated.decode-on-demand.threshold-kb", - ImageAnimatedDecodeOnDemandThresholdKB, - RelaxedAtomicUint32, 20480 -) - -VARCACHE_PREF( - Live, - "image.animated.decode-on-demand.batch-size", - ImageAnimatedDecodeOnDemandBatchSize, - RelaxedAtomicUint32, 6 -) - -VARCACHE_PREF( - Live, - "image.animated.decode-on-demand.recycle", - ImageAnimatedDecodeOnDemandRecycle, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "image.animated.resume-from-last-displayed", - ImageAnimatedResumeFromLastDisplayed, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "image.cache.factor2.threshold-surfaces", - ImageCacheFactor2ThresholdSurfaces, - RelaxedAtomicInt32, -1 -) - -VARCACHE_PREF( - Live, - "image.cache.max-rasterized-svg-threshold-kb", - ImageCacheMaxRasterizedSVGThresholdKB, - RelaxedAtomicInt32, 90*1024 -) - -VARCACHE_PREF( - Once, - "image.cache.size", - ImageCacheSize, - int32_t, 5*1024*1024 -) - -VARCACHE_PREF( - Once, - "image.cache.timeweight", - ImageCacheTimeWeight, - int32_t, 500 -) - -VARCACHE_PREF( - Live, - "image.decode-immediately.enabled", - ImageDecodeImmediatelyEnabled, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "image.downscale-during-decode.enabled", - ImageDownscaleDuringDecodeEnabled, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "image.infer-src-animation.threshold-ms", - ImageInferSrcAnimationThresholdMS, - RelaxedAtomicUint32, 2000 -) - -VARCACHE_PREF( - Live, - "image.layout_network_priority", - ImageLayoutNetworkPriority, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Once, - "image.mem.decode_bytes_at_a_time", - ImageMemDecodeBytesAtATime, - uint32_t, 200000 -) - -VARCACHE_PREF( - Live, - "image.mem.discardable", - ImageMemDiscardable, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "image.mem.animated.discardable", - ImageMemAnimatedDiscardable, - bool, false -) - -VARCACHE_PREF( - Live, - "image.mem.animated.use_heap", - ImageMemAnimatedUseHeap, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "image.mem.debug-reporting", - ImageMemDebugReporting, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "image.mem.shared", - ImageMemShared, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Once, - "image.mem.surfacecache.discard_factor", - ImageMemSurfaceCacheDiscardFactor, - uint32_t, 1 -) - -VARCACHE_PREF( - Once, - "image.mem.surfacecache.max_size_kb", - ImageMemSurfaceCacheMaxSizeKB, - uint32_t, 100 * 1024 -) - -VARCACHE_PREF( - Once, - "image.mem.surfacecache.min_expiration_ms", - ImageMemSurfaceCacheMinExpirationMS, - uint32_t, 60*1000 -) - -VARCACHE_PREF( - Once, - "image.mem.surfacecache.size_factor", - ImageMemSurfaceCacheSizeFactor, - uint32_t, 64 -) - -VARCACHE_PREF( - Live, - "image.mem.volatile.min_threshold_kb", - ImageMemVolatileMinThresholdKB, - RelaxedAtomicInt32, -1 -) - -VARCACHE_PREF( - Once, - "image.multithreaded_decoding.idle_timeout", - ImageMTDecodingIdleTimeout, - int32_t, -1 -) - -VARCACHE_PREF( - Once, - "image.multithreaded_decoding.limit", - ImageMTDecodingLimit, - int32_t, -1 -) - -VARCACHE_PREF( - Live, - "image.webp.enabled", - ImageWebPEnabled, - RelaxedAtomicBool, false -) - -//--------------------------------------------------------------------------- -// Prefs starting with "JavaScript." -//--------------------------------------------------------------------------- - -// BigInt API -VARCACHE_PREF( - Live, - "javascript.options.bigint", - javascript_options_bigint, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "javascript.options.compact_on_user_inactive", - javascript_options_compact_on_user_inactive, - bool, true -) - -// The default amount of time to wait from the user being idle to starting a -// shrinking GC. -#ifdef NIGHTLY_BUILD -# define PREF_VALUE 15000 // ms -#else -# define PREF_VALUE 300000 // ms -#endif -VARCACHE_PREF( - Live, - "javascript.options.compact_on_user_inactive_delay", - javascript_options_compact_on_user_inactive_delay, - uint32_t, PREF_VALUE -) -#undef PREF_VALUE - -VARCACHE_PREF( - Live, - "javascript.options.experimental.fields", - javascript_options_experimental_fields, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "javascript.options.experimental.await_fix", - javascript_options_experimental_await_fix, - RelaxedAtomicBool, false -) - -// nsJSEnvironmentObserver observes the memory-pressure notifications and -// forces a garbage collection and cycle collection when it happens, if the -// appropriate pref is set. -#ifdef ANDROID - // Disable the JS engine's GC on memory pressure, since we do one in the - // mobile browser (bug 669346). - // XXX: this value possibly should be changed, or the pref removed entirely. - // See bug 1450787. -# define PREF_VALUE false -#else -# define PREF_VALUE true -#endif -VARCACHE_PREF( - Live, - "javascript.options.gc_on_memory_pressure", - javascript_options_gc_on_memory_pressure, - bool, PREF_VALUE -) -#undef PREF_VALUE - -VARCACHE_PREF( - Live, - "javascript.options.mem.log", - javascript_options_mem_log, - bool, false -) - -VARCACHE_PREF( - Live, - "javascript.options.mem.notify", - javascript_options_mem_notify, - bool, false -) - -// Streams API -VARCACHE_PREF( - Live, - "javascript.options.streams", - javascript_options_streams, - RelaxedAtomicBool, false -) - -//--------------------------------------------------------------------------- -// Graphic Layers prefs -//--------------------------------------------------------------------------- - -VARCACHE_PREF( - Once, - "layers.acceleration.disabled", - LayersAccelerationDisabledDoNotUseDirectly, - bool, false -) -// Instead, use gfxConfig::IsEnabled(Feature::HW_COMPOSITING). - -VARCACHE_PREF( - Live, - "layers.acceleration.draw-fps", - LayersDrawFPS, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.acceleration.draw-fps.print-histogram", - FPSPrintHistogram, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.acceleration.draw-fps.write-to-file", - WriteFPSToFile, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "layers.acceleration.force-enabled", - LayersAccelerationForceEnabledDoNotUseDirectly, - bool, false -) - -VARCACHE_PREF( - Live, - "layers.advanced.basic-layer.enabled", - LayersAdvancedBasicLayerEnabled, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "layers.amd-switchable-gfx.enabled", - LayersAMDSwitchableGfxEnabled, - bool, false -) - -VARCACHE_PREF( - Once, - "layers.async-pan-zoom.enabled", - AsyncPanZoomEnabledDoNotUseDirectly, - bool, true -) - -VARCACHE_PREF( - Live, - "layers.bench.enabled", - LayersBenchEnabled, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "layers.bufferrotation.enabled", - BufferRotationEnabled, - bool, true -) - -VARCACHE_PREF( - Live, - "layers.child-process-shutdown", - ChildProcessShutdown, - RelaxedAtomicBool, true -) - -#ifdef MOZ_GFX_OPTIMIZE_MOBILE -// If MOZ_GFX_OPTIMIZE_MOBILE is defined, we force component alpha off -// and ignore the preference. -VARCACHE_PREF( - Skip, - "layers.componentalpha.enabled", - ComponentAlphaEnabled, - bool, false -) -#else -// If MOZ_GFX_OPTIMIZE_MOBILE is not defined, we actually take the -// preference value, defaulting to true. -VARCACHE_PREF( - Once, - "layers.componentalpha.enabled", - ComponentAlphaEnabled, - bool, true -) -#endif - -VARCACHE_PREF( - Once, - "layers.d3d11.force-warp", - LayersD3D11ForceWARP, - bool, false -) - -VARCACHE_PREF( - Live, - "layers.deaa.enabled", - LayersDEAAEnabled, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.draw-bigimage-borders", - DrawBigImageBorders, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.draw-borders", - DrawLayerBorders, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.draw-tile-borders", - DrawTileBorders, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.draw-layer-info", - DrawLayerInfo, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.dump", - LayersDump, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.dump-texture", - LayersDumpTexture, - RelaxedAtomicBool, false -) - -#ifdef MOZ_DUMP_PAINTING -VARCACHE_PREF( - Live, - "layers.dump-client-layers", - DumpClientLayers, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.dump-decision", - LayersDumpDecision, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.dump-host-layers", - DumpHostLayers, - RelaxedAtomicBool, false -) -#endif - -// 0 is "no change" for contrast, positive values increase it, negative values -// decrease it until we hit mid gray at -1 contrast, after that it gets weird. -VARCACHE_PREF( - Live, - "layers.effect.contrast", - LayersEffectContrast, - AtomicFloat, 0.0f -) - -VARCACHE_PREF( - Live, - "layers.effect.grayscale", - LayersEffectGrayscale, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.effect.invert", - LayersEffectInvert, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "layers.enable-tiles", - LayersTilesEnabled, - bool, false -) - -VARCACHE_PREF( - Once, - "layers.enable-tiles-if-skia-pomtp", - LayersTilesEnabledIfSkiaPOMTP, - bool, false -) - -VARCACHE_PREF( - Live, - "layers.flash-borders", - FlashLayerBorders, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "layers.force-shmem-tiles", - ForceShmemTiles, - bool, false -) - -VARCACHE_PREF( - Live, - "layers.draw-mask-debug", - DrawMaskLayer, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.force-synchronous-resize", - LayersForceSynchronousResize, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "layers.geometry.opengl.enabled", - OGLLayerGeometry, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.geometry.basic.enabled", - BasicLayerGeometry, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.geometry.d3d11.enabled", - D3D11LayerGeometry, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "layers.gpu-process.allow-software", - GPUProcessAllowSoftware, - bool, false -) - -VARCACHE_PREF( - Once, - "layers.gpu-process.enabled", - GPUProcessEnabled, - bool, false -) - -VARCACHE_PREF( - Once, - "layers.gpu-process.force-enabled", - GPUProcessForceEnabled, - bool, false -) - -VARCACHE_PREF( - Once, - "layers.gpu-process.ipc_reply_timeout_ms", - GPUProcessIPCReplyTimeoutMs, - int32_t, 10000 -) - -VARCACHE_PREF( - Live, - "layers.gpu-process.max_restarts", - GPUProcessMaxRestarts, - RelaxedAtomicInt32, 1 -) - -// Note: This pref will only be used if it is less than layers.gpu-process.max_restarts. -VARCACHE_PREF( - Live, - "layers.gpu-process.max_restarts_with_decoder", - GPUProcessMaxRestartsWithDecoder, - RelaxedAtomicInt32, 0 -) - -VARCACHE_PREF( - Once, - "layers.gpu-process.startup_timeout_ms", - GPUProcessTimeoutMs, - int32_t, 5000 -) - -VARCACHE_PREF( - Live, - "layers.low-precision-buffer", - UseLowPrecisionBuffer, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.low-precision-opacity", - LowPrecisionOpacity, - AtomicFloat, 1.0f -) - -VARCACHE_PREF( - Live, - "layers.low-precision-resolution", - LowPrecisionResolution, - AtomicFloat, 0.25f -) - -VARCACHE_PREF( - Live, - "layers.max-active", - MaxActiveLayers, - RelaxedAtomicInt32, -1 -) - -VARCACHE_PREF( - Once, - "layers.mlgpu.enabled", - AdvancedLayersEnabledDoNotUseDirectly, - bool, false -) - -VARCACHE_PREF( - Once, - "layers.mlgpu.enable-buffer-cache", - AdvancedLayersEnableBufferCache, - bool, true -) - -VARCACHE_PREF( - Once, - "layers.mlgpu.enable-buffer-sharing", - AdvancedLayersEnableBufferSharing, - bool, true -) - -VARCACHE_PREF( - Once, - "layers.mlgpu.enable-clear-view", - AdvancedLayersEnableClearView, - bool, true -) - -VARCACHE_PREF( - Once, - "layers.mlgpu.enable-cpu-occlusion", - AdvancedLayersEnableCPUOcclusion, - bool, true -) - -VARCACHE_PREF( - Once, - "layers.mlgpu.enable-depth-buffer", - AdvancedLayersEnableDepthBuffer, - bool, false -) - -VARCACHE_PREF( - Live, - "layers.mlgpu.enable-invalidation", - AdvancedLayersUseInvalidation, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Once, - "layers.mlgpu.enable-on-windows7", - AdvancedLayersEnableOnWindows7, - bool, false -) +//--------------------------------------------------------------------------- +// HTML5 parser prefs +//--------------------------------------------------------------------------- +// Toggle which thread the HTML5 parser uses for stream parsing. VARCACHE_PREF( - Once, - "layers.mlgpu.enable-container-resizing", - AdvancedLayersEnableContainerResizing, + "html5.offmainthread", + html5_offmainthread, bool, true ) +// Time in milliseconds between the time a network buffer is seen and the timer +// firing when the timer hasn't fired previously in this parse in the +// off-the-main-thread HTML5 parser. VARCACHE_PREF( - Once, - "layers.offmainthreadcomposition.force-disabled", - LayersOffMainThreadCompositionForceDisabled, - bool, false -) - -VARCACHE_PREF( - Live, - "layers.offmainthreadcomposition.frame-rate", - LayersCompositionFrameRate, - RelaxedAtomicInt32, -1 -) - -VARCACHE_PREF( - Once, - "layers.omtp.capture-limit", - LayersOMTPCaptureLimit, - uint32_t, 25 * 1024 * 1024 -) - -VARCACHE_PREF( - Live, - "layers.omtp.dump-capture", - LayersOMTPDumpCapture, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "layers.omtp.paint-workers", - LayersOMTPPaintWorkers, - int32_t, 1 -) - -VARCACHE_PREF( - Live, - "layers.omtp.release-capture-on-main-thread", - LayersOMTPReleaseCaptureOnMainThread, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.orientation.sync.timeout", - OrientationSyncMillis, - RelaxedAtomicUint32, (uint32_t)0 -) - -VARCACHE_PREF( - Once, - "layers.prefer-opengl", - LayersPreferOpenGL, - bool, false -) - -VARCACHE_PREF( - Live, - "layers.progressive-paint", - ProgressivePaint, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.shared-buffer-provider.enabled", - PersistentBufferProviderSharedEnabled, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.single-tile.enabled", - LayersSingleTileEnabled, - RelaxedAtomicBool, true -) - -// We allow for configurable and rectangular tile size to avoid wasting memory on devices whose -// screen size does not align nicely to the default tile size. Although layers can be any size, -// they are often the same size as the screen, especially for width. -VARCACHE_PREF( - Once, - "layers.tile-width", - LayersTileWidth, - int32_t, 256 -) - -VARCACHE_PREF( - Once, - "layers.tile-height", - LayersTileHeight, - int32_t, 256 -) - -VARCACHE_PREF( - Once, - "layers.tile-initial-pool-size", - LayersTileInitialPoolSize, - uint32_t, (uint32_t)50 -) - -VARCACHE_PREF( - Once, - "layers.tile-pool-unused-size", - LayersTilePoolUnusedSize, - uint32_t, (uint32_t)10 + "html5.flushtimer.initialdelay", + html5_flushtimer_initialdelay, + RelaxedAtomicInt32, 16 ) +// Time in milliseconds between the time a network buffer is seen and the timer +// firing when the timer has already fired previously in this parse. VARCACHE_PREF( - Once, - "layers.tile-pool-shrink-timeout", - LayersTilePoolShrinkTimeout, - uint32_t, (uint32_t)50 + "html5.flushtimer.subsequentdelay", + html5_flushtimer_subsequentdelay, + RelaxedAtomicInt32, 16 ) -VARCACHE_PREF( - Once, - "layers.tile-pool-clear-timeout", - LayersTilePoolClearTimeout, - uint32_t, (uint32_t)5000 -) +//--------------------------------------------------------------------------- +// Layout prefs +//--------------------------------------------------------------------------- +// Whether to block large cursors intersecting UI. VARCACHE_PREF( - Once, - "layers.tiles.adjust", - LayersTilesAdjust, + "layout.cursor.block.enabled", + layout_cursor_block_enabled, bool, true ) +// The maximum width or height of the cursor we should allow when intersecting +// the UI, in CSS pixels. VARCACHE_PREF( - Once, - "layers.tiles.edge-padding", - TileEdgePaddingEnabled, - bool, false -) - -VARCACHE_PREF( - Live, - "layers.tiles.fade-in.enabled", - LayerTileFadeInEnabled, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layers.tiles.fade-in.duration-ms", - LayerTileFadeInDuration, - RelaxedAtomicUint32, 250 -) - -VARCACHE_PREF( - Live, - "layers.tiles.retain-back-buffer", - LayersTileRetainBackBuffer, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "layers.transaction.warning-ms", - LayerTransactionWarning, - RelaxedAtomicUint32, 200 -) - -VARCACHE_PREF( - Once, - "layers.uniformity-info", - UniformityInfo, - bool, false -) - -VARCACHE_PREF( - Once, - "layers.use-image-offscreen-surfaces", - UseImageOffscreenSurfaces, - bool, true + "layout.cursor.block.max-size", + layout_cursor_block_max_size, + uint32_t, 32 ) -//--------------------------------------------------------------------------- -// Prefs starting with "Layout." -//--------------------------------------------------------------------------- - // Debug-only pref to force enable the AccessibleCaret. If you want to // control AccessibleCaret by mouse, you'll need to set // "layout.accessiblecaret.hide_carets_for_mouse_input" to false. VARCACHE_PREF( - Live, "layout.accessiblecaret.enabled", - layout_accessiblecaret_enabled, + layout_accessiblecaret_enabled, bool, false ) @@ -3721,17 +974,15 @@ VARCACHE_PREF( // additional way to enable the accessible carets, rather than // overriding the layout.accessiblecaret.enabled pref. VARCACHE_PREF( - Live, "layout.accessiblecaret.enabled_on_touch", - layout_accessiblecaret_enabled_on_touch, + layout_accessiblecaret_enabled_on_touch, bool, true ) // By default, carets become tilt only when they are overlapping. VARCACHE_PREF( - Live, "layout.accessiblecaret.always_tilt", - layout_accessiblecaret_always_tilt, + layout_accessiblecaret_always_tilt, bool, false ) @@ -3740,9 +991,8 @@ VARCACHE_PREF( // on the emptiness of the content, into something more heuristic. See // AccessibleCaretManager::UpdateCaretsForCursorMode() for the details. VARCACHE_PREF( - Live, "layout.accessiblecaret.caret_shown_when_long_tapping_on_empty_content", - layout_accessiblecaret_caret_shown_when_long_tapping_on_empty_content, + layout_accessiblecaret_caret_shown_when_long_tapping_on_empty_content, bool, false ) @@ -3751,686 +1001,495 @@ VARCACHE_PREF( // but don't show carets if carets are hidden. // 2 = always show carets for selection changes due to JS calls. VARCACHE_PREF( - Live, "layout.accessiblecaret.script_change_update_mode", - layout_accessiblecaret_script_change_update_mode, + layout_accessiblecaret_script_change_update_mode, int32_t, 0 ) // Allow one caret to be dragged across the other caret without any limitation. // This matches the built-in convention for all desktop platforms. VARCACHE_PREF( - Live, "layout.accessiblecaret.allow_dragging_across_other_caret", - layout_accessiblecaret_allow_dragging_across_other_caret, + layout_accessiblecaret_allow_dragging_across_other_caret, bool, true ) // Optionally provide haptic feedback on long-press selection events. VARCACHE_PREF( - Live, "layout.accessiblecaret.hapticfeedback", - layout_accessiblecaret_hapticfeedback, + layout_accessiblecaret_hapticfeedback, bool, false ) // Smart phone-number selection on long-press is not enabled by default. VARCACHE_PREF( - Live, "layout.accessiblecaret.extend_selection_for_phone_number", - layout_accessiblecaret_extend_selection_for_phone_number, + layout_accessiblecaret_extend_selection_for_phone_number, bool, false ) // Keep the accessible carets hidden when the user is using mouse input (as // opposed to touch/pen/etc.). VARCACHE_PREF( - Live, "layout.accessiblecaret.hide_carets_for_mouse_input", - layout_accessiblecaret_hide_carets_for_mouse_input, + layout_accessiblecaret_hide_carets_for_mouse_input, bool, true ) // CSS attributes (width, height, margin-left) of the AccessibleCaret in CSS // pixels. VARCACHE_PREF( - Live, "layout.accessiblecaret.width", - layout_accessiblecaret_width, + layout_accessiblecaret_width, float, 34.0f ) VARCACHE_PREF( - Live, "layout.accessiblecaret.height", - layout_accessiblecaret_height, + layout_accessiblecaret_height, float, 36.0f ) VARCACHE_PREF( - Live, "layout.accessiblecaret.margin-left", - layout_accessiblecaret_margin_left, + layout_accessiblecaret_margin_left, float, -18.5f ) // Simulate long tap events to select words. Mainly used in manual testing // with mouse. VARCACHE_PREF( - Live, "layout.accessiblecaret.use_long_tap_injector", - layout_accessiblecaret_use_long_tap_injector, - bool, false -) - -VARCACHE_PREF( - Live, - "layout.animation.prerender.partial", - PartiallyPrerenderAnimatedContent, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "layout.animation.prerender.viewport-ratio-limit-x", - AnimationPrerenderViewportRatioLimitX, - AtomicFloat, 1.125f -) - -VARCACHE_PREF( - Live, - "layout.animation.prerender.viewport-ratio-limit-y", - AnimationPrerenderViewportRatioLimitY, - AtomicFloat, 1.125f -) - -VARCACHE_PREF( - Live, - "layout.animation.prerender.absolute-limit-x", - AnimationPrerenderAbsoluteLimitX, - RelaxedAtomicUint32, 4096 -) - -VARCACHE_PREF( - Live, - "layout.animation.prerender.absolute-limit-y", - AnimationPrerenderAbsoluteLimitY, - RelaxedAtomicUint32, 4096 -) - -// Is path() supported in clip-path? -VARCACHE_PREF( - Live, - "layout.css.clip-path-path.enabled", - layout_css_clip_path_path_enabled, - bool, false -) - -// Is support for CSS column-span enabled? -VARCACHE_PREF( - Live, - "layout.css.column-span.enabled", - layout_css_column_span_enabled, - bool, false -) - -// Is support for CSS contain enabled? -#ifdef EARLY_BETA_OR_EARLIER -#define PREF_VALUE true -#else -#define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "layout.css.contain.enabled", - layout_css_contain_enabled, - bool, PREF_VALUE -) -#undef PREF_VALUE - -// Should stray control characters be rendered visibly? -#ifdef RELEASE_OR_BETA -# define PREF_VALUE false -#else -# define PREF_VALUE true -#endif -VARCACHE_PREF( - Live, - "layout.css.control-characters.visible", - layout_css_control_characters_visible, - bool, PREF_VALUE -) -#undef PREF_VALUE - -// Are we emulating -moz-{inline}-box layout using CSS flexbox? -VARCACHE_PREF( - Live, - "layout.css.emulate-moz-box-with-flex", - layout_css_emulate_moz_box_with_flex, + layout_accessiblecaret_use_long_tap_injector, bool, false ) -// Is support for the font-display @font-face descriptor enabled? +// Is parallel CSS parsing enabled? VARCACHE_PREF( - Live, - "layout.css.font-display.enabled", - layout_css_font_display_enabled, + "layout.css.parsing.parallel", + layout_css_parsing_parallel, bool, true ) -// Is support for variation fonts enabled? -VARCACHE_PREF( - Live, - "layout.css.font-variations.enabled", - layout_css_font_variations_enabled, - RelaxedAtomicBool, true -) - -// Is support for GeometryUtils.getBoxQuads enabled? +// Are style system use counters enabled? #ifdef RELEASE_OR_BETA -# define PREF_VALUE false -#else -# define PREF_VALUE true -#endif -VARCACHE_PREF( - Live, - "layout.css.getBoxQuads.enabled", - layout_css_getBoxQuads_enabled, - bool, PREF_VALUE -) -#undef PREF_VALUE - -// Is support for CSS "grid-template-{columns,rows}: subgrid X" enabled? -#ifdef NIGHTLY_BUILD -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "layout.css.grid-template-subgrid-value.enabled", - layout_css_grid_template_subgrid_value_enabled, - bool, PREF_VALUE -) -#undef PREF_VALUE - -// Pref to control whether line-height: -moz-block-height is exposed to content. -VARCACHE_PREF( - Live, - "layout.css.line-height-moz-block-height.content.enabled", - layout_css_line_height_moz_block_height_content_enabled, - bool, false -) - -// Pref to control whether @-moz-document rules are enabled in content pages. -VARCACHE_PREF( - Live, - "layout.css.moz-document.content.enabled", - layout_css_moz_document_content_enabled, - bool, false -) - -// Pref to control whether @-moz-document url-prefix() is parsed in content -// pages. Only effective when layout.css.moz-document.content.enabled is false. -#ifdef EARLY_BETA_OR_EARLIER #define PREF_VALUE false #else #define PREF_VALUE true #endif VARCACHE_PREF( - Live, - "layout.css.moz-document.url-prefix-hack.enabled", - layout_css_moz_document_url_prefix_hack_enabled, - bool, PREF_VALUE -) -#undef PREF_VALUE - -// Whether the offset-* logical property aliases are enabled. -VARCACHE_PREF( - Live, - "layout.css.offset-logical-properties.enabled", - layout_css_offset_logical_properties_enabled, - bool, false -) - -VARCACHE_PREF( - Live, - "layout.css.paint-order.enabled", - PaintOrderEnabled, - RelaxedAtomicBool, false + "layout.css.use-counters.enabled", + layout_css_use_counters_enabled, + bool, PREF_VALUE ) +#undef PREF_VALUE -// Is parallel CSS parsing enabled? +// Is CSS error reporting enabled? VARCACHE_PREF( - Live, - "layout.css.parsing.parallel", - layout_css_parsing_parallel, + "layout.css.report_errors", + layout_css_report_errors, bool, true ) -// Are "-webkit-{min|max}-device-pixel-ratio" media queries supported? (Note: -// this pref has no effect if the master 'layout.css.prefixes.webkit' pref is -// set to false.) +// Is support for the font-display @font-face descriptor enabled? VARCACHE_PREF( - Live, - "layout.css.prefixes.device-pixel-ratio-webkit", - layout_css_prefixes_device_pixel_ratio_webkit, + "layout.css.font-display.enabled", + layout_css_font_display_enabled, bool, true ) // Are webkit-prefixed properties & property-values supported? VARCACHE_PREF( - Live, "layout.css.prefixes.webkit", - layout_css_prefixes_webkit, + layout_css_prefixes_webkit, bool, true ) -// Is CSS error reporting enabled? +// Are "-webkit-{min|max}-device-pixel-ratio" media queries supported? (Note: +// this pref has no effect if the master 'layout.css.prefixes.webkit' pref is +// set to false.) VARCACHE_PREF( - Live, - "layout.css.report_errors", - layout_css_report_errors, + "layout.css.prefixes.device-pixel-ratio-webkit", + layout_css_prefixes_device_pixel_ratio_webkit, bool, true ) -VARCACHE_PREF( - Live, - "layout.css.scroll-behavior.damping-ratio", - ScrollBehaviorDampingRatio, - AtomicFloat, 1.0f -) - // Are -moz-prefixed gradients restricted to a simpler syntax? (with an optional // or , but not both)? VARCACHE_PREF( - Live, "layout.css.simple-moz-gradient.enabled", - layout_css_simple_moz_gradient_enabled, + layout_css_simple_moz_gradient_enabled, bool, true ) -#ifdef NIGHTLY_BUILD -# define PREF_VALUE true -#else +// Whether the offset-* logical property aliases are enabled. +VARCACHE_PREF( + "layout.css.offset-logical-properties.enabled", + layout_css_offset_logical_properties_enabled, + bool, false +) + +// Should stray control characters be rendered visibly? +#ifdef RELEASE_OR_BETA # define PREF_VALUE false +#else +# define PREF_VALUE true #endif VARCACHE_PREF( - Live, - "layout.css.supports-selector.enabled", - layout_css_supports_selector_enabled, + "layout.css.control-characters.visible", + layout_css_control_characters_visible, bool, PREF_VALUE ) #undef PREF_VALUE +// Should the :visited selector ever match (otherwise :link matches instead)? VARCACHE_PREF( - Live, - "layout.css.scroll-behavior.enabled", - ScrollBehaviorEnabled, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "layout.css.scroll-behavior.spring-constant", - ScrollBehaviorSpringConstant, - AtomicFloat, 250.0f -) - -VARCACHE_PREF( - Live, - "layout.css.scroll-snap.prediction-max-velocity", - ScrollSnapPredictionMaxVelocity, - RelaxedAtomicInt32, 2000 -) - -VARCACHE_PREF( - Live, - "layout.css.scroll-snap.prediction-sensitivity", - ScrollSnapPredictionSensitivity, - AtomicFloat, 0.750f -) - -VARCACHE_PREF( - Live, - "layout.css.scroll-snap.proximity-threshold", - ScrollSnapProximityThreshold, - RelaxedAtomicInt32, 200 + "layout.css.visited_links_enabled", + layout_css_visited_links_enabled, + bool, true ) -// Is steps(jump-*) supported in easing functions? +// Is the '-webkit-appearance' alias for '-moz-appearance' enabled? VARCACHE_PREF( - Live, - "layout.css.step-position-jump.enabled", - layout_css_step_position_jump_enabled, + "layout.css.webkit-appearance.enabled", + layout_css_webkit_appearance_enabled, bool, true ) +// Pref to control whether @-moz-document rules are enabled in content pages. VARCACHE_PREF( - Live, - "layout.css.touch_action.enabled", - TouchActionEnabled, - RelaxedAtomicBool, false + "layout.css.moz-document.content.enabled", + layout_css_moz_document_content_enabled, + bool, false ) -// Does arbitrary ::-webkit-* pseudo-element parsed? +#ifdef NIGHTLY_BUILD +# define PREF_VALUE true +#else +# define PREF_VALUE false +#endif VARCACHE_PREF( - Live, - "layout.css.unknown-webkit-pseudo-element", - layout_css_unknown_webkit_pseudo_element, - bool, true + "layout.css.supports-selector.enabled", + layout_css_supports_selector_enabled, + bool, PREF_VALUE ) +#undef PREF_VALUE -// Are style system use counters enabled? -#ifdef RELEASE_OR_BETA +// Pref to control whether @-moz-document url-prefix() is parsed in content +// pages. Only effective when layout.css.moz-document.content.enabled is false. +#ifdef EARLY_BETA_OR_EARLIER #define PREF_VALUE false #else #define PREF_VALUE true #endif VARCACHE_PREF( - Live, - "layout.css.use-counters.enabled", - layout_css_use_counters_enabled, + "layout.css.moz-document.url-prefix-hack.enabled", + layout_css_moz_document_url_prefix_hack_enabled, bool, PREF_VALUE ) #undef PREF_VALUE -// Should the :visited selector ever match (otherwise :link matches instead)? -VARCACHE_PREF( - Live, - "layout.css.visited_links_enabled", - layout_css_visited_links_enabled, - bool, true -) - -// Is the '-webkit-appearance' alias for '-moz-appearance' enabled? -VARCACHE_PREF( - Live, - "layout.css.webkit-appearance.enabled", - layout_css_webkit_appearance_enabled, - bool, true -) - VARCACHE_PREF( - Live, "layout.css.xul-display-values.content.enabled", - layout_css_xul_display_values_content_enabled, + layout_css_xul_display_values_content_enabled, bool, false ) // Pref to control whether display: -moz-box and display: -moz-inline-box are // parsed in content pages. VARCACHE_PREF( - Live, "layout.css.xul-box-display-values.content.enabled", - layout_css_xul_box_display_values_content_enabled, + layout_css_xul_box_display_values_content_enabled, bool, false ) // Pref to control whether XUL ::-tree-* pseudo-elements are parsed in content // pages. VARCACHE_PREF( - Live, "layout.css.xul-tree-pseudos.content.enabled", - layout_css_xul_tree_pseudos_content_enabled, + layout_css_xul_tree_pseudos_content_enabled, bool, false ) -// Whether to block large cursors intersecting UI. +// Is support for CSS "grid-template-{columns,rows}: subgrid X" enabled? +#ifdef NIGHTLY_BUILD +# define PREF_VALUE true +#else +# define PREF_VALUE false +#endif VARCACHE_PREF( - Live, - "layout.cursor.block.enabled", - layout_cursor_block_enabled, - bool, true + "layout.css.grid-template-subgrid-value.enabled", + layout_css_grid_template_subgrid_value_enabled, + bool, PREF_VALUE ) +#undef PREF_VALUE -// The maximum width or height of the cursor we should allow when intersecting -// the UI, in CSS pixels. +// Pref to control whether line-height: -moz-block-height is exposed to content. VARCACHE_PREF( - Live, - "layout.cursor.block.max-size", - layout_cursor_block_max_size, - uint32_t, 32 + "layout.css.line-height-moz-block-height.content.enabled", + layout_css_line_height_moz_block_height_content_enabled, + bool, false ) +// Is support for variation fonts enabled? VARCACHE_PREF( - Live, - "layout.display-list.build-twice", - LayoutDisplayListBuildTwice, - RelaxedAtomicBool, false + "layout.css.font-variations.enabled", + layout_css_font_variations_enabled, + RelaxedAtomicBool, true ) +// Are we emulating -moz-{inline}-box layout using CSS flexbox? VARCACHE_PREF( - Live, - "layout.display-list.retain", - LayoutRetainDisplayList, - RelaxedAtomicBool, true + "layout.css.emulate-moz-box-with-flex", + layout_css_emulate_moz_box_with_flex, + bool, false ) +// Does arbitrary ::-webkit-* pseudo-element parsed? VARCACHE_PREF( - Live, - "layout.display-list.retain.chrome", - LayoutRetainDisplayListChrome, - RelaxedAtomicBool, false + "layout.css.unknown-webkit-pseudo-element", + layout_css_unknown_webkit_pseudo_element, + bool, true ) +// Is path() supported in clip-path? VARCACHE_PREF( - Live, - "layout.display-list.retain.verify", - LayoutVerifyRetainDisplayList, - RelaxedAtomicBool, false + "layout.css.clip-path-path.enabled", + layout_css_clip_path_path_enabled, + bool, false +) + +// Is support for CSS column-span enabled? +VARCACHE_PREF( + "layout.css.column-span.enabled", + layout_css_column_span_enabled, + bool, false ) +// Is support for CSS contain enabled? +#ifdef EARLY_BETA_OR_EARLIER +#define PREF_VALUE true +#else +#define PREF_VALUE false +#endif VARCACHE_PREF( - Live, - "layout.display-list.retain.verify.order", - LayoutVerifyRetainDisplayListOrder, - RelaxedAtomicBool, false + "layout.css.contain.enabled", + layout_css_contain_enabled, + bool, PREF_VALUE ) +#undef PREF_VALUE +// Is steps(jump-*) supported in easing functions? VARCACHE_PREF( - Live, - "layout.display-list.rebuild-frame-limit", - LayoutRebuildFrameLimit, - RelaxedAtomicUint32, 500 + "layout.css.step-position-jump.enabled", + layout_css_step_position_jump_enabled, + bool, true ) +// Are dynamic reflow roots enabled? +#ifdef EARLY_BETA_OR_EARLIER +#define PREF_VALUE true +#else +#define PREF_VALUE false +#endif VARCACHE_PREF( - Live, - "layout.display-list.dump", - LayoutDumpDisplayList, - RelaxedAtomicBool, false + "layout.dynamic-reflow-roots.enabled", + layout_dynamic_reflow_roots_enabled, + bool, PREF_VALUE ) +#undef PREF_VALUE VARCACHE_PREF( - Live, - "layout.display-list.dump-content", - LayoutDumpDisplayListContent, - RelaxedAtomicBool, false + "layout.lower_priority_refresh_driver_during_load", + layout_lower_priority_refresh_driver_during_load, + bool, true ) +// Pref to control enabling scroll anchoring. VARCACHE_PREF( - Live, - "layout.display-list.dump-parent", - LayoutDumpDisplayListParent, - RelaxedAtomicBool, false + "layout.css.scroll-anchoring.enabled", + layout_css_scroll_anchoring_enabled, + bool, true ) VARCACHE_PREF( - Live, - "layout.display-list.show-rebuild-area", - LayoutDisplayListShowArea, - RelaxedAtomicBool, false + "layout.css.scroll-anchoring.highlight", + layout_css_scroll_anchoring_highlight, + bool, false ) +// Is the CSS Scroll Snap Module Level 1 enabled? VARCACHE_PREF( - Live, - "layout.display-list.flatten-transform", - LayoutFlattenTransform, + "layout.css.scroll-snap-v1.enabled", + layout_css_scroll_snap_v1_enabled, RelaxedAtomicBool, true ) -// Are dynamic reflow roots enabled? -#ifdef EARLY_BETA_OR_EARLIER -#define PREF_VALUE true +// Are shared memory User Agent style sheets enabled? +VARCACHE_PREF( + "layout.css.shared-memory-ua-sheets.enabled", + layout_css_shared_memory_ua_sheets_enabled, + bool, false +) + +#ifdef NIGHTLY_BUILD +# define PREF_VALUE true #else -#define PREF_VALUE false +# define PREF_VALUE false #endif VARCACHE_PREF( - Live, - "layout.dynamic-reflow-roots.enabled", - layout_dynamic_reflow_roots_enabled, + "layout.css.resizeobserver.enabled", + layout_css_resizeobserver_enabled, bool, PREF_VALUE ) #undef PREF_VALUE +// Is support for GeometryUtils.getBoxQuads enabled? +#ifdef RELEASE_OR_BETA +# define PREF_VALUE false +#else +# define PREF_VALUE true +#endif VARCACHE_PREF( - Live, - "layout.frame_rate", - LayoutFrameRate, - RelaxedAtomicInt32, -1 + "layout.css.getBoxQuads.enabled", + layout_css_getBoxQuads_enabled, + bool, PREF_VALUE ) +#undef PREF_VALUE +// Pref to control whether arrow-panel animations are enabled or not. +// Transitions are currently disabled on Linux due to rendering issues on +// certain configurations. +#ifdef MOZ_WIDGET_GTK +#define PREF_VALUE false +#else +#define PREF_VALUE true +#endif VARCACHE_PREF( - Live, - "layout.min-active-layer-size", - LayoutMinActiveLayerSize, - int, 64 + "xul.panel-animations.enabled", + xul_panel_animations_enabled, + bool, PREF_VALUE ) +#undef PREF_VALUE +// Is support for -webkit-line-clamp enabled? VARCACHE_PREF( - Once, - "layout.paint_rects_separately", - LayoutPaintRectsSeparately, + "layout.css.webkit-line-clamp.enabled", + layout_css_webkit_line_clamp_enabled, bool, true ) -// This and code dependent on it should be removed once containerless scrolling looks stable. +//--------------------------------------------------------------------------- +// JavaScript prefs +//--------------------------------------------------------------------------- + +// nsJSEnvironmentObserver observes the memory-pressure notifications and +// forces a garbage collection and cycle collection when it happens, if the +// appropriate pref is set. +#ifdef ANDROID + // Disable the JS engine's GC on memory pressure, since we do one in the + // mobile browser (bug 669346). + // XXX: this value possibly should be changed, or the pref removed entirely. + // See bug 1450787. +# define PREF_VALUE false +#else +# define PREF_VALUE true +#endif VARCACHE_PREF( - Live, - "layout.scroll.root-frame-containers", - LayoutUseContainersForRootFrames, - RelaxedAtomicBool, false + "javascript.options.gc_on_memory_pressure", + javascript_options_gc_on_memory_pressure, + bool, PREF_VALUE ) +#undef PREF_VALUE -// This pref is to be set by test code only. VARCACHE_PREF( - Live, - "layout.scrollbars.always-layerize-track", - AlwaysLayerizeScrollbarTrackTestOnly, - RelaxedAtomicBool, false + "javascript.options.compact_on_user_inactive", + javascript_options_compact_on_user_inactive, + bool, true ) +// The default amount of time to wait from the user being idle to starting a +// shrinking GC. +#ifdef NIGHTLY_BUILD +# define PREF_VALUE 15000 // ms +#else +# define PREF_VALUE 300000 // ms +#endif VARCACHE_PREF( - Live, - "layout.smaller-painted-layers", - LayoutSmallerPaintedLayers, - RelaxedAtomicBool, false + "javascript.options.compact_on_user_inactive_delay", + javascript_options_compact_on_user_inactive_delay, + uint32_t, PREF_VALUE ) +#undef PREF_VALUE VARCACHE_PREF( - Live, - "layout.lower_priority_refresh_driver_during_load", - layout_lower_priority_refresh_driver_during_load, - bool, true + "javascript.options.mem.log", + javascript_options_mem_log, + bool, false ) -// Pref to control enabling scroll anchoring. VARCACHE_PREF( - Live, - "layout.css.scroll-anchoring.enabled", - layout_css_scroll_anchoring_enabled, - bool, true + "javascript.options.mem.notify", + javascript_options_mem_notify, + bool, false ) +// Streams API VARCACHE_PREF( - Live, - "layout.css.scroll-anchoring.highlight", - layout_css_scroll_anchoring_highlight, - bool, false + "javascript.options.streams", + javascript_options_streams, + RelaxedAtomicBool, false ) -// Is the CSS Scroll Snap Module Level 1 enabled? +// BigInt API VARCACHE_PREF( - Live, - "layout.css.scroll-snap-v1.enabled", - layout_css_scroll_snap_v1_enabled, + "javascript.options.bigint", + javascript_options_bigint, RelaxedAtomicBool, true ) -// Is support for the old unspecced scroll-snap enabled? -// E.g. scroll-snap-points-{x,y}, scroll-snap-coordinate, etc. VARCACHE_PREF( - Live, - "layout.css.scroll-snap.enabled", - layout_css_scroll_snap_enabled, - bool, false + "javascript.options.experimental.fields", + javascript_options_experimental_fields, + RelaxedAtomicBool, false ) -// Are shared memory User Agent style sheets enabled? VARCACHE_PREF( - Live, - "layout.css.shared-memory-ua-sheets.enabled", - layout_css_shared_memory_ua_sheets_enabled, - bool, false + "javascript.options.experimental.await_fix", + javascript_options_experimental_await_fix, + RelaxedAtomicBool, false ) #ifdef NIGHTLY_BUILD -# define PREF_VALUE true +# define PREF_VALUE true #else -# define PREF_VALUE false +# define PREF_VALUE false #endif VARCACHE_PREF( - Live, - "layout.css.resizeobserver.enabled", - layout_css_resizeobserver_enabled, + "dom.ipc.cancel_content_js_when_navigating", + dom_ipc_cancel_content_js_when_navigating, bool, PREF_VALUE ) #undef PREF_VALUE -// Is support for -webkit-line-clamp enabled? -VARCACHE_PREF( - Live, - "layout.css.webkit-line-clamp.enabled", - layout_css_webkit_line_clamp_enabled, - bool, true -) - //--------------------------------------------------------------------------- -// Prefs starting with "media." +// Media prefs //--------------------------------------------------------------------------- // These prefs use camel case instead of snake case for the getter because one -// reviewer had an unshakeable preference for that. Who could that be? - -VARCACHE_PREF( - Live, - "media.autoplay.allow-muted", - MediaAutoplayAllowMuted, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "media.autoplay.blackList-override-default", - MediaAutoplayBlackListOverrideDefault, - RelaxedAtomicBool, true -) +// reviewer had an unshakeable preference for that. // File-backed MediaCache size. VARCACHE_PREF( - Live, "media.cache_size", - MediaCacheSize, + MediaCacheSize, RelaxedAtomicUint32, 512000 // Measured in KiB ) - // Size of file backed MediaCache while on a connection which is cellular (3G, etc), // and thus assumed to be "expensive". VARCACHE_PREF( - Live, "media.cache_size.cellular", - MediaCacheCellularSize, + MediaCacheCellularSize, RelaxedAtomicUint32, 32768 // Measured in KiB ) @@ -4438,42 +1497,37 @@ VARCACHE_PREF( // memory-backed MediaCache may be used; otherwise the (single shared global) // file-backed MediaCache is used. VARCACHE_PREF( - Live, "media.memory_cache_max_size", - MediaMemoryCacheMaxSize, + MediaMemoryCacheMaxSize, uint32_t, 8192 // Measured in KiB ) // Don't create more memory-backed MediaCaches if their combined size would go // above this absolute size limit. VARCACHE_PREF( - Live, "media.memory_caches_combined_limit_kb", - MediaMemoryCachesCombinedLimitKb, + MediaMemoryCachesCombinedLimitKb, uint32_t, 524288 ) // Don't create more memory-backed MediaCaches if their combined size would go // above this relative size limit (a percentage of physical memory). VARCACHE_PREF( - Live, "media.memory_caches_combined_limit_pc_sysmem", - MediaMemoryCachesCombinedLimitPcSysmem, + MediaMemoryCachesCombinedLimitPcSysmem, uint32_t, 5 // A percentage ) // When a network connection is suspended, don't resume it until the amount of // buffered data falls below this threshold (in seconds). VARCACHE_PREF( - Live, "media.cache_resume_threshold", - MediaCacheResumeThreshold, + MediaCacheResumeThreshold, RelaxedAtomicUint32, 30 ) VARCACHE_PREF( - Live, "media.cache_resume_threshold.cellular", - MediaCacheCellularResumeThreshold, + MediaCacheCellularResumeThreshold, RelaxedAtomicUint32, 10 ) @@ -4481,23 +1535,20 @@ VARCACHE_PREF( // current playback position. This limit can stop us from using arbitrary // amounts of network bandwidth prefetching huge videos. VARCACHE_PREF( - Live, "media.cache_readahead_limit", - MediaCacheReadaheadLimit, + MediaCacheReadaheadLimit, RelaxedAtomicUint32, 60 ) VARCACHE_PREF( - Live, "media.cache_readahead_limit.cellular", - MediaCacheCellularReadaheadLimit, + MediaCacheCellularReadaheadLimit, RelaxedAtomicUint32, 30 ) // AudioSink VARCACHE_PREF( - Live, "media.resampling.enabled", - MediaResamplingEnabled, + MediaResamplingEnabled, RelaxedAtomicBool, false ) @@ -4508,18 +1559,16 @@ VARCACHE_PREF( # define PREF_VALUE true #endif VARCACHE_PREF( - Live, "media.forcestereo.enabled", - MediaForcestereoEnabled, + MediaForcestereoEnabled, RelaxedAtomicBool, PREF_VALUE ) #undef PREF_VALUE // VideoSink VARCACHE_PREF( - Live, "media.ruin-av-sync.enabled", - MediaRuinAvSyncEnabled, + MediaRuinAvSyncEnabled, RelaxedAtomicBool, false ) @@ -4543,17 +1592,15 @@ VARCACHE_PREF( # define PREF_VALUE true #endif VARCACHE_PREF( - Live, "media.eme.enabled", - MediaEmeEnabled, + MediaEmeEnabled, bool, PREF_VALUE ) #undef PREF_VALUE VARCACHE_PREF( - Live, "media.clearkey.persistent-license.enabled", - MediaClearkeyPersistentLicenseEnabled, + MediaClearkeyPersistentLicenseEnabled, bool, false ) @@ -4562,9 +1609,8 @@ VARCACHE_PREF( // sandboxing features, loading Gecko Media Plugins unsandboxed. However, EME // CDMs will not be loaded without sandboxing even if this pref is changed. VARCACHE_PREF( - Live, "media.gmp.insecure.allow", - MediaGmpInsecureAllow, + MediaGmpInsecureAllow, RelaxedAtomicBool, false ) #endif @@ -4573,9 +1619,8 @@ VARCACHE_PREF( // blank frames/audio instead of actually decoding. The blank decoder works on // all platforms. VARCACHE_PREF( - Live, "media.use-blank-decoder", - MediaUseBlankDecoder, + MediaUseBlankDecoder, RelaxedAtomicBool, false ) @@ -4585,9 +1630,8 @@ VARCACHE_PREF( # define PREF_VALUE false #endif VARCACHE_PREF( - Live, "media.gpu-process-decoder", - MediaGpuProcessDecoder, + MediaGpuProcessDecoder, RelaxedAtomicBool, PREF_VALUE ) #undef PREF_VALUE @@ -4602,17 +1646,15 @@ VARCACHE_PREF( # define PREF_VALUE false #endif VARCACHE_PREF( - Live, "media.rdd-process.enabled", - MediaRddProcessEnabled, + MediaRddProcessEnabled, RelaxedAtomicBool, PREF_VALUE ) #undef PREF_VALUE VARCACHE_PREF( - Live, "media.rdd-process.startup_timeout_ms", - MediaRddProcessStartupTimeoutMs, + MediaRddProcessStartupTimeoutMs, RelaxedAtomicInt32, 5000 ) @@ -4621,14 +1663,13 @@ VARCACHE_PREF( #elif defined(XP_WIN) && !defined(_ARM64_) # define PREF_VALUE false #elif defined(XP_MACOSX) -# define PREF_VALUE false +# define PREF_VALUE true #else # define PREF_VALUE false #endif VARCACHE_PREF( - Live, "media.rdd-vorbis.enabled", - MediaRddVorbisEnabled, + MediaRddVorbisEnabled, RelaxedAtomicBool, PREF_VALUE ) #undef PREF_VALUE @@ -4637,26 +1678,111 @@ VARCACHE_PREF( // Enable the MediaCodec PlatformDecoderModule by default. VARCACHE_PREF( - Live, "media.android-media-codec.enabled", - MediaAndroidMediaCodecEnabled, + MediaAndroidMediaCodecEnabled, RelaxedAtomicBool, true ) VARCACHE_PREF( - Live, "media.android-media-codec.preferred", - MediaAndroidMediaCodecPreferred, + MediaAndroidMediaCodecPreferred, RelaxedAtomicBool, true ) #endif // ANDROID +//--------------------------------------------------------------------------- +// MediaCapture prefs +//--------------------------------------------------------------------------- + +// Enables navigator.mediaDevices and getUserMedia() support. See also +// media.peerconnection.enabled +VARCACHE_PREF( + "media.navigator.enabled", + media_navigator_enabled, + bool, true + ) + +// This pref turns off [SecureContext] on the navigator.mediaDevices object, for +// more compatible legacy behavior. +VARCACHE_PREF( + "media.devices.insecure.enabled", + media_devices_insecure_enabled, + bool, true + ) + +// If the above pref is also enabled, this pref enabled getUserMedia() support +// in http, bypassing the instant NotAllowedError you get otherwise. +VARCACHE_PREF( + "media.getusermedia.insecure.enabled", + media_getusermedia_insecure_enabled, + bool, false + ) + +//--------------------------------------------------------------------------- +// WebRTC prefs +//--------------------------------------------------------------------------- + +// Enables RTCPeerConnection support. Note that, when true, this pref enables +// navigator.mediaDevices and getUserMedia() support as well. +// See also media.navigator.enabled +VARCACHE_PREF( + "media.peerconnection.enabled", + media_peerconnection_enabled, + bool, true + ) + +#ifdef MOZ_WEBRTC +#ifdef ANDROID + +VARCACHE_PREF( + "media.navigator.hardware.vp8_encode.acceleration_remote_enabled", + MediaNavigatorHardwareVp8encodeAccelerationRemoteEnabled, + bool, true +) + +PREF("media.navigator.hardware.vp8_encode.acceleration_enabled", bool, true) + +PREF("media.navigator.hardware.vp8_decode.acceleration_enabled", bool, false) + +#endif // ANDROID + +// Use MediaDataDecoder API for VP8/VP9 in WebRTC. This includes hardware +// acceleration for decoding. +// disable on android bug 1509316 +#if defined(NIGHTLY_BUILD) && !defined(ANDROID) +# define PREF_VALUE true +#else +# define PREF_VALUE false +#endif +VARCACHE_PREF( + "media.navigator.mediadatadecoder_vpx_enabled", + MediaNavigatorMediadatadecoderVPXEnabled, + RelaxedAtomicBool, PREF_VALUE +) +#undef PREF_VALUE + +// Use MediaDataDecoder API for H264 in WebRTC. This includes hardware +// acceleration for decoding. +# if defined(ANDROID) +# define PREF_VALUE false // Bug 1509316 +# else +# define PREF_VALUE true +# endif + +VARCACHE_PREF( + "media.navigator.mediadatadecoder_h264_enabled", + MediaNavigatorMediadatadecoderH264Enabled, + RelaxedAtomicBool, PREF_VALUE +) +#undef PREF_VALUE + +#endif // MOZ_WEBRTC + #ifdef MOZ_OMX VARCACHE_PREF( - Live, "media.omx.enabled", - MediaOmxEnabled, + MediaOmxEnabled, bool, false ) #endif @@ -4669,17 +1795,15 @@ VARCACHE_PREF( # define PREF_VALUE true # endif VARCACHE_PREF( - Live, "media.ffmpeg.enabled", - MediaFfmpegEnabled, + MediaFfmpegEnabled, RelaxedAtomicBool, PREF_VALUE ) #undef PREF_VALUE VARCACHE_PREF( - Live, "media.libavcodec.allow-obsolete", - MediaLibavcodecAllowObsolete, + MediaLibavcodecAllowObsolete, bool, false ) @@ -4687,18 +1811,16 @@ VARCACHE_PREF( #ifdef MOZ_FFVPX VARCACHE_PREF( - Live, "media.ffvpx.enabled", - MediaFfvpxEnabled, + MediaFfvpxEnabled, RelaxedAtomicBool, true ) #endif #if defined(MOZ_FFMPEG) || defined(MOZ_FFVPX) VARCACHE_PREF( - Live, "media.ffmpeg.low-latency.enabled", - MediaFfmpegLowLatencyEnabled, + MediaFfmpegLowLatencyEnabled, RelaxedAtomicBool, false ) #endif @@ -4706,113 +1828,20 @@ VARCACHE_PREF( #ifdef MOZ_WMF VARCACHE_PREF( - Live, "media.wmf.enabled", - MediaWmfEnabled, + MediaWmfEnabled, RelaxedAtomicBool, true ) // Whether DD should consider WMF-disabled a WMF failure, useful for testing. VARCACHE_PREF( - Live, "media.decoder-doctor.wmf-disabled-is-failure", - MediaDecoderDoctorWmfDisabledIsFailure, + MediaDecoderDoctorWmfDisabledIsFailure, bool, false ) -VARCACHE_PREF( - Live, - "media.wmf.dxva.d3d11.enabled", - PDMWMFAllowD3D11, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "media.wmf.dxva.max-videos", - PDMWMFMaxDXVAVideos, - RelaxedAtomicUint32, 8 -) - -VARCACHE_PREF( - Live, - "media.wmf.use-nv12-format", - PDMWMFUseNV12Format, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "media.wmf.force.allow-p010-format", - PDMWMFForceAllowP010Format, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "media.wmf.use-sync-texture", - PDMWMFUseSyncTexture, - bool, true -) - -VARCACHE_PREF( - Live, - "media.wmf.low-latency.enabled", - PDMWMFLowLatencyEnabled, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "media.wmf.low-latency.force-disabled", - PDMWMFLowLatencyForceDisabled, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "media.wmf.skip-blacklist", - PDMWMFSkipBlacklist, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "media.wmf.deblacklisting-for-telemetry-in-gpu-process", - PDMWMFDeblacklistingForTelemetryInGPUProcess, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "media.wmf.amd.highres.enabled", - PDMWMFAMDHighResEnabled, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "media.wmf.allow-unsupported-resolutions", - PDMWMFAllowUnsupportedResolutions, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Once, - "media.wmf.vp9.enabled", - MediaWmfVp9Enabled, - bool, true -) - #endif // MOZ_WMF -VARCACHE_PREF( - Once, - "media.hardware-video-decoding.force-enabled", - HardwareVideoDecodingForceEnabled, - bool, false -) - // Whether to check the decoder supports recycling. #ifdef ANDROID # define PREF_VALUE true @@ -4820,113 +1849,98 @@ VARCACHE_PREF( # define PREF_VALUE false #endif VARCACHE_PREF( - Live, "media.decoder.recycle.enabled", - MediaDecoderRecycleEnabled, + MediaDecoderRecycleEnabled, RelaxedAtomicBool, PREF_VALUE ) #undef PREF_VALUE // Should MFR try to skip to the next key frame? VARCACHE_PREF( - Live, "media.decoder.skip-to-next-key-frame.enabled", - MediaDecoderSkipToNextKeyFrameEnabled, + MediaDecoderSkipToNextKeyFrameEnabled, RelaxedAtomicBool, true ) VARCACHE_PREF( - Live, "media.gmp.decoder.enabled", - MediaGmpDecoderEnabled, + MediaGmpDecoderEnabled, RelaxedAtomicBool, false ) VARCACHE_PREF( - Live, "media.eme.audio.blank", - MediaEmeAudioBlank, + MediaEmeAudioBlank, RelaxedAtomicBool, false ) VARCACHE_PREF( - Live, "media.eme.video.blank", - MediaEmeVideoBlank, + MediaEmeVideoBlank, RelaxedAtomicBool, false ) VARCACHE_PREF( - Live, "media.eme.chromium-api.video-shmems", - MediaEmeChromiumApiVideoShmems, + MediaEmeChromiumApiVideoShmems, RelaxedAtomicUint32, 6 ) // Whether to suspend decoding of videos in background tabs. VARCACHE_PREF( - Live, "media.suspend-bkgnd-video.enabled", - MediaSuspendBkgndVideoEnabled, + MediaSuspendBkgndVideoEnabled, RelaxedAtomicBool, true ) // Delay, in ms, from time window goes to background to suspending // video decoders. Defaults to 10 seconds. VARCACHE_PREF( - Live, "media.suspend-bkgnd-video.delay-ms", - MediaSuspendBkgndVideoDelayMs, + MediaSuspendBkgndVideoDelayMs, RelaxedAtomicUint32, 10000 ) VARCACHE_PREF( - Live, "media.dormant-on-pause-timeout-ms", - MediaDormantOnPauseTimeoutMs, + MediaDormantOnPauseTimeoutMs, RelaxedAtomicInt32, 5000 ) VARCACHE_PREF( - Live, "media.webspeech.synth.force_global_queue", - MediaWebspeechSynthForceGlobalQueue, + MediaWebspeechSynthForceGlobalQueue, bool, false ) VARCACHE_PREF( - Live, "media.webspeech.test.enable", - MediaWebspeechTestEnable, + MediaWebspeechTestEnable, bool, false ) VARCACHE_PREF( - Live, "media.webspeech.test.fake_fsm_events", - MediaWebspeechTextFakeFsmEvents, + MediaWebspeechTextFakeFsmEvents, bool, false ) VARCACHE_PREF( - Live, "media.webspeech.test.fake_recognition_service", - MediaWebspeechTextFakeRecognitionService, + MediaWebspeechTextFakeRecognitionService, bool, false ) #ifdef MOZ_WEBSPEECH VARCACHE_PREF( - Live, "media.webspeech.recognition.enable", - MediaWebspeechRecognitionEnable, + MediaWebspeechRecognitionEnable, bool, false ) #endif VARCACHE_PREF( - Live, "media.webspeech.recognition.force_enable", - MediaWebspeechRecognitionForceEnable, + MediaWebspeechRecognitionForceEnable, bool, false ) @@ -4936,9 +1950,8 @@ VARCACHE_PREF( # define PREF_VALUE false #endif VARCACHE_PREF( - Live, "media.encoder.webm.enabled", - MediaEncoderWebMEnabled, + MediaEncoderWebMEnabled, RelaxedAtomicBool, true ) #undef PREF_VALUE @@ -4950,9 +1963,8 @@ VARCACHE_PREF( # define PREF_VALUE 0 #endif VARCACHE_PREF( - Live, "media.audio-max-decode-error", - MediaAudioMaxDecodeError, + MediaAudioMaxDecodeError, uint32_t, PREF_VALUE ) #undef PREF_VALUE @@ -4964,42 +1976,37 @@ VARCACHE_PREF( # define PREF_VALUE 0 #endif VARCACHE_PREF( - Live, "media.video-max-decode-error", - MediaVideoMaxDecodeError, + MediaVideoMaxDecodeError, uint32_t, PREF_VALUE ) #undef PREF_VALUE // Opus VARCACHE_PREF( - Live, "media.opus.enabled", - MediaOpusEnabled, + MediaOpusEnabled, RelaxedAtomicBool, true ) // Wave VARCACHE_PREF( - Live, "media.wave.enabled", - MediaWaveEnabled, + MediaWaveEnabled, RelaxedAtomicBool, true ) // Ogg VARCACHE_PREF( - Live, "media.ogg.enabled", - MediaOggEnabled, + MediaOggEnabled, RelaxedAtomicBool, true ) // WebM VARCACHE_PREF( - Live, "media.webm.enabled", - MediaWebMEnabled, + MediaWebMEnabled, RelaxedAtomicBool, true ) @@ -5014,17 +2021,15 @@ VARCACHE_PREF( # define PREF_VALUE false #endif VARCACHE_PREF( - Live, "media.av1.enabled", - MediaAv1Enabled, + MediaAv1Enabled, RelaxedAtomicBool, PREF_VALUE ) #undef PREF_VALUE VARCACHE_PREF( - Live, "media.av1.use-dav1d", - MediaAv1UseDav1d, + MediaAv1UseDav1d, #if defined(XP_WIN) && !defined(_ARM64_) RelaxedAtomicBool, true #elif defined(XP_MACOSX) @@ -5037,9 +2042,8 @@ VARCACHE_PREF( ) VARCACHE_PREF( - Live, "media.flac.enabled", - MediaFlacEnabled, + MediaFlacEnabled, bool, true ) @@ -5050,9 +2054,8 @@ VARCACHE_PREF( # define PREF_VALUE false #endif VARCACHE_PREF( - Live, "media.hls.enabled", - MediaHlsEnabled, + MediaHlsEnabled, bool, PREF_VALUE ) #undef PREF_VALUE @@ -5061,9 +2064,8 @@ VARCACHE_PREF( // Android and when "media.hls.enabled" is true. #ifdef ANDROID VARCACHE_PREF( - Live, "media.hls.max-allocations", - MediaHlsMaxAllocations, + MediaHlsMaxAllocations, uint32_t, 20 ) #endif @@ -5074,9 +2076,8 @@ VARCACHE_PREF( # define PREF_VALUE false #endif VARCACHE_PREF( - Live, "media.mp4.enabled", - MediaMp4Enabled, + MediaMp4Enabled, RelaxedAtomicBool, PREF_VALUE ) #undef PREF_VALUE @@ -5085,253 +2086,106 @@ VARCACHE_PREF( // // Set to true to force demux/decode warnings to be treated as errors. VARCACHE_PREF( - Live, "media.playback.warnings-as-errors", - MediaPlaybackWarningsAsErrors, + MediaPlaybackWarningsAsErrors, RelaxedAtomicBool, false ) // Resume video decoding when the cursor is hovering on a background tab to -// reduce the resume latency and improve the user experience. -VARCACHE_PREF( - Live, - "media.resume-bkgnd-video-on-tabhover", - MediaResumeBkgndVideoOnTabhover, - bool, true -) - -#ifdef ANDROID -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "media.videocontrols.lock-video-orientation", - MediaVideocontrolsLockVideoOrientation, - bool, PREF_VALUE -) -#undef PREF_VALUE - -// Media Seamless Looping -VARCACHE_PREF( - Live, - "media.seamless-looping", - MediaSeamlessLooping, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "media.autoplay.block-event.enabled", - MediaBlockEventEnabled, - bool, false -) - -VARCACHE_PREF( - Live, - "media.media-capabilities.enabled", - MediaCapabilitiesEnabled, - RelaxedAtomicBool, true -) - -VARCACHE_PREF( - Live, - "media.media-capabilities.screen.enabled", - MediaCapabilitiesScreenEnabled, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "media.benchmark.vp9.fps", - MediaBenchmarkVp9Fps, - RelaxedAtomicUint32, 0 -) - -VARCACHE_PREF( - Live, - "media.benchmark.vp9.threshold", - MediaBenchmarkVp9Threshold, - RelaxedAtomicUint32, 150 -) - -VARCACHE_PREF( - Live, - "media.benchmark.vp9.versioncheck", - MediaBenchmarkVp9Versioncheck, - RelaxedAtomicUint32, 0 -) - -VARCACHE_PREF( - Live, - "media.benchmark.frames", - MediaBenchmarkFrames, - RelaxedAtomicUint32, 300 -) - -VARCACHE_PREF( - Live, - "media.benchmark.timeout", - MediaBenchmarkTimeout, - RelaxedAtomicUint32, 1000 -) - -VARCACHE_PREF( - Live, - "media.test.video-suspend", - MediaTestVideoSuspend, - RelaxedAtomicBool, false -) - -// MediaCapture prefs follow - -// Enables navigator.mediaDevices and getUserMedia() support. See also -// media.peerconnection.enabled -VARCACHE_PREF( - Live, - "media.navigator.enabled", - media_navigator_enabled, - bool, true -) - -// This pref turns off [SecureContext] on the navigator.mediaDevices object, for -// more compatible legacy behavior. -VARCACHE_PREF( - Live, - "media.devices.insecure.enabled", - media_devices_insecure_enabled, - bool, true -) - -// If the above pref is also enabled, this pref enabled getUserMedia() support -// in http, bypassing the instant NotAllowedError you get otherwise. -VARCACHE_PREF( - Live, - "media.getusermedia.insecure.enabled", - media_getusermedia_insecure_enabled, - bool, false -) - -// WebRTC prefs follow - -// Enables RTCPeerConnection support. Note that, when true, this pref enables -// navigator.mediaDevices and getUserMedia() support as well. -// See also media.navigator.enabled -VARCACHE_PREF( - Live, - "media.peerconnection.enabled", - media_peerconnection_enabled, - bool, true -) - -#ifdef MOZ_WEBRTC -#ifdef ANDROID - -VARCACHE_PREF( - Live, - "media.navigator.hardware.vp8_encode.acceleration_remote_enabled", - MediaNavigatorHardwareVp8encodeAccelerationRemoteEnabled, - bool, true -) - -PREF("media.navigator.hardware.vp8_encode.acceleration_enabled", bool, true) - -PREF("media.navigator.hardware.vp8_decode.acceleration_enabled", bool, false) - -#endif // ANDROID +// reduce the resume latency and improve the user experience. +VARCACHE_PREF( + "media.resume-bkgnd-video-on-tabhover", + MediaResumeBkgndVideoOnTabhover, + bool, true +) -// Use MediaDataDecoder API for VP8/VP9 in WebRTC. This includes hardware -// acceleration for decoding. -// disable on android bug 1509316 -#if defined(NIGHTLY_BUILD) && !defined(ANDROID) +#ifdef ANDROID # define PREF_VALUE true #else # define PREF_VALUE false #endif VARCACHE_PREF( - Live, - "media.navigator.mediadatadecoder_vpx_enabled", - MediaNavigatorMediadatadecoderVPXEnabled, - RelaxedAtomicBool, PREF_VALUE + "media.videocontrols.lock-video-orientation", + MediaVideocontrolsLockVideoOrientation, + bool, PREF_VALUE ) #undef PREF_VALUE -// Use MediaDataDecoder API for H264 in WebRTC. This includes hardware -// acceleration for decoding. -# if defined(ANDROID) -# define PREF_VALUE false // Bug 1509316 -# else -# define PREF_VALUE true -# endif +// Media Seamless Looping +VARCACHE_PREF( + "media.seamless-looping", + MediaSeamlessLooping, + RelaxedAtomicBool, true +) VARCACHE_PREF( - Live, - "media.navigator.mediadatadecoder_h264_enabled", - MediaNavigatorMediadatadecoderH264Enabled, - RelaxedAtomicBool, PREF_VALUE + "media.autoplay.block-event.enabled", + MediaBlockEventEnabled, + bool, false ) -#undef PREF_VALUE -#endif // MOZ_WEBRTC +VARCACHE_PREF( + "media.media-capabilities.enabled", + MediaCapabilitiesEnabled, + RelaxedAtomicBool, true +) -//--------------------------------------------------------------------------- -// Prefs starting with "mousewheel." -//--------------------------------------------------------------------------- +VARCACHE_PREF( + "media.media-capabilities.screen.enabled", + MediaCapabilitiesScreenEnabled, + RelaxedAtomicBool, false +) -// These affect how line scrolls from wheel events will be accelerated. VARCACHE_PREF( - Live, - "mousewheel.acceleration.factor", - MouseWheelAccelerationFactor, - RelaxedAtomicInt32, -1 + "media.benchmark.vp9.fps", + MediaBenchmarkVp9Fps, + RelaxedAtomicUint32, 0 ) VARCACHE_PREF( - Live, - "mousewheel.acceleration.start", - MouseWheelAccelerationStart, - RelaxedAtomicInt32, -1 + "media.benchmark.vp9.threshold", + MediaBenchmarkVp9Threshold, + RelaxedAtomicUint32, 150 ) -// This affects whether events will be routed through APZ or not. VARCACHE_PREF( - Live, - "mousewheel.system_scroll_override_on_root_content.enabled", - MouseWheelHasRootScrollDeltaOverride, - RelaxedAtomicBool, false + "media.benchmark.vp9.versioncheck", + MediaBenchmarkVp9Versioncheck, + RelaxedAtomicUint32, 0 ) VARCACHE_PREF( - Live, - "mousewheel.system_scroll_override_on_root_content.horizontal.factor", - MouseWheelRootScrollHorizontalFactor, - RelaxedAtomicInt32, 0 + "media.benchmark.frames", + MediaBenchmarkFrames, + RelaxedAtomicUint32, 300 ) VARCACHE_PREF( - Live, - "mousewheel.system_scroll_override_on_root_content.vertical.factor", - MouseWheelRootScrollVerticalFactor, - RelaxedAtomicInt32, 0 + "media.benchmark.timeout", + MediaBenchmarkTimeout, + RelaxedAtomicUint32, 1000 +) + +VARCACHE_PREF( + "media.test.video-suspend", + MediaTestVideoSuspend, + RelaxedAtomicBool, false ) VARCACHE_PREF( - Live, - "mousewheel.transaction.ignoremovedelay", - MouseWheelIgnoreMoveDelayMs, - RelaxedAtomicInt32, (int32_t)100 + "media.autoplay.allow-muted", + MediaAutoplayAllowMuted, + RelaxedAtomicBool, true ) VARCACHE_PREF( - Live, - "mousewheel.transaction.timeout", - MouseWheelTransactionTimeoutMs, - RelaxedAtomicInt32, (int32_t)1500 + "media.autoplay.blackList-override-default", + MediaAutoplayBlackListOverrideDefault, + RelaxedAtomicBool, true ) //--------------------------------------------------------------------------- -// Prefs starting with "network." +// Network prefs //--------------------------------------------------------------------------- // Sub-resources HTTP-authentication: @@ -5341,9 +2195,8 @@ VARCACHE_PREF( // but don't allow it for cross-origin sub-resources // 2 - allow the cross-origin authentication as well. VARCACHE_PREF( - Live, "network.auth.subresource-http-auth-allow", - network_auth_subresource_http_auth_allow, + network_auth_subresource_http_auth_allow, uint32_t, 2 ) @@ -5353,9 +2206,8 @@ VARCACHE_PREF( // If network.auth.subresource-http-auth-allow has values 0 or 1 this pref does // not have any effect. VARCACHE_PREF( - Live, "network.auth.subresource-img-cross-origin-http-auth-allow", - network_auth_subresource_img_cross_origin_http_auth_allow, + network_auth_subresource_img_cross_origin_http_auth_allow, bool, false ) @@ -5363,9 +2215,8 @@ VARCACHE_PREF( // - true: They are allow to present http auth. dialog // - false: They are not allow to present http auth. dialog. VARCACHE_PREF( - Live, "network.auth.non-web-content-triggered-resources-http-auth-allow", - network_auth_non_web_content_triggered_resources_http_auth_allow, + network_auth_non_web_content_triggered_resources_http_auth_allow, bool, false ) @@ -5373,7 +2224,6 @@ VARCACHE_PREF( // 4-rejectTracker // Keep the old default of accepting all cookies VARCACHE_PREF( - Live, "network.cookie.cookieBehavior", network_cookie_cookieBehavior, RelaxedAtomicInt32, 0 @@ -5381,9 +2231,8 @@ VARCACHE_PREF( // Stale threshold for cookies in seconds. VARCACHE_PREF( - Live, "network.cookie.staleThreshold", - network_cookie_staleThreshold, + network_cookie_staleThreshold, uint32_t, 60 ) @@ -5393,7 +2242,6 @@ VARCACHE_PREF( // 2 - accept as session cookies // 3 - deprecated. don't use it. VARCACHE_PREF( - Live, "network.cookie.lifetimePolicy", network_cookie_lifetimePolicy, RelaxedAtomicInt32, 0 @@ -5401,143 +2249,122 @@ VARCACHE_PREF( // Enables the predictive service. VARCACHE_PREF( - Live, "network.predictor.enabled", - network_predictor_enabled, + network_predictor_enabled, bool, true ) // Allow CookieSettings to be unblocked for channels without a document. // This is for testing only. VARCACHE_PREF( - Live, "network.cookieSettings.unblocked_for_testing", - network_cookieSettings_unblocked_for_testing, + network_cookieSettings_unblocked_for_testing, bool, false ) VARCACHE_PREF( - Live, "network.predictor.enable-hover-on-ssl", - network_predictor_enable_hover_on_ssl, + network_predictor_enable_hover_on_ssl, bool, false ) VARCACHE_PREF( - Live, "network.predictor.enable-prefetch", - network_predictor_enable_prefetch, + network_predictor_enable_prefetch, bool, false ) VARCACHE_PREF( - Live, "network.predictor.page-degradation.day", - network_predictor_page_degradation_day, + network_predictor_page_degradation_day, int32_t, 0 ) VARCACHE_PREF( - Live, "network.predictor.page-degradation.week", - network_predictor_page_degradation_week, + network_predictor_page_degradation_week, int32_t, 5 ) VARCACHE_PREF( - Live, "network.predictor.page-degradation.month", - network_predictor_page_degradation_month, + network_predictor_page_degradation_month, int32_t, 10 ) VARCACHE_PREF( - Live, "network.predictor.page-degradation.year", - network_predictor_page_degradation_year, + network_predictor_page_degradation_year, int32_t, 25 ) VARCACHE_PREF( - Live, "network.predictor.page-degradation.max", - network_predictor_page_degradation_max, + network_predictor_page_degradation_max, int32_t, 50 ) VARCACHE_PREF( - Live, "network.predictor.subresource-degradation.day", - network_predictor_subresource_degradation_day, + network_predictor_subresource_degradation_day, int32_t, 1 ) VARCACHE_PREF( - Live, "network.predictor.subresource-degradation.week", - network_predictor_subresource_degradation_week, + network_predictor_subresource_degradation_week, int32_t, 10 ) VARCACHE_PREF( - Live, "network.predictor.subresource-degradation.month", - network_predictor_subresource_degradation_month, + network_predictor_subresource_degradation_month, int32_t, 25 ) VARCACHE_PREF( - Live, "network.predictor.subresource-degradation.year", - network_predictor_subresource_degradation_year, + network_predictor_subresource_degradation_year, int32_t, 50 ) VARCACHE_PREF( - Live, "network.predictor.subresource-degradation.max", - network_predictor_subresource_degradation_max, + network_predictor_subresource_degradation_max, int32_t, 100 ) VARCACHE_PREF( - Live, "network.predictor.prefetch-rolling-load-count", - network_predictor_prefetch_rolling_load_count, + network_predictor_prefetch_rolling_load_count, int32_t, 10 ) VARCACHE_PREF( - Live, "network.predictor.prefetch-min-confidence", - network_predictor_prefetch_min_confidence, + network_predictor_prefetch_min_confidence, int32_t, 100 ) VARCACHE_PREF( - Live, "network.predictor.preconnect-min-confidence", - network_predictor_preconnect_min_confidence, + network_predictor_preconnect_min_confidence, int32_t, 90 ) VARCACHE_PREF( - Live, "network.predictor.preresolve-min-confidence", - network_predictor_preresolve_min_confidence, + network_predictor_preresolve_min_confidence, int32_t, 60 ) VARCACHE_PREF( - Live, "network.predictor.prefetch-force-valid-for", - network_predictor_prefetch_force_valid_for, + network_predictor_prefetch_force_valid_for, int32_t, 10 ) VARCACHE_PREF( - Live, "network.predictor.max-resources-per-entry", - network_predictor_max_resources_per_entry, + network_predictor_max_resources_per_entry, int32_t, 100 ) // This is selected in concert with max-resources-per-entry to keep memory // usage low-ish. The default of the combo of the two is ~50k. VARCACHE_PREF( - Live, "network.predictor.max-uri-length", - network_predictor_max_uri_length, + network_predictor_max_uri_length, uint32_t, 500 ) @@ -5545,94 +2372,86 @@ PREF("network.predictor.cleaned-up", bool, false) // A testing flag. VARCACHE_PREF( - Live, "network.predictor.doing-tests", - network_predictor_doing_tests, + network_predictor_doing_tests, bool, false ) // Telemetry of traffic categories VARCACHE_PREF( - Live, "network.traffic_analyzer.enabled", network_traffic_analyzer_enabled, RelaxedAtomicBool, false ) VARCACHE_PREF( - Live, "network.delay.tracking.load", - network_delay_tracking_load, - uint32_t, 0 + network_delay_tracking_load, + uint32_t, 0 ) // Max time to shutdown the resolver threads VARCACHE_PREF( - Live, "network.dns.resolver_shutdown_timeout_ms", - network_dns_resolver_shutdown_timeout_ms, - uint32_t, 2000 + network_dns_resolver_shutdown_timeout_ms, + uint32_t, 2000 ) // Some requests during a page load are marked as "tail", mainly trackers, but not only. // This pref controls whether such requests are put to the tail, behind other requests // emerging during page loading process. VARCACHE_PREF( - Live, "network.http.tailing.enabled", - network_http_tailing_enabled, - bool, true + network_http_tailing_enabled, + bool, true ) //--------------------------------------------------------------------------- -// Prefs starting with "nglayout." +// ContentSessionStore prefs //--------------------------------------------------------------------------- - +// Maximum number of bytes of DOMSessionStorage data we collect per origin. VARCACHE_PREF( - Live, - "nglayout.debug.widget_update_flashing", - WidgetUpdateFlashing, - RelaxedAtomicBool, false + "browser.sessionstore.dom_storage_limit", + browser_sessionstore_dom_storage_limit, + uint32_t, 2048 ) //--------------------------------------------------------------------------- -// Prefs starting with "plugins." +// Preferences prefs +//--------------------------------------------------------------------------- + +PREF("preferences.allow.omt-write", bool, true) + +//--------------------------------------------------------------------------- +// Privacy prefs //--------------------------------------------------------------------------- +// Whether Content Blocking Third-Party Cookies UI has been enabled. VARCACHE_PREF( - Live, - "plugins.flashBlock.enabled", - plugins_flashBlock_enabled, + "browser.contentblocking.allowlist.storage.enabled", + browser_contentblocking_allowlist_storage_enabled, bool, false ) VARCACHE_PREF( - Live, - "plugins.http_https_only", - plugins_http_https_only, + "browser.contentblocking.allowlist.annotations.enabled", + browser_contentblocking_allowlist_annotations_enabled, bool, true ) -//--------------------------------------------------------------------------- -// Prefs starting with "preferences." -//--------------------------------------------------------------------------- - -PREF("preferences.allow.omt-write", bool, true) - -//--------------------------------------------------------------------------- -// Prefs starting with "print." -//--------------------------------------------------------------------------- - +// How many recent block/unblock actions per origins we remember in the +// Content Blocking log for each top-level window. VARCACHE_PREF( - Live, - "print.font-variations-as-paths", - PrintFontVariationsAsPaths, - RelaxedAtomicBool, true + "browser.contentblocking.originlog.length", + browser_contentblocking_originlog_length, + uint32_t, 32 ) -//--------------------------------------------------------------------------- -// Prefs starting with "privacy." -//--------------------------------------------------------------------------- +VARCACHE_PREF( + "browser.contentblocking.rejecttrackers.control-center.ui.enabled", + browser_contentblocking_rejecttrackers_control_center_ui_enabled, + bool, false +) // Annotate trackers using the strict list. If set to false, the basic list will // be used instead. @@ -5642,609 +2461,438 @@ VARCACHE_PREF( #define PREF_VALUE false #endif VARCACHE_PREF( - Live, "privacy.annotate_channels.strict_list.enabled", - privacy_annotate_channels_strict_list_enabled, + privacy_annotate_channels_strict_list_enabled, bool, PREF_VALUE ) #undef PREF_VALUE // Annotate channels based on the tracking protection list in all modes VARCACHE_PREF( - Live, "privacy.trackingprotection.annotate_channels", - privacy_trackingprotection_annotate_channels, + privacy_trackingprotection_annotate_channels, bool, true ) // Block 3rd party fingerprinting resources. VARCACHE_PREF( - Live, "privacy.trackingprotection.fingerprinting.enabled", - privacy_trackingprotection_fingerprinting_enabled, + privacy_trackingprotection_fingerprinting_enabled, bool, false ) // Annotate fingerprinting resources. VARCACHE_PREF( - Live, "privacy.trackingprotection.fingerprinting.annotate.enabled", - privacy_trackingprotection_fingerprinting_annotate_enabled, + privacy_trackingprotection_fingerprinting_annotate_enabled, bool, true ) // Block 3rd party cryptomining resources. VARCACHE_PREF( - Live, "privacy.trackingprotection.cryptomining.enabled", - privacy_trackingprotection_cryptomining_enabled, + privacy_trackingprotection_cryptomining_enabled, bool, false ) // Annotate cryptomining resources. VARCACHE_PREF( - Live, "privacy.trackingprotection.cryptomining.annotate.enabled", - privacy_trackingprotection_cryptomining_annotate_enabled, - bool, true -) - -// Whether origin telemetry should be enabled -// NOTE: if telemetry.origin_telemetry_test_mode.enabled is enabled, this pref -// won't have any effect. -VARCACHE_PREF( - Live, - "privacy.trackingprotection.origin_telemetry.enabled", - privacy_trackingprotection_origin_telemetry_enabled, - RelaxedAtomicBool, false -) - -// Spoof user locale to English -VARCACHE_PREF( - Live, - "privacy.spoof_english", - privacy_spoof_english, - RelaxedAtomicUint32, 0 -) - -// send "do not track" HTTP header, disabled by default -VARCACHE_PREF( - Live, - "privacy.donottrackheader.enabled", - privacy_donottrackheader_enabled, - bool, false -) - -// Lower the priority of network loads for resources on the tracking protection -// list. Note that this requires the -// privacy.trackingprotection.annotate_channels pref to be on in order to have -// any effect. -#ifdef NIGHTLY_BUILD -# define PREF_VALUE true -#else -# define PREF_VALUE false -#endif -VARCACHE_PREF( - Live, - "privacy.trackingprotection.lower_network_priority", - privacy_trackingprotection_lower_network_priority, - bool, PREF_VALUE -) -#undef PREF_VALUE - -VARCACHE_PREF( - Live, - "privacy.resistFingerprinting", - ResistFingerprinting, - RelaxedAtomicBool, false -) - -// Anti-tracking permission expiration -VARCACHE_PREF( - Live, - "privacy.restrict3rdpartystorage.expiration", - privacy_restrict3rdpartystorage_expiration, - uint32_t, 2592000 // 30 days (in seconds) -) - -// Anti-tracking user-interaction expiration -VARCACHE_PREF( - Live, - "privacy.userInteraction.expiration", - privacy_userInteraction_expiration, - uint32_t, 2592000 // 30 days (in seconds) -) - -// Anti-tracking user-interaction document interval -VARCACHE_PREF( - Live, - "privacy.userInteraction.document.interval", - privacy_userInteraction_document_interval, - uint32_t, 1800 // 30 minutes (in seconds) -) - -// Maximum client-side cookie life-time cap -#ifdef NIGHTLY_BUILD -# define PREF_VALUE 604800 // 7 days -#else -# define PREF_VALUE 0 -#endif -VARCACHE_PREF( - Live, - "privacy.documentCookies.maxage", - privacy_documentCookies_maxage, - uint32_t, PREF_VALUE // (in seconds, set to 0 to disable) -) -#undef PREF_VALUE - -// Anti-fingerprinting, disabled by default -VARCACHE_PREF( - Live, - "privacy.resistFingerprinting", - privacy_resistFingerprinting, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "privacy.resistFingerprinting.autoDeclineNoUserInputCanvasPrompts", - privacy_resistFingerprinting_autoDeclineNoUserInputCanvasPrompts, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "privacy.storagePrincipal.enabledForTrackers", - privacy_storagePrincipal_enabledForTrackers, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "privacy.window.maxInnerWidth", - privacy_window_maxInnerWidth, - int32_t, 1000 -) - -VARCACHE_PREF( - Live, - "privacy.window.maxInnerHeight", - privacy_window_maxInnerHeight, - int32_t, 1000 -) - -//--------------------------------------------------------------------------- -// Prefs starting with "security." -//--------------------------------------------------------------------------- - -VARCACHE_PREF( - Live, - "security.csp.enable", - security_csp_enable, - bool, true -) - -VARCACHE_PREF( - Live, - "security.csp.enableStrictDynamic", - security_csp_enableStrictDynamic, - bool, true -) - -VARCACHE_PREF( - Live, - "security.csp.reporting.script-sample.max-length", - security_csp_reporting_script_sample_max_length, - int32_t, 40 -) - -// Whether strict file origin policy is in effect. -VARCACHE_PREF( - Live, - "security.fileuri.strict_origin_policy", - security_fileuri_strict_origin_policy, - RelaxedAtomicBool, true -) - -//--------------------------------------------------------------------------- -// Prefs starting with "slider." -//--------------------------------------------------------------------------- - -VARCACHE_PREF( - Once, - "slider.snapMultiplier", - SliderSnapMultiplier, - int32_t, 0 -) - -//--------------------------------------------------------------------------- -// Prefs starting with "telemetry." -//--------------------------------------------------------------------------- - -// Enable origin telemetry test mode or not -// NOTE: turning this on will override the -// privacy.trackingprotection.origin_telemetry.enabled pref. -VARCACHE_PREF( - Live, - "telemetry.origin_telemetry_test_mode.enabled", - telemetry_origin_telemetry_test_mode_enabled, - RelaxedAtomicBool, false -) - -//--------------------------------------------------------------------------- -// Prefs starting with "test." -//--------------------------------------------------------------------------- - -VARCACHE_PREF( - Live, - "test.events.async.enabled", - TestEventsAsyncEnabled, - RelaxedAtomicBool, false -) - -VARCACHE_PREF( - Live, - "test.mousescroll", - MouseScrollTestingEnabled, - RelaxedAtomicBool, false -) - -//--------------------------------------------------------------------------- -// Prefs starting with "toolkit." -//--------------------------------------------------------------------------- + privacy_trackingprotection_cryptomining_annotate_enabled, + bool, true +) +// Spoof user locale to English VARCACHE_PREF( - Live, - "toolkit.scrollbox.horizontalScrollDistance", - ToolkitHorizontalScrollDistance, - RelaxedAtomicInt32, 5 + "privacy.spoof_english", + privacy_spoof_english, + RelaxedAtomicUint32, 0 ) +// send "do not track" HTTP header, disabled by default VARCACHE_PREF( - Live, - "toolkit.scrollbox.verticalScrollDistance", - ToolkitVerticalScrollDistance, - RelaxedAtomicInt32, 3 + "privacy.donottrackheader.enabled", + privacy_donottrackheader_enabled, + bool, false ) -//--------------------------------------------------------------------------- -// Prefs starting with "thread." -//--------------------------------------------------------------------------- - +// Lower the priority of network loads for resources on the tracking protection +// list. Note that this requires the +// privacy.trackingprotection.annotate_channels pref to be on in order to have +// any effect. +#ifdef NIGHTLY_BUILD +# define PREF_VALUE true +#else +# define PREF_VALUE false +#endif VARCACHE_PREF( - Live, - "threads.medium_high_event_queue.enabled", - threads_medium_high_event_queue_enabled, - RelaxedAtomicBool, true + "privacy.trackingprotection.lower_network_priority", + privacy_trackingprotection_lower_network_priority, + bool, PREF_VALUE ) +#undef PREF_VALUE -//--------------------------------------------------------------------------- -// Prefs starting with "ui." -//--------------------------------------------------------------------------- - -// Prevent system colors from being exposed to CSS or canvas. +// Anti-tracking permission expiration VARCACHE_PREF( - Live, - "ui.use_standins_for_native_colors", - ui_use_standins_for_native_colors, - RelaxedAtomicBool, false + "privacy.restrict3rdpartystorage.expiration", + privacy_restrict3rdpartystorage_expiration, + uint32_t, 2592000 // 30 days (in seconds) ) -// Disable page loading activity cursor by default. +// Anti-tracking user-interaction expiration VARCACHE_PREF( - Live, - "ui.use_activity_cursor", - ui_use_activity_cursor, - bool, false + "privacy.userInteraction.expiration", + privacy_userInteraction_expiration, + uint32_t, 2592000 // 30 days (in seconds) ) +// Anti-tracking user-interaction document interval VARCACHE_PREF( - Live, - "ui.click_hold_context_menus.delay", - UiClickHoldContextMenusDelay, - RelaxedAtomicInt32, 500 + "privacy.userInteraction.document.interval", + privacy_userInteraction_document_interval, + uint32_t, 1800 // 30 minutes (in seconds) ) -//--------------------------------------------------------------------------- -// View source prefs -//--------------------------------------------------------------------------- - +// Maximum client-side cookie life-time cap +#ifdef NIGHTLY_BUILD +# define PREF_VALUE 604800 // 7 days +#else +# define PREF_VALUE 0 +#endif VARCACHE_PREF( - Live, - "view_source.editor.external", - view_source_editor_external, - bool, false + "privacy.documentCookies.maxage", + privacy_documentCookies_maxage, + uint32_t, PREF_VALUE // (in seconds, set to 0 to disable) ) +#undef PREF_VALUE -//--------------------------------------------------------------------------- -// Prefs starting with "webgl." (for pref access from Worker threads) -//--------------------------------------------------------------------------- - +// Anti-fingerprinting, disabled by default VARCACHE_PREF( - Live, - "webgl.1.allow-core-profiles", - WebGL1AllowCoreProfile, + "privacy.resistFingerprinting", + privacy_resistFingerprinting, RelaxedAtomicBool, false ) - VARCACHE_PREF( - Live, - "webgl.all-angle-options", - WebGLAllANGLEOptions, + "privacy.resistFingerprinting.autoDeclineNoUserInputCanvasPrompts", + privacy_resistFingerprinting_autoDeclineNoUserInputCanvasPrompts, RelaxedAtomicBool, false ) VARCACHE_PREF( - Live, - "webgl.angle.force-d3d11", - WebGLANGLEForceD3D11, + "privacy.storagePrincipal.enabledForTrackers", + privacy_storagePrincipal_enabledForTrackers, RelaxedAtomicBool, false ) VARCACHE_PREF( - Live, - "webgl.angle.try-d3d11", - WebGLANGLETryD3D11, - RelaxedAtomicBool, false + "privacy.window.maxInnerWidth", + privacy_window_maxInnerWidth, + int32_t, 1000 ) VARCACHE_PREF( - Live, - "webgl.angle.force-warp", - WebGLANGLEForceWARP, - RelaxedAtomicBool, false + "privacy.window.maxInnerHeight", + privacy_window_maxInnerHeight, + int32_t, 1000 ) +// Time limit, in milliseconds, for EventStateManager::IsHandlingUserInput(). +// Used to detect long running handlers of user-generated events. VARCACHE_PREF( - Live, - "webgl.can-lose-context-in-foreground", - WebGLCanLoseContextInForeground, - RelaxedAtomicBool, true + "dom.event.handling-user-input-time-limit", + dom_event_handling_user_input_time_limit, + uint32_t, 1000 ) +// Password protection VARCACHE_PREF( - Live, - "webgl.default-low-power", - WebGLDefaultLowPower, - RelaxedAtomicBool, false + "browser.safebrowsing.passwords.enabled", + browser_safebrowsing_passwords_enabled, + bool, false ) +// Malware protection VARCACHE_PREF( - Live, - "webgl.default-no-alpha", - WebGLDefaultNoAlpha, - RelaxedAtomicBool, false + "browser.safebrowsing.malware.enabled", + browser_safebrowsing_malware_enabled, + bool, true ) +// Phishing protection VARCACHE_PREF( - Live, - "webgl.disable-angle", - WebGLDisableANGLE, - RelaxedAtomicBool, false + "browser.safebrowsing.phishing.enabled", + browser_safebrowsing_phishing_enabled, + bool, true ) +// Blocked plugin content VARCACHE_PREF( - Live, - "webgl.disable-wgl", - WebGLDisableWGL, - RelaxedAtomicBool, false + "browser.safebrowsing.blockedURIs.enabled", + browser_safebrowsing_blockedURIs_enabled, + bool, true ) +// Maximum size for an array to store the safebrowsing prefixset. VARCACHE_PREF( - Live, - "webgl.disable-extensions", - WebGLDisableExtensions, - RelaxedAtomicBool, false + "browser.safebrowsing.prefixset_max_array_size", + browser_safebrowsing_prefixset_max_array_size, + RelaxedAtomicUint32, 512*1024 ) +// When this pref is enabled document loads with a mismatched +// Cross-Origin header will fail to load +VARCACHE_PREF("browser.tabs.remote.useCrossOriginPolicy", + browser_tabs_remote_useCrossOriginPolicy, + bool, false +) + +// Prevent system colors from being exposed to CSS or canvas. VARCACHE_PREF( - Live, - "webgl.dxgl.enabled", - WebGLDXGLEnabled, - RelaxedAtomicBool, false + "ui.use_standins_for_native_colors", + ui_use_standins_for_native_colors, + RelaxedAtomicBool, false ) +// Disable page loading activity cursor by default. VARCACHE_PREF( - Live, - "webgl.dxgl.needs-finish", - WebGLDXGLNeedsFinish, - RelaxedAtomicBool, false + "ui.use_activity_cursor", + ui_use_activity_cursor, + bool, false ) +//--------------------------------------------------------------------------- +// ChannelClassifier prefs +//--------------------------------------------------------------------------- VARCACHE_PREF( - Live, - "webgl.disable-fail-if-major-performance-caveat", - WebGLDisableFailIfMajorPerformanceCaveat, - RelaxedAtomicBool, false + "channelclassifier.allowlist_example", + channelclassifier_allowlist_example, + bool, false ) +//--------------------------------------------------------------------------- +// Security prefs +//--------------------------------------------------------------------------- + VARCACHE_PREF( - Live, - "webgl.disable-DOM-blit-uploads", - WebGLDisableDOMBlitUploads, - RelaxedAtomicBool, false + "security.csp.enable", + security_csp_enable, + bool, true ) + VARCACHE_PREF( - Live, - "webgl.disabled", - WebGLDisabled, - RelaxedAtomicBool, false + "security.csp.enableStrictDynamic", + security_csp_enableStrictDynamic, + bool, true ) VARCACHE_PREF( - Live, - "webgl.enable-draft-extensions", - WebGLDraftExtensionsEnabled, - RelaxedAtomicBool, false + "security.csp.reporting.script-sample.max-length", + security_csp_reporting_script_sample_max_length, + int32_t, 40 ) +//--------------------------------------------------------------------------- +// View source prefs +//--------------------------------------------------------------------------- + VARCACHE_PREF( - Live, - "webgl.enable-privileged-extensions", - WebGLPrivilegedExtensionsEnabled, - RelaxedAtomicBool, false + "view_source.editor.external", + view_source_editor_external, + bool, false ) +//--------------------------------------------------------------------------- +// DevTools prefs +//--------------------------------------------------------------------------- + VARCACHE_PREF( - Live, - "webgl.enable-surface-texture", - WebGLSurfaceTextureEnabled, + "devtools.enabled", + devtools_enabled, RelaxedAtomicBool, false ) +#ifdef MOZILLA_OFFICIAL +# define PREF_VALUE false +#else +# define PREF_VALUE true +#endif VARCACHE_PREF( - Live, - "webgl.enable-webgl2", - WebGL2Enabled, - RelaxedAtomicBool, true + "devtools.console.stdout.chrome", + devtools_console_stdout_chrome, + RelaxedAtomicBool, PREF_VALUE ) +#undef PREF_VALUE VARCACHE_PREF( - Live, - "webgl.force-enabled", - WebGLForceEnabled, + "devtools.console.stdout.content", + devtools_console_stdout_content, RelaxedAtomicBool, false ) -VARCACHE_PREF( - Once, - "webgl.force-layers-readback", - WebGLForceLayersReadback, - bool, false -) +//--------------------------------------------------------------------------- +// Feature-Policy prefs +//--------------------------------------------------------------------------- +#ifdef NIGHTLY_BUILD +# define PREF_VALUE true +#else +# define PREF_VALUE false +#endif +// This pref enables FeaturePolicy logic and the parsing of 'allow' attribute in +// HTMLIFrameElement objects. VARCACHE_PREF( - Live, - "webgl.force-index-validation", - WebGLForceIndexValidation, - RelaxedAtomicInt32, 0 + "dom.security.featurePolicy.enabled", + dom_security_featurePolicy_enabled, + bool, PREF_VALUE ) +// This pref enables the featurePolicy header support. VARCACHE_PREF( - Live, - "webgl.lose-context-on-memory-pressure", - WebGLLoseContextOnMemoryPressure, - RelaxedAtomicBool, false + "dom.security.featurePolicy.header.enabled", + dom_security_featurePolicy_header_enabled, + bool, PREF_VALUE ) +// Expose the 'policy' attribute in document and HTMLIFrameElement VARCACHE_PREF( - Live, - "webgl.max-contexts", - WebGLMaxContexts, - RelaxedAtomicUint32, 32 + "dom.security.featurePolicy.webidl.enabled", + dom_security_featurePolicy_webidl_enabled, + bool, PREF_VALUE ) +#undef PREF_VALUE + +//--------------------------------------------------------------------------- +// Plugins prefs +//--------------------------------------------------------------------------- VARCACHE_PREF( - Live, - "webgl.max-contexts-per-principal", - WebGLMaxContextsPerPrincipal, - RelaxedAtomicUint32, 16 + "plugins.flashBlock.enabled", + plugins_flashBlock_enabled, + bool, false ) VARCACHE_PREF( - Live, - "webgl.max-warnings-per-context", - WebGLMaxWarningsPerContext, - RelaxedAtomicUint32, 32 + "plugins.http_https_only", + plugins_http_https_only, + bool, true ) +//--------------------------------------------------------------------------- +// Reporting API +//--------------------------------------------------------------------------- + +#ifdef NIGHTLY_BUILD +# define PREF_VALUE true +#else +# define PREF_VALUE false +#endif VARCACHE_PREF( - Live, - "webgl.min_capability_mode", - WebGLMinCapabilityMode, - RelaxedAtomicBool, false + "dom.reporting.enabled", + dom_reporting_enabled, + RelaxedAtomicBool, PREF_VALUE ) +#undef PREF_VALUE VARCACHE_PREF( - Live, - "webgl.msaa-force", - WebGLForceMSAA, + "dom.reporting.testing.enabled", + dom_reporting_testing_enabled, RelaxedAtomicBool, false ) +#ifdef NIGHTLY_BUILD +# define PREF_VALUE true +#else +# define PREF_VALUE false +#endif VARCACHE_PREF( - Live, - "webgl.msaa-samples", - WebGLMsaaSamples, - RelaxedAtomicUint32, 4 + "dom.reporting.featurePolicy.enabled", + dom_reporting_featurePolicy_enabled, + RelaxedAtomicBool, PREF_VALUE ) +#undef PREF_VALUE VARCACHE_PREF( - Live, - "webgl.prefer-16bpp", - WebGLPrefer16bpp, + "dom.reporting.header.enabled", + dom_reporting_header_enabled, RelaxedAtomicBool, false ) +// In seconds. The timeout to remove not-active report-to endpoints. VARCACHE_PREF( - Live, - "webgl.allow-immediate-queries", - WebGLImmediateQueries, - RelaxedAtomicBool, false + "dom.reporting.cleanup.timeout", + dom_reporting_cleanup_timeout, + uint32_t, 3600 ) +// Any X seconds the reports are dispatched to endpoints. VARCACHE_PREF( - Live, - "webgl.allow-fb-invalidation", - WebGLFBInvalidation, - RelaxedAtomicBool, false + "dom.reporting.delivering.timeout", + dom_reporting_delivering_timeout, + uint32_t, 5 ) +// How many times the delivering of a report should be tried. +VARCACHE_PREF( + "dom.reporting.delivering.maxFailures", + dom_reporting_delivering_maxFailures, + uint32_t, 3 +) +// How many reports should be stored in the report queue before being delivered. VARCACHE_PREF( - Live, - "webgl.perf.max-warnings", - WebGLMaxPerfWarnings, - RelaxedAtomicInt32, 0 + "dom.reporting.delivering.maxReports", + dom_reporting_delivering_maxReports, + uint32_t, 100 ) +// In case Touch API is enabled, this pref controls whether to support +// ontouch* event handlers, document.createTouch, document.createTouchList and +// document.createEvent("TouchEvent"). +#ifdef ANDROID +# define PREF_VALUE true +#else +# define PREF_VALUE false +#endif VARCACHE_PREF( - Live, - "webgl.perf.max-acceptable-fb-status-invals", - WebGLMaxAcceptableFBStatusInvals, - RelaxedAtomicInt32, 0 + "dom.w3c_touch_events.legacy_apis.enabled", + dom_w3c_touch_events_legacy_apis_enabled, + bool, PREF_VALUE ) +#undef PREF_VALUE VARCACHE_PREF( - Live, - "webgl.perf.spew-frame-allocs", - WebGLSpewFrameAllocs, + "medium_high_event_queue.enabled", + medium_high_event_queue_enabled, RelaxedAtomicBool, true ) -//--------------------------------------------------------------------------- -// Prefs starting with "widget." -//--------------------------------------------------------------------------- +// Whether strict file origin policy is in effect. +VARCACHE_PREF( + "security.fileuri.strict_origin_policy", + security_fileuri_strict_origin_policy, + RelaxedAtomicBool, true +) +// Whether origin telemetry should be enabled +// NOTE: if telemetry.origin_telemetry_test_mode.enabled is enabled, this pref +// won't have any effect. VARCACHE_PREF( - Live, - "widget.window-transforms.disabled", - WindowTransformsDisabled, + "privacy.trackingprotection.origin_telemetry.enabled", + privacy_trackingprotection_origin_telemetry_enabled, RelaxedAtomicBool, false ) -//--------------------------------------------------------------------------- -// Prefs starting with "xul." -//--------------------------------------------------------------------------- - -// Pref to control whether arrow-panel animations are enabled or not. -// Transitions are currently disabled on Linux due to rendering issues on -// certain configurations. -#ifdef MOZ_WIDGET_GTK -#define PREF_VALUE false -#else -#define PREF_VALUE true -#endif +// Enable origin telemetry test mode or not +// NOTE: turning this on will override the +// privacy.trackingprotection.origin_telemetry.enabled pref. VARCACHE_PREF( - Live, - "xul.panel-animations.enabled", - xul_panel_animations_enabled, - bool, PREF_VALUE + "telemetry.origin_telemetry_test_mode.enabled", + telemetry_origin_telemetry_test_mode_enabled, + RelaxedAtomicBool, false ) -#undef PREF_VALUE //--------------------------------------------------------------------------- // End of prefs diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index bc699b5ee9336..2a951b8d5a23c 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -737,7 +737,7 @@ pref("apz.pinch_lock.mode", 1); pref("apz.pinch_lock.scoll_lock_threshold", "0.03125"); // 1/32 inches pref("apz.pinch_lock.span_breakout_threshold", "0.03125"); // 1/32 inches pref("apz.pinch_lock.span_lock_threshold", "0.03125"); // 1/32 inches -pref("apz.pinch_lock.buffer_max_age", 50); // milliseconds +pref("apz.pinch_lock.buffer_max_age", "50"); // milliseconds pref("apz.popups.enabled", false); pref("apz.relative-update.enabled", true); diff --git a/modules/libpref/test/gtest/CallbackAndVarCacheOrder.cpp b/modules/libpref/test/gtest/CallbackAndVarCacheOrder.cpp index 366f7dc8150c9..2168136fac232 100644 --- a/modules/libpref/test/gtest/CallbackAndVarCacheOrder.cpp +++ b/modules/libpref/test/gtest/CallbackAndVarCacheOrder.cpp @@ -94,11 +94,6 @@ void AddVarCacheFunc(float* aVar, const nsCString& aPrefName) { ASSERT_TRUE(NS_SUCCEEDED(rv)); } -void AddVarCacheFunc(std::atomic* aVar, const nsCString& aPrefName) { - nsresult rv = Preferences::AddAtomicFloatVarCache(aVar, aPrefName); - ASSERT_TRUE(NS_SUCCEEDED(rv)); -} - template void RunTest(const nsCString& aPrefName1, const nsCString& aPrefName2, T aValue1, T aValue2) { @@ -201,11 +196,4 @@ TEST(CallbackAndVarCacheOrder, Float) NS_LITERAL_CSTRING("test_pref.float.2"), -10.0f, 11.0f); } -TEST(CallbackAndVarCacheOrder, AtomicFloat) -{ - RunTest>( - NS_LITERAL_CSTRING("test_pref.atomic_float.1"), - NS_LITERAL_CSTRING("test_pref.atomic_float.2"), -12.0f, 13.0f); -} - } // namespace mozilla diff --git a/toolkit/content/aboutSupport.js b/toolkit/content/aboutSupport.js index 79762f87a0b67..f10100c10729e 100644 --- a/toolkit/content/aboutSupport.js +++ b/toolkit/content/aboutSupport.js @@ -557,7 +557,7 @@ var snapshotFormatters = { let features = []; for (let feature of featureLog.features) { // Only add interesting decisions - ones that were not automatic based on - // all.js/StaticPrefs defaults. + // all.js/gfxPrefs defaults. if (feature.log.length > 1 || feature.log[0].status != "available") { features.push(feature); } diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 9eca6d1941114..e07b7b89afe10 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -98,6 +98,7 @@ #include "nsAppShellCID.h" #include "mozilla/scache/StartupCache.h" #include "gfxPlatform.h" +#include "gfxPrefs.h" #include "mozilla/Unused.h" @@ -1832,6 +1833,10 @@ static ReturnAbortOnError ShowProfileManager( rv = xpcom.Initialize(); NS_ENSURE_SUCCESS(rv, rv); + // Initialize the graphics prefs, some of the paths need them before + // any other graphics is initialized (e.g., showing the profile chooser.) + gfxPrefs::GetSingleton(); + rv = xpcom.SetWindowCreator(aNative); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); diff --git a/toolkit/xre/nsX11ErrorHandler.h b/toolkit/xre/nsX11ErrorHandler.h index 6565c59262819..246ef061ca1c3 100644 --- a/toolkit/xre/nsX11ErrorHandler.h +++ b/toolkit/xre/nsX11ErrorHandler.h @@ -5,7 +5,6 @@ #ifdef MOZ_X11 # include -# include "X11UndefineNone.h" // Unset some macros defined by X.h included by Xlib.h /** * InstallX11ErrorHandler is not suitable for processes running with GTK3 as diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp index 78a012b234f02..7018658cb4e68 100644 --- a/toolkit/xre/nsXREDirProvider.cpp +++ b/toolkit/xre/nsXREDirProvider.cpp @@ -990,10 +990,6 @@ nsXREDirProvider::DoStartup() { if (policies) { policies->Observe(nullptr, "policies-startup", nullptr); } - - // We may have modified the existing preferences, it's time to complete - // setting up the Once StaticPreferences. - mozilla::Preferences::RefreshStaticPrefsValues(); } #if defined(MOZ_SANDBOX) && defined(XP_WIN) diff --git a/view/nsViewManager.cpp b/view/nsViewManager.cpp index 75afd92b3e6e0..8524ebadee76f 100644 --- a/view/nsViewManager.cpp +++ b/view/nsViewManager.cpp @@ -26,6 +26,7 @@ #include "nsLayoutUtils.h" #include "Layers.h" #include "gfxPlatform.h" +#include "gfxPrefs.h" /** XXX TODO XXX diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index 37908349d649e..1f0d64c901f3c 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -23,13 +23,12 @@ #include "nsXULAppAPI.h" #include "nsIXULAppInfo.h" #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/GPUProcessManager.h" #include "mozilla/gfx/Logging.h" #include "mozilla/gfx/gfxVars.h" #include "mozilla/layers/PaintThread.h" - +#include "gfxPrefs.h" #include "gfxPlatform.h" #include "gfxConfig.h" #include "DriverCrashGuard.h" @@ -589,6 +588,7 @@ GfxInfoBase::~GfxInfoBase() {} nsresult GfxInfoBase::Init() { InitGfxDriverInfoShutdownObserver(); + gfxPrefs::GetSingleton(); nsCOMPtr os = mozilla::services::GetObserverService(); if (os) { @@ -601,7 +601,7 @@ nsresult GfxInfoBase::Init() { NS_IMETHODIMP GfxInfoBase::GetFeatureStatus(int32_t aFeature, nsACString& aFailureId, int32_t* aStatus) { - int32_t blocklistAll = StaticPrefs::BlocklistAll(); + int32_t blocklistAll = gfxPrefs::BlocklistAll(); if (blocklistAll > 0) { gfxCriticalErrorOnce(gfxCriticalError::DefaultOptions(false)) << "Forcing blocklisting all features"; diff --git a/widget/WidgetEventImpl.cpp b/widget/WidgetEventImpl.cpp index 4ddf765b61945..34520b7413bcd 100644 --- a/widget/WidgetEventImpl.cpp +++ b/widget/WidgetEventImpl.cpp @@ -3,6 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "gfxPrefs.h" #include "mozilla/BasicEvents.h" #include "mozilla/ContentEvents.h" #include "mozilla/EventStateManager.h" @@ -10,7 +11,6 @@ #include "mozilla/MiscEvents.h" #include "mozilla/MouseEvents.h" #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/TextEvents.h" #include "mozilla/TouchEvents.h" #include "mozilla/dom/KeyboardEventBinding.h" @@ -656,12 +656,12 @@ bool WidgetMouseEvent::IsMiddleClickPasteEnabled() { /* static */ double WidgetWheelEvent::ComputeOverriddenDelta(double aDelta, bool aIsForVertical) { - if (!StaticPrefs::MouseWheelHasRootScrollDeltaOverride()) { + if (!gfxPrefs::MouseWheelHasRootScrollDeltaOverride()) { return aDelta; } int32_t intFactor = aIsForVertical - ? StaticPrefs::MouseWheelRootScrollVerticalFactor() - : StaticPrefs::MouseWheelRootScrollHorizontalFactor(); + ? gfxPrefs::MouseWheelRootScrollVerticalFactor() + : gfxPrefs::MouseWheelRootScrollHorizontalFactor(); // Making the scroll speed slower doesn't make sense. So, ignore odd factor // which is less than 1.0. if (intFactor <= 100) { diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index bb3d891da8eaa..3b17f16615a4e 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -83,6 +83,7 @@ #include "mozilla/webrender/WebRenderAPI.h" #include "mozilla/widget/CompositorWidget.h" #include "gfxUtils.h" +#include "gfxPrefs.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/BorrowedContext.h" #include "mozilla/gfx/MacIOSurface.h" @@ -92,7 +93,6 @@ #endif #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include @@ -3274,7 +3274,7 @@ - (void)setGLOpaque:(BOOL)aOpaque { // Make the context opaque for fullscreen (since it performs better), and transparent // for windowed (since we need it for rounded corners), but allow overriding // it to opaque for testing purposes, even if that breaks the rounded corners. - GLint opaque = aOpaque || StaticPrefs::CompositorGLContextOpaque(); + GLint opaque = aOpaque || gfxPrefs::CompositorGLContextOpaque(); [mGLContext setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity]; CGLUnlockContext((CGLContextObj)[mGLContext CGLContextObj]); } @@ -3560,7 +3560,7 @@ - (void)magnifyWithEvent:(NSEvent*)anEvent { } // FIXME: bug 1525793 -- this may need to handle zooming or not on a per-document basis. - if (StaticPrefs::APZAllowZooming()) { + if (gfxPrefs::APZAllowZooming()) { NSPoint locationInWindow = nsCocoaUtils::EventLocationForWindow(anEvent, [self window]); ScreenPoint position = ViewAs([self convertWindowCoordinatesRoundDown:locationInWindow], @@ -4377,7 +4377,7 @@ ScrollWheelInput wheelEvent( geckoChildDeathGrip->DispatchAPZWheelInputEvent(wheelEvent, false); } else { ScrollWheelInput::ScrollMode scrollMode = ScrollWheelInput::SCROLLMODE_INSTANT; - if (StaticPrefs::SmoothScrollEnabled() && StaticPrefs::WheelSmoothScrollEnabled()) { + if (gfxPrefs::SmoothScrollEnabled() && gfxPrefs::WheelSmoothScrollEnabled()) { scrollMode = ScrollWheelInput::SCROLLMODE_SMOOTH; } ScrollWheelInput wheelEvent(eventIntervalTime, eventTimeStamp, modifiers, scrollMode, diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm index 93f5642fc48da..ef514aaedad81 100644 --- a/widget/cocoa/nsCocoaWindow.mm +++ b/widget/cocoa/nsCocoaWindow.mm @@ -36,12 +36,12 @@ #include "VibrancyManager.h" #include "gfxPlatform.h" +#include "gfxPrefs.h" #include "qcms.h" #include "mozilla/AutoRestore.h" #include "mozilla/BasicEvents.h" #include "mozilla/Preferences.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/PresShell.h" #include @@ -2007,7 +2007,7 @@ static inline CGAffineTransform GfxMatrixToCGAffineTransform(const gfx::Matrix& return; } - if (StaticPrefs::WindowTransformsDisabled()) { + if (gfxPrefs::WindowTransformsDisabled()) { // CGSSetWindowTransform is a private API. In case calling it causes // problems either now or in the future, we'll want to have an easy kill // switch. So we allow disabling it with a pref. diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index b91f958105e52..f9a84dfd48ba6 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -48,10 +48,10 @@ #include "mozilla/Attributes.h" #include "mozilla/Unused.h" #include "nsContentUtils.h" +#include "gfxPrefs.h" #include "mozilla/gfx/2D.h" #include "mozilla/MouseEvents.h" #include "GLConsts.h" -#include "mozilla/StaticPrefs.h" #include "mozilla/Unused.h" #include "mozilla/IMEStateManager.h" #include "mozilla/VsyncDispatcher.h" @@ -823,7 +823,7 @@ bool nsBaseWidget::UseAPZ() { (WindowType() == eWindowType_toplevel || WindowType() == eWindowType_child || (WindowType() == eWindowType_popup && HasRemoteContent() && - StaticPrefs::APZPopupsEnabled()))); + gfxPrefs::APZPopupsEnabled()))); } bool nsBaseWidget::AllowWebRenderForThisWindow() { @@ -857,7 +857,7 @@ void nsBaseWidget::ConfigureAPZCTreeManager() { NewRunnableMethod("layers::IAPZCTreeManager::SetDPI", mAPZC, &IAPZCTreeManager::SetDPI, dpi)); - if (StaticPrefs::APZKeyboardEnabled()) { + if (gfxPrefs::APZKeyboardEnabled()) { KeyboardMap map = nsXBLWindowKeyHandler::CollectKeyboardShortcuts(); // On Android the main thread is not the controller thread APZThreadUtils::RunOnControllerThread(NewRunnableMethod( @@ -976,7 +976,7 @@ nsEventStatus nsBaseWidget::ProcessUntransformedAPZEvent( UniquePtr postLayerization; if (WidgetTouchEvent* touchEvent = aEvent->AsTouchEvent()) { if (touchEvent->mMessage == eTouchStart) { - if (StaticPrefs::TouchActionEnabled()) { + if (gfxPrefs::TouchActionEnabled()) { APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification( this, GetDocument(), *(original->AsTouchEvent()), aInputBlockId, mSetAllowedTouchBehaviorCallback); diff --git a/widget/nsXPLookAndFeel.cpp b/widget/nsXPLookAndFeel.cpp index 1d4df74417093..479b673d08d9c 100644 --- a/widget/nsXPLookAndFeel.cpp +++ b/widget/nsXPLookAndFeel.cpp @@ -19,7 +19,7 @@ #include "mozilla/widget/WidgetMessageUtils.h" #include "gfxPlatform.h" - +#include "gfxPrefs.h" #include "qcms.h" #ifdef DEBUG @@ -881,6 +881,10 @@ nsresult nsXPLookAndFeel::GetColorImpl(ColorID aID, if (sUseNativeColors && NS_SUCCEEDED(NativeGetColor(aID, aResult))) { if (!mozilla::ServoStyleSet::IsInServoTraversal()) { MOZ_ASSERT(NS_IsMainThread()); + // Make sure the preferences are initialized. In the normal run, + // they would already be, because gfxPlatform would have been created, + // but with some addon, that is not the case. See Bug 1357307. + gfxPrefs::GetSingleton(); if ((gfxPlatform::GetCMSMode() == eCMSMode_All) && !IsSpecialColor(aID, aResult)) { qcms_transform* transform = gfxPlatform::GetCMSInverseRGBTransform(); diff --git a/widget/windows/WinCompositorWidget.cpp b/widget/windows/WinCompositorWidget.cpp index 72d9e26b17a94..74d63572e1183 100644 --- a/widget/windows/WinCompositorWidget.cpp +++ b/widget/windows/WinCompositorWidget.cpp @@ -4,7 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "WinCompositorWidget.h" - +#include "gfxPrefs.h" #include "mozilla/gfx/DeviceManagerDx.h" #include "mozilla/gfx/Point.h" #include "mozilla/layers/Compositor.h" @@ -37,7 +37,7 @@ WinCompositorWidget::WinCompositorWidget( // mNotDeferEndRemoteDrawing is set on the main thread during init, // but is only accessed after on the compositor thread. - mNotDeferEndRemoteDrawing = StaticPrefs::LayersCompositionFrameRate() == 0 || + mNotDeferEndRemoteDrawing = gfxPrefs::LayersCompositionFrameRate() == 0 || gfxPlatform::IsInLayoutAsapMode() || gfxPlatform::ForceSoftwareVsync(); } diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index f2521cc0e26ca..a17af3063fda4 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -57,7 +57,7 @@ #include "gfx2DGlue.h" #include "gfxEnv.h" #include "gfxPlatform.h" - +#include "gfxPrefs.h" #include "mozilla/AutoRestore.h" #include "mozilla/Logging.h" #include "mozilla/MathAlgorithms.h" @@ -4195,7 +4195,7 @@ bool nsWindow::DispatchMouseEvent(EventMessage aEventMessage, WPARAM wParam, // Messages should be only at topLevel window. && nsWindowType::eWindowType_toplevel == mWindowType // Currently this scheme is used only when pointer events is enabled. - && StaticPrefs::PointerEventsEnabled() && InkCollector::sInkCollector) { + && gfxPrefs::PointerEventsEnabled() && InkCollector::sInkCollector) { InkCollector::sInkCollector->SetTarget(mWnd); InkCollector::sInkCollector->SetPointerId(pointerId); } diff --git a/widget/windows/nsWindowBase.cpp b/widget/windows/nsWindowBase.cpp index ed8774caebdd3..a28bbc1112173 100644 --- a/widget/windows/nsWindowBase.cpp +++ b/widget/windows/nsWindowBase.cpp @@ -5,6 +5,7 @@ #include "nsWindowBase.h" +#include "gfxPrefs.h" #include "mozilla/MiscEvents.h" #include "mozilla/PresShell.h" #include "KeyboardLayout.h" @@ -133,7 +134,7 @@ nsresult nsWindowBase::SynthesizeNativeTouchPoint( uint32_t aPointerOrientation, nsIObserver* aObserver) { AutoObserverNotifier notifier(aObserver, "touchpoint"); - if (StaticPrefs::APZTestFailsWithNativeInjection() || !InitTouchInjection()) { + if (gfxPrefs::APZTestFailsWithNativeInjection() || !InitTouchInjection()) { // If we don't have touch injection from the OS, or if we are running a test // that cannot properly inject events to satisfy the OS requirements (see // bug 1313170) we can just fake it and synthesize the events from here. diff --git a/xpcom/threads/PrioritizedEventQueue.cpp b/xpcom/threads/PrioritizedEventQueue.cpp index 05d58be51fc6b..6a75c17615b14 100644 --- a/xpcom/threads/PrioritizedEventQueue.cpp +++ b/xpcom/threads/PrioritizedEventQueue.cpp @@ -26,7 +26,7 @@ void PrioritizedEventQueue::PutEvent( mInputQueueState == STATE_DISABLED) { priority = EventQueuePriority::Normal; } else if (priority == EventQueuePriority::MediumHigh && - !StaticPrefs::threads_medium_high_event_queue_enabled()) { + !StaticPrefs::medium_high_event_queue_enabled()) { priority = EventQueuePriority::Normal; }