Compare commits

...

15 Commits

Author SHA1 Message Date
Delan Azabani
669d1d57f5 Merge pull request #31409 from delan/style-config
style: Remove dependency on servo_config
2024-02-23 10:53:56 +08:00
Delan Azabani
b968157cb5 Add comments about logging and mapping new pref types 2024-02-23 10:49:33 +08:00
Delan Azabani
ffa68c0c58 Plumb default prefs into Stylo as well 2024-02-23 10:30:47 +08:00
Delan Azabani
21b6837a45 Remove stray dbg!() 2024-02-22 19:30:25 +08:00
Delan Azabani
4c728e8c25 Fix bug where getters acquire unnecessary write lock 2024-02-22 18:14:57 +08:00
Delan Azabani
6e01ad9b02 Add comment about avoiding clone 2024-02-22 17:55:48 +08:00
Delan Azabani
1e8d5d3df1 Add unit tests 2024-02-22 17:54:28 +08:00
Delan Azabani
da625aa614 Fix formatting 2024-02-22 17:40:17 +08:00
Delan Azabani
4f0990777b Clean up dependencies 2024-02-22 17:39:35 +08:00
Delan Azabani
279e28faaf Plumb servo prefs into stylo 2024-02-22 17:32:18 +08:00
Delan Azabani
46f2467767 Remove servo_config from tests/unit/style 2024-02-22 17:30:18 +08:00
Delan Azabani
81edc95c8c Remove servo_config from style 2024-02-22 17:30:15 +08:00
Delan Azabani
a4ff899aa8 Initial style_config crate 2024-02-22 17:30:13 +08:00
Delan Azabani
eda22944dc Do the minimum amount of formatting to appease mach test-tidy 2024-02-22 17:24:10 +08:00
Delan Azabani
be6057b910 Revert remaining changes from Stylo split-into-commits branch 2024-02-22 17:19:31 +08:00
24 changed files with 239 additions and 94 deletions

12
Cargo.lock generated
View File

@@ -3492,7 +3492,6 @@ dependencies = [
"cssparser",
"euclid",
"http",
"hyper_serde",
"indexmap 2.2.3",
"keyboard-types",
"selectors",
@@ -5411,6 +5410,7 @@ dependencies = [
"servo_config_plugins",
"servo_geometry",
"servo_url",
"style_config",
"url",
]
@@ -5796,12 +5796,12 @@ dependencies = [
"serde",
"servo_arc",
"servo_atoms",
"servo_config",
"smallbitvec",
"smallvec",
"static_assertions",
"static_prefs",
"string_cache",
"style_config",
"style_derive",
"style_traits",
"thin-vec",
@@ -5817,6 +5817,13 @@ dependencies = [
"walkdir",
]
[[package]]
name = "style_config"
version = "0.0.1"
dependencies = [
"lazy_static",
]
[[package]]
name = "style_derive"
version = "0.0.1"
@@ -5842,7 +5849,6 @@ dependencies = [
"serde_json",
"servo_arc",
"servo_atoms",
"servo_config",
"style",
"style_traits",
"url",

View File

@@ -95,6 +95,7 @@ smallvec = "1.13"
sparkle = "0.1.26"
string_cache = "0.8"
string_cache_codegen = "0.5"
style_config = { path = "components/style_config" }
style_traits = { path = "components/style_traits", features = ["servo"] }
# NOTE: the sm-angle feature only enables ANGLE on Windows, not other platforms!
surfman = { version = "0.9", features = ["chains", "sm-angle", "sm-angle-default"] }

View File

@@ -22,6 +22,7 @@ serde_json = { workspace = true }
servo_config_plugins = { path = "../config_plugins" }
servo_geometry = { path = "../geometry" }
servo_url = { path = "../url" }
style_config = { path = "../style_config" }
url = { workspace = true }
[target.'cfg(not(target_os = "android"))'.dependencies]

View File

@@ -4,10 +4,12 @@
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::convert::{TryFrom, TryInto};
use embedder_traits::resources::{self, Resource};
use gen::Prefs;
use lazy_static::lazy_static;
use log::warn;
use serde_json::{self, Value};
use crate::pref_util::Preferences;
@@ -17,7 +19,11 @@ lazy_static! {
static ref PREFS: Preferences<'static, Prefs> = {
let def_prefs: Prefs = serde_json::from_str(&resources::read_string(Resource::Preferences))
.expect("Failed to initialize config preferences.");
Preferences::new(def_prefs, &gen::PREF_ACCESSORS)
let result = Preferences::new(def_prefs, &gen::PREF_ACCESSORS);
for (key, value) in result.iter() {
set_stylo_pref_ref(&key, &value);
}
result
};
}
@@ -38,9 +44,11 @@ macro_rules! pref {
#[macro_export]
macro_rules! set_pref {
($($segment: ident).+, $value: expr) => {{
let value = $value;
$crate::prefs::set_stylo_pref(stringify!($($segment).+), value);
let values = $crate::prefs::pref_map().values();
let mut lock = values.write().unwrap();
lock$ (.$segment)+ = $value;
lock$ (.$segment)+ = value;
}};
}
@@ -56,11 +64,62 @@ pub fn pref_map() -> &'static Preferences<'static, Prefs> {
}
pub fn add_user_prefs(prefs: HashMap<String, PrefValue>) {
for (key, value) in prefs.iter() {
set_stylo_pref_ref(key, value);
}
if let Err(error) = PREFS.set_all(prefs.into_iter()) {
panic!("Error setting preference: {:?}", error);
}
}
pub fn set_stylo_pref(key: &str, value: impl Into<PrefValue>) {
set_stylo_pref_ref(key, &value.into());
}
fn set_stylo_pref_ref(key: &str, value: &PrefValue) {
match value.try_into() {
Ok(StyloPrefValue::Bool(value)) => style_config::set_bool(key, value),
Ok(StyloPrefValue::Int(value)) => style_config::set_i32(key, value),
Err(TryFromPrefValueError::IntegerOverflow(value)) => {
// TODO: logging doesnt actually work this early, so we should
// split PrefValue into i32 and i64 variants.
warn!("Pref value too big for Stylo: {} ({})", key, value);
},
Err(TryFromPrefValueError::UnmappedType) => {
// Most of Servos prefs will hit this. When adding a new pref type
// in Stylo, update TryFrom<&PrefValue> for StyloPrefValue as well.
},
}
}
enum StyloPrefValue {
Bool(bool),
Int(i32),
}
enum TryFromPrefValueError {
IntegerOverflow(i64),
UnmappedType,
}
impl TryFrom<&PrefValue> for StyloPrefValue {
type Error = TryFromPrefValueError;
fn try_from(value: &PrefValue) -> Result<Self, Self::Error> {
match value {
&PrefValue::Int(value) => {
if let Ok(value) = value.try_into() {
Ok(Self::Int(value))
} else {
Err(TryFromPrefValueError::IntegerOverflow(value))
}
},
&PrefValue::Bool(value) => Ok(Self::Bool(value)),
_ => Err(TryFromPrefValueError::UnmappedType),
}
}
}
pub fn read_prefs_map(txt: &str) -> Result<HashMap<String, PrefValue>, PrefError> {
let prefs: HashMap<String, Value> =
serde_json::from_str(txt).map_err(|e| PrefError::JsonParseErr(e))?;

View File

@@ -5,11 +5,11 @@
use darling::{FromDeriveInput, FromField, FromVariant};
use proc_macro2::{Span, TokenStream};
use quote::TokenStreamExt;
use syn::{
self, AngleBracketedGenericArguments, AssocType, DeriveInput, Field, GenericArgument,
GenericParam, Ident, Path, PathArguments, PathSegment, QSelf, Type, TypeArray, TypeGroup,
TypeParam, TypeParen, TypePath, TypeSlice, TypeTuple, Variant, WherePredicate,
};
use syn::{self, AngleBracketedGenericArguments, AssocType, DeriveInput, Field};
use syn::{GenericArgument, GenericParam, Ident, Path};
use syn::{PathArguments, PathSegment, QSelf, Type, TypeArray, TypeGroup};
use syn::{TypeParam, TypeParen, TypePath, TypeSlice, TypeTuple};
use syn::{Variant, WherePredicate};
use synstructure::{self, BindStyle, BindingInfo, VariantAst, VariantInfo};
/// Given an input type which has some where clauses already, like:

View File

@@ -0,0 +1 @@
disable_all_formatting = true

View File

@@ -14,7 +14,6 @@ servo = [
"content-security-policy",
"crossbeam-channel",
"http",
"hyper_serde",
"keyboard-types",
"serde",
"serde_bytes",
@@ -34,10 +33,9 @@ crossbeam-channel = { workspace = true, optional = true }
cssparser = { workspace = true }
euclid = { workspace = true }
http = { workspace = true, optional = true }
hyper_serde = { workspace = true, optional = true }
indexmap = { workspace = true }
keyboard-types = { workspace = true, optional = true }
selectors = { path = "../selectors", features = ["shmem"] }
selectors = { path = "../selectors" }
serde = { workspace = true, optional = true }
serde_bytes = { workspace = true, optional = true }
servo_arc = { path = "../servo_arc" }
@@ -46,7 +44,7 @@ smallvec = { workspace = true }
string_cache = { workspace = true, optional = true }
thin-vec = { workspace = true }
time = { workspace = true, optional = true }
tokio = { workspace = true }
tokio = { workspace = true, features = ["sync"] }
url = { workspace = true, optional = true }
uuid = { workspace = true, optional = true }
void = "1.0.2"

View File

@@ -81,24 +81,18 @@ extern crate webrender_api;
#[cfg(feature = "servo")]
extern crate xml5ever;
use std::hash::{BuildHasher, Hash};
use std::mem::size_of;
use std::ops::{Deref, DerefMut, Range};
use std::os::raw::c_void;
#[cfg(feature = "servo")]
use content_security_policy as csp;
#[cfg(feature = "servo")]
use serde_bytes::ByteBuf;
use std::hash::{BuildHasher, Hash};
use std::mem::size_of;
use std::ops::Range;
use std::ops::{Deref, DerefMut};
use std::os::raw::c_void;
#[cfg(feature = "servo")]
use uuid::Uuid;
use void::Void;
use webrender_api::{
BorderRadius, BorderStyle, BoxShadowClipMode, ColorF, ComplexClipRegion, ExtendMode,
ExternalScrollId, FilterOp, FontInstanceKey, GlyphInstance, GradientStop, ImageKey,
ImageRendering, LineStyle, MixBlendMode, NinePatchBorder, NormalBorder, RepeatMode,
StickyOffsetBounds, TransformStyle,
};
/// A C function that takes a pointer to a heap allocation and returns its size.
type VoidPtrToSizeFn = unsafe extern "C" fn(ptr: *const c_void) -> usize;
@@ -863,45 +857,45 @@ impl MallocSizeOf for url::Host {
}
}
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(BorderRadius);
malloc_size_of_is_0!(webrender_api::BorderRadius);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(BorderStyle);
malloc_size_of_is_0!(webrender_api::BorderStyle);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(BoxShadowClipMode);
malloc_size_of_is_0!(webrender_api::BoxShadowClipMode);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(ColorF);
malloc_size_of_is_0!(webrender_api::ColorF);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(ComplexClipRegion);
malloc_size_of_is_0!(webrender_api::ComplexClipRegion);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(ExtendMode);
malloc_size_of_is_0!(webrender_api::ExtendMode);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(FilterOp);
malloc_size_of_is_0!(webrender_api::FilterOp);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(ExternalScrollId);
malloc_size_of_is_0!(webrender_api::ExternalScrollId);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(FontInstanceKey);
malloc_size_of_is_0!(webrender_api::FontInstanceKey);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(GradientStop);
malloc_size_of_is_0!(webrender_api::GradientStop);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(GlyphInstance);
malloc_size_of_is_0!(webrender_api::GlyphInstance);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(NinePatchBorder);
malloc_size_of_is_0!(webrender_api::NinePatchBorder);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(ImageKey);
malloc_size_of_is_0!(webrender_api::ImageKey);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(ImageRendering);
malloc_size_of_is_0!(webrender_api::ImageRendering);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(LineStyle);
malloc_size_of_is_0!(webrender_api::LineStyle);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(MixBlendMode);
malloc_size_of_is_0!(webrender_api::MixBlendMode);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(NormalBorder);
malloc_size_of_is_0!(webrender_api::NormalBorder);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(RepeatMode);
malloc_size_of_is_0!(webrender_api::RepeatMode);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(StickyOffsetBounds);
malloc_size_of_is_0!(webrender_api::StickyOffsetBounds);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(TransformStyle);
malloc_size_of_is_0!(webrender_api::TransformStyle);
#[cfg(feature = "servo")]
impl MallocSizeOf for keyboard_types::Key {
@@ -934,18 +928,6 @@ malloc_size_of_is_0!(std::time::SystemTime);
#[cfg(feature = "servo")]
malloc_size_of_is_0!(std::time::Instant);
#[cfg(feature = "servo")]
impl<T> MallocSizeOf for hyper_serde::Serde<T>
where
for<'de> hyper_serde::De<T>: serde::Deserialize<'de>,
for<'a> hyper_serde::Ser<'a, T>: serde::Serialize,
T: MallocSizeOf,
{
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
self.0.size_of(ops)
}
}
// Placeholder for unique case where internals of Sender cannot be measured.
// malloc size of is 0 macro complains about type supplied!
#[cfg(feature = "servo")]

View File

@@ -87,7 +87,7 @@ ref_filter_map = "1.0.1"
regex = { workspace = true }
script_layout_interface = { workspace = true }
script_traits = { workspace = true }
selectors = { path = "../selectors", features = ["shmem"] }
selectors = { path = "../selectors" }
serde = { workspace = true, features = ["derive"] }
serde_bytes = { workspace = true }
servo-media = { git = "https://github.com/servo/media" }

View File

@@ -16,7 +16,6 @@ path = "lib.rs"
[features]
bench = []
shmem = ["dep:to_shmem", "dep:to_shmem_derive"]
[dependencies]
bitflags = "1.0"
@@ -30,8 +29,8 @@ precomputed-hash = "0.1"
servo_arc = { version = "0.2", path = "../servo_arc" }
size_of_test = { path = "../size_of_test" }
smallvec = "1.0"
to_shmem = { version = "0.0.1", path = "../to_shmem", optional = true }
to_shmem_derive = { version = "0.0.1", path = "../to_shmem_derive", optional = true }
to_shmem = { version = "0.0.1", path = "../to_shmem" }
to_shmem_derive = { version = "0.0.1", path = "../to_shmem_derive" }
[build-dependencies]
phf_codegen = "0.10"

View File

@@ -28,7 +28,7 @@ net_traits = { workspace = true }
profile_traits = { workspace = true }
range = { path = "../../range" }
script_traits = { workspace = true }
selectors = { path = "../../selectors", features = ["shmem"] }
selectors = { path = "../../selectors" }
servo_arc = { path = "../../servo_arc" }
servo_atoms = { path = "../../atoms" }
servo_url = { path = "../../url" }

View File

@@ -22,7 +22,6 @@ servo = [
"serde",
"style_traits/servo",
"servo_atoms",
"servo_config",
"html5ever",
"cssparser/serde",
"encoding_rs",
@@ -64,26 +63,26 @@ owning_ref = "0.4"
parking_lot = "0.12"
precomputed-hash = "0.1.1"
rayon = "1"
selectors = { path = "../selectors", features = ["shmem"] }
selectors = { path = "../selectors" }
serde = { version = "1.0", optional = true, features = ["derive"] }
servo_arc = { path = "../servo_arc" }
servo_atoms = { path = "../atoms", optional = true }
servo_config = { path = "../config", optional = true }
smallbitvec = "2.3.0"
smallvec = "1.0"
static_assertions = "1.1"
static_prefs = { path = "../style_static_prefs" }
string_cache = { version = "0.8", optional = true }
style_config = { path = "../style_config" }
style_derive = { path = "../style_derive" }
style_traits = { workspace = true }
style_traits = { path = "../style_traits" }
time = "0.1"
thin-vec = { workspace = true }
to_shmem = { path = "../to_shmem" }
to_shmem_derive = { path = "../to_shmem_derive" }
url = { workspace = true, optional = true, features = ["serde"] }
uluru = "3.0"
unicode-bidi = "0.3"
unicode-segmentation = "1.0"
url = { workspace = true, optional = true }
void = "1.0.2"
[build-dependencies]

View File

@@ -114,8 +114,7 @@ impl StyleThreadPool {
#[cfg(feature = "servo")]
fn stylo_threads_pref() -> i32 {
use servo_config::pref;
pref!(layout.threads) as i32
style_config::get_i32("layout.threads")
}
#[cfg(feature = "gecko")]

View File

@@ -14,7 +14,7 @@ use crate::{Atom, LocalName, Namespace, ShrinkIfNeeded};
use selectors::attr::NamespaceConstraint;
use selectors::parser::{Combinator, Component};
use selectors::parser::{Selector, SelectorIter};
use selectors::visitor::{SelectorVisitor, SelectorListKind};
use selectors::visitor::{SelectorListKind, SelectorVisitor};
use smallvec::SmallVec;
use style_traits::dom::{DocumentState, ElementState};

View File

@@ -27,10 +27,10 @@ ${helpers.single_keyword(
${helpers.single_keyword(
"list-style-type",
"""disc none circle square disclosure-open disclosure-closed
decimal lower-alpha upper-alpha arabic-indic bengali cambodian cjk-decimal devanagari
gujarati gurmukhi kannada khmer lao malayalam mongolian myanmar oriya persian telugu
thai tibetan cjk-earthly-branch cjk-heavenly-stem lower-greek hiragana hiragana-iroha
katakana katakana-iroha
decimal lower-alpha upper-alpha arabic-indic bengali cambodian cjk-decimal devanagari
gujarati gurmukhi kannada khmer lao malayalam mongolian myanmar oriya persian telugu
thai tibetan cjk-earthly-branch cjk-heavenly-stem lower-greek hiragana hiragana-iroha
katakana katakana-iroha
""",
engines="servo",
animation_value_type="discrete",

View File

@@ -32,7 +32,6 @@ use fxhash::FxHashMap;
use crate::media_queries::Device;
use crate::parser::ParserContext;
use crate::selector_parser::PseudoElement;
#[cfg(feature = "servo")] use servo_config::prefs;
use style_traits::{CssWriter, KeywordsCollectFn, ParseError, ParsingMode};
use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss};
use to_shmem::impl_trivial_to_shmem;
@@ -525,7 +524,7 @@ impl NonCustomPropertyId {
Some(pref) => pref,
};
prefs::pref_map().get(pref).as_bool().unwrap_or(false)
style_config::get_bool(pref)
% endif
};

View File

@@ -31,8 +31,7 @@ use crate::stylesheets::{
};
use crate::values::computed::font::FamilyName;
use crate::values::{CssUrl, CustomIdent, DashedIdent, KeyframesName};
use crate::Atom;
use crate::{Namespace, Prefix};
use crate::{Atom, Namespace, Prefix};
use cssparser::{
AtRuleParser, BasicParseError, BasicParseErrorKind, CowRcStr, DeclarationParser, Parser,
ParserState, QualifiedRuleParser, RuleBodyItemParser, RuleBodyParser, SourceLocation,

View File

@@ -27,10 +27,7 @@ fn flexbox_enabled() -> bool {
#[cfg(feature = "servo")]
fn flexbox_enabled() -> bool {
servo_config::prefs::pref_map()
.get("layout.flexbox.enabled")
.as_bool()
.unwrap_or(false)
style_config::get_bool("layout.flexbox.enabled")
}
/// Defines an elements display type, which consists of

View File

@@ -1591,7 +1591,7 @@ macro_rules! impl_variant_numeric {
} => {
bitflags! {
#[derive(MallocSizeOf, ToComputedValue, ToResolvedValue, ToShmem)]
/// Vairants of numeric values
/// Variants of numeric values
pub struct FontVariantNumeric: u8 {
/// None of other variants are enabled.
const NORMAL = 0;

View File

@@ -370,15 +370,9 @@ impl Side for VerticalPositionKeyword {
}
bitflags! {
/// Controls how the auto-placement algorithm works
/// specifying exactly how auto-placed items get flowed into the grid
#[derive(
MallocSizeOf,
SpecifiedValueInfo,
ToComputedValue,
ToResolvedValue,
ToShmem
)]
/// Controls how the auto-placement algorithm works specifying exactly how auto-placed items
/// get flowed into the grid.
#[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)]
#[value_info(other_values = "row,column,dense")]
#[repr(C)]
pub struct GridAutoFlow: u8 {

View File

@@ -0,0 +1,14 @@
[package]
name = "style_config"
version = "0.0.1"
authors = ["The Servo Project Developers"]
license = "MPL-2.0"
edition = "2021"
publish = false
[lib]
name = "style_config"
path = "lib.rs"
[dependencies]
lazy_static = { workspace = true }

View File

@@ -0,0 +1,97 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::collections::HashMap;
use std::sync::RwLock;
use lazy_static::lazy_static;
lazy_static! {
static ref PREFS: Preferences = Preferences::default();
}
#[derive(Debug, Default)]
pub struct Preferences {
// When adding a new pref type, be sure to update the TryFrom<&PrefValue> in
// servo_config, to plumb the values in from Servo.
bool_prefs: RwLock<HashMap<String, bool>>,
i32_prefs: RwLock<HashMap<String, i32>>,
}
impl Preferences {
pub fn get_bool(&self, key: &str) -> bool {
let prefs = self.bool_prefs.read().expect("RwLock is poisoned");
*prefs.get(key).unwrap_or(&false)
}
pub fn get_i32(&self, key: &str) -> i32 {
let prefs = self.i32_prefs.read().expect("RwLock is poisoned");
*prefs.get(key).unwrap_or(&0)
}
pub fn set_bool(&self, key: &str, value: bool) {
let mut prefs = self.bool_prefs.write().expect("RwLock is poisoned");
// Avoid cloning the key if it exists.
if let Some(pref) = prefs.get_mut(key) {
*pref = value;
} else {
prefs.insert(key.to_owned(), value);
}
}
pub fn set_i32(&self, key: &str, value: i32) {
let mut prefs = self.i32_prefs.write().expect("RwLock is poisoned");
// Avoid cloning the key if it exists.
if let Some(pref) = prefs.get_mut(key) {
*pref = value;
} else {
prefs.insert(key.to_owned(), value);
}
}
}
pub fn get_bool(key: &str) -> bool {
PREFS.get_bool(key)
}
pub fn get_i32(key: &str) -> i32 {
PREFS.get_i32(key)
}
pub fn set_bool(key: &str, value: bool) {
PREFS.set_bool(key, value)
}
pub fn set_i32(key: &str, value: i32) {
PREFS.set_i32(key, value)
}
#[test]
fn test() {
let mut prefs = Preferences::default();
// Prefs have default values when unset.
assert_eq!(prefs.get_bool("foo"), false);
assert_eq!(prefs.get_i32("bar"), 0);
// Prefs can be set and retrieved.
prefs.set_bool("foo", true);
prefs.set_i32("bar", 1);
assert_eq!(prefs.get_bool("foo"), true);
assert_eq!(prefs.get_i32("bar"), 1);
prefs.set_bool("foo", false);
prefs.set_i32("bar", 2);
assert_eq!(prefs.get_bool("foo"), false);
assert_eq!(prefs.get_i32("bar"), 2);
// Each value type currently has an independent namespace.
prefs.set_i32("foo", 3);
prefs.set_bool("bar", true);
assert_eq!(prefs.get_i32("foo"), 3);
assert_eq!(prefs.get_bool("foo"), false);
assert_eq!(prefs.get_bool("bar"), true);
assert_eq!(prefs.get_i32("bar"), 2);
}

View File

@@ -141,6 +141,7 @@ class MachCommands(CommandBase):
"servo_remutex",
"crown",
"constellation",
"style_config",
]
if not packages:
packages = set(os.listdir(path.join(self.context.topdir, "tests", "unit"))) - set(['.DS_Store'])

View File

@@ -16,10 +16,9 @@ euclid = { workspace = true }
html5ever = { workspace = true }
rayon = { workspace = true }
serde_json = { workspace = true }
selectors = {path = "../../../components/selectors", features = ["shmem"] }
selectors = {path = "../../../components/selectors" }
servo_arc = {path = "../../../components/servo_arc"}
servo_atoms = {path = "../../../components/atoms"}
servo_config = {path = "../../../components/config"}
style = {path = "../../../components/style", features = ["servo"]}
style_traits = {path = "../../../components/style_traits"}
url = { workspace = true }