initial import
[vuplus_webkit] / Source / WebCore / rendering / RenderWidget.h
1 /*
2  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3  * Copyright (C) 2004, 2005, 2006, 2009, 2010 Apple Inc. All rights reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  */
21
22 #ifndef RenderWidget_h
23 #define RenderWidget_h
24
25 #include "OverlapTestRequestClient.h"
26 #include "RenderReplaced.h"
27 #include "Widget.h"
28
29 namespace WebCore {
30
31 class RenderWidget : public RenderReplaced, private OverlapTestRequestClient {
32 public:
33     virtual ~RenderWidget();
34
35     Widget* widget() const { return m_widget.get(); }
36     virtual void setWidget(PassRefPtr<Widget>);
37
38     static RenderWidget* find(const Widget*);
39
40     void updateWidgetPosition();
41     void widgetPositionsUpdated();
42     IntRect windowClipRect() const;
43
44     void notifyWidget(WidgetNotification);
45     
46     static void suspendWidgetHierarchyUpdates();
47     static void resumeWidgetHierarchyUpdates();
48
49     RenderArena* ref() { ++m_refCount; return renderArena(); }
50     void deref(RenderArena*);
51
52 protected:
53     RenderWidget(Node*);
54
55     FrameView* frameView() const { return m_frameView; }
56
57     void clearWidget();
58
59     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
60     virtual void layout();
61     virtual void paint(PaintInfo&, const LayoutPoint&);
62
63 private:
64     virtual bool isWidget() const { return true; }
65
66     virtual void willBeDestroyed();
67     virtual void destroy();
68     virtual void setSelectionState(SelectionState);
69     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
70     virtual void setOverlapTestResult(bool);
71
72     bool setWidgetGeometry(const IntRect&, const IntSize&);
73
74     RefPtr<Widget> m_widget;
75     FrameView* m_frameView;
76     IntRect m_clipRect; // The rectangle needs to remain correct after scrolling, so it is stored in content view coordinates, and not clipped to window.
77     int m_refCount;
78 };
79
80 inline RenderWidget* toRenderWidget(RenderObject* object)
81 {
82     ASSERT(!object || object->isWidget());
83     return static_cast<RenderWidget*>(object);
84 }
85
86 inline const RenderWidget* toRenderWidget(const RenderObject* object)
87 {
88     ASSERT(!object || object->isWidget());
89     return static_cast<const RenderWidget*>(object);
90 }
91
92 // This will catch anyone doing an unnecessary cast.
93 void toRenderWidget(const RenderWidget*);
94
95 } // namespace WebCore
96
97 #endif // RenderWidget_h