Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update prefs API to return an Option<bool>. #7545

Merged
merged 1 commit into from Sep 4, 2015
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -891,7 +891,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
containing_pipeline_id: PipelineId,
subpage_id: SubpageId,
event: MozBrowserEvent) {
assert!(prefs::get_pref("dom.mozbrowser.enabled", false));
assert!(prefs::get_pref("dom.mozbrowser.enabled").unwrap_or(false));

// Find the script channel for the given parent pipeline,
// and pass the event to that script task.
@@ -1373,7 +1373,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {

// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserlocationchange
fn trigger_mozbrowserlocationchange(&self, pipeline_id: PipelineId) {
if prefs::get_pref("dom.mozbrowser.enabled", false) {
if prefs::get_pref("dom.mozbrowser.enabled").unwrap_or(false) {
// Work around borrow checker
let event_info = {
let pipeline = self.pipeline(pipeline_id);
@@ -269,7 +269,7 @@ impl Pipeline {
pub fn trigger_mozbrowser_event(&self,
subpage_id: SubpageId,
event: MozBrowserEvent) {
assert!(prefs::get_pref("dom.mozbrowser.enabled", false));
assert!(prefs::get_pref("dom.mozbrowser.enabled").unwrap_or(false));

let event = ConstellationControlMsg::MozBrowserEvent(self.id,
subpage_id,
@@ -42,7 +42,7 @@ use url::{Url, UrlParser};
use util::str::{self, LengthOrPercentageOrAuto};

pub fn mozbrowser_enabled() -> bool {
prefs::get_pref("dom.mozbrowser.enabled", false)
prefs::get_pref("dom.mozbrowser.enabled").unwrap_or(false)
}

#[derive(HeapSizeOf)]
@@ -171,7 +171,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", false) {
if prefs::get_pref("dom.mouseevent.which.enabled").unwrap_or(false) {
(self.button.get() + 1) as i32
} else {
0
@@ -494,7 +494,7 @@ pub mod longhands {
% for value in values[:-1]:
"${value}" => {
% if value in experimental_values:
if !::util::prefs::get_pref("layout.${value}.enabled", false) {
if !::util::prefs::get_pref("layout.${value}.enabled").unwrap_or(false) {
return Err(())
}
% endif
@@ -504,7 +504,7 @@ pub mod longhands {
% for value in values[-1:]:
"${value}" => {
% if value in experimental_values:
if !::util::prefs::get_pref("layout.${value}.enabled", false) {
if !::util::prefs::get_pref("layout.${value}.enabled".unwrap_or(false) {
return Err(())
}
% endif
@@ -5796,7 +5796,7 @@ impl PropertyDeclaration {
% if property.derived_from is None:
"${property.name}" => {
% if property.experimental:
if !::util::prefs::get_pref("${property.experimental}", false) {
if !::util::prefs::get_pref("${property.experimental}").unwrap_or(false) {
return PropertyDeclarationParseResult::ExperimentalProperty
}
% endif
@@ -5815,7 +5815,7 @@ impl PropertyDeclaration {
% for shorthand in SHORTHANDS:
"${shorthand.name}" => {
% if shorthand.experimental:
if !::util::prefs::get_pref("${shorthand.experimental}", false) {
if !::util::prefs::get_pref("${shorthand.experimental}").unwrap_or(false) {
return PropertyDeclarationParseResult::ExperimentalProperty
}
% endif
@@ -429,7 +429,7 @@ impl<'a, 'b> AtRuleParser for NestedRuleParser<'a, 'b> {
Ok(AtRuleType::WithBlock(AtRulePrelude::FontFace))
},
"viewport" => {
if ::util::prefs::get_pref("layout.viewport.enabled", false) {
if ::util::prefs::get_pref("layout.viewport.enabled").unwrap_or(false) {
Ok(AtRuleType::WithBlock(AtRulePrelude::Viewport))
} else {
Err(())
@@ -41,8 +41,8 @@ fn read_prefs() -> Result<HashMap<String, bool>, ()> {
Ok(prefs)
}

pub fn get_pref(name: &str, default: bool) -> bool {
*PREFS.lock().unwrap().get(name).unwrap_or(&default)
pub fn get_pref(name: &str) -> Option<bool> {
PREFS.lock().unwrap().get(name).cloned()
}

pub fn set_pref(name: &str, value: bool) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.