HTMLBaseElement.cpp [plain text]
#include "config.h"
#include "HTMLBaseElement.h"
#include "Attribute.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));
}
PassRefPtr<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);
}
KURL HTMLBaseElement::href() const
{
const AtomicString& attributeValue = fastGetAttribute(hrefAttr);
if (attributeValue.isNull())
return document()->url();
KURL url = !document()->decoder() ?
KURL(document()->url(), stripLeadingAndTrailingHTMLSpaces(attributeValue)) :
KURL(document()->url(), stripLeadingAndTrailingHTMLSpaces(attributeValue), document()->decoder()->encoding());
if (!url.isValid())
return KURL();
return url;
}
void HTMLBaseElement::setHref(const AtomicString& value)
{
setAttribute(hrefAttr, value);
}
}