This source file includes following definitions.
- create
- parseAttribute
- insertedInto
- removedFrom
- isURLAttribute
- href
- setHref
#include "config.h"
#include "core/html/HTMLBaseElement.h"
#include "HTMLNames.h"
#include "core/dom/Attribute.h"
#include "core/dom/Document.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "core/html/parser/TextResourceDecoder.h"
namespace WebCore {
using namespace HTMLNames;
inline HTMLBaseElement::HTMLBaseElement(Document& document)
: HTMLElement(baseTag, document)
{
ScriptWrappable::init(this);
}
PassRefPtr<HTMLBaseElement> HTMLBaseElement::create(Document& document)
{
return adoptRef(new HTMLBaseElement(document));
}
void HTMLBaseElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == hrefAttr || name == targetAttr)
document().processBaseElement();
else
HTMLElement::parseAttribute(name, value);
}
Node::InsertionNotificationRequest HTMLBaseElement::insertedInto(ContainerNode* insertionPoint)
{
HTMLElement::insertedInto(insertionPoint);
if (insertionPoint->inDocument())
document().processBaseElement();
return InsertionDone;
}
void HTMLBaseElement::removedFrom(ContainerNode* insertionPoint)
{
HTMLElement::removedFrom(insertionPoint);
if (insertionPoint->inDocument())
document().processBaseElement();
}
bool HTMLBaseElement::isURLAttribute(const Attribute& attribute) const
{
return attribute.name().localName() == hrefAttr || HTMLElement::isURLAttribute(attribute);
}
KURL HTMLBaseElement::href() const
{
const AtomicString& attributeValue = fastGetAttribute(hrefAttr);
if (attributeValue.isNull())
return document().url();
KURL url = document().encoding().isValid() ?
KURL(document().url(), stripLeadingAndTrailingHTMLSpaces(attributeValue)) :
KURL(document().url(), stripLeadingAndTrailingHTMLSpaces(attributeValue), document().encoding());
if (!url.isValid())
return KURL();
return url;
}
void HTMLBaseElement::setHref(const AtomicString& value)
{
setAttribute(hrefAttr, value);
}
}