nsXBLProtoImplField.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* -*- Mode: C++; tab-width: 8; 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/. */
  5. #ifndef nsXBLProtoImplField_h__
  6. #define nsXBLProtoImplField_h__
  7. #include "nsIAtom.h"
  8. #include "nsString.h"
  9. #include "jsapi.h"
  10. #include "nsString.h"
  11. #include "nsXBLProtoImplMember.h"
  12. class nsIObjectInputStream;
  13. class nsIObjectOutputStream;
  14. class nsIURI;
  15. class nsXBLProtoImplField
  16. {
  17. public:
  18. nsXBLProtoImplField(const char16_t* aName, const char16_t* aReadOnly);
  19. explicit nsXBLProtoImplField(const bool aIsReadOnly);
  20. ~nsXBLProtoImplField();
  21. void AppendFieldText(const nsAString& aText);
  22. void SetLineNumber(uint32_t aLineNumber) {
  23. mLineNumber = aLineNumber;
  24. }
  25. nsXBLProtoImplField* GetNext() const { return mNext; }
  26. void SetNext(nsXBLProtoImplField* aNext) { mNext = aNext; }
  27. nsresult InstallField(JS::Handle<JSObject*> aBoundNode,
  28. nsIURI* aBindingDocURI,
  29. bool* aDidInstall) const;
  30. nsresult InstallAccessors(JSContext* aCx,
  31. JS::Handle<JSObject*> aTargetClassObject);
  32. nsresult Read(nsIObjectInputStream* aStream);
  33. nsresult Write(nsIObjectOutputStream* aStream);
  34. const char16_t* GetName() const { return mName; }
  35. unsigned AccessorAttributes() const {
  36. return JSPROP_SHARED | JSPROP_GETTER | JSPROP_SETTER |
  37. (mJSAttributes & (JSPROP_ENUMERATE | JSPROP_PERMANENT));
  38. }
  39. bool IsEmpty() const { return mFieldTextLength == 0; }
  40. protected:
  41. nsXBLProtoImplField* mNext;
  42. char16_t* mName;
  43. char16_t* mFieldText;
  44. uint32_t mFieldTextLength;
  45. uint32_t mLineNumber;
  46. unsigned mJSAttributes;
  47. };
  48. #endif // nsXBLProtoImplField_h__