mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Implement Document.currentScript
This commit is contained in:
parent
8ad3c5aeb6
commit
5f5d1246ef
5 changed files with 24 additions and 31 deletions
|
@ -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| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue