#ifndef RenderSelectionInfo_h
#define RenderSelectionInfo_h
#include "core/rendering/RenderBox.h"
#include "platform/geometry/IntRect.h"
namespace WebCore {
class RenderSelectionInfoBase {
WTF_MAKE_NONCOPYABLE(RenderSelectionInfoBase); WTF_MAKE_FAST_ALLOCATED;
public:
RenderSelectionInfoBase()
: m_object(0)
, m_repaintContainer(0)
, m_state(RenderObject::SelectionNone)
{
}
RenderSelectionInfoBase(RenderObject* o)
: m_object(o)
, m_repaintContainer(o->containerForRepaint())
, m_state(o->selectionState())
{
}
RenderObject* object() const { return m_object; }
RenderLayerModelObject* repaintContainer() const { return m_repaintContainer; }
RenderObject::SelectionState state() const { return m_state; }
protected:
RenderObject* m_object;
RenderLayerModelObject* m_repaintContainer;
RenderObject::SelectionState m_state;
};
class RenderSelectionInfo : public RenderSelectionInfoBase {
public:
RenderSelectionInfo(RenderObject* o, bool clipToVisibleContent)
: RenderSelectionInfoBase(o)
, m_rect(o->canUpdateSelectionOnRootLineBoxes() ? o->selectionRectForRepaint(m_repaintContainer, clipToVisibleContent) : LayoutRect())
{
}
void repaint()
{
m_object->repaintUsingContainer(m_repaintContainer, enclosingIntRect(m_rect), InvalidationSelection);
}
LayoutRect rect() const { return m_rect; }
private:
LayoutRect m_rect;
};
class RenderBlockSelectionInfo : public RenderSelectionInfoBase {
public:
RenderBlockSelectionInfo(RenderBlock* b)
: RenderSelectionInfoBase(b)
, m_rects(b->canUpdateSelectionOnRootLineBoxes() ? block()->selectionGapRectsForRepaint(m_repaintContainer) : GapRects())
{
}
void repaint()
{
m_object->repaintUsingContainer(m_repaintContainer, enclosingIntRect(m_rects), InvalidationSelection);
}
RenderBlock* block() const { return toRenderBlock(m_object); }
GapRects rects() const { return m_rects; }
private:
GapRects m_rects;
};
}
#endif