Make preference system more robust#314
Merged
Loirooriol merged 1 commit intoservo:mainfrom Mar 3, 2026
Merged
Conversation
This makes the `stylo_static_prefs` crate more robust. In particular, the `set_bool()` and `set_i32()` functions are removed, in favor of a new `set_pref!()` macro. This macro ensures (at compile time) that the preference being set actually exists, and that the provided value has the correct type. That will be useful for embedders of Stylo, since they will now detect accidental typos, or if e.g. a Stylo upgrade renamed or removed a pref that they are setting. This is not hypothetical: both Servo and Blitz are currently setting 2 preferences which no longer exist. For consistency, this removes `get_bool()` and `get_i32()` too, in favor of the `pref!()` macro. And `default_value!()` no longer defaults to false, in order to be able to tell whether the preference exists. It's still possible to get or set preferences without using the macros, by using the `Preference` trait (renamed from `Getter`, since now it can also set). But it's discouraged. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
8755641 to
2734500
Compare
mrobinson
approved these changes
Mar 3, 2026
github-merge-queue Bot
pushed a commit
to servo/servo
that referenced
this pull request
Mar 3, 2026
Bumps Stylo to servo/stylo#314 In particular, we would now get a compile error because we were setting `layout.flexbox.enabled` and `layout.css.transition-behavior.enabled`, even if Stylo removed at some point. So stop setting them. Testing: Not needed, no behavior change Signed-off-by: Oriol Brufau <obrufau@igalia.com>
minghuaw
pushed a commit
to minghuaw/stylo
that referenced
this pull request
Mar 5, 2026
This makes the `stylo_static_prefs` crate more robust. In particular, the `set_bool()` and `set_i32()` functions are removed, in favor of a new `set_pref!()` macro. This macro ensures (at compile time) that the preference being set actually exists, and that the provided value has the correct type. That will be useful for embedders of Stylo, since they will now detect accidental typos, or if e.g. a Stylo upgrade renamed or removed a pref that they are setting. This is not hypothetical: both Servo and Blitz are currently setting 2 preferences which no longer exist. For consistency, this removes `get_bool()` and `get_i32()` too, in favor of the `pref!()` macro. And `default_value!()` no longer defaults to false, in order to be able to tell whether the preference exists. It's still possible to get or set preferences without using the macros, by using the `Preference` trait (renamed from `Getter`, since now it can also set). But it's discouraged. Servo PR: servo/servo#42741 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Loirooriol
added a commit
that referenced
this pull request
Mar 5, 2026
This makes the `stylo_static_prefs` crate more robust. In particular, the `set_bool()` and `set_i32()` functions are removed, in favor of a new `set_pref!()` macro. This macro ensures (at compile time) that the preference being set actually exists, and that the provided value has the correct type. That will be useful for embedders of Stylo, since they will now detect accidental typos, or if e.g. a Stylo upgrade renamed or removed a pref that they are setting. This is not hypothetical: both Servo and Blitz are currently setting 2 preferences which no longer exist. For consistency, this removes `get_bool()` and `get_i32()` too, in favor of the `pref!()` macro. And `default_value!()` no longer defaults to false, in order to be able to tell whether the preference exists. It's still possible to get or set preferences without using the macros, by using the `Preference` trait (renamed from `Getter`, since now it can also set). But it's discouraged. Servo PR: servo/servo#42741 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
lando-worker Bot
pushed a commit
to mozilla-firefox/firefox
that referenced
this pull request
Mar 6, 2026
…reviewers,dshin This imports: - Allow the embedder to override all preferences servo/stylo#309 - Make preference system more robust servo/stylo#314 Differential Revision: https://phabricator.services.mozilla.com/D286392
github-actions Bot
pushed a commit
that referenced
this pull request
Mar 7, 2026
…reviewers,dshin This imports: - Allow the embedder to override all preferences #309 - Make preference system more robust #314 Differential Revision: https://phabricator.services.mozilla.com/D286392
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes the
stylo_static_prefscrate more robust. In particular, theset_bool()andset_i32()functions are removed, in favor of a newset_pref!()macro. This macro ensures (at compile time) that the preference being set actually exists, and that the provided value has the correct type.That will be useful for embedders of Stylo, since they will now detect accidental typos, or if e.g. a Stylo upgrade renamed or removed a pref that they are setting. This is not hypothetical: both Servo and Blitz are currently setting 2 preferences which no longer exist.
For consistency, this removes
get_bool()andget_i32()too, in favor of thepref!()macro. Anddefault_value!()no longer defaults to false, in order to be able to tell whether the preference exists.It's still possible to get or set preferences without using the macros, by using the
Preferencetrait (renamed fromGetter, since now it can also set). But it's discouraged.Servo PR: servo/servo#42741