aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/document.rs
diff options
context:
space:
mode:
authorJames Gilbertson <james.gilbertson@luniv.ca>2015-02-26 06:43:49 -0700
committerJames Gilbertson <james.gilbertson@luniv.ca>2015-02-27 11:11:02 -0700
commit5f5d1246ef136f4189dbbe9aeec173a385c82e6c (patch)
treec19861c0aee1debeb09283dca1f93b4c780607b8 /components/script/dom/document.rs
parent8ad3c5aeb65e473a4c099b12e9439dfc556024f8 (diff)
downloadservo-5f5d1246ef136f4189dbbe9aeec173a385c82e6c.tar.gz
servo-5f5d1246ef136f4189dbbe9aeec173a385c82e6c.zip
Implement Document.currentScript
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r--components/script/dom/document.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 5e29dd60e46..c369b8f1d74 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -45,6 +45,7 @@ use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmlheadelement::HTMLHeadElement;
use dom::htmlhtmlelement::HTMLHtmlElement;
use dom::htmltitleelement::HTMLTitleElement;
+use dom::htmlscriptelement::HTMLScriptElement;
use dom::location::Location;
use dom::mouseevent::MouseEvent;
use dom::keyboardevent::KeyboardEvent;
@@ -116,6 +117,8 @@ pub struct Document {
possibly_focused: MutNullableJS<Element>,
/// The element that currently has the document focus context.
focused: MutNullableJS<Element>,
+ /// The script element that is currently executing.
+ current_script: MutNullableJS<HTMLScriptElement>,
}
impl DocumentDerived for EventTarget {
@@ -206,6 +209,7 @@ pub trait DocumentHelpers<'a> {
fn handle_click_event(self, js_runtime: *mut JSRuntime, _button: uint, point: Point2D<f32>);
fn dispatch_key_event(self, key: Key, state: KeyState,
modifiers: KeyModifiers, compositor: &mut Box<ScriptListener+'static>);
+ fn set_current_script(self, script: Option<JSRef<HTMLScriptElement>>);
}
impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
@@ -535,6 +539,10 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
window.r().flush_layout(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery);
}
+
+ fn set_current_script(self, script: Option<JSRef<HTMLScriptElement>>) {
+ self.current_script.assign(script);
+ }
}
#[derive(PartialEq)]
@@ -601,6 +609,7 @@ impl Document {
ready_state: Cell::new(ready_state),
possibly_focused: Default::default(),
focused: Default::default(),
+ current_script: Default::default(),
}
}
@@ -1002,6 +1011,11 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
})
}
+ // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-currentscript
+ fn GetCurrentScript(self) -> Option<Temporary<HTMLScriptElement>> {
+ self.current_script.get()
+ }
+
// http://www.whatwg.org/specs/web-apps/current-work/#dom-document-body
fn GetBody(self) -> Option<Temporary<HTMLElement>> {
self.get_html_element().and_then(|root| {