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.
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.
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.
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.
29 #include "RenderLayer.h"
30 #include "ScrollView.h"
31 #include <wtf/Forward.h>
32 #include <wtf/OwnPtr.h>
38 class EventTargetNode
;
40 class FrameViewPrivate
;
43 class PlatformMouseEvent
;
46 class RenderPartObject
;
50 template <typename T
> class Timer
;
52 class FrameView
: public ScrollView
{
54 friend class RenderView
;
57 FrameView(Frame
*, const IntSize
& initialSize
);
61 virtual HostWindow
* hostWindow() const;
63 virtual void invalidateRect(const IntRect
&);
65 Frame
* frame() const { return m_frame
.get(); }
68 void ref() { ++m_refCount
; }
69 void deref() { if (!--m_refCount
) delete this; }
70 bool hasOneRef() { return m_refCount
== 1; }
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);
77 virtual void setCanHaveScrollbars(bool);
79 virtual PassRefPtr
<Scrollbar
> createScrollbar(ScrollbarOrientation
);
81 virtual void setContentsSize(const IntSize
&);
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;
91 RenderObject
* layoutRoot(bool onlyDuringLayout
= false) const;
92 int layoutCount() const { return m_layoutCount
; }
94 // These two helper functions just pass through to the RenderView.
95 bool needsLayout() const;
96 void setNeedsLayout();
98 bool needsFullRepaint() const { return m_doFullRepaint
; }
99 IntSize
offsetInWindow() const;
100 void setFrameRect(const IntRect
&rect
);
102 #if USE(ACCELERATED_COMPOSITING)
103 enum CompositingUpdate
{ NormalCompositingUpdate
, ForcedCompositingUpdate
};
104 void updateCompositingLayers(CompositingUpdate updateType
= NormalCompositingUpdate
);
106 // Called when changes to the GraphicsLayer hierarchy have to be synchronized with
107 // content rendered via the normal painting path.
108 void setNeedsOneShotDrawingSynchronization();
111 void didMoveOnscreen();
112 void willMoveOffscreen();
114 void resetScrollbars();
118 bool isTransparent() const;
119 void setTransparent(bool isTransparent
);
121 Color
baseBackgroundColor() const;
122 void setBaseBackgroundColor(Color
);
123 void updateBackgroundRecursively(const Color
&, bool);
125 bool shouldUpdateWhileOffscreen() const;
126 void setShouldUpdateWhileOffscreen(bool);
128 void adjustViewSize();
129 void initScrollbars();
130 void updateDefaultScrollbarState();
132 virtual IntRect
windowClipRect(bool clipToContents
= true) const;
133 IntRect
windowClipRectForLayer(const RenderLayer
*, bool clipToLayerContents
) const;
135 virtual bool isActive() const;
136 virtual void invalidateScrollbarRect(Scrollbar
*, const IntRect
&);
137 virtual void valueChanged(Scrollbar
*);
138 virtual void getTickmarks(Vector
<IntRect
>&) const;
140 virtual IntRect
windowResizerRect() const;
142 virtual void scrollRectIntoViewRecursively(const IntRect
&);
143 virtual void setScrollPosition(const IntPoint
&);
145 String
mediaType() const;
146 void setMediaType(const String
&);
148 void setUseSlowRepaints();
150 void addSlowRepaintObject();
151 void removeSlowRepaintObject();
153 void beginDeferredRepaints();
154 void endDeferredRepaints();
155 void checkStopDelayingDeferredRepaints();
156 void resetDeferredRepaintDelay();
158 #if ENABLE(DASHBOARD_SUPPORT)
159 void updateDashboardRegions();
161 void updateControlTints();
163 void restoreScrollbar();
165 void scheduleEvent(PassRefPtr
<Event
>, PassRefPtr
<EventTargetNode
>);
166 void pauseScheduledEvents();
167 void resumeScheduledEvents();
168 void postLayoutTimerFired(Timer
<FrameView
>*);
170 bool wasScrolledByUser() const;
171 void setWasScrolledByUser(bool);
173 void addWidgetToUpdate(RenderPartObject
*);
174 void removeWidgetToUpdate(RenderPartObject
*);
176 virtual void paintContents(GraphicsContext
*, const IntRect
& damageRect
);
177 void setPaintRestriction(PaintRestriction
);
178 bool isPainting() const;
179 void setNodeToDraw(Node
*);
181 static double currentPaintTimeStamp() { return sCurrentPaintTimeStamp
; } // returns 0 if not painting
183 void layoutIfNeededRecursive();
185 void setIsVisuallyNonEmpty() { m_isVisuallyNonEmpty
= true; }
191 virtual bool isFrameView() const;
193 bool useSlowRepaints() const;
195 void applyOverflowToViewport(RenderObject
*, ScrollbarMode
& hMode
, ScrollbarMode
& vMode
);
197 void updateOverflowStatus(bool horizontalOverflow
, bool verticalOverflow
);
199 void dispatchScheduledEvents();
200 void performPostLayoutTasks();
202 virtual void repaintContentRectangle(const IntRect
&, bool immediate
);
203 virtual void contentsResized() { setNeedsLayout(); }
204 virtual void visibleContentsResized() { layout(); }
206 void deferredRepaintTimerFired(Timer
<FrameView
>*);
207 void doDeferredRepaints();
208 void updateDeferredRepaintDelay();
209 double adjustedDeferredRepaintDelay() const;
211 static double sCurrentPaintTimeStamp
; // used for detecting decoded resource thrash in the cache
216 OwnPtr
<HashSet
<RenderPartObject
*> > m_widgetUpdateSet
;
217 RefPtr
<Frame
> m_frame
;
219 bool m_doFullRepaint
;
221 ScrollbarMode m_vmode
;
222 ScrollbarMode m_hmode
;
223 bool m_useSlowRepaints
;
224 unsigned m_slowRepaintObjectCount
;
226 int m_borderX
, m_borderY
;
228 Timer
<FrameView
> m_layoutTimer
;
229 bool m_delayedLayout
;
230 RenderObject
* m_layoutRoot
;
232 bool m_layoutSchedulingEnabled
;
236 unsigned m_nestedLayoutCount
;
237 Timer
<FrameView
> m_postLayoutTasksTimer
;
238 bool m_firstLayoutCallbackPending
;
241 bool m_needToInitScrollbars
;
242 bool m_isTransparent
;
243 Color m_baseBackgroundColor
;
244 IntSize m_lastLayoutSize
;
245 float m_lastZoomFactor
;
249 unsigned m_enqueueEvents
;
250 Vector
<ScheduledEvent
*> m_scheduledEvents
;
252 bool m_overflowStatusDirty
;
253 bool m_horizontalOverflow
;
254 bool m_verticalOverflow
;
255 RenderObject
* m_viewportRenderer
;
257 bool m_wasScrolledByUser
;
258 bool m_inProgrammaticScroll
;
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
;
267 bool m_shouldUpdateWhileOffscreen
;
269 RefPtr
<Node
> m_nodeToDraw
;
270 PaintRestriction m_paintRestriction
;
273 bool m_isVisuallyNonEmpty
;
274 bool m_firstVisuallyNonEmptyLayoutCallbackPending
;
277 } // namespace WebCore
279 #endif // FrameView_h