• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
widget()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 showSubstituteImage(PassRefPtr<Image>);
45 
46     void notifyWidget(WidgetNotification);
47 
48     static void suspendWidgetHierarchyUpdates();
49     static void resumeWidgetHierarchyUpdates();
50 
ref()51     RenderArena* ref() { ++m_refCount; return renderArena(); }
52     void deref(RenderArena*);
53 
54 protected:
55     RenderWidget(Node*);
56 
frameView()57     FrameView* frameView() const { return m_frameView; }
58 
59     void clearWidget();
60 
61     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
62     virtual void layout();
63     virtual void paint(PaintInfo&, int x, int y);
64 
65 private:
isWidget()66     virtual bool isWidget() const { return true; }
67 
68     virtual void destroy();
69     virtual void setSelectionState(SelectionState);
70     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
71     virtual void setOverlapTestResult(bool);
72 
73     bool setWidgetGeometry(const IntRect&, const IntSize&);
74 
75     RefPtr<Widget> m_widget;
76     RefPtr<Image> m_substituteImage;
77     FrameView* m_frameView;
78     IntRect m_clipRect; // The rectangle needs to remain correct after scrolling, so it is stored in content view coordinates, and not clipped to window.
79     int m_refCount;
80 };
81 
toRenderWidget(RenderObject * object)82 inline RenderWidget* toRenderWidget(RenderObject* object)
83 {
84     ASSERT(!object || object->isWidget());
85     return static_cast<RenderWidget*>(object);
86 }
87 
toRenderWidget(const RenderObject * object)88 inline const RenderWidget* toRenderWidget(const RenderObject* object)
89 {
90     ASSERT(!object || object->isWidget());
91     return static_cast<const RenderWidget*>(object);
92 }
93 
94 // This will catch anyone doing an unnecessary cast.
95 void toRenderWidget(const RenderWidget*);
96 
97 } // namespace WebCore
98 
99 #endif // RenderWidget_h
100