This source file includes following definitions.
- didAddUserAgentShadowRoot
- parseAttribute
- appendFormData
- formControlType
- resetImpl
- shadowSelect
- isInteractiveContent
- supportsAutofocus
#include "config.h"
#include "core/html/HTMLKeygenElement.h"
#include "HTMLNames.h"
#include "bindings/v8/ExceptionStatePlaceholder.h"
#include "core/dom/Document.h"
#include "core/dom/Text.h"
#include "core/dom/shadow/ShadowRoot.h"
#include "core/html/FormDataList.h"
#include "core/html/HTMLOptionElement.h"
#include "core/html/HTMLSelectElement.h"
#include "platform/SSLKeyGenerator.h"
#include "wtf/StdLibExtras.h"
using namespace WebCore;
namespace WebCore {
using namespace HTMLNames;
HTMLKeygenElement::HTMLKeygenElement(Document& document, HTMLFormElement* form)
: HTMLFormControlElementWithState(keygenTag, document, form)
{
ScriptWrappable::init(this);
ensureUserAgentShadowRoot();
}
void HTMLKeygenElement::didAddUserAgentShadowRoot(ShadowRoot& root)
{
DEFINE_STATIC_LOCAL(AtomicString, keygenSelectPseudoId, ("-webkit-keygen-select", AtomicString::ConstructFromLiteral));
Vector<String> keys;
getSupportedKeySizes(locale(), keys);
RefPtr<HTMLSelectElement> select = HTMLSelectElement::create(document());
select->setShadowPseudoId(keygenSelectPseudoId);
for (size_t i = 0; i < keys.size(); ++i) {
RefPtr<HTMLOptionElement> option = HTMLOptionElement::create(document());
option->appendChild(Text::create(document(), keys[i]));
select->appendChild(option);
}
root.appendChild(select);
}
void HTMLKeygenElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == disabledAttr)
shadowSelect()->setAttribute(name, value);
HTMLFormControlElement::parseAttribute(name, value);
}
bool HTMLKeygenElement::appendFormData(FormDataList& encoding, bool)
{
const AtomicString& keyType = fastGetAttribute(keytypeAttr);
if (!keyType.isNull() && !equalIgnoringCase(keyType, "rsa"))
return false;
String value = signedPublicKeyAndChallengeString(shadowSelect()->selectedIndex(), fastGetAttribute(challengeAttr), document().baseURL());
if (value.isNull())
return false;
encoding.appendData(name(), value.utf8());
return true;
}
const AtomicString& HTMLKeygenElement::formControlType() const
{
DEFINE_STATIC_LOCAL(const AtomicString, keygen, ("keygen", AtomicString::ConstructFromLiteral));
return keygen;
}
void HTMLKeygenElement::resetImpl()
{
shadowSelect()->reset();
}
HTMLSelectElement* HTMLKeygenElement::shadowSelect() const
{
ShadowRoot* root = userAgentShadowRoot();
return root ? toHTMLSelectElement(root->firstChild()) : 0;
}
bool HTMLKeygenElement::isInteractiveContent() const
{
return true;
}
bool HTMLKeygenElement::supportsAutofocus() const
{
return true;
}
}