Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / svg / SVGFEComponentTransferElement.cpp
blobb9156e011d6dc341c3a6b455da16a85104b7f932
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 std::size(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 if (auto* child =
61 SVGComponentTransferFunctionElement::FromNode(childContent)) {
62 childForChannel[child->GetChannel()] = child;
66 ComponentTransferAttributes atts;
67 for (int32_t i = 0; i < 4; i++) {
68 if (childForChannel[i]) {
69 childForChannel[i]->ComputeAttributes(i, atts);
70 } else {
71 atts.mTypes[i] = (uint8_t)SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY;
74 return FilterPrimitiveDescription(AsVariant(std::move(atts)));
77 bool SVGFEComponentTransferElement::AttributeAffectsRendering(
78 int32_t aNameSpaceID, nsAtom* aAttribute) const {
79 return SVGFEComponentTransferElementBase::AttributeAffectsRendering(
80 aNameSpaceID, aAttribute) ||
81 (aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::in);
84 void SVGFEComponentTransferElement::GetSourceImageNames(
85 nsTArray<SVGStringInfo>& aSources) {
86 aSources.AppendElement(SVGStringInfo(&mStringAttributes[IN1], this));
89 nsresult SVGFEComponentTransferElement::BindToTree(BindContext& aCtx,
90 nsINode& aParent) {
91 if (aCtx.InComposedDoc()) {
92 aCtx.OwnerDoc().SetUseCounter(eUseCounter_custom_feComponentTransfer);
95 return SVGFEComponentTransferElementBase::BindToTree(aCtx, aParent);
98 } // namespace mozilla::dom