зеркало из https://github.com/mozilla/pjs.git
Make some props absolute URIs resolved relative to other props (eg. codebase).
Bug 213701, patch by Florian Qu�ze <f.qu@queze.net>, r+sr=bzbarsky
This commit is contained in:
Родитель
ae8a224346
Коммит
1f454f5c02
|
@ -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<nsIURI> baseURI = GetBaseURI();
|
||||
nsresult rv;
|
||||
|
||||
if (aBaseAttr) {
|
||||
nsAutoString baseAttrValue;
|
||||
if (GetAttr(kNameSpaceID_None, aBaseAttr, baseAttrValue)) {
|
||||
nsCOMPtr<nsIURI> 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<nsIURI> 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;
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче