#ifndef PaintInfo_h
#define PaintInfo_h
#include <limits>
#include "core/rendering/PaintPhase.h"
#include "platform/geometry/IntRect.h"
#include "platform/geometry/LayoutRect.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/transforms/AffineTransform.h"
#include "wtf/HashMap.h"
#include "wtf/ListHashSet.h"
namespace WebCore {
class RenderInline;
class RenderLayerModelObject;
class RenderObject;
class RenderWidget;
typedef HashMap<RenderWidget*, IntRect> OverlapTestRequestMap;
struct PaintInfo {
PaintInfo(GraphicsContext* newContext, const IntRect& newRect, PaintPhase newPhase, PaintBehavior newPaintBehavior,
RenderObject* newPaintingRoot = 0, ListHashSet<RenderInline*>* newOutlineObjects = 0,
OverlapTestRequestMap* overlapTestRequests = 0, const RenderLayerModelObject* newPaintContainer = 0)
: context(newContext)
, rect(newRect)
, phase(newPhase)
, paintBehavior(newPaintBehavior)
, paintingRoot(newPaintingRoot)
, overlapTestRequests(overlapTestRequests)
, m_paintContainer(newPaintContainer)
, m_outlineObjects(newOutlineObjects)
{
}
void updatePaintingRootForChildren(const RenderObject* renderer)
{
if (!paintingRoot)
return;
if (paintingRoot == renderer) {
paintingRoot = 0;
return;
}
}
bool shouldPaintWithinRoot(const RenderObject* renderer) const
{
return !paintingRoot || paintingRoot == renderer;
}
bool forceBlackText() const { return paintBehavior & PaintBehaviorForceBlackText; }
bool skipRootBackground() const { return paintBehavior & PaintBehaviorSkipRootBackground; }
bool paintRootBackgroundOnly() const { return paintBehavior & PaintBehaviorRootBackgroundOnly; }
void applyTransform(const AffineTransform& localToAncestorTransform, bool identityStatusUnknown = true)
{
if (identityStatusUnknown && localToAncestorTransform.isIdentity())
return;
context->concatCTM(localToAncestorTransform);
if (rect == infiniteRect())
return;
if (localToAncestorTransform.isInvertible())
rect = localToAncestorTransform.inverse().mapRect(rect);
else
rect.setSize(IntSize(0, 0));
}
static IntRect infiniteRect() { return IntRect(LayoutRect::infiniteRect()); }
const RenderLayerModelObject* paintContainer() const { return m_paintContainer; }
ListHashSet<RenderInline*>* outlineObjects() { return m_outlineObjects; }
void setOutlineObjects(ListHashSet<RenderInline*>* objects) { m_outlineObjects = objects; }
GraphicsContext* context;
IntRect rect;
PaintPhase phase;
PaintBehavior paintBehavior;
RenderObject* paintingRoot;
OverlapTestRequestMap* overlapTestRequests;
private:
const RenderLayerModelObject* m_paintContainer;
ListHashSet<RenderInline*>* m_outlineObjects;
};
}
#endif