tor-browser

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

SVGAElement.h (3738B)


      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_SVGAELEMENT_H_
      8 #define DOM_SVG_SVGAELEMENT_H_
      9 
     10 #include "Link.h"
     11 #include "SVGAnimatedString.h"
     12 #include "mozilla/dom/SVGGraphicsElement.h"
     13 #include "nsDOMTokenList.h"
     14 
     15 nsresult NS_NewSVGAElement(
     16    nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
     17 
     18 namespace mozilla {
     19 
     20 class EventChainPostVisitor;
     21 class EventChainPreVisitor;
     22 
     23 namespace dom {
     24 
     25 using SVGAElementBase = SVGGraphicsElement;
     26 
     27 class SVGAElement final : public SVGAElementBase, public Link {
     28 protected:
     29  using Element::GetCharacterDataBuffer;
     30 
     31  explicit SVGAElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
     32  friend nsresult(::NS_NewSVGAElement(
     33      nsIContent** aResult,
     34      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
     35  JSObject* WrapNode(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
     36 
     37 public:
     38  NS_DECL_ISUPPORTS_INHERITED
     39 
     40  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGAElement, SVGAElementBase)
     41 
     42  // nsINode interface methods
     43  void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
     44  MOZ_CAN_RUN_SCRIPT
     45  nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
     46  nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
     47 
     48  // nsIContent
     49  nsresult BindToTree(BindContext&, nsINode& aParent) override;
     50  void UnbindFromTree(UnbindContext&) override;
     51 
     52  int32_t TabIndexDefault() override;
     53  Focusable IsFocusableWithoutStyle(IsFocusableFlags) override;
     54 
     55  void GetLinkTargetImpl(nsAString& aTarget) override;
     56  already_AddRefed<nsIURI> GetHrefURI() const override;
     57  bool HasHref() const;
     58 
     59  virtual void AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
     60                            const nsAttrValue* aValue,
     61                            const nsAttrValue* aOldValue,
     62                            nsIPrincipal* aMaybeScriptedPrincipal,
     63                            bool aNotify) override;
     64 
     65  // WebIDL
     66  already_AddRefed<DOMSVGAnimatedString> Href();
     67  already_AddRefed<DOMSVGAnimatedString> Target();
     68  void GetDownload(nsAString& aDownload);
     69  void SetDownload(const nsAString& aDownload, ErrorResult& rv);
     70  void GetPing(nsAString& aPing);
     71  void SetPing(const nsAString& aPing, mozilla::ErrorResult& rv);
     72  void GetRel(nsAString& aRel);
     73  void SetRel(const nsAString& aRel, mozilla::ErrorResult& rv);
     74  void SetReferrerPolicy(const nsAString& aPolicy, mozilla::ErrorResult& rv);
     75  void GetReferrerPolicy(nsAString& aPolicy);
     76  nsDOMTokenList* RelList();
     77  void GetHreflang(nsAString& aHreflang);
     78  void SetHreflang(const nsAString& aHreflang, mozilla::ErrorResult& rv);
     79  void GetType(nsAString& aType);
     80  void SetType(const nsAString& aType, mozilla::ErrorResult& rv);
     81  void GetText(nsAString& aText, mozilla::ErrorResult& rv) const;
     82  void SetText(const nsAString& aText, mozilla::ErrorResult& rv);
     83 
     84  void NodeInfoChanged(Document* aOldDoc) final {
     85    ClearHasPendingLinkUpdate();
     86    SVGAElementBase::NodeInfoChanged(aOldDoc);
     87  }
     88 
     89  NS_IMPL_FROMNODE_WITH_TAG(SVGAElement, kNameSpaceID_SVG, a)
     90 
     91 protected:
     92  virtual ~SVGAElement() = default;
     93 
     94  StringAttributesInfo GetStringInfo() override;
     95  void DidAnimateAttribute(int32_t aNameSpaceID, nsAtom* aAttribute) override;
     96 
     97  enum { HREF, XLINK_HREF, TARGET };
     98  SVGAnimatedString mStringAttributes[3];
     99  static StringInfo sStringInfo[3];
    100 
    101  RefPtr<nsDOMTokenList> mRelList;
    102 };
    103 
    104 }  // namespace dom
    105 }  // namespace mozilla
    106 
    107 #endif  // DOM_SVG_SVGAELEMENT_H_