blob: 96bfda8465fd3b436a679bdbf8e0de57286a1ea4 [file] [log] [blame]
hyatt82bdd232005-10-21 21:27:51 +00001/*
mjs@apple.com92047332014-03-15 04:08:27 +00002 * Copyright (C) 2005 Apple Inc.
hyatt82bdd232005-10-21 21:27:51 +00003 *
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
ddkilzerc8eccec2007-09-26 02:29:57 +000016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
hyatt82bdd232005-10-21 21:27:51 +000018 *
19 */
darin9d0a6282006-03-01 07:49:33 +000020
commit-queue@webkit.org46c0f522016-11-13 10:05:43 +000021#pragma once
hyatt82bdd232005-10-21 21:27:51 +000022
commit-queue@webkit.orge7c35fc2013-02-21 20:56:18 +000023#include "RenderFlexibleBox.h"
sfalken@apple.com14e9c0b2008-05-05 20:51:32 +000024#include "Timer.h"
zandobersek@gmail.com31dae992014-03-31 10:12:49 +000025#include <memory>
hyatt82bdd232005-10-21 21:27:51 +000026
darin9d0a6282006-03-01 07:49:33 +000027namespace WebCore {
hyatt82bdd232005-10-21 21:27:51 +000028
akling@apple.comb82aab52013-09-13 09:00:04 +000029class HTMLFormControlElement;
bdash9f45d102007-10-14 11:44:20 +000030class RenderTextFragment;
31
hyatt82bdd232005-10-21 21:27:51 +000032// RenderButtons are just like normal flexboxes except that they will generate an anonymous block child.
33// For inputs, they will also generate an anonymous RenderText and keep its style and content up
34// to date as the button changes.
andersca@apple.com16d2dd42014-01-16 23:08:24 +000035class RenderButton final : public RenderFlexibleBox {
hyatt82bdd232005-10-21 21:27:51 +000036public:
antti@apple.com454418f2016-04-25 19:49:23 +000037 RenderButton(HTMLFormControlElement&, RenderStyle&&);
commit-queue@webkit.org7538c252010-10-09 02:00:07 +000038 virtual ~RenderButton();
hyatt82bdd232005-10-21 21:27:51 +000039
akling@apple.comb82aab52013-09-13 09:00:04 +000040 HTMLFormControlElement& formControlElement() const;
weinigc24ab182006-10-30 22:41:29 +000041
darin@apple.com11ff47c2016-03-04 16:47:55 +000042 bool canBeSelectionLeaf() const override;
rniwa@webkit.org85059ba2012-03-24 00:54:04 +000043
darin@apple.com11ff47c2016-03-04 16:47:55 +000044 void addChild(RenderObject* newChild, RenderObject *beforeChild = 0) override;
45 void removeChild(RenderObject&) override;
46 void removeLeftoverAnonymousBlock(RenderBlock*) override { }
47 bool createsAnonymousWrapper() const override { return true; }
hyatt82bdd232005-10-21 21:27:51 +000048
darin@chromium.orge040ff22008-12-09 21:46:03 +000049 void setupInnerStyle(RenderStyle*);
darin@apple.com11ff47c2016-03-04 16:47:55 +000050 void updateFromElement() override;
hyatt82bdd232005-10-21 21:27:51 +000051
darin@apple.com11ff47c2016-03-04 16:47:55 +000052 bool canHaveGeneratedChildren() const override;
53 bool hasControlClip() const override { return true; }
54 LayoutRect controlClipRect(const LayoutPoint&) const override;
hyattebae6a82005-10-22 18:19:27 +000055
commit-queue@webkit.orge27a9182012-09-21 09:22:51 +000056 void setText(const String&);
57 String text() const;
58
joepeck@webkit.orgb982bd02014-01-11 01:33:47 +000059#if PLATFORM(IOS)
darin@apple.com11ff47c2016-03-04 16:47:55 +000060 void layout() override;
joepeck@webkit.orgb982bd02014-01-11 01:33:47 +000061#endif
62
mitz@apple.com55bf8722010-05-21 00:37:06 +000063private:
commit-queue@webkit.orge7227452014-01-17 12:24:16 +000064 void element() const = delete;
akling@apple.comb82aab52013-09-13 09:00:04 +000065
darin@apple.com11ff47c2016-03-04 16:47:55 +000066 const char* renderName() const override { return "RenderButton"; }
67 bool isRenderButton() const override { return true; }
akling@apple.comb82aab52013-09-13 09:00:04 +000068
darin@apple.com11ff47c2016-03-04 16:47:55 +000069 void styleWillChange(StyleDifference, const RenderStyle& newStyle) override;
70 void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
simon.fraser@apple.coma89b8cd2008-10-10 03:15:31 +000071
darin@apple.com11ff47c2016-03-04 16:47:55 +000072 bool hasLineIfEmpty() const override;
adele05abee32006-08-25 23:44:05 +000073
svillar@igalia.come2c93522015-09-10 11:58:24 +000074 bool isFlexibleBoxImpl() const override { return true; }
75
commit-queue@webkit.orge27a9182012-09-21 09:22:51 +000076 RenderTextFragment* m_buttonText;
hyatt82bdd232005-10-21 21:27:51 +000077 RenderBlock* m_inner;
78};
79
weinigc24ab182006-10-30 22:41:29 +000080} // namespace WebCore
darin9d0a6282006-03-01 07:49:33 +000081
cdumez@apple.comf85e2f62014-10-07 00:26:25 +000082SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderButton, isRenderButton())