mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Use opts as a global, to avoid cloning and passing the struct all over the code.
This commit is contained in:
parent
a983debaf1
commit
076495db94
20 changed files with 108 additions and 132 deletions
|
@ -42,7 +42,7 @@ use servo_msg::constellation_msg::{LoadData, PipelineId, ResizedWindowMsg, Windo
|
||||||
use servo_msg::constellation_msg;
|
use servo_msg::constellation_msg;
|
||||||
use servo_util::geometry::{PagePx, ScreenPx, ViewportPx};
|
use servo_util::geometry::{PagePx, ScreenPx, ViewportPx};
|
||||||
use servo_util::memory::MemoryProfilerChan;
|
use servo_util::memory::MemoryProfilerChan;
|
||||||
use servo_util::opts::Opts;
|
use servo_util::opts;
|
||||||
use servo_util::time::{profile, TimeProfilerChan};
|
use servo_util::time::{profile, TimeProfilerChan};
|
||||||
use servo_util::{memory, time};
|
use servo_util::{memory, time};
|
||||||
use std::io::timer::sleep;
|
use std::io::timer::sleep;
|
||||||
|
@ -112,9 +112,6 @@ pub struct IOCompositor<Window: WindowMethods> {
|
||||||
/// many times for a single page.
|
/// many times for a single page.
|
||||||
got_load_complete_message: bool,
|
got_load_complete_message: bool,
|
||||||
|
|
||||||
/// The command line option flags.
|
|
||||||
opts: Opts,
|
|
||||||
|
|
||||||
/// The channel on which messages can be sent to the constellation.
|
/// The channel on which messages can be sent to the constellation.
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
|
|
||||||
|
@ -137,7 +134,6 @@ enum ShutdownState {
|
||||||
|
|
||||||
impl<Window: WindowMethods> IOCompositor<Window> {
|
impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
fn new(window: Rc<Window>,
|
fn new(window: Rc<Window>,
|
||||||
opts: Opts,
|
|
||||||
port: Receiver<Msg>,
|
port: Receiver<Msg>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
|
@ -150,11 +146,10 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
let window_size = window.framebuffer_size();
|
let window_size = window.framebuffer_size();
|
||||||
let hidpi_factor = window.hidpi_factor();
|
let hidpi_factor = window.hidpi_factor();
|
||||||
|
|
||||||
let show_debug_borders = opts.show_debug_borders;
|
let show_debug_borders = opts::get().show_debug_borders;
|
||||||
IOCompositor {
|
IOCompositor {
|
||||||
window: window,
|
window: window,
|
||||||
port: port,
|
port: port,
|
||||||
opts: opts,
|
|
||||||
context: rendergl::RenderContext::new(CompositorTask::create_graphics_context(),
|
context: rendergl::RenderContext::new(CompositorTask::create_graphics_context(),
|
||||||
show_debug_borders),
|
show_debug_borders),
|
||||||
root_pipeline: None,
|
root_pipeline: None,
|
||||||
|
@ -183,13 +178,11 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(window: Rc<Window>,
|
pub fn create(window: Rc<Window>,
|
||||||
opts: Opts,
|
|
||||||
port: Receiver<Msg>,
|
port: Receiver<Msg>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan) {
|
memory_profiler_chan: MemoryProfilerChan) {
|
||||||
let mut compositor = IOCompositor::new(window,
|
let mut compositor = IOCompositor::new(window,
|
||||||
opts,
|
|
||||||
port,
|
port,
|
||||||
constellation_chan,
|
constellation_chan,
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
|
@ -373,7 +366,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
|
|
||||||
fn has_render_msg_tracking(&self) -> bool {
|
fn has_render_msg_tracking(&self) -> bool {
|
||||||
// only track RenderMsg's if the compositor outputs to a file.
|
// only track RenderMsg's if the compositor outputs to a file.
|
||||||
self.opts.output_file.is_some()
|
opts::get().output_file.is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_outstanding_render_msgs(&self) -> bool {
|
fn has_outstanding_render_msgs(&self) -> bool {
|
||||||
|
@ -440,7 +433,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
let root_layer = CompositorData::new_layer(frame_tree.pipeline.clone(),
|
let root_layer = CompositorData::new_layer(frame_tree.pipeline.clone(),
|
||||||
layer_properties,
|
layer_properties,
|
||||||
WantsScrollEvents,
|
WantsScrollEvents,
|
||||||
self.opts.tile_size);
|
opts::get().tile_size);
|
||||||
|
|
||||||
match frame_rect {
|
match frame_rect {
|
||||||
Some(ref frame_rect) => {
|
Some(ref frame_rect) => {
|
||||||
|
@ -500,7 +493,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
let first_child = CompositorData::new_layer(root_layer_pipeline.clone(),
|
let first_child = CompositorData::new_layer(root_layer_pipeline.clone(),
|
||||||
layer_properties,
|
layer_properties,
|
||||||
DoesntWantScrollEvents,
|
DoesntWantScrollEvents,
|
||||||
self.opts.tile_size);
|
opts::get().tile_size);
|
||||||
|
|
||||||
// Add the first child / base layer to the front of the child list, so that
|
// Add the first child / base layer to the front of the child list, so that
|
||||||
// child iframe layers are rendered on top of the base layer. These iframe
|
// child iframe layers are rendered on top of the base layer. These iframe
|
||||||
|
@ -671,7 +664,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
FinishedWindowEvent => {
|
FinishedWindowEvent => {
|
||||||
let exit = self.opts.exit_after_load;
|
let exit = opts::get().exit_after_load;
|
||||||
if exit {
|
if exit {
|
||||||
debug!("shutting down the constellation for FinishedWindowEvent");
|
debug!("shutting down the constellation for FinishedWindowEvent");
|
||||||
let ConstellationChan(ref chan) = self.constellation_chan;
|
let ConstellationChan(ref chan) = self.constellation_chan;
|
||||||
|
@ -758,9 +751,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn device_pixels_per_screen_px(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32> {
|
fn device_pixels_per_screen_px(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32> {
|
||||||
match self.opts.device_pixels_per_px {
|
match opts::get().device_pixels_per_px {
|
||||||
Some(device_pixels_per_px) => device_pixels_per_px,
|
Some(device_pixels_per_px) => device_pixels_per_px,
|
||||||
None => match self.opts.output_file {
|
None => match opts::get().output_file {
|
||||||
Some(_) => ScaleFactor(1.0),
|
Some(_) => ScaleFactor(1.0),
|
||||||
None => self.hidpi_factor
|
None => self.hidpi_factor
|
||||||
}
|
}
|
||||||
|
@ -917,7 +910,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn composite(&mut self) {
|
fn composite(&mut self) {
|
||||||
let output_image = self.opts.output_file.is_some() &&
|
let output_image = opts::get().output_file.is_some() &&
|
||||||
self.is_ready_to_render_image_output();
|
self.is_ready_to_render_image_output();
|
||||||
|
|
||||||
let mut framebuffer_ids = vec!();
|
let mut framebuffer_ids = vec!();
|
||||||
|
@ -959,7 +952,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
});
|
});
|
||||||
|
|
||||||
if output_image {
|
if output_image {
|
||||||
let path = from_str::<Path>(self.opts.output_file.as_ref().unwrap().as_slice()).unwrap();
|
let path = from_str::<Path>(opts::get().output_file.as_ref().unwrap().as_slice()).unwrap();
|
||||||
let mut pixels = gl2::read_pixels(0, 0,
|
let mut pixels = gl2::read_pixels(0, 0,
|
||||||
width as gl2::GLsizei,
|
width as gl2::GLsizei,
|
||||||
height as gl2::GLsizei,
|
height as gl2::GLsizei,
|
||||||
|
@ -998,7 +991,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
|
|
||||||
self.window.present();
|
self.window.present();
|
||||||
|
|
||||||
let exit = self.opts.exit_after_load;
|
let exit = opts::get().exit_after_load;
|
||||||
if exit {
|
if exit {
|
||||||
debug!("shutting down the constellation for exit_after_load");
|
debug!("shutting down the constellation for exit_after_load");
|
||||||
let ConstellationChan(ref chan) = self.constellation_chan;
|
let ConstellationChan(ref chan) = self.constellation_chan;
|
||||||
|
|
|
@ -19,7 +19,6 @@ use servo_msg::compositor_msg::{Epoch, LayerId, LayerMetadata, ReadyState};
|
||||||
use servo_msg::compositor_msg::{RenderListener, RenderState, ScriptListener, ScrollPolicy};
|
use servo_msg::compositor_msg::{RenderListener, RenderState, ScriptListener, ScrollPolicy};
|
||||||
use servo_msg::constellation_msg::{ConstellationChan, PipelineId};
|
use servo_msg::constellation_msg::{ConstellationChan, PipelineId};
|
||||||
use servo_util::memory::MemoryProfilerChan;
|
use servo_util::memory::MemoryProfilerChan;
|
||||||
use servo_util::opts::Opts;
|
|
||||||
use servo_util::time::TimeProfilerChan;
|
use servo_util::time::TimeProfilerChan;
|
||||||
use std::comm::{channel, Sender, Receiver};
|
use std::comm::{channel, Sender, Receiver};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -200,7 +199,6 @@ impl CompositorTask {
|
||||||
|
|
||||||
pub fn create<Window: WindowMethods>(
|
pub fn create<Window: WindowMethods>(
|
||||||
window: Option<Rc<Window>>,
|
window: Option<Rc<Window>>,
|
||||||
opts: Opts,
|
|
||||||
port: Receiver<Msg>,
|
port: Receiver<Msg>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
|
@ -209,7 +207,6 @@ impl CompositorTask {
|
||||||
match window {
|
match window {
|
||||||
Some(window) => {
|
Some(window) => {
|
||||||
compositor::IOCompositor::create(window,
|
compositor::IOCompositor::create(window,
|
||||||
opts,
|
|
||||||
port,
|
port,
|
||||||
constellation_chan.clone(),
|
constellation_chan.clone(),
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
|
|
|
@ -25,7 +25,7 @@ use gfx::font_cache_task::FontCacheTask;
|
||||||
use servo_net::resource_task::ResourceTask;
|
use servo_net::resource_task::ResourceTask;
|
||||||
use servo_net::resource_task;
|
use servo_net::resource_task;
|
||||||
use servo_util::geometry::PagePx;
|
use servo_util::geometry::PagePx;
|
||||||
use servo_util::opts::Opts;
|
use servo_util::opts;
|
||||||
use servo_util::time::TimeProfilerChan;
|
use servo_util::time::TimeProfilerChan;
|
||||||
use servo_util::task::spawn_named;
|
use servo_util::task::spawn_named;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
@ -50,7 +50,6 @@ pub struct Constellation<LTF, STF> {
|
||||||
pending_sizes: HashMap<(PipelineId, SubpageId), TypedRect<PagePx, f32>>,
|
pending_sizes: HashMap<(PipelineId, SubpageId), TypedRect<PagePx, f32>>,
|
||||||
pub time_profiler_chan: TimeProfilerChan,
|
pub time_profiler_chan: TimeProfilerChan,
|
||||||
pub window_size: WindowSizeData,
|
pub window_size: WindowSizeData,
|
||||||
pub opts: Opts,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stores the Id of the outermost frame's pipeline, along with a vector of children frames
|
/// Stores the Id of the outermost frame's pipeline, along with a vector of children frames
|
||||||
|
@ -241,7 +240,6 @@ impl NavigationContext {
|
||||||
|
|
||||||
impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
pub fn start(compositor_chan: CompositorChan,
|
pub fn start(compositor_chan: CompositorChan,
|
||||||
opts: &Opts,
|
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
|
@ -250,7 +248,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
-> ConstellationChan {
|
-> ConstellationChan {
|
||||||
let (constellation_port, constellation_chan) = ConstellationChan::new();
|
let (constellation_port, constellation_chan) = ConstellationChan::new();
|
||||||
let constellation_chan_clone = constellation_chan.clone();
|
let constellation_chan_clone = constellation_chan.clone();
|
||||||
let opts_clone = opts.clone();
|
|
||||||
spawn_named("Constellation", proc() {
|
spawn_named("Constellation", proc() {
|
||||||
let mut constellation : Constellation<LTF, STF> = Constellation {
|
let mut constellation : Constellation<LTF, STF> = Constellation {
|
||||||
chan: constellation_chan_clone,
|
chan: constellation_chan_clone,
|
||||||
|
@ -267,11 +264,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
pending_sizes: HashMap::new(),
|
pending_sizes: HashMap::new(),
|
||||||
time_profiler_chan: time_profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
window_size: WindowSizeData {
|
window_size: WindowSizeData {
|
||||||
visible_viewport: opts_clone.initial_window_size.as_f32() * ScaleFactor(1.0),
|
visible_viewport: opts::get().initial_window_size.as_f32() * ScaleFactor(1.0),
|
||||||
initial_viewport: opts_clone.initial_window_size.as_f32() * ScaleFactor(1.0),
|
initial_viewport: opts::get().initial_window_size.as_f32() * ScaleFactor(1.0),
|
||||||
device_pixel_ratio: ScaleFactor(1.0),
|
device_pixel_ratio: ScaleFactor(1.0),
|
||||||
},
|
},
|
||||||
opts: opts_clone,
|
|
||||||
};
|
};
|
||||||
constellation.run();
|
constellation.run();
|
||||||
});
|
});
|
||||||
|
@ -304,7 +300,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
self.resource_task.clone(),
|
self.resource_task.clone(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
self.window_size,
|
self.window_size,
|
||||||
self.opts.clone(),
|
|
||||||
script_pipeline,
|
script_pipeline,
|
||||||
load_data);
|
load_data);
|
||||||
pipe.load();
|
pipe.load();
|
||||||
|
@ -405,7 +400,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
fn handle_failure_msg(&mut self, pipeline_id: PipelineId, subpage_id: Option<SubpageId>) {
|
fn handle_failure_msg(&mut self, pipeline_id: PipelineId, subpage_id: Option<SubpageId>) {
|
||||||
debug!("handling failure message from pipeline {:?}, {:?}", pipeline_id, subpage_id);
|
debug!("handling failure message from pipeline {:?}, {:?}", pipeline_id, subpage_id);
|
||||||
|
|
||||||
if self.opts.hard_fail {
|
if opts::get().hard_fail {
|
||||||
// It's quite difficult to make Servo exit cleanly if some tasks have failed.
|
// It's quite difficult to make Servo exit cleanly if some tasks have failed.
|
||||||
// Hard fail exists for test runners so we crash and that's good enough.
|
// Hard fail exists for test runners so we crash and that's good enough.
|
||||||
let mut stderr = io::stderr();
|
let mut stderr = io::stderr();
|
||||||
|
|
|
@ -15,7 +15,6 @@ use servo_msg::constellation_msg::{LoadData, WindowSizeData};
|
||||||
use servo_net::image_cache_task::ImageCacheTask;
|
use servo_net::image_cache_task::ImageCacheTask;
|
||||||
use gfx::font_cache_task::FontCacheTask;
|
use gfx::font_cache_task::FontCacheTask;
|
||||||
use servo_net::resource_task::ResourceTask;
|
use servo_net::resource_task::ResourceTask;
|
||||||
use servo_util::opts::Opts;
|
|
||||||
use servo_util::time::TimeProfilerChan;
|
use servo_util::time::TimeProfilerChan;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
@ -55,7 +54,6 @@ impl Pipeline {
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
window_size: WindowSizeData,
|
window_size: WindowSizeData,
|
||||||
opts: Opts,
|
|
||||||
script_pipeline: Option<Rc<Pipeline>>,
|
script_pipeline: Option<Rc<Pipeline>>,
|
||||||
load_data: LoadData)
|
load_data: LoadData)
|
||||||
-> Pipeline {
|
-> Pipeline {
|
||||||
|
@ -107,7 +105,6 @@ impl Pipeline {
|
||||||
constellation_chan.clone(),
|
constellation_chan.clone(),
|
||||||
font_cache_task.clone(),
|
font_cache_task.clone(),
|
||||||
failure.clone(),
|
failure.clone(),
|
||||||
opts.clone(),
|
|
||||||
time_profiler_chan.clone(),
|
time_profiler_chan.clone(),
|
||||||
render_shutdown_chan);
|
render_shutdown_chan);
|
||||||
|
|
||||||
|
@ -122,7 +119,6 @@ impl Pipeline {
|
||||||
resource_task,
|
resource_task,
|
||||||
image_cache_task,
|
image_cache_task,
|
||||||
font_cache_task,
|
font_cache_task,
|
||||||
opts.clone(),
|
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
layout_shutdown_chan);
|
layout_shutdown_chan);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ use geom::{Point2D, Rect, SideOffsets2D, Size2D, Matrix2D};
|
||||||
use libc::uintptr_t;
|
use libc::uintptr_t;
|
||||||
use servo_net::image::base::Image;
|
use servo_net::image::base::Image;
|
||||||
use servo_util::geometry::Au;
|
use servo_util::geometry::Au;
|
||||||
|
use servo_util::opts;
|
||||||
use servo_util::range::Range;
|
use servo_util::range::Range;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -562,7 +563,7 @@ impl DisplayItem {
|
||||||
&text.range,
|
&text.range,
|
||||||
baseline_origin,
|
baseline_origin,
|
||||||
text.text_color,
|
text.text_color,
|
||||||
render_context.opts.enable_text_antialiasing
|
opts::get().enable_text_antialiasing
|
||||||
);
|
);
|
||||||
|
|
||||||
// Undo the transform, only when we did one.
|
// Undo the transform, only when we did one.
|
||||||
|
|
|
@ -18,13 +18,11 @@ use libc::size_t;
|
||||||
use png::{RGB8, RGBA8, K8, KA8};
|
use png::{RGB8, RGBA8, K8, KA8};
|
||||||
use servo_net::image::base::Image;
|
use servo_net::image::base::Image;
|
||||||
use servo_util::geometry::Au;
|
use servo_util::geometry::Au;
|
||||||
use servo_util::opts::Opts;
|
|
||||||
use sync::Arc;
|
use sync::Arc;
|
||||||
|
|
||||||
pub struct RenderContext<'a> {
|
pub struct RenderContext<'a> {
|
||||||
pub draw_target: &'a DrawTarget,
|
pub draw_target: &'a DrawTarget,
|
||||||
pub font_ctx: &'a mut Box<FontContext>,
|
pub font_ctx: &'a mut Box<FontContext>,
|
||||||
pub opts: &'a Opts,
|
|
||||||
/// The rectangle that this context encompasses in page coordinates.
|
/// The rectangle that this context encompasses in page coordinates.
|
||||||
pub page_rect: Rect<f32>,
|
pub page_rect: Rect<f32>,
|
||||||
/// The rectangle that this context encompasses in screen coordinates (pixels).
|
/// The rectangle that this context encompasses in screen coordinates (pixels).
|
||||||
|
|
|
@ -26,7 +26,7 @@ use servo_msg::constellation_msg::{ConstellationChan, Failure, FailureMsg, Pipel
|
||||||
use servo_msg::constellation_msg::{RendererReadyMsg};
|
use servo_msg::constellation_msg::{RendererReadyMsg};
|
||||||
use servo_msg::platform::surface::NativeSurfaceAzureMethods;
|
use servo_msg::platform::surface::NativeSurfaceAzureMethods;
|
||||||
use servo_util::geometry::{Au, mod};
|
use servo_util::geometry::{Au, mod};
|
||||||
use servo_util::opts::Opts;
|
use servo_util::opts;
|
||||||
use servo_util::smallvec::{SmallVec, SmallVec1};
|
use servo_util::smallvec::{SmallVec, SmallVec1};
|
||||||
use servo_util::task::spawn_named_with_send_on_failure;
|
use servo_util::task::spawn_named_with_send_on_failure;
|
||||||
use servo_util::time::{TimeProfilerChan, profile};
|
use servo_util::time::{TimeProfilerChan, profile};
|
||||||
|
@ -99,7 +99,6 @@ pub struct RenderTask<C> {
|
||||||
compositor: C,
|
compositor: C,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
font_ctx: Box<FontContext>,
|
font_ctx: Box<FontContext>,
|
||||||
opts: Opts,
|
|
||||||
|
|
||||||
/// A channel to the time profiler.
|
/// A channel to the time profiler.
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
|
@ -154,7 +153,6 @@ impl<C:RenderListener + Send> RenderTask<C> {
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
failure_msg: Failure,
|
failure_msg: Failure,
|
||||||
opts: Opts,
|
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
shutdown_chan: Sender<()>) {
|
shutdown_chan: Sender<()>) {
|
||||||
|
|
||||||
|
@ -165,7 +163,7 @@ impl<C:RenderListener + Send> RenderTask<C> {
|
||||||
{ // Ensures RenderTask and graphics context are destroyed before shutdown msg
|
{ // Ensures RenderTask and graphics context are destroyed before shutdown msg
|
||||||
let native_graphics_context = compositor.get_graphics_metadata().map(
|
let native_graphics_context = compositor.get_graphics_metadata().map(
|
||||||
|md| NativePaintingGraphicsContext::from_metadata(&md));
|
|md| NativePaintingGraphicsContext::from_metadata(&md));
|
||||||
let cpu_painting = opts.cpu_painting;
|
let cpu_painting = opts::get().cpu_painting;
|
||||||
|
|
||||||
// FIXME: rust/#5967
|
// FIXME: rust/#5967
|
||||||
let mut render_task = RenderTask {
|
let mut render_task = RenderTask {
|
||||||
|
@ -174,7 +172,6 @@ impl<C:RenderListener + Send> RenderTask<C> {
|
||||||
compositor: compositor,
|
compositor: compositor,
|
||||||
constellation_chan: constellation_chan,
|
constellation_chan: constellation_chan,
|
||||||
font_ctx: box FontContext::new(fc.clone()),
|
font_ctx: box FontContext::new(fc.clone()),
|
||||||
opts: opts,
|
|
||||||
time_profiler_chan: time_profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
|
|
||||||
graphics_context: if cpu_painting {
|
graphics_context: if cpu_painting {
|
||||||
|
@ -342,7 +339,6 @@ impl<C:RenderListener + Send> RenderTask<C> {
|
||||||
let mut ctx = RenderContext {
|
let mut ctx = RenderContext {
|
||||||
draw_target: &draw_target,
|
draw_target: &draw_target,
|
||||||
font_ctx: &mut self.font_ctx,
|
font_ctx: &mut self.font_ctx,
|
||||||
opts: &self.opts,
|
|
||||||
page_rect: tile.page_rect,
|
page_rect: tile.page_rect,
|
||||||
screen_rect: tile.screen_rect,
|
screen_rect: tile.screen_rect,
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,6 +58,7 @@ use script::dom::node::{CommentNodeTypeId, DoctypeNodeTypeId, DocumentFragmentNo
|
||||||
use script::dom::node::{DocumentNodeTypeId, ElementNodeTypeId, ProcessingInstructionNodeTypeId};
|
use script::dom::node::{DocumentNodeTypeId, ElementNodeTypeId, ProcessingInstructionNodeTypeId};
|
||||||
use script::dom::node::{TextNodeTypeId};
|
use script::dom::node::{TextNodeTypeId};
|
||||||
use script::dom::htmlobjectelement::is_image_data;
|
use script::dom::htmlobjectelement::is_image_data;
|
||||||
|
use servo_util::opts;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::sync::atomics::Relaxed;
|
use std::sync::atomics::Relaxed;
|
||||||
use style::ComputedValues;
|
use style::ComputedValues;
|
||||||
|
@ -83,8 +84,8 @@ pub enum ConstructionResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConstructionResult {
|
impl ConstructionResult {
|
||||||
pub fn swap_out(&mut self, layout_context: &LayoutContext) -> ConstructionResult {
|
pub fn swap_out(&mut self) -> ConstructionResult {
|
||||||
if layout_context.shared.opts.incremental_layout {
|
if opts::get().incremental_layout {
|
||||||
return (*self).clone();
|
return (*self).clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +353,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
inline_flow.minimum_depth_below_baseline = descent;
|
inline_flow.minimum_depth_below_baseline = descent;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline_flow_ref.finish(self.layout_context);
|
inline_flow_ref.finish();
|
||||||
|
|
||||||
if flow.need_anonymous_flow(&*inline_flow_ref) {
|
if flow.need_anonymous_flow(&*inline_flow_ref) {
|
||||||
flow_list.push(inline_flow_ref)
|
flow_list.push(inline_flow_ref)
|
||||||
|
@ -370,7 +371,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
&mut InlineFragmentsAccumulator,
|
&mut InlineFragmentsAccumulator,
|
||||||
abs_descendants: &mut Descendants,
|
abs_descendants: &mut Descendants,
|
||||||
first_fragment: &mut bool) {
|
first_fragment: &mut bool) {
|
||||||
match kid.swap_out_construction_result(self.layout_context) {
|
match kid.swap_out_construction_result() {
|
||||||
NoConstructionResult => {}
|
NoConstructionResult => {}
|
||||||
FlowConstructionResult(kid_flow, kid_abs_descendants) => {
|
FlowConstructionResult(kid_flow, kid_abs_descendants) => {
|
||||||
// If kid_flow is TableCaptionFlow, kid_flow should be added under
|
// If kid_flow is TableCaptionFlow, kid_flow should be added under
|
||||||
|
@ -522,7 +523,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// The flow is done.
|
// The flow is done.
|
||||||
flow.finish(self.layout_context);
|
flow.finish();
|
||||||
|
|
||||||
// Set up the absolute descendants.
|
// Set up the absolute descendants.
|
||||||
let is_positioned = flow.as_block().is_positioned();
|
let is_positioned = flow.as_block().is_positioned();
|
||||||
|
@ -573,7 +574,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
if kid.get_pseudo_element_type() != Normal {
|
if kid.get_pseudo_element_type() != Normal {
|
||||||
self.process(&kid);
|
self.process(&kid);
|
||||||
}
|
}
|
||||||
match kid.swap_out_construction_result(self.layout_context) {
|
match kid.swap_out_construction_result() {
|
||||||
NoConstructionResult => {}
|
NoConstructionResult => {}
|
||||||
FlowConstructionResult(flow, kid_abs_descendants) => {
|
FlowConstructionResult(flow, kid_abs_descendants) => {
|
||||||
// {ib} split. Flush the accumulator to our new split and make a new
|
// {ib} split. Flush the accumulator to our new split and make a new
|
||||||
|
@ -757,7 +758,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
table_wrapper_flow: &mut FlowRef,
|
table_wrapper_flow: &mut FlowRef,
|
||||||
node: &ThreadSafeLayoutNode) {
|
node: &ThreadSafeLayoutNode) {
|
||||||
for kid in node.children() {
|
for kid in node.children() {
|
||||||
match kid.swap_out_construction_result(self.layout_context) {
|
match kid.swap_out_construction_result() {
|
||||||
NoConstructionResult | ConstructionItemConstructionResult(_) => {}
|
NoConstructionResult | ConstructionItemConstructionResult(_) => {}
|
||||||
FlowConstructionResult(kid_flow, _) => {
|
FlowConstructionResult(kid_flow, _) => {
|
||||||
// Only kid flows with table-caption are matched here.
|
// Only kid flows with table-caption are matched here.
|
||||||
|
@ -794,7 +795,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
self.generate_anonymous_missing_child(consecutive_siblings, &mut anonymous_flow, node);
|
self.generate_anonymous_missing_child(consecutive_siblings, &mut anonymous_flow, node);
|
||||||
}
|
}
|
||||||
// The flow is done.
|
// The flow is done.
|
||||||
anonymous_flow.finish(self.layout_context);
|
anonymous_flow.finish();
|
||||||
flow.add_new_child(anonymous_flow);
|
flow.add_new_child(anonymous_flow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,7 +837,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// The flow is done.
|
// The flow is done.
|
||||||
wrapper_flow.finish(self.layout_context);
|
wrapper_flow.finish();
|
||||||
let is_positioned = wrapper_flow.as_block().is_positioned();
|
let is_positioned = wrapper_flow.as_block().is_positioned();
|
||||||
let is_fixed_positioned = wrapper_flow.as_block().is_fixed();
|
let is_fixed_positioned = wrapper_flow.as_block().is_fixed();
|
||||||
let is_absolutely_positioned = wrapper_flow.as_block().is_absolutely_positioned();
|
let is_absolutely_positioned = wrapper_flow.as_block().is_absolutely_positioned();
|
||||||
|
@ -918,7 +919,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
for kid in node.children() {
|
for kid in node.children() {
|
||||||
// CSS 2.1 § 17.2.1. Treat all non-column child fragments of `table-column-group`
|
// CSS 2.1 § 17.2.1. Treat all non-column child fragments of `table-column-group`
|
||||||
// as `display: none`.
|
// as `display: none`.
|
||||||
match kid.swap_out_construction_result(self.layout_context) {
|
match kid.swap_out_construction_result() {
|
||||||
ConstructionItemConstructionResult(TableColumnFragmentConstructionItem(
|
ConstructionItemConstructionResult(TableColumnFragmentConstructionItem(
|
||||||
fragment)) => {
|
fragment)) => {
|
||||||
col_fragments.push(fragment);
|
col_fragments.push(fragment);
|
||||||
|
@ -933,7 +934,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
}
|
}
|
||||||
let flow = box TableColGroupFlow::from_node_and_fragments(node, fragment, col_fragments);
|
let flow = box TableColGroupFlow::from_node_and_fragments(node, fragment, col_fragments);
|
||||||
let mut flow = FlowRef::new(flow as Box<Flow>);
|
let mut flow = FlowRef::new(flow as Box<Flow>);
|
||||||
flow.finish(self.layout_context);
|
flow.finish();
|
||||||
|
|
||||||
FlowConstructionResult(flow, Descendants::new())
|
FlowConstructionResult(flow, Descendants::new())
|
||||||
}
|
}
|
||||||
|
@ -987,7 +988,7 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
||||||
// results of children.
|
// results of children.
|
||||||
(display::none, _, _) => {
|
(display::none, _, _) => {
|
||||||
for child in node.children() {
|
for child in node.children() {
|
||||||
drop(child.swap_out_construction_result(self.layout_context))
|
drop(child.swap_out_construction_result())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1099,7 +1100,7 @@ trait NodeUtils {
|
||||||
|
|
||||||
/// Replaces the flow construction result in a node with `NoConstructionResult` and returns the
|
/// Replaces the flow construction result in a node with `NoConstructionResult` and returns the
|
||||||
/// old value.
|
/// old value.
|
||||||
fn swap_out_construction_result(self, layout_context: &LayoutContext) -> ConstructionResult;
|
fn swap_out_construction_result(self) -> ConstructionResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
|
impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
|
||||||
|
@ -1137,11 +1138,11 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn swap_out_construction_result(self, layout_context: &LayoutContext) -> ConstructionResult {
|
fn swap_out_construction_result(self) -> ConstructionResult {
|
||||||
let mut layout_data_ref = self.mutate_layout_data();
|
let mut layout_data_ref = self.mutate_layout_data();
|
||||||
let layout_data = layout_data_ref.as_mut().expect("no layout data");
|
let layout_data = layout_data_ref.as_mut().expect("no layout data");
|
||||||
|
|
||||||
self.get_construction_result(layout_data).swap_out(layout_context)
|
self.get_construction_result(layout_data).swap_out()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1189,7 +1190,7 @@ pub trait FlowConstructionUtils {
|
||||||
///
|
///
|
||||||
/// All flows must be finished at some point, or they will not have their intrinsic inline-sizes
|
/// All flows must be finished at some point, or they will not have their intrinsic inline-sizes
|
||||||
/// properly computed. (This is not, however, a memory safety problem.)
|
/// properly computed. (This is not, however, a memory safety problem.)
|
||||||
fn finish(&mut self, context: &LayoutContext);
|
fn finish(&mut self);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FlowConstructionUtils for FlowRef {
|
impl FlowConstructionUtils for FlowRef {
|
||||||
|
@ -1216,8 +1217,8 @@ impl FlowConstructionUtils for FlowRef {
|
||||||
/// properly computed. (This is not, however, a memory safety problem.)
|
/// properly computed. (This is not, however, a memory safety problem.)
|
||||||
///
|
///
|
||||||
/// This must not be public because only the layout constructor can do this.
|
/// This must not be public because only the layout constructor can do this.
|
||||||
fn finish(&mut self, context: &LayoutContext) {
|
fn finish(&mut self) {
|
||||||
if !context.shared.opts.bubble_inline_sizes_separately {
|
if !opts::get().bubble_inline_sizes_separately {
|
||||||
self.bubble_inline_sizes()
|
self.bubble_inline_sizes()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ use script_traits::UntrustedNodeAddress;
|
||||||
use servo_msg::constellation_msg::ConstellationChan;
|
use servo_msg::constellation_msg::ConstellationChan;
|
||||||
use servo_net::local_image_cache::LocalImageCache;
|
use servo_net::local_image_cache::LocalImageCache;
|
||||||
use servo_util::geometry::Au;
|
use servo_util::geometry::Au;
|
||||||
use servo_util::opts::Opts;
|
|
||||||
use sync::{Arc, Mutex};
|
use sync::{Arc, Mutex};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use style::Stylist;
|
use style::Stylist;
|
||||||
|
@ -75,9 +74,6 @@ pub struct SharedLayoutContext {
|
||||||
/// The URL.
|
/// The URL.
|
||||||
pub url: Url,
|
pub url: Url,
|
||||||
|
|
||||||
/// The command line options.
|
|
||||||
pub opts: Opts,
|
|
||||||
|
|
||||||
/// The dirty rectangle, used during display list building.
|
/// The dirty rectangle, used during display list building.
|
||||||
pub dirty: Rect<Au>,
|
pub dirty: Rect<Au>,
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
use css::node_style::StyledNode;
|
use css::node_style::StyledNode;
|
||||||
use construct::FlowConstructionResult;
|
use construct::FlowConstructionResult;
|
||||||
use context::{LayoutContext, SharedLayoutContext};
|
use context::SharedLayoutContext;
|
||||||
use flow::{Flow, ImmutableFlowUtils, MutableFlowUtils, MutableOwnedFlowUtils};
|
use flow::{Flow, ImmutableFlowUtils, MutableFlowUtils, MutableOwnedFlowUtils};
|
||||||
use flow;
|
use flow;
|
||||||
use flow_ref::FlowRef;
|
use flow_ref::FlowRef;
|
||||||
|
@ -50,7 +50,7 @@ use servo_net::resource_task::{ResourceTask, load_bytes_iter};
|
||||||
use servo_util::geometry::Au;
|
use servo_util::geometry::Au;
|
||||||
use servo_util::geometry;
|
use servo_util::geometry;
|
||||||
use servo_util::logical_geometry::LogicalPoint;
|
use servo_util::logical_geometry::LogicalPoint;
|
||||||
use servo_util::opts::Opts;
|
use servo_util::opts;
|
||||||
use servo_util::smallvec::{SmallVec, SmallVec1, VecLike};
|
use servo_util::smallvec::{SmallVec, SmallVec1, VecLike};
|
||||||
use servo_util::task::spawn_named_with_send_on_failure;
|
use servo_util::task::spawn_named_with_send_on_failure;
|
||||||
use servo_util::time::{TimeProfilerChan, profile};
|
use servo_util::time::{TimeProfilerChan, profile};
|
||||||
|
@ -130,9 +130,6 @@ pub struct LayoutTask {
|
||||||
/// Public interface to the font cache task.
|
/// Public interface to the font cache task.
|
||||||
pub font_cache_task: FontCacheTask,
|
pub font_cache_task: FontCacheTask,
|
||||||
|
|
||||||
/// The command-line options.
|
|
||||||
pub opts: Opts,
|
|
||||||
|
|
||||||
/// Is this the first reflow in this LayoutTask?
|
/// Is this the first reflow in this LayoutTask?
|
||||||
pub first_reflow: Cell<bool>,
|
pub first_reflow: Cell<bool>,
|
||||||
|
|
||||||
|
@ -181,7 +178,6 @@ impl LayoutTaskFactory for LayoutTask {
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
img_cache_task: ImageCacheTask,
|
img_cache_task: ImageCacheTask,
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
opts: Opts,
|
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
shutdown_chan: Sender<()>) {
|
shutdown_chan: Sender<()>) {
|
||||||
let ConstellationChan(con_chan) = constellation_chan.clone();
|
let ConstellationChan(con_chan) = constellation_chan.clone();
|
||||||
|
@ -200,7 +196,6 @@ impl LayoutTaskFactory for LayoutTask {
|
||||||
resource_task,
|
resource_task,
|
||||||
img_cache_task,
|
img_cache_task,
|
||||||
font_cache_task,
|
font_cache_task,
|
||||||
&opts,
|
|
||||||
time_profiler_chan);
|
time_profiler_chan);
|
||||||
layout.start();
|
layout.start();
|
||||||
}
|
}
|
||||||
|
@ -250,14 +245,13 @@ impl LayoutTask {
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
opts: &Opts,
|
|
||||||
time_profiler_chan: TimeProfilerChan)
|
time_profiler_chan: TimeProfilerChan)
|
||||||
-> LayoutTask {
|
-> LayoutTask {
|
||||||
let local_image_cache = Arc::new(Mutex::new(LocalImageCache::new(image_cache_task.clone())));
|
let local_image_cache = Arc::new(Mutex::new(LocalImageCache::new(image_cache_task.clone())));
|
||||||
let screen_size = Size2D(Au(0), Au(0));
|
let screen_size = Size2D(Au(0), Au(0));
|
||||||
let device = Device::new(Screen, opts.initial_window_size.as_f32());
|
let device = Device::new(Screen, opts::get().initial_window_size.as_f32());
|
||||||
let parallel_traversal = if opts.layout_threads != 1 {
|
let parallel_traversal = if opts::get().layout_threads != 1 {
|
||||||
Some(WorkQueue::new("LayoutWorker", opts.layout_threads, ptr::null()))
|
Some(WorkQueue::new("LayoutWorker", opts::get().layout_threads, ptr::null()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
@ -274,7 +268,6 @@ impl LayoutTask {
|
||||||
resource_task: resource_task,
|
resource_task: resource_task,
|
||||||
image_cache_task: image_cache_task.clone(),
|
image_cache_task: image_cache_task.clone(),
|
||||||
font_cache_task: font_cache_task,
|
font_cache_task: font_cache_task,
|
||||||
opts: opts.clone(),
|
|
||||||
first_reflow: Cell::new(true),
|
first_reflow: Cell::new(true),
|
||||||
device: device,
|
device: device,
|
||||||
rw_data: Arc::new(Mutex::new(
|
rw_data: Arc::new(Mutex::new(
|
||||||
|
@ -315,7 +308,6 @@ impl LayoutTask {
|
||||||
stylist: &*rw_data.stylist,
|
stylist: &*rw_data.stylist,
|
||||||
url: (*url).clone(),
|
url: (*url).clone(),
|
||||||
reflow_root: OpaqueNodeMethods::from_layout_node(reflow_root),
|
reflow_root: OpaqueNodeMethods::from_layout_node(reflow_root),
|
||||||
opts: self.opts.clone(),
|
|
||||||
dirty: Rect::zero(),
|
dirty: Rect::zero(),
|
||||||
generation: rw_data.generation,
|
generation: rw_data.generation,
|
||||||
}
|
}
|
||||||
|
@ -484,11 +476,11 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the flow tree root from the root node.
|
/// Retrieves the flow tree root from the root node.
|
||||||
fn get_layout_root(&self, node: LayoutNode, layout_context: &LayoutContext) -> FlowRef {
|
fn get_layout_root(&self, node: LayoutNode) -> FlowRef {
|
||||||
let mut layout_data_ref = node.mutate_layout_data();
|
let mut layout_data_ref = node.mutate_layout_data();
|
||||||
let layout_data = layout_data_ref.as_mut().expect("no layout data for root node");
|
let layout_data = layout_data_ref.as_mut().expect("no layout data for root node");
|
||||||
|
|
||||||
let result = layout_data.data.flow_construction_result.swap_out(layout_context);
|
let result = layout_data.data.flow_construction_result.swap_out();
|
||||||
|
|
||||||
let mut flow = match result {
|
let mut flow = match result {
|
||||||
FlowConstructionResult(mut flow, abs_descendants) => {
|
FlowConstructionResult(mut flow, abs_descendants) => {
|
||||||
|
@ -628,7 +620,7 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.get_layout_root((*node).clone(), &LayoutContext::new(&shared_layout_ctx))
|
self.get_layout_root((*node).clone())
|
||||||
});
|
});
|
||||||
|
|
||||||
profile(time::LayoutRestyleDamagePropagation,
|
profile(time::LayoutRestyleDamagePropagation,
|
||||||
|
@ -642,7 +634,7 @@ impl LayoutTask {
|
||||||
Some((&data.url, data.iframe, self.first_reflow.get())),
|
Some((&data.url, data.iframe, self.first_reflow.get())),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
if shared_layout_ctx.opts.incremental_layout {
|
if opts::get().incremental_layout {
|
||||||
layout_root.nonincremental_reset();
|
layout_root.nonincremental_reset();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -652,7 +644,7 @@ impl LayoutTask {
|
||||||
// memory safety but is a useful debugging tool.)
|
// memory safety but is a useful debugging tool.)
|
||||||
self.verify_flow_tree(&mut layout_root);
|
self.verify_flow_tree(&mut layout_root);
|
||||||
|
|
||||||
if self.opts.trace_layout {
|
if opts::get().trace_layout {
|
||||||
layout_debug::begin_trace(layout_root.clone());
|
layout_debug::begin_trace(layout_root.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,7 +665,7 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if self.opts.dump_flow_tree {
|
if opts::get().dump_flow_tree {
|
||||||
layout_root.dump();
|
layout_root.dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -772,11 +764,11 @@ impl LayoutTask {
|
||||||
|
|
||||||
self.first_reflow.set(false);
|
self.first_reflow.set(false);
|
||||||
|
|
||||||
if self.opts.trace_layout {
|
if opts::get().trace_layout {
|
||||||
layout_debug::end_trace();
|
layout_debug::end_trace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.opts.dump_flow_tree {
|
if opts::get().dump_flow_tree {
|
||||||
layout_root.dump();
|
layout_root.dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ use wrapper::{layout_node_to_unsafe_layout_node, layout_node_from_unsafe_layout_
|
||||||
use wrapper::{PostorderNodeMutTraversal, UnsafeLayoutNode};
|
use wrapper::{PostorderNodeMutTraversal, UnsafeLayoutNode};
|
||||||
use wrapper::{PreorderDomTraversal, PostorderDomTraversal};
|
use wrapper::{PreorderDomTraversal, PostorderDomTraversal};
|
||||||
|
|
||||||
|
use servo_util::opts;
|
||||||
use servo_util::time::{TimeProfilerChan, profile};
|
use servo_util::time::{TimeProfilerChan, profile};
|
||||||
use servo_util::time;
|
use servo_util::time;
|
||||||
use servo_util::workqueue::{WorkQueue, WorkUnit, WorkerProxy};
|
use servo_util::workqueue::{WorkQueue, WorkUnit, WorkerProxy};
|
||||||
|
@ -427,7 +428,7 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
shared_layout_context: &SharedLayoutContext,
|
shared_layout_context: &SharedLayoutContext,
|
||||||
queue: &mut WorkQueue<*const SharedLayoutContext,UnsafeFlow>) {
|
queue: &mut WorkQueue<*const SharedLayoutContext,UnsafeFlow>) {
|
||||||
if shared_layout_context.opts.bubble_inline_sizes_separately {
|
if opts::get().bubble_inline_sizes_separately {
|
||||||
let layout_context = LayoutContext::new(shared_layout_context);
|
let layout_context = LayoutContext::new(shared_layout_context);
|
||||||
let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context };
|
let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context };
|
||||||
root.traverse_postorder(&bubble_inline_sizes);
|
root.traverse_postorder(&bubble_inline_sizes);
|
||||||
|
|
|
@ -8,6 +8,7 @@ use context::{LayoutContext, SharedLayoutContext};
|
||||||
use flow::{Flow, MutableFlowUtils, PreorderFlowTraversal, PostorderFlowTraversal};
|
use flow::{Flow, MutableFlowUtils, PreorderFlowTraversal, PostorderFlowTraversal};
|
||||||
use flow;
|
use flow;
|
||||||
use flow_ref::FlowRef;
|
use flow_ref::FlowRef;
|
||||||
|
use servo_util::opts;
|
||||||
use traversal::{BubbleISizes, RecalcStyleForNode, ConstructFlows};
|
use traversal::{BubbleISizes, RecalcStyleForNode, ConstructFlows};
|
||||||
use traversal::{AssignBSizesAndStoreOverflow, AssignISizes};
|
use traversal::{AssignBSizesAndStoreOverflow, AssignISizes};
|
||||||
use traversal::{ComputeAbsolutePositions, BuildDisplayList};
|
use traversal::{ComputeAbsolutePositions, BuildDisplayList};
|
||||||
|
@ -54,7 +55,7 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
||||||
|
|
||||||
let root = root.deref_mut();
|
let root = root.deref_mut();
|
||||||
|
|
||||||
if layout_context.shared.opts.bubble_inline_sizes_separately {
|
if opts::get().bubble_inline_sizes_separately {
|
||||||
let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context };
|
let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context };
|
||||||
root.traverse_postorder(&bubble_inline_sizes);
|
root.traverse_postorder(&bubble_inline_sizes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use wrapper::{PostorderNodeMutTraversal, ThreadSafeLayoutNode, UnsafeLayoutNode}
|
||||||
use wrapper::{PreorderDomTraversal, PostorderDomTraversal};
|
use wrapper::{PreorderDomTraversal, PostorderDomTraversal};
|
||||||
|
|
||||||
use servo_util::bloom::BloomFilter;
|
use servo_util::bloom::BloomFilter;
|
||||||
|
use servo_util::opts;
|
||||||
use servo_util::tid::tid;
|
use servo_util::tid::tid;
|
||||||
use style::TNode;
|
use style::TNode;
|
||||||
|
|
||||||
|
@ -204,7 +205,7 @@ impl<'a> PostorderDomTraversal for ConstructFlows<'a> {
|
||||||
let tnode = ThreadSafeLayoutNode::new(&node);
|
let tnode = ThreadSafeLayoutNode::new(&node);
|
||||||
|
|
||||||
// Always re-construct if incremental layout is turned off.
|
// Always re-construct if incremental layout is turned off.
|
||||||
if !self.layout_context.shared.opts.incremental_layout {
|
if !opts::get().incremental_layout {
|
||||||
unsafe {
|
unsafe {
|
||||||
node.set_dirty_descendants(true);
|
node.set_dirty_descendants(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ use servo_msg::constellation_msg::{ConstellationChan, PipelineId};
|
||||||
use servo_msg::constellation_msg::Failure;
|
use servo_msg::constellation_msg::Failure;
|
||||||
use servo_net::image_cache_task::ImageCacheTask;
|
use servo_net::image_cache_task::ImageCacheTask;
|
||||||
use servo_net::resource_task::ResourceTask;
|
use servo_net::resource_task::ResourceTask;
|
||||||
use servo_util::opts::Opts;
|
|
||||||
use servo_util::time::TimeProfilerChan;
|
use servo_util::time::TimeProfilerChan;
|
||||||
use script_traits::{ScriptControlChan, OpaqueScriptLayoutChannel};
|
use script_traits::{ScriptControlChan, OpaqueScriptLayoutChannel};
|
||||||
use std::comm::Sender;
|
use std::comm::Sender;
|
||||||
|
@ -52,7 +51,6 @@ pub trait LayoutTaskFactory {
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
img_cache_task: ImageCacheTask,
|
img_cache_task: ImageCacheTask,
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
opts: Opts,
|
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
shutdown_chan: Sender<()>);
|
shutdown_chan: Sender<()>);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ use std::cmp;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::os;
|
use std::os;
|
||||||
|
use std::ptr;
|
||||||
use std::rt;
|
use std::rt;
|
||||||
|
|
||||||
/// Global flags for Servo, currently set on the command line.
|
/// Global flags for Servo, currently set on the command line.
|
||||||
|
@ -107,7 +108,15 @@ fn args_fail(msg: &str) {
|
||||||
os::set_exit_status(1);
|
os::set_exit_status(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_cmdline_args(args: &[String]) -> Option<Opts> {
|
// Always use CPU rendering on android.
|
||||||
|
|
||||||
|
#[cfg(target_os="android")]
|
||||||
|
static FORCE_CPU_PAINTING: bool = true;
|
||||||
|
|
||||||
|
#[cfg(not(target_os="android"))]
|
||||||
|
static FORCE_CPU_PAINTING: bool = false;
|
||||||
|
|
||||||
|
pub fn from_cmdline_args(args: &[String]) -> bool {
|
||||||
let app_name = args[0].to_string();
|
let app_name = args[0].to_string();
|
||||||
let args = args.tail();
|
let args = args.tail();
|
||||||
|
|
||||||
|
@ -141,19 +150,19 @@ pub fn from_cmdline_args(args: &[String]) -> Option<Opts> {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(f) => {
|
Err(f) => {
|
||||||
args_fail(format!("{}", f).as_slice());
|
args_fail(format!("{}", f).as_slice());
|
||||||
return None;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if opt_match.opt_present("h") || opt_match.opt_present("help") {
|
if opt_match.opt_present("h") || opt_match.opt_present("help") {
|
||||||
print_usage(app_name.as_slice(), opts.as_slice());
|
print_usage(app_name.as_slice(), opts.as_slice());
|
||||||
return None;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
let urls = if opt_match.free.is_empty() {
|
let urls = if opt_match.free.is_empty() {
|
||||||
print_usage(app_name.as_slice(), opts.as_slice());
|
print_usage(app_name.as_slice(), opts.as_slice());
|
||||||
args_fail("servo asks that you provide 1 or more URLs");
|
args_fail("servo asks that you provide 1 or more URLs");
|
||||||
return None;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
opt_match.free.clone()
|
opt_match.free.clone()
|
||||||
};
|
};
|
||||||
|
@ -180,7 +189,7 @@ pub fn from_cmdline_args(args: &[String]) -> Option<Opts> {
|
||||||
from_str(period.as_slice()).unwrap()
|
from_str(period.as_slice()).unwrap()
|
||||||
});
|
});
|
||||||
|
|
||||||
let cpu_painting = opt_match.opt_present("c");
|
let cpu_painting = FORCE_CPU_PAINTING || opt_match.opt_present("c");
|
||||||
|
|
||||||
let mut layout_threads: uint = match opt_match.opt_str("y") {
|
let mut layout_threads: uint = match opt_match.opt_str("y") {
|
||||||
Some(layout_threads_str) => from_str(layout_threads_str.as_slice()).unwrap(),
|
Some(layout_threads_str) => from_str(layout_threads_str.as_slice()).unwrap(),
|
||||||
|
@ -237,12 +246,8 @@ pub fn from_cmdline_args(args: &[String]) -> Option<Opts> {
|
||||||
dump_flow_tree: opt_match.opt_present("dump-flow-tree"),
|
dump_flow_tree: opt_match.opt_present("dump-flow-tree"),
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
set_opts(opts);
|
||||||
let box_opts = box opts.clone();
|
true
|
||||||
OPTIONS = mem::transmute(box_opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(opts)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static mut EXPERIMENTAL_ENABLED: bool = false;
|
static mut EXPERIMENTAL_ENABLED: bool = false;
|
||||||
|
@ -262,10 +267,19 @@ pub fn experimental_enabled() -> bool {
|
||||||
// Make Opts available globally. This saves having to clone and pass
|
// Make Opts available globally. This saves having to clone and pass
|
||||||
// opts everywhere it is used, which gets particularly cumbersome
|
// opts everywhere it is used, which gets particularly cumbersome
|
||||||
// when passing through the DOM structures.
|
// when passing through the DOM structures.
|
||||||
// GWTODO: Change existing code that takes copies of opts to instead
|
|
||||||
// make use of the global copy.
|
|
||||||
static mut OPTIONS: *mut Opts = 0 as *mut Opts;
|
static mut OPTIONS: *mut Opts = 0 as *mut Opts;
|
||||||
|
|
||||||
pub fn get() -> &'static Opts {
|
pub fn set_opts(opts: Opts) {
|
||||||
unsafe { mem::transmute(OPTIONS) }
|
unsafe {
|
||||||
|
let box_opts = box opts;
|
||||||
|
OPTIONS = mem::transmute(box_opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get<'a>() -> &'a Opts {
|
||||||
|
unsafe {
|
||||||
|
assert!(OPTIONS != ptr::null_mut());
|
||||||
|
mem::transmute(OPTIONS)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,14 +30,14 @@ use glut::glut::{init, init_display_mode, DOUBLE};
|
||||||
|
|
||||||
mod window;
|
mod window;
|
||||||
|
|
||||||
pub fn create_window(opts: &opts::Opts) -> Rc<Window> {
|
pub fn create_window() -> Rc<Window> {
|
||||||
// Initialize GLUT.
|
// Initialize GLUT.
|
||||||
init();
|
init();
|
||||||
init_display_mode(DOUBLE);
|
init_display_mode(DOUBLE);
|
||||||
|
|
||||||
// Read command-line options.
|
// Read command-line options.
|
||||||
let scale_factor = opts.device_pixels_per_px.unwrap_or(ScaleFactor(1.0));
|
let scale_factor = opts::get().device_pixels_per_px.unwrap_or(ScaleFactor(1.0));
|
||||||
let size = opts.initial_window_size.as_f32() * scale_factor;
|
let size = opts::get().initial_window_size.as_f32() * scale_factor;
|
||||||
|
|
||||||
// Open a window.
|
// Open a window.
|
||||||
Window::new(size.as_uint())
|
Window::new(size.as_uint())
|
||||||
|
@ -54,11 +54,9 @@ pub extern "C" fn android_start(argc: int, argv: *const *const u8) -> int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
opts::from_cmdline_args(args.as_slice()).map(|mut opts| {
|
if opts::from_cmdline_args(args.as_slice()) {
|
||||||
// Always use CPU rendering on android.
|
let window = Some(create_window());
|
||||||
opts.cpu_painting = true;
|
servo::run(window);
|
||||||
let window = Some(create_window(&opts));
|
}
|
||||||
servo::run(opts, window);
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,8 +75,8 @@ pub extern "C" fn cef_run_message_loop() {
|
||||||
dump_flow_tree: false,
|
dump_flow_tree: false,
|
||||||
};
|
};
|
||||||
native::start(0, 0 as *const *const u8, proc() {
|
native::start(0, 0 as *const *const u8, proc() {
|
||||||
let window = Some(glfw_app::create_window(&opts));
|
let window = Some(glfw_app::create_window());
|
||||||
servo::run(opts, window);
|
servo::run(window);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,11 @@ extern crate util;
|
||||||
use geom::scale_factor::ScaleFactor;
|
use geom::scale_factor::ScaleFactor;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use window::Window;
|
use window::Window;
|
||||||
|
use util::opts;
|
||||||
|
|
||||||
mod window;
|
mod window;
|
||||||
|
|
||||||
pub fn create_window(opts: &util::opts::Opts) -> Rc<Window> {
|
pub fn create_window() -> Rc<Window> {
|
||||||
// Initialize GLFW.
|
// Initialize GLFW.
|
||||||
let glfw = glfw::init(glfw::LOG_ERRORS).unwrap_or_else(|_| {
|
let glfw = glfw::init(glfw::LOG_ERRORS).unwrap_or_else(|_| {
|
||||||
// handles things like inability to connect to X
|
// handles things like inability to connect to X
|
||||||
|
@ -34,9 +35,9 @@ pub fn create_window(opts: &util::opts::Opts) -> Rc<Window> {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Read command-line options.
|
// Read command-line options.
|
||||||
let foreground = opts.output_file.is_none();
|
let foreground = opts::get().output_file.is_none();
|
||||||
let scale_factor = opts.device_pixels_per_px.unwrap_or(ScaleFactor(1.0));
|
let scale_factor = opts::get().device_pixels_per_px.unwrap_or(ScaleFactor(1.0));
|
||||||
let size = opts.initial_window_size.as_f32() * scale_factor;
|
let size = opts::get().initial_window_size.as_f32() * scale_factor;
|
||||||
|
|
||||||
// Open a window.
|
// Open a window.
|
||||||
Window::new(glfw, foreground, size.as_uint())
|
Window::new(glfw, foreground, size.as_uint())
|
||||||
|
|
|
@ -62,8 +62,9 @@ use std::rc::Rc;
|
||||||
use std::task::TaskBuilder;
|
use std::task::TaskBuilder;
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
pub fn run<Window: WindowMethods>(opts: opts::Opts, window: Option<Rc<Window>>) {
|
pub fn run<Window: WindowMethods>(window: Option<Rc<Window>>) {
|
||||||
::servo_util::opts::set_experimental_enabled(opts.enable_experimental);
|
::servo_util::opts::set_experimental_enabled(opts::get().enable_experimental);
|
||||||
|
let opts = opts::get();
|
||||||
RegisterBindings::RegisterProxyHandlers();
|
RegisterBindings::RegisterProxyHandlers();
|
||||||
|
|
||||||
let mut pool_config = green::PoolConfig::new();
|
let mut pool_config = green::PoolConfig::new();
|
||||||
|
@ -77,14 +78,12 @@ pub fn run<Window: WindowMethods>(opts: opts::Opts, window: Option<Rc<Window>>)
|
||||||
devtools::start_server(port)
|
devtools::start_server(port)
|
||||||
});
|
});
|
||||||
|
|
||||||
let opts_clone = opts.clone();
|
|
||||||
let time_profiler_chan_clone = time_profiler_chan.clone();
|
let time_profiler_chan_clone = time_profiler_chan.clone();
|
||||||
|
|
||||||
let (result_chan, result_port) = channel();
|
let (result_chan, result_port) = channel();
|
||||||
TaskBuilder::new()
|
TaskBuilder::new()
|
||||||
.green(&mut pool)
|
.green(&mut pool)
|
||||||
.spawn(proc() {
|
.spawn(proc() {
|
||||||
let opts = &opts_clone;
|
|
||||||
// Create a Servo instance.
|
// Create a Servo instance.
|
||||||
let resource_task = new_resource_task(opts.user_agent.clone());
|
let resource_task = new_resource_task(opts.user_agent.clone());
|
||||||
// If we are emitting an output file, then we need to block on
|
// If we are emitting an output file, then we need to block on
|
||||||
|
@ -99,7 +98,6 @@ pub fn run<Window: WindowMethods>(opts: opts::Opts, window: Option<Rc<Window>>)
|
||||||
let constellation_chan = Constellation::<layout::layout_task::LayoutTask,
|
let constellation_chan = Constellation::<layout::layout_task::LayoutTask,
|
||||||
script::script_task::ScriptTask>::start(
|
script::script_task::ScriptTask>::start(
|
||||||
compositor_chan,
|
compositor_chan,
|
||||||
opts,
|
|
||||||
resource_task,
|
resource_task,
|
||||||
image_cache_task,
|
image_cache_task,
|
||||||
font_cache_task,
|
font_cache_task,
|
||||||
|
@ -128,7 +126,6 @@ pub fn run<Window: WindowMethods>(opts: opts::Opts, window: Option<Rc<Window>>)
|
||||||
|
|
||||||
debug!("preparing to enter main loop");
|
debug!("preparing to enter main loop");
|
||||||
CompositorTask::create(window,
|
CompositorTask::create(window,
|
||||||
opts,
|
|
||||||
compositor_port,
|
compositor_port,
|
||||||
constellation_chan,
|
constellation_chan,
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -28,14 +28,14 @@ use std::os;
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn start(argc: int, argv: *const *const u8) -> int {
|
fn start(argc: int, argv: *const *const u8) -> int {
|
||||||
native::start(argc, argv, proc() {
|
native::start(argc, argv, proc() {
|
||||||
opts::from_cmdline_args(os::args().as_slice()).map(|opts| {
|
if opts::from_cmdline_args(os::args().as_slice()) {
|
||||||
let window = if opts.headless {
|
let window = if opts::get().headless {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(glfw_app::create_window(&opts))
|
Some(glfw_app::create_window())
|
||||||
};
|
};
|
||||||
run(opts, window);
|
run(window);
|
||||||
});
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue