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/. */
6 
7 #include "mozilla/dom/SVGFEMergeElement.h"
8 #include "mozilla/dom/SVGFEMergeElementBinding.h"
9 #include "mozilla/dom/SVGFEMergeNodeElement.h"
10 
11 NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(FEMerge)
12 
13 using namespace mozilla::gfx;
14 
15 namespace mozilla {
16 namespace dom {
17 
WrapNode(JSContext * aCx,JS::Handle<JSObject * > aGivenProto)18 JSObject* SVGFEMergeElement::WrapNode(JSContext* aCx,
19                                       JS::Handle<JSObject*> aGivenProto) {
20   return SVGFEMergeElementBinding::Wrap(aCx, this, aGivenProto);
21 }
22 
23 nsSVGElement::StringInfo SVGFEMergeElement::sStringInfo[1] = {
24     {&nsGkAtoms::result, kNameSpaceID_None, true}};
25 
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEMergeElement)26 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEMergeElement)
27 
28 FilterPrimitiveDescription SVGFEMergeElement::GetPrimitiveDescription(
29     nsSVGFilterInstance* aInstance, const IntRect& aFilterSubregion,
30     const nsTArray<bool>& aInputsAreTainted,
31     nsTArray<RefPtr<SourceSurface>>& aInputImages) {
32   return FilterPrimitiveDescription(PrimitiveType::Merge);
33 }
34 
GetSourceImageNames(nsTArray<nsSVGStringInfo> & aSources)35 void SVGFEMergeElement::GetSourceImageNames(
36     nsTArray<nsSVGStringInfo>& aSources) {
37   for (nsIContent* child = nsINode::GetFirstChild(); child;
38        child = child->GetNextSibling()) {
39     if (child->IsSVGElement(nsGkAtoms::feMergeNode)) {
40       SVGFEMergeNodeElement* node = static_cast<SVGFEMergeNodeElement*>(child);
41       aSources.AppendElement(nsSVGStringInfo(node->GetIn1(), node));
42     }
43   }
44 }
45 
46 //----------------------------------------------------------------------
47 // nsSVGElement methods
48 
GetStringInfo()49 nsSVGElement::StringAttributesInfo SVGFEMergeElement::GetStringInfo() {
50   return StringAttributesInfo(mStringAttributes, sStringInfo,
51                               ArrayLength(sStringInfo));
52 }
53 
54 }  // namespace dom
55 }  // namespace mozilla
56