HTMLBaseElement.cpp [plain text]
#include "config.h"
#include "HTMLBaseElement.h"
#include "Document.h"
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
#include "TextResourceDecoder.h"
namespace WebCore {
using namespace HTMLNames;
inline HTMLBaseElement::HTMLBaseElement(const QualifiedName& tagName, Document& document)
: HTMLElement(tagName, document)
{
ASSERT(hasTagName(baseTag));
}
Ref<HTMLBaseElement> HTMLBaseElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(*new HTMLBaseElement(tagName, 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);
}
String HTMLBaseElement::target() const
{
return fastGetAttribute(targetAttr);
}
URL HTMLBaseElement::href() const
{
const AtomicString& attributeValue = fastGetAttribute(hrefAttr);
if (attributeValue.isNull())
return document().url();
URL url = !document().decoder() ?
URL(document().url(), stripLeadingAndTrailingHTMLSpaces(attributeValue)) :
URL(document().url(), stripLeadingAndTrailingHTMLSpaces(attributeValue), document().decoder()->encoding());
if (!url.isValid())
return URL();
return url;
}
void HTMLBaseElement::setHref(const AtomicString& value)
{
setAttribute(hrefAttr, value);
}
}