HTMLBaseElement.cpp [plain text]
#include "config.h"
#include "HTMLBaseElement.h"
#include "Document.h"
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
#include "TextResourceDecoder.h"
#include <wtf/IsoMallocInlines.h>
namespace WebCore {
WTF_MAKE_ISO_ALLOCATED_IMPL(HTMLBaseElement);
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::InsertedIntoAncestorResult HTMLBaseElement::insertedIntoAncestor(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
{
HTMLElement::insertedIntoAncestor(insertionType, parentOfInsertedTree);
if (insertionType.connectedToDocument)
document().processBaseElement();
return InsertedIntoAncestorResult::Done;
}
void HTMLBaseElement::removedFromAncestor(RemovalType removalType, ContainerNode& oldParentOfRemovedTree)
{
HTMLElement::removedFromAncestor(removalType, oldParentOfRemovedTree);
if (removalType.disconnectedFromDocument)
document().processBaseElement();
}
bool HTMLBaseElement::isURLAttribute(const Attribute& attribute) const
{
return attribute.name().localName() == hrefAttr || HTMLElement::isURLAttribute(attribute);
}
String HTMLBaseElement::target() const
{
return attributeWithoutSynchronization(targetAttr);
}
URL HTMLBaseElement::href() const
{
const AtomicString& attributeValue = attributeWithoutSynchronization(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)
{
setAttributeWithoutSynchronization(hrefAttr, value);
}
}