LCOV - code coverage report
Current view: top level - dom/events - NotifyPaintEvent.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 33 69 47.8 %
Date: 2017-07-14 16:53:18 Functions: 7 13 53.8 %
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 "base/basictypes.h"
       8             : #include "ipc/IPCMessageUtils.h"
       9             : #include "mozilla/dom/DOMRect.h"
      10             : #include "mozilla/dom/NotifyPaintEvent.h"
      11             : #include "mozilla/dom/PaintRequest.h"
      12             : #include "mozilla/GfxMessageUtils.h"
      13             : #include "nsContentUtils.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace dom {
      17             : 
      18          25 : NotifyPaintEvent::NotifyPaintEvent(EventTarget* aOwner,
      19             :                                    nsPresContext* aPresContext,
      20             :                                    WidgetEvent* aEvent,
      21             :                                    EventMessage aEventMessage,
      22             :                                    nsTArray<nsRect>* aInvalidateRequests,
      23             :                                    uint64_t aTransactionId,
      24          25 :                                    DOMHighResTimeStamp aTimeStamp)
      25          25 :   : Event(aOwner, aPresContext, aEvent)
      26             : {
      27          25 :   if (mEvent) {
      28          25 :     mEvent->mMessage = aEventMessage;
      29             :   }
      30          25 :   if (aInvalidateRequests) {
      31          25 :     mInvalidateRequests.SwapElements(*aInvalidateRequests);
      32             :   }
      33             : 
      34          25 :   mTransactionId = aTransactionId;
      35          25 :   mTimeStamp = aTimeStamp;
      36          25 : }
      37             : 
      38         180 : NS_INTERFACE_MAP_BEGIN(NotifyPaintEvent)
      39         180 :   NS_INTERFACE_MAP_ENTRY(nsIDOMNotifyPaintEvent)
      40         180 : NS_INTERFACE_MAP_END_INHERITING(Event)
      41             : 
      42          31 : NS_IMPL_ADDREF_INHERITED(NotifyPaintEvent, Event)
      43          27 : NS_IMPL_RELEASE_INHERITED(NotifyPaintEvent, Event)
      44             : 
      45             : nsRegion
      46           1 : NotifyPaintEvent::GetRegion(SystemCallerGuarantee)
      47             : {
      48           1 :   nsRegion r;
      49           2 :   for (uint32_t i = 0; i < mInvalidateRequests.Length(); ++i) {
      50           1 :     r.Or(r, mInvalidateRequests[i]);
      51           1 :     r.SimplifyOutward(10);
      52             :   }
      53           1 :   return r;
      54             : }
      55             : 
      56             : already_AddRefed<DOMRect>
      57           0 : NotifyPaintEvent::BoundingClientRect(SystemCallerGuarantee aGuarantee)
      58             : {
      59           0 :   RefPtr<DOMRect> rect = new DOMRect(ToSupports(this));
      60             : 
      61           0 :   if (mPresContext) {
      62           0 :     rect->SetLayoutRect(GetRegion(aGuarantee).GetBounds());
      63             :   }
      64             : 
      65           0 :   return rect.forget();
      66             : }
      67             : 
      68             : already_AddRefed<DOMRectList>
      69           1 : NotifyPaintEvent::ClientRects(SystemCallerGuarantee aGuarantee)
      70             : {
      71           1 :   nsISupports* parent = ToSupports(this);
      72           2 :   RefPtr<DOMRectList> rectList = new DOMRectList(parent);
      73             : 
      74           2 :   nsRegion r = GetRegion(aGuarantee);
      75           2 :   for (auto iter = r.RectIter(); !iter.Done(); iter.Next()) {
      76           2 :     RefPtr<DOMRect> rect = new DOMRect(parent);
      77           1 :     rect->SetLayoutRect(iter.Get());
      78           1 :     rectList->Append(rect);
      79             :   }
      80             : 
      81           2 :   return rectList.forget();
      82             : }
      83             : 
      84             : already_AddRefed<PaintRequestList>
      85           0 : NotifyPaintEvent::PaintRequests(SystemCallerGuarantee)
      86             : {
      87           0 :   Event* parent = this;
      88           0 :   RefPtr<PaintRequestList> requests = new PaintRequestList(parent);
      89             : 
      90           0 :   for (uint32_t i = 0; i < mInvalidateRequests.Length(); ++i) {
      91           0 :     RefPtr<PaintRequest> r = new PaintRequest(parent);
      92           0 :     r->SetRequest(mInvalidateRequests[i]);
      93           0 :     requests->Append(r);
      94             :   }
      95             : 
      96           0 :   return requests.forget();
      97             : }
      98             : 
      99             : NS_IMETHODIMP_(void)
     100           0 : NotifyPaintEvent::Serialize(IPC::Message* aMsg,
     101             :                             bool aSerializeInterfaceType)
     102             : {
     103           0 :   if (aSerializeInterfaceType) {
     104           0 :     IPC::WriteParam(aMsg, NS_LITERAL_STRING("notifypaintevent"));
     105             :   }
     106             : 
     107           0 :   Event::Serialize(aMsg, false);
     108             : 
     109           0 :   uint32_t length = mInvalidateRequests.Length();
     110           0 :   IPC::WriteParam(aMsg, length);
     111           0 :   for (uint32_t i = 0; i < length; ++i) {
     112           0 :     IPC::WriteParam(aMsg, mInvalidateRequests[i]);
     113             :   }
     114           0 : }
     115             : 
     116             : NS_IMETHODIMP_(bool)
     117           0 : NotifyPaintEvent::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter)
     118             : {
     119           0 :   NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false);
     120             : 
     121           0 :   uint32_t length = 0;
     122           0 :   NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &length), false);
     123           0 :   mInvalidateRequests.SetCapacity(length);
     124           0 :   for (uint32_t i = 0; i < length; ++i) {
     125           0 :     nsRect req;
     126           0 :     NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &req), false);
     127           0 :     mInvalidateRequests.AppendElement(req);
     128             :   }
     129             : 
     130           0 :   return true;
     131             : }
     132             : 
     133             : uint64_t
     134           0 : NotifyPaintEvent::TransactionId(SystemCallerGuarantee)
     135             : {
     136           0 :   return mTransactionId;
     137             : }
     138             : 
     139             : DOMHighResTimeStamp
     140           0 : NotifyPaintEvent::PaintTimeStamp(SystemCallerGuarantee)
     141             : {
     142           0 :   return mTimeStamp;
     143             : }
     144             : 
     145             : } // namespace dom
     146             : } // namespace mozilla
     147             : 
     148             : using namespace mozilla;
     149             : using namespace mozilla::dom;
     150             : 
     151             : already_AddRefed<NotifyPaintEvent>
     152          25 : NS_NewDOMNotifyPaintEvent(EventTarget* aOwner,
     153             :                           nsPresContext* aPresContext,
     154             :                           WidgetEvent* aEvent,
     155             :                           EventMessage aEventMessage,
     156             :                           nsTArray<nsRect>* aInvalidateRequests,
     157             :                           uint64_t aTransactionId,
     158             :                           DOMHighResTimeStamp aTimeStamp)
     159             : {
     160             :   RefPtr<NotifyPaintEvent> it =
     161             :     new NotifyPaintEvent(aOwner, aPresContext, aEvent, aEventMessage,
     162          50 :                          aInvalidateRequests, aTransactionId, aTimeStamp);
     163          50 :   return it.forget();
     164             : }

Generated by: LCOV version 1.13