diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index d2edcdd59b9..38f8dc0e8d9 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -2811,7 +2811,7 @@ nsGenericHTMLElement::SetIntAttr(nsIAtom* aAttr, PRInt32 aValue) } nsresult -nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsAString& aResult) +nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsIAtom* aBaseAttr, nsAString& aResult) { nsAutoString attrValue; if (!GetAttr(kNameSpaceID_None, aAttr, attrValue)) { @@ -2821,11 +2821,29 @@ nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsAString& aResult) } nsCOMPtr baseURI = GetBaseURI(); + nsresult rv; + + if (aBaseAttr) { + nsAutoString baseAttrValue; + if (GetAttr(kNameSpaceID_None, aBaseAttr, baseAttrValue)) { + nsCOMPtr baseAttrURI; + rv = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(baseAttrURI), + baseAttrValue, GetOwnerDoc(), + baseURI); + if (NS_FAILED(rv)) { + // Just use the attr value as the result... + aResult = attrValue; + + return NS_OK; + } + baseURI.swap(baseAttrURI); + } + } + nsCOMPtr attrURI; - nsresult rv = - nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(attrURI), - attrValue, GetOwnerDoc(), - baseURI); + rv = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(attrURI), + attrValue, GetOwnerDoc(), + baseURI); if (NS_FAILED(rv)) { // Just use the attr value as the result... aResult = attrValue; diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index f4323853aa5..d587ffd4790 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -718,10 +718,11 @@ protected: * isn't a relative URI the value of the attribute is returned as is. Only * works for attributes in null namespace. * - * @param aAttr name of attribute. - * @param aResult result value [out] + * @param aAttr name of attribute. + * @param aBaseAttr name of base attribute. + * @param aResult result value [out] */ - NS_HIDDEN_(nsresult) GetURIAttr(nsIAtom* aAttr, nsAString& aResult); + NS_HIDDEN_(nsresult) GetURIAttr(nsIAtom* aAttr, nsIAtom* aBaseAttr, nsAString& aResult); /** * This method works like GetURIAttr, except that it supports multiple @@ -982,7 +983,7 @@ NS_NewHTML##_elementName##Element(nsINodeInfo *aNodeInfo, PRBool aFromParser)\ NS_IMETHODIMP \ _class::Get##_method(nsAString& aValue) \ { \ - return GetURIAttr(nsHTMLAtoms::_atom, aValue); \ + return GetURIAttr(nsHTMLAtoms::_atom, nsnull, aValue); \ } \ NS_IMETHODIMP \ _class::Set##_method(const nsAString& aValue) \ @@ -990,6 +991,18 @@ NS_NewHTML##_elementName##Element(nsINodeInfo *aNodeInfo, PRBool aFromParser)\ return SetAttrHelper(nsHTMLAtoms::_atom, aValue); \ } +#define NS_IMPL_URI_ATTR_WITH_BASE(_class, _method, _atom, _base_atom) \ + NS_IMETHODIMP \ + _class::Get##_method(nsAString& aValue) \ + { \ + return GetURIAttr(nsHTMLAtoms::_atom, nsHTMLAtoms::_base_atom, aValue); \ + } \ + NS_IMETHODIMP \ + _class::Set##_method(const nsAString& aValue) \ + { \ + return SetAttrHelper(nsHTMLAtoms::_atom, aValue); \ + } + /** * QueryInterface() implementation helper macros */ diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp index 977b91bdd35..02dc6775e22 100644 --- a/content/html/content/src/nsHTMLFormElement.cpp +++ b/content/html/content/src/nsHTMLFormElement.cpp @@ -595,7 +595,7 @@ nsHTMLFormElement::GetAction(nsAString& aValue) // Avoid resolving action="" to the base uri, bug 297761. return NS_OK; } - return GetURIAttr(nsHTMLAtoms::action, aValue); + return GetURIAttr(nsHTMLAtoms::action, nsnull, aValue); } NS_IMETHODIMP diff --git a/content/html/content/src/nsHTMLObjectElement.cpp b/content/html/content/src/nsHTMLObjectElement.cpp index e40e95900bb..2189b0b1732 100644 --- a/content/html/content/src/nsHTMLObjectElement.cpp +++ b/content/html/content/src/nsHTMLObjectElement.cpp @@ -307,10 +307,10 @@ nsHTMLObjectElement::SubmitNamesValues(nsIFormSubmission *aFormSubmission, NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Align, align) NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Archive, archive) NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Border, border) -NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Code, code) +NS_IMPL_URI_ATTR_WITH_BASE(nsHTMLObjectElement, Code, code, codebase) NS_IMPL_URI_ATTR(nsHTMLObjectElement, CodeBase, codebase) NS_IMPL_STRING_ATTR(nsHTMLObjectElement, CodeType, codetype) -NS_IMPL_URI_ATTR(nsHTMLObjectElement, Data, data) +NS_IMPL_URI_ATTR_WITH_BASE(nsHTMLObjectElement, Data, data, codebase) NS_IMPL_BOOL_ATTR(nsHTMLObjectElement, Declare, declare) NS_IMPL_STRING_ATTR(nsHTMLObjectElement, Height, height) NS_IMPL_INT_ATTR(nsHTMLObjectElement, Hspace, hspace) diff --git a/content/html/content/src/nsHTMLSharedObjectElement.cpp b/content/html/content/src/nsHTMLSharedObjectElement.cpp index 3ddcd39417c..f94e05e9fdd 100644 --- a/content/html/content/src/nsHTMLSharedObjectElement.cpp +++ b/content/html/content/src/nsHTMLSharedObjectElement.cpp @@ -302,13 +302,13 @@ nsHTMLSharedObjectElement::GetDesiredIMEState() NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Align, align) NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Alt, alt) NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Archive, archive) -NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Code, code) +NS_IMPL_URI_ATTR_WITH_BASE(nsHTMLSharedObjectElement, Code, code, codebase) NS_IMPL_URI_ATTR(nsHTMLSharedObjectElement, CodeBase, codebase) NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Height, height) NS_IMPL_INT_ATTR(nsHTMLSharedObjectElement, Hspace, hspace) NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Name, name) -NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Object, object) -NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Src, src) +NS_IMPL_URI_ATTR_WITH_BASE(nsHTMLSharedObjectElement, Object, object, codebase) +NS_IMPL_URI_ATTR(nsHTMLSharedObjectElement, Src, src) NS_IMPL_INT_ATTR(nsHTMLSharedObjectElement, TabIndex, tabindex) NS_IMPL_STRING_ATTR(nsHTMLSharedObjectElement, Type, type) NS_IMPL_INT_ATTR(nsHTMLSharedObjectElement, Vspace, vspace)