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

Implement [Func] #11308

Merged
merged 12 commits into from May 27, 2016
Prev

Use [Func] on HTMLIFrameElement.mozbrowser

  • Loading branch information
nox committed May 26, 2016
commit 694deabcd56120ea81b4c88e3b806c3c230b83f9
@@ -433,29 +433,16 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
// Experimental mozbrowser implementation is based on the webidl
// present in the gecko source tree, and the documentation here:
// https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API

// TODO(gw): Use experimental codegen when it is available to avoid
// exposing these APIs. See https://github.com/servo/servo/issues/5264.

// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
fn Mozbrowser(&self) -> bool {
// We don't want to allow mozbrowser iframes within iframes
let is_root_pipeline = window_from_node(self).parent_info().is_none();
if mozbrowser_enabled() && is_root_pipeline {
let element = self.upcast::<Element>();
element.has_attribute(&atom!("mozbrowser"))
} else {
false
}
let element = self.upcast::<Element>();
element.has_attribute(&atom!("mozbrowser"))
}

// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
fn SetMozbrowser(&self, value: bool) -> ErrorResult {
if mozbrowser_enabled() {
let element = self.upcast::<Element>();
element.set_bool_attribute(&atom!("mozbrowser"), value);
}
Ok(())
fn SetMozbrowser(&self, value: bool) {
let element = self.upcast::<Element>();
element.set_bool_attribute(&atom!("mozbrowser"), value);
}

// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goBack
@@ -32,8 +32,8 @@ partial interface HTMLIFrameElement {
};

partial interface HTMLIFrameElement {
[ChromeOnly,SetterThrows,Pref="dom.mozbrowser.enabled"]
attribute boolean mozbrowser;
[Func="Window::global_is_mozbrowser"]
attribute boolean mozbrowser;
};

HTMLIFrameElement implements BrowserElement;
@@ -14,7 +14,7 @@ use dom::bindings::codegen::Bindings::FunctionBinding::Function;
use dom::bindings::codegen::Bindings::WindowBinding::{ScrollBehavior, ScrollToOptions};
use dom::bindings::codegen::Bindings::WindowBinding::{self, FrameRequestCallback, WindowMethods};
use dom::bindings::error::{Error, Fallible, report_pending_exception};
use dom::bindings::global::GlobalRef;
use dom::bindings::global::{GlobalRef, global_root_from_object};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::num::Finite;
@@ -37,9 +37,8 @@ use dom::storage::Storage;
use euclid::{Point2D, Rect, Size2D};
use gfx_traits::LayerId;
use ipc_channel::ipc::{self, IpcSender};
use js::jsapi::{Evaluate2, MutableHandleValue};
use js::jsapi::{HandleValue, JSContext};
use js::jsapi::{JSAutoCompartment, JS_GC, JS_GetRuntime, SetWindowProxy};
use js::jsapi::{Evaluate2, HandleObject, HandleValue, JSAutoCompartment, JSContext};
use js::jsapi::{JS_GetRuntime, JS_GC, MutableHandleValue, SetWindowProxy};
use js::rust::CompileOptionsWrapper;
use js::rust::Runtime;
use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow};
@@ -93,6 +92,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::str::HTML_SPACE_CHARACTERS;
use util::{breakpoint, opts};
use webdriver_handlers::jsval_to_webdriver;
@@ -1432,6 +1432,19 @@ impl Window {
context.active_window()
})
}

/// Returns whether mozbrowser is enabled and `obj` has been created
/// in a top-level `Window` global.
#[allow(unsafe_code)]
pub unsafe fn global_is_mozbrowser(_: *mut JSContext, obj: HandleObject) -> bool {
if !mozbrowser_enabled() {
return false;
}
match global_root_from_object(obj.get()).r() {
GlobalRef::Window(window) => window.parent_info().is_none(),
_ => false,
}
}
}

impl Window {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.