author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 14 May 2010 16:40:13 +0300 | |
changeset 22 | 79de32ba3296 |
parent 19 | fcece45ef507 |
child 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 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 "Frame.h" |
|
29 |
#include "IntSize.h" |
|
30 |
#include "Page.h" |
|
31 |
#include "RenderLayer.h" |
|
32 |
#include "ScrollView.h" |
|
33 |
#include <wtf/Forward.h> |
|
34 |
#include <wtf/OwnPtr.h> |
|
35 |
||
36 |
namespace WebCore { |
|
37 |
||
38 |
class Color; |
|
39 |
class Event; |
|
40 |
class Frame; |
|
41 |
class FrameViewPrivate; |
|
42 |
class InspectorTimelineAgent; |
|
43 |
class IntRect; |
|
44 |
class Node; |
|
45 |
class PlatformMouseEvent; |
|
46 |
class RenderLayer; |
|
47 |
class RenderObject; |
|
48 |
class RenderPartObject; |
|
49 |
class ScheduledEvent; |
|
50 |
class String; |
|
51 |
||
52 |
template <typename T> class Timer; |
|
53 |
||
54 |
class FrameView : public ScrollView { |
|
55 |
public: |
|
56 |
friend class RenderView; |
|
57 |
||
58 |
static PassRefPtr<FrameView> create(Frame*); |
|
59 |
static PassRefPtr<FrameView> create(Frame*, const IntSize& initialSize); |
|
60 |
||
61 |
virtual ~FrameView(); |
|
62 |
||
63 |
virtual HostWindow* hostWindow() const; |
|
64 |
||
65 |
virtual void invalidateRect(const IntRect&); |
|
66 |
||
67 |
Frame* frame() const { return m_frame.get(); } |
|
68 |
void clearFrame(); |
|
69 |
||
70 |
int marginWidth() const { return m_margins.width(); } // -1 means default |
|
71 |
int marginHeight() const { return m_margins.height(); } // -1 means default |
|
72 |
void setMarginWidth(int); |
|
73 |
void setMarginHeight(int); |
|
74 |
||
75 |
virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation); |
|
76 |
||
77 |
virtual void setContentsSize(const IntSize&); |
|
78 |
||
79 |
void layout(bool allowSubtree = true); |
|
80 |
bool didFirstLayout() const; |
|
81 |
void layoutTimerFired(Timer<FrameView>*); |
|
82 |
void scheduleRelayout(); |
|
83 |
void scheduleRelayoutOfSubtree(RenderObject*); |
|
84 |
void unscheduleRelayout(); |
|
85 |
bool layoutPending() const; |
|
86 |
||
87 |
RenderObject* layoutRoot(bool onlyDuringLayout = false) const; |
|
88 |
int layoutCount() const { return m_layoutCount; } |
|
89 |
||
90 |
// These two helper functions just pass through to the RenderView. |
|
91 |
bool needsLayout() const; |
|
92 |
void setNeedsLayout(); |
|
93 |
||
94 |
bool needsFullRepaint() const { return m_doFullRepaint; } |
|
95 |
||
96 |
#if USE(ACCELERATED_COMPOSITING) |
|
97 |
void updateCompositingLayers(); |
|
98 |
||
99 |
// Called when changes to the GraphicsLayer hierarchy have to be synchronized with |
|
100 |
// content rendered via the normal painting path. |
|
101 |
void setNeedsOneShotDrawingSynchronization(); |
|
102 |
#endif |
|
103 |
// Only used with accelerated compositing, but outside the #ifdef to make linkage easier. |
|
104 |
// Returns true if the sync was completed. |
|
105 |
bool syncCompositingStateRecursive(); |
|
106 |
||
107 |
void didMoveOnscreen(); |
|
108 |
void willMoveOffscreen(); |
|
109 |
||
110 |
void resetScrollbars(); |
|
111 |
void detachCustomScrollbars(); |
|
112 |
||
113 |
void clear(); |
|
114 |
||
115 |
bool isTransparent() const; |
|
116 |
void setTransparent(bool isTransparent); |
|
117 |
||
118 |
Color baseBackgroundColor() const; |
|
119 |
void setBaseBackgroundColor(Color); |
|
120 |
void updateBackgroundRecursively(const Color&, bool); |
|
121 |
||
122 |
bool shouldUpdateWhileOffscreen() const; |
|
123 |
void setShouldUpdateWhileOffscreen(bool); |
|
124 |
||
125 |
void adjustViewSize(); |
|
126 |
||
127 |
virtual IntRect windowClipRect(bool clipToContents = true) const; |
|
128 |
IntRect windowClipRectForLayer(const RenderLayer*, bool clipToLayerContents) const; |
|
129 |
||
130 |
virtual IntRect windowResizerRect() const; |
|
131 |
||
132 |
virtual void scrollRectIntoViewRecursively(const IntRect&); |
|
133 |
virtual void setScrollPosition(const IntPoint&); |
|
134 |
void scrollPositionChanged(); |
|
135 |
||
136 |
String mediaType() const; |
|
137 |
void setMediaType(const String&); |
|
138 |
||
139 |
void setUseSlowRepaints(); |
|
140 |
void setIsOverlapped(bool); |
|
141 |
void setContentIsOpaque(bool); |
|
142 |
||
143 |
void addSlowRepaintObject(); |
|
144 |
void removeSlowRepaintObject(); |
|
145 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
146 |
void addFixedObject(); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
147 |
void removeFixedObject(); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
148 |
|
0 | 149 |
void beginDeferredRepaints(); |
150 |
void endDeferredRepaints(); |
|
151 |
void checkStopDelayingDeferredRepaints(); |
|
152 |
void resetDeferredRepaintDelay(); |
|
153 |
||
154 |
#if ENABLE(DASHBOARD_SUPPORT) |
|
155 |
void updateDashboardRegions(); |
|
156 |
#endif |
|
157 |
void updateControlTints(); |
|
158 |
||
159 |
void restoreScrollbar(); |
|
160 |
||
161 |
void scheduleEvent(PassRefPtr<Event>, PassRefPtr<Node>); |
|
162 |
void pauseScheduledEvents(); |
|
163 |
void resumeScheduledEvents(); |
|
164 |
void postLayoutTimerFired(Timer<FrameView>*); |
|
165 |
||
166 |
bool wasScrolledByUser() const; |
|
167 |
void setWasScrolledByUser(bool); |
|
168 |
||
169 |
void addWidgetToUpdate(RenderPartObject*); |
|
170 |
void removeWidgetToUpdate(RenderPartObject*); |
|
171 |
||
172 |
virtual void paintContents(GraphicsContext*, const IntRect& damageRect); |
|
173 |
void setPaintRestriction(PaintRestriction); |
|
174 |
bool isPainting() const; |
|
175 |
void setNodeToDraw(Node*); |
|
176 |
||
177 |
static double currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting |
|
178 |
||
179 |
void layoutIfNeededRecursive(); |
|
180 |
void flushDeferredRepaints(); |
|
181 |
||
182 |
void setIsVisuallyNonEmpty() { m_isVisuallyNonEmpty = true; } |
|
183 |
||
184 |
void forceLayout(bool allowSubtree = false); |
|
185 |
void forceLayoutWithPageWidthRange(float minPageWidth, float maxPageWidth, bool adjustViewSize); |
|
186 |
||
187 |
void adjustPageHeight(float* newBottom, float oldTop, float oldBottom, float bottomLimit); |
|
188 |
||
189 |
bool scrollToFragment(const KURL&); |
|
190 |
bool scrollToAnchor(const String&); |
|
191 |
void maintainScrollPositionAtAnchor(Node*); |
|
192 |
||
193 |
// Methods to convert points and rects between the coordinate space of the renderer, and this view. |
|
194 |
virtual IntRect convertFromRenderer(const RenderObject*, const IntRect&) const; |
|
195 |
virtual IntRect convertToRenderer(const RenderObject*, const IntRect&) const; |
|
196 |
virtual IntPoint convertFromRenderer(const RenderObject*, const IntPoint&) const; |
|
197 |
virtual IntPoint convertToRenderer(const RenderObject*, const IntPoint&) const; |
|
198 |
||
199 |
bool isFrameViewScrollCorner(RenderScrollbarPart* scrollCorner) const { return m_scrollCorner == scrollCorner; } |
|
200 |
void invalidateScrollCorner(); |
|
201 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
202 |
protected: |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
203 |
virtual void scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
204 |
|
0 | 205 |
private: |
206 |
FrameView(Frame*); |
|
207 |
||
208 |
void reset(); |
|
209 |
void init(); |
|
210 |
||
211 |
virtual bool isFrameView() const; |
|
212 |
||
213 |
friend class RenderWidget; |
|
214 |
bool useSlowRepaints() const; |
|
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
215 |
bool useSlowRepaintsIfNotOverlapped() const; |
0 | 216 |
|
217 |
void applyOverflowToViewport(RenderObject*, ScrollbarMode& hMode, ScrollbarMode& vMode); |
|
218 |
||
219 |
void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow); |
|
220 |
||
221 |
void dispatchScheduledEvents(); |
|
222 |
void performPostLayoutTasks(); |
|
223 |
||
224 |
virtual void repaintContentRectangle(const IntRect&, bool immediate); |
|
225 |
virtual void contentsResized() { setNeedsLayout(); } |
|
226 |
virtual void visibleContentsResized(); |
|
227 |
||
228 |
// Override ScrollView methods to do point conversion via renderers, in order to |
|
229 |
// take transforms into account. |
|
230 |
virtual IntRect convertToContainingView(const IntRect&) const; |
|
231 |
virtual IntRect convertFromContainingView(const IntRect&) const; |
|
232 |
virtual IntPoint convertToContainingView(const IntPoint&) const; |
|
233 |
virtual IntPoint convertFromContainingView(const IntPoint&) const; |
|
234 |
||
235 |
// ScrollBarClient interface |
|
236 |
virtual void valueChanged(Scrollbar*); |
|
237 |
virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&); |
|
238 |
virtual bool isActive() const; |
|
239 |
virtual void getTickmarks(Vector<IntRect>&) const; |
|
240 |
||
241 |
void deferredRepaintTimerFired(Timer<FrameView>*); |
|
242 |
void doDeferredRepaints(); |
|
243 |
void updateDeferredRepaintDelay(); |
|
244 |
double adjustedDeferredRepaintDelay() const; |
|
245 |
||
246 |
bool updateWidgets(); |
|
247 |
void scrollToAnchor(); |
|
248 |
||
249 |
#if ENABLE(INSPECTOR) |
|
250 |
InspectorTimelineAgent* inspectorTimelineAgent() const; |
|
251 |
#endif |
|
252 |
||
253 |
bool hasCustomScrollbars() const; |
|
254 |
||
255 |
virtual void updateScrollCorner(); |
|
256 |
virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect); |
|
257 |
||
258 |
static double sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache |
|
259 |
||
260 |
IntSize m_size; |
|
261 |
IntSize m_margins; |
|
262 |
OwnPtr<HashSet<RenderPartObject*> > m_widgetUpdateSet; |
|
263 |
RefPtr<Frame> m_frame; |
|
264 |
||
265 |
bool m_doFullRepaint; |
|
266 |
||
267 |
bool m_useSlowRepaints; |
|
268 |
bool m_isOverlapped; |
|
269 |
bool m_contentIsOpaque; |
|
270 |
unsigned m_slowRepaintObjectCount; |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
271 |
unsigned m_fixedObjectCount; |
0 | 272 |
|
273 |
int m_borderX, m_borderY; |
|
274 |
||
275 |
Timer<FrameView> m_layoutTimer; |
|
276 |
bool m_delayedLayout; |
|
277 |
RenderObject* m_layoutRoot; |
|
278 |
||
279 |
bool m_layoutSchedulingEnabled; |
|
280 |
bool m_midLayout; |
|
281 |
int m_layoutCount; |
|
282 |
unsigned m_nestedLayoutCount; |
|
283 |
Timer<FrameView> m_postLayoutTasksTimer; |
|
284 |
bool m_firstLayoutCallbackPending; |
|
285 |
||
286 |
bool m_firstLayout; |
|
287 |
bool m_isTransparent; |
|
288 |
Color m_baseBackgroundColor; |
|
289 |
IntSize m_lastLayoutSize; |
|
290 |
float m_lastZoomFactor; |
|
291 |
||
292 |
String m_mediaType; |
|
293 |
||
294 |
unsigned m_enqueueEvents; |
|
295 |
Vector<ScheduledEvent*> m_scheduledEvents; |
|
296 |
||
297 |
bool m_overflowStatusDirty; |
|
298 |
bool m_horizontalOverflow; |
|
299 |
bool m_verticalOverflow; |
|
300 |
RenderObject* m_viewportRenderer; |
|
301 |
||
302 |
bool m_wasScrolledByUser; |
|
303 |
bool m_inProgrammaticScroll; |
|
304 |
||
305 |
unsigned m_deferringRepaints; |
|
306 |
unsigned m_repaintCount; |
|
307 |
Vector<IntRect> m_repaintRects; |
|
308 |
Timer<FrameView> m_deferredRepaintTimer; |
|
309 |
double m_deferredRepaintDelay; |
|
310 |
double m_lastPaintTime; |
|
311 |
||
312 |
bool m_shouldUpdateWhileOffscreen; |
|
313 |
||
314 |
unsigned m_deferSetNeedsLayouts; |
|
315 |
bool m_setNeedsLayoutWasDeferred; |
|
316 |
||
317 |
RefPtr<Node> m_nodeToDraw; |
|
318 |
PaintRestriction m_paintRestriction; |
|
319 |
bool m_isPainting; |
|
320 |
||
321 |
bool m_isVisuallyNonEmpty; |
|
322 |
bool m_firstVisuallyNonEmptyLayoutCallbackPending; |
|
323 |
||
324 |
RefPtr<Node> m_maintainScrollPositionAnchor; |
|
325 |
||
326 |
// Renderer to hold our custom scroll corner. |
|
327 |
RenderScrollbarPart* m_scrollCorner; |
|
328 |
}; |
|
329 |
||
330 |
#if ENABLE(INSPECTOR) |
|
331 |
inline InspectorTimelineAgent* FrameView::inspectorTimelineAgent() const |
|
332 |
{ |
|
333 |
return m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0; |
|
334 |
} |
|
335 |
#endif |
|
336 |
||
337 |
} // namespace WebCore |
|
338 |
||
339 |
#endif // FrameView_h |