FrameView.h 6.35 KB
Newer Older
kocienda's avatar
kocienda committed
1
2
3
4
5
6
7
/* This file is part of the KDE project

   Copyright (C) 1997 Martin Jones (mjones@kde.org)
             (C) 1998 Waldo Bastian (bastian@kde.org)
             (C) 1998, 1999 Torben Weis (weis@kde.org)
             (C) 1999 Lars Knoll (knoll@kde.org)
             (C) 1999 Antti Koivisto (koivisto@kde.org)
8
   Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
kocienda's avatar
kocienda committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
*/

26
27
#ifndef FRAMEVIEW_H
#define FRAMEVIEW_H
kocienda's avatar
kocienda committed
28

darin's avatar
darin committed
29
#include "QString.h"
darin's avatar
darin committed
30
#include "ScrollView.h"
darin's avatar
darin committed
31

darin's avatar
darin committed
32
class QStringList;
kocienda's avatar
kocienda committed
33

darin's avatar
darin committed
34
namespace WebCore {
kocienda's avatar
kocienda committed
35

darin's avatar
darin committed
36
class AtomicString;
darin's avatar
darin committed
37
38
39
40
41
42
class CSSProperty;
class CSSStyleSelector;
class ClipboardImpl;
class DocumentImpl;
class ElementImpl;
class Frame;
43
class FrameViewPrivate;
darin's avatar
darin committed
44
class GraphicsContext;
darin's avatar
darin committed
45
46
47
48
class HTMLAnchorElementImpl;
class HTMLDocumentImpl;
class HTMLElementImpl;
class HTMLFormElementImpl;
ap's avatar
ap committed
49
class HTMLFrameSetElementImpl;
darin's avatar
darin committed
50
51
52
53
class HTMLGenericFormElementImpl;
class HTMLTitleElementImpl;
class InlineBox;
class IntRect;
darin's avatar
darin committed
54
class KeyEvent;
darin's avatar
darin committed
55
class MacFrame;
darin's avatar
darin committed
56
class MouseEvent;
darin's avatar
darin committed
57
58
59
60
61
62
63
64
65
class NodeImpl;
class RenderBox;
class RenderCanvas;
class RenderLineEdit;
class RenderObject;
class RenderPart;
class RenderPartObject;
class RenderStyle;
class RenderWidget;
darin's avatar
darin committed
66
class WheelEvent;
darin's avatar
darin committed
67
68
69
70

template <typename T> class Timer;

void applyRule(CSSProperty*);
kocienda's avatar
kocienda committed
71

darin's avatar
darin committed
72
class FrameView : public ScrollView {
darin's avatar
darin committed
73
74
    friend class CSSStyleSelector;
    friend class DocumentImpl;
mjs's avatar
mjs committed
75
    friend class Frame;
darin's avatar
darin committed
76
77
78
79
80
    friend class HTMLAnchorElementImpl;
    friend class HTMLDocumentImpl;
    friend class HTMLFormElementImpl;
    friend class HTMLGenericFormElementImpl;
    friend class HTMLTitleElementImpl;
mjs's avatar
mjs committed
81
    friend class MacFrame;
darin's avatar
darin committed
82
83
84
85
86
87
88
    friend class RenderBox;
    friend class RenderCanvas;
    friend class RenderLineEdit;
    friend class RenderObject;
    friend class RenderPart;
    friend class RenderPartObject;
    friend class RenderWidget;
darin's avatar
darin committed
89
    friend void applyRule(CSSProperty *prop);
kocienda's avatar
kocienda committed
90
91

public:
darin's avatar
darin committed
92
    FrameView(Frame*);
93
    virtual ~FrameView();
kocienda's avatar
kocienda committed
94

darin's avatar
darin committed
95
    Frame* frame() const { return m_frame.get(); }
kocienda's avatar
kocienda committed
96
97
98

    int frameWidth() const { return _width; }

99
    void setMarginWidth(int x);
kocienda's avatar
kocienda committed
100
101

    /**
102
     * Returns the margin width.
kocienda's avatar
kocienda committed
103
104
105
106
107
     *
     * A return value of -1 means the default value will be used.
     */
    int marginWidth() const { return _marginWidth; }

108
    void setMarginHeight(int y);
kocienda's avatar
kocienda committed
109

110
111
    /**
     * Returns the margin height.
kocienda's avatar
kocienda committed
112
113
114
115
116
     *
     * A return value of -1 means the default value will be used.
     */
    int marginHeight() { return _marginHeight; }

darin's avatar
darin committed
117
118
119
    virtual void setVScrollBarMode(ScrollBarMode);
    virtual void setHScrollBarMode(ScrollBarMode);
    virtual void setScrollBarsMode(ScrollBarMode);
120
    
121
    void print();
kocienda's avatar
kocienda committed
122

123
    void layout();
kocienda's avatar
kocienda committed
124

125
    bool inLayout() const;
126
    int layoutCount() const;
127
128

    bool needsFullRepaint() const;
129
    
darin's avatar
darin committed
130
    void addRepaintInfo(RenderObject* o, const IntRect& r);
131

132
133
    void resetScrollBars();

134
135
     void clear();

136
public:
eseidel's avatar
eseidel committed
137
    void clearPart();
darin's avatar
darin committed
138

darin's avatar
darin committed
139
140
141
142
143
    void viewportMousePressEvent(const MouseEvent&);
    void viewportMouseDoubleClickEvent(const MouseEvent&);
    void viewportMouseMoveEvent(const MouseEvent&);
    void viewportMouseReleaseEvent(const MouseEvent&);
    void viewportWheelEvent(WheelEvent&);
kocienda's avatar
kocienda committed
144
145
146

    void doAutoScroll();

darin's avatar
darin committed
147
148
149
    bool updateDragAndDrop(const MouseEvent&, ClipboardImpl*);
    void cancelDragAndDrop(const MouseEvent&, ClipboardImpl*);
    bool performDragAndDrop(const MouseEvent&, ClipboardImpl*);
trey's avatar
trey committed
150

darin's avatar
darin committed
151
    void layoutTimerFired(Timer<FrameView>*);
adele's avatar
adele committed
152
    void hoverTimerFired(Timer<FrameView>*);
153

154
    void repaintRectangle(const IntRect& r, bool immediate);
darin's avatar
darin committed
155
156
157

    bool isTransparent() const;
    void setTransparent(bool isTransparent);
158
    
159
160
161
162
163
    void scheduleRelayout();
    void unscheduleRelayout();
    bool haveDelayedLayoutScheduled();
    bool layoutPending();

adele's avatar
adele committed
164
165
    void scheduleHoverStateUpdate();

166
    void adjustViewSize();
167
    void initScrollBars();
168
    
darin's avatar
darin committed
169
170
171
    void setHasBorder(bool);
    bool hasBorder() const;
    
ap's avatar
ap committed
172
173
    void setResizingFrameSet(HTMLFrameSetElementImpl *);

174
#if __APPLE__
175
    void updateDashboardRegions();
176
#endif
mjs's avatar
mjs committed
177
178
179

    void ref() { ++_refCount; }
    void deref() { if (!--_refCount) delete this; }
mjs's avatar
mjs committed
180
    
kocienda's avatar
kocienda committed
181
private:
darin's avatar
darin committed
182
183
    void cleared();
    void scrollBarMoved();
184
185

    void resetCursor();
darin's avatar
darin committed
186
    void invalidateClick();
187

kocienda's avatar
kocienda committed
188
    /**
189
190
191
192
193
194
195
196
     * Get/set the CSS Media Type.
     *
     * Media type is set to "screen" for on-screen rendering and "print"
     * during printing. Other media types lack the proper support in the
     * renderer and are not activated. The DOM tree and the parser itself,
     * however, properly handle other media types. To make them actually work
     * you only need to enable the media type in the view and if necessary
     * add the media type dependent changes to the renderer.
kocienda's avatar
kocienda committed
197
     */
darin's avatar
darin committed
198
    void setMediaType(const QString&);
199
200
    QString mediaType() const;

darin's avatar
darin committed
201
    bool scrollTo(const IntRect&);
202
203

    void focusNextPrevNode(bool next);
kocienda's avatar
kocienda committed
204
205
206

    void useSlowRepaints();

207
208
    void setIgnoreWheelEvents(bool e);

kocienda's avatar
kocienda committed
209
210
    void init();

darin's avatar
darin committed
211
    NodeImpl *nodeUnderMouse() const;
kocienda's avatar
kocienda committed
212
213
214
215
216
217

    void restoreScrollBar();

    QStringList formCompletionItems(const QString &name) const;
    void addFormCompletionItem(const QString &name, const QString &value);

darin's avatar
darin committed
218
    bool dispatchMouseEvent(const AtomicString& eventType, NodeImpl* target,
darin's avatar
darin committed
219
        bool cancelable, int clickCount, const MouseEvent&, bool setUnder);
darin's avatar
darin committed
220
    bool dispatchDragEvent(const AtomicString& eventType, NodeImpl* target,
darin's avatar
darin committed
221
        const MouseEvent&, ClipboardImpl*);
kocienda's avatar
kocienda committed
222

darin's avatar
darin committed
223
    void applyOverflowToViewport(RenderObject* o, ScrollBarMode& hMode, ScrollBarMode& vMode);
224

225
    virtual bool isFrameView() const;
darin's avatar
darin committed
226

darin's avatar
darin committed
227
228
    void updateBorder();

mjs's avatar
mjs committed
229
230
    unsigned _refCount;

kocienda's avatar
kocienda committed
231
232
233
234
235
236
    int _width;
    int _height;

    int _marginWidth;
    int _marginHeight;

darin's avatar
darin committed
237
238
    RefPtr<Frame> m_frame;
    FrameViewPrivate* d;
239

darin's avatar
darin committed
240
    QString m_medium; // media type
kocienda's avatar
kocienda committed
241
242
};

darin's avatar
darin committed
243
244
}

kocienda's avatar
kocienda committed
245
246
#endif