blob: 566d48fd3a42f8c804b1fff486b12daad3adf7f1 [file] [log] [blame]
darinb9481ed2006-03-20 02:57:59 +00001/*
darinb9481ed2006-03-20 02:57:59 +00002 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org)
darin@apple.com8faae442010-05-28 04:21:55 +00005 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
darinb9481ed2006-03-20 02:57:59 +00006 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
ddkilzerc8eccec2007-09-26 02:29:57 +000019 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
darinb9481ed2006-03-20 02:57:59 +000021 *
22 */
adele714147d2007-04-29 04:09:26 +000023
eseidel8eddecf2007-01-16 00:49:43 +000024#ifndef HTMLButtonElement_h
25#define HTMLButtonElement_h
darinb9481ed2006-03-20 02:57:59 +000026
darin@apple.com3d8b64f2008-06-15 06:09:21 +000027#include "HTMLFormControlElement.h"
darinb9481ed2006-03-20 02:57:59 +000028
29namespace WebCore {
30
andersca@apple.com16d2dd42014-01-16 23:08:24 +000031class HTMLButtonElement final : public HTMLFormControlElement {
darinb9481ed2006-03-20 02:57:59 +000032public:
weinig@apple.com02f433a2015-01-06 22:32:48 +000033 static Ref<HTMLButtonElement> create(const QualifiedName&, Document&, HTMLFormElement*);
darin@apple.com8faae442010-05-28 04:21:55 +000034
commit-queue@webkit.orged51ad42012-06-14 08:31:25 +000035 void setType(const AtomicString&);
commit-queue@webkit.org0e2df182012-06-13 04:50:42 +000036
cdumez@apple.com52850002014-09-18 16:52:10 +000037 const AtomicString& value() const;
darin@apple.com8faae442010-05-28 04:21:55 +000038
darin@apple.com11ff47c2016-03-04 16:47:55 +000039 bool willRespondToMouseClickEvents() override;
allan.jensen@nokia.comd4a972d2012-07-30 13:33:14 +000040
darin@apple.com8faae442010-05-28 04:21:55 +000041private:
weinig@apple.com6becaaf2013-09-14 21:33:13 +000042 HTMLButtonElement(const QualifiedName& tagName, Document&, HTMLFormElement*);
darin@apple.com8faae442010-05-28 04:21:55 +000043
44 enum Type { SUBMIT, RESET, BUTTON };
darinb9481ed2006-03-20 02:57:59 +000045
darin@apple.com11ff47c2016-03-04 16:47:55 +000046 const AtomicString& formControlType() const override;
esprehn@chromium.org1326ee12013-01-30 19:41:07 +000047
darin@apple.com11ff47c2016-03-04 16:47:55 +000048 RenderPtr<RenderElement> createElementRenderer(Ref<RenderStyle>&&, const RenderTreePosition&) override;
darinb9481ed2006-03-20 02:57:59 +000049
esprehn@chromium.org1326ee12013-01-30 19:41:07 +000050 // HTMLFormControlElement always creates one, but buttons don't need it.
darin@apple.com11ff47c2016-03-04 16:47:55 +000051 bool alwaysCreateUserAgentShadowRoot() const override { return false; }
darin@apple.com49cc03e2016-03-04 17:20:46 +000052 bool canHaveUserAgentShadowRoot() const final { return true; }
shinyak@chromium.org9ff511c2012-08-22 01:47:20 +000053
darin@apple.com11ff47c2016-03-04 16:47:55 +000054 void parseAttribute(const QualifiedName&, const AtomicString&) override;
55 bool isPresentationAttribute(const QualifiedName&) const override;
56 void defaultEventHandler(Event*) override;
allan.jensen@nokia.comd4a972d2012-07-30 13:33:14 +000057
darin@apple.com11ff47c2016-03-04 16:47:55 +000058 bool appendFormData(FormDataList&, bool) override;
darinb9481ed2006-03-20 02:57:59 +000059
darin@apple.com11ff47c2016-03-04 16:47:55 +000060 bool isEnumeratable() const override { return true; }
61 bool supportLabels() const override { return true; }
darinb9481ed2006-03-20 02:57:59 +000062
darin@apple.com11ff47c2016-03-04 16:47:55 +000063 bool isSuccessfulSubmitButton() const override;
64 bool isActivatedSubmit() const override;
65 void setActivatedSubmit(bool flag) override;
darinb9481ed2006-03-20 02:57:59 +000066
darin@apple.com11ff47c2016-03-04 16:47:55 +000067 void accessKeyAction(bool sendMouseEvents) override;
68 bool isURLAttribute(const Attribute&) const override;
darinb9481ed2006-03-20 02:57:59 +000069
darin@apple.com11ff47c2016-03-04 16:47:55 +000070 bool canStartSelection() const override { return false; }
adele79c8ed22007-09-19 18:04:30 +000071
darin@apple.com11ff47c2016-03-04 16:47:55 +000072 bool isOptionalFormControl() const override { return true; }
73 bool computeWillValidate() const override;
adele714147d2007-04-29 04:09:26 +000074
75 Type m_type;
darin@apple.com7e8868d2011-01-01 00:58:22 +000076 bool m_isActivatedSubmit;
darinb9481ed2006-03-20 02:57:59 +000077};
78
darinf4b05b22006-07-10 05:20:17 +000079} // namespace
darinb9481ed2006-03-20 02:57:59 +000080
81#endif