#ifndef PaintInfo_h
#define PaintInfo_h
#include "AffineTransform.h"
#include "GraphicsContext.h"
#include "IntRect.h"
#include "LayoutRect.h"
#include "PaintPhase.h"
#include <limits>
#include <wtf/HashMap.h>
#include <wtf/ListHashSet.h>
namespace WebCore {
class OverlapTestRequestClient;
class RenderInline;
class RenderLayerModelObject;
class RenderObject;
typedef HashMap<OverlapTestRequestClient*, IntRect> OverlapTestRequestMap;
struct PaintInfo {
PaintInfo(GraphicsContext* newContext, const LayoutRect& newRect, PaintPhase newPhase, PaintBehavior newPaintBehavior,
RenderObject* newSubtreePaintRoot = nullptr, ListHashSet<RenderInline*>* newOutlineObjects = nullptr,
OverlapTestRequestMap* overlapTestRequests = nullptr, const RenderLayerModelObject* newPaintContainer = nullptr)
: context(newContext)
, rect(newRect)
, phase(newPhase)
, paintBehavior(newPaintBehavior)
, subtreePaintRoot(newSubtreePaintRoot)
, outlineObjects(newOutlineObjects)
, overlapTestRequests(overlapTestRequests)
, paintContainer(newPaintContainer)
{
}
void updateSubtreePaintRootForChildren(const RenderObject* renderer)
{
if (!subtreePaintRoot)
return;
if (subtreePaintRoot == renderer) {
subtreePaintRoot = nullptr;
return;
}
}
bool shouldPaintWithinRoot(const RenderObject& renderer) const
{
return !subtreePaintRoot || subtreePaintRoot == &renderer;
}
bool forceBlackText() const { return paintBehavior & PaintBehaviorForceBlackText; }
bool skipRootBackground() const { return paintBehavior & PaintBehaviorSkipRootBackground; }
bool paintRootBackgroundOnly() const { return paintBehavior & PaintBehaviorRootBackgroundOnly; }
void applyTransform(const AffineTransform& localToAncestorTransform)
{
if (localToAncestorTransform.isIdentity())
return;
context->concatCTM(localToAncestorTransform);
if (rect == LayoutRect::infiniteRect())
return;
FloatRect tranformedRect(localToAncestorTransform.inverse().mapRect(rect));
rect.setLocation(LayoutPoint(tranformedRect.location()));
rect.setSize(LayoutSize(tranformedRect.size()));
}
GraphicsContext* context;
LayoutRect rect;
PaintPhase phase;
PaintBehavior paintBehavior;
RenderObject* subtreePaintRoot; ListHashSet<RenderInline*>* outlineObjects; OverlapTestRequestMap* overlapTestRequests;
const RenderLayerModelObject* paintContainer; };
}
#endif // PaintInfo_h