LCOV - code coverage report
Current view: top level - dom/events - CompositionEvent.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 53 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "mozilla/dom/CompositionEvent.h"
       8             : #include "mozilla/TextEvents.h"
       9             : #include "prtime.h"
      10             : 
      11             : namespace mozilla {
      12             : namespace dom {
      13             : 
      14           0 : CompositionEvent::CompositionEvent(EventTarget* aOwner,
      15             :                                    nsPresContext* aPresContext,
      16           0 :                                    WidgetCompositionEvent* aEvent)
      17             :   : UIEvent(aOwner, aPresContext,
      18             :             aEvent ? aEvent :
      19           0 :                      new WidgetCompositionEvent(false, eVoidEvent, nullptr))
      20             : {
      21           0 :   NS_ASSERTION(mEvent->mClass == eCompositionEventClass,
      22             :                "event type mismatch");
      23             : 
      24           0 :   if (aEvent) {
      25           0 :     mEventIsInternal = false;
      26             :   } else {
      27           0 :     mEventIsInternal = true;
      28           0 :     mEvent->mTime = PR_Now();
      29             : 
      30             :     // XXX compositionstart is cancelable in draft of DOM3 Events.
      31             :     //     However, it doesn't make sence for us, we cannot cancel composition
      32             :     //     when we sends compositionstart event.
      33           0 :     mEvent->mFlags.mCancelable = false;
      34             :   }
      35             : 
      36             :   // XXX Do we really need to duplicate the data value?
      37           0 :   mData = mEvent->AsCompositionEvent()->mData;
      38             :   // TODO: Native event should have locale information.
      39           0 : }
      40             : 
      41             : // static
      42             : already_AddRefed<CompositionEvent>
      43           0 : CompositionEvent::Constructor(const GlobalObject& aGlobal,
      44             :                      const nsAString& aType,
      45             :                      const CompositionEventInit& aParam,
      46             :                      ErrorResult& aRv)
      47             : {
      48           0 :   nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
      49           0 :   RefPtr<CompositionEvent> e = new CompositionEvent(t, nullptr, nullptr);
      50           0 :   bool trusted = e->Init(t);
      51           0 :   e->InitCompositionEvent(aType, aParam.mBubbles, aParam.mCancelable,
      52           0 :                           aParam.mView, aParam.mData, EmptyString());
      53           0 :   e->mDetail = aParam.mDetail;
      54           0 :   e->SetTrusted(trusted);
      55           0 :   e->SetComposed(aParam.mComposed);
      56           0 :   return e.forget();
      57             : }
      58             : 
      59           0 : NS_IMPL_CYCLE_COLLECTION_INHERITED(CompositionEvent, UIEvent,
      60             :                                    mRanges)
      61             : 
      62           0 : NS_IMPL_ADDREF_INHERITED(CompositionEvent, UIEvent)
      63           0 : NS_IMPL_RELEASE_INHERITED(CompositionEvent, UIEvent)
      64             : 
      65           0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(CompositionEvent)
      66           0 : NS_INTERFACE_MAP_END_INHERITING(UIEvent)
      67             : 
      68             : void
      69           0 : CompositionEvent::GetData(nsAString& aData) const
      70             : {
      71           0 :   aData = mData;
      72           0 : }
      73             : 
      74             : void
      75           0 : CompositionEvent::GetLocale(nsAString& aLocale) const
      76             : {
      77           0 :   aLocale = mLocale;
      78           0 : }
      79             : 
      80             : void
      81           0 : CompositionEvent::InitCompositionEvent(const nsAString& aType,
      82             :                                        bool aCanBubble,
      83             :                                        bool aCancelable,
      84             :                                        nsGlobalWindow* aView,
      85             :                                        const nsAString& aData,
      86             :                                        const nsAString& aLocale)
      87             : {
      88           0 :   NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
      89             : 
      90           0 :   UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
      91           0 :   mData = aData;
      92           0 :   mLocale = aLocale;
      93             : }
      94             : 
      95             : void
      96           0 : CompositionEvent::GetRanges(TextClauseArray& aRanges)
      97             : {
      98             :   // If the mRanges is not empty, we return the cached value.
      99           0 :   if (!mRanges.IsEmpty()) {
     100           0 :     aRanges = mRanges;
     101           0 :     return;
     102             :   }
     103           0 :   RefPtr<TextRangeArray> textRangeArray = mEvent->AsCompositionEvent()->mRanges;
     104           0 :   if (!textRangeArray) {
     105           0 :     return;
     106             :   }
     107           0 :   nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(mOwner);
     108           0 :   const TextRange* targetRange = textRangeArray->GetTargetClause();
     109           0 :   for (size_t i = 0; i < textRangeArray->Length(); i++) {
     110           0 :     const TextRange& range = textRangeArray->ElementAt(i);
     111           0 :     mRanges.AppendElement(new TextClause(window, range, targetRange));
     112             :   }
     113           0 :   aRanges = mRanges;
     114             : }
     115             : 
     116             : } // namespace dom
     117             : } // namespace mozilla
     118             : 
     119             : using namespace mozilla;
     120             : using namespace mozilla::dom;
     121             : 
     122             : already_AddRefed<CompositionEvent>
     123           0 : NS_NewDOMCompositionEvent(EventTarget* aOwner,
     124             :                           nsPresContext* aPresContext,
     125             :                           WidgetCompositionEvent* aEvent)
     126             : {
     127             :   RefPtr<CompositionEvent> event =
     128           0 :     new CompositionEvent(aOwner, aPresContext, aEvent);
     129           0 :   return event.forget();
     130             : }

Generated by: LCOV version 1.13