mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +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,
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ use style::servo::Stylesheet;
|
|||
use time;
|
||||
use url::Url;
|
||||
use url::percent_encoding::percent_decode;
|
||||
use util::prefs::mozbrowser_enabled;
|
||||
use util::prefs::PREFS;
|
||||
use util::str::{split_html_space_chars, str_join};
|
||||
|
||||
#[derive(JSTraceable, PartialEq, HeapSizeOf)]
|
||||
|
@ -1262,7 +1262,7 @@ impl Document {
|
|||
}
|
||||
|
||||
pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
|
||||
if mozbrowser_enabled() {
|
||||
if PREFS.is_mozbrowser_enabled() {
|
||||
if let Some((containing_pipeline_id, subpage_id, _)) = self.window.parent_info() {
|
||||
let event = ConstellationMsg::MozBrowserEvent(containing_pipeline_id,
|
||||
subpage_id,
|
||||
|
|
|
@ -29,7 +29,7 @@ use std::default::Default;
|
|||
use string_cache::Atom;
|
||||
use style::attr::AttrValue;
|
||||
use url::Url;
|
||||
use util::prefs::mozbrowser_enabled;
|
||||
use util::prefs::PREFS;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct HTMLAnchorElement {
|
||||
|
@ -575,7 +575,7 @@ fn follow_hyperlink(subject: &Element, hyperlink_suffix: Option<String>) {
|
|||
|
||||
// Step 8: navigate to the URL.
|
||||
if let Some(target) = target {
|
||||
if mozbrowser_enabled() && !is_current_browsing_context(target.Value()) {
|
||||
if PREFS.is_mozbrowser_enabled() && !is_current_browsing_context(target.Value()) {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowseropenwindow
|
||||
// TODO: referrer and opener
|
||||
// TODO: should we send the normalized url or the non-normalized href?
|
||||
|
|
|
@ -48,7 +48,7 @@ use string_cache::Atom;
|
|||
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
|
||||
use style::context::ReflowGoal;
|
||||
use url::Url;
|
||||
use util::prefs::mozbrowser_enabled;
|
||||
use util::prefs::PREFS;
|
||||
use util::servo_version;
|
||||
|
||||
bitflags! {
|
||||
|
@ -145,7 +145,7 @@ impl HTMLIFrameElement {
|
|||
.send(ConstellationMsg::ScriptLoadedURLInIFrame(load_info))
|
||||
.unwrap();
|
||||
|
||||
if mozbrowser_enabled() {
|
||||
if PREFS.is_mozbrowser_enabled() {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadstart
|
||||
self.dispatch_mozbrowser_event(MozBrowserEvent::LoadStart);
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ impl HTMLIFrameElement {
|
|||
// TODO(gw): Support mozbrowser event types that have detail which is not a string.
|
||||
// See https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API
|
||||
// for a list of mozbrowser events.
|
||||
assert!(mozbrowser_enabled());
|
||||
assert!(PREFS.is_mozbrowser_enabled());
|
||||
|
||||
if self.Mozbrowser() {
|
||||
let window = window_from_node(self);
|
||||
|
|
|
@ -70,7 +70,7 @@ impl HTMLMetaElement {
|
|||
}
|
||||
|
||||
fn apply_viewport(&self) {
|
||||
if !::util::prefs::get_pref("layout.viewport.enabled").as_boolean().unwrap_or(false) {
|
||||
if !::util::prefs::PREFS.get("layout.viewport.enabled").as_boolean().unwrap_or(false) {
|
||||
return;
|
||||
}
|
||||
let element = self.upcast::<Element>();
|
||||
|
|
|
@ -17,7 +17,7 @@ use dom::uievent::UIEvent;
|
|||
use dom::window::Window;
|
||||
use std::cell::Cell;
|
||||
use std::default::Default;
|
||||
use util::prefs;
|
||||
use util::prefs::PREFS;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct MouseEvent {
|
||||
|
@ -157,7 +157,7 @@ impl MouseEventMethods for MouseEvent {
|
|||
// This returns the same result as current gecko.
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which
|
||||
fn Which(&self) -> i32 {
|
||||
if prefs::get_pref("dom.mouseevent.which.enabled").as_boolean().unwrap_or(false) {
|
||||
if PREFS.get("dom.mouseevent.which.enabled").as_boolean().unwrap_or(false) {
|
||||
(self.button.get() + 1) as i32
|
||||
} else {
|
||||
0
|
||||
|
|
|
@ -37,7 +37,7 @@ use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
|
|||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Instant;
|
||||
use url::Url;
|
||||
use util::prefs;
|
||||
use util::prefs::PREFS;
|
||||
use util::thread::spawn_named;
|
||||
use util::thread_state;
|
||||
use util::thread_state::{IN_WORKER, SCRIPT};
|
||||
|
@ -225,7 +225,7 @@ impl ServiceWorkerGlobalScope {
|
|||
scope.mem_profiler_chan().run_with_memory_reporting(|| {
|
||||
// Service workers are time limited
|
||||
let sw_lifetime = Instant::now();
|
||||
let sw_lifetime_timeout = prefs::get_pref("dom.serviceworker.timeout_seconds").as_u64().unwrap();
|
||||
let sw_lifetime_timeout = PREFS.get("dom.serviceworker.timeout_seconds").as_u64().unwrap();
|
||||
while let Ok(event) = global.receive_event() {
|
||||
if scope.is_closing() {
|
||||
break;
|
||||
|
|
|
@ -29,7 +29,7 @@ use js::jsval::{JSVal, NullValue};
|
|||
use std::borrow::ToOwned;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use util::prefs::get_pref;
|
||||
use util::prefs::PREFS;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct TestBinding {
|
||||
|
@ -558,10 +558,10 @@ impl TestBindingMethods for TestBinding {
|
|||
fn PassVariadicAny(&self, _: *mut JSContext, _: Vec<HandleValue>) {}
|
||||
fn PassVariadicObject(&self, _: *mut JSContext, _: Vec<*mut JSObject>) {}
|
||||
fn BooleanMozPreference(&self, pref_name: DOMString) -> bool {
|
||||
get_pref(pref_name.as_ref()).as_boolean().unwrap_or(false)
|
||||
PREFS.get(pref_name.as_ref()).as_boolean().unwrap_or(false)
|
||||
}
|
||||
fn StringMozPreference(&self, pref_name: DOMString) -> DOMString {
|
||||
get_pref(pref_name.as_ref()).as_string().map(|s| DOMString::from(s)).unwrap_or_else(|| DOMString::new())
|
||||
PREFS.get(pref_name.as_ref()).as_string().map(|s| DOMString::from(s)).unwrap_or_else(|| DOMString::new())
|
||||
}
|
||||
fn PrefControlledAttributeDisabled(&self) -> bool { false }
|
||||
fn PrefControlledAttributeEnabled(&self) -> bool { false }
|
||||
|
|
|
@ -96,7 +96,7 @@ use timers::{IsInterval, OneshotTimerCallback, OneshotTimerHandle, OneshotTimers
|
|||
use tinyfiledialogs::{self, MessageBoxIcon};
|
||||
use url::Url;
|
||||
use util::geometry::{self, MAX_RECT};
|
||||
use util::prefs::mozbrowser_enabled;
|
||||
use util::prefs::PREFS;
|
||||
use util::str::HTML_SPACE_CHARACTERS;
|
||||
use util::{breakpoint, opts};
|
||||
use webdriver_handlers::jsval_to_webdriver;
|
||||
|
@ -1581,7 +1581,7 @@ impl Window {
|
|||
|
||||
/// Returns whether this window is mozbrowser.
|
||||
pub fn is_mozbrowser(&self) -> bool {
|
||||
mozbrowser_enabled() && self.parent_info().is_none()
|
||||
PREFS.is_mozbrowser_enabled() && self.parent_info().is_none()
|
||||
}
|
||||
|
||||
/// Returns whether mozbrowser is enabled and `obj` has been created
|
||||
|
@ -1757,4 +1757,3 @@ fn debug_reflow_events(id: PipelineId, goal: &ReflowGoal, query_type: &ReflowQue
|
|||
|
||||
println!("{}", debug_msg);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ use string_cache::Atom;
|
|||
use time;
|
||||
use timers::{OneshotTimerCallback, OneshotTimerHandle};
|
||||
use url::{Url, Position};
|
||||
use util::prefs::mozbrowser_enabled;
|
||||
use util::prefs::PREFS;
|
||||
|
||||
#[derive(JSTraceable, PartialEq, Copy, Clone, HeapSizeOf)]
|
||||
enum XMLHttpRequestState {
|
||||
|
@ -581,8 +581,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
// story. See https://github.com/servo/servo/issues/9582
|
||||
if let GlobalRoot::Window(win) = self.global() {
|
||||
let is_root_pipeline = win.parent_info().is_none();
|
||||
let is_mozbrowser_enabled = mozbrowser_enabled();
|
||||
is_root_pipeline && is_mozbrowser_enabled
|
||||
is_root_pipeline && PREFS.is_mozbrowser_enabled()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ use std::os;
|
|||
use std::ptr;
|
||||
use time::{Tm, now};
|
||||
use util::opts;
|
||||
use util::prefs::get_pref;
|
||||
use util::prefs::PREFS;
|
||||
use util::thread_state;
|
||||
|
||||
/// Common messages used to control the event loops in both the script and the worker
|
||||
|
@ -124,30 +124,30 @@ pub unsafe fn new_rt_and_cx() -> Runtime {
|
|||
|
||||
// Enable or disable the JITs.
|
||||
let rt_opts = &mut *RuntimeOptionsRef(runtime.rt());
|
||||
if let Some(val) = get_pref("js.baseline.enabled").as_boolean() {
|
||||
if let Some(val) = PREFS.get("js.baseline.enabled").as_boolean() {
|
||||
rt_opts.set_baseline_(val);
|
||||
}
|
||||
if let Some(val) = get_pref("js.ion.enabled").as_boolean() {
|
||||
if let Some(val) = PREFS.get("js.ion.enabled").as_boolean() {
|
||||
rt_opts.set_ion_(val);
|
||||
}
|
||||
if let Some(val) = get_pref("js.asmjs.enabled").as_boolean() {
|
||||
if let Some(val) = PREFS.get("js.asmjs.enabled").as_boolean() {
|
||||
rt_opts.set_asmJS_(val);
|
||||
}
|
||||
if let Some(val) = get_pref("js.strict.enabled").as_boolean() {
|
||||
if let Some(val) = PREFS.get("js.strict.enabled").as_boolean() {
|
||||
rt_opts.set_extraWarnings_(val);
|
||||
}
|
||||
// TODO: handle js.strict.debug.enabled
|
||||
// TODO: handle js.throw_on_asmjs_validation_failure (needs new Spidermonkey)
|
||||
if let Some(val) = get_pref("js.native_regexp.enabled").as_boolean() {
|
||||
if let Some(val) = PREFS.get("js.native_regexp.enabled").as_boolean() {
|
||||
rt_opts.set_nativeRegExp_(val);
|
||||
}
|
||||
if let Some(val) = get_pref("js.parallel_parsing.enabled").as_boolean() {
|
||||
if let Some(val) = PREFS.get("js.parallel_parsing.enabled").as_boolean() {
|
||||
JS_SetParallelParsingEnabled(runtime.rt(), val);
|
||||
}
|
||||
if let Some(val) = get_pref("js.offthread_compilation_enabled").as_boolean() {
|
||||
if let Some(val) = PREFS.get("js.offthread_compilation_enabled").as_boolean() {
|
||||
JS_SetOffthreadIonCompilationEnabled(runtime.rt(), val);
|
||||
}
|
||||
if let Some(val) = get_pref("js.baseline.unsafe_eager_compilation.enabled").as_boolean() {
|
||||
if let Some(val) = PREFS.get("js.baseline.unsafe_eager_compilation.enabled").as_boolean() {
|
||||
let trigger: i32 = if val {
|
||||
0
|
||||
} else {
|
||||
|
@ -157,7 +157,7 @@ pub unsafe fn new_rt_and_cx() -> Runtime {
|
|||
JSJitCompilerOption::JSJITCOMPILER_BASELINE_WARMUP_TRIGGER,
|
||||
trigger as u32);
|
||||
}
|
||||
if let Some(val) = get_pref("js.ion.unsafe_eager_compilation.enabled").as_boolean() {
|
||||
if let Some(val) = PREFS.get("js.ion.unsafe_eager_compilation.enabled").as_boolean() {
|
||||
let trigger: i64 = if val {
|
||||
0
|
||||
} else {
|
||||
|
@ -171,14 +171,14 @@ pub unsafe fn new_rt_and_cx() -> Runtime {
|
|||
// TODO: handle js.asyncstack.enabled (needs new Spidermonkey)
|
||||
// TODO: handle js.throw_on_debugee_would_run (needs new Spidermonkey)
|
||||
// TODO: handle js.dump_stack_on_debugee_would_run (needs new Spidermonkey)
|
||||
if let Some(val) = get_pref("js.werror.enabled").as_boolean() {
|
||||
if let Some(val) = PREFS.get("js.werror.enabled").as_boolean() {
|
||||
rt_opts.set_werror_(val);
|
||||
}
|
||||
// TODO: handle js.shared_memory.enabled
|
||||
if let Some(val) = get_pref("js.mem.high_water_mark").as_i64() {
|
||||
if let Some(val) = PREFS.get("js.mem.high_water_mark").as_i64() {
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MAX_MALLOC_BYTES, val as u32 * 1024 * 1024);
|
||||
}
|
||||
if let Some(val) = get_pref("js.mem.max").as_i64() {
|
||||
if let Some(val) = PREFS.get("js.mem.max").as_i64() {
|
||||
let max = if val <= 0 || val >= 0x1000 {
|
||||
-1
|
||||
} else {
|
||||
|
@ -187,8 +187,8 @@ pub unsafe fn new_rt_and_cx() -> Runtime {
|
|||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MAX_BYTES, max as u32);
|
||||
}
|
||||
// NOTE: This is disabled above, so enabling it here will do nothing for now.
|
||||
if let Some(val) = get_pref("js.mem.gc.incremental.enabled").as_boolean() {
|
||||
let compartment = if let Some(val) = get_pref("js.mem.gc.per_compartment.enabled").as_boolean() {
|
||||
if let Some(val) = PREFS.get("js.mem.gc.incremental.enabled").as_boolean() {
|
||||
let compartment = if let Some(val) = PREFS.get("js.mem.gc.per_compartment.enabled").as_boolean() {
|
||||
val
|
||||
} else {
|
||||
false
|
||||
|
@ -202,67 +202,67 @@ pub unsafe fn new_rt_and_cx() -> Runtime {
|
|||
};
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MODE, mode as u32);
|
||||
}
|
||||
if let Some(val) = get_pref("js.mem.gc.incremental.slice_ms").as_i64() {
|
||||
if let Some(val) = PREFS.get("js.mem.gc.incremental.slice_ms").as_i64() {
|
||||
if val >= 0 && val < 100000 {
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_SLICE_TIME_BUDGET, val as u32);
|
||||
}
|
||||
}
|
||||
if let Some(val) = get_pref("js.mem.gc.compacting.enabled").as_boolean() {
|
||||
if let Some(val) = PREFS.get("js.mem.gc.compacting.enabled").as_boolean() {
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_COMPACTING_ENABLED, val as u32);
|
||||
}
|
||||
if let Some(val) = get_pref("js.mem.gc.high_frequency_time_limit_ms").as_i64() {
|
||||
if let Some(val) = PREFS.get("js.mem.gc.high_frequency_time_limit_ms").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_HIGH_FREQUENCY_TIME_LIMIT, val as u32);
|
||||
}
|
||||
}
|
||||
if let Some(val) = get_pref("js.mem.gc.dynamic_mark_slice.enabled").as_boolean() {
|
||||
if let Some(val) = PREFS.get("js.mem.gc.dynamic_mark_slice.enabled").as_boolean() {
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_DYNAMIC_MARK_SLICE, val as u32);
|
||||
}
|
||||
// TODO: handle js.mem.gc.refresh_frame_slices.enabled
|
||||
if let Some(val) = get_pref("js.mem.gc.dynamic_heap_growth.enabled").as_boolean() {
|
||||
if let Some(val) = PREFS.get("js.mem.gc.dynamic_heap_growth.enabled").as_boolean() {
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_DYNAMIC_HEAP_GROWTH, val as u32);
|
||||
}
|
||||
if let Some(val) = get_pref("js.mem.gc.low_frequency_heap_growth").as_i64() {
|
||||
if let Some(val) = PREFS.get("js.mem.gc.low_frequency_heap_growth").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_LOW_FREQUENCY_HEAP_GROWTH, val as u32);
|
||||
}
|
||||
}
|
||||
if let Some(val) = get_pref("js.mem.gc.high_frequency_heap_growth_min").as_i64() {
|
||||
if let Some(val) = PREFS.get("js.mem.gc.high_frequency_heap_growth_min").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN, val as u32);
|
||||
}
|
||||
}
|
||||
if let Some(val) = get_pref("js.mem.gc.high_frequency_heap_growth_max").as_i64() {
|
||||
if let Some(val) = PREFS.get("js.mem.gc.high_frequency_heap_growth_max").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX, val as u32);
|
||||
}
|
||||
}
|
||||
if let Some(val) = get_pref("js.mem.gc.high_frequency_low_limit_mb").as_i64() {
|
||||
if let Some(val) = PREFS.get("js.mem.gc.high_frequency_low_limit_mb").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_HIGH_FREQUENCY_LOW_LIMIT, val as u32);
|
||||
}
|
||||
}
|
||||
if let Some(val) = get_pref("js.mem.gc.high_frequency_high_limit_mb").as_i64() {
|
||||
if let Some(val) = PREFS.get("js.mem.gc.high_frequency_high_limit_mb").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_HIGH_FREQUENCY_HIGH_LIMIT, val as u32);
|
||||
}
|
||||
}
|
||||
if let Some(val) = get_pref("js.mem.gc.allocation_threshold_mb").as_i64() {
|
||||
if let Some(val) = PREFS.get("js.mem.gc.allocation_threshold_mb").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_ALLOCATION_THRESHOLD, val as u32);
|
||||
}
|
||||
}
|
||||
if let Some(val) = get_pref("js.mem.gc.decommit_threshold_mb").as_i64() {
|
||||
if let Some(val) = PREFS.get("js.mem.gc.decommit_threshold_mb").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_DECOMMIT_THRESHOLD, val as u32);
|
||||
}
|
||||
}
|
||||
if let Some(val) = get_pref("js.mem.gc.empty_chunk_count_min").as_i64() {
|
||||
if let Some(val) = PREFS.get("js.mem.gc.empty_chunk_count_min").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MIN_EMPTY_CHUNK_COUNT, val as u32);
|
||||
}
|
||||
}
|
||||
if let Some(val) = get_pref("js.mem.gc.empty_chunk_count_max").as_i64() {
|
||||
if let Some(val) = PREFS.get("js.mem.gc.empty_chunk_count_max").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(runtime.rt(), JSGCParamKey::JSGC_MAX_EMPTY_CHUNK_COUNT, val as u32);
|
||||
}
|
||||
|
@ -403,11 +403,11 @@ unsafe extern fn trace_rust_roots(tr: *mut JSTracer, _data: *mut os::raw::c_void
|
|||
unsafe fn set_gc_zeal_options(cx: *mut JSContext) {
|
||||
use js::jsapi::{JS_DEFAULT_ZEAL_FREQ, JS_SetGCZeal};
|
||||
|
||||
let level = match get_pref("js.mem.gc.zeal.level").as_i64() {
|
||||
let level = match PREFS.get("js.mem.gc.zeal.level").as_i64() {
|
||||
Some(level @ 0...14) => level as u8,
|
||||
_ => return,
|
||||
};
|
||||
let frequency = match get_pref("js.mem.gc.zeal.frequency").as_i64() {
|
||||
let frequency = match PREFS.get("js.mem.gc.zeal.frequency").as_i64() {
|
||||
Some(frequency) if frequency >= 0 => frequency as u32,
|
||||
_ => JS_DEFAULT_ZEAL_FREQ,
|
||||
};
|
||||
|
|
|
@ -22,7 +22,7 @@ use std::cmp::{self, Ord, Ordering};
|
|||
use std::collections::HashMap;
|
||||
use std::default::Default;
|
||||
use std::rc::Rc;
|
||||
use util::prefs::get_pref;
|
||||
use util::prefs::PREFS;
|
||||
|
||||
#[derive(JSTraceable, PartialEq, Eq, Copy, Clone, HeapSizeOf, Hash, PartialOrd, Ord, Debug)]
|
||||
pub struct OneshotTimerHandle(i32);
|
||||
|
@ -214,7 +214,7 @@ impl OneshotTimers {
|
|||
}
|
||||
|
||||
pub fn slow_down(&self) {
|
||||
let duration = get_pref("js.timers.minimum_duration").as_u64().unwrap_or(1000);
|
||||
let duration = PREFS.get("js.timers.minimum_duration").as_u64().unwrap_or(1000);
|
||||
self.js_timers.set_min_duration(MsDuration::new(duration));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue