FormattingContext.h [plain text]
#pragma once
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
#include "DisplayBox.h"
#include <wtf/IsoMalloc.h>
#include <wtf/WeakPtr.h>
namespace WebCore {
class LayoutPoint;
class LayoutUnit;
namespace Layout {
class Box;
class Container;
class FormattingState;
class LayoutState;
class FormattingContext {
WTF_MAKE_ISO_ALLOCATED(FormattingContext);
public:
FormattingContext(const Box& formattingContextRoot, FormattingState&);
virtual ~FormattingContext();
virtual void layout() const = 0;
void layoutOutOfFlowDescendants(const Box&) const;
struct InstrinsicWidthConstraints {
LayoutUnit minimum;
LayoutUnit maximum;
};
virtual InstrinsicWidthConstraints instrinsicWidthConstraints() const = 0;
static Display::Box mapBoxToAncestor(const LayoutState&, const Box&, const Container& ancestor);
static Point mapTopLeftToAncestor(const LayoutState&, const Box&, const Container& ancestor);
static Point mapCoordinateToAncestor(const LayoutState&, Point, const Container& containingBlock, const Container& ancestor);
protected:
using LayoutQueue = Vector<const Box*>;
FormattingState& formattingState() const;
LayoutState& layoutState() const;
const Box& root() const { return *m_root; }
void computeBorderAndPadding(const Box&) const;
#ifndef NDEBUG
virtual void validateGeometryConstraintsAfterLayout() const;
#endif
class Geometry {
public:
static VerticalGeometry outOfFlowVerticalGeometry(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { });
static HorizontalGeometry outOfFlowHorizontalGeometry(LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { });
static HeightAndMargin floatingHeightAndMargin(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { });
static WidthAndMargin floatingWidthAndMargin(LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { });
static HeightAndMargin inlineReplacedHeightAndMargin(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { });
static WidthAndMargin inlineReplacedWidthAndMargin(const LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { },
Optional<LayoutUnit> precomputedMarginStart = { }, Optional<LayoutUnit> precomputedMarginEnd = { });
static LayoutSize inFlowPositionedPositionOffset(const LayoutState&, const Box&);
static HeightAndMargin complicatedCases(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { });
static LayoutUnit shrinkToFitWidth(LayoutState&, const Box&);
static Edges computedBorder(const LayoutState&, const Box&);
static Optional<Edges> computedPadding(const LayoutState&, const Box&);
static ComputedHorizontalMargin computedHorizontalMargin(const LayoutState&, const Box&);
static ComputedVerticalMargin computedVerticalMargin(const LayoutState&, const Box&);
static Optional<LayoutUnit> computedValueIfNotAuto(const Length& geometryProperty, LayoutUnit containingBlockWidth);
static Optional<LayoutUnit> fixedValue(const Length& geometryProperty);
static Optional<LayoutUnit> computedMinHeight(const LayoutState&, const Box&);
static Optional<LayoutUnit> computedMaxHeight(const LayoutState&, const Box&);
protected:
enum class HeightType { Min, Max, Normal };
static Optional<LayoutUnit> computedHeightValue(const LayoutState&, const Box&, HeightType);
private:
static VerticalGeometry outOfFlowReplacedVerticalGeometry(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { });
static HorizontalGeometry outOfFlowReplacedHorizontalGeometry(const LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { });
static VerticalGeometry outOfFlowNonReplacedVerticalGeometry(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { });
static HorizontalGeometry outOfFlowNonReplacedHorizontalGeometry(LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { });
static HeightAndMargin floatingReplacedHeightAndMargin(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { });
static WidthAndMargin floatingReplacedWidthAndMargin(const LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { });
static WidthAndMargin floatingNonReplacedWidthAndMargin(LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { });
};
class Quirks {
public:
static LayoutUnit heightValueOfNearestContainingBlockWithFixedHeight(const LayoutState&, const Box&);
};
private:
void computeOutOfFlowVerticalGeometry(const Box&) const;
void computeOutOfFlowHorizontalGeometry(const Box&) const;
WeakPtr<const Box> m_root;
FormattingState& m_formattingState;
};
}
}
#endif