diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/html/HTMLKeygenElement.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/html/HTMLKeygenElement.cpp')
-rw-r--r-- | Source/WebCore/html/HTMLKeygenElement.cpp | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/Source/WebCore/html/HTMLKeygenElement.cpp b/Source/WebCore/html/HTMLKeygenElement.cpp index 401de1c95..3758ae380 100644 --- a/Source/WebCore/html/HTMLKeygenElement.cpp +++ b/Source/WebCore/html/HTMLKeygenElement.cpp @@ -2,7 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2004-2006, 2010, 2012-2016 Apple Inc. All rights reserved. * (C) 2006 Alexey Proskuryakov (ap@nypop.com) * * This library is free software; you can redistribute it and/or @@ -27,6 +27,7 @@ #include "Attribute.h" #include "Document.h" +#include "ElementChildIterator.h" #include "FormDataList.h" #include "HTMLNames.h" #include "HTMLSelectElement.h" @@ -34,6 +35,7 @@ #include "SSLKeyGenerator.h" #include "ShadowRoot.h" #include "Text.h" +#include <wtf/NeverDestroyed.h> #include <wtf/StdLibExtras.h> using namespace WebCore; @@ -44,23 +46,23 @@ using namespace HTMLNames; class KeygenSelectElement final : public HTMLSelectElement { public: - static PassRefPtr<KeygenSelectElement> create(Document& document) + static Ref<KeygenSelectElement> create(Document& document) { - return adoptRef(new KeygenSelectElement(document)); + return adoptRef(*new KeygenSelectElement(document)); } protected: KeygenSelectElement(Document& document) : HTMLSelectElement(selectTag, document, 0) { - DEFINE_STATIC_LOCAL(AtomicString, pseudoId, ("-webkit-keygen-select", AtomicString::ConstructFromLiteral)); + static NeverDestroyed<AtomicString> pseudoId("-webkit-keygen-select", AtomicString::ConstructFromLiteral); setPseudo(pseudoId); } private: - virtual PassRefPtr<Element> cloneElementWithoutAttributesAndChildren() override + Ref<Element> cloneElementWithoutAttributesAndChildren(Document& targetDocument) override { - return create(document()); + return create(targetDocument); } }; @@ -73,19 +75,19 @@ inline HTMLKeygenElement::HTMLKeygenElement(const QualifiedName& tagName, Docume Vector<String> keys; getSupportedKeySizes(keys); - RefPtr<HTMLSelectElement> select = KeygenSelectElement::create(document); - for (size_t i = 0; i < keys.size(); ++i) { - RefPtr<HTMLOptionElement> option = HTMLOptionElement::create(document); - select->appendChild(option, IGNORE_EXCEPTION); - option->appendChild(Text::create(document, keys[i]), IGNORE_EXCEPTION); + auto select = KeygenSelectElement::create(document); + for (auto& key : keys) { + auto option = HTMLOptionElement::create(document); + select->appendChild(option); + option->appendChild(Text::create(document, key)); } - ensureUserAgentShadowRoot().appendChild(select, IGNORE_EXCEPTION); + ensureUserAgentShadowRoot().appendChild(select); } -PassRefPtr<HTMLKeygenElement> HTMLKeygenElement::create(const QualifiedName& tagName, Document& document, HTMLFormElement* form) +Ref<HTMLKeygenElement> HTMLKeygenElement::create(const QualifiedName& tagName, Document& document, HTMLFormElement* form) { - return adoptRef(new HTMLKeygenElement(tagName, document, form)); + return adoptRef(*new HTMLKeygenElement(tagName, document, form)); } void HTMLKeygenElement::parseAttribute(const QualifiedName& name, const AtomicString& value) @@ -97,13 +99,28 @@ void HTMLKeygenElement::parseAttribute(const QualifiedName& name, const AtomicSt HTMLFormControlElement::parseAttribute(name, value); } +bool HTMLKeygenElement::isKeytypeRSA() const +{ + const auto& keyType = attributeWithoutSynchronization(keytypeAttr); + return keyType.isNull() || equalLettersIgnoringASCIICase(keyType, "rsa"); +} + +void HTMLKeygenElement::setKeytype(const AtomicString& value) +{ + setAttributeWithoutSynchronization(keytypeAttr, value); +} + +String HTMLKeygenElement::keytype() const +{ + return isKeytypeRSA() ? ASCIILiteral("rsa") : emptyString(); +} + bool HTMLKeygenElement::appendFormData(FormDataList& encoded_values, bool) { // Only RSA is supported at this time. - const AtomicString& keyType = fastGetAttribute(keytypeAttr); - if (!keyType.isNull() && !equalIgnoringCase(keyType, "rsa")) + if (!isKeytypeRSA()) return false; - String value = signedPublicKeyAndChallengeString(shadowSelect()->selectedIndex(), fastGetAttribute(challengeAttr), document().baseURL()); + String value = signedPublicKeyAndChallengeString(shadowSelect()->selectedIndex(), attributeWithoutSynchronization(challengeAttr), document().baseURL()); if (value.isNull()) return false; encoded_values.appendData(name(), value.utf8()); @@ -112,7 +129,7 @@ bool HTMLKeygenElement::appendFormData(FormDataList& encoded_values, bool) const AtomicString& HTMLKeygenElement::formControlType() const { - DEFINE_STATIC_LOCAL(const AtomicString, keygen, ("keygen", AtomicString::ConstructFromLiteral)); + static NeverDestroyed<const AtomicString> keygen("keygen", AtomicString::ConstructFromLiteral); return keygen; } @@ -129,7 +146,10 @@ bool HTMLKeygenElement::shouldSaveAndRestoreFormControlState() const HTMLSelectElement* HTMLKeygenElement::shadowSelect() const { ShadowRoot* root = userAgentShadowRoot(); - return root ? toHTMLSelectElement(root->firstChild()) : 0; + if (!root) + return nullptr; + + return childrenOfType<HTMLSelectElement>(*root).first(); } } // namespace |