1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2009 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
28 namespace WebCore {
29
30 class Widget;
31
32 class RenderWidget : public RenderReplaced, private OverlapTestRequestClient {
33 public:
34 virtual ~RenderWidget();
35
widget()36 Widget* widget() const { return m_widget.get(); }
37 virtual void setWidget(PassRefPtr<Widget>);
38
39 static RenderWidget* find(const Widget*);
40
41 void updateWidgetPosition();
42
43 protected:
44 RenderWidget(Node*);
45
frameView()46 FrameView* frameView() const { return m_frameView; }
47
48 void clearWidget();
49
50 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
51 virtual void layout();
52
53 private:
isWidget()54 virtual bool isWidget() const { return true; }
55
56 virtual void paint(PaintInfo&, int x, int y);
57 virtual void destroy();
58 virtual void setSelectionState(SelectionState);
59 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
60 virtual void setOverlapTestResult(bool);
61
62 void setWidgetGeometry(const IntRect&);
63
ref()64 RenderArena* ref() { ++m_refCount; return renderArena(); }
65 void deref(RenderArena*);
66
67 RefPtr<Widget> m_widget;
68 FrameView* m_frameView;
69 int m_refCount;
70 };
71
toRenderWidget(RenderObject * object)72 inline RenderWidget* toRenderWidget(RenderObject* object)
73 {
74 ASSERT(!object || object->isWidget());
75 return static_cast<RenderWidget*>(object);
76 }
77
toRenderWidget(const RenderObject * object)78 inline const RenderWidget* toRenderWidget(const RenderObject* object)
79 {
80 ASSERT(!object || object->isWidget());
81 return static_cast<const RenderWidget*>(object);
82 }
83
84 // This will catch anyone doing an unnecessary cast.
85 void toRenderWidget(const RenderWidget*);
86
87 } // namespace WebCore
88
89 #endif // RenderWidget_h
90