aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlscriptelement.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/htmlscriptelement.rs')
-rw-r--r--components/script/dom/htmlscriptelement.rs72
1 files changed, 17 insertions, 55 deletions
diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs
index 64ab605ba40..42d398899d1 100644
--- a/components/script/dom/htmlscriptelement.rs
+++ b/components/script/dom/htmlscriptelement.rs
@@ -6,7 +6,6 @@ use std::ascii::AsciiExt;
use document_loader::LoadType;
use dom::attr::Attr;
-use dom::attr::AttrHelpers;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
@@ -21,17 +20,15 @@ use dom::bindings::js::RootedReference;
use dom::bindings::js::{JS, Root};
use dom::bindings::refcounted::Trusted;
use dom::bindings::trace::JSTraceable;
-use dom::document::{Document, DocumentHelpers};
-use dom::element::ElementTypeId;
-use dom::element::{AttributeHandlers, ElementCreator};
-use dom::event::{Event, EventBubbles, EventCancelable, EventHelpers};
+use dom::document::Document;
+use dom::element::{ElementCreator, ElementTypeId};
+use dom::event::{Event, EventBubbles, EventCancelable};
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
-use dom::node::{ChildrenMutation, CloneChildrenFlag, Node, NodeHelpers};
+use dom::node::{ChildrenMutation, CloneChildrenFlag, Node};
use dom::node::{NodeTypeId, document_from_node, window_from_node};
-use dom::servohtmlparser::ServoHTMLParserHelpers;
use dom::virtualmethods::VirtualMethods;
-use dom::window::{WindowHelpers, ScriptHelpers};
+use dom::window::ScriptHelpers;
use js::jsapi::RootedValue;
use js::jsval::UndefinedValue;
use network_listener::{NetworkListener, PreInvoke};
@@ -110,35 +107,6 @@ impl HTMLScriptElement {
}
}
-pub trait HTMLScriptElementHelpers {
- /// Prepare a script (<https://www.whatwg.org/html/#prepare-a-script>)
- fn prepare(self) -> NextParserState;
-
- /// [Execute a script block]
- /// (https://html.spec.whatwg.org/multipage/#execute-the-script-block)
- fn execute(self, load: ScriptOrigin);
-
- /// Prepare a script, steps 6 and 7.
- fn is_javascript(self) -> bool;
-
- /// Set the "already started" flag (<https://whatwg.org/html/#already-started>)
- fn mark_already_started(self);
-
- // Queues error event
- fn queue_error_event(self);
-
- /// Dispatch beforescriptexecute event.
- fn dispatch_before_script_execute_event(self) -> bool;
-
- /// Dispatch afterscriptexecute event.
- fn dispatch_after_script_execute_event(self);
-
- /// Dispatch load event.
- fn dispatch_load_event(self);
-
- /// Dispatch error event.
- fn dispatch_error_event(self);
-}
/// Supported script types as defined by
/// <https://whatwg.org/html/#support-the-scripting-language>.
@@ -212,8 +180,8 @@ impl AsyncResponseListener for ScriptContext {
impl PreInvoke for ScriptContext {}
-impl<'a> HTMLScriptElementHelpers for &'a HTMLScriptElement {
- fn prepare(self) -> NextParserState {
+impl HTMLScriptElement {
+ pub fn prepare(&self) -> NextParserState {
// https://html.spec.whatwg.org/multipage/#prepare-a-script
// Step 1.
if self.already_started.get() {
@@ -365,7 +333,7 @@ impl<'a> HTMLScriptElementHelpers for &'a HTMLScriptElement {
NextParserState::Continue
}
- fn execute(self, load: ScriptOrigin) {
+ pub fn execute(&self, load: ScriptOrigin) {
// Step 1.
// TODO: If the element is flagged as "parser-inserted", but the
// element's node document is not the Document of the parser that
@@ -462,7 +430,7 @@ impl<'a> HTMLScriptElementHelpers for &'a HTMLScriptElement {
}
}
- fn queue_error_event(self) {
+ pub fn queue_error_event(&self) {
let window = window_from_node(self);
let window = window.r();
let chan = window.script_chan();
@@ -474,31 +442,31 @@ impl<'a> HTMLScriptElementHelpers for &'a HTMLScriptElement {
chan.send(CommonScriptMsg::RunnableMsg(dispatcher)).unwrap();
}
- fn dispatch_before_script_execute_event(self) -> bool {
+ pub fn dispatch_before_script_execute_event(&self) -> bool {
self.dispatch_event("beforescriptexecute".to_owned(),
EventBubbles::Bubbles,
EventCancelable::Cancelable)
}
- fn dispatch_after_script_execute_event(self) {
+ pub fn dispatch_after_script_execute_event(&self) {
self.dispatch_event("afterscriptexecute".to_owned(),
EventBubbles::Bubbles,
EventCancelable::NotCancelable);
}
- fn dispatch_load_event(self) {
+ pub fn dispatch_load_event(&self) {
self.dispatch_event("load".to_owned(),
EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable);
}
- fn dispatch_error_event(self) {
+ pub fn dispatch_error_event(&self) {
self.dispatch_event("error".to_owned(),
EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable);
}
- fn is_javascript(self) -> bool {
+ pub fn is_javascript(&self) -> bool {
let element = ElementCast::from_ref(self);
match element.get_attribute(&ns!(""), &atom!("type")).map(|s| s.r().Value()) {
Some(ref s) if s.is_empty() => {
@@ -531,20 +499,14 @@ impl<'a> HTMLScriptElementHelpers for &'a HTMLScriptElement {
}
}
- fn mark_already_started(self) {
+ pub fn mark_already_started(&self) {
self.already_started.set(true);
}
}
-trait PrivateHTMLScriptElementHelpers {
- fn dispatch_event(self,
- type_: DOMString,
- bubbles: EventBubbles,
- cancelable: EventCancelable) -> bool;
-}
-impl<'a> PrivateHTMLScriptElementHelpers for &'a HTMLScriptElement {
- fn dispatch_event(self,
+impl HTMLScriptElement {
+ fn dispatch_event(&self,
type_: DOMString,
bubbles: EventBubbles,
cancelable: EventCancelable) -> bool {