Bug 1663089 [wpt PR 25399] - idle-detection: Implement requestPermission() method...
[gecko.git] / dom / svg / SVGFEComponentTransferElement.cpp
blob2704280d9c263386de95b63e0a95f3af8ed136c3
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"
13 NS_IMPL_NS_NEW_SVG_ELEMENT(FEComponentTransfer)
15 using namespace mozilla::gfx;
18 namespace mozilla {
19 namespace dom {
21 JSObject* SVGFEComponentTransferElement::WrapNode(
22 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
23 return SVGFEComponentTransferElement_Binding::Wrap(aCx, this, aGivenProto);
26 SVGElement::StringInfo SVGFEComponentTransferElement::sStringInfo[2] = {
27 {nsGkAtoms::result, kNameSpaceID_None, true},
28 {nsGkAtoms::in, kNameSpaceID_None, true}};
30 //----------------------------------------------------------------------
31 // nsINode methods
33 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEComponentTransferElement)
35 already_AddRefed<DOMSVGAnimatedString> SVGFEComponentTransferElement::In1() {
36 return mStringAttributes[IN1].ToDOMAnimatedString(this);
39 //----------------------------------------------------------------------
40 // SVGElement methods
42 SVGElement::StringAttributesInfo
43 SVGFEComponentTransferElement::GetStringInfo() {
44 return StringAttributesInfo(mStringAttributes, sStringInfo,
45 ArrayLength(sStringInfo));
48 //--------------------------------------------
50 FilterPrimitiveDescription
51 SVGFEComponentTransferElement::GetPrimitiveDescription(
52 SVGFilterInstance* aInstance, const IntRect& aFilterSubregion,
53 const nsTArray<bool>& aInputsAreTainted,
54 nsTArray<RefPtr<SourceSurface>>& aInputImages) {
55 RefPtr<SVGComponentTransferFunctionElement> childForChannel[4];
57 for (nsIContent* childContent = nsINode::GetFirstChild(); childContent;
58 childContent = childContent->GetNextSibling()) {
59 RefPtr<SVGComponentTransferFunctionElement> child;
60 CallQueryInterface(
61 childContent,
62 (SVGComponentTransferFunctionElement**)getter_AddRefs(child));
63 if (child) {
64 childForChannel[child->GetChannel()] = child;
68 ComponentTransferAttributes atts;
69 for (int32_t i = 0; i < 4; i++) {
70 if (childForChannel[i]) {
71 childForChannel[i]->ComputeAttributes(i, atts);
72 } else {
73 atts.mTypes[i] = (uint8_t)SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY;
76 return FilterPrimitiveDescription(AsVariant(std::move(atts)));
79 bool SVGFEComponentTransferElement::AttributeAffectsRendering(
80 int32_t aNameSpaceID, nsAtom* aAttribute) const {
81 return SVGFEComponentTransferElementBase::AttributeAffectsRendering(
82 aNameSpaceID, aAttribute) ||
83 (aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::in);
86 void SVGFEComponentTransferElement::GetSourceImageNames(
87 nsTArray<SVGStringInfo>& aSources) {
88 aSources.AppendElement(SVGStringInfo(&mStringAttributes[IN1], this));
91 } // namespace dom
92 } // namespace mozilla