]> git.saurik.com Git - iphone-api.git/blob - WebCore/FrameView.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / FrameView.h
1 /*
2 Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 (C) 1998 Waldo Bastian (bastian@kde.org)
4 (C) 1998, 1999 Torben Weis (weis@kde.org)
5 (C) 1999 Lars Knoll (knoll@kde.org)
6 (C) 1999 Antti Koivisto (koivisto@kde.org)
7 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA.
23 */
24
25 #ifndef FrameView_h
26 #define FrameView_h
27
28 #include "IntSize.h"
29 #include "RenderLayer.h"
30 #include "ScrollView.h"
31 #include <wtf/Forward.h>
32 #include <wtf/OwnPtr.h>
33
34 namespace WebCore {
35
36 class Color;
37 class Event;
38 class EventTargetNode;
39 class Frame;
40 class FrameViewPrivate;
41 class IntRect;
42 class Node;
43 class PlatformMouseEvent;
44 class RenderLayer;
45 class RenderObject;
46 class RenderPartObject;
47 class ScheduledEvent;
48 class String;
49
50 template <typename T> class Timer;
51
52 class FrameView : public ScrollView {
53 public:
54 friend class RenderView;
55
56 FrameView(Frame*);
57 FrameView(Frame*, const IntSize& initialSize);
58
59 virtual ~FrameView();
60
61 virtual HostWindow* hostWindow() const;
62
63 virtual void invalidateRect(const IntRect&);
64
65 Frame* frame() const { return m_frame.get(); }
66 void clearFrame();
67
68 void ref() { ++m_refCount; }
69 void deref() { if (!--m_refCount) delete this; }
70 bool hasOneRef() { return m_refCount == 1; }
71
72 int marginWidth() const { return m_margins.width(); } // -1 means default
73 int marginHeight() const { return m_margins.height(); } // -1 means default
74 void setMarginWidth(int);
75 void setMarginHeight(int);
76
77 virtual void setCanHaveScrollbars(bool);
78
79 virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation);
80
81 virtual void setContentsSize(const IntSize&);
82
83 void layout(bool allowSubtree = true);
84 bool didFirstLayout() const;
85 void layoutTimerFired(Timer<FrameView>*);
86 void scheduleRelayout();
87 void scheduleRelayoutOfSubtree(RenderObject*);
88 void unscheduleRelayout();
89 bool layoutPending() const;
90
91 RenderObject* layoutRoot(bool onlyDuringLayout = false) const;
92 int layoutCount() const { return m_layoutCount; }
93
94 // These two helper functions just pass through to the RenderView.
95 bool needsLayout() const;
96 void setNeedsLayout();
97
98 bool needsFullRepaint() const { return m_doFullRepaint; }
99 IntSize offsetInWindow() const;
100 void setFrameRect(const IntRect &rect);
101
102 #if USE(ACCELERATED_COMPOSITING)
103 enum CompositingUpdate { NormalCompositingUpdate, ForcedCompositingUpdate };
104 void updateCompositingLayers(CompositingUpdate updateType = NormalCompositingUpdate);
105
106 // Called when changes to the GraphicsLayer hierarchy have to be synchronized with
107 // content rendered via the normal painting path.
108 void setNeedsOneShotDrawingSynchronization();
109 #endif
110
111 void didMoveOnscreen();
112 void willMoveOffscreen();
113
114 void resetScrollbars();
115
116 void clear();
117
118 bool isTransparent() const;
119 void setTransparent(bool isTransparent);
120
121 Color baseBackgroundColor() const;
122 void setBaseBackgroundColor(Color);
123 void updateBackgroundRecursively(const Color&, bool);
124
125 bool shouldUpdateWhileOffscreen() const;
126 void setShouldUpdateWhileOffscreen(bool);
127
128 void adjustViewSize();
129 void initScrollbars();
130 void updateDefaultScrollbarState();
131
132 virtual IntRect windowClipRect(bool clipToContents = true) const;
133 IntRect windowClipRectForLayer(const RenderLayer*, bool clipToLayerContents) const;
134
135 virtual bool isActive() const;
136 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&);
137 virtual void valueChanged(Scrollbar*);
138 virtual void getTickmarks(Vector<IntRect>&) const;
139
140 virtual IntRect windowResizerRect() const;
141
142 virtual void scrollRectIntoViewRecursively(const IntRect&);
143 virtual void setScrollPosition(const IntPoint&);
144
145 String mediaType() const;
146 void setMediaType(const String&);
147
148 void setUseSlowRepaints();
149
150 void addSlowRepaintObject();
151 void removeSlowRepaintObject();
152
153 void beginDeferredRepaints();
154 void endDeferredRepaints();
155 void checkStopDelayingDeferredRepaints();
156 void resetDeferredRepaintDelay();
157
158 #if ENABLE(DASHBOARD_SUPPORT)
159 void updateDashboardRegions();
160 #endif
161 void updateControlTints();
162
163 void restoreScrollbar();
164
165 void scheduleEvent(PassRefPtr<Event>, PassRefPtr<EventTargetNode>);
166 void pauseScheduledEvents();
167 void resumeScheduledEvents();
168 void postLayoutTimerFired(Timer<FrameView>*);
169
170 bool wasScrolledByUser() const;
171 void setWasScrolledByUser(bool);
172
173 void addWidgetToUpdate(RenderPartObject*);
174 void removeWidgetToUpdate(RenderPartObject*);
175
176 virtual void paintContents(GraphicsContext*, const IntRect& damageRect);
177 void setPaintRestriction(PaintRestriction);
178 bool isPainting() const;
179 void setNodeToDraw(Node*);
180
181 static double currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting
182
183 void layoutIfNeededRecursive();
184
185 void setIsVisuallyNonEmpty() { m_isVisuallyNonEmpty = true; }
186
187 private:
188 void reset();
189 void init();
190
191 virtual bool isFrameView() const;
192
193 bool useSlowRepaints() const;
194
195 void applyOverflowToViewport(RenderObject*, ScrollbarMode& hMode, ScrollbarMode& vMode);
196
197 void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
198
199 void dispatchScheduledEvents();
200 void performPostLayoutTasks();
201
202 virtual void repaintContentRectangle(const IntRect&, bool immediate);
203 virtual void contentsResized() { setNeedsLayout(); }
204 virtual void visibleContentsResized() { layout(); }
205
206 void deferredRepaintTimerFired(Timer<FrameView>*);
207 void doDeferredRepaints();
208 void updateDeferredRepaintDelay();
209 double adjustedDeferredRepaintDelay() const;
210
211 static double sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache
212
213 unsigned m_refCount;
214 IntSize m_size;
215 IntSize m_margins;
216 OwnPtr<HashSet<RenderPartObject*> > m_widgetUpdateSet;
217 RefPtr<Frame> m_frame;
218
219 bool m_doFullRepaint;
220
221 ScrollbarMode m_vmode;
222 ScrollbarMode m_hmode;
223 bool m_useSlowRepaints;
224 unsigned m_slowRepaintObjectCount;
225
226 int m_borderX, m_borderY;
227
228 Timer<FrameView> m_layoutTimer;
229 bool m_delayedLayout;
230 RenderObject* m_layoutRoot;
231
232 bool m_layoutSchedulingEnabled;
233 bool m_midLayout;
234 int m_layoutCount;
235
236 unsigned m_nestedLayoutCount;
237 Timer<FrameView> m_postLayoutTasksTimer;
238 bool m_firstLayoutCallbackPending;
239
240 bool m_firstLayout;
241 bool m_needToInitScrollbars;
242 bool m_isTransparent;
243 Color m_baseBackgroundColor;
244 IntSize m_lastLayoutSize;
245 float m_lastZoomFactor;
246
247 String m_mediaType;
248
249 unsigned m_enqueueEvents;
250 Vector<ScheduledEvent*> m_scheduledEvents;
251
252 bool m_overflowStatusDirty;
253 bool m_horizontalOverflow;
254 bool m_verticalOverflow;
255 RenderObject* m_viewportRenderer;
256
257 bool m_wasScrolledByUser;
258 bool m_inProgrammaticScroll;
259
260 unsigned m_deferringRepaints;
261 unsigned m_repaintCount;
262 Vector<IntRect> m_repaintRects;
263 Timer<FrameView> m_deferredRepaintTimer;
264 double m_deferredRepaintDelay;
265 double m_lastPaintTime;
266
267 bool m_shouldUpdateWhileOffscreen;
268
269 RefPtr<Node> m_nodeToDraw;
270 PaintRestriction m_paintRestriction;
271 bool m_isPainting;
272
273 bool m_isVisuallyNonEmpty;
274 bool m_firstVisuallyNonEmptyLayoutCallbackPending;
275 };
276
277 } // namespace WebCore
278
279 #endif // FrameView_h