Skip to main content

style/
prefs.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5//! Macro helpers to get preference values.
6
7/// Returns the value of a preference exposed to the style crate.
8/// It allows overriding the result for either Gecko or Servo, which is
9/// useful when the preference only exists for one of them.
10#[macro_export]
11#[cfg(feature = "gecko")]
12macro_rules! pref {
13    ($string:tt $(, servo = $_:tt)?) => {
14        static_prefs::pref!($string)
15    };
16    ($string:tt, gecko = $value:tt) => {
17        $value
18    };
19}
20
21/// Returns the value of a preference exposed to the style crate.
22/// It allows overriding the result for either Gecko or Servo, which is
23/// useful when the preference only exists for one of them.
24#[macro_export]
25#[cfg(feature = "servo")]
26macro_rules! pref {
27    ($string:tt $(, gecko = $_:tt)?) => {
28        static_prefs::pref!($string)
29    };
30    ($string:tt, servo = $value:tt) => {
31        $value
32    };
33}