Bug 1856362 part 2 - introduce and use IsSVGFilterPrimitiveElement r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D189858
This commit is contained in:
Robert Longson 2023-10-03 10:40:46 +00:00
parent d2dacc2146
commit b20238137a
8 changed files with 11 additions and 44 deletions

View File

@ -868,6 +868,7 @@ class nsINode : public mozilla::dom::EventTarget {
}
virtual bool IsSVGAnimationElement() const { return false; }
virtual bool IsSVGFilterPrimitiveElement() const { return false; }
virtual bool IsSVGGeometryElement() const { return false; }
virtual bool IsSVGGraphicsElement() const { return false; }

View File

@ -54,18 +54,6 @@ SVGElement::LengthInfo SVGFilterPrimitiveElement::sLengthInfo[4] = {
{nsGkAtoms::height, 100, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE,
SVGContentUtils::Y}};
//----------------------------------------------------------------------
// nsISupports methods
NS_IMPL_ADDREF_INHERITED(SVGFilterPrimitiveElement,
SVGFilterPrimitiveElementBase)
NS_IMPL_RELEASE_INHERITED(SVGFilterPrimitiveElement,
SVGFilterPrimitiveElementBase)
NS_INTERFACE_MAP_BEGIN(SVGFilterPrimitiveElement)
NS_INTERFACE_MAP_ENTRY_CONCRETE(SVGFilterPrimitiveElement)
NS_INTERFACE_MAP_END_INHERITING(SVGFilterPrimitiveElementBase)
//----------------------------------------------------------------------
// Implementation

View File

@ -31,13 +31,6 @@ struct SVGStringInfo {
using SVGFilterPrimitiveElementBase = SVGElement;
#define NS_SVG_FE_CID \
{ \
0x60483958, 0xd229, 0x4a77, { \
0x96, 0xb2, 0x62, 0x3e, 0x69, 0x95, 0x1e, 0x0e \
} \
}
/**
* Base class for filter primitive elements
* Children of those elements e.g. feMergeNode
@ -61,6 +54,9 @@ class SVGFilterPrimitiveElement : public SVGFilterPrimitiveElementBase {
public:
using PrimitiveAttributes = mozilla::gfx::PrimitiveAttributes;
NS_IMPL_FROMNODE_HELPER(SVGFilterPrimitiveElement,
IsSVGFilterPrimitiveElement())
ColorSpace GetInputColorSpace(int32_t aInputIndex,
ColorSpace aUnchangedInputColorSpace) {
return OperatesOnSRGB(aInputIndex,
@ -78,10 +74,7 @@ class SVGFilterPrimitiveElement : public SVGFilterPrimitiveElementBase {
// See http://www.w3.org/TR/SVG/filters.html#FilterPrimitiveSubRegion
virtual bool SubregionIsUnionOfRegions() { return true; }
NS_DECLARE_STATIC_IID_ACCESSOR(NS_SVG_FE_CID)
// interfaces:
NS_DECL_ISUPPORTS_INHERITED
bool IsSVGFilterPrimitiveElement() const final { return true; }
// SVGElement interface
nsresult Clone(mozilla::dom::NodeInfo*, nsINode** aResult) const override = 0;
@ -146,8 +139,6 @@ class SVGFilterPrimitiveElement : public SVGFilterPrimitiveElementBase {
static LengthInfo sLengthInfo[4];
};
NS_DEFINE_STATIC_IID_ACCESSOR(SVGFilterPrimitiveElement, NS_SVG_FE_CID)
using SVGFilterPrimitiveChildElementBase = SVGElement;
class SVGFilterPrimitiveChildElement

View File

@ -117,7 +117,6 @@
#undef NOISY_FIRST_LETTER
#include "nsMathMLParts.h"
#include "mozilla/dom/SVGFilters.h"
#include "mozilla/dom/SVGTests.h"
#include "mozilla/SVGGradientFrame.h"
@ -4956,10 +4955,8 @@ nsCSSFrameConstructor::FindSVGData(const Element& aElement,
// primitives. If aParentFrame is null, we know that the frame that will
// be created will be an nsInlineFrame, so it can never be a filter.
bool parentIsFilter = aParentFrame && aParentFrame->IsSVGFilterFrame();
nsCOMPtr<SVGFilterPrimitiveElement> filterPrimitive =
do_QueryInterface(const_cast<Element*>(&aElement));
if ((parentIsFilter && !filterPrimitive) ||
(!parentIsFilter && filterPrimitive)) {
if ((parentIsFilter && !aElement.IsSVGFilterPrimitiveElement()) ||
(!parentIsFilter && aElement.IsSVGFilterPrimitiveElement())) {
return &sSuppressData;
}

View File

@ -81,9 +81,7 @@ NS_IMPL_FRAMEARENA_HELPERS(SVGFEContainerFrame)
#ifdef DEBUG
void SVGFEContainerFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
nsIFrame* aPrevInFlow) {
nsCOMPtr<SVGFilterPrimitiveElement> filterPrimitive =
do_QueryInterface(aContent);
NS_ASSERTION(filterPrimitive,
NS_ASSERTION(aContent->IsSVGFilterPrimitiveElement(),
"Trying to construct an SVGFEContainerFrame for a "
"content element that doesn't support the right interfaces");

View File

@ -79,9 +79,7 @@ NS_IMPL_FRAMEARENA_HELPERS(SVGFELeafFrame)
#ifdef DEBUG
void SVGFELeafFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
nsIFrame* aPrevInFlow) {
nsCOMPtr<SVGFilterPrimitiveElement> filterPrimitive =
do_QueryInterface(aContent);
NS_ASSERTION(filterPrimitive,
NS_ASSERTION(aContent->IsSVGFilterPrimitiveElement(),
"Trying to construct an SVGFELeafFrame for a "
"content element that doesn't support the right interfaces");

View File

@ -88,10 +88,7 @@ const SVGAnimatedLength* SVGFilterFrame::GetLengthValue(uint32_t aIndex,
const SVGFilterElement* SVGFilterFrame::GetFilterContent(nsIContent* aDefault) {
for (nsIContent* child = mContent->GetFirstChild(); child;
child = child->GetNextSibling()) {
RefPtr<SVGFilterPrimitiveElement> primitive;
CallQueryInterface(child,
(SVGFilterPrimitiveElement**)getter_AddRefs(primitive));
if (primitive) {
if (child->IsSVGFilterPrimitiveElement()) {
return static_cast<SVGFilterElement*>(GetContent());
}
}

View File

@ -378,10 +378,7 @@ nsresult SVGFilterInstance::BuildPrimitives(
AutoTArray<RefPtr<SVGFilterPrimitiveElement>, 8> primitives;
for (nsIContent* child = mFilterElement->nsINode::GetFirstChild(); child;
child = child->GetNextSibling()) {
RefPtr<SVGFilterPrimitiveElement> primitive;
CallQueryInterface(child,
(SVGFilterPrimitiveElement**)getter_AddRefs(primitive));
if (primitive) {
if (auto* primitive = SVGFilterPrimitiveElement::FromNode(child)) {
primitives.AppendElement(primitive);
}
}