1 | /* |
2 | * Copyright (C) 2005 Apple Inc. |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Library General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Library General Public License |
15 | * along with this library; see the file COPYING.LIB. If not, write to |
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | * Boston, MA 02110-1301, USA. |
18 | * |
19 | */ |
20 | |
21 | #pragma once |
22 | |
23 | #include "RenderFlexibleBox.h" |
24 | #include <memory> |
25 | |
26 | namespace WebCore { |
27 | |
28 | class HTMLFormControlElement; |
29 | class RenderTextFragment; |
30 | |
31 | // RenderButtons are just like normal flexboxes except that they will generate an anonymous block child. |
32 | // For inputs, they will also generate an anonymous RenderText and keep its style and content up |
33 | // to date as the button changes. |
34 | class RenderButton final : public RenderFlexibleBox { |
35 | WTF_MAKE_ISO_ALLOCATED(RenderButton); |
36 | public: |
37 | RenderButton(HTMLFormControlElement&, RenderStyle&&); |
38 | virtual ~RenderButton(); |
39 | |
40 | HTMLFormControlElement& formControlElement() const; |
41 | |
42 | bool canBeSelectionLeaf() const override; |
43 | |
44 | bool createsAnonymousWrapper() const override { return true; } |
45 | |
46 | void updateFromElement() override; |
47 | |
48 | bool canHaveGeneratedChildren() const override; |
49 | bool hasControlClip() const override { return true; } |
50 | LayoutRect controlClipRect(const LayoutPoint&) const override; |
51 | |
52 | void updateAnonymousChildStyle(RenderStyle&) const override; |
53 | |
54 | void setText(const String&); |
55 | String text() const; |
56 | |
57 | #if PLATFORM(IOS_FAMILY) |
58 | void layout() override; |
59 | #endif |
60 | |
61 | RenderBlock* innerRenderer() const { return m_inner.get(); } |
62 | void setInnerRenderer(RenderBlock&); |
63 | |
64 | int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override; |
65 | |
66 | private: |
67 | void element() const = delete; |
68 | |
69 | const char* renderName() const override { return "RenderButton" ; } |
70 | bool isRenderButton() const override { return true; } |
71 | |
72 | bool hasLineIfEmpty() const override; |
73 | |
74 | bool isFlexibleBoxImpl() const override { return true; } |
75 | |
76 | WeakPtr<RenderTextFragment> m_buttonText; |
77 | WeakPtr<RenderBlock> m_inner; |
78 | }; |
79 | |
80 | } // namespace WebCore |
81 | |
82 | SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderButton, isRenderButton()) |
83 | |