tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SVGFEDisplacementMapElement.h (3209B)


      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/. */
      6 
      7 #ifndef DOM_SVG_SVGFEDISPLACEMENTMAPELEMENT_H_
      8 #define DOM_SVG_SVGFEDISPLACEMENTMAPELEMENT_H_
      9 
     10 #include "SVGAnimatedEnumeration.h"
     11 #include "mozilla/dom/SVGFilters.h"
     12 
     13 nsresult NS_NewSVGFEDisplacementMapElement(
     14    nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
     15 
     16 namespace mozilla::dom {
     17 
     18 using SVGFEDisplacementMapElementBase = SVGFilterPrimitiveElement;
     19 
     20 class SVGFEDisplacementMapElement final
     21    : public SVGFEDisplacementMapElementBase {
     22 protected:
     23  friend nsresult(::NS_NewSVGFEDisplacementMapElement(
     24      nsIContent** aResult,
     25      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
     26  explicit SVGFEDisplacementMapElement(
     27      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
     28      : SVGFEDisplacementMapElementBase(std::move(aNodeInfo)) {}
     29  JSObject* WrapNode(JSContext* aCx,
     30                     JS::Handle<JSObject*> aGivenProto) override;
     31 
     32 public:
     33  FilterPrimitiveDescription GetPrimitiveDescription(
     34      SVGFilterInstance* aInstance, const IntRect& aFilterSubregion,
     35      const nsTArray<bool>& aInputsAreTainted,
     36      nsTArray<RefPtr<SourceSurface>>& aInputImages) override;
     37  bool AttributeAffectsRendering(int32_t aNameSpaceID,
     38                                 nsAtom* aAttribute) const override;
     39  SVGAnimatedString& GetResultImageName() override {
     40    return mStringAttributes[RESULT];
     41  }
     42  void GetSourceImageNames(nsTArray<SVGStringInfo>& aSources) override;
     43 
     44  nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
     45 
     46  nsresult BindToTree(BindContext& aCtx, nsINode& aParent) override;
     47 
     48  // WebIDL
     49  already_AddRefed<DOMSVGAnimatedString> In1();
     50  already_AddRefed<DOMSVGAnimatedString> In2();
     51  already_AddRefed<DOMSVGAnimatedNumber> Scale();
     52  already_AddRefed<DOMSVGAnimatedEnumeration> XChannelSelector();
     53  already_AddRefed<DOMSVGAnimatedEnumeration> YChannelSelector();
     54 
     55 protected:
     56  virtual bool OperatesOnSRGB(int32_t aInputIndex,
     57                              bool aInputIsAlreadySRGB) override {
     58    switch (aInputIndex) {
     59      case 0:
     60        return aInputIsAlreadySRGB;
     61      case 1:
     62        return SVGFEDisplacementMapElementBase::OperatesOnSRGB(
     63            aInputIndex, aInputIsAlreadySRGB);
     64      default:
     65        NS_ERROR("Will not give correct color model");
     66        return false;
     67    }
     68  }
     69 
     70  NumberAttributesInfo GetNumberInfo() override;
     71  EnumAttributesInfo GetEnumInfo() override;
     72  StringAttributesInfo GetStringInfo() override;
     73 
     74  enum { SCALE };
     75  SVGAnimatedNumber mNumberAttributes[1];
     76  static NumberInfo sNumberInfo[1];
     77 
     78  enum { CHANNEL_X, CHANNEL_Y };
     79  SVGAnimatedEnumeration mEnumAttributes[2];
     80  static SVGEnumMapping sChannelMap[];
     81  static EnumInfo sEnumInfo[2];
     82 
     83  enum { RESULT, IN1, IN2 };
     84  SVGAnimatedString mStringAttributes[3];
     85  static StringInfo sStringInfo[3];
     86 };
     87 
     88 }  // namespace mozilla::dom
     89 
     90 #endif  // DOM_SVG_SVGFEDISPLACEMENTMAPELEMENT_H_