2013-01-18 04:45:12 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2005-01-15 03:10:19 +03:00
|
|
|
|
2006-03-30 09:56:38 +04:00
|
|
|
/* implementation of interface for managing user and user-agent style sheets */
|
|
|
|
|
2005-01-15 03:10:19 +03:00
|
|
|
#ifndef nsStyleSheetService_h_
|
|
|
|
#define nsStyleSheetService_h_
|
|
|
|
|
2013-11-07 09:35:30 +04:00
|
|
|
#include "nsIMemoryReporter.h"
|
2013-01-18 04:45:12 +04:00
|
|
|
#include "nsIStyleSheetService.h"
|
2017-02-21 05:42:27 +03:00
|
|
|
#include "mozilla/Array.h"
|
2012-06-19 07:26:34 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2016-09-26 15:03:25 +03:00
|
|
|
#include "mozilla/StyleSheet.h"
|
2005-01-15 03:10:19 +03:00
|
|
|
|
2013-01-18 04:45:12 +04:00
|
|
|
class nsISimpleEnumerator;
|
2005-01-15 03:10:19 +03:00
|
|
|
|
2019-04-16 10:25:10 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class PresShell;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2005-01-15 03:10:19 +03:00
|
|
|
#define NS_STYLESHEETSERVICE_CID \
|
2018-11-30 13:46:48 +03:00
|
|
|
{ \
|
2015-11-17 09:04:09 +03:00
|
|
|
0x3b55e72e, 0xab7e, 0x431b, { \
|
|
|
|
0x89, 0xc0, 0x3b, 0x06, 0xa8, 0xb1, 0x40, 0x16 \
|
|
|
|
} \
|
|
|
|
}
|
2005-01-15 03:10:19 +03:00
|
|
|
|
|
|
|
#define NS_STYLESHEETSERVICE_CONTRACTID \
|
|
|
|
"@mozilla.org/content/style-sheet-service;1"
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsStyleSheetService final : public nsIStyleSheetService,
|
2013-12-08 10:09:10 +04:00
|
|
|
public nsIMemoryReporter {
|
2017-02-21 05:42:27 +03:00
|
|
|
public:
|
|
|
|
typedef nsTArray<RefPtr<mozilla::StyleSheet>> SheetArray;
|
|
|
|
|
2014-06-02 16:08:24 +04:00
|
|
|
nsStyleSheetService();
|
2005-01-15 03:10:19 +03:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISTYLESHEETSERVICE
|
2013-12-08 10:09:10 +04:00
|
|
|
NS_DECL_NSIMEMORYREPORTER
|
2005-01-15 03:10:19 +03:00
|
|
|
|
2014-06-02 16:08:21 +04:00
|
|
|
nsresult Init();
|
2005-01-15 03:10:19 +03:00
|
|
|
|
2018-03-28 18:34:34 +03:00
|
|
|
SheetArray* AgentStyleSheets() { return &mSheets[AGENT_SHEET]; }
|
|
|
|
SheetArray* UserStyleSheets() { return &mSheets[USER_SHEET]; }
|
|
|
|
SheetArray* AuthorStyleSheets() { return &mSheets[AUTHOR_SHEET]; }
|
2005-01-15 03:10:19 +03:00
|
|
|
|
2019-04-16 10:25:10 +03:00
|
|
|
void RegisterPresShell(mozilla::PresShell* aPresShell);
|
|
|
|
void UnregisterPresShell(mozilla::PresShell* aPresShell);
|
2017-02-17 10:56:28 +03:00
|
|
|
|
2013-01-18 04:45:12 +04:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-10-12 08:05:38 +04:00
|
|
|
|
2012-10-16 23:45:56 +04:00
|
|
|
static nsStyleSheetService* GetInstance();
|
2005-01-15 03:10:19 +03:00
|
|
|
static nsStyleSheetService* gInstance;
|
|
|
|
|
2017-02-21 05:42:27 +03:00
|
|
|
private:
|
2014-06-24 02:40:01 +04:00
|
|
|
~nsStyleSheetService();
|
2005-01-15 03:10:19 +03:00
|
|
|
|
2018-03-28 18:34:34 +03:00
|
|
|
int32_t FindSheetByURI(uint32_t aSheetType, nsIURI* aSheetURI);
|
2005-03-23 05:34:30 +03:00
|
|
|
|
2009-07-27 12:47:02 +04:00
|
|
|
// Like LoadAndRegisterSheet, but doesn't notify. If successful, the
|
2006-06-08 18:32:20 +04:00
|
|
|
// new sheet will be the last sheet in mSheets[aSheetType].
|
2014-06-02 16:08:21 +04:00
|
|
|
nsresult LoadAndRegisterSheetInternal(nsIURI* aSheetURI, uint32_t aSheetType);
|
2012-10-12 08:05:38 +04:00
|
|
|
|
2018-03-28 18:34:34 +03:00
|
|
|
mozilla::Array<SheetArray, 3> mSheets;
|
2017-02-17 10:56:28 +03:00
|
|
|
|
|
|
|
// Registered PresShells that will be notified when sheets are added and
|
|
|
|
// removed from the style sheet service.
|
2019-04-16 10:25:10 +03:00
|
|
|
nsTArray<RefPtr<mozilla::PresShell>> mPresShells;
|
2005-01-15 03:10:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|