Skip to content

Commit

Permalink
auto merge of #5332 : glennw/servo/fix-root-window-rect, r=jdm
Browse files Browse the repository at this point in the history
  • Loading branch information
bors-servo committed Mar 24, 2015
2 parents be68ea0 + 30ac159 commit cad58b3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 31 deletions.
39 changes: 14 additions & 25 deletions components/compositing/constellation.rs
Expand Up @@ -7,6 +7,7 @@ use pipeline::{Pipeline, CompositionPipeline};
use compositor_task::CompositorProxy;
use compositor_task::Msg as CompositorMsg;
use devtools_traits::{DevtoolsControlChan, DevtoolsControlMsg};
use geom::point::Point2D;
use geom::rect::{Rect, TypedRect};
use geom::scale_factor::ScaleFactor;
use gfx::font_cache_task::FontCacheTask;
Expand Down Expand Up @@ -220,23 +221,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
}

/// Gets the current window_size rect for an existing pipeline. This is used
/// to initialize the window size for a new pipeline, but may be None
/// when a new frame is loading.
fn get_window_size_data_for_pipeline(&self, pipeline_id: PipelineId) -> Option<WindowSizeData> {
self.pipeline(pipeline_id).rect.map(|rect| {
WindowSizeData {
visible_viewport: rect.size,
initial_viewport: rect.size * ScaleFactor::new(1.0),
device_pixel_ratio: self.window_size.device_pixel_ratio,
}
})
}

/// Helper function for creating a pipeline
fn new_pipeline(&mut self,
parent_info: Option<(PipelineId, SubpageId)>,
initial_window_size: Option<WindowSizeData>,
initial_window_rect: Option<TypedRect<PagePx, f32>>,
script_channel: Option<ScriptControlChan>,
load_data: LoadData)
-> PipelineId {
Expand All @@ -255,9 +243,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
self.storage_task.clone(),
self.time_profiler_chan.clone(),
self.memory_profiler_chan.clone(),
initial_window_size,
initial_window_rect,
script_channel,
load_data);
load_data,
self.window_size.device_pixel_ratio);

assert!(!self.pipelines.contains_key(&pipeline_id));
self.pipelines.insert(pipeline_id, pipeline);
Expand Down Expand Up @@ -433,16 +422,16 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
debug!("creating replacement pipeline for about:failure");

let window_size = self.get_window_size_data_for_pipeline(pipeline_id);
let new_pipeline_id = self.new_pipeline(parent_info, window_size, None,
let window_rect = self.pipeline(pipeline_id).rect;
let new_pipeline_id = self.new_pipeline(parent_info, window_rect, None,
LoadData::new(Url::parse("about:failure").unwrap()));

self.push_pending_frame(new_pipeline_id, Some(pipeline_id));
}

fn handle_init_load(&mut self, url: Url) {
let window_size = self.window_size;
let root_pipeline_id = self.new_pipeline(None, Some(window_size), None, LoadData::new(url));
let window_rect = Rect(Point2D::zero(), self.window_size.visible_viewport);
let root_pipeline_id = self.new_pipeline(None, Some(window_rect), None, LoadData::new(url));
self.push_pending_frame(root_pipeline_id, None);
}

Expand Down Expand Up @@ -508,11 +497,11 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let old_pipeline_id = old_subpage_id.map(|old_subpage_id| {
self.find_subpage(containing_pipeline_id, old_subpage_id).id
});
let window_size = old_pipeline_id.and_then(|old_pipeline_id| {
self.get_window_size_data_for_pipeline(old_pipeline_id)
let window_rect = old_pipeline_id.and_then(|old_pipeline_id| {
self.pipeline(old_pipeline_id).rect
});
let new_pipeline_id = self.new_pipeline(Some((containing_pipeline_id, new_subpage_id)),
window_size,
window_rect,
script_chan,
LoadData::new(url));
self.subpage_map.insert((containing_pipeline_id, new_subpage_id), new_pipeline_id);
Expand Down Expand Up @@ -551,8 +540,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// changes would be overridden by changing the subframe associated with source_id.

// Create the new pipeline
let window_size = self.get_window_size_data_for_pipeline(source_id);
let new_pipeline_id = self.new_pipeline(None, window_size, None, load_data);
let window_rect = self.pipeline(source_id).rect;
let new_pipeline_id = self.new_pipeline(None, window_rect, None, load_data);
self.push_pending_frame(new_pipeline_id, Some(source_id));

// Send message to ScriptTask that will suspend all timers
Expand Down
26 changes: 20 additions & 6 deletions components/compositing/pipeline.rs
Expand Up @@ -9,16 +9,18 @@ use script_traits::{NewLayoutInfo, ConstellationControlMsg};

use devtools_traits::DevtoolsControlChan;
use geom::rect::{TypedRect};
use geom::scale_factor::ScaleFactor;
use gfx::paint_task::Msg as PaintMsg;
use gfx::paint_task::{PaintChan, PaintTask};
use gfx::font_cache_task::FontCacheTask;
use layers::geometry::DevicePixel;
use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId};
use msg::constellation_msg::{LoadData, WindowSizeData, PipelineExitType};
use net::image_cache_task::ImageCacheTask;
use net::resource_task::ResourceTask;
use net::storage_task::StorageTask;
use url::Url;
use util::geometry::{PagePx};
use util::geometry::{PagePx, ViewportPx};
use util::memory::MemoryProfilerChan;
use util::time::TimeProfilerChan;
use std::sync::mpsc::{Receiver, channel};
Expand Down Expand Up @@ -63,9 +65,10 @@ impl Pipeline {
storage_task: StorageTask,
time_profiler_chan: TimeProfilerChan,
memory_profiler_chan: MemoryProfilerChan,
window_size: Option<WindowSizeData>,
window_rect: Option<TypedRect<PagePx, f32>>,
script_chan: Option<ScriptControlChan>,
load_data: LoadData)
load_data: LoadData,
device_pixel_ratio: ScaleFactor<ViewportPx, DevicePixel, f32>)
-> Pipeline
where LTF: LayoutTaskFactory, STF:ScriptTaskFactory {
let layout_pair = ScriptTaskFactory::create_layout_channel(None::<&mut STF>);
Expand All @@ -82,6 +85,15 @@ impl Pipeline {
let script_chan = match script_chan {
None => {
let (script_chan, script_port) = channel();

let window_size = window_rect.map(|rect| {
WindowSizeData {
visible_viewport: rect.size,
initial_viewport: rect.size * ScaleFactor::new(1.0),
device_pixel_ratio: device_pixel_ratio,
}
});

ScriptTaskFactory::create(None::<&mut STF>,
id,
parent_info,
Expand Down Expand Up @@ -147,7 +159,8 @@ impl Pipeline {
paint_chan,
layout_shutdown_port,
paint_shutdown_port,
load_data.url)
load_data.url,
window_rect)
}

pub fn new(id: PipelineId,
Expand All @@ -157,7 +170,8 @@ impl Pipeline {
paint_chan: PaintChan,
layout_shutdown_port: Receiver<()>,
paint_shutdown_port: Receiver<()>,
url: Url)
url: Url,
rect: Option<TypedRect<PagePx, f32>>)
-> Pipeline {
Pipeline {
id: id,
Expand All @@ -170,7 +184,7 @@ impl Pipeline {
url: url,
title: None,
children: vec!(),
rect: None,
rect: rect,
}
}

Expand Down

0 comments on commit cad58b3

Please sign in to comment.