From 7b239bd2461e234710df0871da5a937e0ba38f5a Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Fri, 13 Sep 2013 16:30:55 -0700 Subject: [PATCH] Move border computation into unpruned traversal. Get rid of extraneous explicit initial reflow. Fixes #935. --- src/components/main/layout/block.rs | 8 +++----- src/components/main/layout/layout_task.rs | 1 + src/components/script/script_task.rs | 25 +++++++++++------------ src/test/html/test_inline_border.html | 12 +++++++++++ 4 files changed, 28 insertions(+), 18 deletions(-) create mode 100644 src/test/html/test_inline_border.html diff --git a/src/components/main/layout/block.rs b/src/components/main/layout/block.rs index 212441c8798..ccfd546ca27 100644 --- a/src/components/main/layout/block.rs +++ b/src/components/main/layout/block.rs @@ -107,11 +107,6 @@ impl BlockFlowData { /* if not an anonymous block context, add in block box's widths. these widths will not include child elements, just padding etc. */ 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)); pref_width = pref_width.add(&box.get_pref_width(ctx)); }); @@ -194,6 +189,9 @@ impl BlockFlowData { for &box in self.box.iter() { let style = box.style(); 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. model.compute_padding(style, remaining_width); diff --git a/src/components/main/layout/layout_task.rs b/src/components/main/layout/layout_task.rs index e51eb822ec1..3f497fcb458 100644 --- a/src/components/main/layout/layout_task.rs +++ b/src/components/main/layout/layout_task.rs @@ -281,6 +281,7 @@ impl LayoutTask { // FIXME: We want to do // 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. + // NOTE: this currently computes borders, so any pruning should separate that operation out. debug!("assigning widths"); do layout_root.each_preorder |flow| { flow.assign_widths(&mut layout_ctx); diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index 8701b6e8b4e..8eb37845851 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -292,6 +292,8 @@ impl Page { 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) } @@ -661,11 +663,6 @@ impl ScriptTask { }); 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. // // 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. assert!(js_scripts.is_some()); let js_scripts = js_scripts.take_unwrap(); 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. let compartment = page.js_info.get_ref().js_compartment; let cx = page.js_info.get_ref().js_context; diff --git a/src/test/html/test_inline_border.html b/src/test/html/test_inline_border.html new file mode 100644 index 00000000000..7d0e8cdfefb --- /dev/null +++ b/src/test/html/test_inline_border.html @@ -0,0 +1,12 @@ + + + + + +hi there + +