mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Rename ClassicScript to ScriptOrigin
This is basically revert 965370c0bf
. After introducing module script, we
can reuse this struct and add field to see the type of script.
This commit is contained in:
parent
608c44f103
commit
19eb2392f5
1 changed files with 13 additions and 13 deletions
|
@ -131,23 +131,23 @@ pub enum ScriptType {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(JSTraceable, MallocSizeOf)]
|
#[derive(JSTraceable, MallocSizeOf)]
|
||||||
pub struct ClassicScript {
|
pub struct ScriptOrigin {
|
||||||
text: DOMString,
|
text: DOMString,
|
||||||
url: ServoUrl,
|
url: ServoUrl,
|
||||||
external: bool,
|
external: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClassicScript {
|
impl ScriptOrigin {
|
||||||
fn internal(text: DOMString, url: ServoUrl) -> ClassicScript {
|
fn internal(text: DOMString, url: ServoUrl) -> ScriptOrigin {
|
||||||
ClassicScript {
|
ScriptOrigin {
|
||||||
text: text,
|
text: text,
|
||||||
url: url,
|
url: url,
|
||||||
external: false,
|
external: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn external(text: DOMString, url: ServoUrl) -> ClassicScript {
|
fn external(text: DOMString, url: ServoUrl) -> ScriptOrigin {
|
||||||
ClassicScript {
|
ScriptOrigin {
|
||||||
text: text,
|
text: text,
|
||||||
url: url,
|
url: url,
|
||||||
external: true,
|
external: true,
|
||||||
|
@ -155,7 +155,7 @@ impl ClassicScript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ScriptResult = Result<ClassicScript, NetworkError>;
|
pub type ScriptResult = Result<ScriptOrigin, NetworkError>;
|
||||||
|
|
||||||
/// The context required for asynchronously loading an external script source.
|
/// The context required for asynchronously loading an external script source.
|
||||||
struct ClassicContext {
|
struct ClassicContext {
|
||||||
|
@ -231,7 +231,7 @@ impl FetchResponseListener for ClassicContext {
|
||||||
|
|
||||||
// Step 7.
|
// Step 7.
|
||||||
let (source_text, _, _) = encoding.decode(&self.data);
|
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.
|
// Step 9.
|
||||||
|
@ -473,7 +473,7 @@ impl HTMLScriptElement {
|
||||||
return;
|
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.
|
// Step 24.4-24.5.
|
||||||
let url = match base_url.join(&src) {
|
let url = match base_url.join(&src) {
|
||||||
|
@ -526,7 +526,7 @@ impl HTMLScriptElement {
|
||||||
// Step 25.
|
// Step 25.
|
||||||
assert!(!text.is_empty());
|
assert!(!text.is_empty());
|
||||||
// Step 25-1.
|
// Step 25-1.
|
||||||
let result = Ok(ClassicScript::internal(text, base_url));
|
let result = Ok(ScriptOrigin::internal(text, base_url));
|
||||||
|
|
||||||
// TODO: Step 25-2.
|
// 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() {
|
if !self.parser_document.window().unminify_js() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -598,7 +598,7 @@ impl HTMLScriptElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#execute-the-script-block>
|
/// <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.
|
// Step 1.
|
||||||
let doc = document_from_node(self);
|
let doc = document_from_node(self);
|
||||||
if self.parser_inserted.get() && &*doc != &*self.parser_document {
|
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
|
// 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
|
// TODO use a settings object rather than this element's document/window
|
||||||
// Step 2
|
// Step 2
|
||||||
let document = document_from_node(self);
|
let document = document_from_node(self);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue