InlineFormattingContextGeometry.cpp [plain text]
#include "config.h"
#include "InlineFormattingContext.h"
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
#include "FormattingContext.h"
#include "LayoutBox.h"
#include "LayoutContainer.h"
#include "LengthFunctions.h"
namespace WebCore {
namespace Layout {
ContentWidthAndMargin InlineFormattingContext::Geometry::inlineBlockWidthAndMargin(const Box& formattingContextRoot, const UsedHorizontalValues& usedHorizontalValues)
{
ASSERT(formattingContextRoot.isInFlow());
if (formattingContextRoot.replaced())
return inlineReplacedWidthAndMargin(formattingContextRoot, usedHorizontalValues);
auto width = computedValueIfNotAuto(formattingContextRoot.style().logicalWidth(), usedHorizontalValues.constraints.width);
if (!width)
width = shrinkToFitWidth(formattingContextRoot, usedHorizontalValues.constraints.width);
auto computedHorizontalMargin = Geometry::computedHorizontalMargin(formattingContextRoot, usedHorizontalValues);
return ContentWidthAndMargin { *width, { computedHorizontalMargin.start.valueOr(0_lu), computedHorizontalMargin.end.valueOr(0_lu) }, computedHorizontalMargin };
}
ContentHeightAndMargin InlineFormattingContext::Geometry::inlineBlockHeightAndMargin(const Box& layoutBox, const UsedHorizontalValues& usedHorizontalValues, const UsedVerticalValues& usedVerticalValues) const
{
ASSERT(layoutBox.isInFlow());
if (layoutBox.replaced())
return inlineReplacedHeightAndMargin(layoutBox, usedHorizontalValues, usedVerticalValues);
return complicatedCases(layoutBox, usedHorizontalValues, usedVerticalValues);
}
Optional<InlineLayoutUnit> InlineFormattingContext::Geometry::computedTextIndent(const Container& formattingContextRoot, const UsedHorizontalValues::Constraints& horizontalConstraints) const
{
auto textIndent = formattingContextRoot.style().textIndent();
if (textIndent == RenderStyle::initialTextIndent())
return { };
return InlineLayoutUnit { minimumValueForLength(textIndent, horizontalConstraints.width) };
}
}
}
#endif