Move border computation into unpruned traversal. Get rid of extraneous explicit initial reflow. Fixes #935.

This commit is contained in:
Josh Matthews 2013-09-13 16:30:55 -07:00
parent 4f58545fd6
commit 7b239bd246
4 changed files with 28 additions and 18 deletions

View file

@ -107,11 +107,6 @@ impl BlockFlowData {
/* if not an anonymous block context, add in block box's widths. /* if not an anonymous block context, add in block box's widths.
these widths will not include child elements, just padding etc. */ these widths will not include child elements, just padding etc. */
self.box.map(|&box| { self.box.map(|&box| {
//Can compute border width here since it doesn't depend on anything
let style = box.style();
do box.with_model |model| {
model.compute_borders(style)
}
min_width = min_width.add(&box.get_min_width(ctx)); min_width = min_width.add(&box.get_min_width(ctx));
pref_width = pref_width.add(&box.get_pref_width(ctx)); pref_width = pref_width.add(&box.get_pref_width(ctx));
}); });
@ -194,6 +189,9 @@ impl BlockFlowData {
for &box in self.box.iter() { for &box in self.box.iter() {
let style = box.style(); let style = box.style();
do box.with_model |model| { do box.with_model |model| {
//Can compute border width here since it doesn't depend on anything
model.compute_borders(style);
// Can compute padding here since we know containing block width. // Can compute padding here since we know containing block width.
model.compute_padding(style, remaining_width); model.compute_padding(style, remaining_width);

View file

@ -281,6 +281,7 @@ impl LayoutTask {
// FIXME: We want to do // FIXME: We want to do
// for flow in layout_root.traverse_preorder_prune(|f| f.restyle_damage().lacks(Reflow)) // for flow in layout_root.traverse_preorder_prune(|f| f.restyle_damage().lacks(Reflow))
// but FloatContext values can't be reused, so we need to recompute them every time. // but FloatContext values can't be reused, so we need to recompute them every time.
// NOTE: this currently computes borders, so any pruning should separate that operation out.
debug!("assigning widths"); debug!("assigning widths");
do layout_root.each_preorder |flow| { do layout_root.each_preorder |flow| {
flow.assign_widths(&mut layout_ctx); flow.assign_widths(&mut layout_ctx);

View file

@ -292,6 +292,8 @@ impl Page {
self.damage(MatchSelectorsDocumentDamage); self.damage(MatchSelectorsDocumentDamage);
} }
//FIXME: In the case where an initial reflow is required, we should always
// ReflowForDisplay, regardless of the original goal.
self.reflow(goal, script_chan, compositor) self.reflow(goal, script_chan, compositor)
} }
@ -661,11 +663,6 @@ impl ScriptTask {
}); });
page.url = Some((url.clone(), true)); page.url = Some((url.clone(), true));
// Tie the root into the document.
do root.with_mut_base |base| {
base.add_to_doc(document)
}
// Send style sheets over to layout. // Send style sheets over to layout.
// //
// FIXME: These should be streamed to layout as they're parsed. We don't need to stop here // FIXME: These should be streamed to layout as they're parsed. We don't need to stop here
@ -698,19 +695,21 @@ impl ScriptTask {
} }
} }
// Tie the root into the document. This will kick off the initial reflow
// of the page.
// FIXME: We have no way to ensure that the first reflow performed is a
// ReflowForDisplay operation.
do root.with_mut_base |base| {
base.add_to_doc(document)
}
// No more reflow required
page.url = Some((url, false));
// Receive the JavaScript scripts. // Receive the JavaScript scripts.
assert!(js_scripts.is_some()); assert!(js_scripts.is_some());
let js_scripts = js_scripts.take_unwrap(); let js_scripts = js_scripts.take_unwrap();
debug!("js_scripts: %?", js_scripts); debug!("js_scripts: %?", js_scripts);
// Perform the initial reflow.
page.damage = Some(DocumentDamage {
root: root,
level: MatchSelectorsDocumentDamage,
});
page.reflow(ReflowForDisplay, self.chan.clone(), self.compositor);
page.url = Some((url, false));
// Define debug functions. // Define debug functions.
let compartment = page.js_info.get_ref().js_compartment; let compartment = page.js_info.get_ref().js_compartment;
let cx = page.js_info.get_ref().js_context; let cx = page.js_info.get_ref().js_context;

View file

@ -0,0 +1,12 @@
<html>
<head>
<style>
span {
border: 1px solid black;
}
</style>
</head>
<body>
<span style="display: block;">hi there</span>
</body>
</html>