Bug 1245751 - Part 4: Allow href without xlink on SVG <filter> elements.
MozReview-Commit-ID: Idloqv5h2PT
--- a/dom/svg/SVGFilterElement.cpp
+++ b/dom/svg/SVGFilterElement.cpp
@@ -38,18 +38,19 @@ nsSVGElement::EnumInfo SVGFilterElement:
SVG_UNIT_TYPE_OBJECTBOUNDINGBOX
},
{ &nsGkAtoms::primitiveUnits,
sSVGUnitTypesMap,
SVG_UNIT_TYPE_USERSPACEONUSE
}
};
-nsSVGElement::StringInfo SVGFilterElement::sStringInfo[1] =
+nsSVGElement::StringInfo SVGFilterElement::sStringInfo[2] =
{
+ { &nsGkAtoms::href, kNameSpaceID_None, true },
{ &nsGkAtoms::href, kNameSpaceID_XLink, true }
};
//----------------------------------------------------------------------
// Implementation
SVGFilterElement::SVGFilterElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
: SVGFilterElementBase(aNodeInfo)
@@ -99,17 +100,19 @@ already_AddRefed<SVGAnimatedEnumeration>
SVGFilterElement::PrimitiveUnits()
{
return mEnumAttributes[PRIMITIVEUNITS].ToDOMAnimatedEnum(this);
}
already_AddRefed<SVGAnimatedString>
SVGFilterElement::Href()
{
- return mStringAttributes[HREF].ToDOMAnimatedString(this);
+ return mStringAttributes[HREF].IsExplicitlySet()
+ ? mStringAttributes[HREF].ToDOMAnimatedString(this)
+ : mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
}
//----------------------------------------------------------------------
// nsIContent methods
NS_IMETHODIMP_(bool)
SVGFilterElement::IsAttributeMapped(const nsIAtom* name) const
{
--- a/dom/svg/SVGFilterElement.h
+++ b/dom/svg/SVGFilterElement.h
@@ -65,17 +65,17 @@ protected:
enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT };
nsSVGLength2 mLengthAttributes[4];
static LengthInfo sLengthInfo[4];
enum { FILTERUNITS, PRIMITIVEUNITS };
nsSVGEnum mEnumAttributes[2];
static EnumInfo sEnumInfo[2];
- enum { HREF };
- nsSVGString mStringAttributes[1];
- static StringInfo sStringInfo[1];
+ enum { HREF, XLINK_HREF };
+ nsSVGString mStringAttributes[2];
+ static StringInfo sStringInfo[2];
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_SVGFilterElement_h
--- a/layout/svg/nsSVGFilterFrame.cpp
+++ b/layout/svg/nsSVGFilterFrame.cpp
@@ -105,20 +105,27 @@ nsSVGFilterFrame::GetReferencedFilter()
{
if (mNoHRefURI)
return nullptr;
nsSVGPaintingProperty *property =
Properties().Get(nsSVGEffects::HrefAsPaintingProperty());
if (!property) {
- // Fetch our Filter element's xlink:href attribute
+ // Fetch our Filter element's href or xlink:href attribute
SVGFilterElement *filter = static_cast<SVGFilterElement *>(mContent);
nsAutoString href;
- filter->mStringAttributes[SVGFilterElement::HREF].GetAnimValue(href, filter);
+ if (filter->mStringAttributes[SVGFilterElement::HREF].IsExplicitlySet()) {
+ filter->mStringAttributes[SVGFilterElement::HREF]
+ .GetAnimValue(href, filter);
+ } else {
+ filter->mStringAttributes[SVGFilterElement::XLINK_HREF]
+ .GetAnimValue(href, filter);
+ }
+
if (href.IsEmpty()) {
mNoHRefURI = true;
return nullptr; // no URL
}
// Convert href to an nsIURI
nsCOMPtr<nsIURI> targetURI;
nsCOMPtr<nsIURI> base = mContent->GetBaseURI();
@@ -167,17 +174,18 @@ nsSVGFilterFrame::AttributeChanged(int32
if (aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::x ||
aAttribute == nsGkAtoms::y ||
aAttribute == nsGkAtoms::width ||
aAttribute == nsGkAtoms::height ||
aAttribute == nsGkAtoms::filterUnits ||
aAttribute == nsGkAtoms::primitiveUnits)) {
nsSVGEffects::InvalidateDirectRenderingObservers(this);
- } else if (aNameSpaceID == kNameSpaceID_XLink &&
+ } else if ((aNameSpaceID == kNameSpaceID_XLink ||
+ aNameSpaceID == kNameSpaceID_None) &&
aAttribute == nsGkAtoms::href) {
// Blow away our reference, if any
Properties().Delete(nsSVGEffects::HrefAsPaintingProperty());
mNoHRefURI = false;
// And update whoever references us
nsSVGEffects::InvalidateDirectRenderingObservers(this);
}
return nsSVGContainerFrame::AttributeChanged(aNameSpaceID,