dom/events/BeforeUnloadEvent.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/events/BeforeUnloadEvent.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,48 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "mozilla/dom/BeforeUnloadEvent.h"
    1.10 +
    1.11 +namespace mozilla {
    1.12 +namespace dom {
    1.13 +
    1.14 +NS_IMPL_ADDREF_INHERITED(BeforeUnloadEvent, Event)
    1.15 +NS_IMPL_RELEASE_INHERITED(BeforeUnloadEvent, Event)
    1.16 +
    1.17 +NS_INTERFACE_MAP_BEGIN(BeforeUnloadEvent)
    1.18 +  NS_INTERFACE_MAP_ENTRY(nsIDOMBeforeUnloadEvent)
    1.19 +NS_INTERFACE_MAP_END_INHERITING(Event)
    1.20 +
    1.21 +NS_IMETHODIMP
    1.22 +BeforeUnloadEvent::SetReturnValue(const nsAString& aReturnValue)
    1.23 +{
    1.24 +  mText = aReturnValue;
    1.25 +  return NS_OK;  // Don't throw an exception
    1.26 +}
    1.27 +
    1.28 +NS_IMETHODIMP
    1.29 +BeforeUnloadEvent::GetReturnValue(nsAString& aReturnValue)
    1.30 +{
    1.31 +  aReturnValue = mText;
    1.32 +  return NS_OK;  // Don't throw an exception
    1.33 +}
    1.34 +
    1.35 +} // namespace dom
    1.36 +} // namespace mozilla
    1.37 +
    1.38 +using namespace mozilla;
    1.39 +using namespace mozilla::dom;
    1.40 +
    1.41 +nsresult
    1.42 +NS_NewDOMBeforeUnloadEvent(nsIDOMEvent** aInstancePtrResult,
    1.43 +                           EventTarget* aOwner,
    1.44 +                           nsPresContext* aPresContext,
    1.45 +                           WidgetEvent* aEvent) 
    1.46 +{
    1.47 +  BeforeUnloadEvent* it = new BeforeUnloadEvent(aOwner, aPresContext, aEvent);
    1.48 +  NS_ADDREF(it);
    1.49 +  *aInstancePtrResult = static_cast<Event*>(it);
    1.50 +  return NS_OK;
    1.51 +}

mercurial