Bug 1449064 - Convert view_source.editor.external to a StaticPref. r=hsivonen
MozReview-Commit-ID: EKVI5KAtXdJ
--- a/modules/libpref/init/StaticPrefList.h
+++ b/modules/libpref/init/StaticPrefList.h
@@ -898,12 +898,22 @@ VARCACHE_PREF(
//---------------------------------------------------------------------------
// Preferences prefs
//---------------------------------------------------------------------------
PREF("preferences.allow.omt-write", bool, true)
//---------------------------------------------------------------------------
+// View source prefs
+//---------------------------------------------------------------------------
+
+VARCACHE_PREF(
+ "view_source.editor.external",
+ view_source_editor_external,
+ bool, false
+)
+
+//---------------------------------------------------------------------------
// End of prefs
//---------------------------------------------------------------------------
// clang-format on
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1066,17 +1066,16 @@ pref("devtools.gcli.imgurClientID", '0df
pref("devtools.gcli.imgurUploadURL", "https://api.imgur.com/3/image");
// GCLI commands directory
pref("devtools.commands.dir", "");
// view source
pref("view_source.syntax_highlight", true);
pref("view_source.wrap_long_lines", false);
-pref("view_source.editor.external", false);
pref("view_source.editor.path", "");
// allows to add further arguments to the editor; use the %LINE% placeholder
// for jumping to a specific line (e.g. "/line:%LINE%" or "--goto %LINE%")
pref("view_source.editor.args", "");
// When true this will word-wrap plain text documents.
pref("plain_text.wrap_long_lines", false);
--- a/parser/html/nsHtml5TreeOpExecutor.cpp
+++ b/parser/html/nsHtml5TreeOpExecutor.cpp
@@ -8,16 +8,17 @@
#include "mozilla/Likely.h"
#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/nsCSPService.h"
#include "GeckoProfiler.h"
#include "mozAutoDocUpdate.h"
#include "mozilla/IdleTaskRunner.h"
#include "mozilla/Preferences.h"
+#include "mozilla/StaticPrefs.h"
#include "mozilla/css/Loader.h"
#include "nsContentUtils.h"
#include "nsError.h"
#include "nsHtml5AutoPauseUpdate.h"
#include "nsHtml5Parser.h"
#include "nsHtml5StreamParser.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
@@ -917,28 +918,20 @@ nsHtml5TreeOpExecutor::GetViewSourceBase
// Fail gracefully if the base URL isn't a view-source: URL.
// Not sure if this can ever happen.
mViewSourceBaseURI = orig;
}
}
return mViewSourceBaseURI;
}
-// static
-void
-nsHtml5TreeOpExecutor::InitializeStatics()
-{
- mozilla::Preferences::AddBoolVarCache(&sExternalViewSource,
- "view_source.editor.external");
-}
-
bool
nsHtml5TreeOpExecutor::IsExternalViewSource()
{
- if (!sExternalViewSource) {
+ if (!StaticPrefs::view_source_editor_external()) {
return false;
}
bool isViewSource = false;
if (mDocumentURI) {
mDocumentURI->SchemeIs("view-source", &isViewSource);
}
return isViewSource;
}
@@ -1187,9 +1180,8 @@ nsHtml5TreeOpExecutor::SetSpeculationRef
#ifdef DEBUG_NS_HTML5_TREE_OP_EXECUTOR_FLUSH
uint32_t nsHtml5TreeOpExecutor::sAppendBatchMaxSize = 0;
uint32_t nsHtml5TreeOpExecutor::sAppendBatchSlotsExamined = 0;
uint32_t nsHtml5TreeOpExecutor::sAppendBatchExaminations = 0;
uint32_t nsHtml5TreeOpExecutor::sLongestTimeOffTheEventLoop = 0;
uint32_t nsHtml5TreeOpExecutor::sTimesFlushLoopInterrupted = 0;
#endif
-bool nsHtml5TreeOpExecutor::sExternalViewSource = false;
--- a/parser/html/nsHtml5TreeOpExecutor.h
+++ b/parser/html/nsHtml5TreeOpExecutor.h
@@ -40,17 +40,16 @@ class nsHtml5TreeOpExecutor final
using Encoding = mozilla::Encoding;
template<typename T>
using NotNull = mozilla::NotNull<T>;
public:
NS_DECL_ISUPPORTS_INHERITED
private:
- static bool sExternalViewSource;
#ifdef DEBUG_NS_HTML5_TREE_OP_EXECUTOR_FLUSH
static uint32_t sAppendBatchMaxSize;
static uint32_t sAppendBatchSlotsExamined;
static uint32_t sAppendBatchExaminations;
static uint32_t sLongestTimeOffTheEventLoop;
static uint32_t sTimesFlushLoopInterrupted;
#endif
@@ -262,18 +261,16 @@ public:
void SetSpeculationReferrerPolicy(ReferrerPolicy aReferrerPolicy);
void SetSpeculationReferrerPolicy(const nsAString& aReferrerPolicy);
void AddSpeculationCSP(const nsAString& aCSP);
void AddBase(const nsAString& aURL);
- static void InitializeStatics();
-
private:
nsHtml5Parser* GetParser();
bool IsExternalViewSource();
/**
* Get a nsIURI for an nsString if the URL hasn't been preloaded yet.
*/