mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
auto merge of #5491 : ChimeraCoder/servo/fix-issue-5466, r=Manishearth
@kenpratt and I moved the URL and IFrame fields from Reflow to LayoutTask, as described in #5466. This is my first attempt at Rust, so let me know how this is!
This commit is contained in:
commit
e4da29b28b
5 changed files with 25 additions and 28 deletions
|
@ -146,6 +146,7 @@ impl Pipeline {
|
||||||
LayoutTaskFactory::create(None::<&mut LTF>,
|
LayoutTaskFactory::create(None::<&mut LTF>,
|
||||||
id,
|
id,
|
||||||
load_data.url.clone(),
|
load_data.url.clone(),
|
||||||
|
parent_info.is_some(),
|
||||||
layout_pair,
|
layout_pair,
|
||||||
pipeline_port,
|
pipeline_port,
|
||||||
constellation_chan,
|
constellation_chan,
|
||||||
|
|
|
@ -135,6 +135,9 @@ pub struct LayoutTask {
|
||||||
/// The URL of the pipeline that we belong to.
|
/// The URL of the pipeline that we belong to.
|
||||||
pub url: Url,
|
pub url: Url,
|
||||||
|
|
||||||
|
/// Is the current reflow of an iframe, as opposed to a root window?
|
||||||
|
pub is_iframe: bool,
|
||||||
|
|
||||||
/// The port on which we receive messages from the script task.
|
/// The port on which we receive messages from the script task.
|
||||||
pub port: Receiver<Msg>,
|
pub port: Receiver<Msg>,
|
||||||
|
|
||||||
|
@ -206,6 +209,7 @@ impl LayoutTaskFactory for LayoutTask {
|
||||||
fn create(_phantom: Option<&mut LayoutTask>,
|
fn create(_phantom: Option<&mut LayoutTask>,
|
||||||
id: PipelineId,
|
id: PipelineId,
|
||||||
url: Url,
|
url: Url,
|
||||||
|
is_iframe: bool,
|
||||||
chan: OpaqueScriptLayoutChannel,
|
chan: OpaqueScriptLayoutChannel,
|
||||||
pipeline_port: Receiver<LayoutControlMsg>,
|
pipeline_port: Receiver<LayoutControlMsg>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
|
@ -224,6 +228,7 @@ impl LayoutTaskFactory for LayoutTask {
|
||||||
let sender = chan.sender();
|
let sender = chan.sender();
|
||||||
let layout = LayoutTask::new(id,
|
let layout = LayoutTask::new(id,
|
||||||
url,
|
url,
|
||||||
|
is_iframe,
|
||||||
chan.receiver(),
|
chan.receiver(),
|
||||||
LayoutChan(sender),
|
LayoutChan(sender),
|
||||||
pipeline_port,
|
pipeline_port,
|
||||||
|
@ -276,6 +281,7 @@ impl LayoutTask {
|
||||||
/// Creates a new `LayoutTask` structure.
|
/// Creates a new `LayoutTask` structure.
|
||||||
fn new(id: PipelineId,
|
fn new(id: PipelineId,
|
||||||
url: Url,
|
url: Url,
|
||||||
|
is_iframe: bool,
|
||||||
port: Receiver<Msg>,
|
port: Receiver<Msg>,
|
||||||
chan: LayoutChan,
|
chan: LayoutChan,
|
||||||
pipeline_port: Receiver<LayoutControlMsg>,
|
pipeline_port: Receiver<LayoutControlMsg>,
|
||||||
|
@ -314,6 +320,7 @@ impl LayoutTask {
|
||||||
LayoutTask {
|
LayoutTask {
|
||||||
id: id,
|
id: id,
|
||||||
url: url,
|
url: url,
|
||||||
|
is_iframe: is_iframe,
|
||||||
port: port,
|
port: port,
|
||||||
pipeline_port: pipeline_port,
|
pipeline_port: pipeline_port,
|
||||||
chan: chan,
|
chan: chan,
|
||||||
|
@ -470,7 +477,7 @@ impl LayoutTask {
|
||||||
},
|
},
|
||||||
Msg::Reflow(data) => {
|
Msg::Reflow(data) => {
|
||||||
profile(time::ProfilerCategory::LayoutPerform,
|
profile(time::ProfilerCategory::LayoutPerform,
|
||||||
self.profiler_metadata(&data.reflow_info),
|
self.profiler_metadata(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| self.handle_reflow(&*data, possibly_locked_rw_data));
|
|| self.handle_reflow(&*data, possibly_locked_rw_data));
|
||||||
},
|
},
|
||||||
|
@ -664,7 +671,6 @@ impl LayoutTask {
|
||||||
/// benchmarked against those two. It is marked `#[inline(never)]` to aid profiling.
|
/// benchmarked against those two. It is marked `#[inline(never)]` to aid profiling.
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
fn solve_constraints_parallel(&self,
|
fn solve_constraints_parallel(&self,
|
||||||
data: &Reflow,
|
|
||||||
rw_data: &mut LayoutTaskData,
|
rw_data: &mut LayoutTaskData,
|
||||||
layout_root: &mut FlowRef,
|
layout_root: &mut FlowRef,
|
||||||
shared_layout_context: &SharedLayoutContext) {
|
shared_layout_context: &SharedLayoutContext) {
|
||||||
|
@ -676,7 +682,7 @@ impl LayoutTask {
|
||||||
// NOTE: this currently computes borders, so any pruning should separate that
|
// NOTE: this currently computes borders, so any pruning should separate that
|
||||||
// operation out.
|
// operation out.
|
||||||
parallel::traverse_flow_tree_preorder(layout_root,
|
parallel::traverse_flow_tree_preorder(layout_root,
|
||||||
self.profiler_metadata(data),
|
self.profiler_metadata(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
shared_layout_context,
|
shared_layout_context,
|
||||||
traversal);
|
traversal);
|
||||||
|
@ -728,7 +734,7 @@ impl LayoutTask {
|
||||||
rw_data: &mut LayoutTaskData) {
|
rw_data: &mut LayoutTaskData) {
|
||||||
let writing_mode = flow::base(&**layout_root).writing_mode;
|
let writing_mode = flow::base(&**layout_root).writing_mode;
|
||||||
profile(time::ProfilerCategory::LayoutDispListBuild,
|
profile(time::ProfilerCategory::LayoutDispListBuild,
|
||||||
self.profiler_metadata(data),
|
self.profiler_metadata(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
shared_layout_context.dirty =
|
shared_layout_context.dirty =
|
||||||
|
@ -747,7 +753,7 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
Some(ref mut traversal) => {
|
Some(ref mut traversal) => {
|
||||||
parallel::build_display_list_for_subtree(layout_root,
|
parallel::build_display_list_for_subtree(layout_root,
|
||||||
self.profiler_metadata(data),
|
self.profiler_metadata(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
shared_layout_context,
|
shared_layout_context,
|
||||||
traversal);
|
traversal);
|
||||||
|
@ -805,7 +811,7 @@ impl LayoutTask {
|
||||||
transmute(&mut node)
|
transmute(&mut node)
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("layout: received layout request for: {}", data.reflow_info.url.serialize());
|
debug!("layout: received layout request for: {}", self.url.serialize());
|
||||||
if log_enabled!(log::DEBUG) {
|
if log_enabled!(log::DEBUG) {
|
||||||
node.dump();
|
node.dump();
|
||||||
}
|
}
|
||||||
|
@ -854,11 +860,11 @@ impl LayoutTask {
|
||||||
let mut shared_layout_context = self.build_shared_layout_context(&*rw_data,
|
let mut shared_layout_context = self.build_shared_layout_context(&*rw_data,
|
||||||
screen_size_changed,
|
screen_size_changed,
|
||||||
Some(&node),
|
Some(&node),
|
||||||
&data.reflow_info.url);
|
&self.url);
|
||||||
|
|
||||||
// Recalculate CSS styles and rebuild flows and fragments.
|
// Recalculate CSS styles and rebuild flows and fragments.
|
||||||
profile(time::ProfilerCategory::LayoutStyleRecalc,
|
profile(time::ProfilerCategory::LayoutStyleRecalc,
|
||||||
self.profiler_metadata(&data.reflow_info),
|
self.profiler_metadata(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
// Perform CSS selector matching and flow construction.
|
// Perform CSS selector matching and flow construction.
|
||||||
|
@ -913,11 +919,8 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tick_animation<'a>(&'a self, animation: Animation, rw_data: &mut LayoutTaskData) {
|
pub fn tick_animation<'a>(&'a self, animation: Animation, rw_data: &mut LayoutTaskData) {
|
||||||
// FIXME(#5466, pcwalton): These data are lies.
|
|
||||||
let reflow_info = Reflow {
|
let reflow_info = Reflow {
|
||||||
goal: ReflowGoal::ForDisplay,
|
goal: ReflowGoal::ForDisplay,
|
||||||
url: Url::parse("http://animation.com/").unwrap(),
|
|
||||||
iframe: false,
|
|
||||||
page_clip_rect: MAX_RECT,
|
page_clip_rect: MAX_RECT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -925,10 +928,10 @@ impl LayoutTask {
|
||||||
let mut layout_context = self.build_shared_layout_context(&*rw_data,
|
let mut layout_context = self.build_shared_layout_context(&*rw_data,
|
||||||
false,
|
false,
|
||||||
None,
|
None,
|
||||||
&reflow_info.url);
|
&self.url);
|
||||||
let mut root_flow = (*rw_data.root_flow.as_ref().unwrap()).clone();
|
let mut root_flow = (*rw_data.root_flow.as_ref().unwrap()).clone();
|
||||||
profile(time::ProfilerCategory::LayoutStyleRecalc,
|
profile(time::ProfilerCategory::LayoutStyleRecalc,
|
||||||
self.profiler_metadata(&reflow_info),
|
self.profiler_metadata(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| animation::recalc_style_for_animation(root_flow.deref_mut(), &animation));
|
|| animation::recalc_style_for_animation(root_flow.deref_mut(), &animation));
|
||||||
|
|
||||||
|
@ -943,7 +946,7 @@ impl LayoutTask {
|
||||||
layout_context: &mut SharedLayoutContext) {
|
layout_context: &mut SharedLayoutContext) {
|
||||||
let mut root_flow = (*rw_data.root_flow.as_ref().unwrap()).clone();
|
let mut root_flow = (*rw_data.root_flow.as_ref().unwrap()).clone();
|
||||||
profile(time::ProfilerCategory::LayoutRestyleDamagePropagation,
|
profile(time::ProfilerCategory::LayoutRestyleDamagePropagation,
|
||||||
self.profiler_metadata(data),
|
self.profiler_metadata(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
if opts::get().nonincremental_layout || root_flow.deref_mut()
|
if opts::get().nonincremental_layout || root_flow.deref_mut()
|
||||||
|
@ -964,14 +967,14 @@ impl LayoutTask {
|
||||||
|
|
||||||
// Resolve generated content.
|
// Resolve generated content.
|
||||||
profile(time::ProfilerCategory::LayoutGeneratedContent,
|
profile(time::ProfilerCategory::LayoutGeneratedContent,
|
||||||
self.profiler_metadata(data),
|
self.profiler_metadata(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| sequential::resolve_generated_content(&mut root_flow, &layout_context));
|
|| sequential::resolve_generated_content(&mut root_flow, &layout_context));
|
||||||
|
|
||||||
// Perform the primary layout passes over the flow tree to compute the locations of all
|
// Perform the primary layout passes over the flow tree to compute the locations of all
|
||||||
// the boxes.
|
// the boxes.
|
||||||
profile(time::ProfilerCategory::LayoutMain,
|
profile(time::ProfilerCategory::LayoutMain,
|
||||||
self.profiler_metadata(data),
|
self.profiler_metadata(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
match rw_data.parallel_traversal {
|
match rw_data.parallel_traversal {
|
||||||
|
@ -981,8 +984,7 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
// Parallel mode.
|
// Parallel mode.
|
||||||
self.solve_constraints_parallel(data,
|
self.solve_constraints_parallel(rw_data,
|
||||||
rw_data,
|
|
||||||
&mut root_flow,
|
&mut root_flow,
|
||||||
&mut *layout_context);
|
&mut *layout_context);
|
||||||
}
|
}
|
||||||
|
@ -1058,9 +1060,9 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns profiling information which is passed to the time profiler.
|
/// Returns profiling information which is passed to the time profiler.
|
||||||
fn profiler_metadata<'a>(&self, data: &'a Reflow) -> ProfilerMetadata<'a> {
|
fn profiler_metadata(&self) -> ProfilerMetadata {
|
||||||
Some((&data.url,
|
Some((&self.url,
|
||||||
if data.iframe {
|
if self.is_iframe {
|
||||||
TimerMetadataFrameType::IFrame
|
TimerMetadataFrameType::IFrame
|
||||||
} else {
|
} else {
|
||||||
TimerMetadataFrameType::RootWindow
|
TimerMetadataFrameType::RootWindow
|
||||||
|
@ -1234,4 +1236,3 @@ fn get_root_flow_background_color(flow: &mut Flow) -> AzColor {
|
||||||
.resolve_color(kid_block_flow.fragment.style.get_background().background_color)
|
.resolve_color(kid_block_flow.fragment.style.get_background().background_color)
|
||||||
.to_gfx_color()
|
.to_gfx_color()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ pub trait LayoutTaskFactory {
|
||||||
fn create(_phantom: Option<&mut Self>,
|
fn create(_phantom: Option<&mut Self>,
|
||||||
id: PipelineId,
|
id: PipelineId,
|
||||||
url: Url,
|
url: Url,
|
||||||
|
is_iframe: bool,
|
||||||
chan: OpaqueScriptLayoutChannel,
|
chan: OpaqueScriptLayoutChannel,
|
||||||
pipeline_port: Receiver<LayoutControlMsg>,
|
pipeline_port: Receiver<LayoutControlMsg>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
|
|
|
@ -567,8 +567,6 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
|
||||||
let reflow = box ScriptReflow {
|
let reflow = box ScriptReflow {
|
||||||
reflow_info: Reflow {
|
reflow_info: Reflow {
|
||||||
goal: goal,
|
goal: goal,
|
||||||
url: self.get_url(),
|
|
||||||
iframe: self.parent_info.is_some(),
|
|
||||||
page_clip_rect: self.page_clip_rect.get(),
|
page_clip_rect: self.page_clip_rect.get(),
|
||||||
},
|
},
|
||||||
document_root: root.to_trusted_node_address(),
|
document_root: root.to_trusted_node_address(),
|
||||||
|
|
|
@ -108,10 +108,6 @@ pub enum ReflowQueryType {
|
||||||
pub struct Reflow {
|
pub struct Reflow {
|
||||||
/// The goal of reflow: either to render to the screen or to flush layout info for script.
|
/// The goal of reflow: either to render to the screen or to flush layout info for script.
|
||||||
pub goal: ReflowGoal,
|
pub goal: ReflowGoal,
|
||||||
/// The URL of the page.
|
|
||||||
pub url: Url,
|
|
||||||
/// Is the current reflow of an iframe, as opposed to a root window?
|
|
||||||
pub iframe: bool,
|
|
||||||
/// A clipping rectangle for the page, an enlarged rectangle containing the viewport.
|
/// A clipping rectangle for the page, an enlarged rectangle containing the viewport.
|
||||||
pub page_clip_rect: Rect<Au>,
|
pub page_clip_rect: Rect<Au>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue