HTMLOutputElement.cpp [plain text]
#include "config.h"
#include "HTMLOutputElement.h"
#include "ExceptionCodePlaceholder.h"
#include "HTMLFormElement.h"
#include "HTMLNames.h"
namespace WebCore {
inline HTMLOutputElement::HTMLOutputElement(const QualifiedName& tagName, Document& document, HTMLFormElement* form)
: HTMLFormControlElement(tagName, document, form)
, m_isDefaultValueMode(true)
, m_isSetTextContentInProgress(false)
, m_defaultValue("")
, m_tokens(DOMSettableTokenList::create())
{
}
PassRefPtr<HTMLOutputElement> HTMLOutputElement::create(const QualifiedName& tagName, Document& document, HTMLFormElement* form)
{
return adoptRef(new HTMLOutputElement(tagName, document, form));
}
const AtomicString& HTMLOutputElement::formControlType() const
{
DEPRECATED_DEFINE_STATIC_LOCAL(const AtomicString, output, ("output", AtomicString::ConstructFromLiteral));
return output;
}
bool HTMLOutputElement::supportsFocus() const
{
return HTMLElement::supportsFocus();
}
void HTMLOutputElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == HTMLNames::forAttr)
setFor(value);
else
HTMLFormControlElement::parseAttribute(name, value);
}
DOMSettableTokenList* HTMLOutputElement::htmlFor() const
{
return m_tokens.get();
}
void HTMLOutputElement::setFor(const String& value)
{
m_tokens->setValue(value);
}
void HTMLOutputElement::childrenChanged(const ChildChange& change)
{
HTMLFormControlElement::childrenChanged(change);
if (change.source == ChildChangeSourceParser || m_isSetTextContentInProgress) {
m_isSetTextContentInProgress = false;
return;
}
if (m_isDefaultValueMode)
m_defaultValue = textContent();
}
void HTMLOutputElement::reset()
{
m_isDefaultValueMode = true;
if (m_defaultValue == value())
return;
setTextContentInternal(m_defaultValue);
}
String HTMLOutputElement::value() const
{
return textContent();
}
void HTMLOutputElement::setValue(const String& value)
{
m_isDefaultValueMode = false;
if (value == this->value())
return;
setTextContentInternal(value);
}
String HTMLOutputElement::defaultValue() const
{
return m_defaultValue;
}
void HTMLOutputElement::setDefaultValue(const String& value)
{
if (m_defaultValue == value)
return;
m_defaultValue = value;
if (m_isDefaultValueMode)
setTextContentInternal(value);
}
void HTMLOutputElement::setTextContentInternal(const String& value)
{
ASSERT(!m_isSetTextContentInProgress);
m_isSetTextContentInProgress = true;
setTextContent(value, IGNORE_EXCEPTION);
}
}