dom/events/PaintRequest.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     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 #ifndef mozilla_dom_PaintRequest_h_
     7 #define mozilla_dom_PaintRequest_h_
     9 #include "nsIDOMPaintRequest.h"
    10 #include "nsPresContext.h"
    11 #include "nsIDOMEvent.h"
    12 #include "mozilla/Attributes.h"
    13 #include "nsWrapperCache.h"
    15 namespace mozilla {
    16 namespace dom {
    18 class DOMRect;
    20 class PaintRequest MOZ_FINAL : public nsIDOMPaintRequest
    21                              , public nsWrapperCache
    22 {
    23 public:
    24   PaintRequest(nsIDOMEvent* aParent)
    25     : mParent(aParent)
    26   {
    27     mRequest.mFlags = 0;
    28     SetIsDOMBinding();
    29   }
    31   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    32   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PaintRequest)
    33   NS_DECL_NSIDOMPAINTREQUEST
    35   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    37   nsIDOMEvent* GetParentObject() const
    38   {
    39     return mParent;
    40   }
    42   already_AddRefed<DOMRect> ClientRect();
    43   void GetReason(nsAString& aResult) const
    44   {
    45     aResult.AssignLiteral("repaint");
    46   }
    48   void SetRequest(const nsInvalidateRequestList::Request& aRequest)
    49   { mRequest = aRequest; }
    51 private:
    52   ~PaintRequest() {}
    54   nsCOMPtr<nsIDOMEvent> mParent;
    55   nsInvalidateRequestList::Request mRequest;
    56 };
    58 class PaintRequestList MOZ_FINAL : public nsISupports,
    59                                    public nsWrapperCache
    60 {
    61 public:
    62   PaintRequestList(nsIDOMEvent *aParent) : mParent(aParent)
    63   {
    64     SetIsDOMBinding();
    65   }
    67   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    68   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PaintRequestList)
    70   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    71   nsISupports* GetParentObject()
    72   {
    73     return mParent;
    74   }
    76   void Append(PaintRequest* aElement)
    77   {
    78     mArray.AppendElement(aElement);
    79   }
    81   uint32_t Length()
    82   {
    83     return mArray.Length();
    84   }
    86   PaintRequest* Item(uint32_t aIndex)
    87   {
    88     return mArray.SafeElementAt(aIndex);
    89   }
    90   PaintRequest* IndexedGetter(uint32_t aIndex, bool& aFound)
    91   {
    92     aFound = aIndex < mArray.Length();
    93     return aFound ? mArray.ElementAt(aIndex) : nullptr;
    94   }
    96 private:
    97   ~PaintRequestList() {}
    99   nsTArray< nsRefPtr<PaintRequest> > mArray;
   100   nsCOMPtr<nsIDOMEvent> mParent;
   101 };
   103 } // namespace dom
   104 } // namespace mozilla
   106 #endif // mozilla_dom_PaintRequest_h_

mercurial