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/SVGFEFloodElement.h"
9 #include "FilterSupport.h"
10 #include "mozilla/dom/SVGFEFloodElementBinding.h"
13 #include "mozilla/dom/Document.h"
14 #include "mozilla/dom/BindContext.h"
16 NS_IMPL_NS_NEW_SVG_ELEMENT(FEFlood
)
18 using namespace mozilla::gfx
;
20 namespace mozilla::dom
{
22 JSObject
* SVGFEFloodElement::WrapNode(JSContext
* aCx
,
23 JS::Handle
<JSObject
*> aGivenProto
) {
24 return SVGFEFloodElement_Binding::Wrap(aCx
, this, aGivenProto
);
27 SVGElement::StringInfo
SVGFEFloodElement::sStringInfo
[1] = {
28 {nsGkAtoms::result
, kNameSpaceID_None
, true}};
30 //----------------------------------------------------------------------
33 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFEFloodElement
)
35 FilterPrimitiveDescription
SVGFEFloodElement::GetPrimitiveDescription(
36 SVGFilterInstance
* aInstance
, const IntRect
& aFilterSubregion
,
37 const nsTArray
<bool>& aInputsAreTainted
,
38 nsTArray
<RefPtr
<SourceSurface
>>& aInputImages
) {
40 if (const auto* frame
= GetPrimaryFrame()) {
41 const nsStyleSVGReset
* styleSVGReset
= frame
->Style()->StyleSVGReset();
43 sRGBColor::FromABGR(styleSVGReset
->mFloodColor
.CalcColor(frame
)));
44 color
.a
*= styleSVGReset
->mFloodOpacity
;
47 atts
.mColor
= sRGBColor();
49 return FilterPrimitiveDescription(AsVariant(std::move(atts
)));
52 bool SVGFEFloodElement::OutputIsTainted(const nsTArray
<bool>& aInputsAreTainted
,
53 nsIPrincipal
* aReferencePrincipal
) {
54 if (const auto* frame
= GetPrimaryFrame()) {
55 if (frame
->Style()->StyleSVGReset()->mFloodColor
.IsCurrentColor()) {
60 return SVGFEFloodElementBase::OutputIsTainted(aInputsAreTainted
,
64 //----------------------------------------------------------------------
67 nsresult
SVGFEFloodElement::BindToTree(BindContext
& aCtx
, nsINode
& aParent
) {
68 if (aCtx
.InComposedDoc()) {
69 aCtx
.OwnerDoc().SetUseCounter(eUseCounter_custom_feFlood
);
72 return SVGFEFloodElementBase::BindToTree(aCtx
, aParent
);
75 //----------------------------------------------------------------------
78 SVGElement::StringAttributesInfo
SVGFEFloodElement::GetStringInfo() {
79 return StringAttributesInfo(mStringAttributes
, sStringInfo
,
80 std::size(sStringInfo
));
83 } // namespace mozilla::dom