Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of changes #515

Merged
merged 25 commits into from Jun 14, 2013
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a53a7f6
Add link following and refactor the profiler.
Jun 6, 2013
9085b88
Implement scrolling and better zooming
Jun 6, 2013
abe6a06
Update rust-layers for GL_LINEAR zooming
pcwalton Jun 6, 2013
bf4df24
Provide an interface to the engine for the script task
Jun 6, 2013
ff1178f
handle relative url's when clicking
Jun 6, 2013
0bbf2fc
Refactor flow tree construction and actually use display property.
Jun 8, 2013
1fbfd7d
Implement horizontal scrolling and pinch-to-zoom
pcwalton Jun 9, 2013
7b28462
Send status messages to the compositor
Jun 7, 2013
a9ed2d8
Spin the event loop every 50 ms to allow Rust channels to be processed.
pcwalton Jun 10, 2013
e50cee9
Resolve relative URLs that begin with '//'
pcwalton Jun 10, 2013
f3ad95f
Added a command-line argument for rendering tiles at higher resolutions
Jun 11, 2013
1aa8d64
Fix URL relativization so that links on Wikipedia work
pcwalton Jun 11, 2013
96b9be6
Add a cheesy progress indicator
pcwalton Jun 11, 2013
204c5b6
Add a spinner for layout
pcwalton Jun 11, 2013
aad5113
Update submodules
pcwalton Jun 12, 2013
162ba83
Fix merge fallout
pcwalton Jun 12, 2013
aee2611
Make script and style display:none
pcwalton Jun 12, 2013
e1b9e01
Fix merge fallout which was disabling all CSS classes.
pcwalton Jun 12, 2013
327e799
test: Add a box model smoketest
pcwalton Jun 12, 2013
b75b2de
Compute percent widths/margins properly and fix numerous small visual…
Jun 4, 2013
4017839
Fix padding
Jun 4, 2013
badf1b8
Vertical margins now contribute to content height.
Jun 4, 2013
f3cdbaf
Stop sorting after every profiler datum comes in.
pcwalton Jun 13, 2013
2ec3412
Fix submodules and test_slam_layout
pcwalton Jun 13, 2013
c35abb2
Update rust-glut
pcwalton Jun 14, 2013
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Provide an interface to the engine for the script task

  • Loading branch information
Tim Kuehn authored and pcwalton committed Jun 12, 2013
commit bf4df245215b1ffe90fab9e7b4781098db708c78
@@ -4,29 +4,21 @@

use compositing::CompositorTask;
use layout::layout_task;
use util::task::spawn_listener;

use core::cell::Cell;
use core::comm::{Chan, Port, SharedChan};
use core::comm::{Port, SharedChan};
use gfx::opts::Opts;
use gfx::render_task::RenderTask;
use gfx::render_task;
use script::engine_interface::{EngineTask, ExitMsg, LoadUrlMsg, Msg};
use script::layout_interface::LayoutTask;
use script::layout_interface;
use script::script_task::{ExecuteMsg, LoadMsg, ScriptMsg, ScriptTask};
use script::script_task;
use servo_net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
use servo_net::resource_task::ResourceTask;
use servo_net::resource_task;
use servo_util::time::{profiler_force_print, ProfilerChan, ProfilerPort, ProfilerTask};
use std::net::url::Url;

pub type EngineTask = Chan<Msg>;

pub enum Msg {
LoadUrlMsg(Url),
ExitMsg(Chan<()>),
}
use servo_util::time::{ProfilerChan, ProfilerPort, ProfilerTask, ForcePrintMsg};

pub struct Engine {
request_port: Port<Msg>,
@@ -41,7 +33,7 @@ pub struct Engine {

impl Drop for Engine {
fn finalize(&self) {
profiler_force_print(self.profiler_task.chan.clone());
self.profiler_task.chan.send(ForcePrintMsg);
}
}

@@ -56,10 +48,13 @@ impl Engine {
profiler_chan: ProfilerChan)
-> EngineTask {
let (script_port, script_chan) = (Cell(script_port), Cell(script_chan));
let (request_port, request_chan) = comm::stream();
let (request_port, request_chan) = (Cell(request_port), SharedChan::new(request_chan));
let request_chan_clone = request_chan.clone();
let profiler_port = Cell(profiler_port);
let opts = Cell(copy *opts);

do spawn_listener::<Msg> |request| {
do task::spawn {
let render_task = RenderTask::new(compositor.clone(),
opts.with_ref(|o| copy *o),
profiler_chan.clone());
@@ -77,22 +72,24 @@ impl Engine {

let script_task = ScriptTask::new(script_port.take(),
script_chan.take(),
request_chan_clone.clone(),
layout_task.clone(),
resource_task.clone(),
image_cache_task.clone());


Engine {
request_port: request,
request_port: request_port.take(),
compositor: compositor.clone(),
render_task: render_task,
resource_task: resource_task.clone(),
image_cache_task: image_cache_task.clone(),
layout_task: layout_task,
script_task: script_task,
profiler_task: profiler_task,
}.run()
}.run();
}
request_chan.clone()
}

fn run(&self) {
@@ -34,7 +34,8 @@ extern mod core_graphics;
extern mod core_text;

use compositing::CompositorTask;
use engine::{Engine, LoadUrlMsg};
use engine::Engine;
use script::engine_interface::{ExitMsg, LoadUrlMsg};

use core::comm::SharedChan;
use gfx::opts;
@@ -121,7 +122,7 @@ fn run(opts: &Opts) {
// Shut the engine down.
debug!("master: Shut down");
let (exit_response_from_engine, exit_chan) = comm::stream();
engine_task.send(engine::ExitMsg(exit_chan));
engine_task.send(ExitMsg(exit_chan));
exit_response_from_engine.recv();
}

@@ -5,11 +5,11 @@
use core::comm::{Chan, Port};

pub fn spawn_listener<A: Owned>(f: ~fn(Port<A>)) -> Chan<A> {
let (setup_po, setup_ch) = comm::stream();
let (setup_port, setup_chan) = comm::stream();
do task::spawn {
let (po, ch) = comm::stream();
setup_ch.send(ch);
f(po);
let (port, chan) = comm::stream();
setup_chan.send(chan);
f(port);
}
setup_po.recv()
setup_port.recv()
}
@@ -0,0 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

//! The high-level interface from script to engine. Using this abstract interface helps reduce
/// coupling between these two components

use core::comm::{Chan, SharedChan};
use std::net::url::Url;

pub type EngineTask = SharedChan<Msg>;

pub enum Msg {
LoadUrlMsg(Url),
ExitMsg(Chan<()>),
}

@@ -65,5 +65,6 @@ pub mod html {
}

pub mod layout_interface;
pub mod engine_interface;
pub mod script_task;

@@ -16,6 +16,7 @@ use layout_interface::{HitTestResponse, LayoutQuery, LayoutResponse, LayoutTask}
use layout_interface::{MatchSelectorsDocumentDamage, QueryMsg, Reflow, ReflowDocumentDamage};
use layout_interface::{ReflowForDisplay, ReflowForScriptQuery, ReflowGoal, ReflowMsg};
use layout_interface;
use engine_interface::{EngineTask, LoadUrlMsg};

use core::cast::transmute;
use core::cell::Cell;
@@ -65,6 +66,7 @@ impl ScriptTask {
/// Creates a new script task.
pub fn new(script_port: Port<ScriptMsg>,
script_chan: SharedChan<ScriptMsg>,
engine_task: EngineTask,
layout_task: LayoutTask,
resource_task: ResourceTask,
image_cache_task: ImageCacheTask)
@@ -78,6 +80,7 @@ impl ScriptTask {
let script_context = ScriptContext::new(layout_task.clone(),
script_port.take(),
script_chan_copy.clone(),
engine_task.clone(),
resource_task.clone(),
image_cache_task.clone());
script_context.start();
@@ -117,6 +120,9 @@ pub struct ScriptContext {
/// messages.
script_chan: SharedChan<ScriptMsg>,

/// For communicating load url messages to the engine
engine_task: EngineTask,

/// The JavaScript runtime.
js_runtime: js::rust::rt,
/// The JavaScript context.
@@ -168,6 +174,7 @@ impl ScriptContext {
pub fn new(layout_task: LayoutTask,
script_port: Port<ScriptMsg>,
script_chan: SharedChan<ScriptMsg>,
engine_task: EngineTask,
resource_task: ResourceTask,
img_cache_task: ImageCacheTask)
-> @mut ScriptContext {
@@ -191,6 +198,8 @@ impl ScriptContext {
script_port: script_port,
script_chan: script_chan,

engine_task: engine_task,

js_runtime: js_runtime,
js_context: js_context,
js_compartment: compartment,
@@ -552,7 +561,7 @@ impl ScriptContext {
debug!("clicked on link to %?", attr.value);
let url = from_str(attr.value);
match url {
Ok(url) => self.script_chan.send(LoadMsg(url)),
Ok(url) => self.engine_task.send(LoadUrlMsg(url)),
Err(msg) => debug!(msg)
};
break;
@@ -8,6 +8,9 @@ use core::cell::Cell;
use core::comm::{Port, SharedChan};
use std::sort::tim_sort;

pub type ProfilerChan = SharedChan<ProfilerMsg>;
pub type ProfilerPort = Port<ProfilerMsg>;

#[deriving(Eq)]
pub enum ProfilerCategory {
CompositingCategory,
@@ -26,6 +29,29 @@ pub enum ProfilerCategory {
// hackish but helps prevent errors when adding new categories
NUM_BUCKETS,
}
// FIXME(#5873) this should be initialized by a NUM_BUCKETS cast,
static BUCKETS: uint = 13;

pub enum ProfilerMsg {
// Normal message used for reporting time
TimeMsg(ProfilerCategory, f64),
// Message used to force print the profiling metrics
ForcePrintMsg,
}

// front-end representation of the profiler used to communicate with the profiler context
pub struct ProfilerTask {
chan: ProfilerChan,
}

// back end of the profiler that handles data aggregation and performance metrics
pub struct ProfilerContext {
port: ProfilerPort,
buckets: ~[(ProfilerCategory, ~[f64])],
verbose: bool,
period: f64,
last_print: f64,
}

impl ProfilerCategory {

@@ -76,20 +102,6 @@ impl ProfilerCategory {
fmt!("%s%?", padding, self)
}
}
// FIXME(#5873) this should be initialized by a NUM_BUCKETS cast,
static BUCKETS: uint = 13;

pub enum ProfilerMsg {
// Normal message used for reporting time
TimeMsg(ProfilerCategory, f64),
// Message used to force print the profiling metrics
ForcePrintMsg,
}
pub type ProfilerChan = SharedChan<ProfilerMsg>;
pub type ProfilerPort = Port<ProfilerMsg>;
pub struct ProfilerTask {
chan: ProfilerChan,
}

impl ProfilerTask {
pub fn new(profiler_port: ProfilerPort,
@@ -109,14 +121,6 @@ impl ProfilerTask {
}
}

pub struct ProfilerContext {
port: ProfilerPort,
buckets: ~[(ProfilerCategory, ~[f64])],
verbose: bool,
period: f64,
mut last_print: f64,
}

impl ProfilerContext {
pub fn new(port: ProfilerPort, period: Option<f64>) -> ProfilerContext {
let (verbose, period) = match period {
@@ -197,11 +201,6 @@ pub fn profile<T>(category: ProfilerCategory,
return val;
}


pub fn profiler_force_print(profiler_chan: ProfilerChan) {
profiler_chan.send(ForcePrintMsg);
}

pub fn time<T>(msg: &str, callback: &fn() -> T) -> T{
let start_time = precise_time_ns();
let val = callback();
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.