layout: Add a new MARGINS_CANNOT_COLLAPSE flow flag.

This commit is contained in:
Patrick Walton 2016-10-24 17:31:55 -07:00
parent be252371ea
commit b809aae74b
2 changed files with 7 additions and 2 deletions

View file

@ -36,7 +36,7 @@ use floats::{ClearType, FloatKind, Floats, PlacementInfo};
use flow::{self, BaseFlow, EarlyAbsolutePositionInfo, Flow, FlowClass, ForceNonfloatedFlag};
use flow::{BLOCK_POSITION_IS_STATIC, CLEARS_LEFT, CLEARS_RIGHT};
use flow::{CONTAINS_TEXT_OR_REPLACED_FRAGMENTS, INLINE_POSITION_IS_STATIC};
use flow::{FragmentationContext, PreorderFlowTraversal};
use flow::{FragmentationContext, MARGINS_CANNOT_COLLAPSE, PreorderFlowTraversal};
use flow::{ImmutableFlowUtils, LateAbsolutePositionInfo, MutableFlowUtils, OpaqueFlow};
use flow::IS_ABSOLUTELY_POSITIONED;
use flow_list::FlowList;
@ -1911,7 +1911,9 @@ impl Flow for BlockFlow {
self.fragment.restyle_damage.remove(REFLOW_OUT_OF_FLOW | REFLOW);
}
None
} else if self.is_root() || self.formatting_context_type() != FormattingContextType::None {
} else if self.is_root() ||
self.formatting_context_type() != FormattingContextType::None ||
self.base.flags.contains(MARGINS_CANNOT_COLLAPSE) {
// Root element margins should never be collapsed according to CSS § 8.3.1.
debug!("assign_block_size: assigning block_size for root flow {:?}",
flow::base(self).debug_id());

View file

@ -665,6 +665,9 @@ bitflags! {
/// Whether this flow contains any text and/or replaced fragments.
const CONTAINS_TEXT_OR_REPLACED_FRAGMENTS = 0b0001_0000_0000_0000_0000_0000,
/// Whether margins are prohibited from collapsing with this flow.
const MARGINS_CANNOT_COLLAPSE = 0b0010_0000_0000_0000_0000_0000,
}
}