From c0b7a1247a295e78487fa8112d3ca4ca8d036c15 Mon Sep 17 00:00:00 2001 From: Pu Xingyu Date: Sat, 8 Apr 2017 23:41:53 +0800 Subject: [PATCH] layout: Ensure abs-pos elements establish block formatting contexts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per CSS 2.1 ยง 9.4.1, absolutely positioned elements establish new block formatting contexts for their contents. --- components/layout/block.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/layout/block.rs b/components/layout/block.rs index 5504f0fc4121..7707b833475c 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -1429,6 +1429,9 @@ impl BlockFlow { /// Determines the type of formatting context this is. See the definition of /// `FormattingContextType`. pub fn formatting_context_type(&self) -> FormattingContextType { + if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) { + return FormattingContextType::Other + } let style = self.fragment.style(); if style.get_box().float != float::T::none { return FormattingContextType::Other