BeforeUnloadEvent.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #include "mozilla/dom/BeforeUnloadEvent.h"
  6. namespace mozilla {
  7. namespace dom {
  8. NS_IMPL_ADDREF_INHERITED(BeforeUnloadEvent, Event)
  9. NS_IMPL_RELEASE_INHERITED(BeforeUnloadEvent, Event)
  10. NS_INTERFACE_MAP_BEGIN(BeforeUnloadEvent)
  11. NS_INTERFACE_MAP_ENTRY(nsIDOMBeforeUnloadEvent)
  12. NS_INTERFACE_MAP_END_INHERITING(Event)
  13. NS_IMETHODIMP
  14. BeforeUnloadEvent::SetReturnValue(const nsAString& aReturnValue)
  15. {
  16. mText = aReturnValue;
  17. return NS_OK; // Don't throw an exception
  18. }
  19. NS_IMETHODIMP
  20. BeforeUnloadEvent::GetReturnValue(nsAString& aReturnValue)
  21. {
  22. aReturnValue = mText;
  23. return NS_OK; // Don't throw an exception
  24. }
  25. } // namespace dom
  26. } // namespace mozilla
  27. using namespace mozilla;
  28. using namespace mozilla::dom;
  29. already_AddRefed<BeforeUnloadEvent>
  30. NS_NewDOMBeforeUnloadEvent(EventTarget* aOwner,
  31. nsPresContext* aPresContext,
  32. WidgetEvent* aEvent)
  33. {
  34. RefPtr<BeforeUnloadEvent> it =
  35. new BeforeUnloadEvent(aOwner, aPresContext, aEvent);
  36. return it.forget();
  37. }