From b809aae74b5b5b993cca1ee8622b8800fcdd1c61 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 24 Oct 2016 17:31:55 -0700 Subject: [PATCH] layout: Add a new `MARGINS_CANNOT_COLLAPSE` flow flag. --- components/layout/block.rs | 6 ++++-- components/layout/flow.rs | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/components/layout/block.rs b/components/layout/block.rs index df1f001076f..1658a703182 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -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()); diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 0e92de265d1..0a595cdc4aa 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -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, } }