diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
commit | 32761a6cee1d0dee366b885b7b9c777e67885688 (patch) | |
tree | d6bec92bebfb216f4126356e55518842c2f476a1 /Source/WebCore/html/HTMLButtonElement.cpp | |
parent | a4e969f4965059196ca948db781e52f7cfebf19e (diff) | |
download | WebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz |
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/WebCore/html/HTMLButtonElement.cpp')
-rw-r--r-- | Source/WebCore/html/HTMLButtonElement.cpp | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/Source/WebCore/html/HTMLButtonElement.cpp b/Source/WebCore/html/HTMLButtonElement.cpp index b3aa7aaa2..bceeef5e9 100644 --- a/Source/WebCore/html/HTMLButtonElement.cpp +++ b/Source/WebCore/html/HTMLButtonElement.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "HTMLButtonElement.h" +#include "Attribute.h" #include "EventNames.h" #include "FormDataList.h" #include "HTMLFormElement.h" @@ -46,9 +47,9 @@ inline HTMLButtonElement::HTMLButtonElement(const QualifiedName& tagName, Docume ASSERT(hasTagName(buttonTag)); } -Ref<HTMLButtonElement> HTMLButtonElement::create(const QualifiedName& tagName, Document& document, HTMLFormElement* form) +PassRefPtr<HTMLButtonElement> HTMLButtonElement::create(const QualifiedName& tagName, Document& document, HTMLFormElement* form) { - return adoptRef(*new HTMLButtonElement(tagName, document, form)); + return adoptRef(new HTMLButtonElement(tagName, document, form)); } void HTMLButtonElement::setType(const AtomicString& type) @@ -56,24 +57,24 @@ void HTMLButtonElement::setType(const AtomicString& type) setAttribute(typeAttr, type); } -RenderPtr<RenderElement> HTMLButtonElement::createElementRenderer(Ref<RenderStyle>&& style, const RenderTreePosition&) +RenderPtr<RenderElement> HTMLButtonElement::createElementRenderer(PassRef<RenderStyle> style) { - return createRenderer<RenderButton>(*this, WTFMove(style)); + return createRenderer<RenderButton>(*this, std::move(style)); } const AtomicString& HTMLButtonElement::formControlType() const { switch (m_type) { case SUBMIT: { - static NeverDestroyed<const AtomicString> submit("submit", AtomicString::ConstructFromLiteral); + DEFINE_STATIC_LOCAL(const AtomicString, submit, ("submit", AtomicString::ConstructFromLiteral)); return submit; } case BUTTON: { - static NeverDestroyed<const AtomicString> button("button", AtomicString::ConstructFromLiteral); + DEFINE_STATIC_LOCAL(const AtomicString, button, ("button", AtomicString::ConstructFromLiteral)); return button; } case RESET: { - static NeverDestroyed<const AtomicString> reset("reset", AtomicString::ConstructFromLiteral); + DEFINE_STATIC_LOCAL(const AtomicString, reset, ("reset", AtomicString::ConstructFromLiteral)); return reset; } } @@ -96,9 +97,9 @@ bool HTMLButtonElement::isPresentationAttribute(const QualifiedName& name) const void HTMLButtonElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { if (name == typeAttr) { - if (equalLettersIgnoringASCIICase(value, "reset")) + if (equalIgnoringCase(value, "reset")) m_type = RESET; - else if (equalLettersIgnoringASCIICase(value, "button")) + else if (equalIgnoringCase(value, "button")) m_type = BUTTON; else m_type = SUBMIT; @@ -122,29 +123,28 @@ void HTMLButtonElement::defaultEventHandler(Event* event) } } - if (is<KeyboardEvent>(*event)) { - KeyboardEvent& keyboardEvent = downcast<KeyboardEvent>(*event); - if (keyboardEvent.type() == eventNames().keydownEvent && keyboardEvent.keyIdentifier() == "U+0020") { + if (event->isKeyboardEvent()) { + if (event->type() == eventNames().keydownEvent && static_cast<KeyboardEvent*>(event)->keyIdentifier() == "U+0020") { setActive(true, true); // No setDefaultHandled() - IE dispatches a keypress in this case. return; } - if (keyboardEvent.type() == eventNames().keypressEvent) { - switch (keyboardEvent.charCode()) { + if (event->type() == eventNames().keypressEvent) { + switch (static_cast<KeyboardEvent*>(event)->charCode()) { case '\r': - dispatchSimulatedClick(&keyboardEvent); - keyboardEvent.setDefaultHandled(); + dispatchSimulatedClick(event); + event->setDefaultHandled(); return; case ' ': // Prevent scrolling down the page. - keyboardEvent.setDefaultHandled(); + event->setDefaultHandled(); return; } } - if (keyboardEvent.type() == eventNames().keyupEvent && keyboardEvent.keyIdentifier() == "U+0020") { + if (event->type() == eventNames().keyupEvent && static_cast<KeyboardEvent*>(event)->keyIdentifier() == "U+0020") { if (active()) - dispatchSimulatedClick(&keyboardEvent); - keyboardEvent.setDefaultHandled(); + dispatchSimulatedClick(event); + event->setDefaultHandled(); return; } } @@ -154,7 +154,9 @@ void HTMLButtonElement::defaultEventHandler(Event* event) bool HTMLButtonElement::willRespondToMouseClickEvents() { - return !isDisabledFormControl(); + if (!isDisabledFormControl() && form() && (m_type == SUBMIT || m_type == RESET)) + return true; + return HTMLFormControlElement::willRespondToMouseClickEvents(); } bool HTMLButtonElement::isSuccessfulSubmitButton() const @@ -194,14 +196,14 @@ bool HTMLButtonElement::isURLAttribute(const Attribute& attribute) const return attribute.name() == formactionAttr || HTMLFormControlElement::isURLAttribute(attribute); } -const AtomicString& HTMLButtonElement::value() const +String HTMLButtonElement::value() const { - return fastGetAttribute(valueAttr); + return getAttribute(valueAttr); } -bool HTMLButtonElement::computeWillValidate() const +bool HTMLButtonElement::recalcWillValidate() const { - return m_type == SUBMIT && HTMLFormControlElement::computeWillValidate(); + return m_type == SUBMIT && HTMLFormControlElement::recalcWillValidate(); } } // namespace |