1 /* This file is part of the KDE project
3 Copyright (C) 1997 Martin Jones (mjones@kde.org)
4 (C) 1998 Waldo Bastian (bastian@kde.org)
5 (C) 1998, 1999 Torben Weis (weis@kde.org)
6 (C) 1999 Lars Knoll (knoll@kde.org)
7 (C) 1999 Antti Koivisto (koivisto@kde.org)
8 Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public
12 License as published by the Free Software Foundation; either
13 version 2 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details.
20 You should have received a copy of the GNU Library General Public License
21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA.
29 #include "ScrollView.h"
31 #include "PlatformString.h"
39 class EventTargetNode;
41 class FrameViewPrivate;
42 class HTMLFrameSetElement;
46 class PlatformMouseEvent;
47 class MouseEventWithHitTestResults;
51 class PlatformWheelEvent;
53 template <typename T> class Timer;
55 class FrameView : public ScrollView {
60 Frame* frame() const { return m_frame.get(); }
62 void ref() { ++m_refCount; }
63 void deref() { if (!--m_refCount) delete this; }
64 bool hasOneRef() { return m_refCount == 1; }
66 int marginWidth() const { return m_margins.width(); } // -1 means default
67 int marginHeight() const { return m_margins.height(); } // -1 means default
68 void setMarginWidth(int);
69 void setMarginHeight(int);
71 virtual void setVScrollbarMode(ScrollbarMode);
72 virtual void setHScrollbarMode(ScrollbarMode);
73 virtual void setScrollbarsMode(ScrollbarMode);
77 void layout(bool allowSubtree = true);
78 bool didFirstLayout() const;
79 void layoutTimerFired(Timer<FrameView>*);
80 void scheduleRelayout();
81 void scheduleRelayoutOfSubtree(Node*);
82 void unscheduleRelayout();
83 bool haveDelayedLayoutScheduled();
84 bool layoutPending() const;
86 Node* layoutRoot() const;
87 int layoutCount() const;
89 bool needsFullRepaint() const;
90 void repaintRectangle(const IntRect&, bool immediate);
91 void addRepaintInfo(RenderObject*, const IntRect&);
93 void resetScrollbars();
98 bool isTransparent() const;
99 void setTransparent(bool isTransparent);
101 Color baseBackgroundColor() const;
102 void setBaseBackgroundColor(Color);
104 void adjustViewSize();
105 void initScrollbars();
107 void setHasBorder(bool);
108 bool hasBorder() const;
110 virtual IntRect windowClipRect() const;
111 IntRect windowClipRect(bool clipToContents) const;
112 IntRect windowClipRectForLayer(const RenderLayer*, bool clipToLayerContents) const;
114 virtual void scrollPointRecursively(int x, int y);
115 virtual void setContentsPos(int x, int y);
117 String mediaType() const;
119 void setUseSlowRepaints();
121 void addSlowRepaintObject();
122 void removeSlowRepaintObject();
125 void updateDashboardRegions();
128 void restoreScrollbar();
130 void setMediaType(const String&);
135 virtual bool isFrameView() const;
137 bool scrollTo(const IntRect&);
139 bool useSlowRepaints() const;
141 void applyOverflowToViewport(RenderObject*, ScrollbarMode& hMode, ScrollbarMode& vMode);
145 void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
150 RefPtr<Frame> m_frame;
154 friend class FrameMac;
156 // === to be moved into EventHandler
159 void handleMousePressEvent(const PlatformMouseEvent&);
160 void handleMouseDoubleClickEvent(const PlatformMouseEvent&);
161 virtual void handleMouseMoveEvent(const PlatformMouseEvent&);
162 virtual void handleMouseReleaseEvent(const PlatformMouseEvent&);
163 void handleWheelEvent(PlatformWheelEvent&);
165 bool passMousePressEventToSubframe(MouseEventWithHitTestResults&, Frame*);
166 bool passMouseMoveEventToSubframe(MouseEventWithHitTestResults&, Frame*);
167 bool passMouseReleaseEventToSubframe(MouseEventWithHitTestResults&, Frame*);
168 bool passWheelEventToSubframe(PlatformWheelEvent&, Frame*);
169 bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&, PlatformScrollbar*);
172 void setMousePressed(bool);
176 bool advanceFocus(KeyboardEvent*);
178 bool updateDragAndDrop(const PlatformMouseEvent&, Clipboard*);
179 void cancelDragAndDrop(const PlatformMouseEvent&, Clipboard*);
180 bool performDragAndDrop(const PlatformMouseEvent&, Clipboard*);
182 void scheduleHoverStateUpdate();
183 void hoverTimerFired(Timer<FrameView>*);
185 void setResizingFrameSet(HTMLFrameSetElement*);
187 void scheduleEvent(PassRefPtr<Event>, PassRefPtr<EventTargetNode>, bool tempEvent);
189 IntPoint currentMousePosition() const;
191 void setIgnoreWheelEvents(bool);
194 void invalidateClick();
196 Node *nodeUnderMouse() const;
198 MouseEventWithHitTestResults prepareMouseEvent(bool readonly, bool active, bool mouseMove, const PlatformMouseEvent&);
200 bool dispatchMouseEvent(const AtomicString& eventType, Node* target,
201 bool cancelable, int clickCount, const PlatformMouseEvent&, bool setUnder);
202 bool dispatchDragEvent(const AtomicString& eventType, Node* target,
203 const PlatformMouseEvent&, Clipboard*);
205 void dispatchScheduledEvents();