Revert "Bug 1968202 - Generalize GlobalStyleSheetCache to support author stylesheets. r=smaug" for causing wpt failures in prefetch-transfer-size-executor.html.

This reverts commit e2ac38c2a8.
This commit is contained in:
Serban Stanca
2025-05-24 04:50:14 +03:00
committed by sstanca@mozilla.com
parent 0374590d23
commit 4c663869d9
18 changed files with 149 additions and 172 deletions

View File

@@ -997,8 +997,8 @@ class StyleSheetsManager extends EventEmitter {
// FIXME(bug 1826538): Make accessiblecaret.css and similar UA-widget // FIXME(bug 1826538): Make accessiblecaret.css and similar UA-widget
// sheets system sheets, then remove this special-case. // sheets system sheets, then remove this special-case.
if ( if (
href === "resource://gre-resources/accessiblecaret.css" || href === "resource://content-accessible/accessiblecaret.css" ||
href === "resource://gre-resources/details.css" || href === "resource://content-accessible/details.css" ||
(href === "resource://devtools-highlighter-styles/highlighters.css" && (href === "resource://devtools-highlighter-styles/highlighters.css" &&
this.#targetActor.sessionContext.type !== "all") this.#targetActor.sessionContext.type !== "all")
) { ) {

View File

@@ -23,7 +23,6 @@
#include "mozilla/dom/TrustedTypeUtils.h" #include "mozilla/dom/TrustedTypeUtils.h"
#include "mozilla/dom/TrustedTypesConstants.h" #include "mozilla/dom/TrustedTypesConstants.h"
#include "mozilla/dom/UnbindContext.h" #include "mozilla/dom/UnbindContext.h"
#include "mozilla/GlobalStyleSheetCache.h"
#include "mozilla/EventDispatcher.h" #include "mozilla/EventDispatcher.h"
#include "mozilla/IdentifierMapEntry.h" #include "mozilla/IdentifierMapEntry.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
@@ -549,15 +548,6 @@ void ShadowRoot::StyleSheetApplicableStateChanged(StyleSheet& aSheet) {
} }
} }
void ShadowRoot::AppendBuiltInStyleSheet(BuiltInStyleSheet aSheet) {
auto* cache = GlobalStyleSheetCache::Singleton();
// NOTE(emilio): It's important to Clone() the stylesheet to avoid leaking,
// since the built-in sheet is kept alive forever, and AppendStyleSheet will
// set the associated shadow root and global of the stylesheet.
RefPtr sheet = cache->BuiltInSheet(aSheet)->Clone(nullptr, nullptr);
AppendStyleSheet(*sheet);
}
void ShadowRoot::RemoveSheetFromStyles(StyleSheet& aSheet) { void ShadowRoot::RemoveSheetFromStyles(StyleSheet& aSheet) {
MOZ_ASSERT(aSheet.IsApplicable()); MOZ_ASSERT(aSheet.IsApplicable());
MOZ_ASSERT(mServoStyles); MOZ_ASSERT(mServoStyles);

View File

@@ -29,7 +29,6 @@ class EventChainPreVisitor;
class ServoStyleRuleMap; class ServoStyleRuleMap;
enum class StyleRuleChangeKind : uint32_t; enum class StyleRuleChangeKind : uint32_t;
enum class BuiltInStyleSheet : uint8_t;
namespace css { namespace css {
class Rule; class Rule;
@@ -99,9 +98,6 @@ class ShadowRoot final : public DocumentFragment, public DocumentOrShadowRoot {
void SheetCloned(StyleSheet&); void SheetCloned(StyleSheet&);
void StyleSheetApplicableStateChanged(StyleSheet&); void StyleSheetApplicableStateChanged(StyleSheet&);
// Adds a built-in author style-sheet to the shadow tree.
void AppendBuiltInStyleSheet(BuiltInStyleSheet);
/** /**
* Clones internal state, for example stylesheets, of aOther to 'this'. * Clones internal state, for example stylesheets, of aOther to 'this'.
*/ */

View File

@@ -101,7 +101,20 @@ void HTMLDetailsElement::SetupShadowTree() {
nsNodeInfoManager* nim = OwnerDoc()->NodeInfoManager(); nsNodeInfoManager* nim = OwnerDoc()->NodeInfoManager();
RefPtr<NodeInfo> slotNodeInfo = nim->GetNodeInfo( RefPtr<NodeInfo> slotNodeInfo = nim->GetNodeInfo(
nsGkAtoms::slot, nullptr, kNameSpaceID_XHTML, nsINode::ELEMENT_NODE); nsGkAtoms::slot, nullptr, kNameSpaceID_XHTML, nsINode::ELEMENT_NODE);
sr->AppendBuiltInStyleSheet(BuiltInStyleSheet::Details); {
RefPtr<NodeInfo> linkNodeInfo = nim->GetNodeInfo(
nsGkAtoms::link, nullptr, kNameSpaceID_XHTML, nsINode::ELEMENT_NODE);
RefPtr<nsGenericHTMLElement> link =
NS_NewHTMLLinkElement(linkNodeInfo.forget());
if (NS_WARN_IF(!link)) {
return;
}
link->SetAttr(nsGkAtoms::rel, u"stylesheet"_ns, IgnoreErrors());
link->SetAttr(nsGkAtoms::href,
u"resource://content-accessible/details.css"_ns,
IgnoreErrors());
sr->AppendChildTo(link, kNotify, IgnoreErrors());
}
{ {
RefPtr<nsGenericHTMLElement> slot = RefPtr<nsGenericHTMLElement> slot =
NS_NewHTMLSlotElement(do_AddRef(slotNodeInfo)); NS_NewHTMLSlotElement(do_AddRef(slotNodeInfo));

View File

@@ -8,7 +8,6 @@
#include "AccessibleCaretLogger.h" #include "AccessibleCaretLogger.h"
#include "mozilla/Assertions.h" #include "mozilla/Assertions.h"
#include "mozilla/BuiltInStyleSheets.h"
#include "mozilla/ErrorResult.h" #include "mozilla/ErrorResult.h"
#include "mozilla/FloatingPoint.h" #include "mozilla/FloatingPoint.h"
#include "mozilla/PresShell.h" #include "mozilla/PresShell.h"
@@ -204,6 +203,7 @@ void AccessibleCaret::CreateCaretElement() const {
// Content structure of AccessibleCaret // Content structure of AccessibleCaret
// <div class="moz-accessiblecaret"> <- CaretElement() // <div class="moz-accessiblecaret"> <- CaretElement()
// <#shadow-root> // <#shadow-root>
// <link rel="stylesheet" href="accessiblecaret.css">
// <div id="text-overlay"> <- TextOverlayElement() // <div id="text-overlay"> <- TextOverlayElement()
// <div id="image"> <- CaretImageElement() // <div id="image"> <- CaretImageElement()
@@ -215,7 +215,20 @@ void AccessibleCaret::CreateCaretElement() const {
ShadowRoot* root = mCaretElementHolder->Root(); ShadowRoot* root = mCaretElementHolder->Root();
Document* doc = host.OwnerDoc(); Document* doc = host.OwnerDoc();
root->AppendBuiltInStyleSheet(BuiltInStyleSheet::AccessibleCaret); {
RefPtr<NodeInfo> linkNodeInfo = doc->NodeInfoManager()->GetNodeInfo(
nsGkAtoms::link, nullptr, kNameSpaceID_XHTML, nsINode::ELEMENT_NODE);
RefPtr<nsGenericHTMLElement> link =
NS_NewHTMLLinkElement(linkNodeInfo.forget());
if (NS_WARN_IF(!link)) {
return;
}
link->SetAttr(nsGkAtoms::rel, u"stylesheet"_ns, IgnoreErrors());
link->SetAttr(nsGkAtoms::href,
u"resource://content-accessible/accessiblecaret.css"_ns,
IgnoreErrors());
root->AppendChildTo(link, kNotify, IgnoreErrors());
}
auto CreateAndAppendChildElement = [&](const nsLiteralString& aElementId) { auto CreateAndAppendChildElement = [&](const nsLiteralString& aElementId) {
RefPtr<Element> child = doc->CreateHTMLElement(nsGkAtoms::div); RefPtr<Element> child = doc->CreateHTMLElement(nsGkAtoms::div);

View File

@@ -41,7 +41,7 @@ async function testApplicableStateChangeEvent(testRoot) {
// accessiblecaret.css might be reported, interfering with the test // accessiblecaret.css might be reported, interfering with the test
// assertions, so let's ignore it // assertions, so let's ignore it
return ( return (
e.stylesheet?.href === "resource://gre-resources/accessiblecaret.css" e.stylesheet?.href === "resource://content-accessible/accessiblecaret.css"
); );
} }

View File

@@ -1,35 +0,0 @@
/* -*- 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 GlobalStyleSheetCache manages */
/*
* STYLE_SHEET(identifier_, url_, flags_)
*
* identifier_
* An identifier for the style sheet, suitable for use as an enum class value.
*
* url_
* The URL of the style sheet.
*
* flags_
* UserStyleSheetType indicating whether the sheet can be safely placed in
* shared memory, and the kind of sheet it is.
*/
STYLE_SHEET(ContentEditable, "resource://gre/res/contenteditable.css", UA)
STYLE_SHEET(CounterStyles, "resource://gre-resources/counterstyles.css", UA)
STYLE_SHEET(Forms, "resource://gre-resources/forms.css", UA)
STYLE_SHEET(HTML, "resource://gre-resources/html.css", UA)
STYLE_SHEET(MathML, "resource://gre-resources/mathml.css", UA)
STYLE_SHEET(NoFrames, "resource://gre-resources/noframes.css", UA)
STYLE_SHEET(Quirk, "resource://gre-resources/quirk.css", UA)
STYLE_SHEET(Scrollbars, "resource://gre-resources/scrollbars.css", UA)
STYLE_SHEET(SVG, "resource://gre/res/svg.css", UA)
STYLE_SHEET(UA, "resource://gre-resources/ua.css", UA)
STYLE_SHEET(XUL, "chrome://global/content/xul.css", UAUnshared)
STYLE_SHEET(AccessibleCaret, "resource://gre-resources/accessiblecaret.css", Author)
STYLE_SHEET(Details, "resource://gre-resources/details.css", Author)

View File

@@ -1,38 +0,0 @@
/* -*- 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/. */
/* an identifier for User Agent style sheets */
#ifndef mozilla_BuiltInStyleSheets_h
#define mozilla_BuiltInStyleSheets_h
#include <stdint.h>
#include "mozilla/TypedEnumBits.h"
namespace mozilla {
enum class BuiltInStyleSheetFlags : uint8_t {
UA = 1,
Author = 1 << 1,
// By default sheets are shared, except xul.css which we only need in the
// parent process.
NotShared = 1 << 2,
UAUnshared = (UA | NotShared),
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(BuiltInStyleSheetFlags);
enum class BuiltInStyleSheet : uint8_t {
#define STYLE_SHEET(identifier_, url_, flags_) identifier_,
#include "mozilla/BuiltInStyleSheetList.h"
#undef STYLE_SHEET
Count
};
} // namespace mozilla
#endif // mozilla_BuiltInStyleSheets_h

View File

@@ -19,7 +19,6 @@
#include "mozilla/dom/SRIMetadata.h" #include "mozilla/dom/SRIMetadata.h"
#include "mozilla/ipc/SharedMemoryHandle.h" #include "mozilla/ipc/SharedMemoryHandle.h"
#include "mozilla/ipc/SharedMemoryMapping.h" #include "mozilla/ipc/SharedMemoryMapping.h"
#include "mozilla/ServoBindings.h"
#include "MainThreadUtils.h" #include "MainThreadUtils.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsIConsoleService.h" #include "nsIConsoleService.h"
@@ -31,6 +30,8 @@
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "nsXULAppAPI.h" #include "nsXULAppAPI.h"
#include <mozilla/ServoBindings.h>
namespace mozilla { namespace mozilla {
// The GlobalStyleSheetCache is responsible for sharing user agent style sheet // The GlobalStyleSheetCache is responsible for sharing user agent style sheet
@@ -129,30 +130,15 @@ nsresult GlobalStyleSheetCache::Observe(nsISupports* aSubject,
return NS_OK; return NS_OK;
} }
static constexpr struct { #define STYLE_SHEET(identifier_, url_, shared_) \
nsLiteralCString mURL; NotNull<StyleSheet*> GlobalStyleSheetCache::identifier_##Sheet() { \
BuiltInStyleSheetFlags mFlags; if (!m##identifier_##Sheet) { \
} kBuiltInSheetInfo[] = { m##identifier_##Sheet = LoadSheetURL(url_, eAgentSheetFeatures, eCrash); \
#define STYLE_SHEET(identifier_, url_, flags_) \ } \
{nsLiteralCString(url_), BuiltInStyleSheetFlags::flags_}, return WrapNotNull(m##identifier_##Sheet); \
#include "mozilla/BuiltInStyleSheetList.h"
#undef STYLE_SHEET
};
NotNull<StyleSheet*> GlobalStyleSheetCache::BuiltInSheet(
BuiltInStyleSheet aSheet) {
auto& slot = mBuiltIns[aSheet];
if (!slot) {
const auto& info = kBuiltInSheetInfo[size_t(aSheet)];
const auto parsingMode = (info.mFlags & BuiltInStyleSheetFlags::UA)
? eAgentSheetFeatures
: eAuthorSheetFeatures;
MOZ_ASSERT(info.mFlags & BuiltInStyleSheetFlags::UA ||
info.mFlags & BuiltInStyleSheetFlags::Author);
slot = LoadSheetURL(info.mURL, parsingMode, eCrash);
} }
return WrapNotNull(slot); #include "mozilla/UserAgentStyleSheetList.h"
} #undef STYLE_SHEET
StyleSheet* GlobalStyleSheetCache::GetUserContentSheet() { StyleSheet* GlobalStyleSheetCache::GetUserContentSheet() {
return mUserContentSheet; return mUserContentSheet;
@@ -208,9 +194,9 @@ size_t GlobalStyleSheetCache::SizeOfIncludingThis(
#define MEASURE(s) n += s ? s->SizeOfIncludingThis(aMallocSizeOf) : 0; #define MEASURE(s) n += s ? s->SizeOfIncludingThis(aMallocSizeOf) : 0;
for (const auto& sheet : mBuiltIns) { #define STYLE_SHEET(identifier_, url_, shared_) MEASURE(m##identifier_##Sheet);
MEASURE(sheet); #include "mozilla/UserAgentStyleSheetList.h"
} #undef STYLE_SHEET
MEASURE(mUserChromeSheet); MEASURE(mUserChromeSheet);
MEASURE(mUserContentSheet); MEASURE(mUserContentSheet);
@@ -284,25 +270,21 @@ GlobalStyleSheetCache::GlobalStyleSheetCache() {
reinterpret_cast<const Header*>(sSharedMemory.data())) { reinterpret_cast<const Header*>(sSharedMemory.data())) {
MOZ_RELEASE_ASSERT(header->mMagic == Header::kMagic); MOZ_RELEASE_ASSERT(header->mMagic == Header::kMagic);
for (auto kind : MakeEnumeratedRange(BuiltInStyleSheet::Count)) { #define STYLE_SHEET(identifier_, url_, shared_) \
const auto& info = kBuiltInSheetInfo[size_t(kind)]; if (shared_) { \
if (info.mFlags & BuiltInStyleSheetFlags::NotShared) { LoadSheetFromSharedMemory(url_, &m##identifier_##Sheet, \
continue; eAgentSheetFeatures, header, \
} UserAgentStyleSheetID::identifier_); \
const auto parsingMode = (info.mFlags & BuiltInStyleSheetFlags::UA)
? eAgentSheetFeatures
: eAuthorSheetFeatures;
LoadSheetFromSharedMemory(info.mURL, &mBuiltIns[kind], parsingMode,
header, kind);
} }
#include "mozilla/UserAgentStyleSheetList.h"
#undef STYLE_SHEET
} }
} }
} }
void GlobalStyleSheetCache::LoadSheetFromSharedMemory( void GlobalStyleSheetCache::LoadSheetFromSharedMemory(
const nsACString& aURL, RefPtr<StyleSheet>* aSheet, const char* aURL, RefPtr<StyleSheet>* aSheet, SheetParsingMode aParsingMode,
SheetParsingMode aParsingMode, const Header* aHeader, const Header* aHeader, UserAgentStyleSheetID aSheetID) {
BuiltInStyleSheet aSheetID) {
auto i = size_t(aSheetID); auto i = size_t(aSheetID);
auto sheet = auto sheet =
@@ -395,20 +377,19 @@ void GlobalStyleSheetCache::InitSharedSheetsInParent() {
// Normally calling ToShared on UA sheets should not fail. It happens // Normally calling ToShared on UA sheets should not fail. It happens
// in practice in odd cases that seem like corrupted installations; see bug // in practice in odd cases that seem like corrupted installations; see bug
// 1621773. On failure, return early and fall back to non-shared sheets. // 1621773. On failure, return early and fall back to non-shared sheets.
for (auto kind : MakeEnumeratedRange(BuiltInStyleSheet::Count)) { #define STYLE_SHEET(identifier_, url_, shared_) \
auto i = size_t(kind); if (shared_) { \
const auto& info = kBuiltInSheetInfo[i]; StyleSheet* sheet = identifier_##Sheet(); \
if (info.mFlags & BuiltInStyleSheetFlags::NotShared) { size_t i = size_t(UserAgentStyleSheetID::identifier_); \
continue; URLExtraData::sShared[i] = sheet->URLData(); \
} header->mSheets[i] = sheet->ToShared(builder.get(), message); \
StyleSheet* sheet = BuiltInSheet(kind); if (!header->mSheets[i]) { \
URLExtraData::sShared[i] = sheet->URLData(); CrashReporter::AppendAppNotesToCrashReport("\n"_ns + message); \
header->mSheets[i] = sheet->ToShared(builder.get(), message); return; \
if (!header->mSheets[i]) { } \
CrashReporter::AppendAppNotesToCrashReport("\n"_ns + message);
return;
}
} }
#include "mozilla/UserAgentStyleSheetList.h"
#undef STYLE_SHEET
// Finished writing into the shared memory. Freeze it, so that a process // Finished writing into the shared memory. Freeze it, so that a process
// can't confuse other processes by changing the UA style sheet contents. // can't confuse other processes by changing the UA style sheet contents.
@@ -498,7 +479,7 @@ void GlobalStyleSheetCache::InitFromProfile() {
} }
RefPtr<StyleSheet> GlobalStyleSheetCache::LoadSheetURL( RefPtr<StyleSheet> GlobalStyleSheetCache::LoadSheetURL(
const nsACString& aURL, SheetParsingMode aParsingMode, const char* aURL, SheetParsingMode aParsingMode,
FailureAction aFailureAction) { FailureAction aFailureAction) {
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), aURL); NS_NewURI(getter_AddRefs(uri), aURL);

View File

@@ -10,11 +10,11 @@
#include "nsIMemoryReporter.h" #include "nsIMemoryReporter.h"
#include "nsIObserver.h" #include "nsIObserver.h"
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/BuiltInStyleSheets.h"
#include "mozilla/MemoryReporting.h" #include "mozilla/MemoryReporting.h"
#include "mozilla/PreferenceSheet.h" #include "mozilla/PreferenceSheet.h"
#include "mozilla/NotNull.h" #include "mozilla/NotNull.h"
#include "mozilla/StaticPtr.h" #include "mozilla/StaticPtr.h"
#include "mozilla/UserAgentStyleSheetID.h"
#include "mozilla/css/Loader.h" #include "mozilla/css/Loader.h"
#include "mozilla/ipc/SharedMemoryHandle.h" #include "mozilla/ipc/SharedMemoryHandle.h"
#include "mozilla/ipc/SharedMemoryMapping.h" #include "mozilla/ipc/SharedMemoryMapping.h"
@@ -43,15 +43,11 @@ class GlobalStyleSheetCache final : public nsIObserver,
static GlobalStyleSheetCache* Singleton(); static GlobalStyleSheetCache* Singleton();
#define STYLE_SHEET(identifier_, url_, flags_) \ #define STYLE_SHEET(identifier_, url_, shared_) \
NotNull<StyleSheet*> identifier_##Sheet() { \ NotNull<StyleSheet*> identifier_##Sheet();
return BuiltInSheet(BuiltInStyleSheet::identifier_); \ #include "mozilla/UserAgentStyleSheetList.h"
}
#include "mozilla/BuiltInStyleSheetList.h"
#undef STYLE_SHEET #undef STYLE_SHEET
NotNull<StyleSheet*> BuiltInSheet(BuiltInStyleSheet);
StyleSheet* GetUserContentSheet(); StyleSheet* GetUserContentSheet();
StyleSheet* GetUserChromeSheet(); StyleSheet* GetUserChromeSheet();
@@ -91,7 +87,7 @@ class GlobalStyleSheetCache final : public nsIObserver,
struct Header { struct Header {
static constexpr uint32_t kMagic = 0x55415353; static constexpr uint32_t kMagic = 0x55415353;
uint32_t mMagic; // Must be set to kMagic. uint32_t mMagic; // Must be set to kMagic.
const StyleLockedCssRules* mSheets[size_t(BuiltInStyleSheet::Count)]; const StyleLockedCssRules* mSheets[size_t(UserAgentStyleSheetID::Count)];
uint8_t mBuffer[1]; uint8_t mBuffer[1];
}; };
@@ -101,25 +97,25 @@ class GlobalStyleSheetCache final : public nsIObserver,
void InitFromProfile(); void InitFromProfile();
void InitSharedSheetsInParent(); void InitSharedSheetsInParent();
void InitMemoryReporter(); void InitMemoryReporter();
RefPtr<StyleSheet> LoadSheetURL(const nsACString& aURL, RefPtr<StyleSheet> LoadSheetURL(const char* aURL,
css::SheetParsingMode aParsingMode, css::SheetParsingMode aParsingMode,
css::FailureAction aFailureAction); css::FailureAction aFailureAction);
RefPtr<StyleSheet> LoadSheetFile(nsIFile* aFile, RefPtr<StyleSheet> LoadSheetFile(nsIFile* aFile,
css::SheetParsingMode aParsingMode); css::SheetParsingMode aParsingMode);
RefPtr<StyleSheet> LoadSheet(nsIURI* aURI, css::SheetParsingMode aParsingMode, RefPtr<StyleSheet> LoadSheet(nsIURI* aURI, css::SheetParsingMode aParsingMode,
css::FailureAction aFailureAction); css::FailureAction aFailureAction);
void LoadSheetFromSharedMemory(const nsACString& aURL, void LoadSheetFromSharedMemory(const char* aURL, RefPtr<StyleSheet>* aSheet,
RefPtr<StyleSheet>* aSheet,
css::SheetParsingMode, const Header*, css::SheetParsingMode, const Header*,
BuiltInStyleSheet); UserAgentStyleSheetID);
static StaticRefPtr<GlobalStyleSheetCache> gStyleCache; static StaticRefPtr<GlobalStyleSheetCache> gStyleCache;
static StaticRefPtr<css::Loader> gCSSLoader; static StaticRefPtr<css::Loader> gCSSLoader;
static StaticRefPtr<nsIURI> gUserContentSheetURL; static StaticRefPtr<nsIURI> gUserContentSheetURL;
EnumeratedArray<BuiltInStyleSheet, RefPtr<StyleSheet>, #define STYLE_SHEET(identifier_, url_, shared_) \
size_t(BuiltInStyleSheet::Count)> RefPtr<StyleSheet> m##identifier_##Sheet;
mBuiltIns; #include "mozilla/UserAgentStyleSheetList.h"
#undef STYLE_SHEET
RefPtr<StyleSheet> mUserChromeSheet; RefPtr<StyleSheet> mUserChromeSheet;
RefPtr<StyleSheet> mUserContentSheet; RefPtr<StyleSheet> mUserContentSheet;

View File

@@ -1510,7 +1510,10 @@ Loader::Completed Loader::ParseSheet(
} }
AUTO_PROFILER_LABEL_CATEGORY_PAIR_RELEVANT_FOR_JS(LAYOUT_CSSParsing); AUTO_PROFILER_LABEL_CATEGORY_PAIR_RELEVANT_FOR_JS(LAYOUT_CSSParsing);
// TODO(emilio): fix browser_css_cache.js to deal with accessiblecaret.css.
if (!loadData->mURI || !IsPrivilegedURI(loadData->mURI)) {
++mParsedSheetCount; ++mParsedSheetCount;
}
loadData->mIsBeingParsed = true; loadData->mIsBeingParsed = true;

View File

@@ -47,6 +47,6 @@ void URLExtraData::Shutdown() {
URLExtraData::~URLExtraData() = default; URLExtraData::~URLExtraData() = default;
StaticRefPtr<URLExtraData> StaticRefPtr<URLExtraData>
URLExtraData::sShared[size_t(BuiltInStyleSheet::Count)]; URLExtraData::sShared[size_t(UserAgentStyleSheetID::Count)];
} // namespace mozilla } // namespace mozilla

View File

@@ -12,7 +12,7 @@
#include <utility> #include <utility>
#include "mozilla/StaticPtr.h" #include "mozilla/StaticPtr.h"
#include "mozilla/BuiltInStyleSheets.h" #include "mozilla/UserAgentStyleSheetID.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIPrincipal.h" #include "nsIPrincipal.h"
#include "nsIReferrerInfo.h" #include "nsIReferrerInfo.h"
@@ -66,7 +66,8 @@ struct URLExtraData {
// URLExtraData objects that shared style sheets use a sheet ID index to // URLExtraData objects that shared style sheets use a sheet ID index to
// refer to. // refer to.
static StaticRefPtr<URLExtraData> sShared[size_t(BuiltInStyleSheet::Count)]; static StaticRefPtr<URLExtraData>
sShared[size_t(UserAgentStyleSheetID::Count)];
private: private:
~URLExtraData(); ~URLExtraData();

View File

@@ -0,0 +1,23 @@
/* -*- 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/. */
/* an identifier for User Agent style sheets */
#ifndef mozilla_UserAgentStyleSheetID_h
#define mozilla_UserAgentStyleSheetID_h
namespace mozilla {
enum class UserAgentStyleSheetID : uint8_t {
#define STYLE_SHEET(identifier_, url_, shared_) identifier_,
#include "mozilla/UserAgentStyleSheetList.h"
#undef STYLE_SHEET
Count
};
} // namespace mozilla
#endif // mozilla_UserAgentStyleSheetID_h

View File

@@ -0,0 +1,33 @@
/* -*- 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 GlobalStyleSheetCache manages */
/*
* STYLE_SHEET(identifier_, url_, shared_)
*
* identifier_
* An identifier for the style sheet, suitable for use as an enum class value.
*
* url_
* The URL of the style sheet.
*
* shared_
* A boolean indicating whether the sheet can be safely placed in shared
* memory.
*/
STYLE_SHEET(ContentEditable, "resource://gre/res/contenteditable.css", true)
STYLE_SHEET(CounterStyles, "resource://gre-resources/counterstyles.css", true)
STYLE_SHEET(Forms, "resource://gre-resources/forms.css", true)
STYLE_SHEET(HTML, "resource://gre-resources/html.css", true)
STYLE_SHEET(MathML, "resource://gre-resources/mathml.css", true)
STYLE_SHEET(NoFrames, "resource://gre-resources/noframes.css", true)
STYLE_SHEET(Quirk, "resource://gre-resources/quirk.css", true)
STYLE_SHEET(Scrollbars, "resource://gre-resources/scrollbars.css", true)
STYLE_SHEET(SVG, "resource://gre/res/svg.css", true)
STYLE_SHEET(UA, "resource://gre-resources/ua.css", true)
STYLE_SHEET(XUL, "chrome://global/content/xul.css", false)

View File

@@ -10,8 +10,6 @@ toolkit.jar:
res/noframes.css (res/noframes.css) res/noframes.css (res/noframes.css)
res/scrollbars.css (res/scrollbars.css) res/scrollbars.css (res/scrollbars.css)
res/forms.css (res/forms.css) res/forms.css (res/forms.css)
res/accessiblecaret.css (res/accessiblecaret.css)
res/details.css (res/details.css)
#ifdef ANDROID #ifdef ANDROID
res/accessiblecaret-normal.svg (res/accessiblecaret-normal.svg) res/accessiblecaret-normal.svg (res/accessiblecaret-normal.svg)
res/accessiblecaret-tilt-left.svg (res/accessiblecaret-tilt-left.svg) res/accessiblecaret-tilt-left.svg (res/accessiblecaret-tilt-left.svg)

View File

@@ -75,8 +75,6 @@ EXPORTS.mozilla += [
"AnimatedPropertyIDSet.h", "AnimatedPropertyIDSet.h",
"AnimationCollection.h", "AnimationCollection.h",
"AttributeStyles.h", "AttributeStyles.h",
"BuiltInStyleSheetList.h",
"BuiltInStyleSheets.h",
"CachedInheritingStyles.h", "CachedInheritingStyles.h",
"ComputedStyle.h", "ComputedStyle.h",
"ComputedStyleInlines.h", "ComputedStyleInlines.h",
@@ -124,6 +122,8 @@ EXPORTS.mozilla += [
"TimelineCollection.h", "TimelineCollection.h",
"TimelineManager.h", "TimelineManager.h",
"URLExtraData.h", "URLExtraData.h",
"UserAgentStyleSheetID.h",
"UserAgentStyleSheetList.h",
] ]
EXPORTS.mozilla.dom += [ EXPORTS.mozilla.dom += [
@@ -296,7 +296,9 @@ RESOURCE_FILES += [
CONTENT_ACCESSIBLE_FILES += [ CONTENT_ACCESSIBLE_FILES += [
"ImageDocument.css", "ImageDocument.css",
"res/accessiblecaret.css",
"res/close-12.svg", "res/close-12.svg",
"res/details.css",
"res/plaintext.css", "res/plaintext.css",
"res/viewsource.css", "res/viewsource.css",
"TopLevelImageDocument.css", "TopLevelImageDocument.css",

View File

@@ -8911,6 +8911,7 @@ pub unsafe extern "C" fn Servo_SharedMemoryBuilder_AddStylesheet(
) -> *const LockedCssRules { ) -> *const LockedCssRules {
// Assert some things we assume when we create a style sheet from shared // Assert some things we assume when we create a style sheet from shared
// memory. // memory.
debug_assert_eq!(contents.origin, Origin::UserAgent);
debug_assert_eq!(contents.quirks_mode, QuirksMode::NoQuirks); debug_assert_eq!(contents.quirks_mode, QuirksMode::NoQuirks);
debug_assert!(contents.source_map_url.read().is_none()); debug_assert!(contents.source_map_url.read().is_none());
debug_assert!(contents.source_url.read().is_none()); debug_assert!(contents.source_url.read().is_none());