• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of the html renderer for KDE.
3  *
4  * Copyright (C) 2005 Apple Computer
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef RenderButton_h
24 #define RenderButton_h
25 
26 #include "RenderFlexibleBox.h"
27 #include "Timer.h"
28 #include <wtf/OwnPtr.h>
29 
30 namespace WebCore {
31 
32 class RenderTextFragment;
33 
34 // RenderButtons are just like normal flexboxes except that they will generate an anonymous block child.
35 // For inputs, they will also generate an anonymous RenderText and keep its style and content up
36 // to date as the button changes.
37 class RenderButton : public RenderFlexibleBox {
38 public:
39     RenderButton(Node*);
40 
renderName()41     virtual const char* renderName() const { return "RenderButton"; }
isRenderButton()42     virtual bool isRenderButton() const { return true; }
43 
44     virtual void addChild(RenderObject* newChild, RenderObject *beforeChild = 0);
45     virtual void removeChild(RenderObject*);
removeLeftoverAnonymousBlock(RenderBlock *)46     virtual void removeLeftoverAnonymousBlock(RenderBlock*) { }
createsAnonymousWrapper()47     virtual bool createsAnonymousWrapper() const { return true; }
48 
49     void setupInnerStyle(RenderStyle*);
50     virtual void updateFromElement();
51 
52     virtual void updateBeforeAfterContent(PseudoId);
53 
hasControlClip()54     virtual bool hasControlClip() const { return true; }
55     virtual IntRect controlClipRect(int /*tx*/, int /*ty*/) const;
56 
57     void setText(const String&);
58     String text() const;
59 
60     virtual bool canHaveChildren() const;
61 
62 protected:
63     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
64     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
65 
hasLineIfEmpty()66     virtual bool hasLineIfEmpty() const { return true; }
67 
68     void timerFired(Timer<RenderButton>*);
69 
70     RenderTextFragment* m_buttonText;
71     RenderBlock* m_inner;
72 
73     OwnPtr<Timer<RenderButton> > m_timer;
74     bool m_default;
75 };
76 
toRenderButton(RenderObject * object)77 inline RenderButton* toRenderButton(RenderObject* object)
78 {
79     ASSERT(!object || object->isRenderButton());
80     return static_cast<RenderButton*>(object);
81 }
82 
toRenderButton(const RenderObject * object)83 inline const RenderButton* toRenderButton(const RenderObject* object)
84 {
85     ASSERT(!object || object->isRenderButton());
86     return static_cast<const RenderButton*>(object);
87 }
88 
89 // This will catch anyone doing an unnecessary cast.
90 void toRenderButton(const RenderButton*);
91 
92 } // namespace WebCore
93 
94 #endif // RenderButton_h
95