Merge mozilla-central to autoland on a CLOSED TREE
[gecko.git] / dom / svg / SVGFEComponentTransferElement.cpp
blobd313c9ad15ce3775f8a0d56087b4a46fd22bf18a
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/SVGFEComponentTransferElement.h"
9 #include "mozilla/dom/SVGComponentTransferFunctionElement.h"
10 #include "mozilla/dom/SVGFEComponentTransferElementBinding.h"
11 #include "mozilla/gfx/2D.h"
12 #include "mozilla/dom/Document.h"
13 #include "mozilla/dom/BindContext.h"
15 NS_IMPL_NS_NEW_SVG_ELEMENT(FEComponentTransfer)
17 using namespace mozilla::gfx;
20 namespace mozilla::dom {
22 JSObject* SVGFEComponentTransferElement::WrapNode(
23 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
24 return SVGFEComponentTransferElement_Binding::Wrap(aCx, this, aGivenProto);
27 SVGElement::StringInfo SVGFEComponentTransferElement::sStringInfo[2] = {
28 {nsGkAtoms::result, kNameSpaceID_None, true},
29 {nsGkAtoms::in, kNameSpaceID_None, true}};
31 //----------------------------------------------------------------------
32 // nsINode methods
34 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEComponentTransferElement)
36 already_AddRefed<DOMSVGAnimatedString> SVGFEComponentTransferElement::In1() {
37 return mStringAttributes[IN1].ToDOMAnimatedString(this);
40 //----------------------------------------------------------------------
41 // SVGElement methods
43 SVGElement::StringAttributesInfo
44 SVGFEComponentTransferElement::GetStringInfo() {
45 return StringAttributesInfo(mStringAttributes, sStringInfo,
46 ArrayLength(sStringInfo));
49 //--------------------------------------------
51 FilterPrimitiveDescription
52 SVGFEComponentTransferElement::GetPrimitiveDescription(
53 SVGFilterInstance* aInstance, const IntRect& aFilterSubregion,
54 const nsTArray<bool>& aInputsAreTainted,
55 nsTArray<RefPtr<SourceSurface>>& aInputImages) {
56 RefPtr<SVGComponentTransferFunctionElement> childForChannel[4];
58 for (nsIContent* childContent = nsINode::GetFirstChild(); childContent;
59 childContent = childContent->GetNextSibling()) {
60 RefPtr<SVGComponentTransferFunctionElement> child;
61 CallQueryInterface(
62 childContent,
63 (SVGComponentTransferFunctionElement**)getter_AddRefs(child));
64 if (child) {
65 childForChannel[child->GetChannel()] = child;
69 ComponentTransferAttributes atts;
70 for (int32_t i = 0; i < 4; i++) {
71 if (childForChannel[i]) {
72 childForChannel[i]->ComputeAttributes(i, atts);
73 } else {
74 atts.mTypes[i] = (uint8_t)SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY;
77 return FilterPrimitiveDescription(AsVariant(std::move(atts)));
80 bool SVGFEComponentTransferElement::AttributeAffectsRendering(
81 int32_t aNameSpaceID, nsAtom* aAttribute) const {
82 return SVGFEComponentTransferElementBase::AttributeAffectsRendering(
83 aNameSpaceID, aAttribute) ||
84 (aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::in);
87 void SVGFEComponentTransferElement::GetSourceImageNames(
88 nsTArray<SVGStringInfo>& aSources) {
89 aSources.AppendElement(SVGStringInfo(&mStringAttributes[IN1], this));
92 nsresult SVGFEComponentTransferElement::BindToTree(BindContext& aCtx,
93 nsINode& aParent) {
94 if (aCtx.InComposedDoc()) {
95 aCtx.OwnerDoc().SetUseCounter(eUseCounter_custom_feComponentTransfer);
98 return SVGFE::BindToTree(aCtx, aParent);
101 } // namespace mozilla::dom