Upstream | d8543bb | 1970-01-12 13:46:40 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * This file is part of the HTML widget for KDE. |
| 3 | * |
| 4 | * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 5 | * Copyright (C) 2006 Apple Computer, Inc. |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Library General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Library General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Library General Public License |
| 18 | * along with this library; see the file COPYING.LIB. If not, write to |
| 19 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 | * Boston, MA 02110-1301, USA. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #ifndef RenderView_h |
| 25 | #define RenderView_h |
| 26 | |
| 27 | #include "FrameView.h" |
| 28 | #include "LayoutState.h" |
| 29 | #include "RenderBlock.h" |
| 30 | |
| 31 | namespace WebCore { |
| 32 | |
| 33 | class RenderView : public RenderBlock { |
| 34 | public: |
| 35 | RenderView(Node*, FrameView*); |
| 36 | virtual ~RenderView(); |
| 37 | |
| 38 | virtual const char* renderName() const { return "RenderView"; } |
| 39 | |
| 40 | virtual bool isRenderView() const { return true; } |
| 41 | |
| 42 | virtual void layout(); |
| 43 | virtual void calcWidth(); |
| 44 | virtual void calcHeight(); |
| 45 | virtual void calcPrefWidths(); |
| 46 | virtual bool absolutePosition(int& xPos, int& yPos, bool fixed = false) const; |
| 47 | |
| 48 | int docHeight() const; |
| 49 | int docWidth() const; |
| 50 | |
| 51 | FrameView* frameView() const { return m_frameView; } |
| 52 | |
| 53 | virtual bool hasOverhangingFloats() { return false; } |
| 54 | |
| 55 | virtual void computeAbsoluteRepaintRect(IntRect&, bool fixed = false); |
| 56 | virtual void repaintViewRectangle(const IntRect&, bool immediate = false); |
| 57 | |
| 58 | virtual void paint(PaintInfo&, int tx, int ty); |
| 59 | virtual void paintBoxDecorations(PaintInfo&, int tx, int ty); |
| 60 | |
| 61 | void setSelection(RenderObject* start, int startPos, RenderObject* end, int endPos); |
| 62 | void clearSelection(); |
| 63 | virtual RenderObject* selectionStart() const { return m_selectionStart; } |
| 64 | virtual RenderObject* selectionEnd() const { return m_selectionEnd; } |
| 65 | |
| 66 | bool printing() const; |
| 67 | void setPrintImages(bool enable) { m_printImages = enable; } |
| 68 | bool printImages() const { return m_printImages; } |
| 69 | void setTruncatedAt(int y) { m_truncatedAt = y; m_bestTruncatedAt = m_truncatorWidth = 0; m_forcedPageBreak = false; } |
| 70 | void setBestTruncatedAt(int y, RenderObject *forRenderer, bool forcedBreak = false); |
| 71 | int bestTruncatedAt() const { return m_bestTruncatedAt; } |
| 72 | |
| 73 | int truncatedAt() const { return m_truncatedAt; } |
| 74 | |
| 75 | virtual void absoluteRects(Vector<IntRect>&, int tx, int ty, bool topLevel = true); |
| 76 | |
| 77 | IntRect selectionRect(bool clipToVisibleContent = true) const; |
| 78 | |
| 79 | void setMaximalOutlineSize(int o) { m_maximalOutlineSize = o; } |
| 80 | int maximalOutlineSize() const { return m_maximalOutlineSize; } |
| 81 | |
| 82 | virtual IntRect viewRect() const; |
| 83 | |
| 84 | virtual void selectionStartEnd(int& startPos, int& endPos) const; |
| 85 | |
| 86 | IntRect printRect() const { return m_printRect; } |
| 87 | void setPrintRect(const IntRect& r) { m_printRect = r; } |
| 88 | |
| 89 | void updateWidgetPositions(); |
| 90 | void addWidget(RenderObject*); |
| 91 | void removeWidget(RenderObject*); |
| 92 | |
| 93 | const IntSize& layoutDelta() const { return m_layoutDelta; } |
| 94 | void addLayoutDelta(const IntSize& delta) { m_layoutDelta += delta; } |
| 95 | |
| 96 | void pushLayoutState(RenderBox* renderer, const IntSize& offset) |
| 97 | { |
| 98 | if (m_layoutStateDisableCount || m_frameView->needsFullRepaint()) |
| 99 | return; |
| 100 | m_layoutState = new (renderArena()) LayoutState(m_layoutState, renderer, offset); |
| 101 | } |
| 102 | |
| 103 | void pushLayoutState(RenderObject*); |
| 104 | |
| 105 | void popLayoutState() |
| 106 | { |
| 107 | if (m_layoutStateDisableCount || m_frameView->needsFullRepaint()) |
| 108 | return; |
| 109 | LayoutState* state = m_layoutState; |
| 110 | m_layoutState = state->m_next; |
| 111 | state->destroy(renderArena()); |
| 112 | } |
| 113 | |
| 114 | LayoutState* layoutState() const { return m_layoutStateDisableCount ? 0 : m_layoutState; } |
| 115 | |
| 116 | // Suspends the LayoutState optimization. Used under transforms that cannot be represented by |
| 117 | // LayoutState (common in SVG) and when manipulating the render tree during layout in ways |
| 118 | // that can trigger repaint of a non-child (e.g. when a list item moves its list marker around). |
| 119 | void disableLayoutState() { m_layoutStateDisableCount++; } |
| 120 | void enableLayoutState() { ASSERT(m_layoutStateDisableCount > 0); m_layoutStateDisableCount--; } |
| 121 | |
| 122 | protected: |
| 123 | FrameView* m_frameView; |
| 124 | |
| 125 | RenderObject* m_selectionStart; |
| 126 | RenderObject* m_selectionEnd; |
| 127 | int m_selectionStartPos; |
| 128 | int m_selectionEndPos; |
| 129 | |
| 130 | // used to ignore viewport width when printing to the printer |
| 131 | bool m_printImages; |
| 132 | int m_truncatedAt; |
| 133 | |
| 134 | int m_maximalOutlineSize; // Used to apply a fudge factor to dirty-rect checks on blocks/tables. |
| 135 | IntRect m_printRect; // Used when printing. |
| 136 | |
| 137 | typedef HashSet<RenderObject*> RenderObjectSet; |
| 138 | |
| 139 | RenderObjectSet m_widgets; |
| 140 | |
| 141 | private: |
| 142 | int m_bestTruncatedAt; |
| 143 | int m_truncatorWidth; |
| 144 | bool m_forcedPageBreak; |
| 145 | IntSize m_layoutDelta; |
| 146 | LayoutState* m_layoutState; |
| 147 | unsigned m_layoutStateDisableCount; |
| 148 | }; |
| 149 | |
| 150 | } // namespace WebCore |
| 151 | |
| 152 | #endif // RenderView_h |