HTMLDialogElement.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef HTMLDialogElement_h
  6. #define HTMLDialogElement_h
  7. #include "mozilla/AsyncEventDispatcher.h"
  8. #include "mozilla/Attributes.h"
  9. #include "nsGenericHTMLElement.h"
  10. #include "nsGkAtoms.h"
  11. namespace mozilla {
  12. namespace dom {
  13. class HTMLDialogElement final : public nsGenericHTMLElement
  14. {
  15. public:
  16. explicit HTMLDialogElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo) : nsGenericHTMLElement(aNodeInfo)
  17. {
  18. }
  19. NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLDialogElement, dialog)
  20. virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const override;
  21. static bool IsDialogEnabled();
  22. bool Open() const { return GetBoolAttr(nsGkAtoms::open); }
  23. void SetOpen(bool aOpen, ErrorResult& aError)
  24. {
  25. SetHTMLBoolAttr(nsGkAtoms::open, aOpen, aError);
  26. }
  27. void GetReturnValue(nsAString& aReturnValue)
  28. {
  29. aReturnValue = mReturnValue;
  30. }
  31. void SetReturnValue(const nsAString& aReturnValue)
  32. {
  33. mReturnValue = aReturnValue;
  34. }
  35. void Close(const mozilla::dom::Optional<nsAString>& aReturnValue);
  36. void Show();
  37. void ShowModal(ErrorResult& aError);
  38. nsString mReturnValue;
  39. protected:
  40. virtual ~HTMLDialogElement();
  41. JSObject* WrapNode(JSContext* aCx,
  42. JS::Handle<JSObject*> aGivenProto) override;
  43. };
  44. } // namespace dom
  45. } // namespace mozilla
  46. #endif