LCOV - code coverage report
Current view: directory - content/events/src - nsDOMMessageEvent.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 68 2 2.9 %
Date: 2012-06-02 Functions: 20 2 10.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Mozilla Foundation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2007
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Jeff Walden <jwalden+code@mit.edu> (original author)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      27                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #include "nsDOMMessageEvent.h"
      40                 : #include "nsContentUtils.h"
      41                 : #include "jsapi.h"
      42                 : 
      43            1464 : NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMMessageEvent)
      44                 : 
      45               0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMessageEvent, nsDOMEvent)
      46               0 :   if (tmp->mDataRooted) {
      47               0 :     tmp->UnrootData();
      48                 :   }
      49               0 :   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mSource)
      50               0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_END
      51                 : 
      52               0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMMessageEvent, nsDOMEvent)
      53               0 :   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
      54               0 :   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mSource)
      55               0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
      56                 : 
      57               0 : NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsDOMMessageEvent)
      58               0 :   if (JSVAL_IS_GCTHING(tmp->mData)) {
      59               0 :     void *gcThing = JSVAL_TO_GCTHING(tmp->mData);
      60               0 :     NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(gcThing, "mData")
      61                 :   }
      62               0 : NS_IMPL_CYCLE_COLLECTION_TRACE_END
      63                 : 
      64                 : DOMCI_DATA(MessageEvent, nsDOMMessageEvent)
      65                 : 
      66               0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMMessageEvent)
      67               0 :   NS_INTERFACE_MAP_ENTRY(nsIDOMMessageEvent)
      68               0 :   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MessageEvent)
      69               0 : NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
      70                 : 
      71               0 : NS_IMPL_ADDREF_INHERITED(nsDOMMessageEvent, nsDOMEvent)
      72               0 : NS_IMPL_RELEASE_INHERITED(nsDOMMessageEvent, nsDOMEvent)
      73                 : 
      74               0 : nsDOMMessageEvent::nsDOMMessageEvent(nsPresContext* aPresContext,
      75                 :                                      nsEvent* aEvent)
      76                 :   : nsDOMEvent(aPresContext, aEvent),
      77                 :     mData(JSVAL_VOID),
      78               0 :     mDataRooted(false)
      79                 : {
      80               0 : }
      81                 : 
      82               0 : nsDOMMessageEvent::~nsDOMMessageEvent()
      83                 : {
      84               0 :   if (mDataRooted)
      85               0 :     UnrootData();
      86               0 : }
      87                 : 
      88                 : void
      89               0 : nsDOMMessageEvent::RootData()
      90                 : {
      91               0 :   NS_ASSERTION(!mDataRooted, "...");
      92               0 :   NS_HOLD_JS_OBJECTS(this, nsDOMMessageEvent);
      93               0 :   mDataRooted = true;
      94               0 : }
      95                 : 
      96                 : void
      97               0 : nsDOMMessageEvent::UnrootData()
      98                 : {
      99               0 :   NS_ASSERTION(mDataRooted, "...");
     100               0 :   NS_DROP_JS_OBJECTS(this, nsDOMMessageEvent);
     101               0 :   mDataRooted = false;
     102               0 :   mData = JSVAL_VOID;
     103               0 : }
     104                 : 
     105                 : NS_IMETHODIMP
     106               0 : nsDOMMessageEvent::GetData(JSContext* aCx, jsval* aData)
     107                 : {
     108               0 :   *aData = mData;
     109               0 :   if (!JS_WrapValue(aCx, aData))
     110               0 :     return NS_ERROR_FAILURE;
     111               0 :   return NS_OK;
     112                 : }
     113                 : 
     114                 : NS_IMETHODIMP
     115               0 : nsDOMMessageEvent::GetOrigin(nsAString& aOrigin)
     116                 : {
     117               0 :   aOrigin = mOrigin;
     118               0 :   return NS_OK;
     119                 : }
     120                 : 
     121                 : NS_IMETHODIMP
     122               0 : nsDOMMessageEvent::GetLastEventId(nsAString& aLastEventId)
     123                 : {
     124               0 :   aLastEventId = mLastEventId;
     125               0 :   return NS_OK;
     126                 : }
     127                 : 
     128                 : NS_IMETHODIMP
     129               0 : nsDOMMessageEvent::GetSource(nsIDOMWindow** aSource)
     130                 : {
     131               0 :   NS_IF_ADDREF(*aSource = mSource);
     132               0 :   return NS_OK;
     133                 : }
     134                 : 
     135                 : NS_IMETHODIMP
     136               0 : nsDOMMessageEvent::InitMessageEvent(const nsAString& aType,
     137                 :                                     bool aCanBubble,
     138                 :                                     bool aCancelable,
     139                 :                                     const jsval& aData,
     140                 :                                     const nsAString& aOrigin,
     141                 :                                     const nsAString& aLastEventId,
     142                 :                                     nsIDOMWindow* aSource)
     143                 : {
     144               0 :   nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
     145               0 :   NS_ENSURE_SUCCESS(rv, rv);
     146                 : 
     147                 :   // Allowing double-initialization seems a little silly, but we have a test
     148                 :   // for it so it might be important ...
     149               0 :   if (mDataRooted)
     150               0 :     UnrootData();
     151               0 :   mData = aData;
     152               0 :   RootData();
     153               0 :   mOrigin = aOrigin;
     154               0 :   mLastEventId = aLastEventId;
     155               0 :   mSource = aSource;
     156                 : 
     157               0 :   return NS_OK;
     158                 : }
     159                 : 
     160                 : nsresult
     161               0 : NS_NewDOMMessageEvent(nsIDOMEvent** aInstancePtrResult,
     162                 :                       nsPresContext* aPresContext,
     163                 :                       nsEvent* aEvent) 
     164                 : {
     165               0 :   nsDOMMessageEvent* it = new nsDOMMessageEvent(aPresContext, aEvent);
     166                 : 
     167               0 :   return CallQueryInterface(it, aInstancePtrResult);
     168            4392 : }

Generated by: LCOV version 1.7