1 /* 2 * Copyright (C) 1999 Lars Knoll (knoll (at) 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 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 void showSubstituteImage(PassRefPtr<Image>); 44 45 static void suspendWidgetHierarchyUpdates(); 46 static void resumeWidgetHierarchyUpdates(); 47 48 protected: 49 RenderWidget(Node*); 50 51 FrameView* frameView() const { return m_frameView; } 52 53 void clearWidget(); 54 55 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle); 56 virtual void layout(); 57 58 private: 59 virtual bool isWidget() const { return true; } 60 61 virtual void paint(PaintInfo&, int x, int y); 62 virtual void destroy(); 63 virtual void setSelectionState(SelectionState); 64 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction); 65 virtual void setOverlapTestResult(bool); 66 67 bool setWidgetGeometry(const IntRect&); 68 69 friend class RenderWidgetProtector; 70 RenderArena* ref() { ++m_refCount; return renderArena(); } 71 void deref(RenderArena*); 72 73 RefPtr<Widget> m_widget; 74 RefPtr<Image> m_substituteImage; 75 FrameView* m_frameView; 76 int m_refCount; 77 }; 78 79 inline RenderWidget* toRenderWidget(RenderObject* object) 80 { 81 ASSERT(!object || object->isWidget()); 82 return static_cast<RenderWidget*>(object); 83 } 84 85 inline const RenderWidget* toRenderWidget(const RenderObject* object) 86 { 87 ASSERT(!object || object->isWidget()); 88 return static_cast<const RenderWidget*>(object); 89 } 90 91 // This will catch anyone doing an unnecessary cast. 92 void toRenderWidget(const RenderWidget*); 93 94 } // namespace WebCore 95 96 #endif // RenderWidget_h 97