diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 2f23c9b2336a..9f993e4ac15c 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -6645,8 +6645,19 @@ nsBlockFrame::Init(nsIContent* aContent, nsBlockFrameSuper::Init(aContent, aParent, aPrevInFlow); if (!aPrevInFlow || - aPrevInFlow->GetStateBits() & NS_BLOCK_NEEDS_BIDI_RESOLUTION) + aPrevInFlow->GetStateBits() & NS_BLOCK_NEEDS_BIDI_RESOLUTION) { AddStateBits(NS_BLOCK_NEEDS_BIDI_RESOLUTION); + } + + // If a box has a different block flow direction than its containing block: + // ... + // If the box is a block container, then it establishes a new block + // formatting context. + // (http://dev.w3.org/csswg/css-writing-modes/#block-flow) + if (GetParent() && StyleVisibility()->mWritingMode != + GetParent()->StyleVisibility()->mWritingMode) { + AddStateBits(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT); + } if ((GetStateBits() & (NS_FRAME_FONT_INFLATION_CONTAINER | NS_BLOCK_FLOAT_MGR)) ==