shouldEstablishInlineFormattingContext method
Check if this element should establish an inline formatting context. This method checks from the RenderObject perspective to properly handle anonymous blocks that may wrap inline elements.
Implementation
bool shouldEstablishInlineFormattingContext() {
// Block and inline-block containers can establish inline formatting contexts
if (effectiveDisplay != CSSDisplay.block && effectiveDisplay != CSSDisplay.inlineBlock) {
return false;
}
// Per CSS Inline Layout (css-inline-3) and CSS 2.1 §9.4.2, a block container
// establishes an inline formatting context for its inline-level content
// regardless of the 'overflow' property. Overflow only affects painting and
// scrollability (block formatting context establishment), not whether inline
// content forms line boxes. Therefore, do NOT early-return here when overflow
// is not visible; allow IFC when the content qualifies.
// Do not special-case BODY/HTML here. They can also establish IFC
// when they contain only inline content and no block-level content.
// Positioned elements (absolute/fixed) are taken out of normal flow with
// respect to their placement, but their in-flow descendants still form
// formatting contexts as usual. Per CSS 2.1 §9.4.1 and css-position-3,
// an absolutely positioned block container with inline-level content
// still establishes an inline formatting context for its content.
// Therefore, do NOT block IFC establishment solely due to positioning.
// Flex items may establish their own IFC; do not block based on parent.
// Do not suppress IFC solely because the parent is inline-level.
// A block container inside an inline element creates anonymous block boxes
// and still establishes an inline formatting context for its inline content
// per CSS 2.1 §9.2.1.1 and §9.4.2.
// Check children from RenderObject perspective
// This properly accounts for anonymous blocks
return _shouldEstablishIFCFromRenderObject();
}