Clean up StaticPrefList.yaml
Categories
(Core :: Preferences: Backend, task, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox70 | --- | fixed |
People
(Reporter: n.nethercote, Assigned: KrisWright)
Details
Attachments
(3 files)
There are several cleanups that could be done for modules/libpref/init/StaticPrefList.yaml, to make it shorter and easier to read.
First, this pattern occurs a lot:
#ifdef RELEASE_OR_BETA
#define PREF_VALUE false
#else
#define PREF_VALUE true
#endif
- name: dom.animations-api.timelines.enabled
type: bool
value: @PREF_VALUE@
mirror: always
#undef PREF_VALUE
It can be shortened to the following, using the NOT_IN_RELEASE_OR_BETA_VALUE
constant defined near the top of the file:
- name: dom.animations-api.timelines.enabled
type: bool
value: @NOT_IN_RELEASE_OR_BETA_VALUE@
mirror: always
Second, a couple more constants could be created that are similar to NOT_IN_RELEASE_OR_BETA_VALUE
:
#ifdef NIGHTLY_BUILD
tests could be replaced with a newNIGHTLY_BUILD_VALUE
constant.#ifdef MOZILLA_OFFICIAL
tests could be replaced with a newMOZILLA_OFFICIAL_VALUE
constant.
Third, lots of prefs involve a PREF_VALUE
constant, like this:
#if !defined(ANDROID) && !defined(XP_MACOSX) && defined(XP_UNIX)
#define PREF_VALUE true
#else
#define PREF_VALUE false
#endif
- name: clipboard.autocopy
type: bool
value: @PREF_VALUE@
mirror: always
#undef PREF_VALUE
These can be streamlined to this:
- name: clipboard.autocopy
type: bool
#if !defined(ANDROID) && !defined(XP_MACOSX) && defined(XP_UNIX)
value: true
#else
value: false
#endif
mirror: always
(The use of PREF_VALUE
is because MSVC couldn't handle the #ifdef
s within the pref definition back when they were in a .h file, but that's not relevant any more.)
These three changes would be best done in three (or more) patches.
Assignee | ||
Comment 1•5 years ago
|
||
Updated repetitive #ifdef RELEASE_OR_BETA pattern to use the existing constant at the top of the file.
Assignee | ||
Comment 2•5 years ago
|
||
Patterns which commonly recur in StaticPrefList.yaml, such as #ifdef NIGHTLY_BUILD, have constants defined at the top and used instead
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 3•5 years ago
|
||
Streamlined ifdefs by removing the remaining instances of PREF_VALUE. Some prefs had nested ifdefs that could be unfolded, and some had some repetitive logic that could be removed.
Pushed by kwright@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/fe115a13286b 1. Use existing NOT_IN_RELEASE_OR_BETA_VALUE instead of creating a PREF_VALUE r=njn https://hg.mozilla.org/integration/autoland/rev/92495e70e654 2. Expand on constants for commonly-recurring patterns in StaticPrefs r=njn https://hg.mozilla.org/integration/autoland/rev/4c81a7d21279 3. Clean up instances of PREF_VALUE, streamline ifdefs r=njn
Reporter | ||
Comment 5•5 years ago
|
||
Thanks, Kris!
Comment 6•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/fe115a13286b
https://hg.mozilla.org/mozilla-central/rev/92495e70e654
https://hg.mozilla.org/mozilla-central/rev/4c81a7d21279
Description
•