23 #ifndef render_canvas_h
24 #define render_canvas_h
26 #include "render_block.h"
42 class RenderCanvas :
public RenderBlock
45 RenderCanvas(DOM::NodeImpl *node,
KHTMLView *view);
48 const char *renderName()
const override
50 return "RenderCanvas";
53 bool isCanvas()
const override
58 void setStyle(RenderStyle *style)
override;
59 void layout()
override;
60 void calcWidth()
override;
61 void calcHeight()
override;
62 void calcMinMaxWidth()
override;
63 bool absolutePosition(
int &xPos,
int &yPos,
bool f =
false)
const override;
65 int docHeight()
const;
73 void repaint(Priority p = NormalPriority)
override;
74 void repaintRectangle(
int x,
int y,
int w,
int h, Priority p = NormalPriority,
bool f =
false)
override;
75 void repaintViewRectangle(
int x,
int y,
int w,
int h,
bool asap =
false);
76 bool needsFullRepaint()
const;
77 void deferredRepaint(RenderObject *o);
78 void scheduleDeferredRepaints();
80 void paint(PaintInfo &,
int tx,
int ty)
override;
81 void paintBoxDecorations(PaintInfo &paintInfo,
int _tx,
int _ty)
override;
82 virtual void setSelection(RenderObject *s,
int sp, RenderObject *e,
int ep);
83 virtual void clearSelection(
bool doRepaint =
true);
84 virtual RenderObject *selectionStart()
const
86 return m_selectionStart;
88 virtual RenderObject *selectionEnd()
const
90 return m_selectionEnd;
92 bool hasSelection()
const
94 return m_selectionStart && m_selectionEnd;
97 void setPrintImages(
bool enable)
99 m_printImages = enable;
101 bool printImages()
const
103 return m_printImages;
106 void setCanvasMode(CanvasMode mode)
110 CanvasMode canvasMode()
const
115 void setPagedMode(
bool b)
119 void setStaticMode(
bool b)
124 bool pagedMode()
const
128 bool staticMode()
const
133 void setPageTop(
int top)
138 void setPageBottom(
int bottom)
140 m_pageBottom = bottom;
146 int pageBottom()
const
151 int pageTopAfter(
int y)
const override
153 if (pageHeight() == 0) {
156 return (y / pageHeight() + 1) * pageHeight();
159 int crossesPageBreak(
int top,
int bottom)
const override
161 if (pageHeight() == 0) {
164 int pT = top / pageHeight();
166 int pB = (bottom - 1) / pageHeight();
167 return (pT == pB) ? 0 : (pB + 1);
170 void setPageNumber(
int number)
174 int pageNumber()
const
179 void updateInvalidatedFonts();
181 void setWidth(
int width)
override
183 m_rootWidth = m_width = width;
185 void setHeight(
int height)
override
187 m_rootHeight = m_height = height;
191 int pageHeight()
const
193 return m_pageBottom - m_pageTop;
196 int viewportWidth()
const
198 return m_viewportWidth;
200 int viewportHeight()
const
202 return m_viewportHeight;
207 QRect selectionRect()
const;
210 void setMaximalOutlineSize(
int o)
212 m_maximalOutlineSize = o;
214 int maximalOutlineSize()
const
216 return m_maximalOutlineSize;
219 void setNeedsWidgetMasks(
bool b =
true);
220 bool needsWidgetMasks()
const
222 return m_needsWidgetMasks;
225 void addStaticObject(RenderObject *o,
bool positioned =
false);
226 void removeStaticObject(RenderObject *o,
bool positioned =
false);
228 void updateDocSizeAfterLayerTranslation(RenderObject *o,
bool posXOffset,
bool posYOffset);
230 bool isPerformingLayout()
const
232 return m_isPerformingLayout;
236 void updateDocumentSize();
240 void setCachedDocWidth(
int w)
242 m_cachedDocWidth = w;
244 void setCachedDocHeight(
int h)
246 m_cachedDocHeight = h;
249 void selectionStartEnd(
int &spos,
int &epos)
override;
251 QRect viewRect()
const override;
255 RenderObject *m_selectionStart;
256 RenderObject *m_selectionEnd;
257 int m_selectionStartPos;
258 int m_selectionEndPos;
260 CanvasMode m_canvasMode;
266 int m_viewportHeight;
268 int m_cachedDocWidth;
269 int m_cachedDocHeight;
272 bool m_needsFullRepaint;
279 bool m_needsWidgetMasks;
281 bool m_isPerformingLayout;
290 int m_maximalOutlineSize;
296 inline RenderCanvas *RenderObject::canvas()
const
298 return static_cast<RenderCanvas *
>(document()->renderer());
305 RenderPage(RenderCanvas *canvas) : m_canvas(canvas),
306 m_marginTop(0), m_marginBottom(0),
307 m_marginLeft(0), m_marginRight(0),
308 m_pageWidth(0), m_pageHeight(0),
311 m_style =
new RenderPageStyle();
313 virtual ~RenderPage()
318 int marginTop()
const
322 int marginBottom()
const
324 return m_marginBottom;
326 int marginLeft()
const
330 int marginRight()
const
332 return m_marginRight;
335 void setMarginTop(
int margin)
337 m_marginTop = margin;
339 void setMarginBottom(
int margin)
341 m_marginBottom = margin;
343 void setMarginLeft(
int margin)
345 m_marginLeft = margin;
347 void setMarginRight(
int margin)
349 m_marginRight = margin;
352 int pageWidth()
const
356 int pageHeight()
const
361 void setPageSize(
int width,
int height)
364 m_pageHeight = height;
368 bool fixedSize()
const
372 void setFixedSize(
bool b)
377 RenderPageStyle *style()
381 const RenderPageStyle *style()
const
387 RenderCanvas *m_canvas;
388 RenderPageStyle *m_style;