#ifndef RenderRegion_h
#define RenderRegion_h
#include "RenderBlockFlow.h"
#include "StyleInheritedData.h"
#include "VisiblePosition.h"
#include <memory>
namespace WebCore {
struct LayerFragment;
typedef Vector<LayerFragment, 1> LayerFragments;
class Element;
class RenderBox;
class RenderBoxRegionInfo;
class RenderFlowThread;
class RenderNamedFlowThread;
class RenderRegion : public RenderBlockFlow {
public:
virtual bool isRenderRegion() const override final { return true; }
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
void setFlowThreadPortionRect(const LayoutRect& rect) { m_flowThreadPortionRect = rect; }
LayoutRect flowThreadPortionRect() const { return m_flowThreadPortionRect; }
LayoutRect flowThreadPortionOverflowRect();
LayoutPoint flowThreadPortionLocation() const;
virtual void attachRegion();
virtual void detachRegion();
RenderNamedFlowThread* parentNamedFlowThread() const { return m_parentNamedFlowThread; }
RenderFlowThread* flowThread() const { return m_flowThread; }
bool isValid() const { return m_isValid; }
void setIsValid(bool valid) { m_isValid = valid; }
RenderBoxRegionInfo* renderBoxRegionInfo(const RenderBox*) const;
RenderBoxRegionInfo* setRenderBoxRegionInfo(const RenderBox*, LayoutUnit logicalLeftInset, LayoutUnit logicalRightInset,
bool containingBlockChainIsInset);
std::unique_ptr<RenderBoxRegionInfo> takeRenderBoxRegionInfo(const RenderBox*);
void removeRenderBoxRegionInfo(const RenderBox*);
void deleteAllRenderBoxRegionInfo();
bool isFirstRegion() const;
bool isLastRegion() const;
virtual bool shouldClipFlowThreadContent() const;
virtual LayoutUnit pageLogicalWidth() const;
virtual LayoutUnit pageLogicalHeight() const;
LayoutUnit logicalTopOfFlowThreadContentRect(const LayoutRect&) const;
LayoutUnit logicalBottomOfFlowThreadContentRect(const LayoutRect&) const;
LayoutUnit logicalTopForFlowThreadContent() const { return logicalTopOfFlowThreadContentRect(flowThreadPortionRect()); };
LayoutUnit logicalBottomForFlowThreadContent() const { return logicalBottomOfFlowThreadContentRect(flowThreadPortionRect()); };
virtual LayoutUnit logicalHeightOfAllFlowThreadContent() const;
virtual LayoutUnit pageLogicalTopForOffset(LayoutUnit offset) const;
virtual bool isRenderRegionSet() const { return false; }
virtual void repaintFlowThreadContent(const LayoutRect& repaintRect);
virtual void collectLayerFragments(LayerFragments&, const LayoutRect&, const LayoutRect&) { }
virtual void adjustRegionBoundsFromFlowThreadPortionRect(const LayoutPoint& layerOffset, LayoutRect& regionBounds);
void addLayoutOverflowForBox(const RenderBox*, const LayoutRect&);
void addVisualOverflowForBox(const RenderBox*, const LayoutRect&);
LayoutRect layoutOverflowRectForBox(const RenderBox*);
LayoutRect visualOverflowRectForBox(const RenderBoxModelObject*);
LayoutRect layoutOverflowRectForBoxForPropagation(const RenderBox*);
LayoutRect visualOverflowRectForBoxForPropagation(const RenderBoxModelObject*);
LayoutRect rectFlowPortionForBox(const RenderBox*, const LayoutRect&) const;
void setRegionObjectsRegionStyle();
void restoreRegionObjectsOriginalStyle();
virtual bool canHaveChildren() const override { return false; }
virtual bool canHaveGeneratedChildren() const override { return true; }
virtual VisiblePosition positionForPoint(const LayoutPoint&, const RenderRegion*) override;
virtual bool hasAutoLogicalHeight() const { return false; }
virtual void absoluteQuadsForBoxInRegion(Vector<FloatQuad>&, bool*, const RenderBox*, float, float) { }
protected:
RenderRegion(Element&, PassRef<RenderStyle>, RenderFlowThread*);
RenderRegion(Document&, PassRef<RenderStyle>, RenderFlowThread*);
void ensureOverflowForBox(const RenderBox*, RefPtr<RenderOverflow>&, bool);
virtual void computePreferredLogicalWidths() override;
virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const override;
enum OverflowType {
LayoutOverflow = 0,
VisualOverflow
};
LayoutRect overflowRectForFlowThreadPortion(const LayoutRect& flowThreadPortionRect, bool isFirstPortion, bool isLastPortion, OverflowType);
void repaintFlowThreadContentRectangle(const LayoutRect& repaintRect, const LayoutRect& flowThreadPortionRect, const LayoutPoint& regionLocation, const LayoutRect* flowThreadPortionClipRect = 0);
void computeOverflowFromFlowThread();
private:
virtual const char* renderName() const { return "RenderRegion"; }
virtual void insertedIntoTree() override;
virtual void willBeRemovedFromTree() override;
virtual void installFlowThread();
LayoutPoint mapRegionPointIntoFlowThreadCoordinates(const LayoutPoint&);
protected:
RenderFlowThread* m_flowThread;
private:
RenderNamedFlowThread* m_parentNamedFlowThread;
LayoutRect m_flowThreadPortionRect;
typedef HashMap<const RenderBox*, std::unique_ptr<RenderBoxRegionInfo>> RenderBoxRegionInfoMap;
RenderBoxRegionInfoMap m_renderBoxRegionInfo;
bool m_isValid : 1;
};
RENDER_OBJECT_TYPE_CASTS(RenderRegion, isRenderRegion())
class CurrentRenderRegionMaintainer {
WTF_MAKE_NONCOPYABLE(CurrentRenderRegionMaintainer);
public:
CurrentRenderRegionMaintainer(RenderRegion&);
~CurrentRenderRegionMaintainer();
RenderRegion& region() const { return m_region; }
private:
RenderRegion& m_region;
};
}
#endif // RenderRegion_h