dom/events/PaintRequest.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/events/PaintRequest.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,106 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef mozilla_dom_PaintRequest_h_
    1.10 +#define mozilla_dom_PaintRequest_h_
    1.11 +
    1.12 +#include "nsIDOMPaintRequest.h"
    1.13 +#include "nsPresContext.h"
    1.14 +#include "nsIDOMEvent.h"
    1.15 +#include "mozilla/Attributes.h"
    1.16 +#include "nsWrapperCache.h"
    1.17 +
    1.18 +namespace mozilla {
    1.19 +namespace dom {
    1.20 +
    1.21 +class DOMRect;
    1.22 +
    1.23 +class PaintRequest MOZ_FINAL : public nsIDOMPaintRequest
    1.24 +                             , public nsWrapperCache
    1.25 +{
    1.26 +public:
    1.27 +  PaintRequest(nsIDOMEvent* aParent)
    1.28 +    : mParent(aParent)
    1.29 +  {
    1.30 +    mRequest.mFlags = 0;
    1.31 +    SetIsDOMBinding();
    1.32 +  }
    1.33 +
    1.34 +  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    1.35 +  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PaintRequest)
    1.36 +  NS_DECL_NSIDOMPAINTREQUEST
    1.37 +
    1.38 +  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.39 +
    1.40 +  nsIDOMEvent* GetParentObject() const
    1.41 +  {
    1.42 +    return mParent;
    1.43 +  }
    1.44 +
    1.45 +  already_AddRefed<DOMRect> ClientRect();
    1.46 +  void GetReason(nsAString& aResult) const
    1.47 +  {
    1.48 +    aResult.AssignLiteral("repaint");
    1.49 +  }
    1.50 +
    1.51 +  void SetRequest(const nsInvalidateRequestList::Request& aRequest)
    1.52 +  { mRequest = aRequest; }
    1.53 +
    1.54 +private:
    1.55 +  ~PaintRequest() {}
    1.56 +
    1.57 +  nsCOMPtr<nsIDOMEvent> mParent;
    1.58 +  nsInvalidateRequestList::Request mRequest;
    1.59 +};
    1.60 +
    1.61 +class PaintRequestList MOZ_FINAL : public nsISupports,
    1.62 +                                   public nsWrapperCache
    1.63 +{
    1.64 +public:
    1.65 +  PaintRequestList(nsIDOMEvent *aParent) : mParent(aParent)
    1.66 +  {
    1.67 +    SetIsDOMBinding();
    1.68 +  }
    1.69 +
    1.70 +  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    1.71 +  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PaintRequestList)
    1.72 +  
    1.73 +  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.74 +  nsISupports* GetParentObject()
    1.75 +  {
    1.76 +    return mParent;
    1.77 +  }
    1.78 +
    1.79 +  void Append(PaintRequest* aElement)
    1.80 +  {
    1.81 +    mArray.AppendElement(aElement);
    1.82 +  }
    1.83 +
    1.84 +  uint32_t Length()
    1.85 +  {
    1.86 +    return mArray.Length();
    1.87 +  }
    1.88 +
    1.89 +  PaintRequest* Item(uint32_t aIndex)
    1.90 +  {
    1.91 +    return mArray.SafeElementAt(aIndex);
    1.92 +  }
    1.93 +  PaintRequest* IndexedGetter(uint32_t aIndex, bool& aFound)
    1.94 +  {
    1.95 +    aFound = aIndex < mArray.Length();
    1.96 +    return aFound ? mArray.ElementAt(aIndex) : nullptr;
    1.97 +  }
    1.98 +
    1.99 +private:
   1.100 +  ~PaintRequestList() {}
   1.101 +
   1.102 +  nsTArray< nsRefPtr<PaintRequest> > mArray;
   1.103 +  nsCOMPtr<nsIDOMEvent> mParent;
   1.104 +};
   1.105 +
   1.106 +} // namespace dom
   1.107 +} // namespace mozilla
   1.108 +
   1.109 +#endif // mozilla_dom_PaintRequest_h_

mercurial