Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / svg / SVGFEFloodElement.cpp
blob7f97a5b59cf289e138f2bfc01c2cde9d63912d86
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"
11 #include "nsColor.h"
12 #include "nsIFrame.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 //----------------------------------------------------------------------
31 // nsINode methods
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) {
39 FloodAttributes atts;
40 if (const auto* frame = GetPrimaryFrame()) {
41 const nsStyleSVGReset* styleSVGReset = frame->Style()->StyleSVGReset();
42 sRGBColor color(
43 sRGBColor::FromABGR(styleSVGReset->mFloodColor.CalcColor(frame)));
44 color.a *= styleSVGReset->mFloodOpacity;
45 atts.mColor = color;
46 } else {
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()) {
56 return true;
60 return SVGFEFloodElementBase::OutputIsTainted(aInputsAreTainted,
61 aReferencePrincipal);
64 //----------------------------------------------------------------------
65 // nsIContent methods
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 //----------------------------------------------------------------------
76 // SVGElement methods
78 SVGElement::StringAttributesInfo SVGFEFloodElement::GetStringInfo() {
79 return StringAttributesInfo(mStringAttributes, sStringInfo,
80 std::size(sStringInfo));
83 } // namespace mozilla::dom