dom/xbl/nsXBLProtoImplMember.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/xbl/nsXBLProtoImplMember.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,103 @@
     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 nsXBLProtoImplMember_h__
    1.10 +#define nsXBLProtoImplMember_h__
    1.11 +
    1.12 +#include "nsIAtom.h"
    1.13 +#include "nsString.h"
    1.14 +#include "nsString.h"
    1.15 +#include "nsIServiceManager.h"
    1.16 +#include "nsContentUtils.h" // For NS_CONTENT_DELETE_LIST_MEMBER.
    1.17 +#include "nsCycleCollectionParticipant.h"
    1.18 +
    1.19 +class nsIContent;
    1.20 +class nsIObjectOutputStream;
    1.21 +
    1.22 +struct nsXBLTextWithLineNumber
    1.23 +{
    1.24 +  char16_t* mText;
    1.25 +  uint32_t mLineNumber;
    1.26 +
    1.27 +  nsXBLTextWithLineNumber() :
    1.28 +    mText(nullptr),
    1.29 +    mLineNumber(0)
    1.30 +  {
    1.31 +    MOZ_COUNT_CTOR(nsXBLTextWithLineNumber);
    1.32 +  }
    1.33 +
    1.34 +  ~nsXBLTextWithLineNumber() {
    1.35 +    MOZ_COUNT_DTOR(nsXBLTextWithLineNumber);
    1.36 +    if (mText) {
    1.37 +      nsMemory::Free(mText);
    1.38 +    }
    1.39 +  }
    1.40 +
    1.41 +  void AppendText(const nsAString& aText) {
    1.42 +    if (mText) {
    1.43 +      char16_t* temp = mText;
    1.44 +      mText = ToNewUnicode(nsDependentString(temp) + aText);
    1.45 +      nsMemory::Free(temp);
    1.46 +    } else {
    1.47 +      mText = ToNewUnicode(aText);
    1.48 +    }
    1.49 +  }
    1.50 +
    1.51 +  char16_t* GetText() {
    1.52 +    return mText;
    1.53 +  }
    1.54 +
    1.55 +  void SetLineNumber(uint32_t aLineNumber) {
    1.56 +    mLineNumber = aLineNumber;
    1.57 +  }
    1.58 +
    1.59 +  uint32_t GetLineNumber() {
    1.60 +    return mLineNumber;
    1.61 +  }
    1.62 +};
    1.63 +
    1.64 +class nsXBLProtoImplMember
    1.65 +{
    1.66 +public:
    1.67 +  nsXBLProtoImplMember(const char16_t* aName)
    1.68 +    : mNext(nullptr)
    1.69 +    , mExposeToUntrustedContent(false)
    1.70 +  {
    1.71 +    mName = ToNewUnicode(nsDependentString(aName));
    1.72 +  }
    1.73 +  virtual ~nsXBLProtoImplMember() {
    1.74 +    nsMemory::Free(mName);
    1.75 +    NS_CONTENT_DELETE_LIST_MEMBER(nsXBLProtoImplMember, this, mNext);
    1.76 +  }
    1.77 +
    1.78 +  nsXBLProtoImplMember* GetNext() { return mNext; }
    1.79 +  void SetNext(nsXBLProtoImplMember* aNext) { mNext = aNext; }
    1.80 +  bool ShouldExposeToUntrustedContent() { return mExposeToUntrustedContent; }
    1.81 +  void SetExposeToUntrustedContent(bool aExpose) { mExposeToUntrustedContent = aExpose; }
    1.82 +  const char16_t* GetName() { return mName; }
    1.83 +
    1.84 +  virtual nsresult InstallMember(JSContext* aCx,
    1.85 +                                 JS::Handle<JSObject*> aTargetClassObject) = 0;
    1.86 +  virtual nsresult CompileMember(const nsCString& aClassStr,
    1.87 +                                 JS::Handle<JSObject*> aClassObject) = 0;
    1.88 +
    1.89 +  virtual void Trace(const TraceCallbacks& aCallbacks, void *aClosure) = 0;
    1.90 +
    1.91 +  virtual nsresult Write(nsIObjectOutputStream* aStream)
    1.92 +  {
    1.93 +    return NS_OK;
    1.94 +  }
    1.95 +
    1.96 +protected:
    1.97 +  nsXBLProtoImplMember* mNext;  // The members of an implementation are chained.
    1.98 +  char16_t* mName;               // The name of the field, method, or property.
    1.99 +
   1.100 +  bool mExposeToUntrustedContent; // If this binding is installed on an element
   1.101 +                                  // in an untrusted scope, should this
   1.102 +                                  // implementation member be accessible to the
   1.103 +                                  // content?
   1.104 +};
   1.105 +
   1.106 +#endif // nsXBLProtoImplMember_h__

mercurial