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 frame()65 Frame* frame() const { return m_frame.get(); } 66 void clearFrame(); 67 ref()68 void ref() { ++m_refCount; } deref()69 void deref() { if (!--m_refCount) delete this; } hasOneRef()70 bool hasOneRef() { return m_refCount == 1; } 71 marginWidth()72 int marginWidth() const { return m_margins.width(); } // -1 means default marginHeight()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; layoutCount()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 needsFullRepaint()98 bool needsFullRepaint() const { return m_doFullRepaint; } 99 100 void resetScrollbars(); 101 102 void clear(); 103 104 bool isTransparent() const; 105 void setTransparent(bool isTransparent); 106 107 Color baseBackgroundColor() const; 108 void setBaseBackgroundColor(Color); 109 void updateBackgroundRecursively(const Color&, bool); 110 111 bool shouldUpdateWhileOffscreen() const; 112 void setShouldUpdateWhileOffscreen(bool); 113 114 void adjustViewSize(); 115 void initScrollbars(); 116 void updateDefaultScrollbarState(); 117 118 virtual IntRect windowClipRect(bool clipToContents = true) const; 119 IntRect windowClipRectForLayer(const RenderLayer*, bool clipToLayerContents) const; 120 121 virtual bool isActive() const; 122 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&); 123 virtual void valueChanged(Scrollbar*); 124 virtual void getTickmarks(Vector<IntRect>&) const; 125 126 virtual IntRect windowResizerRect() const; 127 128 virtual void scrollRectIntoViewRecursively(const IntRect&); 129 virtual void setScrollPosition(const IntPoint&); 130 131 String mediaType() const; 132 void setMediaType(const String&); 133 134 void setUseSlowRepaints(); 135 136 void addSlowRepaintObject(); 137 void removeSlowRepaintObject(); 138 139 void beginDeferredRepaints(); 140 void endDeferredRepaints(); 141 142 #if ENABLE(DASHBOARD_SUPPORT) 143 void updateDashboardRegions(); 144 #endif 145 void updateControlTints(); 146 147 void restoreScrollbar(); 148 149 void scheduleEvent(PassRefPtr<Event>, PassRefPtr<EventTargetNode>); 150 void pauseScheduledEvents(); 151 void resumeScheduledEvents(); 152 void postLayoutTimerFired(Timer<FrameView>*); 153 154 bool wasScrolledByUser() const; 155 void setWasScrolledByUser(bool); 156 157 void addWidgetToUpdate(RenderPartObject*); 158 void removeWidgetToUpdate(RenderPartObject*); 159 160 virtual void paintContents(GraphicsContext*, const IntRect& damageRect); 161 void setPaintRestriction(PaintRestriction); 162 bool isPainting() const; 163 void setNodeToDraw(Node*); 164 currentPaintTimeStamp()165 static double currentPaintTimeStamp() { return sCurrentPaintTimeStamp; } // returns 0 if not painting 166 167 void layoutIfNeededRecursive(); 168 setIsVisuallyNonEmpty()169 void setIsVisuallyNonEmpty() { m_isVisuallyNonEmpty = true; } 170 171 private: 172 void reset(); 173 void init(); 174 175 virtual bool isFrameView() const; 176 177 bool useSlowRepaints() const; 178 179 void applyOverflowToViewport(RenderObject*, ScrollbarMode& hMode, ScrollbarMode& vMode); 180 181 void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow); 182 183 void dispatchScheduledEvents(); 184 void performPostLayoutTasks(); 185 186 virtual void repaintContentRectangle(const IntRect&, bool immediate); contentsResized()187 virtual void contentsResized() { setNeedsLayout(); } visibleContentsResized()188 virtual void visibleContentsResized() { layout(); } 189 190 static double sCurrentPaintTimeStamp; // used for detecting decoded resource thrash in the cache 191 192 unsigned m_refCount; 193 IntSize m_size; 194 IntSize m_margins; 195 OwnPtr<HashSet<RenderPartObject*> > m_widgetUpdateSet; 196 RefPtr<Frame> m_frame; 197 198 bool m_doFullRepaint; 199 200 ScrollbarMode m_vmode; 201 ScrollbarMode m_hmode; 202 bool m_useSlowRepaints; 203 unsigned m_slowRepaintObjectCount; 204 205 int m_borderX, m_borderY; 206 207 Timer<FrameView> m_layoutTimer; 208 bool m_delayedLayout; 209 RenderObject* m_layoutRoot; 210 211 bool m_layoutSchedulingEnabled; 212 bool m_midLayout; 213 int m_layoutCount; 214 unsigned m_nestedLayoutCount; 215 Timer<FrameView> m_postLayoutTasksTimer; 216 bool m_firstLayoutCallbackPending; 217 218 bool m_firstLayout; 219 bool m_needToInitScrollbars; 220 bool m_isTransparent; 221 Color m_baseBackgroundColor; 222 IntSize m_lastLayoutSize; 223 float m_lastZoomFactor; 224 225 String m_mediaType; 226 227 unsigned m_enqueueEvents; 228 Vector<ScheduledEvent*> m_scheduledEvents; 229 230 bool m_overflowStatusDirty; 231 bool m_horizontalOverflow; 232 bool m_verticalOverflow; 233 RenderObject* m_viewportRenderer; 234 235 bool m_wasScrolledByUser; 236 bool m_inProgrammaticScroll; 237 238 unsigned m_deferringRepaints; 239 unsigned m_repaintCount; 240 IntRect m_repaintRect; 241 Vector<IntRect> m_repaintRects; 242 243 bool m_shouldUpdateWhileOffscreen; 244 245 RefPtr<Node> m_nodeToDraw; 246 PaintRestriction m_paintRestriction; 247 bool m_isPainting; 248 249 bool m_isVisuallyNonEmpty; 250 bool m_firstVisuallyNonEmptyLayoutCallbackPending; 251 }; 252 253 } // namespace WebCore 254 255 #endif // FrameView_h 256