зеркало из https://github.com/mozilla/gecko-dev.git
Bug 448938 - Fix relative URIs in image filters and make href processing more consistent. r+sr=roc
This commit is contained in:
Родитель
059983533d
Коммит
06d962c3ea
|
@ -256,12 +256,8 @@ nsSVGAElement::IsLink(nsIURI** aURI) const
|
|||
nsIContent::ATTR_VALUE_NO_MATCH) {
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
// Get absolute URI
|
||||
// XXX: should really be using href->GetStringValue(), but nsSVGElement::
|
||||
// ParseAttribute has set the nsAttrValue type to eSVGValue, so we need
|
||||
// to use the more expensive ToString (generates, rather than fetches).
|
||||
nsAutoString hrefStr;
|
||||
href->ToString(hrefStr);
|
||||
nsContentUtils::NewURIWithDocumentCharset(aURI, hrefStr,
|
||||
nsContentUtils::NewURIWithDocumentCharset(aURI,
|
||||
mStringAttributes[HREF].GetAnimValue(),
|
||||
GetOwnerDoc(), baseURI);
|
||||
// must promise out param is non-null if we return true
|
||||
return !!*aURI;
|
||||
|
@ -274,7 +270,7 @@ nsSVGAElement::IsLink(nsIURI** aURI) const
|
|||
void
|
||||
nsSVGAElement::GetLinkTarget(nsAString& aTarget)
|
||||
{
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::target, aTarget);
|
||||
aTarget = mStringAttributes[TARGET].GetAnimValue();
|
||||
if (aTarget.IsEmpty()) {
|
||||
|
||||
static nsIContent::AttrValuesArray sShowVals[] =
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include "imgIContainer.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "nsIImage.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsSVGAnimatedPreserveAspectRatio.h"
|
||||
#include "nsSVGPreserveAspectRatio.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
|
@ -5194,10 +5195,11 @@ public:
|
|||
NS_FORWARD_NSIDOMNODE(nsSVGFEImageElementBase::)
|
||||
NS_FORWARD_NSIDOMELEMENT(nsSVGFEImageElementBase::)
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
// nsSVGElement
|
||||
virtual void DidChangeString(PRUint8 aAttrEnum, PRBool aDoSetAttr);
|
||||
|
||||
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
|
||||
const nsAString* aValue, PRBool aNotify);
|
||||
// nsIContent
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
|
@ -5218,6 +5220,8 @@ private:
|
|||
// Invalidate users of the filter containing this element.
|
||||
void Invalidate();
|
||||
|
||||
nsresult LoadSVGImage(PRBool aForce, PRBool aNotify);
|
||||
|
||||
protected:
|
||||
virtual PRBool OperatesOnSRGB(nsSVGFilterInstance*,
|
||||
PRUint32, Image*) { return PR_TRUE; }
|
||||
|
@ -5293,25 +5297,25 @@ nsSVGFEImageElement::Init()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIContent methods:
|
||||
|
||||
nsresult
|
||||
nsSVGFEImageElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
|
||||
const nsAString* aValue, PRBool aNotify)
|
||||
nsSVGFEImageElement::LoadSVGImage(PRBool aForce, PRBool aNotify)
|
||||
{
|
||||
if (aNamespaceID == kNameSpaceID_XLink && aName == nsGkAtoms::href) {
|
||||
nsAutoString href;
|
||||
if (GetAttr(kNameSpaceID_XLink, nsGkAtoms::href, href)) {
|
||||
// Note: no need to notify here; since we're just now being bound
|
||||
// we don't have any frames or anything yet.
|
||||
LoadImage(href, PR_FALSE, PR_FALSE);
|
||||
}
|
||||
}
|
||||
// resolve href attribute
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
|
||||
return nsSVGFEImageElementBase::AfterSetAttr(aNamespaceID, aName,
|
||||
aValue, aNotify);
|
||||
nsAutoString href(mStringAttributes[HREF].GetAnimValue());
|
||||
href.Trim(" \t\n\r");
|
||||
|
||||
if (baseURI && !href.IsEmpty())
|
||||
NS_MakeAbsoluteURI(href, href, baseURI);
|
||||
|
||||
return LoadImage(href, aForce, aNotify);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIContent methods:
|
||||
|
||||
nsresult
|
||||
nsSVGFEImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
|
@ -5324,12 +5328,9 @@ nsSVGFEImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|||
|
||||
// Our base URI may have changed; claim that our URI changed, and the
|
||||
// nsImageLoadingContent will decide whether a new image load is warranted.
|
||||
nsAutoString href;
|
||||
if (GetAttr(kNameSpaceID_XLink, nsGkAtoms::href, href)) {
|
||||
// Note: no need to notify here; since we're just now being bound
|
||||
// we don't have any frames or anything yet.
|
||||
LoadImage(href, PR_FALSE, PR_FALSE);
|
||||
}
|
||||
// Note: no need to notify here; since we're just now being bound
|
||||
// we don't have any frames or anything yet.
|
||||
LoadSVGImage(PR_FALSE, PR_FALSE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -5433,6 +5434,16 @@ nsSVGFEImageElement::GetStringInfo()
|
|||
NS_ARRAY_LENGTH(sStringInfo));
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGFEImageElement::DidChangeString(PRUint8 aAttrEnum, PRBool aDoSetAttr)
|
||||
{
|
||||
nsSVGFEImageElementBase::DidChangeString(aAttrEnum, aDoSetAttr);
|
||||
|
||||
if (aAttrEnum == HREF) {
|
||||
LoadSVGImage(PR_TRUE, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// imgIDecoderObserver methods
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
||||
protected:
|
||||
void GetSrc(nsAString& src);
|
||||
nsresult LoadSVGImage(PRBool aForce, PRBool aNotify);
|
||||
|
||||
virtual LengthAttributesInfo GetLengthInfo();
|
||||
virtual StringAttributesInfo GetStringInfo();
|
||||
|
@ -255,13 +255,6 @@ nsSVGImageElement::DidChangeString(PRUint8 aAttrEnum, PRBool aDoSetAttr)
|
|||
nsSVGImageElementBase::DidChangeString(aAttrEnum, aDoSetAttr);
|
||||
|
||||
if (aAttrEnum == HREF) {
|
||||
nsAutoString href;
|
||||
GetSrc(href);
|
||||
|
||||
#ifdef DEBUG_tor
|
||||
fprintf(stderr, "nsSVGImageElement - URI <%s>\n", ToNewCString(href));
|
||||
#endif
|
||||
|
||||
// If caller is not chrome and dom.disable_image_src_set is true,
|
||||
// prevent setting image.src by exiting early
|
||||
if (nsContentUtils::GetBoolPref("dom.disable_image_src_set") &&
|
||||
|
@ -269,25 +262,25 @@ nsSVGImageElement::DidChangeString(PRUint8 aAttrEnum, PRBool aDoSetAttr)
|
|||
return;
|
||||
}
|
||||
|
||||
LoadImage(href, PR_TRUE, PR_TRUE);
|
||||
LoadSVGImage(PR_TRUE, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void nsSVGImageElement::GetSrc(nsAString& src)
|
||||
nsresult
|
||||
nsSVGImageElement::LoadSVGImage(PRBool aForce, PRBool aNotify)
|
||||
{
|
||||
// resolve href attribute
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
|
||||
nsAutoString relURIStr(mStringAttributes[HREF].GetAnimValue());
|
||||
relURIStr.Trim(" \t\n\r");
|
||||
nsAutoString href(mStringAttributes[HREF].GetAnimValue());
|
||||
href.Trim(" \t\n\r");
|
||||
|
||||
if (baseURI && !relURIStr.IsEmpty())
|
||||
NS_MakeAbsoluteURI(src, relURIStr, baseURI);
|
||||
else
|
||||
src = relURIStr;
|
||||
if (baseURI && !href.IsEmpty())
|
||||
NS_MakeAbsoluteURI(href, href, baseURI);
|
||||
|
||||
return LoadImage(href, aForce, aNotify);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -305,12 +298,9 @@ nsSVGImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|||
|
||||
// Our base URI may have changed; claim that our URI changed, and the
|
||||
// nsImageLoadingContent will decide whether a new image load is warranted.
|
||||
nsAutoString href;
|
||||
if (GetAttr(kNameSpaceID_XLink, nsGkAtoms::href, href)) {
|
||||
// Note: no need to notify here; since we're just now being bound
|
||||
// we don't have any frames or anything yet.
|
||||
LoadImage(href, PR_FALSE, PR_FALSE);
|
||||
}
|
||||
// Note: no need to notify here; since we're just now being bound
|
||||
// we don't have any frames or anything yet.
|
||||
LoadSVGImage(PR_FALSE, PR_FALSE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче