• 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"; }
42 
43     virtual void addChild(RenderObject* newChild, RenderObject *beforeChild = 0);
44     virtual void removeChild(RenderObject*);
removeLeftoverAnonymousBlock(RenderBlock *)45     virtual void removeLeftoverAnonymousBlock(RenderBlock*) { }
createsAnonymousWrapper()46     virtual bool createsAnonymousWrapper() const { return true; }
47 
48     void setupInnerStyle(RenderStyle*);
49     virtual void updateFromElement();
50 
51     virtual void updateBeforeAfterContent(RenderStyle::PseudoId);
52 
hasControlClip()53     virtual bool hasControlClip() const { return true; }
54     virtual IntRect controlClipRect(int /*tx*/, int /*ty*/) const;
55 
56     void setText(const String&);
57 
58     virtual bool canHaveChildren() const;
59 
60 protected:
61     virtual void styleWillChange(RenderStyle::Diff, const RenderStyle* newStyle);
62     virtual void styleDidChange(RenderStyle::Diff, const RenderStyle* oldStyle);
63 
hasLineIfEmpty()64     virtual bool hasLineIfEmpty() const { return true; }
65 
66     void timerFired(Timer<RenderButton>*);
67 
68     RenderTextFragment* m_buttonText;
69     RenderBlock* m_inner;
70 
71     OwnPtr<Timer<RenderButton> > m_timer;
72     bool m_default;
73 };
74 
75 } // namespace WebCore
76 
77 #endif // RenderButton_h
78