FrameView.h 6.78 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 "ScrollView.h"
30
31
#include "IntSize.h"
#include "PlatformString.h"
darin's avatar
darin committed
32

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

darin's avatar
darin committed
35
class AtomicString;
darin's avatar
darin committed
36
37
class CSSProperty;
class CSSStyleSelector;
darin's avatar
darin committed
38
class Clipboard;
darin's avatar
darin committed
39
class DeprecatedStringList;
darin's avatar
darin committed
40
41
class Document;
class Element;
andersca's avatar
andersca committed
42
43
class Event;
class EventTargetNode;
darin's avatar
darin committed
44
class Frame;
45
class FrameViewPrivate;
darin's avatar
darin committed
46
class GraphicsContext;
darin's avatar
darin committed
47
48
49
50
51
52
53
class HTMLAnchorElement;
class HTMLDocument;
class HTMLElement;
class HTMLFormElement;
class HTMLFrameSetElement;
class HTMLGenericFormElement;
class HTMLTitleElement;
darin's avatar
darin committed
54
55
class InlineBox;
class IntRect;
darin's avatar
darin committed
56
57
58
class PlatformKeyboardEvent;
class FrameMac;
class PlatformMouseEvent;
ap's avatar
ap committed
59
class MouseEventWithHitTestResults;
darin's avatar
darin committed
60
class Node;
darin's avatar
darin committed
61
class RenderBox;
62
class RenderView;
darin's avatar
darin committed
63
64
65
66
67
68
class RenderLineEdit;
class RenderObject;
class RenderPart;
class RenderPartObject;
class RenderStyle;
class RenderWidget;
darin's avatar
darin committed
69
class PlatformWheelEvent;
70
class String;
darin's avatar
darin committed
71
72
73
74

template <typename T> class Timer;

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

darin's avatar
darin committed
76
class FrameView : public ScrollView {
darin's avatar
darin committed
77
    friend class CSSStyleSelector;
darin's avatar
darin committed
78
    friend class Document;
mjs's avatar
mjs committed
79
    friend class Frame;
darin's avatar
darin committed
80
81
82
83
84
85
    friend class HTMLAnchorElement;
    friend class HTMLDocument;
    friend class HTMLFormElement;
    friend class HTMLGenericFormElement;
    friend class HTMLTitleElement;
    friend class FrameMac;
darin's avatar
darin committed
86
    friend class RenderBox;
87
    friend class RenderView;
darin's avatar
darin committed
88
89
90
91
92
    friend class RenderLineEdit;
    friend class RenderObject;
    friend class RenderPart;
    friend class RenderPartObject;
    friend class RenderWidget;
darin's avatar
darin committed
93
    friend void applyRule(CSSProperty *prop);
kocienda's avatar
kocienda committed
94
95

public:
darin's avatar
darin committed
96
    FrameView(Frame*);
97
    virtual ~FrameView();
kocienda's avatar
kocienda committed
98

darin's avatar
darin committed
99
    Frame* frame() const { return m_frame.get(); }
kocienda's avatar
kocienda committed
100

101
    int frameWidth() const { return m_size.width(); }
kocienda's avatar
kocienda committed
102

103
    /**
104
     * Gets/Sets the margin width/height
kocienda's avatar
kocienda committed
105
106
107
     *
     * A return value of -1 means the default value will be used.
     */
108
109
110
111
    int marginWidth() const { return m_margins.width(); }
    int marginHeight() { return  m_margins.height(); }
    void setMarginWidth(int);
    void setMarginHeight(int);
kocienda's avatar
kocienda committed
112

darin's avatar
darin committed
113
114
115
    virtual void setVScrollBarMode(ScrollBarMode);
    virtual void setHScrollBarMode(ScrollBarMode);
    virtual void setScrollBarsMode(ScrollBarMode);
116
    
117
    void print();
kocienda's avatar
kocienda committed
118

adele's avatar
adele committed
119
    void layout(bool allowSubtree = true);
kocienda's avatar
kocienda committed
120

ap's avatar
ap committed
121
    Node* layoutRoot() const;
122
    int layoutCount() const;
123
124

    bool needsFullRepaint() const;
125
    
126
    void addRepaintInfo(RenderObject*, const IntRect&);
127

128
129
    void resetScrollBars();

130
    void clear();
131

132
public:
eseidel's avatar
eseidel committed
133
    void clearPart();
darin's avatar
darin committed
134

darin's avatar
darin committed
135
136
137
138
139
    void handleMousePressEvent(const PlatformMouseEvent&);
    void handleMouseDoubleClickEvent(const PlatformMouseEvent&);
    void handleMouseMoveEvent(const PlatformMouseEvent&);
    void handleMouseReleaseEvent(const PlatformMouseEvent&);
    void handleWheelEvent(PlatformWheelEvent&);
kocienda's avatar
kocienda committed
140

adele's avatar
adele committed
141
142
    bool mousePressed();

kocienda's avatar
kocienda committed
143
144
    void doAutoScroll();

darin's avatar
darin committed
145
146
147
    bool updateDragAndDrop(const PlatformMouseEvent&, Clipboard*);
    void cancelDragAndDrop(const PlatformMouseEvent&, Clipboard*);
    bool performDragAndDrop(const PlatformMouseEvent&, Clipboard*);
trey's avatar
trey committed
148

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

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

    bool isTransparent() const;
    void setTransparent(bool isTransparent);
156
    
157
    void scheduleRelayout();
adele's avatar
adele committed
158
    void scheduleRelayoutOfSubtree(Node*);
159
160
    void unscheduleRelayout();
    bool haveDelayedLayoutScheduled();
ap's avatar
ap committed
161
    bool layoutPending() const;
162

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

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

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

andersca's avatar
andersca committed
177
178
    void scheduleEvent(PassRefPtr<Event>, PassRefPtr<EventTargetNode>, bool tempEvent);

179
180
    void ref() { ++m_refCount; }
    void deref() { if (!--m_refCount) delete this; }
adele's avatar
adele committed
181
    bool hasOneRef() { return m_refCount == 1; }
mjs's avatar
mjs committed
182
    
kocienda's avatar
kocienda committed
183
private:
darin's avatar
darin committed
184
185
    void cleared();
    void scrollBarMoved();
186
187

    void resetCursor();
darin's avatar
darin committed
188
    void invalidateClick();
189

kocienda's avatar
kocienda committed
190
    /**
191
192
193
194
195
196
197
198
     * 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
199
     */
200
201
    void setMediaType(const String&);
    String mediaType() const;
202

darin's avatar
darin committed
203
    bool scrollTo(const IntRect&);
204
205

    void focusNextPrevNode(bool next);
kocienda's avatar
kocienda committed
206
207
208

    void useSlowRepaints();

209
210
    void setIgnoreWheelEvents(bool e);

kocienda's avatar
kocienda committed
211
212
    void init();

darin's avatar
darin committed
213
    Node *nodeUnderMouse() const;
kocienda's avatar
kocienda committed
214
215
216

    void restoreScrollBar();

217
218
    DeprecatedStringList formCompletionItems(const String& name) const;
    void addFormCompletionItem(const String& name, const String& value);
kocienda's avatar
kocienda committed
219

ap's avatar
ap committed
220
221
    MouseEventWithHitTestResults prepareMouseEvent(bool readonly, bool active, bool mouseMove, const PlatformMouseEvent&);

darin's avatar
darin committed
222
223
224
225
    bool dispatchMouseEvent(const AtomicString& eventType, Node* target,
        bool cancelable, int clickCount, const PlatformMouseEvent&, bool setUnder);
    bool dispatchDragEvent(const AtomicString& eventType, Node* target,
        const PlatformMouseEvent&, Clipboard*);
kocienda's avatar
kocienda committed
226

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

229
    virtual bool isFrameView() const;
darin's avatar
darin committed
230

darin's avatar
darin committed
231
232
    void updateBorder();

andersca's avatar
andersca committed
233
234
235
    void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
    void dispatchScheduledEvents();
        
236
237
238
239
240
    unsigned m_refCount;
    
    IntSize m_size;
    IntSize m_margins;
    
darin's avatar
darin committed
241
242
    RefPtr<Frame> m_frame;
    FrameViewPrivate* d;
kocienda's avatar
kocienda committed
243
244
};

darin's avatar
darin committed
245
246
}

kocienda's avatar
kocienda committed
247
248
#endif