#ifndef RenderView_h
#define RenderView_h
#include "FrameView.h"
#include "LayoutState.h"
#include "RenderBlock.h"
#include <wtf/OwnPtr.h>
namespace WebCore {
class RenderWidget;
#if USE(ACCELERATED_COMPOSITING)
class RenderLayerCompositor;
#endif
class RenderView : public RenderBlock {
public:
RenderView(Node*, FrameView*);
virtual ~RenderView();
virtual const char* renderName() const { return "RenderView"; }
virtual bool isRenderView() const { return true; }
virtual bool requiresLayer() const { return true; }
virtual bool isChildAllowed(RenderObject*, RenderStyle*) const;
virtual void layout();
virtual void calcWidth();
virtual void calcHeight();
virtual void calcPrefWidths();
int viewHeight() const;
int viewWidth() const;
float zoomFactor() const;
FrameView* frameView() const { return m_frameView; }
virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false);
virtual void repaintViewRectangle(const IntRect&, bool immediate = false);
virtual void repaintRectangleInViewAndCompositedLayers(const IntRect&, bool immediate = false);
virtual void paint(PaintInfo&, int tx, int ty);
virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
enum SelectionRepaintMode { RepaintNewXOROld, RepaintNewMinusOld };
void setSelection(RenderObject* start, int startPos, RenderObject* end, int endPos, SelectionRepaintMode = RepaintNewXOROld);
void clearSelection();
virtual RenderObject* selectionStart() const { return m_selectionStart; }
virtual RenderObject* selectionEnd() const { return m_selectionEnd; }
bool printing() const;
void setPrintImages(bool enable) { m_printImages = enable; }
bool printImages() const { return m_printImages; }
void setTruncatedAt(int y) { m_truncatedAt = y; m_bestTruncatedAt = m_truncatorWidth = 0; m_minimumColumnHeight = 0; m_forcedPageBreak = false; }
void setBestTruncatedAt(int y, RenderBoxModelObject* forRenderer, bool forcedBreak = false);
void setMinimumColumnHeight(int height) { m_minimumColumnHeight = height; }
int bestTruncatedAt() const { return m_bestTruncatedAt; }
int minimumColumnHeight() const { return m_minimumColumnHeight; }
int truncatedAt() const { return m_truncatedAt; }
virtual void absoluteRects(Vector<IntRect>&, int tx, int ty);
virtual void absoluteQuads(Vector<FloatQuad>&);
IntRect selectionBounds(bool clipToVisibleContent = true) const;
#if USE(ACCELERATED_COMPOSITING)
void setMaximalOutlineSize(int o);
#else
void setMaximalOutlineSize(int o) { m_maximalOutlineSize = o; }
#endif
int maximalOutlineSize() const { return m_maximalOutlineSize; }
virtual IntRect viewRect() const;
void selectionStartEnd(int& startPos, int& endPos) const;
IntRect printRect() const { return m_printRect; }
void setPrintRect(const IntRect& r) { m_printRect = r; }
void updateWidgetPositions();
void addWidget(RenderWidget*);
void removeWidget(RenderWidget*);
IntSize layoutDelta() const
{
return m_layoutState ? m_layoutState->m_layoutDelta : IntSize();
}
void addLayoutDelta(const IntSize& delta)
{
if (m_layoutState)
m_layoutState->m_layoutDelta += delta;
}
bool doingFullRepaint() const { return m_frameView->needsFullRepaint(); }
void pushLayoutState(RenderBox* renderer, const IntSize& offset)
{
if (doingFullRepaint())
return;
m_layoutState = new (renderArena()) LayoutState(m_layoutState, renderer, offset);
}
void pushLayoutState(RenderObject*);
void popLayoutState()
{
if (doingFullRepaint())
return;
LayoutState* state = m_layoutState;
m_layoutState = state->m_next;
state->destroy(renderArena());
}
bool shouldDisableLayoutStateForSubtree(RenderObject*) const;
bool layoutStateEnabled() const { return m_layoutStateDisableCount == 0 && m_layoutState; }
LayoutState* layoutState() const { return m_layoutState; }
void disableLayoutState() { m_layoutStateDisableCount++; }
void enableLayoutState() { ASSERT(m_layoutStateDisableCount > 0); m_layoutStateDisableCount--; }
virtual void updateHitTestResult(HitTestResult&, const IntPoint&);
void didMoveOnscreen();
void willMoveOffscreen();
#if USE(ACCELERATED_COMPOSITING)
RenderLayerCompositor* compositor();
bool usesCompositing() const;
#endif
protected:
virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&) const;
virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
private:
bool shouldRepaint(const IntRect& r) const;
int docHeight() const;
int docWidth() const;
protected:
FrameView* m_frameView;
RenderObject* m_selectionStart;
RenderObject* m_selectionEnd;
int m_selectionStartPos;
int m_selectionEndPos;
bool m_printImages;
int m_truncatedAt;
int m_maximalOutlineSize; IntRect m_printRect;
typedef HashSet<RenderWidget*> RenderWidgetSet;
RenderWidgetSet m_widgets;
private:
int m_bestTruncatedAt;
int m_truncatorWidth;
int m_minimumColumnHeight;
bool m_forcedPageBreak;
LayoutState* m_layoutState;
unsigned m_layoutStateDisableCount;
#if USE(ACCELERATED_COMPOSITING)
OwnPtr<RenderLayerCompositor> m_compositor;
#endif
};
inline RenderView* toRenderView(RenderObject* object)
{
ASSERT(!object || object->isRenderView());
return static_cast<RenderView*>(object);
}
inline const RenderView* toRenderView(const RenderObject* object)
{
ASSERT(!object || object->isRenderView());
return static_cast<const RenderView*>(object);
}
void toRenderView(const RenderView*);
class LayoutStateMaintainer : public Noncopyable {
public:
LayoutStateMaintainer(RenderView* view, RenderBox* root, IntSize offset, bool disableState = false)
: m_view(view)
, m_disabled(disableState)
, m_didStart(false)
, m_didEnd(false)
{
push(root, offset);
}
LayoutStateMaintainer(RenderView* view)
: m_view(view)
, m_disabled(false)
, m_didStart(false)
, m_didEnd(false)
{
}
~LayoutStateMaintainer()
{
ASSERT(m_didStart == m_didEnd); }
void push(RenderBox* root, IntSize offset)
{
ASSERT(!m_didStart);
m_view->pushLayoutState(root, offset);
if (m_disabled)
m_view->disableLayoutState();
m_didStart = true;
}
void pop()
{
if (m_didStart) {
ASSERT(!m_didEnd);
m_view->popLayoutState();
if (m_disabled)
m_view->enableLayoutState();
m_didEnd = true;
}
}
bool didPush() const { return m_didStart; }
private:
RenderView* m_view;
bool m_disabled : 1; bool m_didStart : 1; bool m_didEnd : 1; };
}
#endif // RenderView_h