15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/*
25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *           (C) 1999 Antti Koivisto (koivisto@kde.org)
45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *           (C) 2001 Dirk Mueller (mueller@kde.org)
55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *           (C) 2006 Alexey Proskuryakov (ap@nypop.com)
75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * This library is free software; you can redistribute it and/or
105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modify it under the terms of the GNU Library General Public
115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * License as published by the Free Software Foundation; either
125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * version 2 of the License, or (at your option) any later version.
135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * This library is distributed in the hope that it will be useful,
155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * but WITHOUT ANY WARRANTY; without even the implied warranty of
165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Library General Public License for more details.
185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * You should have received a copy of the GNU Library General Public License
205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * along with this library; see the file COPYING.LIB.  If not, write to
215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Boston, MA 02110-1301, USA.
235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */
255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "config.h"
2753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/html/HTMLButtonElement.h"
285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
29197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8DOMActivityLogger.h"
305d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)#include "core/HTMLNames.h"
3153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/dom/Attribute.h"
3206f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)#include "core/events/KeyboardEvent.h"
33bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)#include "core/html/FormDataList.h"
3453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/html/HTMLFormElement.h"
3553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/rendering/RenderButton.h"
36e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "wtf/StdLibExtras.h"
375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
38c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)using namespace HTMLNames;
415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
4251b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)inline HTMLButtonElement::HTMLButtonElement(Document& document, HTMLFormElement* form)
4351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    : HTMLFormControlElement(buttonTag, document, form)
445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    , m_type(SUBMIT)
455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    , m_isActivatedSubmit(false)
465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
49323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)PassRefPtrWillBeRawPtr<HTMLButtonElement> HTMLButtonElement::create(Document& document, HTMLFormElement* form)
505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
515d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    return adoptRefWillBeNoop(new HTMLButtonElement(document, form));
525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void HTMLButtonElement::setType(const AtomicString& type)
555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    setAttribute(typeAttr, type);
575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
59591b958dee2cf159d33a0b931e6231072eaf38d5Ben MurdochRenderObject* HTMLButtonElement::createRenderer(RenderStyle*)
605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
61f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles)    return new RenderButton(this);
625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)const AtomicString& HTMLButtonElement::formControlType() const
655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    switch (m_type) {
675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        case SUBMIT: {
685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            DEFINE_STATIC_LOCAL(const AtomicString, submit, ("submit", AtomicString::ConstructFromLiteral));
695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            return submit;
705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        }
715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        case BUTTON: {
725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            DEFINE_STATIC_LOCAL(const AtomicString, button, ("button", AtomicString::ConstructFromLiteral));
735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            return button;
745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        }
755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        case RESET: {
765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            DEFINE_STATIC_LOCAL(const AtomicString, reset, ("reset", AtomicString::ConstructFromLiteral));
775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            return reset;
785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        }
795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    }
805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    ASSERT_NOT_REACHED();
825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    return emptyAtom;
835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)bool HTMLButtonElement::isPresentationAttribute(const QualifiedName& name) const
865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    if (name == alignAttr) {
885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        // Don't map 'align' attribute.  This matches what Firefox and IE do, but not Opera.
895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        // See http://bugs.webkit.org/show_bug.cgi?id=12071
905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        return false;
915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    }
925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    return HTMLFormControlElement::isPresentationAttribute(name);
945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
96926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)void HTMLButtonElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
98926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    if (name == typeAttr) {
99926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        if (equalIgnoringCase(value, "reset"))
1005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            m_type = RESET;
101926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        else if (equalIgnoringCase(value, "button"))
1025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            m_type = BUTTON;
1035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        else
1045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            m_type = SUBMIT;
1055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        setNeedsWillValidateCheck();
1065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    } else
107926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        HTMLFormControlElement::parseAttribute(name, value);
1085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
1095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void HTMLButtonElement::defaultEventHandler(Event* event)
1115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
1121e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    if (event->type() == EventTypeNames::DOMActivate && !isDisabledFormControl()) {
1135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        if (form() && m_type == SUBMIT) {
1145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            m_isActivatedSubmit = true;
1155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            form()->prepareForSubmission(event);
1165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            event->setDefaultHandled();
1175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            m_isActivatedSubmit = false; // Do this in case submission was canceled.
1185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        }
1195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        if (form() && m_type == RESET) {
1205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            form()->reset();
1215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            event->setDefaultHandled();
1225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        }
1235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    }
1245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    if (event->isKeyboardEvent()) {
1261e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)        if (event->type() == EventTypeNames::keydown && toKeyboardEvent(event)->keyIdentifier() == "U+0020") {
12751b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)            setActive(true);
1285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            // No setDefaultHandled() - IE dispatches a keypress in this case.
1295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            return;
1305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        }
1311e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)        if (event->type() == EventTypeNames::keypress) {
132591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch            switch (toKeyboardEvent(event)->charCode()) {
1335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                case '\r':
1345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                    dispatchSimulatedClick(event);
1355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                    event->setDefaultHandled();
1365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                    return;
1375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                case ' ':
1385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                    // Prevent scrolling down the page.
1395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                    event->setDefaultHandled();
1405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                    return;
1415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            }
1425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        }
1431e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)        if (event->type() == EventTypeNames::keyup && toKeyboardEvent(event)->keyIdentifier() == "U+0020") {
1445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            if (active())
1455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)                dispatchSimulatedClick(event);
1465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            event->setDefaultHandled();
1475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)            return;
1485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        }
1495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    }
1505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    HTMLFormControlElement::defaultEventHandler(event);
1525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
1535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)bool HTMLButtonElement::willRespondToMouseClickEvents()
1555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
15653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    if (!isDisabledFormControl() && form() && (m_type == SUBMIT || m_type == RESET))
1575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        return true;
1585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    return HTMLFormControlElement::willRespondToMouseClickEvents();
1595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
1605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
16151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)bool HTMLButtonElement::canBeSuccessfulSubmitButton() const
1625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
16351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)    return m_type == SUBMIT;
1645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
1655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)bool HTMLButtonElement::isActivatedSubmit() const
1675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
1685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    return m_isActivatedSubmit;
1695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
1705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void HTMLButtonElement::setActivatedSubmit(bool flag)
1725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
1735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    m_isActivatedSubmit = flag;
1745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
1755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)bool HTMLButtonElement::appendFormData(FormDataList& formData, bool)
1775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
1785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    if (m_type != SUBMIT || name().isEmpty() || !m_isActivatedSubmit)
1795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        return false;
1805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    formData.appendData(name(), value());
1815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    return true;
1825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
1835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void HTMLButtonElement::accessKeyAction(bool sendMouseEvents)
1855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
1865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    focus();
187926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
188926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEvents);
1895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
1905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)bool HTMLButtonElement::isURLAttribute(const Attribute& attribute) const
1925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
1935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    return attribute.name() == formactionAttr || HTMLFormControlElement::isURLAttribute(attribute);
1945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
1955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
196a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)const AtomicString& HTMLButtonElement::value() const
1975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
1985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    return getAttribute(valueAttr);
1995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
2005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
2015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)bool HTMLButtonElement::recalcWillValidate() const
2025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles){
2035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    return m_type == SUBMIT && HTMLFormControlElement::recalcWillValidate();
2045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}
2055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
206bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)bool HTMLButtonElement::isInteractiveContent() const
207bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles){
208bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)    return true;
209bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)}
210bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)
21109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)bool HTMLButtonElement::supportsAutofocus() const
21209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles){
21309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    return true;
21409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
21509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
216197021e6b966cfb06891637935ef33fff06433d1Ben MurdochNode::InsertionNotificationRequest HTMLButtonElement::insertedInto(ContainerNode* insertionPoint)
217197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{
218197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    if (insertionPoint->inDocument()) {
219197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch        V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLoggerIfIsolatedWorld();
220197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch        if (activityLogger) {
221197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch            Vector<String> argv;
222197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch            argv.append("button");
223197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch            argv.append(fastGetAttribute(typeAttr));
224197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch            argv.append(fastGetAttribute(formmethodAttr));
225197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch            argv.append(fastGetAttribute(formactionAttr));
226197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch            activityLogger->logEvent("blinkAddElement", argv.size(), argv.data());
227197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch        }
228197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    }
229197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    return HTMLFormControlElement::insertedInto(insertionPoint);
230197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}
231197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
232197021e6b966cfb06891637935ef33fff06433d1Ben Murdochvoid HTMLButtonElement::attributeWillChange(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue)
233197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{
234197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    if (name == formactionAttr && inDocument()) {
235197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch        V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLoggerIfIsolatedWorld();
236197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch        if (activityLogger) {
237197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch            Vector<String> argv;
238197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch            argv.append("button");
239197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch            argv.append(formactionAttr.toString());
240197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch            argv.append(oldValue);
241197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch            argv.append(newValue);
242197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch            activityLogger->logEvent("blinkSetAttribute", argv.size(), argv.data());
243197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch        }
244197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    }
245197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch    HTMLFormControlElement::attributeWillChange(name, oldValue, newValue);
246197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}
247197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch
2485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} // namespace
249