Closed Bug 1567063 Opened 5 years ago Closed 5 years ago

Clean up StaticPrefList.yaml

Categories

(Core :: Preferences: Backend, task, P3)

task

Tracking

()

RESOLVED FIXED
mozilla70
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 new NIGHTLY_BUILD_VALUE constant.
  • #ifdef MOZILLA_OFFICIAL tests could be replaced with a new MOZILLA_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 #ifdefs 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.

Updated repetitive #ifdef RELEASE_OR_BETA pattern to use the existing constant at the top of the file.

Patterns which commonly recur in StaticPrefList.yaml, such as #ifdef NIGHTLY_BUILD, have constants defined at the top and used instead

Assignee: nobody → kwright

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

Thanks, Kris!

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: