This source file includes following definitions.
- isTextField
- isText
- isPasswordField
- isImageButton
- isRadioButton
- isCheckbox
- maxLength
- isActivatedSubmit
- setActivatedSubmit
- size
- setEditingValue
- isValidValue
- setChecked
- isChecked
- isMultiple
- dataListOptions
- localizeValue
- isSpeechInputEnabled
- speechButtonElement
- getSpeechInputState
- startSpeechInput
- stopSpeechInput
- defaultMaxLength
- decorationElementFor
- passwordGeneratorButtonElement
- setShouldRevealPassword
- toWebInputElement
#include "config.h"
#include "WebInputElement.h"
#include "HTMLNames.h"
#include "RuntimeEnabledFeatures.h"
#include "WebElementCollection.h"
#include "core/dom/shadow/ElementShadow.h"
#include "core/dom/shadow/ShadowRoot.h"
#include "core/html/HTMLDataListElement.h"
#include "core/html/HTMLInputElement.h"
#include "core/html/shadow/ShadowElementNames.h"
#include "core/html/shadow/TextControlInnerElements.h"
#include "public/platform/WebString.h"
#include "wtf/PassRefPtr.h"
using namespace WebCore;
namespace blink {
bool WebInputElement::isTextField() const
{
return constUnwrap<HTMLInputElement>()->isTextField();
}
bool WebInputElement::isText() const
{
return constUnwrap<HTMLInputElement>()->isText();
}
bool WebInputElement::isPasswordField() const
{
return constUnwrap<HTMLInputElement>()->isPasswordField();
}
bool WebInputElement::isImageButton() const
{
return constUnwrap<HTMLInputElement>()->isImageButton();
}
bool WebInputElement::isRadioButton() const
{
return constUnwrap<HTMLInputElement>()->isRadioButton();
}
bool WebInputElement::isCheckbox() const
{
return constUnwrap<HTMLInputElement>()->isCheckbox();
}
int WebInputElement::maxLength() const
{
return constUnwrap<HTMLInputElement>()->maxLength();
}
bool WebInputElement::isActivatedSubmit() const
{
return constUnwrap<HTMLInputElement>()->isActivatedSubmit();
}
void WebInputElement::setActivatedSubmit(bool activated)
{
unwrap<HTMLInputElement>()->setActivatedSubmit(activated);
}
int WebInputElement::size() const
{
return constUnwrap<HTMLInputElement>()->size();
}
void WebInputElement::setEditingValue(const WebString& value)
{
unwrap<HTMLInputElement>()->setEditingValue(value);
}
bool WebInputElement::isValidValue(const WebString& value) const
{
return constUnwrap<HTMLInputElement>()->isValidValue(value);
}
void WebInputElement::setChecked(bool nowChecked, bool sendEvents)
{
unwrap<HTMLInputElement>()->setChecked(nowChecked, sendEvents ? DispatchInputAndChangeEvent : DispatchNoEvent);
}
bool WebInputElement::isChecked() const
{
return constUnwrap<HTMLInputElement>()->checked();
}
bool WebInputElement::isMultiple() const
{
return constUnwrap<HTMLInputElement>()->multiple();
}
WebElementCollection WebInputElement::dataListOptions() const
{
if (HTMLDataListElement* dataList = toHTMLDataListElement(constUnwrap<HTMLInputElement>()->list()))
return WebElementCollection(dataList->options());
return WebElementCollection();
}
WebString WebInputElement::localizeValue(const WebString& proposedValue) const
{
return constUnwrap<HTMLInputElement>()->localizeValue(proposedValue);
}
bool WebInputElement::isSpeechInputEnabled() const
{
#if ENABLE(INPUT_SPEECH)
return constUnwrap<HTMLInputElement>()->isSpeechEnabled();
#else
return false;
#endif
}
#if ENABLE(INPUT_SPEECH)
static inline InputFieldSpeechButtonElement* speechButtonElement(const WebInputElement* webInput)
{
return toInputFieldSpeechButtonElement(webInput->constUnwrap<HTMLInputElement>()->userAgentShadowRoot()->getElementById(ShadowElementNames::speechButton()));
}
#endif
WebInputElement::SpeechInputState WebInputElement::getSpeechInputState() const
{
#if ENABLE(INPUT_SPEECH)
if (InputFieldSpeechButtonElement* speechButton = speechButtonElement(this))
return static_cast<WebInputElement::SpeechInputState>(speechButton->state());
#endif
return Idle;
}
void WebInputElement::startSpeechInput()
{
#if ENABLE(INPUT_SPEECH)
if (InputFieldSpeechButtonElement* speechButton = speechButtonElement(this))
speechButton->startSpeechInput();
#endif
}
void WebInputElement::stopSpeechInput()
{
#if ENABLE(INPUT_SPEECH)
if (InputFieldSpeechButtonElement* speechButton = speechButtonElement(this))
speechButton->stopSpeechInput();
#endif
}
int WebInputElement::defaultMaxLength()
{
return HTMLInputElement::maximumLength;
}
WebElement WebInputElement::decorationElementFor(void*)
{
return passwordGeneratorButtonElement();
}
WebElement WebInputElement::passwordGeneratorButtonElement() const
{
return WebElement(constUnwrap<HTMLInputElement>()->passwordGeneratorButtonElement());
}
void WebInputElement::setShouldRevealPassword(bool value)
{
unwrap<HTMLInputElement>()->setShouldRevealPassword(value);
}
WebInputElement::WebInputElement(const PassRefPtr<HTMLInputElement>& elem)
: WebFormControlElement(elem)
{
}
WebInputElement& WebInputElement::operator=(const PassRefPtr<HTMLInputElement>& elem)
{
m_private = elem;
return *this;
}
WebInputElement::operator PassRefPtr<HTMLInputElement>() const
{
return toHTMLInputElement(m_private.get());
}
WebInputElement* toWebInputElement(WebElement* webElement)
{
if (!isHTMLInputElement(*webElement->unwrap<Element>()))
return 0;
return static_cast<WebInputElement*>(webElement);
}
}