michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=8 sts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* implementation of interface for managing user and user-agent style sheets */ michael@0: michael@0: #ifndef nsStyleSheetService_h_ michael@0: #define nsStyleSheetService_h_ michael@0: michael@0: #include "nsCOMArray.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsIMemoryReporter.h" michael@0: #include "nsIStyleSheetService.h" michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/MemoryReporting.h" michael@0: michael@0: class nsICategoryManager; michael@0: class nsIMemoryReporter; michael@0: class nsISimpleEnumerator; michael@0: class nsIStyleSheet; michael@0: michael@0: #define NS_STYLESHEETSERVICE_CID \ michael@0: {0xfcca6f83, 0x9f7d, 0x44e4, {0xa7, 0x4b, 0xb5, 0x94, 0x33, 0xe6, 0xc8, 0xc3}} michael@0: michael@0: #define NS_STYLESHEETSERVICE_CONTRACTID \ michael@0: "@mozilla.org/content/style-sheet-service;1" michael@0: michael@0: class nsStyleSheetService MOZ_FINAL michael@0: : public nsIStyleSheetService michael@0: , public nsIMemoryReporter michael@0: { michael@0: public: michael@0: nsStyleSheetService() NS_HIDDEN; michael@0: ~nsStyleSheetService() NS_HIDDEN; michael@0: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSISTYLESHEETSERVICE michael@0: NS_DECL_NSIMEMORYREPORTER michael@0: michael@0: NS_HIDDEN_(nsresult) Init(); michael@0: michael@0: nsCOMArray* AgentStyleSheets() { return &mSheets[AGENT_SHEET]; } michael@0: nsCOMArray* UserStyleSheets() { return &mSheets[USER_SHEET]; } michael@0: nsCOMArray* AuthorStyleSheets() { return &mSheets[AUTHOR_SHEET]; } michael@0: michael@0: size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; michael@0: michael@0: static nsStyleSheetService *GetInstance(); michael@0: static nsStyleSheetService *gInstance; michael@0: michael@0: private: michael@0: michael@0: NS_HIDDEN_(void) RegisterFromEnumerator(nsICategoryManager *aManager, michael@0: const char *aCategory, michael@0: nsISimpleEnumerator *aEnumerator, michael@0: uint32_t aSheetType); michael@0: michael@0: NS_HIDDEN_(int32_t) FindSheetByURI(const nsCOMArray &sheets, michael@0: nsIURI *sheetURI); michael@0: michael@0: // Like LoadAndRegisterSheet, but doesn't notify. If successful, the michael@0: // new sheet will be the last sheet in mSheets[aSheetType]. michael@0: NS_HIDDEN_(nsresult) LoadAndRegisterSheetInternal(nsIURI *aSheetURI, michael@0: uint32_t aSheetType); michael@0: michael@0: nsCOMArray mSheets[3]; michael@0: }; michael@0: michael@0: #endif