layout: Make the compositor rather than layout determine the position of

each iframe.

The old code that attempted to do this during layout wasn't able to work
for multiple reasons: it couldn't know where the iframe was going to be
on the page (because of nested iframes), and at the time it was building
the display list for a fragment it couldn't know where that fragment was
going to be in page coordinates.

This patch rewrites that code so that both the sizes and positions of
iframes are determined by the compositor. Layout layerizes all iframes
and marks the iframe layers with the appropriate pipeline and subpage
IDs so that the compositor can place them correctly. This approach is
similar in spirit to Gecko's `RefLayer` infrastructure. The logic that
determines when it is time to take the screenshot for reftests has been
significantly revamped to deal with this change in delegation of
responsibility.

Additionally, this code removes the infrastructure that sends layout
data back to the layout task to be destroyed, since it is now all
thread-safe and can be destroyed on the script task.

The failing tests now fail because of a pre-existing bug related to
intrinsic heights and borders on inline replaced elements. They happened
to pass before because we never rendered the iframes at all, which meant
they never had a chance to draw the red border the tests expect to not
render!

Closes #7377.
This commit is contained in:
Patrick Walton 2015-08-27 16:29:57 -07:00
parent ed0d70e234
commit c72d0c2ed0
20 changed files with 602 additions and 389 deletions

View file

@ -637,7 +637,7 @@ impl LayoutTask {
unsafe {
self.handle_reap_layout_data(dead_layout_data)
}
},
}
Msg::CollectReports(reports_chan) => {
self.collect_reports(reports_chan, possibly_locked_rw_data);
},
@ -724,8 +724,7 @@ impl LayoutTask {
info.layout_shutdown_chan);
}
/// Enters a quiescent state in which no new messages except for
/// `layout_interface::Msg::ReapLayoutData` will be processed until an `ExitNow` is
/// Enters a quiescent state in which no new messages will be processed until an `ExitNow` is
/// received. A pong is immediately sent on the given response channel.
fn prepare_to_exit<'a>(&'a self,
response_chan: Sender<()>,
@ -1099,6 +1098,7 @@ impl LayoutTask {
flow::mut_base(flow_ref::deref_mut(layout_root))
.display_list_building_result
.add_to(&mut *display_list);
let origin = Rect::new(Point2D::new(Au(0), Au(0)), root_size);
let layer_id = layout_root.layer_id();
let stacking_context = Arc::new(StackingContext::new(display_list,
@ -1112,11 +1112,8 @@ impl LayoutTask {
true,
false,
ScrollPolicy::Scrollable,
Some(layer_id)));
let paint_layer = PaintLayer::new(layer_id,
root_background_color,
stacking_context.clone());
Some(layer_id),
None));
if opts::get().dump_display_list {
stacking_context.print("DisplayList".to_owned());
}
@ -1124,7 +1121,12 @@ impl LayoutTask {
println!("{}", serde_json::to_string_pretty(&stacking_context).unwrap());
}
rw_data.stacking_context = Some(stacking_context);
rw_data.stacking_context = Some(stacking_context.clone());
let paint_layer = PaintLayer::new(layout_root.layer_id(),
root_background_color,
stacking_context,
ScrollPolicy::Scrollable);
debug!("Layout done!");
@ -1489,8 +1491,7 @@ impl LayoutTask {
/// Handles a message to destroy layout data. Layout data must be destroyed on *this* task
/// because the struct type is transmuted to a different type on the script side.
unsafe fn handle_reap_layout_data(&self, layout_data: LayoutData) {
let layout_data_wrapper: LayoutDataWrapper = transmute(layout_data);
layout_data_wrapper.remove_compositor_layers(self.constellation_chan.clone());
let _: LayoutDataWrapper = transmute(layout_data);
}
/// Returns profiling information which is passed to the time profiler.