dom/events/FocusEvent.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
     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/. */
     6 #include "mozilla/dom/FocusEvent.h"
     7 #include "mozilla/ContentEvents.h"
     8 #include "prtime.h"
    10 namespace mozilla {
    11 namespace dom {
    13 NS_IMPL_ISUPPORTS_INHERITED(FocusEvent, UIEvent, nsIDOMFocusEvent)
    15 FocusEvent::FocusEvent(EventTarget* aOwner,
    16                        nsPresContext* aPresContext,
    17                        InternalFocusEvent* aEvent)
    18   : UIEvent(aOwner, aPresContext,
    19             aEvent ? aEvent : new InternalFocusEvent(false, NS_FOCUS_CONTENT))
    20 {
    21   if (aEvent) {
    22     mEventIsInternal = false;
    23   } else {
    24     mEventIsInternal = true;
    25     mEvent->time = PR_Now();
    26   }
    27 }
    29 /* readonly attribute nsIDOMEventTarget relatedTarget; */
    30 NS_IMETHODIMP
    31 FocusEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
    32 {
    33   NS_ENSURE_ARG_POINTER(aRelatedTarget);
    34   NS_IF_ADDREF(*aRelatedTarget = GetRelatedTarget());
    35   return NS_OK;
    36 }
    38 EventTarget*
    39 FocusEvent::GetRelatedTarget()
    40 {
    41   return mEvent->AsFocusEvent()->relatedTarget;
    42 }
    44 nsresult
    45 FocusEvent::InitFocusEvent(const nsAString& aType,
    46                            bool aCanBubble,
    47                            bool aCancelable,
    48                            nsIDOMWindow* aView,
    49                            int32_t aDetail,
    50                            EventTarget* aRelatedTarget)
    51 {
    52   nsresult rv =
    53     UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
    54   NS_ENSURE_SUCCESS(rv, rv);
    55   mEvent->AsFocusEvent()->relatedTarget = aRelatedTarget;
    56   return NS_OK;
    57 }
    59 already_AddRefed<FocusEvent>
    60 FocusEvent::Constructor(const GlobalObject& aGlobal,
    61                         const nsAString& aType,
    62                         const FocusEventInit& aParam,
    63                         ErrorResult& aRv)
    64 {
    65   nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
    66   nsRefPtr<FocusEvent> e = new FocusEvent(t, nullptr, nullptr);
    67   bool trusted = e->Init(t);
    68   aRv = e->InitFocusEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView,
    69                           aParam.mDetail, aParam.mRelatedTarget);
    70   e->SetTrusted(trusted);
    71   return e.forget();
    72 }
    74 } // namespace dom
    75 } // namespace mozilla
    77 using namespace mozilla;
    78 using namespace mozilla::dom;
    80 nsresult
    81 NS_NewDOMFocusEvent(nsIDOMEvent** aInstancePtrResult,
    82                     EventTarget* aOwner,
    83                     nsPresContext* aPresContext,
    84                     InternalFocusEvent* aEvent)
    85 {
    86   FocusEvent* it = new FocusEvent(aOwner, aPresContext, aEvent);
    87   NS_ADDREF(it);
    88   *aInstancePtrResult = static_cast<Event*>(it);
    89   return NS_OK;
    90 }

mercurial