diff options
Diffstat (limited to 'Source/WebCore/html/HTMLBaseElement.cpp')
-rw-r--r-- | Source/WebCore/html/HTMLBaseElement.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Source/WebCore/html/HTMLBaseElement.cpp b/Source/WebCore/html/HTMLBaseElement.cpp index 2754717c0..b58035e99 100644 --- a/Source/WebCore/html/HTMLBaseElement.cpp +++ b/Source/WebCore/html/HTMLBaseElement.cpp @@ -26,6 +26,8 @@ #include "Attribute.h" #include "Document.h" #include "HTMLNames.h" +#include "HTMLParserIdioms.h" +#include "TextResourceDecoder.h" namespace WebCore { @@ -75,4 +77,29 @@ String HTMLBaseElement::target() const return fastGetAttribute(targetAttr); } +KURL HTMLBaseElement::href() const +{ + // This does not use the getURLAttribute function because that will resolve relative to the document's base URL; + // base elements like this one can be used to set that base URL. Thus we need to resolve relative to the document's + // URL and ignore the base URL. + + 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); +} + } |