FormattingContextQuirks.cpp [plain text]
#include "config.h"
#include "FormattingContext.h"
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
#include "LayoutBox.h"
#include "LayoutBoxGeometry.h"
#include "LayoutInitialContainingBlock.h"
namespace WebCore {
namespace Layout {
LayoutUnit FormattingContext::Quirks::heightValueOfNearestContainingBlockWithFixedHeight(const Box& layoutBox)
{
auto& formattingContext = this->formattingContext();
auto* containingBlock = &layoutBox.containingBlock();
LayoutUnit bodyAndDocumentVerticalMarginPaddingAndBorder;
while (containingBlock) {
auto containingBlockHeight = containingBlock->style().logicalHeight();
if (containingBlockHeight.isFixed())
return LayoutUnit(containingBlockHeight.value() - bodyAndDocumentVerticalMarginPaddingAndBorder);
if (containingBlock->isBodyBox() || containingBlock->isDocumentBox()) {
auto geometry = formattingContext.geometry();
auto horizontalConstraints = geometry.constraintsForInFlowContent(containingBlock->containingBlock(), FormattingContext::EscapeReason::FindFixedHeightAncestorQuirk).horizontal;
auto verticalMargin = geometry.computedVerticalMargin(*containingBlock, horizontalConstraints);
auto& boxGeometry = formattingContext.geometryForBox(*containingBlock, FormattingContext::EscapeReason::FindFixedHeightAncestorQuirk);
auto verticalPadding = boxGeometry.paddingTop().valueOr(0) + boxGeometry.paddingBottom().valueOr(0);
auto verticalBorder = boxGeometry.borderTop() + boxGeometry.borderBottom();
bodyAndDocumentVerticalMarginPaddingAndBorder += verticalMargin.before.valueOr(0) + verticalMargin.after.valueOr(0) + verticalPadding + verticalBorder;
}
if (is<InitialContainingBlock>(*containingBlock))
break;
containingBlock = &containingBlock->containingBlock();
}
return formattingContext.geometryForBox(layoutBox.initialContainingBlock(), FormattingContext::EscapeReason::FindFixedHeightAncestorQuirk).contentBox().height() - bodyAndDocumentVerticalMarginPaddingAndBorder;
}
}
}
#endif