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"
37 class CSSStyleSelector;
39 class DeprecatedStringList;
43 class EventTargetNode;
45 class FrameViewPrivate;
46 class GraphicsContext;
47 class HTMLAnchorElement;
50 class HTMLFormElement;
51 class HTMLFrameSetElement;
52 class HTMLGenericFormElement;
53 class HTMLTitleElement;
56 class PlatformKeyboardEvent;
58 class PlatformMouseEvent;
59 class MouseEventWithHitTestResults;
66 class RenderPartObject;
69 class PlatformWheelEvent;
72 template <typename T> class Timer;
74 void applyRule(CSSProperty*);
76 class FrameView : public ScrollView {
77 friend class CSSStyleSelector;
78 friend class Document;
80 friend class HTMLAnchorElement;
81 friend class HTMLDocument;
82 friend class HTMLFormElement;
83 friend class HTMLGenericFormElement;
84 friend class HTMLTitleElement;
85 friend class FrameMac;
86 friend class RenderBox;
87 friend class RenderView;
88 friend class RenderLineEdit;
89 friend class RenderObject;
90 friend class RenderPart;
91 friend class RenderPartObject;
92 friend class RenderWidget;
93 friend void applyRule(CSSProperty *prop);
99 Frame* frame() const { return m_frame.get(); }
101 int frameWidth() const { return m_size.width(); }
104 * Gets/Sets the margin width/height
106 * A return value of -1 means the default value will be used.
108 int marginWidth() const { return m_margins.width(); }
109 int marginHeight() { return m_margins.height(); }
110 void setMarginWidth(int);
111 void setMarginHeight(int);
113 virtual void setVScrollBarMode(ScrollBarMode);
114 virtual void setHScrollBarMode(ScrollBarMode);
115 virtual void setScrollBarsMode(ScrollBarMode);
119 void layout(bool allowSubtree = true);
121 Node* layoutRoot() const;
122 int layoutCount() const;
124 bool needsFullRepaint() const;
126 void addRepaintInfo(RenderObject*, const IntRect&);
128 void resetScrollBars();
135 void handleMousePressEvent(const PlatformMouseEvent&);
136 void handleMouseDoubleClickEvent(const PlatformMouseEvent&);
137 void handleMouseMoveEvent(const PlatformMouseEvent&);
138 void handleMouseReleaseEvent(const PlatformMouseEvent&);
139 void handleWheelEvent(PlatformWheelEvent&);
145 bool updateDragAndDrop(const PlatformMouseEvent&, Clipboard*);
146 void cancelDragAndDrop(const PlatformMouseEvent&, Clipboard*);
147 bool performDragAndDrop(const PlatformMouseEvent&, Clipboard*);
149 void layoutTimerFired(Timer<FrameView>*);
150 void hoverTimerFired(Timer<FrameView>*);
152 void repaintRectangle(const IntRect& r, bool immediate);
154 bool isTransparent() const;
155 void setTransparent(bool isTransparent);
157 void scheduleRelayout();
158 void scheduleRelayoutOfSubtree(Node*);
159 void unscheduleRelayout();
160 bool haveDelayedLayoutScheduled();
161 bool layoutPending() const;
163 void scheduleHoverStateUpdate();
165 void adjustViewSize();
166 void initScrollBars();
168 void setHasBorder(bool);
169 bool hasBorder() const;
171 void setResizingFrameSet(HTMLFrameSetElement *);
174 void updateDashboardRegions();
177 virtual void scrollPointRecursively(int x, int y);
178 virtual void setContentsPos(int x, int y);
180 void scheduleEvent(PassRefPtr<Event>, PassRefPtr<EventTargetNode>, bool tempEvent);
182 void ref() { ++m_refCount; }
183 void deref() { if (!--m_refCount) delete this; }
184 bool hasOneRef() { return m_refCount == 1; }
188 void scrollBarMoved();
191 void invalidateClick();
194 * Get/set the CSS Media Type.
196 * Media type is set to "screen" for on-screen rendering and "print"
197 * during printing. Other media types lack the proper support in the
198 * renderer and are not activated. The DOM tree and the parser itself,
199 * however, properly handle other media types. To make them actually work
200 * you only need to enable the media type in the view and if necessary
201 * add the media type dependent changes to the renderer.
203 void setMediaType(const String&);
204 String mediaType() const;
206 bool scrollTo(const IntRect&);
208 void focusNextPrevNode(bool next);
210 bool useSlowRepaints() const;
211 void setUseSlowRepaints();
212 void addSlowRepaintObject();
213 void removeSlowRepaintObject();
215 void setIgnoreWheelEvents(bool e);
219 Node *nodeUnderMouse() const;
221 void restoreScrollBar();
223 DeprecatedStringList formCompletionItems(const String& name) const;
224 void addFormCompletionItem(const String& name, const String& value);
226 MouseEventWithHitTestResults prepareMouseEvent(bool readonly, bool active, bool mouseMove, const PlatformMouseEvent&);
228 bool dispatchMouseEvent(const AtomicString& eventType, Node* target,
229 bool cancelable, int clickCount, const PlatformMouseEvent&, bool setUnder);
230 bool dispatchDragEvent(const AtomicString& eventType, Node* target,
231 const PlatformMouseEvent&, Clipboard*);
233 void applyOverflowToViewport(RenderObject* o, ScrollBarMode& hMode, ScrollBarMode& vMode);
235 virtual bool isFrameView() const;
239 void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
240 void dispatchScheduledEvents();
247 RefPtr<Frame> m_frame;