Skip to content
Permalink
Browse files

Rename ClassicScript to ScriptOrigin

This is basically revert 965370c. After introducing module script, we
can reuse this struct and add field to see the type of script.
  • Loading branch information...
CYBAI committed Jun 8, 2019
1 parent 608c44f commit 19eb2392f548d65e3879291ac2289f0e8dea94d4
Showing with 13 additions and 13 deletions.
  1. +13 −13 components/script/dom/htmlscriptelement.rs
@@ -131,31 +131,31 @@ pub enum ScriptType {
}

#[derive(JSTraceable, MallocSizeOf)]
pub struct ClassicScript {
pub struct ScriptOrigin {
text: DOMString,
url: ServoUrl,
external: bool,
}

impl ClassicScript {
fn internal(text: DOMString, url: ServoUrl) -> ClassicScript {
ClassicScript {
impl ScriptOrigin {
fn internal(text: DOMString, url: ServoUrl) -> ScriptOrigin {
ScriptOrigin {
text: text,
url: url,
external: false,
}
}

fn external(text: DOMString, url: ServoUrl) -> ClassicScript {
ClassicScript {
fn external(text: DOMString, url: ServoUrl) -> ScriptOrigin {
ScriptOrigin {
text: text,
url: url,
external: true,
}
}
}

pub type ScriptResult = Result<ClassicScript, NetworkError>;
pub type ScriptResult = Result<ScriptOrigin, NetworkError>;

/// The context required for asynchronously loading an external script source.
struct ClassicContext {
@@ -231,7 +231,7 @@ impl FetchResponseListener for ClassicContext {

// Step 7.
let (source_text, _, _) = encoding.decode(&self.data);
ClassicScript::external(DOMString::from(source_text), metadata.final_url)
ScriptOrigin::external(DOMString::from(source_text), metadata.final_url)
});

// Step 9.
@@ -473,7 +473,7 @@ impl HTMLScriptElement {
return;
}

// Step 24.3: The "from an external file"" flag is stored in ClassicScript.
// Step 24.3: The "from an external file"" flag is stored in ScriptOrigin.

// Step 24.4-24.5.
let url = match base_url.join(&src) {
@@ -526,7 +526,7 @@ impl HTMLScriptElement {
// Step 25.
assert!(!text.is_empty());
// Step 25-1.
let result = Ok(ClassicScript::internal(text, base_url));
let result = Ok(ScriptOrigin::internal(text, base_url));

// TODO: Step 25-2.

@@ -545,7 +545,7 @@ impl HTMLScriptElement {
}
}

fn unminify_js(&self, script: &mut ClassicScript) {
fn unminify_js(&self, script: &mut ScriptOrigin) {
if !self.parser_document.window().unminify_js() {
return;
}
@@ -598,7 +598,7 @@ impl HTMLScriptElement {
}

/// <https://html.spec.whatwg.org/multipage/#execute-the-script-block>
pub fn execute(&self, result: Result<ClassicScript, NetworkError>) {
pub fn execute(&self, result: Result<ScriptOrigin, NetworkError>) {
// Step 1.
let doc = document_from_node(self);
if self.parser_inserted.get() && &*doc != &*self.parser_document {
@@ -653,7 +653,7 @@ impl HTMLScriptElement {
}

// https://html.spec.whatwg.org/multipage/#run-a-classic-script
pub fn run_a_classic_script(&self, script: &ClassicScript) {
pub fn run_a_classic_script(&self, script: &ScriptOrigin) {
// TODO use a settings object rather than this element's document/window
// Step 2
let document = document_from_node(self);

0 comments on commit 19eb239

Please sign in to comment.
You can’t perform that action at this time.