Auto merge of #7391 - jdm:prefs, r=Ms2ger

Replace catch-all experimental flag with fine-grained boolean prefere…

…nces initialized from a JSON document.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7391)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-08-28 10:08:32 -06:00
commit 72125f070d
14 changed files with 122 additions and 59 deletions

View file

@ -30,7 +30,7 @@ use msg::constellation_msg::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandbo
use msg::constellation_msg::Msg as ConstellationMsg;
use msg::constellation_msg::{PipelineId, SubpageId, ConstellationChan, MozBrowserEvent, NavigationDirection};
use string_cache::Atom;
use util::opts;
use util::prefs;
use util::str::DOMString;
use js::jsapi::{RootedValue, JSAutoRequest, JSAutoCompartment};
@ -41,6 +41,10 @@ use std::cell::Cell;
use url::{Url, UrlParser};
use util::str::{self, LengthOrPercentageOrAuto};
pub fn mozbrowser_enabled() -> bool {
prefs::get_pref("dom.mozbrowser.enabled", false)
}
#[derive(HeapSizeOf)]
enum SandboxAllowance {
AllowNothing = 0x00,
@ -117,7 +121,7 @@ impl HTMLIFrameElement {
old_subpage_id,
sandboxed)).unwrap();
if opts::experimental_enabled() {
if mozbrowser_enabled() {
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadstart
self.dispatch_mozbrowser_event(MozBrowserEvent::LoadStart);
}
@ -136,7 +140,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!(opts::experimental_enabled());
assert!(mozbrowser_enabled());
if self.Mozbrowser() {
let window = window_from_node(self);
@ -298,7 +302,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
fn Mozbrowser(&self) -> bool {
if opts::experimental_enabled() {
if mozbrowser_enabled() {
let element = ElementCast::from_ref(self);
element.has_attribute(&Atom::from_slice("mozbrowser"))
} else {
@ -308,7 +312,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
fn SetMozbrowser(&self, value: bool) -> ErrorResult {
if opts::experimental_enabled() {
if mozbrowser_enabled() {
let element = ElementCast::from_ref(self);
element.set_bool_attribute(&Atom::from_slice("mozbrowser"), value);
}