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
This commit is contained in:
John Elliot V 2020-02-20 14:16:50 +00:00
parent 8308badf1c
commit ac48f9b971
2 changed files with 19 additions and 3 deletions

View File

@ -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)
#---------------------------------------------------------------------------

View File

@ -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: ");