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_SVGGRAPHICSELEMENT_H_
8 #define DOM_SVG_SVGGRAPHICSELEMENT_H_
9 
10 #include "mozilla/dom/SVGTests.h"
11 #include "mozilla/dom/SVGTransformableElement.h"
12 
13 namespace mozilla {
14 namespace dom {
15 
16 using SVGGraphicsElementBase = SVGTransformableElement;
17 
18 class SVGGraphicsElement : public SVGGraphicsElementBase, public SVGTests {
19  protected:
20   explicit SVGGraphicsElement(
21       already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
22   ~SVGGraphicsElement() = default;
23 
24  public:
25   // interfaces:
26   NS_DECL_ISUPPORTS_INHERITED
27 
28   // WebIDL
Autofocus()29   bool Autofocus() const { return GetBoolAttr(nsGkAtoms::autofocus); }
SetAutofocus(bool aAutofocus)30   void SetAutofocus(bool aAutofocus) {
31     SetBoolAttr(nsGkAtoms::autofocus, aAutofocus);
32   }
33 
34   bool IsFocusableInternal(int32_t* aTabIndex, bool aWithMouse) override;
35   nsresult BindToTree(BindContext&, nsINode& aParent) override;
AsSVGElement()36   SVGElement* AsSVGElement() final { return this; }
37 
38  protected:
39   // returns true if focusability has been definitively determined otherwise
40   // false
41   bool IsSVGFocusable(bool* aIsFocusable, int32_t* aTabIndex);
42 
43   template <typename T>
IsInLengthInfo(const nsAtom * aAttribute,const T & aLengthInfos)44   bool IsInLengthInfo(const nsAtom* aAttribute, const T& aLengthInfos) const {
45     for (auto const& e : aLengthInfos) {
46       if (e.mName == aAttribute) {
47         return true;
48       }
49     }
50     return false;
51   }
52 };
53 
54 }  // namespace dom
55 }  // namespace mozilla
56 
57 #endif  // DOM_SVG_SVGGRAPHICSELEMENT_H_
58