dom/xbl/nsXBLProtoImplMember.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 nsXBLProtoImplMember_h__
     7 #define nsXBLProtoImplMember_h__
     9 #include "nsIAtom.h"
    10 #include "nsString.h"
    11 #include "nsString.h"
    12 #include "nsIServiceManager.h"
    13 #include "nsContentUtils.h" // For NS_CONTENT_DELETE_LIST_MEMBER.
    14 #include "nsCycleCollectionParticipant.h"
    16 class nsIContent;
    17 class nsIObjectOutputStream;
    19 struct nsXBLTextWithLineNumber
    20 {
    21   char16_t* mText;
    22   uint32_t mLineNumber;
    24   nsXBLTextWithLineNumber() :
    25     mText(nullptr),
    26     mLineNumber(0)
    27   {
    28     MOZ_COUNT_CTOR(nsXBLTextWithLineNumber);
    29   }
    31   ~nsXBLTextWithLineNumber() {
    32     MOZ_COUNT_DTOR(nsXBLTextWithLineNumber);
    33     if (mText) {
    34       nsMemory::Free(mText);
    35     }
    36   }
    38   void AppendText(const nsAString& aText) {
    39     if (mText) {
    40       char16_t* temp = mText;
    41       mText = ToNewUnicode(nsDependentString(temp) + aText);
    42       nsMemory::Free(temp);
    43     } else {
    44       mText = ToNewUnicode(aText);
    45     }
    46   }
    48   char16_t* GetText() {
    49     return mText;
    50   }
    52   void SetLineNumber(uint32_t aLineNumber) {
    53     mLineNumber = aLineNumber;
    54   }
    56   uint32_t GetLineNumber() {
    57     return mLineNumber;
    58   }
    59 };
    61 class nsXBLProtoImplMember
    62 {
    63 public:
    64   nsXBLProtoImplMember(const char16_t* aName)
    65     : mNext(nullptr)
    66     , mExposeToUntrustedContent(false)
    67   {
    68     mName = ToNewUnicode(nsDependentString(aName));
    69   }
    70   virtual ~nsXBLProtoImplMember() {
    71     nsMemory::Free(mName);
    72     NS_CONTENT_DELETE_LIST_MEMBER(nsXBLProtoImplMember, this, mNext);
    73   }
    75   nsXBLProtoImplMember* GetNext() { return mNext; }
    76   void SetNext(nsXBLProtoImplMember* aNext) { mNext = aNext; }
    77   bool ShouldExposeToUntrustedContent() { return mExposeToUntrustedContent; }
    78   void SetExposeToUntrustedContent(bool aExpose) { mExposeToUntrustedContent = aExpose; }
    79   const char16_t* GetName() { return mName; }
    81   virtual nsresult InstallMember(JSContext* aCx,
    82                                  JS::Handle<JSObject*> aTargetClassObject) = 0;
    83   virtual nsresult CompileMember(const nsCString& aClassStr,
    84                                  JS::Handle<JSObject*> aClassObject) = 0;
    86   virtual void Trace(const TraceCallbacks& aCallbacks, void *aClosure) = 0;
    88   virtual nsresult Write(nsIObjectOutputStream* aStream)
    89   {
    90     return NS_OK;
    91   }
    93 protected:
    94   nsXBLProtoImplMember* mNext;  // The members of an implementation are chained.
    95   char16_t* mName;               // The name of the field, method, or property.
    97   bool mExposeToUntrustedContent; // If this binding is installed on an element
    98                                   // in an untrusted scope, should this
    99                                   // implementation member be accessible to the
   100                                   // content?
   101 };
   103 #endif // nsXBLProtoImplMember_h__

mercurial