content/base/src/DOMPoint.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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_DOMPOINT_H_
     7 #define MOZILLA_DOMPOINT_H_
     9 #include "nsWrapperCache.h"
    10 #include "nsISupports.h"
    11 #include "nsCycleCollectionParticipant.h"
    12 #include "mozilla/Attributes.h"
    13 #include "mozilla/ErrorResult.h"
    14 #include "nsCOMPtr.h"
    15 #include "mozilla/dom/BindingDeclarations.h"
    17 namespace mozilla {
    18 namespace dom {
    20 class GlobalObject;
    21 class DOMPointInit;
    23 class DOMPointReadOnly : public nsWrapperCache
    24 {
    25 public:
    26   DOMPointReadOnly(nsISupports* aParent, double aX, double aY,
    27                    double aZ, double aW)
    28     : mParent(aParent)
    29     , mX(aX)
    30     , mY(aY)
    31     , mZ(aZ)
    32     , mW(aW)
    33   {
    34     SetIsDOMBinding();
    35   }
    37   double X() const { return mX; }
    38   double Y() const { return mY; }
    39   double Z() const { return mZ; }
    40   double W() const { return mW; }
    42 protected:
    43   nsCOMPtr<nsISupports> mParent;
    44   double mX, mY, mZ, mW;
    45 };
    47 class DOMPoint MOZ_FINAL : public DOMPointReadOnly
    48 {
    49 public:
    50   DOMPoint(nsISupports* aParent, double aX = 0.0, double aY = 0.0,
    51            double aZ = 0.0, double aW = 1.0)
    52     : DOMPointReadOnly(aParent, aX, aY, aZ, aW)
    53   {}
    55   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMPoint)
    56   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMPoint)
    58   static already_AddRefed<DOMPoint>
    59   Constructor(const GlobalObject& aGlobal, const DOMPointInit& aParams,
    60               ErrorResult& aRV);
    61   static already_AddRefed<DOMPoint>
    62   Constructor(const GlobalObject& aGlobal, double aX, double aY,
    63               double aZ, double aW, ErrorResult& aRV);
    65   nsISupports* GetParentObject() const { return mParent; }
    66   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    68   void SetX(double aX) { mX = aX; }
    69   void SetY(double aY) { mY = aY; }
    70   void SetZ(double aZ) { mZ = aZ; }
    71   void SetW(double aW) { mW = aW; }
    72 };
    74 }
    75 }
    77 #endif /*MOZILLA_DOMPOINT_H_*/

mercurial