auto merge of #5054 : psdh/servo/scriptimplementation, r=jdm

Fixes #4089
This commit is contained in:
bors-servo 2015-03-06 13:36:53 -07:00
commit 73e5bbec43
3 changed files with 39 additions and 9 deletions

View file

@ -121,6 +121,9 @@ pub struct Document {
focused: MutNullableJS<Element>,
/// The script element that is currently executing.
current_script: MutNullableJS<HTMLScriptElement>,
/// https://html.spec.whatwg.org/multipage/webappapis.html#concept-n-noscript
/// True if scripting is enabled for all scripts in this document
scripting_enabled: Cell<bool>,
}
impl DocumentDerived for EventTarget {
@ -206,6 +209,7 @@ pub trait DocumentHelpers<'a> {
fn get_nodes_under_mouse(self, point: &Point2D<f32>) -> Vec<UntrustedNodeAddress>;
fn set_ready_state(self, state: DocumentReadyState);
fn get_focused_element(self) -> Option<Temporary<Element>>;
fn is_scripting_enabled(self) -> bool;
fn begin_focus_transaction(self);
fn request_focus(self, elem: JSRef<Element>);
fn commit_focus_transaction(self);
@ -430,6 +434,11 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
let _ = event.r().fire(target);
}
/// Return whether scripting is enabled or not
fn is_scripting_enabled(self) -> bool {
self.scripting_enabled.get()
}
/// Return the element that currently has focus.
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#events-focusevent-doc-focus
fn get_focused_element(self) -> Option<Temporary<Element>> {
@ -737,6 +746,7 @@ impl Document {
possibly_focused: Default::default(),
focused: Default::default(),
current_script: Default::default(),
scripting_enabled: Cell::new(true),
}
}