1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/SVGFEMergeElement.h"
8 #include "mozilla/dom/SVGFEMergeElementBinding.h"
9 #include "mozilla/dom/SVGFEMergeNodeElement.h"
10 #include "mozilla/dom/Document.h"
11 #include "mozilla/dom/BindContext.h"
13 NS_IMPL_NS_NEW_SVG_ELEMENT(FEMerge
)
15 using namespace mozilla::gfx
;
17 namespace mozilla::dom
{
19 JSObject
* SVGFEMergeElement::WrapNode(JSContext
* aCx
,
20 JS::Handle
<JSObject
*> aGivenProto
) {
21 return SVGFEMergeElement_Binding::Wrap(aCx
, this, aGivenProto
);
24 SVGElement::StringInfo
SVGFEMergeElement::sStringInfo
[1] = {
25 {nsGkAtoms::result
, kNameSpaceID_None
, true}};
27 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEMergeElement
)
29 FilterPrimitiveDescription
SVGFEMergeElement::GetPrimitiveDescription(
30 SVGFilterInstance
* aInstance
, const IntRect
& aFilterSubregion
,
31 const nsTArray
<bool>& aInputsAreTainted
,
32 nsTArray
<RefPtr
<SourceSurface
>>& aInputImages
) {
33 return FilterPrimitiveDescription(AsVariant(MergeAttributes()));
36 void SVGFEMergeElement::GetSourceImageNames(nsTArray
<SVGStringInfo
>& aSources
) {
37 for (nsIContent
* child
= nsINode::GetFirstChild(); child
;
38 child
= child
->GetNextSibling()) {
39 if (auto* node
= SVGFEMergeNodeElement::FromNode(child
)) {
40 aSources
.AppendElement(SVGStringInfo(node
->GetIn1(), node
));
45 nsresult
SVGFEMergeElement::BindToTree(BindContext
& aCtx
, nsINode
& aParent
) {
46 if (aCtx
.InComposedDoc()) {
47 aCtx
.OwnerDoc().SetUseCounter(eUseCounter_custom_feMerge
);
50 return SVGFEMergeElementBase::BindToTree(aCtx
, aParent
);
53 //----------------------------------------------------------------------
56 SVGElement::StringAttributesInfo
SVGFEMergeElement::GetStringInfo() {
57 return StringAttributesInfo(mStringAttributes
, sStringInfo
,
58 ArrayLength(sStringInfo
));
61 } // namespace mozilla::dom