mirror of
https://github.com/servo/servo.git
synced 2025-06-27 10:33:39 +01:00
Remove special-casing of URLs ending in ".js"
This was a very old (May 2012) testing feature which used std::io::read_whole_file rather than our normal resource-loader mechanism. We can implement javascript: URLs later.
This commit is contained in:
parent
377a76ab1b
commit
1cd5d9179d
3 changed files with 24 additions and 68 deletions
|
@ -16,7 +16,7 @@ use servo_msg::constellation_msg::{IFrameSandboxState, InitLoadUrlMsg, LoadIfram
|
||||||
use servo_msg::constellation_msg::{Msg, NavigateMsg, NavigationType, IFrameUnsandboxed};
|
use servo_msg::constellation_msg::{Msg, NavigateMsg, NavigationType, IFrameUnsandboxed};
|
||||||
use servo_msg::constellation_msg::{PipelineId, RendererReadyMsg, ResizedWindowMsg, SubpageId};
|
use servo_msg::constellation_msg::{PipelineId, RendererReadyMsg, ResizedWindowMsg, SubpageId};
|
||||||
use servo_msg::constellation_msg;
|
use servo_msg::constellation_msg;
|
||||||
use script::script_task::{ResizeMsg, ResizeInactiveMsg, ExecuteMsg};
|
use script::script_task::{ResizeMsg, ResizeInactiveMsg};
|
||||||
use servo_net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
|
use servo_net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
|
||||||
use servo_net::resource_task::ResourceTask;
|
use servo_net::resource_task::ResourceTask;
|
||||||
use servo_net::resource_task;
|
use servo_net::resource_task;
|
||||||
|
@ -404,9 +404,6 @@ impl Constellation {
|
||||||
let size = self.compositor_chan.get_size();
|
let size = self.compositor_chan.get_size();
|
||||||
from_value(Size2D(size.width as uint, size.height as uint))
|
from_value(Size2D(size.width as uint, size.height as uint))
|
||||||
});
|
});
|
||||||
if url.path.ends_with(".js") {
|
|
||||||
pipeline.script_chan.send(ExecuteMsg(pipeline.id, url));
|
|
||||||
} else {
|
|
||||||
pipeline.load(url);
|
pipeline.load(url);
|
||||||
|
|
||||||
self.pending_frames.push(FrameChange{
|
self.pending_frames.push(FrameChange{
|
||||||
|
@ -418,7 +415,6 @@ impl Constellation {
|
||||||
},
|
},
|
||||||
navigation_type: constellation_msg::Load,
|
navigation_type: constellation_msg::Load,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
self.pipelines.insert(pipeline.id, pipeline);
|
self.pipelines.insert(pipeline.id, pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,12 +545,8 @@ impl Constellation {
|
||||||
size_future)
|
size_future)
|
||||||
};
|
};
|
||||||
|
|
||||||
if url.path.ends_with(".js") {
|
|
||||||
pipeline.execute(url);
|
|
||||||
} else {
|
|
||||||
debug!("Constellation: sending load msg to pipeline %?", pipeline.id);
|
debug!("Constellation: sending load msg to pipeline %?", pipeline.id);
|
||||||
pipeline.load(url);
|
pipeline.load(url);
|
||||||
}
|
|
||||||
let rect = self.pending_sizes.pop(&(source_pipeline_id, subpage_id));
|
let rect = self.pending_sizes.pop(&(source_pipeline_id, subpage_id));
|
||||||
for frame_tree in frame_trees.iter() {
|
for frame_tree in frame_trees.iter() {
|
||||||
frame_tree.children.push(ChildFrameTree {
|
frame_tree.children.push(ChildFrameTree {
|
||||||
|
@ -606,9 +598,6 @@ impl Constellation {
|
||||||
self.opts.clone(),
|
self.opts.clone(),
|
||||||
size_future);
|
size_future);
|
||||||
|
|
||||||
if url.path.ends_with(".js") {
|
|
||||||
pipeline.script_chan.send(ExecuteMsg(pipeline.id, url));
|
|
||||||
} else {
|
|
||||||
pipeline.load(url);
|
pipeline.load(url);
|
||||||
|
|
||||||
self.pending_frames.push(FrameChange{
|
self.pending_frames.push(FrameChange{
|
||||||
|
@ -620,7 +609,6 @@ impl Constellation {
|
||||||
},
|
},
|
||||||
navigation_type: constellation_msg::Load,
|
navigation_type: constellation_msg::Load,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
self.pipelines.insert(pipeline.id, pipeline);
|
self.pipelines.insert(pipeline.id, pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use gfx::render_task::{PaintPermissionGranted, PaintPermissionRevoked};
|
||||||
use gfx::opts::Opts;
|
use gfx::opts::Opts;
|
||||||
use layout::layout_task::LayoutTask;
|
use layout::layout_task::LayoutTask;
|
||||||
use script::layout_interface::LayoutChan;
|
use script::layout_interface::LayoutChan;
|
||||||
use script::script_task::{ExecuteMsg, LoadMsg};
|
use script::script_task::LoadMsg;
|
||||||
use servo_msg::constellation_msg::{ConstellationChan, FailureMsg, PipelineId, SubpageId};
|
use servo_msg::constellation_msg::{ConstellationChan, FailureMsg, PipelineId, SubpageId};
|
||||||
use script::dom::node::AbstractNode;
|
use script::dom::node::AbstractNode;
|
||||||
use script::script_task::{AttachLayoutMsg, NewLayoutInfo, ScriptTask, ScriptChan};
|
use script::script_task::{AttachLayoutMsg, NewLayoutInfo, ScriptTask, ScriptChan};
|
||||||
|
@ -194,11 +194,6 @@ impl Pipeline {
|
||||||
self.script_chan.send(LoadMsg(self.id, url));
|
self.script_chan.send(LoadMsg(self.id, url));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn execute(&mut self, url: Url) {
|
|
||||||
self.url = Some(url.clone());
|
|
||||||
self.script_chan.send(ExecuteMsg(self.id, url));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn grant_paint_permission(&self) {
|
pub fn grant_paint_permission(&self) {
|
||||||
self.render_chan.try_send(PaintPermissionGranted);
|
self.render_chan.try_send(PaintPermissionGranted);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,7 @@ use servo_msg::constellation_msg;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::comm;
|
use std::comm;
|
||||||
use std::comm::{Port, SharedChan};
|
use std::comm::{Port, SharedChan};
|
||||||
use std::io::read_whole_file;
|
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::str;
|
|
||||||
use std::task::{spawn_sched, SingleThreaded};
|
use std::task::{spawn_sched, SingleThreaded};
|
||||||
use std::util::replace;
|
use std::util::replace;
|
||||||
use dom::window::TimerData;
|
use dom::window::TimerData;
|
||||||
|
@ -58,8 +56,6 @@ pub enum ScriptMsg {
|
||||||
LoadMsg(PipelineId, Url),
|
LoadMsg(PipelineId, Url),
|
||||||
/// Gives a channel and ID to a layout task, as well as the ID of that layout's parent
|
/// Gives a channel and ID to a layout task, as well as the ID of that layout's parent
|
||||||
AttachLayoutMsg(NewLayoutInfo),
|
AttachLayoutMsg(NewLayoutInfo),
|
||||||
/// Executes a standalone script.
|
|
||||||
ExecuteMsg(PipelineId, Url),
|
|
||||||
/// Instructs the script task to send a navigate message to the constellation.
|
/// Instructs the script task to send a navigate message to the constellation.
|
||||||
NavigateMsg(NavigationDirection),
|
NavigateMsg(NavigationDirection),
|
||||||
/// Sends a DOM event.
|
/// Sends a DOM event.
|
||||||
|
@ -533,7 +529,6 @@ impl ScriptTask {
|
||||||
// TODO(tkuehn) need to handle auxiliary layouts for iframes
|
// TODO(tkuehn) need to handle auxiliary layouts for iframes
|
||||||
AttachLayoutMsg(new_layout_info) => self.handle_new_layout(new_layout_info),
|
AttachLayoutMsg(new_layout_info) => self.handle_new_layout(new_layout_info),
|
||||||
LoadMsg(id, url) => self.load(id, url),
|
LoadMsg(id, url) => self.load(id, url),
|
||||||
ExecuteMsg(id, url) => self.handle_execute_msg(id, url),
|
|
||||||
SendEventMsg(id, event) => self.handle_event(id, event),
|
SendEventMsg(id, event) => self.handle_event(id, event),
|
||||||
FireTimerMsg(id, timer_data) => self.handle_fire_timer_msg(id, timer_data),
|
FireTimerMsg(id, timer_data) => self.handle_fire_timer_msg(id, timer_data),
|
||||||
NavigateMsg(direction) => self.handle_navigate_msg(direction),
|
NavigateMsg(direction) => self.handle_navigate_msg(direction),
|
||||||
|
@ -564,28 +559,6 @@ impl ScriptTask {
|
||||||
parent_page_tree.inner.push(new_page_tree);
|
parent_page_tree.inner.push(new_page_tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles a request to execute a script.
|
|
||||||
fn handle_execute_msg(&mut self, id: PipelineId, url: Url) {
|
|
||||||
debug!("script: Received url `%s` to execute", url.to_str());
|
|
||||||
|
|
||||||
let page_tree = self.page_tree.find(id).expect("ScriptTask: received fire timer msg for a
|
|
||||||
pipeline ID not associated with this script task. This is a bug.");
|
|
||||||
let compartment = page_tree.page.js_info.get_ref().js_compartment;
|
|
||||||
let cx = page_tree.page.js_info.get_ref().js_context;
|
|
||||||
|
|
||||||
match read_whole_file(&Path(url.path)) {
|
|
||||||
Err(msg) => println(fmt!("Error opening %s: %s", url.to_str(), msg)),
|
|
||||||
|
|
||||||
Ok(bytes) => {
|
|
||||||
compartment.define_functions(debug_fns);
|
|
||||||
cx.evaluate_script(compartment.global_obj,
|
|
||||||
str::from_utf8(bytes),
|
|
||||||
url.path.clone(),
|
|
||||||
1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Handles a timer that fired.
|
/// Handles a timer that fired.
|
||||||
#[fixed_stack_segment]
|
#[fixed_stack_segment]
|
||||||
fn handle_fire_timer_msg(&mut self, id: PipelineId, timer_data: ~TimerData) {
|
fn handle_fire_timer_msg(&mut self, id: PipelineId, timer_data: ~TimerData) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue