Bug 1655413 [wpt PR 24763] - Make CSP default-src without 'unsafe-eval' block eval...
[gecko.git] / dom / html / HTMLDialogElement.h
blob430b6b1ce0f6a6e334576091932fd98c7f6e5550
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/. */
7 #ifndef HTMLDialogElement_h
8 #define HTMLDialogElement_h
10 #include "mozilla/AsyncEventDispatcher.h"
11 #include "mozilla/Attributes.h"
12 #include "nsGenericHTMLElement.h"
13 #include "nsGkAtoms.h"
15 namespace mozilla {
16 namespace dom {
18 class HTMLDialogElement final : public nsGenericHTMLElement {
19 public:
20 explicit HTMLDialogElement(
21 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
22 : nsGenericHTMLElement(std::move(aNodeInfo)) {}
24 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLDialogElement, dialog)
26 nsresult Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const override;
28 static bool IsDialogEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
30 bool Open() const { return GetBoolAttr(nsGkAtoms::open); }
31 void SetOpen(bool aOpen, ErrorResult& aError) {
32 SetHTMLBoolAttr(nsGkAtoms::open, aOpen, aError);
35 void GetReturnValue(nsAString& aReturnValue) { aReturnValue = mReturnValue; }
36 void SetReturnValue(const nsAString& aReturnValue) {
37 mReturnValue = aReturnValue;
40 void UnbindFromTree(bool aNullParent = true) override;
42 void Close(const mozilla::dom::Optional<nsAString>& aReturnValue);
43 void Show();
44 void ShowModal(ErrorResult& aError);
46 bool IsInTopLayer() const;
47 void QueueCancelDialog();
48 void RunCancelDialogSteps();
50 nsString mReturnValue;
52 protected:
53 virtual ~HTMLDialogElement();
54 void FocusDialog();
55 JSObject* WrapNode(JSContext* aCx,
56 JS::Handle<JSObject*> aGivenProto) override;
58 private:
59 void RemoveFromTopLayerIfNeeded();
62 } // namespace dom
63 } // namespace mozilla
65 #endif