WebInputElement.cpp [plain text]
#include "config.h"
#include "WebInputElement.h"
#include "HTMLDataListElement.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "TextControlInnerElements.h"
#include "WebNodeCollection.h"
#include "platform/WebString.h"
#include <wtf/PassRefPtr.h>
using namespace WebCore;
namespace WebKit {
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::autoComplete() const
{
return constUnwrap<HTMLInputElement>()->shouldAutocomplete();
}
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::setValue(const WebString& value, bool sendChangeEvent)
{
unwrap<HTMLInputElement>()->setValue(value, sendChangeEvent ? DispatchChangeEvent : DispatchNoEvent);
}
WebString WebInputElement::value() const
{
return constUnwrap<HTMLInputElement>()->value();
}
void WebInputElement::setSuggestedValue(const WebString& value)
{
unwrap<HTMLInputElement>()->setSuggestedValue(value);
}
WebString WebInputElement::suggestedValue() const
{
return constUnwrap<HTMLInputElement>()->suggestedValue();
}
void WebInputElement::setPlaceholder(const WebString& value)
{
unwrap<HTMLInputElement>()->setPlaceholder(value);
}
WebString WebInputElement::placeholder() const
{
return constUnwrap<HTMLInputElement>()->placeholder();
}
bool WebInputElement::isAutofilled() const
{
return constUnwrap<HTMLInputElement>()->isAutofilled();
}
void WebInputElement::setAutofilled(bool autofilled)
{
unwrap<HTMLInputElement>()->setAutofilled(autofilled);
}
void WebInputElement::setSelectionRange(int start, int end)
{
unwrap<HTMLInputElement>()->setSelectionRange(start, end);
}
int WebInputElement::selectionStart() const
{
return constUnwrap<HTMLInputElement>()->selectionStart();
}
int WebInputElement::selectionEnd() const
{
return constUnwrap<HTMLInputElement>()->selectionEnd();
}
bool WebInputElement::isValidValue(const WebString& value) const
{
return constUnwrap<HTMLInputElement>()->isValidValue(value);
}
bool WebInputElement::isChecked() const
{
return constUnwrap<HTMLInputElement>()->checked();
}
WebNodeCollection WebInputElement::dataListOptions() const
{
#if ENABLE(DATALIST)
HTMLDataListElement* dataList = static_cast<HTMLDataListElement*>(constUnwrap<HTMLInputElement>()->list());
if (dataList)
return WebNodeCollection(dataList->options());
#endif
return WebNodeCollection();
}
bool WebInputElement::isSpeechInputEnabled() const
{
#if ENABLE(INPUT_SPEECH)
return constUnwrap<HTMLInputElement>()->isSpeechEnabled();
#else
return false;
#endif
}
WebInputElement::SpeechInputState WebInputElement::getSpeechInputState() const
{
#if ENABLE(INPUT_SPEECH)
InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(constUnwrap<HTMLInputElement>()->speechButtonElement());
if (speechButton)
return static_cast<WebInputElement::SpeechInputState>(speechButton->state());
#endif
return Idle;
}
void WebInputElement::startSpeechInput()
{
#if ENABLE(INPUT_SPEECH)
InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(constUnwrap<HTMLInputElement>()->speechButtonElement());
if (speechButton)
speechButton->startSpeechInput();
#endif
}
void WebInputElement::stopSpeechInput()
{
#if ENABLE(INPUT_SPEECH)
InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(constUnwrap<HTMLInputElement>()->speechButtonElement());
if (speechButton)
speechButton->stopSpeechInput();
#endif
}
int WebInputElement::defaultMaxLength()
{
return HTMLInputElement::maximumLength;
}
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 static_cast<HTMLInputElement*>(m_private.get());
}
WebInputElement* toWebInputElement(WebElement* webElement)
{
HTMLInputElement* inputElement = webElement->unwrap<Element>()->toInputElement();
if (!inputElement)
return 0;
return static_cast<WebInputElement*>(webElement);
}
}