зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1511276 - Add UserAgentStyleSheetList.h and use it to simplify nsLayoutStylesheetCache. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D13585 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
55fdbb742f
Коммит
e7bc28da03
|
@ -0,0 +1,35 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
/* list of user agent style sheets that nsLayoutStylesheetCache manages */
|
||||
|
||||
/*
|
||||
* STYLE_SHEET(identifier_, url_, lazy_)
|
||||
*
|
||||
* identifier_
|
||||
* An identifier for the style sheet, suitable for use as an enum class value.
|
||||
*
|
||||
* url_
|
||||
* The URL of the style sheet.
|
||||
*
|
||||
* lazy_
|
||||
* A boolean indicating whether the sheet is loaded lazily.
|
||||
*/
|
||||
|
||||
STYLE_SHEET(ContentEditable, "resource://gre/res/contenteditable.css", true)
|
||||
STYLE_SHEET(CounterStyles, "resource://gre-resources/counterstyles.css", false)
|
||||
STYLE_SHEET(DesignMode, "resource://gre/res/designmode.css", true)
|
||||
STYLE_SHEET(Forms, "resource://gre-resources/forms.css", true)
|
||||
STYLE_SHEET(HTML, "resource://gre-resources/html.css", false)
|
||||
STYLE_SHEET(MathML, "resource://gre-resources/mathml.css", true)
|
||||
STYLE_SHEET(MinimalXUL, "chrome://global/content/minimal-xul.css", false)
|
||||
STYLE_SHEET(NoFrames, "resource://gre-resources/noframes.css", true)
|
||||
STYLE_SHEET(NoScript, "resource://gre-resources/noscript.css", true)
|
||||
STYLE_SHEET(Quirk, "resource://gre-resources/quirk.css", false)
|
||||
STYLE_SHEET(Scrollbars, "chrome://global/skin/scrollbars.css", true)
|
||||
STYLE_SHEET(SVG, "resource://gre/res/svg.css", false)
|
||||
STYLE_SHEET(UA, "resource://gre-resources/ua.css", true)
|
||||
STYLE_SHEET(XUL, "chrome://global/content/xul.css", true)
|
|
@ -112,6 +112,7 @@ EXPORTS.mozilla += [
|
|||
'StyleSheetInfo.h',
|
||||
'StyleSheetInlines.h',
|
||||
'URLExtraData.h',
|
||||
'UserAgentStyleSheetList.h',
|
||||
]
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
|
|
|
@ -59,25 +59,15 @@ nsresult nsLayoutStylesheetCache::Observe(nsISupports* aSubject,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::ScrollbarsSheet() {
|
||||
if (!mScrollbarsSheet) {
|
||||
// Scrollbars don't need access to unsafe rules
|
||||
LoadSheetURL("chrome://global/skin/scrollbars.css", &mScrollbarsSheet,
|
||||
eSafeAgentSheetFeatures, eCrash);
|
||||
#define STYLE_SHEET(identifier_, url_, lazy_) \
|
||||
StyleSheet* nsLayoutStylesheetCache::identifier_##Sheet() { \
|
||||
if (lazy_ && !m##identifier_##Sheet) { \
|
||||
LoadSheetURL(url_, &m##identifier_##Sheet, eAgentSheetFeatures, eCrash); \
|
||||
} \
|
||||
return m##identifier_##Sheet; \
|
||||
}
|
||||
|
||||
return mScrollbarsSheet;
|
||||
}
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::FormsSheet() {
|
||||
if (!mFormsSheet) {
|
||||
// forms.css needs access to unsafe rules
|
||||
LoadSheetURL("resource://gre-resources/forms.css", &mFormsSheet,
|
||||
eAgentSheetFeatures, eCrash);
|
||||
}
|
||||
|
||||
return mFormsSheet;
|
||||
}
|
||||
#include "mozilla/UserAgentStyleSheetList.h"
|
||||
#undef STYLE_SHEET
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::UserContentSheet() {
|
||||
return mUserContentSheet;
|
||||
|
@ -87,65 +77,6 @@ StyleSheet* nsLayoutStylesheetCache::UserChromeSheet() {
|
|||
return mUserChromeSheet;
|
||||
}
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::UASheet() {
|
||||
if (!mUASheet) {
|
||||
LoadSheetURL("resource://gre-resources/ua.css", &mUASheet,
|
||||
eAgentSheetFeatures, eCrash);
|
||||
}
|
||||
|
||||
return mUASheet;
|
||||
}
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::HTMLSheet() { return mHTMLSheet; }
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::MinimalXULSheet() {
|
||||
return mMinimalXULSheet;
|
||||
}
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::XULSheet() {
|
||||
if (!mXULSheet) {
|
||||
LoadSheetURL("chrome://global/content/xul.css", &mXULSheet,
|
||||
eAgentSheetFeatures, eCrash);
|
||||
}
|
||||
|
||||
return mXULSheet;
|
||||
}
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::QuirkSheet() { return mQuirkSheet; }
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::SVGSheet() { return mSVGSheet; }
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::MathMLSheet() {
|
||||
if (!mMathMLSheet) {
|
||||
LoadSheetURL("resource://gre-resources/mathml.css", &mMathMLSheet,
|
||||
eAgentSheetFeatures, eCrash);
|
||||
}
|
||||
|
||||
return mMathMLSheet;
|
||||
}
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::CounterStylesSheet() {
|
||||
return mCounterStylesSheet;
|
||||
}
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::NoScriptSheet() {
|
||||
if (!mNoScriptSheet) {
|
||||
LoadSheetURL("resource://gre-resources/noscript.css", &mNoScriptSheet,
|
||||
eAgentSheetFeatures, eCrash);
|
||||
}
|
||||
|
||||
return mNoScriptSheet;
|
||||
}
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::NoFramesSheet() {
|
||||
if (!mNoFramesSheet) {
|
||||
LoadSheetURL("resource://gre-resources/noframes.css", &mNoFramesSheet,
|
||||
eAgentSheetFeatures, eCrash);
|
||||
}
|
||||
|
||||
return mNoFramesSheet;
|
||||
}
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::ChromePreferenceSheet(
|
||||
nsPresContext* aPresContext) {
|
||||
if (!mChromePreferenceSheet) {
|
||||
|
@ -164,24 +95,6 @@ StyleSheet* nsLayoutStylesheetCache::ContentPreferenceSheet(
|
|||
return mContentPreferenceSheet;
|
||||
}
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::ContentEditableSheet() {
|
||||
if (!mContentEditableSheet) {
|
||||
LoadSheetURL("resource://gre/res/contenteditable.css",
|
||||
&mContentEditableSheet, eAgentSheetFeatures, eCrash);
|
||||
}
|
||||
|
||||
return mContentEditableSheet;
|
||||
}
|
||||
|
||||
StyleSheet* nsLayoutStylesheetCache::DesignModeSheet() {
|
||||
if (!mDesignModeSheet) {
|
||||
LoadSheetURL("resource://gre/res/designmode.css", &mDesignModeSheet,
|
||||
eAgentSheetFeatures, eCrash);
|
||||
}
|
||||
|
||||
return mDesignModeSheet;
|
||||
}
|
||||
|
||||
void nsLayoutStylesheetCache::Shutdown() {
|
||||
gCSSLoader = nullptr;
|
||||
NS_WARNING_ASSERTION(!gStyleCache || !gUserContentSheetURL,
|
||||
|
@ -214,24 +127,14 @@ size_t nsLayoutStylesheetCache::SizeOfIncludingThis(
|
|||
|
||||
#define MEASURE(s) n += s ? s->SizeOfIncludingThis(aMallocSizeOf) : 0;
|
||||
|
||||
#define STYLE_SHEET(identifier_, url_, lazy_) MEASURE(m##identifier_##Sheet);
|
||||
#include "mozilla/UserAgentStyleSheetList.h"
|
||||
#undef STYLE_SHEET
|
||||
|
||||
MEASURE(mChromePreferenceSheet);
|
||||
MEASURE(mContentEditableSheet);
|
||||
MEASURE(mContentPreferenceSheet);
|
||||
MEASURE(mCounterStylesSheet);
|
||||
MEASURE(mDesignModeSheet);
|
||||
MEASURE(mFormsSheet);
|
||||
MEASURE(mHTMLSheet);
|
||||
MEASURE(mMathMLSheet);
|
||||
MEASURE(mMinimalXULSheet);
|
||||
MEASURE(mNoFramesSheet);
|
||||
MEASURE(mNoScriptSheet);
|
||||
MEASURE(mQuirkSheet);
|
||||
MEASURE(mSVGSheet);
|
||||
MEASURE(mScrollbarsSheet);
|
||||
MEASURE(mUASheet);
|
||||
MEASURE(mUserChromeSheet);
|
||||
MEASURE(mUserContentSheet);
|
||||
MEASURE(mXULSheet);
|
||||
|
||||
// Measurement of the following members may be added later if DMD finds it is
|
||||
// worthwhile:
|
||||
|
@ -255,16 +158,13 @@ nsLayoutStylesheetCache::nsLayoutStylesheetCache() {
|
|||
|
||||
// And make sure that we load our UA sheets. No need to do this
|
||||
// per-profile, since they're profile-invariant.
|
||||
LoadSheetURL("resource://gre-resources/counterstyles.css",
|
||||
&mCounterStylesSheet, eAgentSheetFeatures, eCrash);
|
||||
LoadSheetURL("resource://gre-resources/html.css", &mHTMLSheet,
|
||||
eAgentSheetFeatures, eCrash);
|
||||
LoadSheetURL("chrome://global/content/minimal-xul.css", &mMinimalXULSheet,
|
||||
eAgentSheetFeatures, eCrash);
|
||||
LoadSheetURL("resource://gre-resources/quirk.css", &mQuirkSheet,
|
||||
eAgentSheetFeatures, eCrash);
|
||||
LoadSheetURL("resource://gre/res/svg.css", &mSVGSheet, eAgentSheetFeatures,
|
||||
eCrash);
|
||||
#define STYLE_SHEET(identifier_, url_, lazy_) \
|
||||
if (!lazy_) { \
|
||||
LoadSheetURL(url_, &m##identifier_##Sheet, eAgentSheetFeatures, eCrash); \
|
||||
}
|
||||
#include "mozilla/UserAgentStyleSheetList.h"
|
||||
#undef STYLE_SHEET
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
// We know we need xul.css for the UI, so load that now too:
|
||||
XULSheet();
|
||||
|
|
|
@ -38,24 +38,15 @@ class nsLayoutStylesheetCache final : public nsIObserver,
|
|||
|
||||
static nsLayoutStylesheetCache* Singleton();
|
||||
|
||||
mozilla::StyleSheet* ScrollbarsSheet();
|
||||
mozilla::StyleSheet* FormsSheet();
|
||||
#define STYLE_SHEET(identifier_, url_, lazy_) \
|
||||
mozilla::StyleSheet* identifier_##Sheet();
|
||||
#include "mozilla/UserAgentStyleSheetList.h"
|
||||
#undef STYLE_SHEET
|
||||
|
||||
mozilla::StyleSheet* UserContentSheet();
|
||||
mozilla::StyleSheet* UserChromeSheet();
|
||||
mozilla::StyleSheet* UASheet();
|
||||
mozilla::StyleSheet* HTMLSheet();
|
||||
mozilla::StyleSheet* MinimalXULSheet();
|
||||
mozilla::StyleSheet* XULSheet();
|
||||
mozilla::StyleSheet* QuirkSheet();
|
||||
mozilla::StyleSheet* SVGSheet();
|
||||
mozilla::StyleSheet* MathMLSheet();
|
||||
mozilla::StyleSheet* CounterStylesSheet();
|
||||
mozilla::StyleSheet* NoScriptSheet();
|
||||
mozilla::StyleSheet* NoFramesSheet();
|
||||
mozilla::StyleSheet* ChromePreferenceSheet(nsPresContext* aPresContext);
|
||||
mozilla::StyleSheet* ContentPreferenceSheet(nsPresContext* aPresContext);
|
||||
mozilla::StyleSheet* ContentEditableSheet();
|
||||
mozilla::StyleSheet* DesignModeSheet();
|
||||
|
||||
static void InvalidatePreferenceSheets();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче