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 mozilla_dom_HTMLMetaElement_h
8 #define mozilla_dom_HTMLMetaElement_h
9 
10 #include "mozilla/Attributes.h"
11 #include "nsGenericHTMLElement.h"
12 
13 namespace mozilla {
14 namespace dom {
15 
16 class HTMLMetaElement final : public nsGenericHTMLElement {
17  public:
18   explicit HTMLMetaElement(
19       already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
20 
21   // nsISupports
22   NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLMetaElement, nsGenericHTMLElement)
23 
24   virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
25   virtual void UnbindFromTree(bool aNullParent = true) override;
26 
27   virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
28                                 const nsAttrValue* aValue,
29                                 const nsAttrValue* aOldValue,
30                                 nsIPrincipal* aSubjectPrincipal,
31                                 bool aNotify) override;
32 
33   void CreateAndDispatchEvent(Document* aDoc, const nsAString& aEventName);
34 
35   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
36 
GetName(nsAString & aValue)37   void GetName(nsAString& aValue) { GetHTMLAttr(nsGkAtoms::name, aValue); }
SetName(const nsAString & aName,ErrorResult & aRv)38   void SetName(const nsAString& aName, ErrorResult& aRv) {
39     SetHTMLAttr(nsGkAtoms::name, aName, aRv);
40   }
GetHttpEquiv(nsAString & aValue)41   void GetHttpEquiv(nsAString& aValue) {
42     GetHTMLAttr(nsGkAtoms::httpEquiv, aValue);
43   }
SetHttpEquiv(const nsAString & aHttpEquiv,ErrorResult & aRv)44   void SetHttpEquiv(const nsAString& aHttpEquiv, ErrorResult& aRv) {
45     SetHTMLAttr(nsGkAtoms::httpEquiv, aHttpEquiv, aRv);
46   }
GetContent(nsAString & aValue)47   void GetContent(nsAString& aValue) {
48     GetHTMLAttr(nsGkAtoms::content, aValue);
49   }
SetContent(const nsAString & aContent,ErrorResult & aRv)50   void SetContent(const nsAString& aContent, ErrorResult& aRv) {
51     SetHTMLAttr(nsGkAtoms::content, aContent, aRv);
52   }
GetScheme(nsAString & aValue)53   void GetScheme(nsAString& aValue) { GetHTMLAttr(nsGkAtoms::scheme, aValue); }
SetScheme(const nsAString & aScheme,ErrorResult & aRv)54   void SetScheme(const nsAString& aScheme, ErrorResult& aRv) {
55     SetHTMLAttr(nsGkAtoms::scheme, aScheme, aRv);
56   }
57 
58   virtual JSObject* WrapNode(JSContext* aCx,
59                              JS::Handle<JSObject*> aGivenProto) override;
60 
61  protected:
62   virtual ~HTMLMetaElement();
63 
64  private:
65   void SetMetaReferrer(Document* aDocument);
66   void ProcessViewportContent(Document* aDocument);
67   void DiscardViewportContent(Document* aDocument);
68 };
69 
70 }  // namespace dom
71 }  // namespace mozilla
72 
73 #endif  // mozilla_dom_HTMLMetaElement_h
74