mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Enable resetable and String prefs.
This allows both boolean and string-type preferences. It also implements a system where prefs that are read from a configuration file can be reset back to their initial value, which is useful in a number of cases e.g. when running tests to ensure that each test starts with the same values for the prefs.
This commit is contained in:
parent
d811f2d1ba
commit
79e548905e
10 changed files with 174 additions and 33 deletions
|
@ -477,7 +477,8 @@ pub mod longhands {
|
|||
% for value in values[:-1]:
|
||||
"${value}" => {
|
||||
% if value in experimental_values:
|
||||
if !::util::prefs::get_pref("layout.${value}.enabled").unwrap_or(false) {
|
||||
if !::util::prefs::get_pref("layout.${value}.enabled")
|
||||
.as_boolean().unwrap_or(false) {
|
||||
return Err(())
|
||||
}
|
||||
% endif
|
||||
|
@ -487,7 +488,8 @@ pub mod longhands {
|
|||
% for value in values[-1:]:
|
||||
"${value}" => {
|
||||
% if value in experimental_values:
|
||||
if !::util::prefs::get_pref("layout.${value}.enabled".unwrap_or(false) {
|
||||
if !::util::prefs::get_pref("layout.${value}.enabled")
|
||||
.as_boolean().unwrap_or(false) {
|
||||
return Err(())
|
||||
}
|
||||
% endif
|
||||
|
@ -5945,7 +5947,8 @@ impl PropertyDeclaration {
|
|||
% if property.derived_from is None:
|
||||
"${property.name}" => {
|
||||
% if property.experimental:
|
||||
if !::util::prefs::get_pref("${property.experimental}").unwrap_or(false) {
|
||||
if !::util::prefs::get_pref("${property.experimental}")
|
||||
.as_boolean().unwrap_or(false) {
|
||||
return PropertyDeclarationParseResult::ExperimentalProperty
|
||||
}
|
||||
% endif
|
||||
|
@ -5964,7 +5967,8 @@ impl PropertyDeclaration {
|
|||
% for shorthand in SHORTHANDS:
|
||||
"${shorthand.name}" => {
|
||||
% if shorthand.experimental:
|
||||
if !::util::prefs::get_pref("${shorthand.experimental}").unwrap_or(false) {
|
||||
if !::util::prefs::get_pref("${shorthand.experimental}")
|
||||
.as_boolean().unwrap_or(false) {
|
||||
return PropertyDeclarationParseResult::ExperimentalProperty
|
||||
}
|
||||
% endif
|
||||
|
|
|
@ -426,7 +426,7 @@ impl<'a, 'b> AtRuleParser for NestedRuleParser<'a, 'b> {
|
|||
Ok(AtRuleType::WithBlock(AtRulePrelude::FontFace))
|
||||
},
|
||||
"viewport" => {
|
||||
if ::util::prefs::get_pref("layout.viewport.enabled").unwrap_or(false) {
|
||||
if ::util::prefs::get_pref("layout.viewport.enabled").as_boolean().unwrap_or(false) {
|
||||
Ok(AtRuleType::WithBlock(AtRulePrelude::Viewport))
|
||||
} else {
|
||||
Err(())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue