#ifndef RenderRegion_h
#define RenderRegion_h
#include "RenderReplaced.h"
namespace WebCore {
class RenderBox;
class RenderBoxRegionInfo;
class RenderFlowThread;
class RenderNamedFlowThread;
class RenderRegion : public RenderReplaced {
public:
explicit RenderRegion(Node*, RenderFlowThread*);
virtual bool isRenderRegion() const { return true; }
virtual void paintReplaced(PaintInfo&, const LayoutPoint&);
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
void setRegionRect(const LayoutRect& rect) { m_regionRect = rect; }
LayoutRect regionRect() const { return m_regionRect; }
LayoutRect regionOverflowRect() const;
void attachRegion();
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; }
bool hasCustomRegionStyle() const { return m_hasCustomRegionStyle; }
void setHasCustomRegionStyle(bool hasCustomRegionStyle) { m_hasCustomRegionStyle = hasCustomRegionStyle; }
virtual void layout();
RenderBoxRegionInfo* renderBoxRegionInfo(const RenderBox*) const;
RenderBoxRegionInfo* setRenderBoxRegionInfo(const RenderBox*, LayoutUnit logicalLeftInset, LayoutUnit logicalRightInset,
bool containingBlockChainIsInset);
PassOwnPtr<RenderBoxRegionInfo> takeRenderBoxRegionInfo(const RenderBox*);
void removeRenderBoxRegionInfo(const RenderBox*);
void deleteAllRenderBoxRegionInfo();
LayoutUnit offsetFromLogicalTopOfFirstPage() const;
bool isFirstRegion() const;
bool isLastRegion() const;
void clearBoxStyleInRegion(const RenderBox*);
enum RegionState {
RegionUndefined,
RegionEmpty,
RegionFit,
RegionOverflow
};
RegionState regionState() const { return isValid() ? m_regionState : RegionUndefined; }
void setRegionState(RegionState regionState) { m_regionState = regionState; }
void setDispatchRegionLayoutUpdateEvent(bool value) { m_dispatchRegionLayoutUpdateEvent = value; }
bool shouldDispatchRegionLayoutUpdateEvent() { return m_dispatchRegionLayoutUpdateEvent; }
private:
virtual const char* renderName() const { return "RenderRegion"; }
virtual void insertedIntoTree() OVERRIDE;
virtual void willBeRemovedFromTree() OVERRIDE;
PassRefPtr<RenderStyle> renderBoxRegionStyle(const RenderBox*);
PassRefPtr<RenderStyle> computeStyleInRegion(const RenderBox*);
void setRegionBoxesRegionStyle();
void restoreRegionBoxesOriginalStyle();
RenderFlowThread* m_flowThread;
RenderNamedFlowThread* m_parentNamedFlowThread;
LayoutRect m_regionRect;
typedef HashMap<const RenderBox*, OwnPtr<RenderBoxRegionInfo> > RenderBoxRegionInfoMap;
RenderBoxRegionInfoMap m_renderBoxRegionInfo;
typedef HashMap<const RenderBox*, RefPtr<RenderStyle> > RenderBoxRegionStyleMap;
RenderBoxRegionStyleMap m_renderBoxRegionStyle;
bool m_isValid;
bool m_hasCustomRegionStyle;
RegionState m_regionState;
bool m_dispatchRegionLayoutUpdateEvent;
};
inline RenderRegion* toRenderRegion(RenderObject* object)
{
ASSERT(!object || object->isRenderRegion());
return static_cast<RenderRegion*>(object);
}
inline const RenderRegion* toRenderRegion(const RenderObject* object)
{
ASSERT(!object || object->isRenderRegion());
return static_cast<const RenderRegion*>(object);
}
void toRenderRegion(const RenderRegion*);
}
#endif // RenderRegion_h