From ac48f9b97148329f79c0cae928635de798ee0d69 Mon Sep 17 00:00:00 2001 From: John Elliot V Date: Thu, 20 Feb 2020 14:16:50 +0000 Subject: [PATCH] Bug 1610402 - Use static prefs for view_source.{wrap_long_lines,syntax_highlight,tab_size} r=emilio Differential Revision: https://phabricator.services.mozilla.com/D63470 --HG-- extra : moz-landing-system : lando --- modules/libpref/init/StaticPrefList.yaml | 15 +++++++++++++++ parser/html/nsHtml5ViewSourceUtils.cpp | 7 ++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index f48c4844234d..16e488d5275b 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -8130,6 +8130,21 @@ value: false mirror: always +- name: view_source.wrap_long_lines + type: bool + value: true + mirror: always + +- name: view_source.syntax_highlight + type: bool + value: true + mirror: always + +- name: view_source.tab_size + type: int32_t + value: 4 + mirror: always + #--------------------------------------------------------------------------- # Prefs starting with "webgl." (for pref access from Worker threads) #--------------------------------------------------------------------------- diff --git a/parser/html/nsHtml5ViewSourceUtils.cpp b/parser/html/nsHtml5ViewSourceUtils.cpp index 179222156463..2ea8f7e3eb20 100644 --- a/parser/html/nsHtml5ViewSourceUtils.cpp +++ b/parser/html/nsHtml5ViewSourceUtils.cpp @@ -6,6 +6,7 @@ #include "mozilla/Preferences.h" #include "nsHtml5AttributeName.h" #include "nsHtml5String.h" +#include "mozilla/StaticPrefs_view_source.h" // static nsHtml5HtmlAttributes* nsHtml5ViewSourceUtils::NewBodyAttributes() { @@ -14,10 +15,10 @@ nsHtml5HtmlAttributes* nsHtml5ViewSourceUtils::NewBodyAttributes() { bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id, -1); nsString klass; - if (mozilla::Preferences::GetBool("view_source.wrap_long_lines", true)) { + if (StaticPrefs::view_source_wrap_long_lines()) { klass.AppendLiteral(u"wrap "); } - if (mozilla::Preferences::GetBool("view_source.syntax_highlight", true)) { + if (StaticPrefs::view_source_syntax_highlight()) { klass.AppendLiteral(u"highlight"); } if (!klass.IsEmpty()) { @@ -25,7 +26,7 @@ nsHtml5HtmlAttributes* nsHtml5ViewSourceUtils::NewBodyAttributes() { nsHtml5String::FromString(klass), -1); } - int32_t tabSize = mozilla::Preferences::GetInt("view_source.tab_size", 4); + int32_t tabSize = StaticPrefs::view_source_tab_size(); if (tabSize > 0) { nsString style; style.AssignLiteral("-moz-tab-size: ");