Skip to content


Browse files Browse the repository at this point in the history
Force reflow in the sequential fallback of block format context
When reflowing a block format context during the inorder traversal,
propagate restyle damage manually to its children since they were
already reflowed.
  • Loading branch information
stshine committed Apr 23, 2017
1 parent 56435db commit 68f74d5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 14 deletions.
3 changes: 2 additions & 1 deletion components/layout/
Expand Up @@ -43,6 +43,7 @@ use flow_list::FlowList;
use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
use gfx_traits::print_tree::PrintTree;
use incremental::RelayoutMode;
use layout_debug;
use model::{AdjoiningMargins, CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo, MaybeAuto};
use model::{specified, specified_or_none};
Expand Down Expand Up @@ -1549,7 +1550,7 @@ impl BlockFlow {
// Re-run layout on our children.
for child in flow::mut_base(self).children.iter_mut() {
sequential::traverse_flow_tree_preorder(child, layout_context);
sequential::traverse_flow_tree_preorder(child, layout_context, RelayoutMode::Force);
// Assign our final-final block size.
Expand Down
7 changes: 7 additions & 0 deletions components/layout/
Expand Up @@ -7,6 +7,13 @@ use style::computed_values::float;
use style::selector_parser::RestyleDamage;
use style::servo::restyle_damage::{REFLOW, RECONSTRUCT_FLOW};

/// Used in a flow traversal to indicate whether this re-layout should be incremental or not.
#[derive(Clone, Copy, PartialEq)]
pub enum RelayoutMode {

bitflags! {
pub flags SpecialRestyleDamage: u8 {
#[doc = "If this flag is set, we need to reflow the entire document. This is more or less a \
Expand Down
19 changes: 14 additions & 5 deletions components/layout/
Expand Up @@ -14,8 +14,9 @@ use flow::{PostorderFlowTraversal, PreorderFlowTraversal};
use fragment::FragmentBorderBoxIterator;
use generated_content::ResolveGeneratedContent;
use incremental::RelayoutMode;
use servo_config::opts;
use style::servo::restyle_damage::{REFLOW, STORE_OVERFLOW};
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, STORE_OVERFLOW};
use traversal::{AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList};

pub use style::sequential::traverse_dom;
Expand All @@ -38,16 +39,24 @@ pub fn resolve_generated_content(root: &mut Flow, layout_context: &LayoutContext

pub fn traverse_flow_tree_preorder(root: &mut Flow,
layout_context: &LayoutContext) {
layout_context: &LayoutContext,
relayout_mode: RelayoutMode) {
fn doit(flow: &mut Flow,
assign_inline_sizes: AssignISizes,
assign_block_sizes: AssignBSizes) {
assign_block_sizes: AssignBSizes,
relayout_mode: RelayoutMode) {
// Force reflow children during this traversal. This is needed when we failed
// the float speculation of a block formatting context and need to fix it.
if relayout_mode == RelayoutMode::Force {
flow::mut_base(flow).restyle_damage.insert(REFLOW_OUT_OF_FLOW | REFLOW);

if assign_inline_sizes.should_process(flow) {

for kid in flow::child_iter_mut(flow) {
doit(kid, assign_inline_sizes, assign_block_sizes);
doit(kid, assign_inline_sizes, assign_block_sizes, relayout_mode);

if assign_block_sizes.should_process(flow) {
Expand All @@ -66,7 +75,7 @@ pub fn traverse_flow_tree_preorder(root: &mut Flow,
let assign_inline_sizes = AssignISizes { layout_context: &layout_context };
let assign_block_sizes = AssignBSizes { layout_context: &layout_context };

doit(root, assign_inline_sizes, assign_block_sizes);
doit(root, assign_inline_sizes, assign_block_sizes, relayout_mode);

pub fn build_display_list_for_subtree<'a>(flow_root: &mut Flow,
Expand Down
4 changes: 2 additions & 2 deletions components/layout_thread/
Expand Up @@ -60,7 +60,7 @@ use layout::context::heap_size_of_persistent_local_context;
use layout::display_list_builder::ToGfxColor;
use layout::flow::{self, Flow, ImmutableFlowUtils, MutableFlowUtils, MutableOwnedFlowUtils};
use layout::flow_ref::FlowRef;
use layout::incremental::{LayoutDamageComputation, REFLOW_ENTIRE_DOCUMENT};
use layout::incremental::{LayoutDamageComputation, REFLOW_ENTIRE_DOCUMENT, RelayoutMode};
use layout::layout_debug;
use layout::opaque_node::OpaqueNodeMethods;
use layout::parallel;
Expand Down Expand Up @@ -810,7 +810,7 @@ impl LayoutThread {
fn solve_constraints(layout_root: &mut Flow,
layout_context: &LayoutContext) {
let _scope = layout_debug_scope!("solve_constraints");
sequential::traverse_flow_tree_preorder(layout_root, layout_context);
sequential::traverse_flow_tree_preorder(layout_root, layout_context, RelayoutMode::Incremental);

/// Performs layout constraint solving in parallel.
Expand Down
3 changes: 0 additions & 3 deletions tests/wpt/metadata-css/css21_dev/html4/floats-038.htm.ini

This file was deleted.

This file was deleted.

0 comments on commit 68f74d5

Please sign in to comment.