InlineFormattingContextGeometry.cpp [plain text]
#include "config.h"
#include "InlineFormattingContext.h"
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
#include "FormattingContext.h"
#include "LayoutBox.h"
#include "LayoutContainerBox.h"
#include "LayoutReplacedBox.h"
#include "LengthFunctions.h"
namespace WebCore {
namespace Layout {
ContentWidthAndMargin InlineFormattingContext::Geometry::inlineBlockWidthAndMargin(const Box& formattingContextRoot, const HorizontalConstraints& horizontalConstraints, const OverrideHorizontalValues& overrideHorizontalValues)
{
ASSERT(formattingContextRoot.isInFlow());
if (formattingContextRoot.isReplacedBox())
return inlineReplacedWidthAndMargin(downcast<ReplacedBox>(formattingContextRoot), horizontalConstraints, { }, overrideHorizontalValues);
auto width = computedValue(formattingContextRoot.style().logicalWidth(), horizontalConstraints.logicalWidth);
if (!width)
width = shrinkToFitWidth(formattingContextRoot, horizontalConstraints.logicalWidth);
auto computedHorizontalMargin = Geometry::computedHorizontalMargin(formattingContextRoot, horizontalConstraints);
return ContentWidthAndMargin { *width, { computedHorizontalMargin.start.valueOr(0_lu), computedHorizontalMargin.end.valueOr(0_lu) } };
}
ContentHeightAndMargin InlineFormattingContext::Geometry::inlineBlockHeightAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverrideVerticalValues& overrideVerticalValues) const
{
ASSERT(layoutBox.isInFlow());
if (layoutBox.isReplacedBox())
return inlineReplacedHeightAndMargin(downcast<ReplacedBox>(layoutBox), horizontalConstraints, { }, overrideVerticalValues);
return complicatedCases(layoutBox, horizontalConstraints, overrideVerticalValues);
}
Optional<InlineLayoutUnit> InlineFormattingContext::Geometry::computedTextIndent(const ContainerBox& formattingContextRoot, const HorizontalConstraints& horizontalConstraints) const
{
auto textIndent = formattingContextRoot.style().textIndent();
if (textIndent == RenderStyle::initialTextIndent())
return { };
return InlineLayoutUnit { minimumValueForLength(textIndent, horizontalConstraints.logicalWidth) };
}
}
}
#endif