Skip to content

Commit

Permalink
Rename ClassicScript to ScriptOrigin
Browse files Browse the repository at this point in the history
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 Sep 6, 2019
1 parent 608c44f commit 19eb239
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions components/script/dom/htmlscriptelement.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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.

Expand All @@ -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;
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 19eb239

Please sign in to comment.