Bug 1420229 - Create a new components.css file and load it as a UA stylesheet;r=bz,r=Gijs
This provides a place for current XBL stylesheets to be loaded without using XBL <resources>,
that load as a UA sheet instead of loading them as document sheets. This makes the styles
apply more similarly to XBL, in that they are less specific than document styles.
MozReview-Commit-ID: 3ewomJZMbrk
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -2433,16 +2433,22 @@ nsDocumentViewer::CreateStyleSet(nsIDocu
}
sheet = cache->FormsSheet();
if (sheet) {
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
}
if (aDocument->LoadsFullXULStyleSheetUpFront()) {
+ // This is the only place components.css gets loaded, unlike xul.css
+ sheet = cache->XULComponentsSheet();
+ if (sheet) {
+ styleSet->PrependStyleSheet(SheetType::Agent, sheet);
+ }
+
// nsXULElement::BindToTree loads xul.css on-demand if we don't load it
// up-front here.
sheet = cache->XULSheet();
if (sheet) {
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
}
}
--- a/layout/style/nsLayoutStylesheetCache.cpp
+++ b/layout/style/nsLayoutStylesheetCache.cpp
@@ -152,16 +152,27 @@ nsLayoutStylesheetCache::XULSheet()
LoadSheetURL("chrome://global/content/xul.css",
&mXULSheet, eAgentSheetFeatures, eCrash);
}
return mXULSheet;
}
StyleSheet*
+nsLayoutStylesheetCache::XULComponentsSheet()
+{
+ if (!mXULComponentsSheet) {
+ LoadSheetURL("chrome://global/content/components.css",
+ &mXULComponentsSheet, eAgentSheetFeatures, eCrash);
+ }
+
+ return mXULComponentsSheet;
+}
+
+StyleSheet*
nsLayoutStylesheetCache::QuirkSheet()
{
return mQuirkSheet;
}
StyleSheet*
nsLayoutStylesheetCache::SVGSheet()
{
@@ -308,16 +319,17 @@ nsLayoutStylesheetCache::SizeOfIncluding
MEASURE(mNumberControlSheet);
MEASURE(mQuirkSheet);
MEASURE(mSVGSheet);
MEASURE(mScrollbarsSheet);
MEASURE(mUASheet);
MEASURE(mUserChromeSheet);
MEASURE(mUserContentSheet);
MEASURE(mXULSheet);
+ MEASURE(mXULComponentsSheet);
// Measurement of the following members may be added later if DMD finds it is
// worthwhile:
// - gCSSLoader_Gecko
// - gCSSLoader_Servo
return n;
}
@@ -348,16 +360,17 @@ nsLayoutStylesheetCache::nsLayoutStylesh
&mMinimalXULSheet, eAgentSheetFeatures, eCrash);
LoadSheetURL("resource://gre-resources/quirk.css",
&mQuirkSheet, eAgentSheetFeatures, eCrash);
LoadSheetURL("resource://gre/res/svg.css",
&mSVGSheet, eAgentSheetFeatures, eCrash);
if (XRE_IsParentProcess()) {
// We know we need xul.css for the UI, so load that now too:
XULSheet();
+ XULComponentsSheet();
}
auto& userContentSheetURL = aType == StyleBackendType::Gecko ?
gUserContentSheetURL_Gecko :
gUserContentSheetURL_Servo;
if (userContentSheetURL) {
MOZ_ASSERT(XRE_IsContentProcess(), "Only used in content processes.");
LoadSheet(userContentSheetURL, &mUserContentSheet, eUserSheetFeatures, eLogToConsole);
--- a/layout/style/nsLayoutStylesheetCache.h
+++ b/layout/style/nsLayoutStylesheetCache.h
@@ -58,16 +58,17 @@ class nsLayoutStylesheetCache final
// pref is disabled.
mozilla::StyleSheet* NumberControlSheet();
mozilla::StyleSheet* UserContentSheet();
mozilla::StyleSheet* UserChromeSheet();
mozilla::StyleSheet* UASheet();
mozilla::StyleSheet* HTMLSheet();
mozilla::StyleSheet* MinimalXULSheet();
mozilla::StyleSheet* XULSheet();
+ mozilla::StyleSheet* XULComponentsSheet();
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);
@@ -126,11 +127,12 @@ private:
RefPtr<mozilla::StyleSheet> mNumberControlSheet;
RefPtr<mozilla::StyleSheet> mQuirkSheet;
RefPtr<mozilla::StyleSheet> mSVGSheet;
RefPtr<mozilla::StyleSheet> mScrollbarsSheet;
RefPtr<mozilla::StyleSheet> mUASheet;
RefPtr<mozilla::StyleSheet> mUserChromeSheet;
RefPtr<mozilla::StyleSheet> mUserContentSheet;
RefPtr<mozilla::StyleSheet> mXULSheet;
+ RefPtr<mozilla::StyleSheet> mXULComponentsSheet;
};
#endif
new file mode 100644
--- /dev/null
+++ b/toolkit/content/components.css
@@ -0,0 +1,9 @@
+/* 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/. */
+
+/* ===== components.css =================================================
+ == Styles ported from XBL <resources>, loaded as UA styles in every XUL doc
+ ======================================================================= */
+
+@import url("chrome://global/skin/menu.css");
--- a/toolkit/content/jar.mn
+++ b/toolkit/content/jar.mn
@@ -1,14 +1,15 @@
toolkit.jar:
% content global %content/global/ contentaccessible=yes
* content/global/license.html
content/global/XPCNativeWrapper.js
content/global/minimal-xul.css
* content/global/xul.css
+ content/global/components.css
content/global/textbox.css
content/global/menulist.css
content/global/autocomplete.css
content/global/aboutAbout.js
content/global/aboutAbout.xhtml
#ifdef MOZILLA_OFFICIAL
content/global/aboutRights.xhtml
#else
--- a/toolkit/themes/linux/global/global.css
+++ b/toolkit/themes/linux/global/global.css
@@ -3,17 +3,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* ===== global.css =====================================================
== Styles that apply everywhere.
======================================================================= */
/* all localizable skin settings shall live here */
@import url("chrome://global/locale/intl.css");
-@import url("chrome://global/skin/menu.css");
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* ::::: XBL bindings ::::: */
menulist > menupopup {
-moz-binding: url("chrome://global/content/bindings/popup.xml#popup-scrollbars");
}
--- a/toolkit/themes/osx/global/global.css
+++ b/toolkit/themes/osx/global/global.css
@@ -1,15 +1,14 @@
/* 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/. */
/* all localizable skin settings shall live here */
@import url("chrome://global/locale/intl.css");
-@import url("chrome://global/skin/menu.css");
%include shared.inc
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* ::::: XBL bindings ::::: */
menulist > menupopup {
-moz-binding: url("chrome://global/content/bindings/popup.xml#popup-scrollbars");
--- a/toolkit/themes/windows/global/global.css
+++ b/toolkit/themes/windows/global/global.css
@@ -3,17 +3,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* ===== global.css =====================================================
== Styles that apply everywhere.
======================================================================= */
/* all localizable skin settings shall live here */
@import url("chrome://global/locale/intl.css");
-@import url("chrome://global/skin/menu.css");
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* ::::: XBL bindings ::::: */
menulist > menupopup {
-moz-binding: url("chrome://global/content/bindings/popup.xml#popup-scrollbars");
}