This source file includes following definitions.
- create
- validationMessageClient
- updateValidationMessage
- requestToHideMessage
- isVisible
#include "config.h"
#include "core/html/forms/ValidationMessage.h"
#include "core/html/HTMLFormControlElement.h"
#include "core/page/Page.h"
#include "core/page/ValidationMessageClient.h"
#include "wtf/PassOwnPtr.h"
namespace WebCore {
ALWAYS_INLINE ValidationMessage::ValidationMessage(HTMLFormControlElement* element)
: m_element(element)
{
ASSERT(m_element);
}
ValidationMessage::~ValidationMessage()
{
if (ValidationMessageClient* client = validationMessageClient())
client->hideValidationMessage(*m_element);
}
PassOwnPtr<ValidationMessage> ValidationMessage::create(HTMLFormControlElement* element)
{
return adoptPtr(new ValidationMessage(element));
}
ValidationMessageClient* ValidationMessage::validationMessageClient() const
{
Page* page = m_element->document().page();
if (!page)
return 0;
ASSERT(page->validationMessageClient());
return page->validationMessageClient();
}
void ValidationMessage::updateValidationMessage(const String& message)
{
ValidationMessageClient* client = validationMessageClient();
if (!client)
return;
if (message.isEmpty())
requestToHideMessage();
else
client->showValidationMessage(*m_element, message);
}
void ValidationMessage::requestToHideMessage()
{
if (ValidationMessageClient* client = validationMessageClient())
client->hideValidationMessage(*m_element);
}
bool ValidationMessage::isVisible() const
{
if (ValidationMessageClient* client = validationMessageClient())
return client->isValidationMessageVisible(*m_element);
return false;
}
}