FrameView.h 7.4 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;
thatcher's avatar
thatcher committed
36
class Color;
darin's avatar
darin committed
37 38
class CSSProperty;
class CSSStyleSelector;
darin's avatar
darin committed
39 40 41
class Clipboard;
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
class InlineBox;
adele's avatar
adele committed
55
class IntPoint;
darin's avatar
darin committed
56
class IntRect;
darin's avatar
darin committed
57 58 59
class PlatformKeyboardEvent;
class FrameMac;
class PlatformMouseEvent;
ap's avatar
ap committed
60
class MouseEventWithHitTestResults;
darin's avatar
darin committed
61
class Node;
darin's avatar
darin committed
62
class RenderBox;
63
class RenderView;
darin's avatar
darin committed
64 65 66 67 68 69
class RenderLineEdit;
class RenderObject;
class RenderPart;
class RenderPartObject;
class RenderStyle;
class RenderWidget;
darin's avatar
darin committed
70
class PlatformWheelEvent;
71
class String;
darin's avatar
darin committed
72 73 74 75

template <typename T> class Timer;

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

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

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

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

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

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

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

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

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

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

129 130
    void resetScrollBars();

131
    void clear();
132

133 134
    bool didFirstLayout() const;

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

darin's avatar
darin committed
138 139
    void handleMousePressEvent(const PlatformMouseEvent&);
    void handleMouseDoubleClickEvent(const PlatformMouseEvent&);
hyatt's avatar
hyatt committed
140 141
    virtual void handleMouseMoveEvent(const PlatformMouseEvent&);
    virtual void handleMouseReleaseEvent(const PlatformMouseEvent&);
darin's avatar
darin committed
142
    void handleWheelEvent(PlatformWheelEvent&);
kocienda's avatar
kocienda committed
143

hyatt's avatar
hyatt committed
144 145 146 147
    bool passMousePressEventToSubframe(MouseEventWithHitTestResults&, Frame*);
    bool passMouseMoveEventToSubframe(MouseEventWithHitTestResults&, Frame*);
    bool passMouseReleaseEventToSubframe(MouseEventWithHitTestResults&, Frame*);
    bool passWheelEventToSubframe(PlatformWheelEvent&, Frame*);
148
    bool passMousePressEventToScrollbar(MouseEventWithHitTestResults&);
hyatt's avatar
hyatt committed
149

adele's avatar
adele committed
150
    bool mousePressed();
151
    void setMousePressed(bool);
adele's avatar
adele committed
152

kocienda's avatar
kocienda committed
153 154
    void doAutoScroll();

darin's avatar
darin committed
155 156 157
    bool updateDragAndDrop(const PlatformMouseEvent&, Clipboard*);
    void cancelDragAndDrop(const PlatformMouseEvent&, Clipboard*);
    bool performDragAndDrop(const PlatformMouseEvent&, Clipboard*);
trey's avatar
trey committed
158

darin's avatar
darin committed
159
    void layoutTimerFired(Timer<FrameView>*);
adele's avatar
adele committed
160
    void hoverTimerFired(Timer<FrameView>*);
161

162
    void repaintRectangle(const IntRect& r, bool immediate);
darin's avatar
darin committed
163 164 165

    bool isTransparent() const;
    void setTransparent(bool isTransparent);
thatcher's avatar
thatcher committed
166 167 168 169

    Color baseBackgroundColor() const;
    void setBaseBackgroundColor(Color);

170
    void scheduleRelayout();
adele's avatar
adele committed
171
    void scheduleRelayoutOfSubtree(Node*);
172 173
    void unscheduleRelayout();
    bool haveDelayedLayoutScheduled();
ap's avatar
ap committed
174
    bool layoutPending() const;
175

adele's avatar
adele committed
176 177
    void scheduleHoverStateUpdate();

178
    void adjustViewSize();
179
    void initScrollBars();
180
    
darin's avatar
darin committed
181 182 183
    void setHasBorder(bool);
    bool hasBorder() const;
    
darin's avatar
darin committed
184
    void setResizingFrameSet(HTMLFrameSetElement *);
ap's avatar
ap committed
185

186
#if __APPLE__
187
    void updateDashboardRegions();
188
#endif
mjs's avatar
mjs committed
189

tomernic's avatar
tomernic committed
190 191 192
    virtual void scrollPointRecursively(int x, int y);
    virtual void setContentsPos(int x, int y);

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

adele's avatar
adele committed
195 196
    IntPoint currentMousePosition() const;

197 198
    void ref() { ++m_refCount; }
    void deref() { if (!--m_refCount) delete this; }
adele's avatar
adele committed
199
    bool hasOneRef() { return m_refCount == 1; }
adele's avatar
adele committed
200

kocienda's avatar
kocienda committed
201
private:
darin's avatar
darin committed
202 203
    void cleared();
    void scrollBarMoved();
204 205

    void resetCursor();
darin's avatar
darin committed
206
    void invalidateClick();
207

kocienda's avatar
kocienda committed
208
    /**
209 210 211 212 213 214 215 216
     * 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
217
     */
218 219
    void setMediaType(const String&);
    String mediaType() const;
220

darin's avatar
darin committed
221
    bool scrollTo(const IntRect&);
222 223

    void focusNextPrevNode(bool next);
kocienda's avatar
kocienda committed
224

225 226 227 228
    bool useSlowRepaints() const;
    void setUseSlowRepaints();
    void addSlowRepaintObject();
    void removeSlowRepaintObject();
kocienda's avatar
kocienda committed
229

230 231
    void setIgnoreWheelEvents(bool e);

kocienda's avatar
kocienda committed
232 233
    void init();

darin's avatar
darin committed
234
    Node *nodeUnderMouse() const;
kocienda's avatar
kocienda committed
235 236 237

    void restoreScrollBar();

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

darin's avatar
darin committed
240 241 242 243
    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
244

darin's avatar
darin committed
245
    void applyOverflowToViewport(RenderObject* o, ScrollBarMode& hMode, ScrollBarMode& vMode);
hyatt's avatar
hyatt committed
246

247
    virtual bool isFrameView() const;
darin's avatar
darin committed
248

darin's avatar
darin committed
249 250
    void updateBorder();

andersca's avatar
andersca committed
251 252 253
    void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
    void dispatchScheduledEvents();
        
254 255 256 257 258
    unsigned m_refCount;
    
    IntSize m_size;
    IntSize m_margins;
    
darin's avatar
darin committed
259 260
    RefPtr<Frame> m_frame;
    FrameViewPrivate* d;
kocienda's avatar
kocienda committed
261 262
};

darin's avatar
darin committed
263 264
}

kocienda's avatar
kocienda committed
265 266
#endif