tor-browser

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

SVGScriptElement.h (3265B)


      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_SVGSCRIPTELEMENT_H_
      8 #define DOM_SVG_SVGSCRIPTELEMENT_H_
      9 
     10 #include "SVGAnimatedString.h"
     11 #include "mozilla/AlreadyAddRefed.h"
     12 #include "mozilla/dom/SVGElement.h"
     13 #include "mozilla/dom/ScriptElement.h"
     14 
     15 nsresult NS_NewSVGScriptElement(
     16    nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
     17    mozilla::dom::FromParser aFromParser);
     18 
     19 namespace mozilla::dom {
     20 
     21 using SVGScriptElementBase = SVGElement;
     22 
     23 class SVGScriptElement final : public SVGScriptElementBase,
     24                               public ScriptElement {
     25 protected:
     26  friend nsresult(::NS_NewSVGScriptElement(
     27      nsIContent** aResult,
     28      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
     29      mozilla::dom::FromParser aFromParser));
     30  SVGScriptElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
     31                   FromParser aFromParser);
     32 
     33  JSObject* WrapNode(JSContext* aCx,
     34                     JS::Handle<JSObject*> aGivenProto) override;
     35 
     36 public:
     37  // interfaces:
     38 
     39  NS_DECL_ISUPPORTS_INHERITED
     40 
     41  // nsIScriptElement
     42  void GetScriptText(nsAString& text) const override;
     43  void GetScriptCharset(nsAString& charset) override;
     44  void FreezeExecutionAttrs(const Document* aOwnerDoc) override;
     45  CORSMode GetCORSMode() const override;
     46  FetchPriority GetFetchPriority() const override;
     47 
     48  // ScriptElement
     49  bool HasExternalScriptContent() override;
     50 
     51  // nsIContent specializations:
     52  nsresult BindToTree(BindContext&, nsINode& aParent) override;
     53  bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
     54                      const nsAString& aValue,
     55                      nsIPrincipal* aMaybeScriptedPrincipal,
     56                      nsAttrValue& aResult) override;
     57 
     58  nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
     59 
     60  // WebIDL
     61  void GetType(nsAString& aType);
     62  void SetType(const nsAString& aType, ErrorResult& rv);
     63  bool Async() { return mForceAsync || GetBoolAttr(nsGkAtoms::async); }
     64  void SetAsync(bool aValue) {
     65    mForceAsync = false;
     66    SetBoolAttr(nsGkAtoms::async, aValue);
     67  }
     68  bool Defer() { return GetBoolAttr(nsGkAtoms::defer); }
     69  void SetDefer(bool aDefer) { SetBoolAttr(nsGkAtoms::defer, aDefer); }
     70  void GetCrossOrigin(nsAString& aCrossOrigin);
     71  void SetCrossOrigin(const nsAString& aCrossOrigin, ErrorResult& aError);
     72  already_AddRefed<DOMSVGAnimatedString> Href();
     73  void GetFetchPriority(nsAString& aFetchPriority) const;
     74  void SetFetchPriority(const nsAString& aFetchPriority) {
     75    SetAttr(nsGkAtoms::fetchpriority, aFetchPriority, IgnoreErrors());
     76  }
     77 
     78 protected:
     79  ~SVGScriptElement() = default;
     80 
     81  StringAttributesInfo GetStringInfo() override;
     82 
     83  bool GetAsyncState() override { return Async(); }
     84 
     85  nsIContent* GetAsContent() override { return this; }
     86 
     87  enum { HREF, XLINK_HREF };
     88  SVGAnimatedScriptHrefString mStringAttributes[2];
     89  static StringInfo sStringInfo[2];
     90 };
     91 
     92 }  // namespace mozilla::dom
     93 
     94 #endif  // DOM_SVG_SVGSCRIPTELEMENT_H_