mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Refactor util::prefs
operations to be methods on static struct.
This commit is contained in:
parent
307844a8c1
commit
22928f50ac
30 changed files with 166 additions and 162 deletions
|
@ -2250,7 +2250,7 @@ class CGConstructorEnabled(CGAbstractMethod):
|
|||
pref = iface.getExtendedAttribute("Pref")
|
||||
if pref:
|
||||
assert isinstance(pref, list) and len(pref) == 1
|
||||
conditions.append('prefs::get_pref("%s").as_boolean().unwrap_or(false)' % pref[0])
|
||||
conditions.append('PREFS.get("%s").as_boolean().unwrap_or(false)' % pref[0])
|
||||
func = iface.getExtendedAttribute("Func")
|
||||
if func:
|
||||
assert isinstance(func, list) and len(func) == 1
|
||||
|
@ -5605,7 +5605,7 @@ class CGBindingRoot(CGThing):
|
|||
'dom::browsingcontext::BrowsingContext',
|
||||
'mem::heap_size_of_raw_self_and_children',
|
||||
'libc',
|
||||
'util::prefs',
|
||||
'util::prefs::PREFS',
|
||||
'script_runtime::{store_panic_result, maybe_take_panic_result}',
|
||||
'std::borrow::ToOwned',
|
||||
'std::cmp',
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//! Machinery to conditionally expose things.
|
||||
|
||||
use js::jsapi::{HandleObject, JSContext};
|
||||
use util::prefs::get_pref;
|
||||
use util::prefs::PREFS;
|
||||
|
||||
/// A container with a condition.
|
||||
pub struct Guard<T: Clone + Copy> {
|
||||
|
@ -47,7 +47,7 @@ pub enum Condition {
|
|||
impl Condition {
|
||||
unsafe fn is_satisfied(&self, cx: *mut JSContext, obj: HandleObject) -> bool {
|
||||
match *self {
|
||||
Condition::Pref(name) => get_pref(name).as_boolean().unwrap_or(false),
|
||||
Condition::Pref(name) => PREFS.get(name).as_boolean().unwrap_or(false),
|
||||
Condition::Func(f) => f(cx, obj),
|
||||
Condition::Satisfied => true,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue