#ifndef RenderGeometryMap_h
#define RenderGeometryMap_h
#include "core/rendering/RenderObject.h"
#include "platform/geometry/FloatPoint.h"
#include "platform/geometry/FloatQuad.h"
#include "platform/geometry/IntSize.h"
#include "platform/geometry/LayoutSize.h"
#include "platform/transforms/TransformationMatrix.h"
#include "wtf/OwnPtr.h"
namespace WebCore {
class RenderLayer;
class RenderLayerModelObject;
class RenderView;
class TransformState;
struct RenderGeometryMapStep {
RenderGeometryMapStep(const RenderGeometryMapStep& o)
: m_renderer(o.m_renderer)
, m_offset(o.m_offset)
, m_offsetForFixedPosition(o.m_offsetForFixedPosition)
, m_accumulatingTransform(o.m_accumulatingTransform)
, m_isNonUniform(o.m_isNonUniform)
, m_isFixedPosition(o.m_isFixedPosition)
, m_hasTransform(o.m_hasTransform)
{
ASSERT(!o.m_transform);
}
RenderGeometryMapStep(const RenderObject* renderer, bool accumulatingTransform, bool isNonUniform, bool isFixedPosition, bool hasTransform)
: m_renderer(renderer)
, m_accumulatingTransform(accumulatingTransform)
, m_isNonUniform(isNonUniform)
, m_isFixedPosition(isFixedPosition)
, m_hasTransform(hasTransform)
{
}
const RenderObject* m_renderer;
LayoutSize m_offset;
OwnPtr<TransformationMatrix> m_transform;
LayoutSize m_offsetForFixedPosition;
bool m_accumulatingTransform;
bool m_isNonUniform;
bool m_isFixedPosition;
bool m_hasTransform;
};
class RenderGeometryMap {
WTF_MAKE_NONCOPYABLE(RenderGeometryMap);
public:
RenderGeometryMap(MapCoordinatesFlags = UseTransforms);
~RenderGeometryMap();
MapCoordinatesFlags mapCoordinatesFlags() const { return m_mapCoordinatesFlags; }
FloatPoint absolutePoint(const FloatPoint& p) const
{
return mapToContainer(p, 0);
}
FloatRect absoluteRect(const FloatRect& rect) const
{
return mapToContainer(rect, 0).boundingBox();
}
FloatPoint mapToContainer(const FloatPoint&, const RenderLayerModelObject*) const;
FloatQuad mapToContainer(const FloatRect&, const RenderLayerModelObject*) const;
void pushMappingsToAncestor(const RenderLayer*, const RenderLayer* ancestorLayer);
void popMappingsToAncestor(const RenderLayer*);
void pushMappingsToAncestor(const RenderObject*, const RenderLayerModelObject* ancestorRenderer);
void popMappingsToAncestor(const RenderLayerModelObject*);
void push(const RenderObject*, const LayoutSize&, bool accumulatingTransform = false, bool isNonUniform = false, bool isFixedPosition = false, bool hasTransform = false, LayoutSize offsetForFixedPosition = LayoutSize());
void push(const RenderObject*, const TransformationMatrix&, bool accumulatingTransform = false, bool isNonUniform = false, bool isFixedPosition = false, bool hasTransform = false, LayoutSize offsetForFixedPosition = LayoutSize());
private:
void mapToContainer(TransformState&, const RenderLayerModelObject* container = 0) const;
void stepInserted(const RenderGeometryMapStep&);
void stepRemoved(const RenderGeometryMapStep&);
bool hasNonUniformStep() const { return m_nonUniformStepsCount; }
bool hasTransformStep() const { return m_transformedStepsCount; }
bool hasFixedPositionStep() const { return m_fixedStepsCount; }
#ifndef NDEBUG
void dumpSteps();
#endif
#if !ASSERT_DISABLED
bool isTopmostRenderView(const RenderObject* renderer) const;
#endif
typedef Vector<RenderGeometryMapStep, 32> RenderGeometryMapSteps;
size_t m_insertionPosition;
int m_nonUniformStepsCount;
int m_transformedStepsCount;
int m_fixedStepsCount;
RenderGeometryMapSteps m_mapping;
LayoutSize m_accumulatedOffset;
MapCoordinatesFlags m_mapCoordinatesFlags;
};
}
namespace WTF {
template<> struct VectorTraits<WebCore::RenderGeometryMapStep> : SimpleClassVectorTraits<WebCore::RenderGeometryMapStep> { };
}
#endif