mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1244074 - Part 4: Use StyleSheetHandle instead of concrete style sheet class in most places. r=dholbert
This commit is contained in:
parent
4f8d4767e0
commit
f230a1c1f5
@ -17,7 +17,6 @@
|
||||
#include "nsString.h"
|
||||
#include "nsQueryObject.h"
|
||||
|
||||
#include "mozilla/CSSStyleSheet.h"
|
||||
#include "mozilla/dom/URL.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIDocument.h"
|
||||
@ -30,12 +29,14 @@
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
nsChromeRegistry* nsChromeRegistry::gChromeRegistry;
|
||||
|
||||
// DO NOT use namespace mozilla; it'll break due to a naming conflict between
|
||||
// mozilla::TextRange and a TextRange in OSX headers.
|
||||
using mozilla::CSSStyleSheet;
|
||||
using mozilla::StyleSheetHandle;
|
||||
using mozilla::dom::IsChromeURI;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -401,19 +402,18 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindowOuter* aWindow)
|
||||
nsCOMPtr<nsIPresShell> shell = document->GetShell();
|
||||
if (shell) {
|
||||
// Reload only the chrome URL agent style sheets.
|
||||
nsTArray<RefPtr<CSSStyleSheet>> agentSheets;
|
||||
nsTArray<StyleSheetHandle::RefPtr> agentSheets;
|
||||
rv = shell->GetAgentStyleSheets(agentSheets);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsTArray<RefPtr<CSSStyleSheet>> newAgentSheets;
|
||||
for (CSSStyleSheet* sheet : agentSheets) {
|
||||
nsTArray<StyleSheetHandle::RefPtr> newAgentSheets;
|
||||
for (StyleSheetHandle sheet : agentSheets) {
|
||||
nsIURI* uri = sheet->GetSheetURI();
|
||||
|
||||
if (IsChromeURI(uri)) {
|
||||
// Reload the sheet.
|
||||
RefPtr<CSSStyleSheet> newSheet;
|
||||
rv = document->LoadChromeSheetSync(uri, true,
|
||||
getter_AddRefs(newSheet));
|
||||
StyleSheetHandle::RefPtr newSheet;
|
||||
rv = document->LoadChromeSheetSync(uri, true, &newSheet);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (newSheet) {
|
||||
rv = newAgentSheets.AppendElement(newSheet) ? NS_OK : NS_ERROR_FAILURE;
|
||||
@ -433,27 +433,27 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindowOuter* aWindow)
|
||||
int32_t count = document->GetNumberOfStyleSheets();
|
||||
|
||||
// Build an array of style sheets we need to reload.
|
||||
nsTArray<RefPtr<CSSStyleSheet>> oldSheets(count);
|
||||
nsTArray<RefPtr<CSSStyleSheet>> newSheets(count);
|
||||
nsTArray<StyleSheetHandle::RefPtr> oldSheets(count);
|
||||
nsTArray<StyleSheetHandle::RefPtr> newSheets(count);
|
||||
|
||||
// Iterate over the style sheets.
|
||||
for (int32_t i = 0; i < count; i++) {
|
||||
// Get the style sheet
|
||||
CSSStyleSheet* styleSheet = document->GetStyleSheetAt(i);
|
||||
StyleSheetHandle styleSheet = document->GetStyleSheetAt(i);
|
||||
oldSheets.AppendElement(styleSheet);
|
||||
}
|
||||
|
||||
// Iterate over our old sheets and kick off a sync load of the new
|
||||
// sheet if and only if it's a chrome URL.
|
||||
for (CSSStyleSheet* sheet : oldSheets) {
|
||||
for (StyleSheetHandle sheet : oldSheets) {
|
||||
nsIURI* uri = sheet ? sheet->GetOriginalURI() : nullptr;
|
||||
|
||||
if (uri && IsChromeURI(uri)) {
|
||||
// Reload the sheet.
|
||||
RefPtr<CSSStyleSheet> newSheet;
|
||||
StyleSheetHandle::RefPtr newSheet;
|
||||
// XXX what about chrome sheets that have a title or are disabled? This
|
||||
// only works by sheer dumb luck.
|
||||
document->LoadChromeSheetSync(uri, false, getter_AddRefs(newSheet));
|
||||
document->LoadChromeSheetSync(uri, false, &newSheet);
|
||||
// Even if it's null, we put in in there.
|
||||
newSheets.AppendElement(newSheet);
|
||||
} else {
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "mozilla/dom/HTMLContentElement.h"
|
||||
#include "mozilla/dom/HTMLShadowElement.h"
|
||||
#include "nsXBLPrototypeBinding.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -130,7 +132,7 @@ ShadowRoot::StyleSheetChanged()
|
||||
}
|
||||
|
||||
void
|
||||
ShadowRoot::InsertSheet(CSSStyleSheet* aSheet,
|
||||
ShadowRoot::InsertSheet(StyleSheetHandle aSheet,
|
||||
nsIContent* aLinkingContent)
|
||||
{
|
||||
nsCOMPtr<nsIStyleSheetLinkingElement>
|
||||
@ -148,8 +150,8 @@ ShadowRoot::InsertSheet(CSSStyleSheet* aSheet,
|
||||
break;
|
||||
}
|
||||
|
||||
nsINode* sheetOwnerNode = mProtoBinding->StyleSheetAt(i)->GetOwnerNode();
|
||||
if (nsContentUtils::PositionIsBefore(aLinkingContent, sheetOwnerNode)) {
|
||||
nsINode* sheetOwningNode = mProtoBinding->StyleSheetAt(i)->GetOwnerNode();
|
||||
if (nsContentUtils::PositionIsBefore(aLinkingContent, sheetOwningNode)) {
|
||||
mProtoBinding->InsertStyleSheetAt(i, aSheet);
|
||||
break;
|
||||
}
|
||||
@ -161,7 +163,7 @@ ShadowRoot::InsertSheet(CSSStyleSheet* aSheet,
|
||||
}
|
||||
|
||||
void
|
||||
ShadowRoot::RemoveSheet(CSSStyleSheet* aSheet)
|
||||
ShadowRoot::RemoveSheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
mProtoBinding->RemoveStyleSheet(aSheet);
|
||||
|
||||
@ -752,7 +754,14 @@ ShadowRootStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return mShadowRoot->mProtoBinding->StyleSheetAt(aIndex);
|
||||
// XXXheycam Return null until ServoStyleSheet implements the right
|
||||
// DOM interfaces.
|
||||
StyleSheetHandle sheet = mShadowRoot->mProtoBinding->StyleSheetAt(aIndex);
|
||||
if (sheet->IsServo()) {
|
||||
NS_ERROR("stylo: can't return ServoStyleSheets to script yet");
|
||||
return nullptr;
|
||||
}
|
||||
return sheet->AsGecko();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
#include "mozilla/dom/StyleSheetList.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsTHashtable.h"
|
||||
@ -45,8 +46,8 @@ public:
|
||||
|
||||
void AddToIdTable(Element* aElement, nsIAtom* aId);
|
||||
void RemoveFromIdTable(Element* aElement, nsIAtom* aId);
|
||||
void InsertSheet(CSSStyleSheet* aSheet, nsIContent* aLinkingContent);
|
||||
void RemoveSheet(CSSStyleSheet* aSheet);
|
||||
void InsertSheet(StyleSheetHandle aSheet, nsIContent* aLinkingContent);
|
||||
void RemoveSheet(StyleSheetHandle aSheet);
|
||||
bool ApplyAuthorStyles();
|
||||
void SetApplyAuthorStyles(bool aApplyAuthorStyles);
|
||||
StyleSheetList* StyleSheets();
|
||||
|
@ -213,7 +213,7 @@ nsContentSink::Init(nsIDocument* aDoc,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentSink::StyleSheetLoaded(CSSStyleSheet* aSheet,
|
||||
nsContentSink::StyleSheetLoaded(StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus)
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ class nsContentSink : public nsICSSLoaderObserver,
|
||||
NS_DECL_NSITIMERCALLBACK
|
||||
|
||||
// nsICSSLoaderObserver
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet,
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus) override;
|
||||
|
||||
|
@ -245,6 +245,8 @@
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "mozilla/StyleSetHandle.h"
|
||||
#include "mozilla/StyleSetHandleInlines.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
#include "mozilla/DocLoadingTimelineMarker.h"
|
||||
|
||||
@ -733,10 +735,16 @@ nsDOMStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||
}
|
||||
|
||||
aFound = true;
|
||||
CSSStyleSheet* sheet = mDocument->GetStyleSheetAt(aIndex);
|
||||
StyleSheetHandle sheet = mDocument->GetStyleSheetAt(aIndex);
|
||||
NS_ASSERTION(sheet, "Must have a sheet");
|
||||
|
||||
return static_cast<CSSStyleSheet*>(sheet);
|
||||
// XXXheycam Return null until ServoStyleSheet implements the right DOM
|
||||
// interfaces.
|
||||
if (sheet->IsServo()) {
|
||||
NS_ERROR("stylo: can't return a ServoStyleSheet to the DOM yet");
|
||||
return nullptr;
|
||||
}
|
||||
return sheet->AsGecko();
|
||||
}
|
||||
|
||||
void
|
||||
@ -746,7 +754,7 @@ nsDOMStyleSheetList::NodeWillBeDestroyed(const nsINode *aNode)
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMStyleSheetList::StyleSheetAdded(CSSStyleSheet* aStyleSheet,
|
||||
nsDOMStyleSheetList::StyleSheetAdded(StyleSheetHandle aStyleSheet,
|
||||
bool aDocumentSheet)
|
||||
{
|
||||
if (aDocumentSheet && -1 != mLength) {
|
||||
@ -755,7 +763,7 @@ nsDOMStyleSheetList::StyleSheetAdded(CSSStyleSheet* aStyleSheet,
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMStyleSheetList::StyleSheetRemoved(CSSStyleSheet* aStyleSheet,
|
||||
nsDOMStyleSheetList::StyleSheetRemoved(StyleSheetHandle aStyleSheet,
|
||||
bool aDocumentSheet)
|
||||
{
|
||||
if (aDocumentSheet && -1 != mLength) {
|
||||
@ -1322,9 +1330,14 @@ nsDOMStyleSheetSetList::EnsureFresh()
|
||||
int32_t count = mDocument->GetNumberOfStyleSheets();
|
||||
nsAutoString title;
|
||||
for (int32_t index = 0; index < count; index++) {
|
||||
CSSStyleSheet* sheet = mDocument->GetStyleSheetAt(index);
|
||||
StyleSheetHandle sheet = mDocument->GetStyleSheetAt(index);
|
||||
NS_ASSERTION(sheet, "Null sheet in sheet list!");
|
||||
sheet->GetTitle(title);
|
||||
// XXXheycam ServoStyleSheets don't expose their title yet.
|
||||
if (sheet->IsServo()) {
|
||||
NS_ERROR("stylo: ServoStyleSets don't expose their title yet");
|
||||
continue;
|
||||
}
|
||||
sheet->AsGecko()->GetTitle(title);
|
||||
if (!title.IsEmpty() && !mNames.Contains(title) && !Add(title)) {
|
||||
return;
|
||||
}
|
||||
@ -1604,7 +1617,7 @@ nsDocument::~nsDocument()
|
||||
mCachedRootElement = nullptr;
|
||||
|
||||
// Let the stylesheets know we're going away
|
||||
for (CSSStyleSheet* sheet : mStyleSheets) {
|
||||
for (StyleSheetHandle sheet : mStyleSheets) {
|
||||
sheet->SetOwningDocument(nullptr);
|
||||
}
|
||||
if (mAttrStyleSheet) {
|
||||
@ -2282,7 +2295,7 @@ void
|
||||
nsDocument::RemoveDocStyleSheetsFromStyleSets()
|
||||
{
|
||||
// The stylesheets should forget us
|
||||
for (CSSStyleSheet* sheet : Reversed(mStyleSheets)) {
|
||||
for (StyleSheetHandle sheet : Reversed(mStyleSheets)) {
|
||||
sheet->SetOwningDocument(nullptr);
|
||||
|
||||
if (sheet->IsApplicable()) {
|
||||
@ -2297,11 +2310,11 @@ nsDocument::RemoveDocStyleSheetsFromStyleSets()
|
||||
|
||||
void
|
||||
nsDocument::RemoveStyleSheetsFromStyleSets(
|
||||
nsTArray<RefPtr<CSSStyleSheet>>& aSheets,
|
||||
nsTArray<StyleSheetHandle::RefPtr>& aSheets,
|
||||
SheetType aType)
|
||||
{
|
||||
// The stylesheets should forget us
|
||||
for (CSSStyleSheet* sheet : Reversed(aSheets)) {
|
||||
for (StyleSheetHandle sheet : Reversed(aSheets)) {
|
||||
sheet->SetOwningDocument(nullptr);
|
||||
|
||||
if (sheet->IsApplicable()) {
|
||||
@ -2368,10 +2381,10 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI)
|
||||
|
||||
static void
|
||||
AppendSheetsToStyleSet(StyleSetHandle aStyleSet,
|
||||
const nsTArray<RefPtr<CSSStyleSheet>>& aSheets,
|
||||
const nsTArray<StyleSheetHandle::RefPtr>& aSheets,
|
||||
SheetType aType)
|
||||
{
|
||||
for (CSSStyleSheet* sheet : Reversed(aSheets)) {
|
||||
for (StyleSheetHandle sheet : Reversed(aSheets)) {
|
||||
aStyleSet->AppendStyleSheet(aType, sheet);
|
||||
}
|
||||
}
|
||||
@ -2384,7 +2397,7 @@ nsDocument::FillStyleSet(StyleSetHandle aStyleSet)
|
||||
NS_PRECONDITION(aStyleSet->SheetCount(SheetType::Doc) == 0,
|
||||
"Style set already has document sheets?");
|
||||
|
||||
for (CSSStyleSheet* sheet : Reversed(mStyleSheets)) {
|
||||
for (StyleSheetHandle sheet : Reversed(mStyleSheets)) {
|
||||
if (sheet->IsApplicable()) {
|
||||
aStyleSet->AddDocStyleSheet(sheet, this);
|
||||
}
|
||||
@ -2392,13 +2405,13 @@ nsDocument::FillStyleSet(StyleSetHandle aStyleSet)
|
||||
|
||||
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
||||
if (sheetService) {
|
||||
for (CSSStyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
|
||||
for (StyleSheetHandle sheet : *sheetService->AuthorStyleSheets()) {
|
||||
aStyleSet->AppendStyleSheet(SheetType::Doc, sheet);
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate backwards to maintain order
|
||||
for (CSSStyleSheet* sheet : Reversed(mOnDemandBuiltInUASheets)) {
|
||||
for (StyleSheetHandle sheet : Reversed(mOnDemandBuiltInUASheets)) {
|
||||
if (sheet->IsApplicable()) {
|
||||
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
@ -4051,7 +4064,7 @@ nsDocument::RemoveChildAt(uint32_t aIndex, bool aNotify)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::EnsureOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
|
||||
nsDocument::EnsureOnDemandBuiltInUASheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
if (mOnDemandBuiltInUASheets.Contains(aSheet)) {
|
||||
return;
|
||||
@ -4062,7 +4075,7 @@ nsDocument::EnsureOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::AddOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
|
||||
nsDocument::AddOnDemandBuiltInUASheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
MOZ_ASSERT(!mOnDemandBuiltInUASheets.Contains(aSheet));
|
||||
|
||||
@ -4091,20 +4104,20 @@ nsDocument::GetNumberOfStyleSheets() const
|
||||
return mStyleSheets.Length();
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsDocument::GetStyleSheetAt(int32_t aIndex) const
|
||||
{
|
||||
return mStyleSheets.SafeElementAt(aIndex, nullptr);
|
||||
return mStyleSheets.SafeElementAt(aIndex, StyleSheetHandle());
|
||||
}
|
||||
|
||||
int32_t
|
||||
nsDocument::GetIndexOfStyleSheet(CSSStyleSheet* aSheet) const
|
||||
nsDocument::GetIndexOfStyleSheet(StyleSheetHandle aSheet) const
|
||||
{
|
||||
return mStyleSheets.IndexOf(aSheet);
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::AddStyleSheetToStyleSets(CSSStyleSheet* aSheet)
|
||||
nsDocument::AddStyleSheetToStyleSets(StyleSheetHandle aSheet)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell = GetShell();
|
||||
if (shell) {
|
||||
@ -4117,7 +4130,11 @@ nsDocument::AddStyleSheetToStyleSets(CSSStyleSheet* aSheet)
|
||||
className##Init init; \
|
||||
init.mBubbles = true; \
|
||||
init.mCancelable = true; \
|
||||
init.mStylesheet = aSheet; \
|
||||
/* XXXheycam ServoStyleSheet doesn't implement DOM interfaces yet */ \
|
||||
if (aSheet->IsServo()) { \
|
||||
NS_ERROR("stylo: can't dispatch events for ServoStyleSheets yet"); \
|
||||
} \
|
||||
init.mStylesheet = aSheet->IsGecko() ? aSheet->AsGecko() : nullptr; \
|
||||
init.memberName = argName; \
|
||||
\
|
||||
RefPtr<className> event = \
|
||||
@ -4131,7 +4148,7 @@ nsDocument::AddStyleSheetToStyleSets(CSSStyleSheet* aSheet)
|
||||
} while (0);
|
||||
|
||||
void
|
||||
nsDocument::NotifyStyleSheetAdded(CSSStyleSheet* aSheet, bool aDocumentSheet)
|
||||
nsDocument::NotifyStyleSheetAdded(StyleSheetHandle aSheet, bool aDocumentSheet)
|
||||
{
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleSheetAdded, (aSheet, aDocumentSheet));
|
||||
|
||||
@ -4144,7 +4161,7 @@ nsDocument::NotifyStyleSheetAdded(CSSStyleSheet* aSheet, bool aDocumentSheet)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::NotifyStyleSheetRemoved(CSSStyleSheet* aSheet, bool aDocumentSheet)
|
||||
nsDocument::NotifyStyleSheetRemoved(StyleSheetHandle aSheet, bool aDocumentSheet)
|
||||
{
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleSheetRemoved, (aSheet, aDocumentSheet));
|
||||
|
||||
@ -4157,7 +4174,7 @@ nsDocument::NotifyStyleSheetRemoved(CSSStyleSheet* aSheet, bool aDocumentSheet)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::AddStyleSheet(CSSStyleSheet* aSheet)
|
||||
nsDocument::AddStyleSheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null arg");
|
||||
mStyleSheets.AppendElement(aSheet);
|
||||
@ -4171,7 +4188,7 @@ nsDocument::AddStyleSheet(CSSStyleSheet* aSheet)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::RemoveStyleSheetFromStyleSets(CSSStyleSheet* aSheet)
|
||||
nsDocument::RemoveStyleSheetFromStyleSets(StyleSheetHandle aSheet)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell = GetShell();
|
||||
if (shell) {
|
||||
@ -4180,10 +4197,10 @@ nsDocument::RemoveStyleSheetFromStyleSets(CSSStyleSheet* aSheet)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::RemoveStyleSheet(CSSStyleSheet* aSheet)
|
||||
nsDocument::RemoveStyleSheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null arg");
|
||||
RefPtr<CSSStyleSheet> sheet = aSheet; // hold ref so it won't die too soon
|
||||
StyleSheetHandle::RefPtr sheet = aSheet; // hold ref so it won't die too soon
|
||||
|
||||
if (!mStyleSheets.RemoveElement(aSheet)) {
|
||||
NS_ASSERTION(mInUnlinkOrDeletion, "stylesheet not found");
|
||||
@ -4202,8 +4219,8 @@ nsDocument::RemoveStyleSheet(CSSStyleSheet* aSheet)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::UpdateStyleSheets(nsTArray<RefPtr<CSSStyleSheet>>& aOldSheets,
|
||||
nsTArray<RefPtr<CSSStyleSheet>>& aNewSheets)
|
||||
nsDocument::UpdateStyleSheets(nsTArray<StyleSheetHandle::RefPtr>& aOldSheets,
|
||||
nsTArray<StyleSheetHandle::RefPtr>& aNewSheets)
|
||||
{
|
||||
BeginUpdate(UPDATE_STYLE);
|
||||
|
||||
@ -4212,7 +4229,7 @@ nsDocument::UpdateStyleSheets(nsTArray<RefPtr<CSSStyleSheet>>& aOldSheets,
|
||||
"The lists must be the same length!");
|
||||
int32_t count = aOldSheets.Length();
|
||||
|
||||
RefPtr<CSSStyleSheet> oldSheet;
|
||||
StyleSheetHandle::RefPtr oldSheet;
|
||||
int32_t i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
oldSheet = aOldSheets[i];
|
||||
@ -4223,7 +4240,7 @@ nsDocument::UpdateStyleSheets(nsTArray<RefPtr<CSSStyleSheet>>& aOldSheets,
|
||||
RemoveStyleSheet(oldSheet); // This does the right notifications
|
||||
|
||||
// Now put the new one in its place. If it's null, just ignore it.
|
||||
CSSStyleSheet* newSheet = aNewSheets[i];
|
||||
StyleSheetHandle newSheet = aNewSheets[i];
|
||||
if (newSheet) {
|
||||
mStyleSheets.InsertElementAt(oldIndex, newSheet);
|
||||
newSheet->SetOwningDocument(this);
|
||||
@ -4239,7 +4256,7 @@ nsDocument::UpdateStyleSheets(nsTArray<RefPtr<CSSStyleSheet>>& aOldSheets,
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::InsertStyleSheetAt(CSSStyleSheet* aSheet, int32_t aIndex)
|
||||
nsDocument::InsertStyleSheetAt(StyleSheetHandle aSheet, int32_t aIndex)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null ptr");
|
||||
|
||||
@ -4256,7 +4273,7 @@ nsDocument::InsertStyleSheetAt(CSSStyleSheet* aSheet, int32_t aIndex)
|
||||
|
||||
|
||||
void
|
||||
nsDocument::SetStyleSheetApplicableState(CSSStyleSheet* aSheet,
|
||||
nsDocument::SetStyleSheetApplicableState(StyleSheetHandle aSheet,
|
||||
bool aApplicable)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null arg");
|
||||
@ -4322,7 +4339,7 @@ ConvertAdditionalSheetType(nsIDocument::additionalSheetType aType)
|
||||
}
|
||||
|
||||
static int32_t
|
||||
FindSheet(const nsTArray<RefPtr<CSSStyleSheet>>& aSheets, nsIURI* aSheetURI)
|
||||
FindSheet(const nsTArray<StyleSheetHandle::RefPtr>& aSheets, nsIURI* aSheetURI)
|
||||
{
|
||||
for (int32_t i = aSheets.Length() - 1; i >= 0; i-- ) {
|
||||
bool bEqual;
|
||||
@ -4366,9 +4383,8 @@ nsDocument::LoadAdditionalStyleSheet(additionalSheetType aType,
|
||||
MOZ_CRASH("impossible value for aType");
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleSheet> sheet;
|
||||
nsresult rv = loader->LoadSheetSync(aSheetURI, parsingMode, true,
|
||||
getter_AddRefs(sheet));
|
||||
StyleSheetHandle::RefPtr sheet;
|
||||
nsresult rv = loader->LoadSheetSync(aSheetURI, parsingMode, true, &sheet);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
sheet->SetOwningDocument(this);
|
||||
@ -4378,7 +4394,7 @@ nsDocument::LoadAdditionalStyleSheet(additionalSheetType aType,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocument::AddAdditionalStyleSheet(additionalSheetType aType, CSSStyleSheet* aSheet)
|
||||
nsDocument::AddAdditionalStyleSheet(additionalSheetType aType, StyleSheetHandle aSheet)
|
||||
{
|
||||
if (mAdditionalSheets[aType].Contains(aSheet))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
@ -4407,11 +4423,11 @@ nsDocument::RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheet
|
||||
{
|
||||
MOZ_ASSERT(aSheetURI);
|
||||
|
||||
nsTArray<RefPtr<CSSStyleSheet>>& sheets = mAdditionalSheets[aType];
|
||||
nsTArray<StyleSheetHandle::RefPtr>& sheets = mAdditionalSheets[aType];
|
||||
|
||||
int32_t i = FindSheet(mAdditionalSheets[aType], aSheetURI);
|
||||
if (i >= 0) {
|
||||
RefPtr<CSSStyleSheet> sheetRef = sheets[i];
|
||||
StyleSheetHandle::RefPtr sheetRef = sheets[i];
|
||||
sheets.RemoveElementAt(i);
|
||||
|
||||
BeginUpdate(UPDATE_STYLE);
|
||||
@ -4433,10 +4449,10 @@ nsDocument::RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheet
|
||||
}
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsDocument::FirstAdditionalAuthorSheet()
|
||||
{
|
||||
return mAdditionalSheets[eAuthorSheet].SafeElementAt(0, nullptr);
|
||||
return mAdditionalSheets[eAuthorSheet].SafeElementAt(0, StyleSheetHandle());
|
||||
}
|
||||
|
||||
nsIGlobalObject*
|
||||
@ -5192,7 +5208,7 @@ nsDocument::DocumentStatesChanged(EventStates aStateMask)
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::StyleRuleChanged(CSSStyleSheet* aSheet,
|
||||
nsDocument::StyleRuleChanged(StyleSheetHandle aSheet,
|
||||
css::Rule* aStyleRule)
|
||||
{
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleRuleChanged, (aSheet));
|
||||
@ -5206,7 +5222,7 @@ nsDocument::StyleRuleChanged(CSSStyleSheet* aSheet,
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::StyleRuleAdded(CSSStyleSheet* aSheet,
|
||||
nsDocument::StyleRuleAdded(StyleSheetHandle aSheet,
|
||||
css::Rule* aStyleRule)
|
||||
{
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleRuleAdded, (aSheet));
|
||||
@ -5221,7 +5237,7 @@ nsDocument::StyleRuleAdded(CSSStyleSheet* aSheet,
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::StyleRuleRemoved(CSSStyleSheet* aSheet,
|
||||
nsDocument::StyleRuleRemoved(StyleSheetHandle aSheet,
|
||||
css::Rule* aStyleRule)
|
||||
{
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleRuleRemoved, (aSheet));
|
||||
@ -6462,17 +6478,23 @@ nsIDocument::GetSelectedStyleSheetSet(nsAString& aSheetSet)
|
||||
int32_t count = GetNumberOfStyleSheets();
|
||||
nsAutoString title;
|
||||
for (int32_t index = 0; index < count; index++) {
|
||||
CSSStyleSheet* sheet = GetStyleSheetAt(index);
|
||||
StyleSheetHandle sheet = GetStyleSheetAt(index);
|
||||
NS_ASSERTION(sheet, "Null sheet in sheet list!");
|
||||
|
||||
// XXXheycam Make this work with ServoStyleSheets.
|
||||
if (sheet->IsServo()) {
|
||||
NS_ERROR("stylo: can't handle alternate ServoStyleSheets yet");
|
||||
continue;
|
||||
}
|
||||
|
||||
bool disabled;
|
||||
sheet->GetDisabled(&disabled);
|
||||
sheet->AsGecko()->GetDisabled(&disabled);
|
||||
if (disabled) {
|
||||
// Disabled sheets don't affect the currently selected set
|
||||
continue;
|
||||
}
|
||||
|
||||
sheet->GetTitle(title);
|
||||
sheet->AsGecko()->GetTitle(title);
|
||||
|
||||
if (aSheetSet.IsEmpty()) {
|
||||
aSheetSet = title;
|
||||
@ -6576,11 +6598,18 @@ nsDocument::EnableStyleSheetsForSetInternal(const nsAString& aSheetSet,
|
||||
int32_t count = GetNumberOfStyleSheets();
|
||||
nsAutoString title;
|
||||
for (int32_t index = 0; index < count; index++) {
|
||||
CSSStyleSheet* sheet = GetStyleSheetAt(index);
|
||||
StyleSheetHandle sheet = GetStyleSheetAt(index);
|
||||
NS_ASSERTION(sheet, "Null sheet in sheet list!");
|
||||
sheet->GetTitle(title);
|
||||
|
||||
// XXXheycam Make this work with ServoStyleSheets.
|
||||
if (sheet->IsServo()) {
|
||||
NS_ERROR("stylo: can't handle alternate ServoStyleSheets yet");
|
||||
continue;
|
||||
}
|
||||
|
||||
sheet->AsGecko()->GetTitle(title);
|
||||
if (!title.IsEmpty()) {
|
||||
sheet->SetEnabled(title.Equals(aSheetSet));
|
||||
sheet->AsGecko()->SetEnabled(title.Equals(aSheetSet));
|
||||
}
|
||||
}
|
||||
if (aUpdateCSSLoader) {
|
||||
@ -9854,7 +9883,7 @@ class StubCSSLoaderObserver final : public nsICSSLoaderObserver {
|
||||
~StubCSSLoaderObserver() {}
|
||||
public:
|
||||
NS_IMETHOD
|
||||
StyleSheetLoaded(CSSStyleSheet*, bool, nsresult) override
|
||||
StyleSheetLoaded(StyleSheetHandle, bool, nsresult) override
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
@ -9883,12 +9912,12 @@ nsDocument::PreloadStyle(nsIURI* uri, const nsAString& charset,
|
||||
|
||||
nsresult
|
||||
nsDocument::LoadChromeSheetSync(nsIURI* uri, bool isAgentSheet,
|
||||
CSSStyleSheet** sheet)
|
||||
mozilla::StyleSheetHandle::RefPtr* aSheet)
|
||||
{
|
||||
css::SheetParsingMode mode =
|
||||
isAgentSheet ? css::eAgentSheetFeatures
|
||||
: css::eAuthorSheetFeatures;
|
||||
return CSSLoader()->LoadSheetSync(uri, mode, isAgentSheet, sheet);
|
||||
return CSSLoader()->LoadSheetSync(uri, mode, isAgentSheet, aSheet);
|
||||
}
|
||||
|
||||
class nsDelayedEventDispatcher : public nsRunnable
|
||||
@ -10214,28 +10243,38 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
|
||||
|
||||
int32_t sheetsCount = GetNumberOfStyleSheets();
|
||||
for (int32_t i = 0; i < sheetsCount; ++i) {
|
||||
RefPtr<CSSStyleSheet> sheet = GetStyleSheetAt(i);
|
||||
StyleSheetHandle::RefPtr sheet = GetStyleSheetAt(i);
|
||||
if (sheet) {
|
||||
if (sheet->IsApplicable()) {
|
||||
RefPtr<CSSStyleSheet> clonedSheet =
|
||||
sheet->Clone(nullptr, nullptr, clonedDoc, nullptr);
|
||||
NS_WARN_IF_FALSE(clonedSheet, "Cloning a stylesheet didn't work!");
|
||||
if (clonedSheet) {
|
||||
clonedDoc->AddStyleSheet(clonedSheet);
|
||||
// XXXheycam Need to make ServoStyleSheet cloning work.
|
||||
if (sheet->IsGecko()) {
|
||||
RefPtr<CSSStyleSheet> clonedSheet =
|
||||
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
|
||||
NS_WARN_IF_FALSE(clonedSheet, "Cloning a stylesheet didn't work!");
|
||||
if (clonedSheet) {
|
||||
clonedDoc->AddStyleSheet(clonedSheet);
|
||||
}
|
||||
} else {
|
||||
NS_ERROR("stylo: ServoStyleSheet doesn't support cloning");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate backwards to maintain order
|
||||
for (CSSStyleSheet* sheet : Reversed(thisAsDoc->mOnDemandBuiltInUASheets)) {
|
||||
for (StyleSheetHandle sheet : Reversed(thisAsDoc->mOnDemandBuiltInUASheets)) {
|
||||
if (sheet) {
|
||||
if (sheet->IsApplicable()) {
|
||||
RefPtr<CSSStyleSheet> clonedSheet =
|
||||
sheet->Clone(nullptr, nullptr, clonedDoc, nullptr);
|
||||
NS_WARN_IF_FALSE(clonedSheet, "Cloning a stylesheet didn't work!");
|
||||
if (clonedSheet) {
|
||||
clonedDoc->AddOnDemandBuiltInUASheet(clonedSheet);
|
||||
// XXXheycam Need to make ServoStyleSheet cloning work.
|
||||
if (sheet->IsGecko()) {
|
||||
RefPtr<CSSStyleSheet> clonedSheet =
|
||||
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
|
||||
NS_WARN_IF_FALSE(clonedSheet, "Cloning a stylesheet didn't work!");
|
||||
if (clonedSheet) {
|
||||
clonedDoc->AddOnDemandBuiltInUASheet(clonedSheet);
|
||||
}
|
||||
} else {
|
||||
NS_ERROR("stylo: ServoStyleSheet doesn't support cloning");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12366,7 +12405,7 @@ nsDocument::OnAppThemeChanged()
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < GetNumberOfStyleSheets(); i++) {
|
||||
RefPtr<CSSStyleSheet> sheet = GetStyleSheetAt(i);
|
||||
StyleSheetHandle::RefPtr sheet = GetStyleSheetAt(i);
|
||||
if (!sheet) {
|
||||
continue;
|
||||
}
|
||||
@ -12733,12 +12772,12 @@ nsIDocument::DocAddSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const
|
||||
}
|
||||
|
||||
static size_t
|
||||
SizeOfOwnedSheetArrayExcludingThis(const nsTArray<RefPtr<CSSStyleSheet>>& aSheets,
|
||||
SizeOfOwnedSheetArrayExcludingThis(const nsTArray<StyleSheetHandle::RefPtr>& aSheets,
|
||||
MallocSizeOf aMallocSizeOf)
|
||||
{
|
||||
size_t n = 0;
|
||||
n += aSheets.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
||||
for (CSSStyleSheet* sheet : aSheets) {
|
||||
for (StyleSheetHandle sheet : aSheets) {
|
||||
if (!sheet->GetOwningDocument()) {
|
||||
// Avoid over-reporting shared sheets.
|
||||
continue;
|
||||
@ -13419,3 +13458,15 @@ nsIDocument::ReportHasScrollLinkedEffect()
|
||||
this, nsContentUtils::eLAYOUT_PROPERTIES,
|
||||
"ScrollLinkedEffectFound2");
|
||||
}
|
||||
|
||||
mozilla::StyleBackendType
|
||||
nsIDocument::GetStyleBackendType() const
|
||||
{
|
||||
if (!mPresShell) {
|
||||
#ifdef MOZ_STYLO
|
||||
NS_WARNING("GetStyleBackendType() called on document without a pres shell");
|
||||
#endif
|
||||
return StyleBackendType::Gecko;
|
||||
}
|
||||
return mPresShell->StyleSet()->BackendType();
|
||||
}
|
||||
|
@ -797,36 +797,36 @@ public:
|
||||
virtual Element* FindContentForSubDocument(nsIDocument *aDocument) const override;
|
||||
virtual Element* GetRootElementInternal() const override;
|
||||
|
||||
virtual void EnsureOnDemandBuiltInUASheet(mozilla::CSSStyleSheet* aSheet) override;
|
||||
virtual void EnsureOnDemandBuiltInUASheet(mozilla::StyleSheetHandle aSheet) override;
|
||||
|
||||
/**
|
||||
* Get the (document) style sheets owned by this document.
|
||||
* These are ordered, highest priority last
|
||||
*/
|
||||
virtual int32_t GetNumberOfStyleSheets() const override;
|
||||
virtual mozilla::CSSStyleSheet* GetStyleSheetAt(int32_t aIndex) const override;
|
||||
virtual int32_t GetIndexOfStyleSheet(mozilla::CSSStyleSheet* aSheet) const override;
|
||||
virtual void AddStyleSheet(mozilla::CSSStyleSheet* aSheet) override;
|
||||
virtual void RemoveStyleSheet(mozilla::CSSStyleSheet* aSheet) override;
|
||||
virtual mozilla::StyleSheetHandle GetStyleSheetAt(int32_t aIndex) const override;
|
||||
virtual int32_t GetIndexOfStyleSheet(mozilla::StyleSheetHandle aSheet) const override;
|
||||
virtual void AddStyleSheet(mozilla::StyleSheetHandle aSheet) override;
|
||||
virtual void RemoveStyleSheet(mozilla::StyleSheetHandle aSheet) override;
|
||||
|
||||
virtual void UpdateStyleSheets(
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aOldSheets,
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aNewSheets) override;
|
||||
virtual void AddStyleSheetToStyleSets(mozilla::CSSStyleSheet* aSheet);
|
||||
virtual void RemoveStyleSheetFromStyleSets(mozilla::CSSStyleSheet* aSheet);
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr>& aOldSheets,
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr>& aNewSheets) override;
|
||||
virtual void AddStyleSheetToStyleSets(mozilla::StyleSheetHandle aSheet);
|
||||
virtual void RemoveStyleSheetFromStyleSets(mozilla::StyleSheetHandle aSheet);
|
||||
|
||||
virtual void InsertStyleSheetAt(mozilla::CSSStyleSheet* aSheet,
|
||||
virtual void InsertStyleSheetAt(mozilla::StyleSheetHandle aSheet,
|
||||
int32_t aIndex) override;
|
||||
virtual void SetStyleSheetApplicableState(mozilla::CSSStyleSheet* aSheet,
|
||||
virtual void SetStyleSheetApplicableState(mozilla::StyleSheetHandle aSheet,
|
||||
bool aApplicable) override;
|
||||
|
||||
virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType,
|
||||
nsIURI* aSheetURI) override;
|
||||
virtual nsresult AddAdditionalStyleSheet(additionalSheetType aType,
|
||||
mozilla::CSSStyleSheet* aSheet) override;
|
||||
mozilla::StyleSheetHandle aSheet) override;
|
||||
virtual void RemoveAdditionalStyleSheet(additionalSheetType aType,
|
||||
nsIURI* sheetURI) override;
|
||||
virtual mozilla::CSSStyleSheet* FirstAdditionalAuthorSheet() override;
|
||||
virtual mozilla::StyleSheetHandle FirstAdditionalAuthorSheet() override;
|
||||
|
||||
virtual nsIChannel* GetChannel() const override {
|
||||
return mChannel;
|
||||
@ -886,11 +886,11 @@ public:
|
||||
virtual void DocumentStatesChanged(
|
||||
mozilla::EventStates aStateMask) override;
|
||||
|
||||
virtual void StyleRuleChanged(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleChanged(mozilla::StyleSheetHandle aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) override;
|
||||
virtual void StyleRuleAdded(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleAdded(mozilla::StyleSheetHandle aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) override;
|
||||
virtual void StyleRuleRemoved(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleRemoved(mozilla::StyleSheetHandle aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) override;
|
||||
|
||||
virtual void FlushPendingNotifications(mozFlushType aType) override;
|
||||
@ -962,7 +962,7 @@ public:
|
||||
void ReportUseCounters();
|
||||
|
||||
private:
|
||||
void AddOnDemandBuiltInUASheet(mozilla::CSSStyleSheet* aSheet);
|
||||
void AddOnDemandBuiltInUASheet(mozilla::StyleSheetHandle aSheet);
|
||||
nsRadioGroupStruct* GetRadioGroupInternal(const nsAString& aName) const;
|
||||
void SendToConsole(nsCOMArray<nsISecurityConsoleMessage>& aMessages);
|
||||
|
||||
@ -1144,7 +1144,7 @@ public:
|
||||
const nsAString& aIntegrity) override;
|
||||
|
||||
virtual nsresult LoadChromeSheetSync(nsIURI* uri, bool isAgentSheet,
|
||||
mozilla::CSSStyleSheet** sheet) override;
|
||||
mozilla::StyleSheetHandle::RefPtr* aSheet) override;
|
||||
|
||||
virtual nsISupports* GetCurrentContentSink() override;
|
||||
|
||||
@ -1494,7 +1494,7 @@ protected:
|
||||
|
||||
void RemoveDocStyleSheetsFromStyleSets();
|
||||
void RemoveStyleSheetsFromStyleSets(
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aSheets,
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr>& aSheets,
|
||||
mozilla::SheetType aType);
|
||||
void ResetStylesheetsToURI(nsIURI* aURI);
|
||||
void FillStyleSet(mozilla::StyleSetHandle aStyleSet);
|
||||
@ -1548,9 +1548,9 @@ protected:
|
||||
// EndLoad() has already happened.
|
||||
nsWeakPtr mWeakSink;
|
||||
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mStyleSheets;
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mOnDemandBuiltInUASheets;
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mAdditionalSheets[AdditionalSheetTypeCount];
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr> mStyleSheets;
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr> mOnDemandBuiltInUASheets;
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr> mAdditionalSheets[AdditionalSheetTypeCount];
|
||||
|
||||
// Array of observers
|
||||
nsTObserverArray<nsIDocumentObserver*> mObservers;
|
||||
@ -1709,8 +1709,8 @@ private:
|
||||
friend class nsUnblockOnloadEvent;
|
||||
// Recomputes the visibility state but doesn't set the new value.
|
||||
mozilla::dom::VisibilityState GetVisibilityState() const;
|
||||
void NotifyStyleSheetAdded(mozilla::CSSStyleSheet* aSheet, bool aDocumentSheet);
|
||||
void NotifyStyleSheetRemoved(mozilla::CSSStyleSheet* aSheet, bool aDocumentSheet);
|
||||
void NotifyStyleSheetAdded(mozilla::StyleSheetHandle aSheet, bool aDocumentSheet);
|
||||
void NotifyStyleSheetRemoved(mozilla::StyleSheetHandle aSheet, bool aDocumentSheet);
|
||||
|
||||
void PostUnblockOnloadEvent();
|
||||
void DoUnblockOnload();
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include "prclist.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/StyleBackendType.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include <bitset> // for member
|
||||
|
||||
class gfxUserFontSet;
|
||||
@ -918,7 +920,7 @@ public:
|
||||
* TODO We can get rid of the whole concept of delayed loading if we fix
|
||||
* bug 77999.
|
||||
*/
|
||||
virtual void EnsureOnDemandBuiltInUASheet(mozilla::CSSStyleSheet* aSheet) = 0;
|
||||
virtual void EnsureOnDemandBuiltInUASheet(mozilla::StyleSheetHandle aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Get the number of (document) stylesheets
|
||||
@ -934,7 +936,7 @@ public:
|
||||
* @return the stylesheet at aIndex. Null if aIndex is out of range.
|
||||
* @throws no exceptions
|
||||
*/
|
||||
virtual mozilla::CSSStyleSheet* GetStyleSheetAt(int32_t aIndex) const = 0;
|
||||
virtual mozilla::StyleSheetHandle GetStyleSheetAt(int32_t aIndex) const = 0;
|
||||
|
||||
/**
|
||||
* Insert a sheet at a particular spot in the stylesheet list (zero-based)
|
||||
@ -943,7 +945,7 @@ public:
|
||||
* adjusted for the "special" sheets.
|
||||
* @throws no exceptions
|
||||
*/
|
||||
virtual void InsertStyleSheetAt(mozilla::CSSStyleSheet* aSheet,
|
||||
virtual void InsertStyleSheetAt(mozilla::StyleSheetHandle aSheet,
|
||||
int32_t aIndex) = 0;
|
||||
|
||||
/**
|
||||
@ -952,7 +954,7 @@ public:
|
||||
* @param aSheet the sheet to get the index of
|
||||
* @return aIndex the index of the sheet in the full list
|
||||
*/
|
||||
virtual int32_t GetIndexOfStyleSheet(mozilla::CSSStyleSheet* aSheet) const = 0;
|
||||
virtual int32_t GetIndexOfStyleSheet(mozilla::StyleSheetHandle aSheet) const = 0;
|
||||
|
||||
/**
|
||||
* Replace the stylesheets in aOldSheets with the stylesheets in
|
||||
@ -963,24 +965,24 @@ public:
|
||||
* will simply be removed.
|
||||
*/
|
||||
virtual void UpdateStyleSheets(
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aOldSheets,
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aNewSheets) = 0;
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr>& aOldSheets,
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr>& aNewSheets) = 0;
|
||||
|
||||
/**
|
||||
* Add a stylesheet to the document
|
||||
*/
|
||||
virtual void AddStyleSheet(mozilla::CSSStyleSheet* aSheet) = 0;
|
||||
virtual void AddStyleSheet(mozilla::StyleSheetHandle aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Remove a stylesheet from the document
|
||||
*/
|
||||
virtual void RemoveStyleSheet(mozilla::CSSStyleSheet* aSheet) = 0;
|
||||
virtual void RemoveStyleSheet(mozilla::StyleSheetHandle aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that the applicable state of the sheet changed
|
||||
* and that observers should be notified and style sets updated
|
||||
*/
|
||||
virtual void SetStyleSheetApplicableState(mozilla::CSSStyleSheet* aSheet,
|
||||
virtual void SetStyleSheetApplicableState(mozilla::StyleSheetHandle aSheet,
|
||||
bool aApplicable) = 0;
|
||||
|
||||
enum additionalSheetType {
|
||||
@ -993,10 +995,10 @@ public:
|
||||
virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType,
|
||||
nsIURI* aSheetURI) = 0;
|
||||
virtual nsresult AddAdditionalStyleSheet(additionalSheetType aType,
|
||||
mozilla::CSSStyleSheet* aSheet) = 0;
|
||||
mozilla::StyleSheetHandle aSheet) = 0;
|
||||
virtual void RemoveAdditionalStyleSheet(additionalSheetType aType,
|
||||
nsIURI* sheetURI) = 0;
|
||||
virtual mozilla::CSSStyleSheet* FirstAdditionalAuthorSheet() = 0;
|
||||
virtual mozilla::StyleSheetHandle FirstAdditionalAuthorSheet() = 0;
|
||||
|
||||
/**
|
||||
* Get this document's CSSLoader. This is guaranteed to not return null.
|
||||
@ -1005,6 +1007,8 @@ public:
|
||||
return mCSSLoader;
|
||||
}
|
||||
|
||||
mozilla::StyleBackendType GetStyleBackendType() const;
|
||||
|
||||
/**
|
||||
* Get this document's StyleImageLoader. This is guaranteed to not return null.
|
||||
*/
|
||||
@ -1292,11 +1296,11 @@ public:
|
||||
|
||||
// Observation hooks for style data to propagate notifications
|
||||
// to document observers
|
||||
virtual void StyleRuleChanged(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleChanged(mozilla::StyleSheetHandle aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) = 0;
|
||||
virtual void StyleRuleAdded(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleAdded(mozilla::StyleSheetHandle aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) = 0;
|
||||
virtual void StyleRuleRemoved(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleRemoved(mozilla::StyleSheetHandle aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) = 0;
|
||||
|
||||
/**
|
||||
@ -2091,7 +2095,7 @@ public:
|
||||
* DO NOT USE FOR UNTRUSTED CONTENT.
|
||||
*/
|
||||
virtual nsresult LoadChromeSheetSync(nsIURI* aURI, bool aIsAgentSheet,
|
||||
mozilla::CSSStyleSheet** aSheet) = 0;
|
||||
mozilla::StyleSheetHandle::RefPtr* aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Returns true if the locale used for the document specifies a direction of
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define nsIDocumentObserver_h___
|
||||
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIMutationObserver.h"
|
||||
|
||||
@ -14,7 +15,6 @@ class nsIContent;
|
||||
class nsIDocument;
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
namespace css {
|
||||
class Rule;
|
||||
} // namespace css
|
||||
@ -100,7 +100,7 @@ public:
|
||||
* @param aDocumentSheet True if sheet is in document's style sheet list,
|
||||
* false if sheet is not (i.e., UA or user sheet)
|
||||
*/
|
||||
virtual void StyleSheetAdded(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleSheetAdded(mozilla::StyleSheetHandle aStyleSheet,
|
||||
bool aDocumentSheet) = 0;
|
||||
|
||||
/**
|
||||
@ -113,7 +113,7 @@ public:
|
||||
* @param aDocumentSheet True if sheet is in document's style sheet list,
|
||||
* false if sheet is not (i.e., UA or user sheet)
|
||||
*/
|
||||
virtual void StyleSheetRemoved(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
virtual void StyleSheetRemoved(mozilla::StyleSheetHandle aStyleSheet,
|
||||
bool aDocumentSheet) = 0;
|
||||
|
||||
/**
|
||||
@ -125,7 +125,7 @@ public:
|
||||
*
|
||||
* @param aStyleSheet the StyleSheet that has changed state
|
||||
*/
|
||||
virtual void StyleSheetApplicableStateChanged(mozilla::CSSStyleSheet* aStyleSheet) = 0;
|
||||
virtual void StyleSheetApplicableStateChanged(mozilla::StyleSheetHandle aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* A StyleRule has just been modified within a style sheet.
|
||||
@ -136,7 +136,7 @@ public:
|
||||
*
|
||||
* @param aStyleSheet the StyleSheet that contians the rule
|
||||
*/
|
||||
virtual void StyleRuleChanged(mozilla::CSSStyleSheet* aStyleSheet) = 0;
|
||||
virtual void StyleRuleChanged(mozilla::StyleSheetHandle aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* A StyleRule has just been added to a style sheet.
|
||||
@ -147,7 +147,7 @@ public:
|
||||
*
|
||||
* @param aStyleSheet the StyleSheet that has been modified
|
||||
*/
|
||||
virtual void StyleRuleAdded(mozilla::CSSStyleSheet* aStyleSheet) = 0;
|
||||
virtual void StyleRuleAdded(mozilla::StyleSheetHandle aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* A StyleRule has just been removed from a style sheet.
|
||||
@ -158,7 +158,7 @@ public:
|
||||
*
|
||||
* @param aStyleSheet the StyleSheet that has been modified
|
||||
*/
|
||||
virtual void StyleRuleRemoved(mozilla::CSSStyleSheet* aStyleSheet) = 0;
|
||||
virtual void StyleRuleRemoved(mozilla::StyleSheetHandle aStyleSheet) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
|
||||
@ -186,25 +186,25 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
|
||||
mozilla::EventStates aStateMask) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED \
|
||||
virtual void StyleSheetAdded(mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
virtual void StyleSheetAdded(mozilla::StyleSheetHandle aStyleSheet, \
|
||||
bool aDocumentSheet) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED \
|
||||
virtual void StyleSheetRemoved(mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
virtual void StyleSheetRemoved(mozilla::StyleSheetHandle aStyleSheet, \
|
||||
bool aDocumentSheet) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETAPPLICABLESTATECHANGED \
|
||||
virtual void StyleSheetApplicableStateChanged( \
|
||||
mozilla::CSSStyleSheet* aStyleSheet) override;
|
||||
mozilla::StyleSheetHandle aStyleSheet) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULECHANGED \
|
||||
virtual void StyleRuleChanged(mozilla::CSSStyleSheet* aStyleSheet) override;
|
||||
virtual void StyleRuleChanged(mozilla::StyleSheetHandle aStyleSheet) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEADDED \
|
||||
virtual void StyleRuleAdded(mozilla::CSSStyleSheet* aStyleSheet) override;
|
||||
virtual void StyleRuleAdded(mozilla::StyleSheetHandle aStyleSheet) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEREMOVED \
|
||||
virtual void StyleRuleRemoved(mozilla::CSSStyleSheet* aStyleSheet) override;
|
||||
virtual void StyleRuleRemoved(mozilla::StyleSheetHandle aStyleSheet) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER \
|
||||
NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE \
|
||||
@ -262,29 +262,29 @@ NS_IMPL_NSIMUTATIONOBSERVER_CONTENT(_class)
|
||||
|
||||
#define NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(_class) \
|
||||
void \
|
||||
_class::StyleSheetAdded(mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
_class::StyleSheetAdded(mozilla::StyleSheetHandle aStyleSheet, \
|
||||
bool aDocumentSheet) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleSheetRemoved(mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
_class::StyleSheetRemoved(mozilla::StyleSheetHandle aStyleSheet, \
|
||||
bool aDocumentSheet) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleSheetApplicableStateChanged(mozilla::CSSStyleSheet* aStyleSheet) \
|
||||
_class::StyleSheetApplicableStateChanged(mozilla::StyleSheetHandle aStyleSheet) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleRuleChanged(mozilla::CSSStyleSheet* aStyleSheet) \
|
||||
_class::StyleRuleChanged(mozilla::StyleSheetHandle aStyleSheet) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleRuleAdded(mozilla::CSSStyleSheet* aStyleSheet) \
|
||||
_class::StyleRuleAdded(mozilla::StyleSheetHandle aStyleSheet) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleRuleRemoved(mozilla::CSSStyleSheet* aStyleSheet) \
|
||||
_class::StyleRuleRemoved(mozilla::StyleSheetHandle aStyleSheet) \
|
||||
{ \
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
|
||||
class nsICSSLoaderObserver;
|
||||
class nsIURI;
|
||||
@ -16,10 +17,6 @@ class nsIURI;
|
||||
{ 0xa8b79f3b, 0x9d18, 0x4f9c, \
|
||||
{ 0xb1, 0xaa, 0x8c, 0x9b, 0x1b, 0xaa, 0xac, 0xad } }
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
} // namespace mozilla
|
||||
|
||||
class nsIStyleSheetLinkingElement : public nsISupports {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLESHEETLINKINGELEMENT_IID)
|
||||
@ -31,14 +28,14 @@ public:
|
||||
* @param aStyleSheet the style sheet associated with this
|
||||
* element.
|
||||
*/
|
||||
NS_IMETHOD SetStyleSheet(mozilla::CSSStyleSheet* aStyleSheet) = 0;
|
||||
NS_IMETHOD SetStyleSheet(mozilla::StyleSheetHandle aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* Used to obtain the style sheet linked in by this element.
|
||||
*
|
||||
* @return the style sheet associated with this element.
|
||||
*/
|
||||
NS_IMETHOD_(mozilla::CSSStyleSheet*) GetStyleSheet() = 0;
|
||||
NS_IMETHOD_(mozilla::StyleSheetHandle) GetStyleSheet() = 0;
|
||||
|
||||
/**
|
||||
* Initialize the stylesheet linking element. If aDontLoadStyle is
|
||||
|
@ -12,7 +12,8 @@
|
||||
|
||||
#include "nsStyleLinkElement.h"
|
||||
|
||||
#include "mozilla/CSSStyleSheet.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/FragmentOrElement.h"
|
||||
@ -67,7 +68,7 @@ nsStyleLinkElement::Traverse(nsCycleCollectionTraversalCallback &cb)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStyleLinkElement::SetStyleSheet(CSSStyleSheet* aStyleSheet)
|
||||
nsStyleLinkElement::SetStyleSheet(StyleSheetHandle aStyleSheet)
|
||||
{
|
||||
if (mStyleSheet) {
|
||||
mStyleSheet->SetOwningNode(nullptr);
|
||||
@ -84,7 +85,7 @@ nsStyleLinkElement::SetStyleSheet(CSSStyleSheet* aStyleSheet)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(CSSStyleSheet*)
|
||||
NS_IMETHODIMP_(StyleSheetHandle)
|
||||
nsStyleLinkElement::GetStyleSheet()
|
||||
{
|
||||
return mStyleSheet;
|
||||
@ -316,8 +317,15 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Element* oldScopeElement =
|
||||
mStyleSheet ? mStyleSheet->GetScopeElement() : nullptr;
|
||||
// XXXheycam ServoStyleSheets do not support <style scoped>.
|
||||
Element* oldScopeElement = nullptr;
|
||||
if (mStyleSheet) {
|
||||
if (mStyleSheet->IsServo()) {
|
||||
NS_ERROR("stylo: ServoStyleSheets don't support <style scoped>");
|
||||
} else {
|
||||
oldScopeElement = mStyleSheet->AsGecko()->GetScopeElement();
|
||||
}
|
||||
}
|
||||
|
||||
if (mStyleSheet && (aOldDocument || aOldShadowRoot)) {
|
||||
MOZ_ASSERT(!(aOldDocument && aOldShadowRoot),
|
||||
@ -465,10 +473,18 @@ nsStyleLinkElement::UpdateStyleSheetScopedness(bool aIsNowScoped)
|
||||
return;
|
||||
}
|
||||
|
||||
if (mStyleSheet->IsServo()) {
|
||||
// XXXheycam ServoStyleSheets don't support <style scoped>.
|
||||
NS_ERROR("stylo: ServoStyleSheets don't support <style scoped>");
|
||||
return;
|
||||
}
|
||||
|
||||
CSSStyleSheet* sheet = mStyleSheet->AsGecko();
|
||||
|
||||
nsCOMPtr<nsIContent> thisContent;
|
||||
CallQueryInterface(this, getter_AddRefs(thisContent));
|
||||
|
||||
Element* oldScopeElement = mStyleSheet->GetScopeElement();
|
||||
Element* oldScopeElement = sheet->GetScopeElement();
|
||||
Element* newScopeElement = aIsNowScoped ?
|
||||
thisContent->GetParentElement() :
|
||||
nullptr;
|
||||
@ -483,14 +499,14 @@ nsStyleLinkElement::UpdateStyleSheetScopedness(bool aIsNowScoped)
|
||||
ShadowRoot* containingShadow = thisContent->GetContainingShadow();
|
||||
containingShadow->RemoveSheet(mStyleSheet);
|
||||
|
||||
mStyleSheet->SetScopeElement(newScopeElement);
|
||||
sheet->SetScopeElement(newScopeElement);
|
||||
|
||||
containingShadow->InsertSheet(mStyleSheet, thisContent);
|
||||
} else {
|
||||
document->BeginUpdate(UPDATE_STYLE);
|
||||
document->RemoveStyleSheet(mStyleSheet);
|
||||
|
||||
mStyleSheet->SetScopeElement(newScopeElement);
|
||||
sheet->SetScopeElement(newScopeElement);
|
||||
|
||||
document->AddStyleSheet(mStyleSheet);
|
||||
document->EndUpdate(UPDATE_STYLE);
|
||||
|
@ -24,6 +24,7 @@ class nsIDocument;
|
||||
class nsIURI;
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
namespace dom {
|
||||
class ShadowRoot;
|
||||
} // namespace dom
|
||||
@ -37,11 +38,19 @@ public:
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override = 0;
|
||||
|
||||
mozilla::CSSStyleSheet* GetSheet() const { return mStyleSheet; }
|
||||
mozilla::CSSStyleSheet* GetSheet() const
|
||||
{
|
||||
// XXXheycam Return nullptr for ServoStyleSheets until we have a way of
|
||||
// exposing them to script.
|
||||
NS_ASSERTION(!mStyleSheet || mStyleSheet->IsGecko(),
|
||||
"stylo: ServoStyleSheets can't be exposed to script yet");
|
||||
return mStyleSheet && mStyleSheet->IsGecko() ? mStyleSheet->AsGecko() :
|
||||
nullptr;
|
||||
}
|
||||
|
||||
// nsIStyleSheetLinkingElement
|
||||
NS_IMETHOD SetStyleSheet(mozilla::CSSStyleSheet* aStyleSheet) override;
|
||||
NS_IMETHOD_(mozilla::CSSStyleSheet*) GetStyleSheet() override;
|
||||
NS_IMETHOD SetStyleSheet(mozilla::StyleSheetHandle aStyleSheet) override;
|
||||
NS_IMETHOD_(mozilla::StyleSheetHandle) GetStyleSheet() override;
|
||||
NS_IMETHOD InitStyleLinkElement(bool aDontLoadStyle) override;
|
||||
NS_IMETHOD UpdateStyleSheet(nsICSSLoaderObserver* aObserver,
|
||||
bool* aWillNotify,
|
||||
@ -128,7 +137,7 @@ private:
|
||||
bool* aIsAlternate,
|
||||
bool aForceUpdate);
|
||||
|
||||
RefPtr<mozilla::CSSStyleSheet> mStyleSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mStyleSheet;
|
||||
protected:
|
||||
bool mDontLoadStyle;
|
||||
bool mUpdatesEnabled;
|
||||
|
@ -114,6 +114,8 @@
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -2641,12 +2643,14 @@ nsHTMLDocument::TearingDownEditor(nsIEditor *aEditor)
|
||||
if (!presShell)
|
||||
return;
|
||||
|
||||
nsTArray<RefPtr<CSSStyleSheet>> agentSheets;
|
||||
nsTArray<StyleSheetHandle::RefPtr> agentSheets;
|
||||
presShell->GetAgentStyleSheets(agentSheets);
|
||||
|
||||
agentSheets.RemoveElement(nsLayoutStylesheetCache::ContentEditableSheet());
|
||||
auto cache = nsLayoutStylesheetCache::For(GetStyleBackendType());
|
||||
|
||||
agentSheets.RemoveElement(cache->ContentEditableSheet());
|
||||
if (oldState == eDesignMode)
|
||||
agentSheets.RemoveElement(nsLayoutStylesheetCache::DesignModeSheet());
|
||||
agentSheets.RemoveElement(cache->DesignModeSheet());
|
||||
|
||||
presShell->SetAgentStyleSheets(agentSheets);
|
||||
|
||||
@ -2780,12 +2784,13 @@ nsHTMLDocument::EditingStateChanged()
|
||||
// Before making this window editable, we need to modify UA style sheet
|
||||
// because new style may change whether focused element will be focusable
|
||||
// or not.
|
||||
nsTArray<RefPtr<CSSStyleSheet>> agentSheets;
|
||||
nsTArray<StyleSheetHandle::RefPtr> agentSheets;
|
||||
rv = presShell->GetAgentStyleSheets(agentSheets);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
CSSStyleSheet* contentEditableSheet =
|
||||
nsLayoutStylesheetCache::ContentEditableSheet();
|
||||
auto cache = nsLayoutStylesheetCache::For(GetStyleBackendType());
|
||||
|
||||
StyleSheetHandle contentEditableSheet = cache->ContentEditableSheet();
|
||||
|
||||
if (!agentSheets.Contains(contentEditableSheet)) {
|
||||
agentSheets.AppendElement(contentEditableSheet);
|
||||
@ -2796,8 +2801,7 @@ nsHTMLDocument::EditingStateChanged()
|
||||
// specific states on the elements.
|
||||
if (designMode) {
|
||||
// designMode is being turned on (overrides contentEditable).
|
||||
CSSStyleSheet* designModeSheet =
|
||||
nsLayoutStylesheetCache::DesignModeSheet();
|
||||
StyleSheetHandle designModeSheet = cache->DesignModeSheet();
|
||||
if (!agentSheets.Contains(designModeSheet)) {
|
||||
agentSheets.AppendElement(designModeSheet);
|
||||
}
|
||||
@ -2807,7 +2811,7 @@ nsHTMLDocument::EditingStateChanged()
|
||||
}
|
||||
else if (oldState == eDesignMode) {
|
||||
// designMode is being turned off (contentEditable is still on).
|
||||
agentSheets.RemoveElement(nsLayoutStylesheetCache::DesignModeSheet());
|
||||
agentSheets.RemoveElement(cache->DesignModeSheet());
|
||||
updateState = true;
|
||||
}
|
||||
|
||||
|
@ -2584,7 +2584,10 @@ static void
|
||||
PreloadSlowThings()
|
||||
{
|
||||
// This fetches and creates all the built-in stylesheets.
|
||||
nsLayoutStylesheetCache::UserContentSheet();
|
||||
//
|
||||
// XXXheycam In the future we might want to preload the Servo-flavoured
|
||||
// UA sheets too, but for now that will be a waste of time.
|
||||
nsLayoutStylesheetCache::For(StyleBackendType::Gecko)->UserContentSheet();
|
||||
|
||||
TabChild::PreloadSlowThings();
|
||||
|
||||
|
@ -185,6 +185,8 @@
|
||||
#include "nsPluginHost.h"
|
||||
#include "nsPluginTags.h"
|
||||
#include "nsIBlocklistService.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
#include "nsIBidiKeyboard.h"
|
||||
|
||||
@ -2697,19 +2699,19 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
|
||||
// This looks like a lot of work, but in a normal browser session we just
|
||||
// send two loads.
|
||||
|
||||
for (CSSStyleSheet* sheet : *sheetService->AgentStyleSheets()) {
|
||||
for (StyleSheetHandle sheet : *sheetService->AgentStyleSheets()) {
|
||||
URIParams uri;
|
||||
SerializeURI(sheet->GetSheetURI(), uri);
|
||||
Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AGENT_SHEET);
|
||||
}
|
||||
|
||||
for (CSSStyleSheet* sheet : *sheetService->UserStyleSheets()) {
|
||||
for (StyleSheetHandle sheet : *sheetService->UserStyleSheets()) {
|
||||
URIParams uri;
|
||||
SerializeURI(sheet->GetSheetURI(), uri);
|
||||
Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::USER_SHEET);
|
||||
}
|
||||
|
||||
for (CSSStyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
|
||||
for (StyleSheetHandle sheet : *sheetService->AuthorStyleSheets()) {
|
||||
URIParams uri;
|
||||
SerializeURI(sheet->GetSheetURI(), uri);
|
||||
Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET);
|
||||
|
@ -111,9 +111,9 @@ nsMathMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
// Enable MathML and setup the style sheet during binding, not element
|
||||
// construction, because we could move a MathML element from the document
|
||||
// that created it to another document.
|
||||
auto cache = nsLayoutStylesheetCache::For(doc->GetStyleBackendType());
|
||||
doc->SetMathMLEnabled();
|
||||
doc->
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::MathMLSheet());
|
||||
doc->EnsureOnDemandBuiltInUASheet(cache->MathMLSheet());
|
||||
|
||||
// Rebuild style data for the presshell, because style system
|
||||
// optimizations may have taken place assuming MathML was disabled.
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "nsSVGElement.h"
|
||||
#include "mozilla/dom/SVGDocumentBinding.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
using namespace mozilla::css;
|
||||
using namespace mozilla::dom;
|
||||
@ -155,12 +157,12 @@ SVGDocument::EnsureNonSVGUserAgentStyleSheetsLoaded()
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), spec);
|
||||
if (uri) {
|
||||
RefPtr<CSSStyleSheet> cssSheet;
|
||||
StyleSheetHandle::RefPtr sheet;
|
||||
cssLoader->LoadSheetSync(uri,
|
||||
mozilla::css::eAgentSheetFeatures,
|
||||
true, getter_AddRefs(cssSheet));
|
||||
if (cssSheet) {
|
||||
EnsureOnDemandBuiltInUASheet(cssSheet);
|
||||
true, &sheet);
|
||||
if (sheet) {
|
||||
EnsureOnDemandBuiltInUASheet(sheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,21 +171,23 @@ SVGDocument::EnsureNonSVGUserAgentStyleSheetsLoaded()
|
||||
}
|
||||
}
|
||||
|
||||
CSSStyleSheet* sheet = nsLayoutStylesheetCache::NumberControlSheet();
|
||||
auto cache = nsLayoutStylesheetCache::For(GetStyleBackendType());
|
||||
|
||||
StyleSheetHandle sheet = cache->NumberControlSheet();
|
||||
if (sheet) {
|
||||
// number-control.css can be behind a pref
|
||||
EnsureOnDemandBuiltInUASheet(sheet);
|
||||
}
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::FormsSheet());
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::CounterStylesSheet());
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::HTMLSheet());
|
||||
EnsureOnDemandBuiltInUASheet(cache->FormsSheet());
|
||||
EnsureOnDemandBuiltInUASheet(cache->CounterStylesSheet());
|
||||
EnsureOnDemandBuiltInUASheet(cache->HTMLSheet());
|
||||
if (nsLayoutUtils::ShouldUseNoFramesSheet(this)) {
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::NoFramesSheet());
|
||||
EnsureOnDemandBuiltInUASheet(cache->NoFramesSheet());
|
||||
}
|
||||
if (nsLayoutUtils::ShouldUseNoScriptSheet(this)) {
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::NoScriptSheet());
|
||||
EnsureOnDemandBuiltInUASheet(cache->NoScriptSheet());
|
||||
}
|
||||
EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::UASheet());
|
||||
EnsureOnDemandBuiltInUASheet(cache->UASheet());
|
||||
|
||||
EndUpdate(UPDATE_STYLE);
|
||||
}
|
||||
|
@ -752,7 +752,8 @@ SVGSVGElement::BindToTree(nsIDocument* aDocument,
|
||||
// Setup the style sheet during binding, not element construction,
|
||||
// because we could move the root SVG element from the document
|
||||
// that created it to another document.
|
||||
doc->EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::SVGSheet());
|
||||
auto cache = nsLayoutStylesheetCache::For(doc->GetStyleBackendType());
|
||||
doc->EnsureOnDemandBuiltInUASheet(cache->SVGSheet());
|
||||
}
|
||||
|
||||
if (mTimedDocumentRoot && smilController) {
|
||||
|
@ -773,7 +773,7 @@ nsBindingManager::MediumFeaturesChanged(nsPresContext* aPresContext,
|
||||
}
|
||||
|
||||
void
|
||||
nsBindingManager::AppendAllSheets(nsTArray<CSSStyleSheet*>& aArray)
|
||||
nsBindingManager::AppendAllSheets(nsTArray<StyleSheetHandle>& aArray)
|
||||
{
|
||||
if (!mBoundContentSet) {
|
||||
return;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "nsXBLBinding.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
|
||||
struct ElementDependentRuleProcessorData;
|
||||
class nsIXPConnectWrappedJS;
|
||||
@ -31,10 +32,6 @@ typedef nsTArray<RefPtr<nsXBLBinding> > nsBindingList;
|
||||
class nsIPrincipal;
|
||||
class nsITimer;
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
} // namespace mozilla
|
||||
|
||||
class nsBindingManager final : public nsStubMutationObserver
|
||||
{
|
||||
~nsBindingManager();
|
||||
@ -129,7 +126,7 @@ public:
|
||||
nsresult MediumFeaturesChanged(nsPresContext* aPresContext,
|
||||
bool* aRulesChanged);
|
||||
|
||||
void AppendAllSheets(nsTArray<mozilla::CSSStyleSheet*>& aArray);
|
||||
void AppendAllSheets(nsTArray<mozilla::StyleSheetHandle>& aArray);
|
||||
|
||||
void Traverse(nsIContent *aContent,
|
||||
nsCycleCollectionTraversalCallback &cb);
|
||||
|
@ -44,6 +44,8 @@
|
||||
#include "mozilla/dom/CDATASection.h"
|
||||
#include "mozilla/dom/Comment.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsXULElement.h"
|
||||
@ -1630,14 +1632,14 @@ nsXBLPrototypeBinding::EnsureResources()
|
||||
}
|
||||
|
||||
void
|
||||
nsXBLPrototypeBinding::AppendStyleSheet(CSSStyleSheet* aSheet)
|
||||
nsXBLPrototypeBinding::AppendStyleSheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
EnsureResources();
|
||||
mResources->AppendStyleSheet(aSheet);
|
||||
}
|
||||
|
||||
void
|
||||
nsXBLPrototypeBinding::RemoveStyleSheet(CSSStyleSheet* aSheet)
|
||||
nsXBLPrototypeBinding::RemoveStyleSheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
if (!mResources) {
|
||||
MOZ_ASSERT(false, "Trying to remove a sheet that does not exist.");
|
||||
@ -1647,13 +1649,13 @@ nsXBLPrototypeBinding::RemoveStyleSheet(CSSStyleSheet* aSheet)
|
||||
mResources->RemoveStyleSheet(aSheet);
|
||||
}
|
||||
void
|
||||
nsXBLPrototypeBinding::InsertStyleSheetAt(size_t aIndex, CSSStyleSheet* aSheet)
|
||||
nsXBLPrototypeBinding::InsertStyleSheetAt(size_t aIndex, StyleSheetHandle aSheet)
|
||||
{
|
||||
EnsureResources();
|
||||
mResources->InsertStyleSheetAt(aIndex, aSheet);
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsXBLPrototypeBinding::StyleSheetAt(size_t aIndex) const
|
||||
{
|
||||
MOZ_ASSERT(mResources);
|
||||
@ -1674,7 +1676,7 @@ nsXBLPrototypeBinding::HasStyleSheets() const
|
||||
|
||||
void
|
||||
nsXBLPrototypeBinding::AppendStyleSheetsTo(
|
||||
nsTArray<CSSStyleSheet*>& aResult) const
|
||||
nsTArray<StyleSheetHandle>& aResult) const
|
||||
{
|
||||
if (mResources) {
|
||||
mResources->AppendStyleSheetsTo(aResult);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "nsXBLPrototypeHandler.h"
|
||||
#include "nsXBLPrototypeResources.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
@ -27,10 +28,6 @@ class nsXBLAttributeEntry;
|
||||
class nsXBLBinding;
|
||||
class nsXBLProtoImplField;
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
} // namespace mozilla
|
||||
|
||||
// *********************************************************************/
|
||||
// The XBLPrototypeBinding class
|
||||
|
||||
@ -122,13 +119,13 @@ public:
|
||||
|
||||
void SetInitialAttributes(nsIContent* aBoundElement, nsIContent* aAnonymousContent);
|
||||
|
||||
void AppendStyleSheet(mozilla::CSSStyleSheet* aSheet);
|
||||
void RemoveStyleSheet(mozilla::CSSStyleSheet* aSheet);
|
||||
void InsertStyleSheetAt(size_t aIndex, mozilla::CSSStyleSheet* aSheet);
|
||||
mozilla::CSSStyleSheet* StyleSheetAt(size_t aIndex) const;
|
||||
void AppendStyleSheet(mozilla::StyleSheetHandle aSheet);
|
||||
void RemoveStyleSheet(mozilla::StyleSheetHandle aSheet);
|
||||
void InsertStyleSheetAt(size_t aIndex, mozilla::StyleSheetHandle aSheet);
|
||||
mozilla::StyleSheetHandle StyleSheetAt(size_t aIndex) const;
|
||||
size_t SheetCount() const;
|
||||
bool HasStyleSheets() const;
|
||||
void AppendStyleSheetsTo(nsTArray<mozilla::CSSStyleSheet*>& aResult) const;
|
||||
void AppendStyleSheetsTo(nsTArray<mozilla::StyleSheetHandle>& aResult) const;
|
||||
|
||||
nsIStyleRuleProcessor* GetRuleProcessor();
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "nsStyleSet.h"
|
||||
#include "mozilla/dom/URL.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using mozilla::dom::IsChromeURI;
|
||||
@ -80,20 +82,20 @@ nsXBLPrototypeResources::FlushSkinSheets()
|
||||
// encounter. (If they aren't skin sheets, it doesn't matter, since
|
||||
// they'll still be in the chrome cache.
|
||||
|
||||
nsTArray<RefPtr<CSSStyleSheet>> oldSheets;
|
||||
nsTArray<StyleSheetHandle::RefPtr> oldSheets;
|
||||
|
||||
oldSheets.SwapElements(mStyleSheetList);
|
||||
|
||||
mozilla::css::Loader* cssLoader = doc->CSSLoader();
|
||||
|
||||
for (size_t i = 0, count = oldSheets.Length(); i < count; ++i) {
|
||||
CSSStyleSheet* oldSheet = oldSheets[i];
|
||||
StyleSheetHandle oldSheet = oldSheets[i];
|
||||
|
||||
nsIURI* uri = oldSheet->GetSheetURI();
|
||||
|
||||
RefPtr<CSSStyleSheet> newSheet;
|
||||
StyleSheetHandle::RefPtr newSheet;
|
||||
if (IsChromeURI(uri)) {
|
||||
if (NS_FAILED(cssLoader->LoadSheetSync(uri, getter_AddRefs(newSheet))))
|
||||
if (NS_FAILED(cssLoader->LoadSheetSync(uri, &newSheet)))
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
@ -142,31 +144,39 @@ nsXBLPrototypeResources::ClearLoader()
|
||||
void
|
||||
nsXBLPrototypeResources::GatherRuleProcessor()
|
||||
{
|
||||
mRuleProcessor = new nsCSSRuleProcessor(mStyleSheetList,
|
||||
nsTArray<RefPtr<CSSStyleSheet>> sheets(mStyleSheetList.Length());
|
||||
for (StyleSheetHandle sheet : mStyleSheetList) {
|
||||
MOZ_ASSERT(sheet->IsGecko(),
|
||||
"GatherRuleProcessor must only be called for "
|
||||
"nsXBLPrototypeResources objects with Gecko-flavored style "
|
||||
"backends");
|
||||
sheets.AppendElement(sheet->AsGecko());
|
||||
}
|
||||
mRuleProcessor = new nsCSSRuleProcessor(sheets,
|
||||
SheetType::Doc,
|
||||
nullptr,
|
||||
mRuleProcessor);
|
||||
}
|
||||
|
||||
void
|
||||
nsXBLPrototypeResources::AppendStyleSheet(CSSStyleSheet* aSheet)
|
||||
nsXBLPrototypeResources::AppendStyleSheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
mStyleSheetList.AppendElement(aSheet);
|
||||
}
|
||||
|
||||
void
|
||||
nsXBLPrototypeResources::RemoveStyleSheet(CSSStyleSheet* aSheet)
|
||||
nsXBLPrototypeResources::RemoveStyleSheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
mStyleSheetList.RemoveElement(aSheet);
|
||||
}
|
||||
|
||||
void
|
||||
nsXBLPrototypeResources::InsertStyleSheetAt(size_t aIndex, CSSStyleSheet* aSheet)
|
||||
nsXBLPrototypeResources::InsertStyleSheetAt(size_t aIndex, StyleSheetHandle aSheet)
|
||||
{
|
||||
mStyleSheetList.InsertElementAt(aIndex, aSheet);
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsXBLPrototypeResources::StyleSheetAt(size_t aIndex) const
|
||||
{
|
||||
return mStyleSheetList[aIndex];
|
||||
@ -186,7 +196,7 @@ nsXBLPrototypeResources::HasStyleSheets() const
|
||||
|
||||
void
|
||||
nsXBLPrototypeResources::AppendStyleSheetsTo(
|
||||
nsTArray<CSSStyleSheet*>& aResult) const
|
||||
nsTArray<StyleSheetHandle>& aResult) const
|
||||
{
|
||||
aResult.AppendElements(mStyleSheetList);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#ifndef nsXBLPrototypeResources_h__
|
||||
#define nsXBLPrototypeResources_h__
|
||||
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsICSSLoaderObserver.h"
|
||||
|
||||
@ -41,13 +42,13 @@ public:
|
||||
|
||||
void ClearLoader();
|
||||
|
||||
void AppendStyleSheet(mozilla::CSSStyleSheet* aSheet);
|
||||
void RemoveStyleSheet(mozilla::CSSStyleSheet* aSheet);
|
||||
void InsertStyleSheetAt(size_t aIndex, mozilla::CSSStyleSheet* aSheet);
|
||||
mozilla::CSSStyleSheet* StyleSheetAt(size_t aIndex) const;
|
||||
void AppendStyleSheet(mozilla::StyleSheetHandle aSheet);
|
||||
void RemoveStyleSheet(mozilla::StyleSheetHandle aSheet);
|
||||
void InsertStyleSheetAt(size_t aIndex, mozilla::StyleSheetHandle aSheet);
|
||||
mozilla::StyleSheetHandle StyleSheetAt(size_t aIndex) const;
|
||||
size_t SheetCount() const;
|
||||
bool HasStyleSheets() const;
|
||||
void AppendStyleSheetsTo(nsTArray<mozilla::CSSStyleSheet*>& aResult) const;
|
||||
void AppendStyleSheetsTo(nsTArray<mozilla::StyleSheetHandle>& aResult) const;
|
||||
|
||||
/**
|
||||
* Recreates mRuleProcessor to represent the current list of style sheets
|
||||
@ -63,7 +64,7 @@ private:
|
||||
RefPtr<nsXBLResourceLoader> mLoader;
|
||||
|
||||
// A list of loaded stylesheets for this binding.
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mStyleSheetList;
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr> mStyleSheetList;
|
||||
|
||||
// The list of stylesheets converted to a rule processor.
|
||||
RefPtr<nsCSSRuleProcessor> mRuleProcessor;
|
||||
|
@ -17,7 +17,8 @@
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "imgILoader.h"
|
||||
#include "imgRequestProxy.h"
|
||||
#include "mozilla/CSSStyleSheet.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
@ -139,8 +140,8 @@ nsXBLResourceLoader::LoadResources(bool* aResult)
|
||||
CheckLoadURIWithPrincipal(docPrincipal, url,
|
||||
nsIScriptSecurityManager::ALLOW_CHROME);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
RefPtr<CSSStyleSheet> sheet;
|
||||
rv = cssLoader->LoadSheetSync(url, getter_AddRefs(sheet));
|
||||
StyleSheetHandle::RefPtr sheet;
|
||||
rv = cssLoader->LoadSheetSync(url, &sheet);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Load failed!!!");
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
@ -168,7 +169,7 @@ nsXBLResourceLoader::LoadResources(bool* aResult)
|
||||
|
||||
// nsICSSLoaderObserver
|
||||
NS_IMETHODIMP
|
||||
nsXBLResourceLoader::StyleSheetLoaded(CSSStyleSheet* aSheet,
|
||||
nsXBLResourceLoader::StyleSheetLoaded(StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus)
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(nsXBLResourceLoader)
|
||||
|
||||
// nsICSSLoaderObserver
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet,
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus) override;
|
||||
|
||||
|
@ -411,7 +411,7 @@ nsXMLContentSink::OnTransformDone(nsresult aResult,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::StyleSheetLoaded(CSSStyleSheet* aSheet,
|
||||
nsXMLContentSink::StyleSheetLoaded(StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus)
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
NS_IMETHOD OnTransformDone(nsresult aResult, nsIDocument *aResultDocument) override;
|
||||
|
||||
// nsICSSLoaderObserver
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet,
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus) override;
|
||||
static bool ParsePIData(const nsString &aData, nsString &aHref,
|
||||
|
@ -976,7 +976,7 @@ txTransformNotifier::ScriptEvaluated(nsresult aResult,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
txTransformNotifier::StyleSheetLoaded(CSSStyleSheet* aSheet,
|
||||
txTransformNotifier::StyleSheetLoaded(StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus)
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
NS_DECL_NSISCRIPTLOADEROBSERVER
|
||||
|
||||
// nsICSSLoaderObserver
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet,
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus) override;
|
||||
|
||||
|
@ -93,6 +93,8 @@
|
||||
#include "mozilla/dom/URL.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -3098,7 +3100,7 @@ XULDocument::DoneWalking()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULDocument::StyleSheetLoaded(CSSStyleSheet* aSheet,
|
||||
XULDocument::StyleSheetLoaded(StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus)
|
||||
{
|
||||
@ -3727,11 +3729,11 @@ XULDocument::AddPrototypeSheets()
|
||||
for (int32_t i = 0; i < sheets.Count(); i++) {
|
||||
nsCOMPtr<nsIURI> uri = sheets[i];
|
||||
|
||||
RefPtr<CSSStyleSheet> incompleteSheet;
|
||||
StyleSheetHandle::RefPtr incompleteSheet;
|
||||
rv = CSSLoader()->LoadSheet(uri,
|
||||
mCurrentPrototype->DocumentPrincipal(),
|
||||
EmptyCString(), this,
|
||||
getter_AddRefs(incompleteSheet));
|
||||
&incompleteSheet);
|
||||
|
||||
// XXXldb We need to prevent bogus sheets from being held in the
|
||||
// prototype's list, but until then, don't propagate the failure
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "nsTArray.h"
|
||||
|
||||
#include "mozilla/dom/XMLDocument.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "nsForwardReference.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMXULCommandDispatcher.h"
|
||||
@ -161,7 +162,7 @@ public:
|
||||
NS_DECL_NSIDOMXULDOCUMENT
|
||||
|
||||
// nsICSSLoaderObserver
|
||||
NS_IMETHOD StyleSheetLoaded(CSSStyleSheet* aSheet,
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus) override;
|
||||
|
||||
@ -342,7 +343,7 @@ protected:
|
||||
* An array of style sheets, that will be added (preserving order) to the
|
||||
* document after all of them are loaded (in DoneWalking).
|
||||
*/
|
||||
nsTArray<RefPtr<CSSStyleSheet>> mOverlaySheets;
|
||||
nsTArray<StyleSheetHandle::RefPtr> mOverlaySheets;
|
||||
|
||||
nsCOMPtr<nsIDOMXULCommandDispatcher> mCommandDispatcher; // [OWNER] of the focus tracker
|
||||
|
||||
|
@ -859,7 +859,8 @@ nsXULElement::BindToTree(nsIDocument* aDocument,
|
||||
// can be moved from the document that creates them to another document.
|
||||
|
||||
if (!XULElementsRulesInMinimalXULSheet(NodeInfo()->NameAtom())) {
|
||||
doc->EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::XULSheet());
|
||||
auto cache = nsLayoutStylesheetCache::For(doc->GetStyleBackendType());
|
||||
doc->EnsureOnDemandBuiltInUASheet(cache->XULSheet());
|
||||
// To keep memory usage down it is important that we try and avoid
|
||||
// pulling xul.css into non-XUL documents. That should be very rare, and
|
||||
// for HTML we currently should only pull it in if the document contains
|
||||
|
@ -4253,7 +4253,7 @@ nsEditor::CreateTxnForIMEText(const nsAString& aStringToInsert)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::CreateTxnForAddStyleSheet(CSSStyleSheet* aSheet, AddStyleSheetTxn* *aTxn)
|
||||
nsEditor::CreateTxnForAddStyleSheet(StyleSheetHandle aSheet, AddStyleSheetTxn* *aTxn)
|
||||
{
|
||||
RefPtr<AddStyleSheetTxn> txn = new AddStyleSheetTxn();
|
||||
|
||||
@ -4269,7 +4269,7 @@ nsEditor::CreateTxnForAddStyleSheet(CSSStyleSheet* aSheet, AddStyleSheetTxn* *aT
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditor::CreateTxnForRemoveStyleSheet(CSSStyleSheet* aSheet, RemoveStyleSheetTxn* *aTxn)
|
||||
nsEditor::CreateTxnForRemoveStyleSheet(StyleSheetHandle aSheet, RemoveStyleSheetTxn* *aTxn)
|
||||
{
|
||||
RefPtr<RemoveStyleSheetTxn> txn = new RemoveStyleSheetTxn();
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc.
|
||||
#include "mozilla/OwningNonNull.h" // for OwningNonNull
|
||||
#include "mozilla/StyleSheetHandle.h" // for StyleSheetHandle
|
||||
#include "mozilla/dom/Text.h"
|
||||
#include "nsAutoPtr.h" // for nsRefPtr
|
||||
#include "nsCOMPtr.h" // for already_AddRefed, nsCOMPtr
|
||||
@ -55,7 +56,6 @@ class nsTransactionManager;
|
||||
struct DOMPoint;
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
class ErrorResult;
|
||||
class TextComposition;
|
||||
|
||||
@ -311,12 +311,12 @@ protected:
|
||||
|
||||
/** create a transaction for adding a style sheet
|
||||
*/
|
||||
NS_IMETHOD CreateTxnForAddStyleSheet(mozilla::CSSStyleSheet* aSheet,
|
||||
NS_IMETHOD CreateTxnForAddStyleSheet(mozilla::StyleSheetHandle aSheet,
|
||||
AddStyleSheetTxn* *aTxn);
|
||||
|
||||
/** create a transaction for removing a style sheet
|
||||
*/
|
||||
NS_IMETHOD CreateTxnForRemoveStyleSheet(mozilla::CSSStyleSheet* aSheet,
|
||||
NS_IMETHOD CreateTxnForRemoveStyleSheet(mozilla::StyleSheetHandle aSheet,
|
||||
RemoveStyleSheetTxn* *aTxn);
|
||||
|
||||
nsresult DeleteText(nsGenericDOMDataNode& aElement,
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "nsILinkHandler.h"
|
||||
#include "nsIInlineSpellChecker.h"
|
||||
|
||||
#include "mozilla/CSSStyleSheet.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
#include "nsIDOMStyleSheet.h"
|
||||
|
||||
@ -75,6 +74,8 @@
|
||||
#include "mozilla/dom/HTMLBodyElement.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include "nsContentList.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -2825,13 +2826,11 @@ nsHTMLEditor::ReplaceStyleSheet(const nsAString& aURL)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::RemoveStyleSheet(const nsAString &aURL)
|
||||
{
|
||||
RefPtr<CSSStyleSheet> sheet;
|
||||
nsresult rv = GetStyleSheetForURL(aURL, getter_AddRefs(sheet));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
StyleSheetHandle::RefPtr sheet = GetStyleSheetForURL(aURL);
|
||||
NS_ENSURE_TRUE(sheet, NS_ERROR_UNEXPECTED);
|
||||
|
||||
RefPtr<RemoveStyleSheetTxn> txn;
|
||||
rv = CreateTxnForRemoveStyleSheet(sheet, getter_AddRefs(txn));
|
||||
nsresult rv = CreateTxnForRemoveStyleSheet(sheet, getter_AddRefs(txn));
|
||||
if (!txn) rv = NS_ERROR_NULL_POINTER;
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
@ -2865,11 +2864,11 @@ nsHTMLEditor::AddOverrideStyleSheet(const nsAString& aURL)
|
||||
// We MUST ONLY load synchronous local files (no @import)
|
||||
// XXXbz Except this will actually try to load remote files
|
||||
// synchronously, of course..
|
||||
RefPtr<CSSStyleSheet> sheet;
|
||||
StyleSheetHandle::RefPtr sheet;
|
||||
// Editor override style sheets may want to style Gecko anonymous boxes
|
||||
rv = ps->GetDocument()->CSSLoader()->
|
||||
LoadSheetSync(uaURI, mozilla::css::eAgentSheetFeatures, true,
|
||||
getter_AddRefs(sheet));
|
||||
&sheet);
|
||||
|
||||
// Synchronous loads should ALWAYS return completed
|
||||
NS_ENSURE_TRUE(sheet, NS_ERROR_NULL_POINTER);
|
||||
@ -2910,8 +2909,7 @@ nsHTMLEditor::ReplaceOverrideStyleSheet(const nsAString& aURL)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::RemoveOverrideStyleSheet(const nsAString &aURL)
|
||||
{
|
||||
RefPtr<CSSStyleSheet> sheet;
|
||||
GetStyleSheetForURL(aURL, getter_AddRefs(sheet));
|
||||
StyleSheetHandle::RefPtr sheet = GetStyleSheetForURL(aURL);
|
||||
|
||||
// Make sure we remove the stylesheet from our internal list in all
|
||||
// cases.
|
||||
@ -2933,24 +2931,25 @@ nsHTMLEditor::RemoveOverrideStyleSheet(const nsAString &aURL)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::EnableStyleSheet(const nsAString &aURL, bool aEnable)
|
||||
{
|
||||
RefPtr<CSSStyleSheet> sheet;
|
||||
nsresult rv = GetStyleSheetForURL(aURL, getter_AddRefs(sheet));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
StyleSheetHandle::RefPtr sheet = GetStyleSheetForURL(aURL);
|
||||
NS_ENSURE_TRUE(sheet, NS_OK); // Don't fail if sheet not found
|
||||
|
||||
// Ensure the style sheet is owned by our document.
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocWeak);
|
||||
sheet->SetOwningDocument(doc);
|
||||
|
||||
return sheet->SetDisabled(!aEnable);
|
||||
if (sheet->IsServo()) {
|
||||
// XXXheycam ServoStyleSheets don't support being enabled/disabled yet.
|
||||
NS_ERROR("stylo: ServoStyleSheets can't be disabled yet");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return sheet->AsGecko()->SetDisabled(!aEnable);
|
||||
}
|
||||
|
||||
bool
|
||||
nsHTMLEditor::EnableExistingStyleSheet(const nsAString &aURL)
|
||||
{
|
||||
RefPtr<CSSStyleSheet> sheet;
|
||||
nsresult rv = GetStyleSheetForURL(aURL, getter_AddRefs(sheet));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
StyleSheetHandle::RefPtr sheet = GetStyleSheetForURL(aURL);
|
||||
|
||||
// Enable sheet if already loaded.
|
||||
if (sheet)
|
||||
@ -2959,7 +2958,12 @@ nsHTMLEditor::EnableExistingStyleSheet(const nsAString &aURL)
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocWeak);
|
||||
sheet->SetOwningDocument(doc);
|
||||
|
||||
sheet->SetDisabled(false);
|
||||
if (sheet->IsServo()) {
|
||||
// XXXheycam ServoStyleSheets don't support being enabled/disabled yet.
|
||||
NS_ERROR("stylo: ServoStyleSheets can't be disabled yet");
|
||||
return true;
|
||||
}
|
||||
sheet->AsGecko()->SetDisabled(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -2967,7 +2971,7 @@ nsHTMLEditor::EnableExistingStyleSheet(const nsAString &aURL)
|
||||
|
||||
nsresult
|
||||
nsHTMLEditor::AddNewStyleSheetToList(const nsAString &aURL,
|
||||
CSSStyleSheet* aStyleSheet)
|
||||
StyleSheetHandle aStyleSheet)
|
||||
{
|
||||
uint32_t countSS = mStyleSheets.Length();
|
||||
uint32_t countU = mStyleSheetURLs.Length();
|
||||
@ -2997,41 +3001,33 @@ nsHTMLEditor::RemoveStyleSheetFromList(const nsAString &aURL)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetStyleSheetForURL(const nsAString &aURL,
|
||||
CSSStyleSheet** aStyleSheet)
|
||||
StyleSheetHandle
|
||||
nsHTMLEditor::GetStyleSheetForURL(const nsAString& aURL)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aStyleSheet);
|
||||
*aStyleSheet = 0;
|
||||
|
||||
// is it already in the list?
|
||||
size_t foundIndex;
|
||||
foundIndex = mStyleSheetURLs.IndexOf(aURL);
|
||||
if (foundIndex == mStyleSheetURLs.NoIndex)
|
||||
return NS_OK; //No sheet -- don't fail!
|
||||
if (foundIndex == mStyleSheetURLs.NoIndex) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
*aStyleSheet = mStyleSheets[foundIndex];
|
||||
NS_ENSURE_TRUE(*aStyleSheet, NS_ERROR_FAILURE);
|
||||
|
||||
NS_ADDREF(*aStyleSheet);
|
||||
|
||||
return NS_OK;
|
||||
MOZ_ASSERT(mStyleSheets[foundIndex]);
|
||||
return mStyleSheets[foundIndex];
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::GetURLForStyleSheet(CSSStyleSheet* aStyleSheet,
|
||||
nsAString &aURL)
|
||||
void
|
||||
nsHTMLEditor::GetURLForStyleSheet(StyleSheetHandle aStyleSheet,
|
||||
nsAString& aURL)
|
||||
{
|
||||
// is it already in the list?
|
||||
int32_t foundIndex = mStyleSheets.IndexOf(aStyleSheet);
|
||||
|
||||
// Don't fail if we don't find it in our list
|
||||
if (foundIndex == -1)
|
||||
return NS_OK;
|
||||
return;
|
||||
|
||||
// Found it in the list!
|
||||
aURL = mStyleSheetURLs[foundIndex];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3395,7 +3391,7 @@ nsHTMLEditor::DebugUnitTests(int32_t *outNumTests, int32_t *outNumTestsFailed)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditor::StyleSheetLoaded(CSSStyleSheet* aSheet, bool aWasAlternate,
|
||||
nsHTMLEditor::StyleSheetLoaded(StyleSheetHandle aSheet, bool aWasAlternate,
|
||||
nsresult aStatus)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
|
||||
class nsDocumentFragment;
|
||||
class nsIDOMKeyEvent;
|
||||
@ -333,7 +334,7 @@ public:
|
||||
NS_IMETHOD GetRootElement(nsIDOMElement **aRootElement) override;
|
||||
|
||||
/* ------------ nsICSSLoaderObserver -------------- */
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet,
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::StyleSheetHandle aSheet,
|
||||
bool aWasAlternate, nsresult aStatus) override;
|
||||
|
||||
/* ------------ Utility Routines, not part of public API -------------- */
|
||||
@ -378,14 +379,13 @@ public:
|
||||
bool EnableExistingStyleSheet(const nsAString& aURL);
|
||||
|
||||
// Dealing with the internal style sheet lists:
|
||||
NS_IMETHOD GetStyleSheetForURL(const nsAString &aURL,
|
||||
mozilla::CSSStyleSheet** _retval) override;
|
||||
NS_IMETHOD GetURLForStyleSheet(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
nsAString& aURL) override;
|
||||
mozilla::StyleSheetHandle GetStyleSheetForURL(const nsAString& aURL);
|
||||
void GetURLForStyleSheet(mozilla::StyleSheetHandle aStyleSheet,
|
||||
nsAString& aURL);
|
||||
|
||||
// Add a url + known style sheet to the internal lists:
|
||||
nsresult AddNewStyleSheetToList(const nsAString &aURL,
|
||||
mozilla::CSSStyleSheet* aStyleSheet);
|
||||
mozilla::StyleSheetHandle aStyleSheet);
|
||||
|
||||
nsresult RemoveStyleSheetFromList(const nsAString &aURL);
|
||||
|
||||
@ -782,7 +782,7 @@ protected:
|
||||
|
||||
// Maintain a list of associated style sheets and their urls.
|
||||
nsTArray<nsString> mStyleSheetURLs;
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mStyleSheets;
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr> mStyleSheets;
|
||||
|
||||
// an array for holding default style settings
|
||||
nsTArray<PropItem*> mDefaultStyles;
|
||||
|
@ -9,7 +9,8 @@
|
||||
|
||||
#include "nsAString.h"
|
||||
#include "nsCOMPtr.h" // for nsCOMPtr, do_QueryInterface, etc
|
||||
#include "mozilla/CSSStyleSheet.h" // for mozilla::CSSStyleSheet
|
||||
#include "mozilla/StyleSheetHandle.h" // for mozilla::StyleSheetHandle
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
#include "nsDebug.h" // for NS_ENSURE_TRUE
|
||||
#include "nsError.h" // for NS_OK, etc
|
||||
#include "nsIDOMDocument.h" // for nsIDOMDocument
|
||||
@ -20,7 +21,7 @@
|
||||
using namespace mozilla;
|
||||
|
||||
static void
|
||||
AddStyleSheet(nsIEditor* aEditor, CSSStyleSheet* aSheet)
|
||||
AddStyleSheet(nsIEditor* aEditor, StyleSheetHandle aSheet)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
aEditor->GetDocument(getter_AddRefs(domDoc));
|
||||
@ -33,7 +34,7 @@ AddStyleSheet(nsIEditor* aEditor, CSSStyleSheet* aSheet)
|
||||
}
|
||||
|
||||
static void
|
||||
RemoveStyleSheet(nsIEditor* aEditor, CSSStyleSheet* aSheet)
|
||||
RemoveStyleSheet(nsIEditor* aEditor, StyleSheetHandle aSheet)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
aEditor->GetDocument(getter_AddRefs(domDoc));
|
||||
@ -58,7 +59,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AddStyleSheetTxn)
|
||||
NS_INTERFACE_MAP_END_INHERITING(EditTxn)
|
||||
|
||||
NS_IMETHODIMP
|
||||
AddStyleSheetTxn::Init(nsIEditor *aEditor, CSSStyleSheet *aSheet)
|
||||
AddStyleSheetTxn::Init(nsIEditor* aEditor, StyleSheetHandle aSheet)
|
||||
{
|
||||
NS_ENSURE_TRUE(aEditor && aSheet, NS_ERROR_INVALID_ARG);
|
||||
|
||||
@ -108,7 +109,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(RemoveStyleSheetTxn)
|
||||
NS_INTERFACE_MAP_END_INHERITING(EditTxn)
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoveStyleSheetTxn::Init(nsIEditor *aEditor, CSSStyleSheet *aSheet)
|
||||
RemoveStyleSheetTxn::Init(nsIEditor* aEditor, StyleSheetHandle aSheet)
|
||||
{
|
||||
NS_ENSURE_TRUE(aEditor && aSheet, NS_ERROR_INVALID_ARG);
|
||||
|
||||
|
@ -8,10 +8,9 @@
|
||||
|
||||
#include "EditTxn.h" // for EditTxn, NS_DECL_EDITTXN
|
||||
#include "nsAutoPtr.h" // for nsRefPtr
|
||||
#include "mozilla/CSSStyleSheet.h" // for mozilla::CSSStyleSheet
|
||||
#include "mozilla/StyleSheetHandle.h" // for mozilla::StyleSheetHandle
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsID.h" // for REFNSIID
|
||||
#include "nsISupportsImpl.h" // for CSSStyleSheet::Release
|
||||
#include "nscore.h" // for NS_IMETHOD
|
||||
|
||||
class nsIEditor;
|
||||
@ -23,8 +22,7 @@ public:
|
||||
* @param aEditor the object providing core editing operations
|
||||
* @param aSheet the stylesheet to add
|
||||
*/
|
||||
NS_IMETHOD Init(nsIEditor* aEditor,
|
||||
mozilla::CSSStyleSheet* aSheet);
|
||||
NS_IMETHOD Init(nsIEditor* aEditor, mozilla::StyleSheetHandle aSheet);
|
||||
|
||||
AddStyleSheetTxn();
|
||||
|
||||
@ -36,7 +34,7 @@ public:
|
||||
protected:
|
||||
|
||||
nsIEditor* mEditor; // the editor that created this transaction
|
||||
RefPtr<mozilla::CSSStyleSheet> mSheet; // the style sheet to add
|
||||
mozilla::StyleSheetHandle::RefPtr mSheet; // the style sheet to add
|
||||
|
||||
};
|
||||
|
||||
@ -48,8 +46,7 @@ public:
|
||||
* @param aEditor the object providing core editing operations
|
||||
* @param aSheet the stylesheet to remove
|
||||
*/
|
||||
NS_IMETHOD Init(nsIEditor* aEditor,
|
||||
mozilla::CSSStyleSheet* aSheet);
|
||||
NS_IMETHOD Init(nsIEditor* aEditor, mozilla::StyleSheetHandle aSheet);
|
||||
|
||||
RemoveStyleSheetTxn();
|
||||
|
||||
@ -61,7 +58,7 @@ public:
|
||||
protected:
|
||||
|
||||
nsIEditor* mEditor; // the editor that created this transaction
|
||||
RefPtr<mozilla::CSSStyleSheet> mSheet; // the style sheet to remove
|
||||
mozilla::StyleSheetHandle::RefPtr mSheet; // the style sheet to remove
|
||||
|
||||
};
|
||||
|
||||
|
@ -5,14 +5,6 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
%{C++
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
} // namespace mozilla
|
||||
%}
|
||||
|
||||
[ptr] native CSSStyleSheet(mozilla::CSSStyleSheet);
|
||||
|
||||
[scriptable, uuid(4805e682-49b9-11d3-9ce4-ed60bd6cb5bc)]
|
||||
|
||||
interface nsIEditorStyleSheets : nsISupports
|
||||
@ -76,18 +68,4 @@ interface nsIEditorStyleSheets : nsISupports
|
||||
* @param aEnable true to enable, or false to disable the style sheet
|
||||
*/
|
||||
void enableStyleSheet(in AString aURL, in boolean aEnable);
|
||||
|
||||
/** Get the CSSStyleSheet associated with the given URL.
|
||||
*
|
||||
* @param aURL The style sheet's URL
|
||||
* @return the style sheet
|
||||
*/
|
||||
[noscript] CSSStyleSheet getStyleSheetForURL(in AString aURL);
|
||||
|
||||
/** Get the URL associated with the given CSSStyleSheet.
|
||||
*
|
||||
* @param aStyleSheet The style sheet
|
||||
* @return the style sheet's URL
|
||||
*/
|
||||
[noscript] AString getURLForStyleSheet(in CSSStyleSheet aStyleSheet);
|
||||
};
|
||||
|
@ -40,6 +40,8 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
#include "nsViewManager.h"
|
||||
#include "nsView.h"
|
||||
@ -2170,13 +2172,14 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
auto cache = nsLayoutStylesheetCache::For(styleSet->BackendType());
|
||||
|
||||
// Handle the user sheets.
|
||||
CSSStyleSheet* sheet = nullptr;
|
||||
StyleSheetHandle sheet = nullptr;
|
||||
if (nsContentUtils::IsInChromeDocshell(aDocument)) {
|
||||
sheet = nsLayoutStylesheetCache::UserChromeSheet();
|
||||
}
|
||||
else {
|
||||
sheet = nsLayoutStylesheetCache::UserContentSheet();
|
||||
sheet = cache->UserChromeSheet();
|
||||
} else {
|
||||
sheet = cache->UserContentSheet();
|
||||
}
|
||||
|
||||
if (sheet)
|
||||
@ -2189,7 +2192,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
||||
nsCOMPtr<nsIDocShell> ds(mContainer);
|
||||
nsCOMPtr<nsIDOMEventTarget> chromeHandler;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
RefPtr<CSSStyleSheet> csssheet;
|
||||
StyleSheetHandle::RefPtr chromeSheet;
|
||||
|
||||
if (ds) {
|
||||
ds->GetChromeEventHandler(getter_AddRefs(chromeHandler));
|
||||
@ -2213,10 +2216,10 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
||||
baseURI);
|
||||
if (!uri) continue;
|
||||
|
||||
cssLoader->LoadSheetSync(uri, getter_AddRefs(csssheet));
|
||||
if (!csssheet) continue;
|
||||
cssLoader->LoadSheetSync(uri, &chromeSheet);
|
||||
if (!chromeSheet) continue;
|
||||
|
||||
styleSet->PrependStyleSheet(SheetType::Agent, csssheet);
|
||||
styleSet->PrependStyleSheet(SheetType::Agent, chromeSheet);
|
||||
shouldOverride = true;
|
||||
}
|
||||
free(str);
|
||||
@ -2225,7 +2228,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
||||
}
|
||||
|
||||
if (!shouldOverride) {
|
||||
sheet = nsLayoutStylesheetCache::ScrollbarsSheet();
|
||||
sheet = cache->ScrollbarsSheet();
|
||||
if (sheet) {
|
||||
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
@ -2241,12 +2244,12 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
||||
// an SVG document, and excluding xul.css which will be loaded on demand by
|
||||
// nsXULElement::BindToTree.)
|
||||
|
||||
sheet = nsLayoutStylesheetCache::NumberControlSheet();
|
||||
sheet = cache->NumberControlSheet();
|
||||
if (sheet) {
|
||||
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
|
||||
sheet = nsLayoutStylesheetCache::FormsSheet();
|
||||
sheet = cache->FormsSheet();
|
||||
if (sheet) {
|
||||
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
@ -2254,33 +2257,33 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
||||
if (aDocument->LoadsFullXULStyleSheetUpFront()) {
|
||||
// nsXULElement::BindToTree loads xul.css on-demand if we don't load it
|
||||
// up-front here.
|
||||
sheet = nsLayoutStylesheetCache::XULSheet();
|
||||
sheet = cache->XULSheet();
|
||||
if (sheet) {
|
||||
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
}
|
||||
|
||||
sheet = nsLayoutStylesheetCache::MinimalXULSheet();
|
||||
sheet = cache->MinimalXULSheet();
|
||||
if (sheet) {
|
||||
// Load the minimal XUL rules for scrollbars and a few other XUL things
|
||||
// that non-XUL (typically HTML) documents commonly use.
|
||||
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
|
||||
sheet = nsLayoutStylesheetCache::CounterStylesSheet();
|
||||
sheet = cache->CounterStylesSheet();
|
||||
if (sheet) {
|
||||
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
|
||||
if (nsLayoutUtils::ShouldUseNoScriptSheet(aDocument)) {
|
||||
sheet = nsLayoutStylesheetCache::NoScriptSheet();
|
||||
sheet = cache->NoScriptSheet();
|
||||
if (sheet) {
|
||||
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
}
|
||||
|
||||
if (nsLayoutUtils::ShouldUseNoFramesSheet(aDocument)) {
|
||||
sheet = nsLayoutStylesheetCache::NoFramesSheet();
|
||||
sheet = cache->NoFramesSheet();
|
||||
if (sheet) {
|
||||
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
@ -2289,16 +2292,16 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
||||
// We don't add quirk.css here; nsPresContext::CompatibilityModeChanged will
|
||||
// append it if needed.
|
||||
|
||||
sheet = nsLayoutStylesheetCache::HTMLSheet();
|
||||
sheet = cache->HTMLSheet();
|
||||
if (sheet) {
|
||||
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
|
||||
styleSet->PrependStyleSheet(SheetType::Agent,
|
||||
nsLayoutStylesheetCache::UASheet());
|
||||
cache->UASheet());
|
||||
} else {
|
||||
// SVG documents may have scrollbars and need the scrollbar styling.
|
||||
sheet = nsLayoutStylesheetCache::MinimalXULSheet();
|
||||
sheet = cache->MinimalXULSheet();
|
||||
if (sheet) {
|
||||
styleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
@ -2306,10 +2309,10 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
||||
|
||||
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
|
||||
if (sheetService) {
|
||||
for (CSSStyleSheet* sheet : *sheetService->AgentStyleSheets()) {
|
||||
for (StyleSheetHandle sheet : *sheetService->AgentStyleSheets()) {
|
||||
styleSet->AppendStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
for (CSSStyleSheet* sheet : Reversed(*sheetService->UserStyleSheets())) {
|
||||
for (StyleSheetHandle sheet : Reversed(*sheetService->UserStyleSheets())) {
|
||||
styleSet->PrependStyleSheet(SheetType::User, sheet);
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/StyleSetHandle.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "gfxPoint.h"
|
||||
#include "nsTHashtable.h"
|
||||
@ -945,23 +946,23 @@ public:
|
||||
* Get the set of agent style sheets for this presentation
|
||||
*/
|
||||
virtual nsresult GetAgentStyleSheets(
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aSheets) = 0;
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr>& aSheets) = 0;
|
||||
|
||||
/**
|
||||
* Replace the set of agent style sheets
|
||||
*/
|
||||
virtual nsresult SetAgentStyleSheets(
|
||||
const nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aSheets) = 0;
|
||||
const nsTArray<mozilla::StyleSheetHandle::RefPtr>& aSheets) = 0;
|
||||
|
||||
/**
|
||||
* Add an override style sheet for this presentation
|
||||
*/
|
||||
virtual nsresult AddOverrideStyleSheet(mozilla::CSSStyleSheet* aSheet) = 0;
|
||||
virtual nsresult AddOverrideStyleSheet(mozilla::StyleSheetHandle aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Remove an override style sheet
|
||||
*/
|
||||
virtual nsresult RemoveOverrideStyleSheet(mozilla::CSSStyleSheet* aSheet) = 0;
|
||||
virtual nsresult RemoveOverrideStyleSheet(mozilla::StyleSheetHandle aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Reconstruct frames for all elements in the document
|
||||
|
@ -73,6 +73,8 @@
|
||||
#include "gfxTextRun.h"
|
||||
#include "nsFontFaceUtils.h"
|
||||
#include "nsLayoutStylesheetCache.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
#if defined(MOZ_WIDGET_GTK)
|
||||
#include "gfxPlatformGtk.h" // xxx - for UseFcFontList
|
||||
@ -1357,7 +1359,8 @@ nsPresContext::CompatibilityModeChanged()
|
||||
}
|
||||
|
||||
StyleSetHandle styleSet = mShell->StyleSet();
|
||||
CSSStyleSheet* sheet = nsLayoutStylesheetCache::QuirkSheet();
|
||||
auto cache = nsLayoutStylesheetCache::For(styleSet->BackendType());
|
||||
StyleSheetHandle sheet = cache->QuirkSheet();
|
||||
|
||||
if (needsQuirkSheet) {
|
||||
// quirk.css needs to come after html.css; we just keep it at the end.
|
||||
|
@ -186,6 +186,8 @@
|
||||
#include "mozilla/layers/ScrollInputMethods.h"
|
||||
#include "mozilla/StyleSetHandle.h"
|
||||
#include "mozilla/StyleSetHandleInlines.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
@ -1364,10 +1366,11 @@ PresShell::UpdatePreferenceStyles()
|
||||
// matter which pres context we pass in when it does need to be recreated.
|
||||
// (See nsPresContext::GetDocumentColorPreferences for how whether we
|
||||
// are a chrome origin image affects some pref styling information.)
|
||||
RefPtr<CSSStyleSheet> newPrefSheet =
|
||||
auto cache = nsLayoutStylesheetCache::For(mStyleSet->BackendType());
|
||||
StyleSheetHandle::RefPtr newPrefSheet =
|
||||
mPresContext->IsChromeOriginImage() ?
|
||||
nsLayoutStylesheetCache::ChromePreferenceSheet(mPresContext) :
|
||||
nsLayoutStylesheetCache::ContentPreferenceSheet(mPresContext);
|
||||
cache->ChromePreferenceSheet(mPresContext) :
|
||||
cache->ContentPreferenceSheet(mPresContext);
|
||||
|
||||
if (mPrefStyleSheet == newPrefSheet) {
|
||||
return;
|
||||
@ -1406,16 +1409,16 @@ PresShell::AddUserSheet(nsISupports* aSheet)
|
||||
mStyleSet->BeginUpdate();
|
||||
|
||||
nsStyleSheetService* sheetService = nsStyleSheetService::gInstance;
|
||||
nsTArray<RefPtr<CSSStyleSheet>>& userSheets = *sheetService->UserStyleSheets();
|
||||
nsTArray<StyleSheetHandle::RefPtr>& userSheets = *sheetService->UserStyleSheets();
|
||||
// Iterate forwards when removing so the searches for RemoveStyleSheet are as
|
||||
// short as possible.
|
||||
for (CSSStyleSheet* sheet : userSheets) {
|
||||
for (StyleSheetHandle sheet : userSheets) {
|
||||
mStyleSet->RemoveStyleSheet(SheetType::User, sheet);
|
||||
}
|
||||
|
||||
// Now iterate backwards, so that the order of userSheets will be the same as
|
||||
// the order of sheets from it in the style set.
|
||||
for (CSSStyleSheet* sheet : Reversed(userSheets)) {
|
||||
for (StyleSheetHandle sheet : Reversed(userSheets)) {
|
||||
mStyleSet->PrependStyleSheet(SheetType::User, sheet);
|
||||
}
|
||||
|
||||
@ -1429,8 +1432,10 @@ PresShell::AddAgentSheet(nsISupports* aSheet)
|
||||
{
|
||||
// Make sure this does what nsDocumentViewer::CreateStyleSet does
|
||||
// wrt ordering.
|
||||
// XXXheycam This needs to work with ServoStyleSheets too.
|
||||
RefPtr<CSSStyleSheet> sheet = do_QueryObject(aSheet);
|
||||
if (!sheet) {
|
||||
NS_ERROR("stylo: AddAgentSheet needs to support ServoStyleSheets");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1441,14 +1446,16 @@ PresShell::AddAgentSheet(nsISupports* aSheet)
|
||||
void
|
||||
PresShell::AddAuthorSheet(nsISupports* aSheet)
|
||||
{
|
||||
// XXXheycam This needs to work with ServoStyleSheets too.
|
||||
RefPtr<CSSStyleSheet> sheet = do_QueryObject(aSheet);
|
||||
if (!sheet) {
|
||||
NS_ERROR("stylo: AddAuthorSheet needs to support ServoStyleSheets");
|
||||
return;
|
||||
}
|
||||
|
||||
// Document specific "additional" Author sheets should be stronger than the ones
|
||||
// added with the StyleSheetService.
|
||||
CSSStyleSheet* firstAuthorSheet = mDocument->FirstAdditionalAuthorSheet();
|
||||
StyleSheetHandle firstAuthorSheet = mDocument->FirstAdditionalAuthorSheet();
|
||||
if (firstAuthorSheet) {
|
||||
mStyleSet->InsertStyleSheetBefore(SheetType::Doc, sheet, firstAuthorSheet);
|
||||
} else {
|
||||
@ -1463,6 +1470,7 @@ PresShell::RemoveSheet(SheetType aType, nsISupports* aSheet)
|
||||
{
|
||||
RefPtr<CSSStyleSheet> sheet = do_QueryObject(aSheet);
|
||||
if (!sheet) {
|
||||
NS_ERROR("stylo: RemoveSheet needs to support ServoStyleSheets");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -4424,7 +4432,7 @@ nsIPresShell::ReconstructStyleDataExternal()
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::RecordStyleSheetChange(CSSStyleSheet* aStyleSheet)
|
||||
PresShell::RecordStyleSheetChange(StyleSheetHandle aStyleSheet)
|
||||
{
|
||||
// too bad we can't check that the update is UPDATE_STYLE
|
||||
NS_ASSERTION(mUpdateCount != 0, "must be in an update");
|
||||
@ -4432,20 +4440,22 @@ PresShell::RecordStyleSheetChange(CSSStyleSheet* aStyleSheet)
|
||||
if (mStylesHaveChanged)
|
||||
return;
|
||||
|
||||
RefPtr<CSSStyleSheet> cssStyleSheet = do_QueryObject(aStyleSheet);
|
||||
if (cssStyleSheet) {
|
||||
Element* scopeElement = cssStyleSheet->GetScopeElement();
|
||||
if (aStyleSheet->IsGecko()) {
|
||||
// XXXheycam ServoStyleSheets don't support <style scoped> yet.
|
||||
Element* scopeElement = aStyleSheet->AsGecko()->GetScopeElement();
|
||||
if (scopeElement) {
|
||||
mChangedScopeStyleRoots.AppendElement(scopeElement);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
NS_ERROR("stylo: ServoStyleSheets don't support <style scoped>");
|
||||
}
|
||||
|
||||
mStylesHaveChanged = true;
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::StyleSheetAdded(CSSStyleSheet* aStyleSheet,
|
||||
PresShell::StyleSheetAdded(StyleSheetHandle aStyleSheet,
|
||||
bool aDocumentSheet)
|
||||
{
|
||||
// We only care when enabled sheets are added
|
||||
@ -4457,7 +4467,7 @@ PresShell::StyleSheetAdded(CSSStyleSheet* aStyleSheet,
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::StyleSheetRemoved(CSSStyleSheet* aStyleSheet,
|
||||
PresShell::StyleSheetRemoved(StyleSheetHandle aStyleSheet,
|
||||
bool aDocumentSheet)
|
||||
{
|
||||
// We only care when enabled sheets are removed
|
||||
@ -4469,7 +4479,7 @@ PresShell::StyleSheetRemoved(CSSStyleSheet* aStyleSheet,
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::StyleSheetApplicableStateChanged(CSSStyleSheet* aStyleSheet)
|
||||
PresShell::StyleSheetApplicableStateChanged(StyleSheetHandle aStyleSheet)
|
||||
{
|
||||
if (aStyleSheet->HasRules()) {
|
||||
RecordStyleSheetChange(aStyleSheet);
|
||||
@ -4477,19 +4487,19 @@ PresShell::StyleSheetApplicableStateChanged(CSSStyleSheet* aStyleSheet)
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::StyleRuleChanged(CSSStyleSheet* aStyleSheet)
|
||||
PresShell::StyleRuleChanged(StyleSheetHandle aStyleSheet)
|
||||
{
|
||||
RecordStyleSheetChange(aStyleSheet);
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::StyleRuleAdded(CSSStyleSheet* aStyleSheet)
|
||||
PresShell::StyleRuleAdded(StyleSheetHandle aStyleSheet)
|
||||
{
|
||||
RecordStyleSheetChange(aStyleSheet);
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::StyleRuleRemoved(CSSStyleSheet* aStyleSheet)
|
||||
PresShell::StyleRuleRemoved(StyleSheetHandle aStyleSheet)
|
||||
{
|
||||
RecordStyleSheetChange(aStyleSheet);
|
||||
}
|
||||
@ -8501,7 +8511,7 @@ PresShell::IsVisible()
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresShell::GetAgentStyleSheets(nsTArray<RefPtr<CSSStyleSheet>>& aSheets)
|
||||
PresShell::GetAgentStyleSheets(nsTArray<StyleSheetHandle::RefPtr>& aSheets)
|
||||
{
|
||||
aSheets.Clear();
|
||||
int32_t sheetCount = mStyleSet->SheetCount(SheetType::Agent);
|
||||
@ -8511,7 +8521,7 @@ PresShell::GetAgentStyleSheets(nsTArray<RefPtr<CSSStyleSheet>>& aSheets)
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < sheetCount; ++i) {
|
||||
CSSStyleSheet* sheet = mStyleSet->StyleSheetAt(SheetType::Agent, i);
|
||||
StyleSheetHandle sheet = mStyleSet->StyleSheetAt(SheetType::Agent, i);
|
||||
aSheets.AppendElement(sheet);
|
||||
}
|
||||
|
||||
@ -8519,19 +8529,19 @@ PresShell::GetAgentStyleSheets(nsTArray<RefPtr<CSSStyleSheet>>& aSheets)
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresShell::SetAgentStyleSheets(const nsTArray<RefPtr<CSSStyleSheet>>& aSheets)
|
||||
PresShell::SetAgentStyleSheets(const nsTArray<StyleSheetHandle::RefPtr>& aSheets)
|
||||
{
|
||||
return mStyleSet->ReplaceSheets(SheetType::Agent, aSheets);
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresShell::AddOverrideStyleSheet(CSSStyleSheet* aSheet)
|
||||
PresShell::AddOverrideStyleSheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
return mStyleSet->PrependStyleSheet(SheetType::Override, aSheet);
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresShell::RemoveOverrideStyleSheet(CSSStyleSheet* aSheet)
|
||||
PresShell::RemoveOverrideStyleSheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
return mStyleSet->RemoveStyleSheet(SheetType::Override, aSheet);
|
||||
}
|
||||
|
@ -51,7 +51,6 @@ class nsPresShellEventCB;
|
||||
class nsAutoCauseReflowNotifier;
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
class EventDispatchingCallback;
|
||||
} // namespace mozilla
|
||||
|
||||
@ -155,12 +154,12 @@ public:
|
||||
virtual void UnsuppressPainting() override;
|
||||
|
||||
virtual nsresult GetAgentStyleSheets(
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aSheets) override;
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr>& aSheets) override;
|
||||
virtual nsresult SetAgentStyleSheets(
|
||||
const nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aSheets) override;
|
||||
const nsTArray<mozilla::StyleSheetHandle::RefPtr>& aSheets) override;
|
||||
|
||||
virtual nsresult AddOverrideStyleSheet(mozilla::CSSStyleSheet* aSheet) override;
|
||||
virtual nsresult RemoveOverrideStyleSheet(mozilla::CSSStyleSheet* aSheet) override;
|
||||
virtual nsresult AddOverrideStyleSheet(mozilla::StyleSheetHandle aSheet) override;
|
||||
virtual nsresult RemoveOverrideStyleSheet(mozilla::StyleSheetHandle aSheet) override;
|
||||
|
||||
virtual nsresult HandleEventWithTarget(
|
||||
mozilla::WidgetEvent* aEvent,
|
||||
@ -503,7 +502,7 @@ protected:
|
||||
void ShowEventTargetDebug();
|
||||
#endif
|
||||
|
||||
void RecordStyleSheetChange(mozilla::CSSStyleSheet* aStyleSheet);
|
||||
void RecordStyleSheetChange(mozilla::StyleSheetHandle aStyleSheet);
|
||||
|
||||
void RemovePreferenceStyles();
|
||||
|
||||
@ -781,7 +780,7 @@ protected:
|
||||
nsPoint mMouseLocation;
|
||||
|
||||
// mStyleSet owns it but we maintain a ref, may be null
|
||||
RefPtr<mozilla::CSSStyleSheet> mPrefStyleSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mPrefStyleSheet;
|
||||
|
||||
// Set of frames that we should mark with NS_FRAME_HAS_DIRTY_CHILDREN after
|
||||
// we finish reflowing mCurrentReflowRoot.
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "nsStyleSheetService.h"
|
||||
#include "mozilla/CSSStyleSheet.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
@ -78,7 +80,7 @@ nsStyleSheetService::RegisterFromEnumerator(nsICategoryManager *aManager,
|
||||
}
|
||||
|
||||
int32_t
|
||||
nsStyleSheetService::FindSheetByURI(const nsTArray<RefPtr<CSSStyleSheet>>& aSheets,
|
||||
nsStyleSheetService::FindSheetByURI(const nsTArray<StyleSheetHandle::RefPtr>& aSheets,
|
||||
nsIURI* aSheetURI)
|
||||
{
|
||||
for (int32_t i = aSheets.Length() - 1; i >= 0; i-- ) {
|
||||
@ -152,9 +154,17 @@ nsStyleSheetService::LoadAndRegisterSheet(nsIURI *aSheetURI,
|
||||
if (serv) {
|
||||
// We're guaranteed that the new sheet is the last sheet in
|
||||
// mSheets[aSheetType]
|
||||
CSSStyleSheet* sheet = mSheets[aSheetType].LastElement();
|
||||
serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, sheet),
|
||||
message, nullptr);
|
||||
|
||||
// XXXheycam Once the nsStyleSheetService can hold ServoStyleSheets too,
|
||||
// we'll need to include them in the notification.
|
||||
StyleSheetHandle sheet = mSheets[aSheetType].LastElement();
|
||||
if (sheet->IsGecko()) {
|
||||
CSSStyleSheet* cssSheet = sheet->AsGecko();
|
||||
serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, cssSheet),
|
||||
message, nullptr);
|
||||
} else {
|
||||
NS_ERROR("stylo: can't notify observers of ServoStyleSheets");
|
||||
}
|
||||
}
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
@ -203,9 +213,8 @@ nsStyleSheetService::LoadAndRegisterSheetInternal(nsIURI *aSheetURI,
|
||||
|
||||
RefPtr<css::Loader> loader = new css::Loader();
|
||||
|
||||
RefPtr<CSSStyleSheet> sheet;
|
||||
nsresult rv = loader->LoadSheetSync(aSheetURI, parsingMode, true,
|
||||
getter_AddRefs(sheet));
|
||||
StyleSheetHandle::RefPtr sheet;
|
||||
nsresult rv = loader->LoadSheetSync(aSheetURI, parsingMode, true, &sheet);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mSheets[aSheetType].AppendElement(sheet);
|
||||
@ -253,13 +262,21 @@ nsStyleSheetService::PreloadSheet(nsIURI *aSheetURI, uint32_t aSheetType,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// XXXheycam PreloadSheet can't support ServoStyleSheets until they implement
|
||||
// nsIDOMStyleSheet.
|
||||
|
||||
RefPtr<css::Loader> loader = new css::Loader();
|
||||
|
||||
RefPtr<CSSStyleSheet> sheet;
|
||||
nsresult rv = loader->LoadSheetSync(aSheetURI, parsingMode, true,
|
||||
getter_AddRefs(sheet));
|
||||
StyleSheetHandle::RefPtr sheet;
|
||||
nsresult rv = loader->LoadSheetSync(aSheetURI, parsingMode, true, &sheet);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
sheet.forget(aSheet);
|
||||
|
||||
MOZ_ASSERT(sheet->IsGecko(),
|
||||
"stylo: didn't expect Loader to create a ServoStyleSheet");
|
||||
|
||||
RefPtr<CSSStyleSheet> cssSheet = sheet->AsGecko();
|
||||
cssSheet.forget(aSheet);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -273,7 +290,7 @@ nsStyleSheetService::UnregisterSheet(nsIURI *aSheetURI, uint32_t aSheetType)
|
||||
|
||||
int32_t foundIndex = FindSheetByURI(mSheets[aSheetType], aSheetURI);
|
||||
NS_ENSURE_TRUE(foundIndex >= 0, NS_ERROR_INVALID_ARG);
|
||||
RefPtr<CSSStyleSheet> sheet = mSheets[aSheetType][foundIndex];
|
||||
StyleSheetHandle::RefPtr sheet = mSheets[aSheetType][foundIndex];
|
||||
mSheets[aSheetType].RemoveElementAt(foundIndex);
|
||||
|
||||
const char* message;
|
||||
@ -291,8 +308,15 @@ nsStyleSheetService::UnregisterSheet(nsIURI *aSheetURI, uint32_t aSheetType)
|
||||
|
||||
nsCOMPtr<nsIObserverService> serv = services::GetObserverService();
|
||||
if (serv) {
|
||||
serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, sheet),
|
||||
message, nullptr);
|
||||
// XXXheycam Once the nsStyleSheetService can hold ServoStyleSheets too,
|
||||
// we'll need to include them in the notification.
|
||||
if (sheet->IsGecko()) {
|
||||
CSSStyleSheet* cssSheet = sheet->AsGecko();
|
||||
serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, cssSheet),
|
||||
message, nullptr);
|
||||
} else {
|
||||
NS_ERROR("stylo: can't notify observers of ServoStyleSheets");
|
||||
}
|
||||
}
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
@ -347,7 +371,7 @@ nsStyleSheetService::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) co
|
||||
size_t n = aMallocSizeOf(this);
|
||||
for (auto& sheetArray : mSheets) {
|
||||
n += sheetArray.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
||||
for (CSSStyleSheet* sheet : sheetArray) {
|
||||
for (StyleSheetHandle sheet : sheetArray) {
|
||||
n += sheet->SizeOfIncludingThis(aMallocSizeOf);
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,8 @@
|
||||
#include "nsIStyleSheetService.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
}
|
||||
class nsICategoryManager;
|
||||
class nsIMemoryReporter;
|
||||
class nsISimpleEnumerator;
|
||||
@ -43,15 +41,15 @@ class nsStyleSheetService final
|
||||
|
||||
nsresult Init();
|
||||
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>* AgentStyleSheets()
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr>* AgentStyleSheets()
|
||||
{
|
||||
return &mSheets[AGENT_SHEET];
|
||||
}
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>* UserStyleSheets()
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr>* UserStyleSheets()
|
||||
{
|
||||
return &mSheets[USER_SHEET];
|
||||
}
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>* AuthorStyleSheets()
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr>* AuthorStyleSheets()
|
||||
{
|
||||
return &mSheets[AUTHOR_SHEET];
|
||||
}
|
||||
@ -69,7 +67,7 @@ class nsStyleSheetService final
|
||||
nsISimpleEnumerator *aEnumerator,
|
||||
uint32_t aSheetType);
|
||||
|
||||
int32_t FindSheetByURI(const nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aSheets,
|
||||
int32_t FindSheetByURI(const nsTArray<mozilla::StyleSheetHandle::RefPtr>& aSheets,
|
||||
nsIURI* aSheetURI);
|
||||
|
||||
// Like LoadAndRegisterSheet, but doesn't notify. If successful, the
|
||||
@ -77,7 +75,7 @@ class nsStyleSheetService final
|
||||
nsresult LoadAndRegisterSheetInternal(nsIURI *aSheetURI,
|
||||
uint32_t aSheetType);
|
||||
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mSheets[3];
|
||||
nsTArray<mozilla::StyleSheetHandle::RefPtr> mSheets[3];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -114,7 +114,9 @@ inDOMUtils::GetAllStyleSheets(nsIDOMDocument *aDocument, uint32_t *aLength,
|
||||
|
||||
// Get the document sheets.
|
||||
for (int32_t i = 0; i < document->GetNumberOfStyleSheets(); i++) {
|
||||
sheets.AppendElement(document->GetStyleSheetAt(i));
|
||||
// XXXheycam ServoStyleSets don't have the ability to expose their
|
||||
// sheets in a script-accessible way yet.
|
||||
sheets.AppendElement(document->GetStyleSheetAt(i)->AsGecko());
|
||||
}
|
||||
|
||||
nsISupports** ret = static_cast<nsISupports**>(moz_xmalloc(sheets.Length() *
|
||||
|
@ -2203,14 +2203,19 @@ CSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule,
|
||||
|
||||
// nsICSSLoaderObserver implementation
|
||||
NS_IMETHODIMP
|
||||
CSSStyleSheet::StyleSheetLoaded(CSSStyleSheet* aSheet,
|
||||
CSSStyleSheet::StyleSheetLoaded(StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus)
|
||||
{
|
||||
if (aSheet->GetParentSheet() == nullptr) {
|
||||
MOZ_ASSERT(aSheet->IsGecko(),
|
||||
"why we were called back with a ServoStyleSheet?");
|
||||
|
||||
CSSStyleSheet* sheet = aSheet->AsGecko();
|
||||
|
||||
if (sheet->GetParentSheet() == nullptr) {
|
||||
return NS_OK; // ignore if sheet has been detached already (see parseSheet)
|
||||
}
|
||||
NS_ASSERTION(this == aSheet->GetParentSheet(),
|
||||
NS_ASSERTION(this == sheet->GetParentSheet(),
|
||||
"We are being notified of a sheet load for a sheet that is not our child!");
|
||||
|
||||
if (mDocument && NS_SUCCEEDED(aStatus)) {
|
||||
@ -2218,7 +2223,7 @@ CSSStyleSheet::StyleSheetLoaded(CSSStyleSheet* aSheet,
|
||||
|
||||
// XXXldb @import rules shouldn't even implement nsIStyleRule (but
|
||||
// they do)!
|
||||
mDocument->StyleRuleAdded(this, aSheet->GetOwnerRule());
|
||||
mDocument->StyleRuleAdded(this, sheet->GetOwnerRule());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -248,7 +248,7 @@ public:
|
||||
nsIURI* GetOriginalURI() const { return mInner->mOriginalSheetURI; }
|
||||
|
||||
// nsICSSLoaderObserver interface
|
||||
NS_IMETHOD StyleSheetLoaded(CSSStyleSheet* aSheet, bool aWasAlternate,
|
||||
NS_IMETHOD StyleSheetLoaded(StyleSheetHandle aSheet, bool aWasAlternate,
|
||||
nsresult aStatus) override;
|
||||
|
||||
void EnsureUniqueInner();
|
||||
@ -282,7 +282,7 @@ public:
|
||||
ReferrerPolicy GetReferrerPolicy() const { return mInner->mReferrerPolicy; }
|
||||
|
||||
// Get this style sheet's integrity metadata
|
||||
dom::SRIMetadata GetIntegrity() const { return mInner->mIntegrity; }
|
||||
void GetIntegrity(dom::SRIMetadata& aResult) const { aResult = mInner->mIntegrity; }
|
||||
|
||||
dom::Element* GetScopeElement() const { return mScopeElement; }
|
||||
void SetScopeElement(dom::Element* aScopeElement)
|
||||
|
@ -1694,7 +1694,7 @@ FontFaceSet::PrefEnabled()
|
||||
// nsICSSLoaderObserver
|
||||
|
||||
NS_IMETHODIMP
|
||||
FontFaceSet::StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet,
|
||||
FontFaceSet::StyleSheetLoaded(StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus)
|
||||
{
|
||||
|
@ -144,7 +144,7 @@ public:
|
||||
static bool PrefEnabled();
|
||||
|
||||
// nsICSSLoaderObserver
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet,
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus) override;
|
||||
|
||||
|
@ -51,6 +51,8 @@
|
||||
#include "nsINetworkPredictor.h"
|
||||
#include "mozilla/dom/ShadowRoot.h"
|
||||
#include "mozilla/dom/URL.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsXULPrototypeCache.h"
|
||||
@ -119,7 +121,7 @@ public:
|
||||
SheetLoadData(Loader* aLoader,
|
||||
const nsSubstring& aTitle,
|
||||
nsIURI* aURI,
|
||||
CSSStyleSheet* aSheet,
|
||||
StyleSheetHandle aSheet,
|
||||
nsIStyleSheetLinkingElement* aOwningElement,
|
||||
bool aIsAlternate,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
@ -129,7 +131,7 @@ public:
|
||||
// Data for loading a sheet linked from an @import rule
|
||||
SheetLoadData(Loader* aLoader,
|
||||
nsIURI* aURI,
|
||||
CSSStyleSheet* aSheet,
|
||||
StyleSheetHandle aSheet,
|
||||
SheetLoadData* aParentData,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
nsIPrincipal* aLoaderPrincipal,
|
||||
@ -138,7 +140,7 @@ public:
|
||||
// Data for loading a non-document sheet
|
||||
SheetLoadData(Loader* aLoader,
|
||||
nsIURI* aURI,
|
||||
CSSStyleSheet* aSheet,
|
||||
StyleSheetHandle aSheet,
|
||||
bool aSyncLoad,
|
||||
SheetParsingMode aParsingMode,
|
||||
bool aUseSystemPrincipal,
|
||||
@ -174,7 +176,7 @@ public:
|
||||
uint32_t mLineNumber;
|
||||
|
||||
// The sheet we're loading data for
|
||||
RefPtr<CSSStyleSheet> mSheet;
|
||||
StyleSheetHandle::RefPtr mSheet;
|
||||
|
||||
// Linked list of datas for the same URI as us
|
||||
SheetLoadData* mNext; // strong ref
|
||||
@ -305,7 +307,7 @@ NS_IMPL_ISUPPORTS(SheetLoadData, nsIUnicharStreamLoaderObserver, nsIRunnable,
|
||||
SheetLoadData::SheetLoadData(Loader* aLoader,
|
||||
const nsSubstring& aTitle,
|
||||
nsIURI* aURI,
|
||||
CSSStyleSheet* aSheet,
|
||||
StyleSheetHandle aSheet,
|
||||
nsIStyleSheetLinkingElement* aOwningElement,
|
||||
bool aIsAlternate,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
@ -337,7 +339,7 @@ SheetLoadData::SheetLoadData(Loader* aLoader,
|
||||
|
||||
SheetLoadData::SheetLoadData(Loader* aLoader,
|
||||
nsIURI* aURI,
|
||||
CSSStyleSheet* aSheet,
|
||||
StyleSheetHandle aSheet,
|
||||
SheetLoadData* aParentData,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
nsIPrincipal* aLoaderPrincipal,
|
||||
@ -378,7 +380,7 @@ SheetLoadData::SheetLoadData(Loader* aLoader,
|
||||
|
||||
SheetLoadData::SheetLoadData(Loader* aLoader,
|
||||
nsIURI* aURI,
|
||||
CSSStyleSheet* aSheet,
|
||||
StyleSheetHandle aSheet,
|
||||
bool aSyncLoad,
|
||||
SheetParsingMode aParsingMode,
|
||||
bool aUseSystemPrincipal,
|
||||
@ -950,7 +952,8 @@ SheetLoadData::OnStreamComplete(nsIUnicharStreamLoader* aLoader,
|
||||
}
|
||||
}
|
||||
|
||||
SRIMetadata sriMetadata = mSheet->GetIntegrity();
|
||||
SRIMetadata sriMetadata;
|
||||
mSheet->GetIntegrity(sriMetadata);
|
||||
if (!sriMetadata.IsEmpty() &&
|
||||
NS_FAILED(SRICheck::VerifyIntegrity(sriMetadata, aLoader,
|
||||
mSheet->GetCORSMode(), aBuffer,
|
||||
@ -1068,7 +1071,7 @@ Loader::CreateSheet(nsIURI* aURI,
|
||||
const nsAString& aTitle,
|
||||
StyleSheetState& aSheetState,
|
||||
bool *aIsAlternate,
|
||||
CSSStyleSheet** aSheet)
|
||||
StyleSheetHandle::RefPtr* aSheet)
|
||||
{
|
||||
LOG(("css::Loader::CreateSheet"));
|
||||
NS_PRECONDITION(aSheet, "Null out param!");
|
||||
@ -1084,9 +1087,10 @@ Loader::CreateSheet(nsIURI* aURI,
|
||||
// can mess with our hashtables.
|
||||
*aIsAlternate = IsAlternate(aTitle, aHasAlternateRel);
|
||||
|
||||
// XXXheycam Cached sheets currently must be CSSStyleSheets.
|
||||
if (aURI) {
|
||||
aSheetState = eSheetComplete;
|
||||
RefPtr<CSSStyleSheet> sheet;
|
||||
StyleSheetHandle::RefPtr sheet;
|
||||
|
||||
// First, the XUL cache
|
||||
#ifdef MOZ_XUL
|
||||
@ -1095,7 +1099,7 @@ Loader::CreateSheet(nsIURI* aURI,
|
||||
if (cache) {
|
||||
if (cache->IsEnabled()) {
|
||||
sheet = cache->GetStyleSheet(aURI);
|
||||
LOG((" From XUL cache: %p", sheet.get()));
|
||||
LOG((" From XUL cache: %p", sheet->AsVoidPtr()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1106,22 +1110,28 @@ Loader::CreateSheet(nsIURI* aURI,
|
||||
// Then our per-document complete sheets.
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey key(aURI, aLoaderPrincipal, aCORSMode, aReferrerPolicy);
|
||||
|
||||
mSheets->mCompleteSheets.Get(&key, getter_AddRefs(sheet));
|
||||
LOG((" From completed: %p", sheet.get()));
|
||||
StyleSheetHandle completeSheet;
|
||||
mSheets->mCompleteSheets.Get(&key, &completeSheet);
|
||||
sheet = completeSheet;
|
||||
LOG((" From completed: %p", sheet->AsVoidPtr()));
|
||||
|
||||
fromCompleteSheets = !!sheet;
|
||||
}
|
||||
|
||||
if (sheet) {
|
||||
if (sheet->IsServo()) {
|
||||
MOZ_CRASH("stylo: can't clone ServoStyleSheets yet");
|
||||
}
|
||||
|
||||
// This sheet came from the XUL cache or our per-document hashtable; it
|
||||
// better be a complete sheet.
|
||||
NS_ASSERTION(sheet->IsComplete(),
|
||||
NS_ASSERTION(sheet->AsGecko()->IsComplete(),
|
||||
"Sheet thinks it's not complete while we think it is");
|
||||
|
||||
// Make sure it hasn't been modified; if it has, we can't use it
|
||||
if (sheet->IsModified()) {
|
||||
if (sheet->AsGecko()->IsModified()) {
|
||||
LOG((" Not cloning completed sheet %p because it's been modified",
|
||||
sheet.get()));
|
||||
sheet->AsVoidPtr()));
|
||||
sheet = nullptr;
|
||||
fromCompleteSheets = false;
|
||||
}
|
||||
@ -1135,7 +1145,7 @@ Loader::CreateSheet(nsIURI* aURI,
|
||||
mSheets->mLoadingDatas.Get(&key, &loadData);
|
||||
if (loadData) {
|
||||
sheet = loadData->mSheet;
|
||||
LOG((" From loading: %p", sheet.get()));
|
||||
LOG((" From loading: %p", sheet->AsVoidPtr()));
|
||||
|
||||
#ifdef DEBUG
|
||||
bool debugEqual;
|
||||
@ -1155,7 +1165,7 @@ Loader::CreateSheet(nsIURI* aURI,
|
||||
mSheets->mPendingDatas.Get(&key, &loadData);
|
||||
if (loadData) {
|
||||
sheet = loadData->mSheet;
|
||||
LOG((" From pending: %p", sheet.get()));
|
||||
LOG((" From pending: %p", sheet->AsVoidPtr()));
|
||||
|
||||
#ifdef DEBUG
|
||||
bool debugEqual;
|
||||
@ -1172,20 +1182,28 @@ Loader::CreateSheet(nsIURI* aURI,
|
||||
|
||||
if (sheet) {
|
||||
// The sheet we have now should be either incomplete or unmodified
|
||||
NS_ASSERTION(!sheet->IsModified() || !sheet->IsComplete(),
|
||||
if (sheet->IsServo()) {
|
||||
MOZ_CRASH("stylo: can't clone ServoStyleSheets yet");
|
||||
}
|
||||
NS_ASSERTION(!sheet->AsGecko()->IsModified() ||
|
||||
!sheet->AsGecko()->IsComplete(),
|
||||
"Unexpected modified complete sheet");
|
||||
NS_ASSERTION(sheet->IsComplete() || aSheetState != eSheetComplete,
|
||||
NS_ASSERTION(sheet->AsGecko()->IsComplete() ||
|
||||
aSheetState != eSheetComplete,
|
||||
"Sheet thinks it's not complete while we think it is");
|
||||
|
||||
*aSheet = sheet->Clone(nullptr, nullptr, nullptr, nullptr).take();
|
||||
RefPtr<CSSStyleSheet> clonedSheet =
|
||||
sheet->AsGecko()->Clone(nullptr, nullptr, nullptr, nullptr);
|
||||
*aSheet = Move(clonedSheet);
|
||||
if (*aSheet && fromCompleteSheets &&
|
||||
!sheet->GetOwnerNode() && !sheet->GetParentSheet()) {
|
||||
!sheet->AsGecko()->GetOwnerNode() &&
|
||||
!sheet->AsGecko()->GetParentSheet()) {
|
||||
// The sheet we're cloning isn't actually referenced by
|
||||
// anyone. Replace it in the cache, so that if our CSSOM is
|
||||
// later modified we don't end up with two copies of our inner
|
||||
// hanging around.
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey key(aURI, aLoaderPrincipal, aCORSMode, aReferrerPolicy);
|
||||
NS_ASSERTION((*aSheet)->IsComplete(),
|
||||
NS_ASSERTION((*aSheet)->AsGecko()->IsComplete(),
|
||||
"Should only be caching complete sheets");
|
||||
mSheets->mCompleteSheets.Put(&key, *aSheet);
|
||||
}
|
||||
@ -1218,11 +1236,8 @@ Loader::CreateSheet(nsIURI* aURI,
|
||||
SRICheck::IntegrityMetadata(aIntegrity, mDocument, &sriMetadata);
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleSheet> sheet = new CSSStyleSheet(aCORSMode,
|
||||
aReferrerPolicy,
|
||||
sriMetadata);
|
||||
sheet->SetURIs(sheetURI, originalURI, baseURI);
|
||||
sheet.forget(aSheet);
|
||||
*aSheet = new CSSStyleSheet(aCORSMode, aReferrerPolicy, sriMetadata);
|
||||
(*aSheet)->SetURIs(sheetURI, originalURI, baseURI);
|
||||
}
|
||||
|
||||
NS_ASSERTION(*aSheet, "We should have a sheet by now!");
|
||||
@ -1238,7 +1253,7 @@ Loader::CreateSheet(nsIURI* aURI,
|
||||
* the sheet had "alternate" in its rel.
|
||||
*/
|
||||
void
|
||||
Loader::PrepareSheet(CSSStyleSheet* aSheet,
|
||||
Loader::PrepareSheet(StyleSheetHandle aSheet,
|
||||
const nsSubstring& aTitle,
|
||||
const nsSubstring& aMediaString,
|
||||
nsMediaList* aMediaList,
|
||||
@ -1247,6 +1262,14 @@ Loader::PrepareSheet(CSSStyleSheet* aSheet,
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "Must have a sheet!");
|
||||
|
||||
// XXXheycam Need to set media, title, etc. on ServoStyleSheets.
|
||||
if (aSheet->IsServo()) {
|
||||
NS_ERROR("stylo: should set metadata on ServoStyleSheets");
|
||||
return;
|
||||
}
|
||||
|
||||
CSSStyleSheet* sheet = aSheet->AsGecko();
|
||||
|
||||
RefPtr<nsMediaList> mediaList(aMediaList);
|
||||
|
||||
if (!aMediaString.IsEmpty()) {
|
||||
@ -1261,11 +1284,11 @@ Loader::PrepareSheet(CSSStyleSheet* aSheet,
|
||||
mediumParser.ParseMediaList(aMediaString, nullptr, 0, mediaList, true);
|
||||
}
|
||||
|
||||
aSheet->SetMedia(mediaList);
|
||||
sheet->SetMedia(mediaList);
|
||||
|
||||
aSheet->SetTitle(aTitle);
|
||||
aSheet->SetEnabled(! isAlternate);
|
||||
aSheet->SetScopeElement(aScopeElement);
|
||||
sheet->SetTitle(aTitle);
|
||||
sheet->SetEnabled(!isAlternate);
|
||||
sheet->SetScopeElement(aScopeElement);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1282,7 +1305,7 @@ Loader::PrepareSheet(CSSStyleSheet* aSheet,
|
||||
* as determined by CompareDocumentPosition.
|
||||
*/
|
||||
nsresult
|
||||
Loader::InsertSheetInDoc(CSSStyleSheet* aSheet,
|
||||
Loader::InsertSheetInDoc(StyleSheetHandle aSheet,
|
||||
nsIContent* aLinkingContent,
|
||||
nsIDocument* aDocument)
|
||||
{
|
||||
@ -1304,10 +1327,9 @@ Loader::InsertSheetInDoc(CSSStyleSheet* aSheet,
|
||||
*/
|
||||
int32_t insertionPoint;
|
||||
for (insertionPoint = sheetCount - 1; insertionPoint >= 0; --insertionPoint) {
|
||||
CSSStyleSheet* curSheet = aDocument->GetStyleSheetAt(insertionPoint);
|
||||
StyleSheetHandle curSheet = aDocument->GetStyleSheetAt(insertionPoint);
|
||||
NS_ASSERTION(curSheet, "There must be a sheet here!");
|
||||
nsCOMPtr<nsIDOMNode> sheetOwner;
|
||||
curSheet->GetOwnerNode(getter_AddRefs(sheetOwner));
|
||||
nsCOMPtr<nsINode> sheetOwner = curSheet->GetOwnerNode();
|
||||
if (sheetOwner && !aLinkingContent) {
|
||||
// Keep moving; all sheets with a sheetOwner come after all
|
||||
// sheets without a linkingNode
|
||||
@ -1320,12 +1342,11 @@ Loader::InsertSheetInDoc(CSSStyleSheet* aSheet,
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINode> sheetOwnerNode = do_QueryInterface(sheetOwner);
|
||||
NS_ASSERTION(aLinkingContent != sheetOwnerNode,
|
||||
NS_ASSERTION(aLinkingContent != sheetOwner,
|
||||
"Why do we still have our old sheet?");
|
||||
|
||||
// Have to compare
|
||||
if (nsContentUtils::PositionIsBefore(sheetOwnerNode, aLinkingContent)) {
|
||||
if (nsContentUtils::PositionIsBefore(sheetOwner, aLinkingContent)) {
|
||||
// The current sheet comes before us, and it better be the first
|
||||
// such, because now we break
|
||||
break;
|
||||
@ -1363,8 +1384,8 @@ Loader::InsertSheetInDoc(CSSStyleSheet* aSheet,
|
||||
* bug 1220506.)
|
||||
*/
|
||||
nsresult
|
||||
Loader::InsertChildSheet(CSSStyleSheet* aSheet,
|
||||
CSSStyleSheet* aParentSheet,
|
||||
Loader::InsertChildSheet(StyleSheetHandle aSheet,
|
||||
StyleSheetHandle aParentSheet,
|
||||
ImportRule* aParentRule)
|
||||
{
|
||||
LOG(("css::Loader::InsertChildSheet"));
|
||||
@ -1372,12 +1393,18 @@ Loader::InsertChildSheet(CSSStyleSheet* aSheet,
|
||||
NS_PRECONDITION(aParentSheet, "Need a parent to insert into");
|
||||
NS_PRECONDITION(aParentSheet, "How did we get imported?");
|
||||
|
||||
// XXXheycam The InsertChildSheet API doesn't work with ServoStyleSheets,
|
||||
// since they won't have Gecko ImportRules in them.
|
||||
if (aSheet->IsServo()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// child sheets should always start out enabled, even if they got
|
||||
// cloned off of top-level sheets which were disabled
|
||||
aSheet->SetEnabled(true);
|
||||
aSheet->AsGecko()->SetEnabled(true);
|
||||
|
||||
aParentSheet->AppendStyleSheet(aSheet);
|
||||
aParentRule->SetSheet(aSheet); // This sets the ownerRule on the sheet
|
||||
aParentRule->SetSheet(aSheet->AsGecko()); // This sets the ownerRule on the sheet
|
||||
|
||||
LOG((" Inserting into parent sheet"));
|
||||
// LOG((" Inserting into parent sheet at position %d", insertionPoint));
|
||||
@ -1418,7 +1445,8 @@ Loader::LoadSheet(SheetLoadData* aLoadData,
|
||||
return NS_BINDING_ABORTED;
|
||||
}
|
||||
|
||||
SRIMetadata sriMetadata = aLoadData->mSheet->GetIntegrity();
|
||||
SRIMetadata sriMetadata;
|
||||
aLoadData->mSheet->GetIntegrity(sriMetadata);
|
||||
|
||||
if (aLoadData->mSyncLoad) {
|
||||
LOG((" Synchronous load"));
|
||||
@ -1709,7 +1737,10 @@ Loader::ParseSheet(const nsAString& aInput,
|
||||
|
||||
aCompleted = false;
|
||||
|
||||
nsCSSParser parser(this, aLoadData->mSheet);
|
||||
// XXXheycam ServoStyleSheets don't support parsing their contents yet.
|
||||
MOZ_ASSERT(aLoadData->mSheet->IsGecko(),
|
||||
"stylo: can't parse ServoStyleSheets contents yet");
|
||||
nsCSSParser parser(this, aLoadData->mSheet->AsGecko());
|
||||
|
||||
// Push our load data on the stack so any kids can pick it up
|
||||
mParsingDatas.AppendElement(aLoadData);
|
||||
@ -1830,7 +1861,8 @@ Loader::DoSheetComplete(SheetLoadData* aLoadData, nsresult aStatus,
|
||||
// If mSheetAlreadyComplete, then the sheet could well be modified between
|
||||
// when we posted the async call to SheetComplete and now, since the sheet
|
||||
// was page-accessible during that whole time.
|
||||
MOZ_ASSERT(!data->mSheet->IsModified(),
|
||||
MOZ_ASSERT(!(data->mSheet->IsGecko() &&
|
||||
data->mSheet->AsGecko()->IsModified()),
|
||||
"should not get marked modified during parsing");
|
||||
data->mSheet->SetComplete();
|
||||
data->ScheduleLoadEventIfNeeded(aStatus);
|
||||
@ -1871,39 +1903,43 @@ Loader::DoSheetComplete(SheetLoadData* aLoadData, nsresult aStatus,
|
||||
// one of the sheets that will be kept alive by a document or
|
||||
// parent sheet anyway, so that if someone then accesses it via
|
||||
// CSSOM we won't have extra clones of the inner lying around.
|
||||
data = aLoadData;
|
||||
CSSStyleSheet* sheet = aLoadData->mSheet;
|
||||
while (data) {
|
||||
if (data->mSheet->GetParentSheet() || data->mSheet->GetOwnerNode()) {
|
||||
sheet = data->mSheet;
|
||||
break;
|
||||
if (aLoadData->mSheet->IsGecko()) {
|
||||
data = aLoadData;
|
||||
CSSStyleSheet* sheet = aLoadData->mSheet->AsGecko();
|
||||
while (data) {
|
||||
if (data->mSheet->GetParentSheet() || data->mSheet->GetOwnerNode()) {
|
||||
sheet = data->mSheet->AsGecko();
|
||||
break;
|
||||
}
|
||||
data = data->mNext;
|
||||
}
|
||||
data = data->mNext;
|
||||
}
|
||||
#ifdef MOZ_XUL
|
||||
if (IsChromeURI(aLoadData->mURI)) {
|
||||
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
|
||||
if (cache && cache->IsEnabled()) {
|
||||
if (!cache->GetStyleSheet(aLoadData->mURI)) {
|
||||
LOG((" Putting sheet in XUL prototype cache"));
|
||||
NS_ASSERTION(sheet->IsComplete(),
|
||||
"Should only be caching complete sheets");
|
||||
cache->PutStyleSheet(sheet);
|
||||
if (IsChromeURI(aLoadData->mURI)) {
|
||||
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
|
||||
if (cache && cache->IsEnabled()) {
|
||||
if (!cache->GetStyleSheet(aLoadData->mURI)) {
|
||||
LOG((" Putting sheet in XUL prototype cache"));
|
||||
NS_ASSERTION(sheet->IsComplete(),
|
||||
"Should only be caching complete sheets");
|
||||
cache->PutStyleSheet(sheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
else {
|
||||
#endif
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey key(aLoadData->mURI,
|
||||
aLoadData->mLoaderPrincipal,
|
||||
aLoadData->mSheet->GetCORSMode(),
|
||||
aLoadData->mSheet->GetReferrerPolicy());
|
||||
NS_ASSERTION(sheet->IsComplete(),
|
||||
"Should only be caching complete sheets");
|
||||
mSheets->mCompleteSheets.Put(&key, sheet);
|
||||
URIPrincipalReferrerPolicyAndCORSModeHashKey key(aLoadData->mURI,
|
||||
aLoadData->mLoaderPrincipal,
|
||||
aLoadData->mSheet->GetCORSMode(),
|
||||
aLoadData->mSheet->GetReferrerPolicy());
|
||||
NS_ASSERTION(sheet->IsComplete(),
|
||||
"Should only be caching complete sheets");
|
||||
mSheets->mCompleteSheets.Put(&key, sheet);
|
||||
#ifdef MOZ_XUL
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
NS_ERROR("stylo: not caching ServoStyleSheet");
|
||||
}
|
||||
}
|
||||
|
||||
NS_RELEASE(aLoadData); // this will release parents and siblings and all that
|
||||
@ -1939,12 +1975,12 @@ Loader::LoadInlineStyle(nsIContent* aElement,
|
||||
// load data or to CreateSheet(). Also, OK to use CORS_NONE for the CORS
|
||||
// mode and mDocument's ReferrerPolicy.
|
||||
StyleSheetState state;
|
||||
RefPtr<CSSStyleSheet> sheet;
|
||||
StyleSheetHandle::RefPtr sheet;
|
||||
nsresult rv = CreateSheet(nullptr, aElement, nullptr, CORS_NONE,
|
||||
mDocument->GetReferrerPolicy(),
|
||||
EmptyString(), // no inline integrity checks
|
||||
false, false, aTitle, state, aIsAlternate,
|
||||
getter_AddRefs(sheet));
|
||||
&sheet);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ASSERTION(state == eSheetNeedsParser,
|
||||
"Inline sheets should not be cached");
|
||||
@ -2022,11 +2058,11 @@ Loader::LoadStyleLink(nsIContent* aElement,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
StyleSheetState state;
|
||||
RefPtr<CSSStyleSheet> sheet;
|
||||
StyleSheetHandle::RefPtr sheet;
|
||||
rv = CreateSheet(aURL, aElement, principal, aCORSMode,
|
||||
aReferrerPolicy, aIntegrity, false,
|
||||
aHasAlternateRel, aTitle, state, aIsAlternate,
|
||||
getter_AddRefs(sheet));
|
||||
&sheet);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
LOG((" Sheet is alternate: %d", *aIsAlternate));
|
||||
@ -2039,8 +2075,7 @@ Loader::LoadStyleLink(nsIContent* aElement,
|
||||
nsCOMPtr<nsIStyleSheetLinkingElement> owningElement(do_QueryInterface(aElement));
|
||||
|
||||
if (state == eSheetComplete) {
|
||||
LOG((" Sheet already complete: 0x%p",
|
||||
static_cast<void*>(sheet.get())));
|
||||
LOG((" Sheet already complete: 0x%p", sheet->AsVoidPtr()));
|
||||
if (aObserver || !mObservers.IsEmpty() || owningElement) {
|
||||
rv = PostLoadEvent(aURL, sheet, aObserver, *aIsAlternate,
|
||||
owningElement);
|
||||
@ -2110,7 +2145,7 @@ HaveAncestorDataWithURI(SheetLoadData *aData, nsIURI *aURI)
|
||||
}
|
||||
|
||||
nsresult
|
||||
Loader::LoadChildSheet(CSSStyleSheet* aParentSheet,
|
||||
Loader::LoadChildSheet(StyleSheetHandle aParentSheet,
|
||||
nsIURI* aURL,
|
||||
nsMediaList* aMedia,
|
||||
ImportRule* aParentRule,
|
||||
@ -2127,22 +2162,16 @@ Loader::LoadChildSheet(CSSStyleSheet* aParentSheet,
|
||||
|
||||
LOG_URI(" Child uri: '%s'", aURL);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> owningNode;
|
||||
nsCOMPtr<nsINode> owningNode;
|
||||
|
||||
// check for an owning document: if none, don't bother walking up the parent
|
||||
// sheets
|
||||
if (aParentSheet->GetOwningDocument()) {
|
||||
nsCOMPtr<nsIDOMStyleSheet> nextParentSheet(aParentSheet);
|
||||
NS_ENSURE_TRUE(nextParentSheet, NS_ERROR_FAILURE); //Not a stylesheet!?
|
||||
|
||||
nsCOMPtr<nsIDOMStyleSheet> topSheet;
|
||||
//traverse our way to the top-most sheet
|
||||
do {
|
||||
topSheet.swap(nextParentSheet);
|
||||
topSheet->GetParentStyleSheet(getter_AddRefs(nextParentSheet));
|
||||
} while (nextParentSheet);
|
||||
|
||||
topSheet->GetOwnerNode(getter_AddRefs(owningNode));
|
||||
StyleSheetHandle topSheet = aParentSheet;
|
||||
while (StyleSheetHandle parent = topSheet->GetParentSheet()) {
|
||||
topSheet = parent;
|
||||
}
|
||||
owningNode = topSheet->GetOwnerNode();
|
||||
}
|
||||
|
||||
nsISupports* context = owningNode;
|
||||
@ -2175,15 +2204,20 @@ Loader::LoadChildSheet(CSSStyleSheet* aParentSheet,
|
||||
LOG((" No parent load; must be CSSOM"));
|
||||
// No parent load data, so the sheet will need to be notified when
|
||||
// we finish, if it can be, if we do the load asynchronously.
|
||||
observer = aParentSheet;
|
||||
// XXXheycam ServoStyleSheet doesn't implement nsICSSLoaderObserver yet.
|
||||
MOZ_ASSERT(aParentSheet->IsGecko(),
|
||||
"stylo: ServoStyleSheets don't support child sheet loading yet");
|
||||
observer = aParentSheet->AsGecko();
|
||||
}
|
||||
|
||||
// Now that we know it's safe to load this (passes security check and not a
|
||||
// loop) do so.
|
||||
RefPtr<CSSStyleSheet> sheet;
|
||||
StyleSheetHandle::RefPtr sheet;
|
||||
RefPtr<CSSStyleSheet> reusableSheet;
|
||||
StyleSheetState state;
|
||||
if (aReusableSheets && aReusableSheets->FindReusableStyleSheet(aURL, sheet)) {
|
||||
aParentRule->SetSheet(sheet);
|
||||
if (aReusableSheets && aReusableSheets->FindReusableStyleSheet(aURL, reusableSheet)) {
|
||||
sheet = reusableSheet;
|
||||
aParentRule->SetSheet(reusableSheet);
|
||||
state = eSheetComplete;
|
||||
} else {
|
||||
bool isAlternate;
|
||||
@ -2193,7 +2227,7 @@ Loader::LoadChildSheet(CSSStyleSheet* aParentSheet,
|
||||
aParentSheet->GetReferrerPolicy(),
|
||||
EmptyString(), // integrity is only checked on main sheet
|
||||
parentData ? parentData->mSyncLoad : false,
|
||||
false, empty, state, &isAlternate, getter_AddRefs(sheet));
|
||||
false, empty, state, &isAlternate, &sheet);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PrepareSheet(sheet, empty, empty, aMedia, nullptr, isAlternate);
|
||||
@ -2232,7 +2266,7 @@ nsresult
|
||||
Loader::LoadSheetSync(nsIURI* aURL,
|
||||
SheetParsingMode aParsingMode,
|
||||
bool aUseSystemPrincipal,
|
||||
CSSStyleSheet** aSheet)
|
||||
StyleSheetHandle::RefPtr* aSheet)
|
||||
{
|
||||
LOG(("css::Loader::LoadSheetSync"));
|
||||
return InternalLoadNonDocumentSheet(aURL,
|
||||
@ -2246,7 +2280,7 @@ Loader::LoadSheet(nsIURI* aURL,
|
||||
nsIPrincipal* aOriginPrincipal,
|
||||
const nsCString& aCharset,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
CSSStyleSheet** aSheet)
|
||||
StyleSheetHandle::RefPtr* aSheet)
|
||||
{
|
||||
LOG(("css::Loader::LoadSheet(aURL, aObserver, aSheet) api call"));
|
||||
NS_PRECONDITION(aSheet, "aSheet is null");
|
||||
@ -2281,7 +2315,7 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL,
|
||||
bool aUseSystemPrincipal,
|
||||
nsIPrincipal* aOriginPrincipal,
|
||||
const nsCString& aCharset,
|
||||
CSSStyleSheet** aSheet,
|
||||
StyleSheetHandle::RefPtr* aSheet,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
CORSMode aCORSMode,
|
||||
ReferrerPolicy aReferrerPolicy,
|
||||
@ -2309,13 +2343,13 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL,
|
||||
|
||||
StyleSheetState state;
|
||||
bool isAlternate;
|
||||
RefPtr<CSSStyleSheet> sheet;
|
||||
StyleSheetHandle::RefPtr sheet;
|
||||
bool syncLoad = (aObserver == nullptr);
|
||||
const nsSubstring& empty = EmptyString();
|
||||
|
||||
rv = CreateSheet(aURL, nullptr, aOriginPrincipal, aCORSMode,
|
||||
aReferrerPolicy, aIntegrity, syncLoad, false,
|
||||
empty, state, &isAlternate, getter_AddRefs(sheet));
|
||||
empty, state, &isAlternate, &sheet);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PrepareSheet(sheet, empty, empty, nullptr, nullptr, isAlternate);
|
||||
@ -2352,7 +2386,7 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL,
|
||||
|
||||
nsresult
|
||||
Loader::PostLoadEvent(nsIURI* aURI,
|
||||
CSSStyleSheet* aSheet,
|
||||
StyleSheetHandle aSheet,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
bool aWasAlternate,
|
||||
nsIStyleSheetLinkingElement* aElement)
|
||||
@ -2535,7 +2569,10 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Loader)
|
||||
!iter.Done();
|
||||
iter.Next()) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "Sheet cache nsCSSLoader");
|
||||
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, iter.UserData()));
|
||||
if (iter.UserData()->IsGecko()) {
|
||||
CSSStyleSheet* sheet = iter.UserData()->AsGecko();
|
||||
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, sheet));
|
||||
}
|
||||
}
|
||||
}
|
||||
nsTObserverArray<nsCOMPtr<nsICSSLoaderObserver>>::ForwardIterator
|
||||
@ -2569,10 +2606,10 @@ Loader::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
||||
// If aSheet has a parent, then its parent will report it so we don't
|
||||
// have to worry about it here. Likewise, if aSheet has an owning node,
|
||||
// then the document that node is in will report it.
|
||||
const RefPtr<CSSStyleSheet>& aSheet = iter.Data();
|
||||
n += (aSheet->GetOwnerNode() || aSheet->GetParentSheet())
|
||||
const StyleSheetHandle sheet = iter.UserData();
|
||||
n += (sheet->GetOwnerNode() || sheet->GetParentSheet())
|
||||
? 0
|
||||
: aSheet->SizeOfIncludingThis(aMallocSizeOf);
|
||||
: sheet->SizeOfIncludingThis(aMallocSizeOf);
|
||||
}
|
||||
}
|
||||
n += mObservers.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/CSSStyleSheet.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/net/ReferrerPolicy.h"
|
||||
|
||||
class nsICSSLoaderObserver;
|
||||
@ -286,7 +287,7 @@ public:
|
||||
* @param aSavedSheets any saved style sheets which could be reused
|
||||
* for this load
|
||||
*/
|
||||
nsresult LoadChildSheet(CSSStyleSheet* aParentSheet,
|
||||
nsresult LoadChildSheet(StyleSheetHandle aParentSheet,
|
||||
nsIURI* aURL,
|
||||
nsMediaList* aMedia,
|
||||
ImportRule* aRule,
|
||||
@ -317,13 +318,13 @@ public:
|
||||
nsresult LoadSheetSync(nsIURI* aURL,
|
||||
SheetParsingMode aParsingMode,
|
||||
bool aUseSystemPrincipal,
|
||||
CSSStyleSheet** aSheet);
|
||||
StyleSheetHandle::RefPtr* aSheet);
|
||||
|
||||
/**
|
||||
* As above, but defaults aParsingMode to eAuthorSheetFeatures and
|
||||
* aUseSystemPrincipal to false.
|
||||
*/
|
||||
nsresult LoadSheetSync(nsIURI* aURL, CSSStyleSheet** aSheet) {
|
||||
nsresult LoadSheetSync(nsIURI* aURL, StyleSheetHandle::RefPtr* aSheet) {
|
||||
return LoadSheetSync(aURL, eAuthorSheetFeatures, false, aSheet);
|
||||
}
|
||||
|
||||
@ -352,7 +353,7 @@ public:
|
||||
nsIPrincipal* aOriginPrincipal,
|
||||
const nsCString& aCharset,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
CSSStyleSheet** aSheet);
|
||||
StyleSheetHandle::RefPtr* aSheet);
|
||||
|
||||
/**
|
||||
* Same as above, to be used when the caller doesn't care about the
|
||||
@ -461,24 +462,24 @@ private:
|
||||
const nsAString& aTitle,
|
||||
StyleSheetState& aSheetState,
|
||||
bool *aIsAlternate,
|
||||
CSSStyleSheet** aSheet);
|
||||
StyleSheetHandle::RefPtr* aSheet);
|
||||
|
||||
// Pass in either a media string or the nsMediaList from the
|
||||
// CSSParser. Don't pass both.
|
||||
// This method will set the sheet's enabled state based on isAlternate
|
||||
void PrepareSheet(CSSStyleSheet* aSheet,
|
||||
void PrepareSheet(StyleSheetHandle aSheet,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aMediaString,
|
||||
nsMediaList* aMediaList,
|
||||
dom::Element* aScopeElement,
|
||||
bool isAlternate);
|
||||
|
||||
nsresult InsertSheetInDoc(CSSStyleSheet* aSheet,
|
||||
nsresult InsertSheetInDoc(StyleSheetHandle aSheet,
|
||||
nsIContent* aLinkingContent,
|
||||
nsIDocument* aDocument);
|
||||
|
||||
nsresult InsertChildSheet(CSSStyleSheet* aSheet,
|
||||
CSSStyleSheet* aParentSheet,
|
||||
nsresult InsertChildSheet(StyleSheetHandle aSheet,
|
||||
StyleSheetHandle aParentSheet,
|
||||
ImportRule* aParentRule);
|
||||
|
||||
nsresult InternalLoadNonDocumentSheet(nsIURI* aURL,
|
||||
@ -487,7 +488,7 @@ private:
|
||||
bool aUseSystemPrincipal,
|
||||
nsIPrincipal* aOriginPrincipal,
|
||||
const nsCString& aCharset,
|
||||
CSSStyleSheet** aSheet,
|
||||
StyleSheetHandle::RefPtr* aSheet,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
CORSMode aCORSMode = CORS_NONE,
|
||||
ReferrerPolicy aReferrerPolicy = mozilla::net::RP_Default,
|
||||
@ -501,7 +502,7 @@ private:
|
||||
// sheet was loaded from (may be null for inline sheets). aElement is the
|
||||
// owning element for this sheet.
|
||||
nsresult PostLoadEvent(nsIURI* aURI,
|
||||
CSSStyleSheet* aSheet,
|
||||
StyleSheetHandle aSheet,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
bool aWasAlternate,
|
||||
nsIStyleSheetLinkingElement* aElement);
|
||||
@ -537,8 +538,9 @@ private:
|
||||
LoadDataArray& aDatasToNotify);
|
||||
|
||||
struct Sheets {
|
||||
nsRefPtrHashtable<URIPrincipalReferrerPolicyAndCORSModeHashKey, CSSStyleSheet>
|
||||
mCompleteSheets;
|
||||
nsBaseHashtable<URIPrincipalReferrerPolicyAndCORSModeHashKey,
|
||||
StyleSheetHandle::RefPtr,
|
||||
StyleSheetHandle> mCompleteSheets;
|
||||
nsDataHashtable<URIPrincipalReferrerPolicyAndCORSModeHashKey, SheetLoadData*>
|
||||
mLoadingDatas; // weak refs
|
||||
nsDataHashtable<URIPrincipalReferrerPolicyAndCORSModeHashKey, SheetLoadData*>
|
||||
|
@ -96,36 +96,36 @@ ServoStyleSet::ResolveAnonymousBoxStyle(nsIAtom* aPseudoTag,
|
||||
// manage the set of style sheets in the style set
|
||||
nsresult
|
||||
ServoStyleSet::AppendStyleSheet(SheetType aType,
|
||||
CSSStyleSheet* aSheet)
|
||||
ServoStyleSheet* aSheet)
|
||||
{
|
||||
MOZ_CRASH("stylo: not implemented");
|
||||
}
|
||||
|
||||
nsresult
|
||||
ServoStyleSet::PrependStyleSheet(SheetType aType,
|
||||
CSSStyleSheet* aSheet)
|
||||
ServoStyleSheet* aSheet)
|
||||
{
|
||||
MOZ_CRASH("stylo: not implemented");
|
||||
}
|
||||
|
||||
nsresult
|
||||
ServoStyleSet::RemoveStyleSheet(SheetType aType,
|
||||
CSSStyleSheet* aSheet)
|
||||
ServoStyleSheet* aSheet)
|
||||
{
|
||||
MOZ_CRASH("stylo: not implemented");
|
||||
}
|
||||
|
||||
nsresult
|
||||
ServoStyleSet::ReplaceSheets(SheetType aType,
|
||||
const nsTArray<RefPtr<CSSStyleSheet>>& aNewSheets)
|
||||
const nsTArray<RefPtr<ServoStyleSheet>>& aNewSheets)
|
||||
{
|
||||
MOZ_CRASH("stylo: not implemented");
|
||||
}
|
||||
|
||||
nsresult
|
||||
ServoStyleSet::InsertStyleSheetBefore(SheetType aType,
|
||||
CSSStyleSheet* aNewSheet,
|
||||
CSSStyleSheet* aReferenceSheet)
|
||||
ServoStyleSheet* aNewSheet,
|
||||
ServoStyleSheet* aReferenceSheet)
|
||||
{
|
||||
MOZ_CRASH("stylo: not implemented");
|
||||
}
|
||||
@ -136,7 +136,7 @@ ServoStyleSet::SheetCount(SheetType aType) const
|
||||
MOZ_CRASH("stylo: not implemented");
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
ServoStyleSheet*
|
||||
ServoStyleSet::StyleSheetAt(SheetType aType,
|
||||
int32_t aIndex) const
|
||||
{
|
||||
@ -144,13 +144,13 @@ ServoStyleSet::StyleSheetAt(SheetType aType,
|
||||
}
|
||||
|
||||
nsresult
|
||||
ServoStyleSet::RemoveDocStyleSheet(CSSStyleSheet* aSheet)
|
||||
ServoStyleSet::RemoveDocStyleSheet(ServoStyleSheet* aSheet)
|
||||
{
|
||||
MOZ_CRASH("stylo: not implemented");
|
||||
}
|
||||
|
||||
nsresult
|
||||
ServoStyleSet::AddDocStyleSheet(CSSStyleSheet* aSheet,
|
||||
ServoStyleSet::AddDocStyleSheet(ServoStyleSheet* aSheet,
|
||||
nsIDocument* aDocument)
|
||||
{
|
||||
MOZ_CRASH("stylo: not implemented");
|
||||
|
@ -20,6 +20,7 @@ namespace dom {
|
||||
class Element;
|
||||
} // namespace dom
|
||||
class CSSStyleSheet;
|
||||
class ServoStyleSheet;
|
||||
} // namespace mozilla
|
||||
class nsStyleContext;
|
||||
class nsPresContext;
|
||||
@ -69,20 +70,20 @@ public:
|
||||
uint32_t aFlags = 0);
|
||||
|
||||
// manage the set of style sheets in the style set
|
||||
nsresult AppendStyleSheet(SheetType aType, CSSStyleSheet* aSheet);
|
||||
nsresult PrependStyleSheet(SheetType aType, CSSStyleSheet* aSheet);
|
||||
nsresult RemoveStyleSheet(SheetType aType, CSSStyleSheet* aSheet);
|
||||
nsresult AppendStyleSheet(SheetType aType, ServoStyleSheet* aSheet);
|
||||
nsresult PrependStyleSheet(SheetType aType, ServoStyleSheet* aSheet);
|
||||
nsresult RemoveStyleSheet(SheetType aType, ServoStyleSheet* aSheet);
|
||||
nsresult ReplaceSheets(SheetType aType,
|
||||
const nsTArray<RefPtr<CSSStyleSheet>>& aNewSheets);
|
||||
const nsTArray<RefPtr<ServoStyleSheet>>& aNewSheets);
|
||||
nsresult InsertStyleSheetBefore(SheetType aType,
|
||||
CSSStyleSheet* aNewSheet,
|
||||
CSSStyleSheet* aReferenceSheet);
|
||||
ServoStyleSheet* aNewSheet,
|
||||
ServoStyleSheet* aReferenceSheet);
|
||||
|
||||
int32_t SheetCount(SheetType aType) const;
|
||||
CSSStyleSheet* StyleSheetAt(SheetType aType, int32_t aIndex) const;
|
||||
ServoStyleSheet* StyleSheetAt(SheetType aType, int32_t aIndex) const;
|
||||
|
||||
nsresult RemoveDocStyleSheet(CSSStyleSheet* aSheet);
|
||||
nsresult AddDocStyleSheet(CSSStyleSheet* aSheet, nsIDocument* aDocument);
|
||||
nsresult RemoveDocStyleSheet(ServoStyleSheet* aSheet);
|
||||
nsresult AddDocStyleSheet(ServoStyleSheet* aSheet, nsIDocument* aDocument);
|
||||
|
||||
// check whether there is ::before/::after style for an element
|
||||
already_AddRefed<nsStyleContext>
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/SheetType.h"
|
||||
#include "mozilla/StyleBackendType.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "nsChangeHint.h"
|
||||
#include "nsCSSPseudoElements.h"
|
||||
#include "nsTArray.h"
|
||||
@ -127,18 +128,18 @@ public:
|
||||
inline already_AddRefed<nsStyleContext>
|
||||
ResolveAnonymousBoxStyle(nsIAtom* aPseudoTag, nsStyleContext* aParentContext,
|
||||
uint32_t aFlags = 0);
|
||||
inline nsresult AppendStyleSheet(SheetType aType, CSSStyleSheet* aSheet);
|
||||
inline nsresult PrependStyleSheet(SheetType aType, CSSStyleSheet* aSheet);
|
||||
inline nsresult RemoveStyleSheet(SheetType aType, CSSStyleSheet* aSheet);
|
||||
inline nsresult AppendStyleSheet(SheetType aType, StyleSheetHandle aSheet);
|
||||
inline nsresult PrependStyleSheet(SheetType aType, StyleSheetHandle aSheet);
|
||||
inline nsresult RemoveStyleSheet(SheetType aType, StyleSheetHandle aSheet);
|
||||
inline nsresult ReplaceSheets(SheetType aType,
|
||||
const nsTArray<RefPtr<CSSStyleSheet>>& aNewSheets);
|
||||
const nsTArray<StyleSheetHandle::RefPtr>& aNewSheets);
|
||||
inline nsresult InsertStyleSheetBefore(SheetType aType,
|
||||
CSSStyleSheet* aNewSheet,
|
||||
CSSStyleSheet* aReferenceSheet);
|
||||
StyleSheetHandle aNewSheet,
|
||||
StyleSheetHandle aReferenceSheet);
|
||||
inline int32_t SheetCount(SheetType aType) const;
|
||||
inline CSSStyleSheet* StyleSheetAt(SheetType aType, int32_t aIndex) const;
|
||||
inline nsresult RemoveDocStyleSheet(CSSStyleSheet* aSheet);
|
||||
inline nsresult AddDocStyleSheet(CSSStyleSheet* aSheet, nsIDocument* aDocument);
|
||||
inline StyleSheetHandle StyleSheetAt(SheetType aType, int32_t aIndex) const;
|
||||
inline nsresult RemoveDocStyleSheet(StyleSheetHandle aSheet);
|
||||
inline nsresult AddDocStyleSheet(StyleSheetHandle aSheet, nsIDocument* aDocument);
|
||||
inline already_AddRefed<nsStyleContext>
|
||||
ProbePseudoElementStyle(dom::Element* aParentElement,
|
||||
mozilla::CSSPseudoElementType aType,
|
||||
|
@ -7,11 +7,19 @@
|
||||
#ifndef mozilla_StyleSetHandleInlines_h
|
||||
#define mozilla_StyleSetHandleInlines_h
|
||||
|
||||
#include "mozilla/CSSStyleSheet.h"
|
||||
#include "mozilla/ServoStyleSet.h"
|
||||
#include "mozilla/ServoStyleSheet.h"
|
||||
#include "nsStyleSet.h"
|
||||
|
||||
#define FORWARD(method_, args_) \
|
||||
return IsGecko() ? AsGecko()->method_ args_ : AsServo()->method_ args_;
|
||||
#define FORWARD_CONCRETE(method_, geckoargs_, servoargs_) \
|
||||
if (IsGecko()) { \
|
||||
return AsGecko()->method_ geckoargs_; \
|
||||
} else { \
|
||||
return AsServo()->method_ servoargs_; \
|
||||
}
|
||||
|
||||
#define FORWARD(method_, args_) FORWARD_CONCRETE(method_, args_, args_)
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -112,36 +120,54 @@ StyleSetHandle::Ptr::ResolveAnonymousBoxStyle(nsIAtom* aPseudoTag,
|
||||
|
||||
// manage the set of style sheets in the style set
|
||||
nsresult
|
||||
StyleSetHandle::Ptr::AppendStyleSheet(SheetType aType, CSSStyleSheet* aSheet)
|
||||
StyleSetHandle::Ptr::AppendStyleSheet(SheetType aType, StyleSheetHandle aSheet)
|
||||
{
|
||||
FORWARD(AppendStyleSheet, (aType, aSheet));
|
||||
FORWARD_CONCRETE(AppendStyleSheet, (aType, aSheet->AsGecko()),
|
||||
(aType, aSheet->AsServo()));
|
||||
}
|
||||
|
||||
nsresult
|
||||
StyleSetHandle::Ptr::PrependStyleSheet(SheetType aType, CSSStyleSheet* aSheet)
|
||||
StyleSetHandle::Ptr::PrependStyleSheet(SheetType aType, StyleSheetHandle aSheet)
|
||||
{
|
||||
FORWARD(PrependStyleSheet, (aType, aSheet));
|
||||
FORWARD_CONCRETE(PrependStyleSheet, (aType, aSheet->AsGecko()),
|
||||
(aType, aSheet->AsServo()));
|
||||
}
|
||||
|
||||
nsresult
|
||||
StyleSetHandle::Ptr::RemoveStyleSheet(SheetType aType, CSSStyleSheet* aSheet)
|
||||
StyleSetHandle::Ptr::RemoveStyleSheet(SheetType aType, StyleSheetHandle aSheet)
|
||||
{
|
||||
FORWARD(RemoveStyleSheet, (aType, aSheet));
|
||||
FORWARD_CONCRETE(RemoveStyleSheet, (aType, aSheet->AsGecko()),
|
||||
(aType, aSheet->AsServo()));
|
||||
}
|
||||
|
||||
nsresult
|
||||
StyleSetHandle::Ptr::ReplaceSheets(SheetType aType,
|
||||
const nsTArray<RefPtr<CSSStyleSheet>>& aNewSheets)
|
||||
const nsTArray<StyleSheetHandle::RefPtr>& aNewSheets)
|
||||
{
|
||||
FORWARD(ReplaceSheets, (aType, aNewSheets));
|
||||
if (IsGecko()) {
|
||||
nsTArray<RefPtr<CSSStyleSheet>> newSheets(aNewSheets.Length());
|
||||
for (auto& sheet : aNewSheets) {
|
||||
newSheets.AppendElement(sheet->AsGecko());
|
||||
}
|
||||
return AsGecko()->ReplaceSheets(aType, newSheets);
|
||||
} else {
|
||||
nsTArray<RefPtr<ServoStyleSheet>> newSheets(aNewSheets.Length());
|
||||
for (auto& sheet : aNewSheets) {
|
||||
newSheets.AppendElement(sheet->AsServo());
|
||||
}
|
||||
return AsServo()->ReplaceSheets(aType, newSheets);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
StyleSetHandle::Ptr::InsertStyleSheetBefore(SheetType aType,
|
||||
CSSStyleSheet* aNewSheet,
|
||||
CSSStyleSheet* aReferenceSheet)
|
||||
StyleSheetHandle aNewSheet,
|
||||
StyleSheetHandle aReferenceSheet)
|
||||
{
|
||||
FORWARD(InsertStyleSheetBefore, (aType, aNewSheet, aReferenceSheet));
|
||||
FORWARD_CONCRETE(
|
||||
InsertStyleSheetBefore,
|
||||
(aType, aNewSheet->AsGecko(), aReferenceSheet->AsGecko()),
|
||||
(aType, aReferenceSheet->AsServo(), aReferenceSheet->AsServo()));
|
||||
}
|
||||
|
||||
int32_t
|
||||
@ -150,23 +176,25 @@ StyleSetHandle::Ptr::SheetCount(SheetType aType) const
|
||||
FORWARD(SheetCount, (aType));
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
StyleSetHandle::Ptr::StyleSheetAt(SheetType aType, int32_t aIndex) const
|
||||
{
|
||||
FORWARD(StyleSheetAt, (aType, aIndex));
|
||||
}
|
||||
|
||||
nsresult
|
||||
StyleSetHandle::Ptr::RemoveDocStyleSheet(CSSStyleSheet* aSheet)
|
||||
StyleSetHandle::Ptr::RemoveDocStyleSheet(StyleSheetHandle aSheet)
|
||||
{
|
||||
FORWARD(RemoveDocStyleSheet, (aSheet));
|
||||
FORWARD_CONCRETE(RemoveDocStyleSheet, (aSheet->AsGecko()),
|
||||
(aSheet->AsServo()));
|
||||
}
|
||||
|
||||
nsresult
|
||||
StyleSetHandle::Ptr::AddDocStyleSheet(CSSStyleSheet* aSheet,
|
||||
StyleSetHandle::Ptr::AddDocStyleSheet(StyleSheetHandle aSheet,
|
||||
nsIDocument* aDocument)
|
||||
{
|
||||
FORWARD(AddDocStyleSheet, (aSheet, aDocument));
|
||||
FORWARD_CONCRETE(AddDocStyleSheet, (aSheet->AsGecko(), aDocument),
|
||||
(aSheet->AsServo(), aDocument));
|
||||
}
|
||||
|
||||
// check whether there is ::before/::after style for an element
|
||||
|
@ -9,14 +9,11 @@
|
||||
#define nsICSSLoaderObserver_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
|
||||
#define NS_ICSSLOADEROBSERVER_IID \
|
||||
{ 0x7eb90c74, 0xea0c, 0x4df5, \
|
||||
{0xa1, 0x5f, 0x95, 0xf0, 0x6a, 0x98, 0xb9, 0x40} }
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
} // namespace mozilla
|
||||
#define NS_ICSSLOADEROBSERVER_IID \
|
||||
{ 0xf51fbf2c, 0xfe4b, 0x4a15, \
|
||||
{ 0xaf, 0x7e, 0x5e, 0x20, 0x64, 0x5f, 0xaf, 0x58 } }
|
||||
|
||||
class nsICSSLoaderObserver : public nsISupports {
|
||||
public:
|
||||
@ -37,7 +34,7 @@ public:
|
||||
* as CSS, and doesn't indicate anything about the status of any child
|
||||
* sheets of aSheet.
|
||||
*/
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::CSSStyleSheet* aSheet,
|
||||
NS_IMETHOD StyleSheetLoaded(mozilla::StyleSheetHandle aSheet,
|
||||
bool aWasAlternate,
|
||||
nsresult aStatus) = 0;
|
||||
};
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "mozilla/CSSStyleSheet.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsNetUtil.h"
|
||||
@ -65,217 +67,185 @@ nsLayoutStylesheetCache::Observe(nsISupports* aSubject,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::ScrollbarsSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
|
||||
if (!gStyleCache->mScrollbarsSheet) {
|
||||
if (!mScrollbarsSheet) {
|
||||
// Scrollbars don't need access to unsafe rules
|
||||
LoadSheetURL("chrome://global/skin/scrollbars.css",
|
||||
gStyleCache->mScrollbarsSheet, eAuthorSheetFeatures);
|
||||
mScrollbarsSheet, eAuthorSheetFeatures);
|
||||
}
|
||||
|
||||
return gStyleCache->mScrollbarsSheet;
|
||||
return mScrollbarsSheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::FormsSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
|
||||
if (!gStyleCache->mFormsSheet) {
|
||||
if (!mFormsSheet) {
|
||||
// forms.css needs access to unsafe rules
|
||||
LoadSheetURL("resource://gre-resources/forms.css",
|
||||
gStyleCache->mFormsSheet, eAgentSheetFeatures);
|
||||
mFormsSheet, eAgentSheetFeatures);
|
||||
}
|
||||
|
||||
return gStyleCache->mFormsSheet;
|
||||
return mFormsSheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::NumberControlSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
|
||||
if (!sNumberControlEnabled) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!gStyleCache->mNumberControlSheet) {
|
||||
if (!mNumberControlSheet) {
|
||||
LoadSheetURL("resource://gre-resources/number-control.css",
|
||||
gStyleCache->mNumberControlSheet, eAgentSheetFeatures);
|
||||
mNumberControlSheet, eAgentSheetFeatures);
|
||||
}
|
||||
|
||||
return gStyleCache->mNumberControlSheet;
|
||||
return mNumberControlSheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::UserContentSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
return gStyleCache->mUserContentSheet;
|
||||
return mUserContentSheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::UserChromeSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
return gStyleCache->mUserChromeSheet;
|
||||
return mUserChromeSheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::UASheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
|
||||
if (!gStyleCache->mUASheet) {
|
||||
if (!mUASheet) {
|
||||
LoadSheetURL("resource://gre-resources/ua.css",
|
||||
gStyleCache->mUASheet, eAgentSheetFeatures);
|
||||
mUASheet, eAgentSheetFeatures);
|
||||
}
|
||||
|
||||
return gStyleCache->mUASheet;
|
||||
return mUASheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::HTMLSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
return gStyleCache->mHTMLSheet;
|
||||
return mHTMLSheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::MinimalXULSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
return gStyleCache->mMinimalXULSheet;
|
||||
return mMinimalXULSheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::XULSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
return gStyleCache->mXULSheet;
|
||||
return mXULSheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::QuirkSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
return gStyleCache->mQuirkSheet;
|
||||
return mQuirkSheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::SVGSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
return gStyleCache->mSVGSheet;
|
||||
return mSVGSheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::MathMLSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
|
||||
if (!gStyleCache->mMathMLSheet) {
|
||||
if (!mMathMLSheet) {
|
||||
LoadSheetURL("resource://gre-resources/mathml.css",
|
||||
gStyleCache->mMathMLSheet, eAgentSheetFeatures);
|
||||
mMathMLSheet, eAgentSheetFeatures);
|
||||
}
|
||||
|
||||
return gStyleCache->mMathMLSheet;
|
||||
return mMathMLSheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::CounterStylesSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
|
||||
return gStyleCache->mCounterStylesSheet;
|
||||
return mCounterStylesSheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::NoScriptSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
|
||||
if (!gStyleCache->mNoScriptSheet) {
|
||||
if (!mNoScriptSheet) {
|
||||
LoadSheetURL("resource://gre-resources/noscript.css",
|
||||
gStyleCache->mNoScriptSheet, eAgentSheetFeatures);
|
||||
mNoScriptSheet, eAgentSheetFeatures);
|
||||
}
|
||||
|
||||
return gStyleCache->mNoScriptSheet;
|
||||
return mNoScriptSheet;
|
||||
}
|
||||
|
||||
CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::NoFramesSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
|
||||
if (!gStyleCache->mNoFramesSheet) {
|
||||
if (!mNoFramesSheet) {
|
||||
LoadSheetURL("resource://gre-resources/noframes.css",
|
||||
gStyleCache->mNoFramesSheet, eAgentSheetFeatures);
|
||||
mNoFramesSheet, eAgentSheetFeatures);
|
||||
}
|
||||
|
||||
return gStyleCache->mNoFramesSheet;
|
||||
return mNoFramesSheet;
|
||||
}
|
||||
|
||||
/* static */ CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::ChromePreferenceSheet(nsPresContext* aPresContext)
|
||||
{
|
||||
EnsureGlobal();
|
||||
|
||||
if (!gStyleCache->mChromePreferenceSheet) {
|
||||
gStyleCache->BuildPreferenceSheet(gStyleCache->mChromePreferenceSheet,
|
||||
aPresContext);
|
||||
if (!mChromePreferenceSheet) {
|
||||
BuildPreferenceSheet(mChromePreferenceSheet, aPresContext);
|
||||
}
|
||||
|
||||
return gStyleCache->mChromePreferenceSheet;
|
||||
return mChromePreferenceSheet;
|
||||
}
|
||||
|
||||
/* static */ CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::ContentPreferenceSheet(nsPresContext* aPresContext)
|
||||
{
|
||||
EnsureGlobal();
|
||||
|
||||
if (!gStyleCache->mContentPreferenceSheet) {
|
||||
gStyleCache->BuildPreferenceSheet(gStyleCache->mContentPreferenceSheet,
|
||||
aPresContext);
|
||||
if (!mContentPreferenceSheet) {
|
||||
BuildPreferenceSheet(mContentPreferenceSheet, aPresContext);
|
||||
}
|
||||
|
||||
return gStyleCache->mContentPreferenceSheet;
|
||||
return mContentPreferenceSheet;
|
||||
}
|
||||
|
||||
/* static */ CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::ContentEditableSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
|
||||
if (!gStyleCache->mContentEditableSheet) {
|
||||
if (!mContentEditableSheet) {
|
||||
LoadSheetURL("resource://gre/res/contenteditable.css",
|
||||
gStyleCache->mContentEditableSheet, eAgentSheetFeatures);
|
||||
mContentEditableSheet, eAgentSheetFeatures);
|
||||
}
|
||||
|
||||
return gStyleCache->mContentEditableSheet;
|
||||
return mContentEditableSheet;
|
||||
}
|
||||
|
||||
/* static */ CSSStyleSheet*
|
||||
StyleSheetHandle
|
||||
nsLayoutStylesheetCache::DesignModeSheet()
|
||||
{
|
||||
EnsureGlobal();
|
||||
|
||||
if (!gStyleCache->mDesignModeSheet) {
|
||||
if (!mDesignModeSheet) {
|
||||
LoadSheetURL("resource://gre/res/designmode.css",
|
||||
gStyleCache->mDesignModeSheet, eAgentSheetFeatures);
|
||||
mDesignModeSheet, eAgentSheetFeatures);
|
||||
}
|
||||
|
||||
return gStyleCache->mDesignModeSheet;
|
||||
return mDesignModeSheet;
|
||||
}
|
||||
|
||||
void
|
||||
nsLayoutStylesheetCache::Shutdown()
|
||||
{
|
||||
NS_IF_RELEASE(gCSSLoader);
|
||||
gStyleCache = nullptr;
|
||||
gStyleCache_Gecko = nullptr;
|
||||
gStyleCache_Servo = nullptr;
|
||||
}
|
||||
|
||||
MOZ_DEFINE_MALLOC_SIZE_OF(LayoutStylesheetCacheMallocSizeOf)
|
||||
@ -325,7 +295,8 @@ nsLayoutStylesheetCache::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf
|
||||
return n;
|
||||
}
|
||||
|
||||
nsLayoutStylesheetCache::nsLayoutStylesheetCache()
|
||||
nsLayoutStylesheetCache::nsLayoutStylesheetCache(StyleBackendType aType)
|
||||
: mBackendType(aType)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
mozilla::services::GetObserverService();
|
||||
@ -363,7 +334,6 @@ nsLayoutStylesheetCache::nsLayoutStylesheetCache()
|
||||
nsLayoutStylesheetCache::~nsLayoutStylesheetCache()
|
||||
{
|
||||
mozilla::UnregisterWeakMemoryReporter(this);
|
||||
MOZ_ASSERT(!gStyleCache);
|
||||
}
|
||||
|
||||
void
|
||||
@ -372,28 +342,38 @@ nsLayoutStylesheetCache::InitMemoryReporter()
|
||||
mozilla::RegisterWeakMemoryReporter(this);
|
||||
}
|
||||
|
||||
void
|
||||
nsLayoutStylesheetCache::EnsureGlobal()
|
||||
/* static */ nsLayoutStylesheetCache*
|
||||
nsLayoutStylesheetCache::For(StyleBackendType aType)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (gStyleCache) return;
|
||||
bool mustInit = !gStyleCache_Gecko && !gStyleCache_Servo;
|
||||
auto& cache = aType == StyleBackendType::Gecko ? gStyleCache_Gecko :
|
||||
gStyleCache_Servo;
|
||||
|
||||
gStyleCache = new nsLayoutStylesheetCache();
|
||||
if (!cache) {
|
||||
cache = new nsLayoutStylesheetCache(aType);
|
||||
cache->InitMemoryReporter();
|
||||
}
|
||||
|
||||
gStyleCache->InitMemoryReporter();
|
||||
if (mustInit) {
|
||||
// Initialization that only needs to be done once for both
|
||||
// nsLayoutStylesheetCaches.
|
||||
|
||||
Preferences::AddBoolVarCache(&sNumberControlEnabled, NUMBER_CONTROL_PREF,
|
||||
true);
|
||||
Preferences::AddBoolVarCache(&sNumberControlEnabled, NUMBER_CONTROL_PREF,
|
||||
true);
|
||||
|
||||
// For each pref that controls a CSS feature that a UA style sheet depends
|
||||
// on (such as a pref that enables a property that a UA style sheet uses),
|
||||
// register DependentPrefChanged as a callback to ensure that the relevant
|
||||
// style sheets will be re-parsed.
|
||||
// Preferences::RegisterCallback(&DependentPrefChanged,
|
||||
// "layout.css.example-pref.enabled");
|
||||
Preferences::RegisterCallback(&DependentPrefChanged,
|
||||
"layout.css.grid.enabled");
|
||||
// For each pref that controls a CSS feature that a UA style sheet depends
|
||||
// on (such as a pref that enables a property that a UA style sheet uses),
|
||||
// register DependentPrefChanged as a callback to ensure that the relevant
|
||||
// style sheets will be re-parsed.
|
||||
// Preferences::RegisterCallback(&DependentPrefChanged,
|
||||
// "layout.css.example-pref.enabled");
|
||||
Preferences::RegisterCallback(&DependentPrefChanged,
|
||||
"layout.css.grid.enabled");
|
||||
}
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
void
|
||||
@ -428,7 +408,7 @@ nsLayoutStylesheetCache::InitFromProfile()
|
||||
|
||||
/* static */ void
|
||||
nsLayoutStylesheetCache::LoadSheetURL(const char* aURL,
|
||||
RefPtr<CSSStyleSheet>& aSheet,
|
||||
StyleSheetHandle::RefPtr& aSheet,
|
||||
SheetParsingMode aParsingMode)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
@ -441,7 +421,7 @@ nsLayoutStylesheetCache::LoadSheetURL(const char* aURL,
|
||||
|
||||
void
|
||||
nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile,
|
||||
RefPtr<CSSStyleSheet>& aSheet,
|
||||
StyleSheetHandle::RefPtr& aSheet,
|
||||
SheetParsingMode aParsingMode)
|
||||
{
|
||||
bool exists = false;
|
||||
@ -747,7 +727,7 @@ ErrorLoadingBuiltinSheet(nsIURI* aURI, const char* aMsg)
|
||||
|
||||
void
|
||||
nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI,
|
||||
RefPtr<CSSStyleSheet>& aSheet,
|
||||
StyleSheetHandle::RefPtr& aSheet,
|
||||
SheetParsingMode aParsingMode)
|
||||
{
|
||||
if (!aURI) {
|
||||
@ -768,8 +748,7 @@ nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI,
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
nsZipArchive::sFileCorruptedReason = nullptr;
|
||||
#endif
|
||||
nsresult rv = gCSSLoader->LoadSheetSync(aURI, aParsingMode, true,
|
||||
getter_AddRefs(aSheet));
|
||||
nsresult rv = gCSSLoader->LoadSheetSync(aURI, aParsingMode, true, &aSheet);
|
||||
if (NS_FAILED(rv)) {
|
||||
ErrorLoadingBuiltinSheet(aURI,
|
||||
nsPrintfCString("LoadSheetSync failed with error %x", rv).get());
|
||||
@ -777,43 +756,78 @@ nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI,
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsLayoutStylesheetCache::InvalidateSheet(RefPtr<CSSStyleSheet>& aSheet)
|
||||
nsLayoutStylesheetCache::InvalidateSheet(StyleSheetHandle::RefPtr* aGeckoSheet,
|
||||
StyleSheetHandle::RefPtr* aServoSheet)
|
||||
{
|
||||
MOZ_ASSERT(gCSSLoader, "pref changed before we loaded a sheet?");
|
||||
|
||||
if (aSheet) {
|
||||
gCSSLoader->ObsoleteSheet(aSheet->GetSheetURI());
|
||||
aSheet = nullptr;
|
||||
// Make sure sheets have the expected types
|
||||
MOZ_ASSERT(!aGeckoSheet || (*aGeckoSheet)->IsGecko());
|
||||
MOZ_ASSERT(!aServoSheet || (*aServoSheet)->IsServo());
|
||||
// Make sure the URIs match
|
||||
MOZ_ASSERT(!aGeckoSheet || !aServoSheet ||
|
||||
(*aGeckoSheet)->GetSheetURI() == (*aServoSheet)->GetSheetURI(),
|
||||
"Sheets passed should have the same URI");
|
||||
|
||||
nsIURI* uri;
|
||||
if (aGeckoSheet && *aGeckoSheet) {
|
||||
uri = (*aGeckoSheet)->GetSheetURI();
|
||||
} else if (aServoSheet && *aServoSheet) {
|
||||
uri = (*aServoSheet)->GetSheetURI();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
gCSSLoader->ObsoleteSheet(uri);
|
||||
if (aGeckoSheet) {
|
||||
*aGeckoSheet = nullptr;
|
||||
}
|
||||
if (aServoSheet) {
|
||||
*aServoSheet = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsLayoutStylesheetCache::DependentPrefChanged(const char* aPref, void* aData)
|
||||
{
|
||||
MOZ_ASSERT(gStyleCache, "pref changed after shutdown?");
|
||||
MOZ_ASSERT(gStyleCache_Gecko || gStyleCache_Servo,
|
||||
"pref changed after shutdown?");
|
||||
|
||||
// Cause any UA style sheets whose parsing depends on the value of prefs
|
||||
// to be re-parsed by dropping the sheet from gCSSLoader's cache then
|
||||
// setting our cached sheet pointer to null. This will only work for sheets
|
||||
// that are loaded lazily.
|
||||
InvalidateSheet(gStyleCache->mUASheet); // for layout.css.grid.enabled
|
||||
|
||||
#define INVALIDATE(sheet_) \
|
||||
InvalidateSheet(gStyleCache_Gecko ? &gStyleCache_Gecko->sheet_ : nullptr, \
|
||||
gStyleCache_Servo ? &gStyleCache_Servo->sheet_ : nullptr);
|
||||
|
||||
INVALIDATE(mUASheet); // for layout.css.grid.enabled
|
||||
|
||||
#undef INVALIDATE
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsLayoutStylesheetCache::InvalidatePreferenceSheets()
|
||||
{
|
||||
if (!gStyleCache) {
|
||||
return;
|
||||
if (gStyleCache_Gecko) {
|
||||
gStyleCache_Gecko->mContentPreferenceSheet = nullptr;
|
||||
gStyleCache_Gecko->mChromePreferenceSheet = nullptr;
|
||||
}
|
||||
if (gStyleCache_Servo) {
|
||||
gStyleCache_Servo->mContentPreferenceSheet = nullptr;
|
||||
gStyleCache_Servo->mChromePreferenceSheet = nullptr;
|
||||
}
|
||||
|
||||
gStyleCache->mContentPreferenceSheet = nullptr;
|
||||
gStyleCache->mChromePreferenceSheet = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
nsLayoutStylesheetCache::BuildPreferenceSheet(RefPtr<CSSStyleSheet>& aSheet,
|
||||
nsLayoutStylesheetCache::BuildPreferenceSheet(StyleSheetHandle::RefPtr& aSheet,
|
||||
nsPresContext* aPresContext)
|
||||
{
|
||||
if (mBackendType == StyleBackendType::Servo) {
|
||||
MOZ_CRASH("not implemented");
|
||||
}
|
||||
|
||||
aSheet = new CSSStyleSheet(CORS_NONE, mozilla::net::RP_Default);
|
||||
aSheet->SetParsingMode(eAgentSheetFeatures);
|
||||
|
||||
@ -909,13 +923,16 @@ nsLayoutStylesheetCache::BuildPreferenceSheet(RefPtr<CSSStyleSheet>& aSheet,
|
||||
"kPreallocSize should be big enough to build preference style "
|
||||
"sheet without reallocation");
|
||||
|
||||
aSheet->ReparseSheet(sheetText);
|
||||
aSheet->AsGecko()->ReparseSheet(sheetText);
|
||||
|
||||
#undef NS_GET_R_G_B
|
||||
}
|
||||
|
||||
mozilla::StaticRefPtr<nsLayoutStylesheetCache>
|
||||
nsLayoutStylesheetCache::gStyleCache;
|
||||
nsLayoutStylesheetCache::gStyleCache_Gecko;
|
||||
|
||||
mozilla::StaticRefPtr<nsLayoutStylesheetCache>
|
||||
nsLayoutStylesheetCache::gStyleCache_Servo;
|
||||
|
||||
mozilla::css::Loader*
|
||||
nsLayoutStylesheetCache::gCSSLoader = nullptr;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/StyleBackendType.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
|
||||
class nsIFile;
|
||||
@ -30,27 +31,37 @@ class nsLayoutStylesheetCache final
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIMEMORYREPORTER
|
||||
|
||||
static mozilla::CSSStyleSheet* ScrollbarsSheet();
|
||||
static mozilla::CSSStyleSheet* FormsSheet();
|
||||
/**
|
||||
* Returns the nsLayoutStylesheetCache for the given style backend type.
|
||||
* Callers should pass in a value for aType that matches the style system
|
||||
* backend type for the style set in use. (A process may call For
|
||||
* and obtain nsLayoutStylesheetCache objects for both backend types,
|
||||
* and a particular UA style sheet might be cached in both, one or neither
|
||||
* nsLayoutStylesheetCache.)
|
||||
*/
|
||||
static nsLayoutStylesheetCache* For(mozilla::StyleBackendType aType);
|
||||
|
||||
mozilla::StyleSheetHandle ScrollbarsSheet();
|
||||
mozilla::StyleSheetHandle FormsSheet();
|
||||
// This function is expected to return nullptr when the dom.forms.number
|
||||
// pref is disabled.
|
||||
static mozilla::CSSStyleSheet* NumberControlSheet();
|
||||
static mozilla::CSSStyleSheet* UserContentSheet();
|
||||
static mozilla::CSSStyleSheet* UserChromeSheet();
|
||||
static mozilla::CSSStyleSheet* UASheet();
|
||||
static mozilla::CSSStyleSheet* HTMLSheet();
|
||||
static mozilla::CSSStyleSheet* MinimalXULSheet();
|
||||
static mozilla::CSSStyleSheet* XULSheet();
|
||||
static mozilla::CSSStyleSheet* QuirkSheet();
|
||||
static mozilla::CSSStyleSheet* SVGSheet();
|
||||
static mozilla::CSSStyleSheet* MathMLSheet();
|
||||
static mozilla::CSSStyleSheet* CounterStylesSheet();
|
||||
static mozilla::CSSStyleSheet* NoScriptSheet();
|
||||
static mozilla::CSSStyleSheet* NoFramesSheet();
|
||||
static mozilla::CSSStyleSheet* ChromePreferenceSheet(nsPresContext* aPresContext);
|
||||
static mozilla::CSSStyleSheet* ContentPreferenceSheet(nsPresContext* aPresContext);
|
||||
static mozilla::CSSStyleSheet* ContentEditableSheet();
|
||||
static mozilla::CSSStyleSheet* DesignModeSheet();
|
||||
mozilla::StyleSheetHandle NumberControlSheet();
|
||||
mozilla::StyleSheetHandle UserContentSheet();
|
||||
mozilla::StyleSheetHandle UserChromeSheet();
|
||||
mozilla::StyleSheetHandle UASheet();
|
||||
mozilla::StyleSheetHandle HTMLSheet();
|
||||
mozilla::StyleSheetHandle MinimalXULSheet();
|
||||
mozilla::StyleSheetHandle XULSheet();
|
||||
mozilla::StyleSheetHandle QuirkSheet();
|
||||
mozilla::StyleSheetHandle SVGSheet();
|
||||
mozilla::StyleSheetHandle MathMLSheet();
|
||||
mozilla::StyleSheetHandle CounterStylesSheet();
|
||||
mozilla::StyleSheetHandle NoScriptSheet();
|
||||
mozilla::StyleSheetHandle NoFramesSheet();
|
||||
mozilla::StyleSheetHandle ChromePreferenceSheet(nsPresContext* aPresContext);
|
||||
mozilla::StyleSheetHandle ContentPreferenceSheet(nsPresContext* aPresContext);
|
||||
mozilla::StyleSheetHandle ContentEditableSheet();
|
||||
mozilla::StyleSheetHandle DesignModeSheet();
|
||||
|
||||
static void InvalidatePreferenceSheets();
|
||||
|
||||
@ -59,46 +70,48 @@ class nsLayoutStylesheetCache final
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
|
||||
private:
|
||||
nsLayoutStylesheetCache();
|
||||
explicit nsLayoutStylesheetCache(mozilla::StyleBackendType aImpl);
|
||||
~nsLayoutStylesheetCache();
|
||||
|
||||
static void EnsureGlobal();
|
||||
void InitFromProfile();
|
||||
void InitMemoryReporter();
|
||||
static void LoadSheetURL(const char* aURL,
|
||||
RefPtr<mozilla::CSSStyleSheet>& aSheet,
|
||||
mozilla::StyleSheetHandle::RefPtr& aSheet,
|
||||
mozilla::css::SheetParsingMode aParsingMode);
|
||||
static void LoadSheetFile(nsIFile* aFile,
|
||||
RefPtr<mozilla::CSSStyleSheet>& aSheet,
|
||||
mozilla::StyleSheetHandle::RefPtr& aSheet,
|
||||
mozilla::css::SheetParsingMode aParsingMode);
|
||||
static void LoadSheet(nsIURI* aURI, RefPtr<mozilla::CSSStyleSheet>& aSheet,
|
||||
static void LoadSheet(nsIURI* aURI, mozilla::StyleSheetHandle::RefPtr& aSheet,
|
||||
mozilla::css::SheetParsingMode aParsingMode);
|
||||
static void InvalidateSheet(RefPtr<mozilla::CSSStyleSheet>& aSheet);
|
||||
static void InvalidateSheet(mozilla::StyleSheetHandle::RefPtr* aGeckoSheet,
|
||||
mozilla::StyleSheetHandle::RefPtr* aServoSheet);
|
||||
static void DependentPrefChanged(const char* aPref, void* aData);
|
||||
void BuildPreferenceSheet(RefPtr<mozilla::CSSStyleSheet>& aSheet,
|
||||
void BuildPreferenceSheet(mozilla::StyleSheetHandle::RefPtr& aSheet,
|
||||
nsPresContext* aPresContext);
|
||||
|
||||
static mozilla::StaticRefPtr<nsLayoutStylesheetCache> gStyleCache;
|
||||
static mozilla::StaticRefPtr<nsLayoutStylesheetCache> gStyleCache_Gecko;
|
||||
static mozilla::StaticRefPtr<nsLayoutStylesheetCache> gStyleCache_Servo;
|
||||
static mozilla::css::Loader* gCSSLoader;
|
||||
RefPtr<mozilla::CSSStyleSheet> mChromePreferenceSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mContentEditableSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mContentPreferenceSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mCounterStylesSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mDesignModeSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mFormsSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mHTMLSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mMathMLSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mMinimalXULSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mNoFramesSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mNoScriptSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mNumberControlSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mQuirkSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mSVGSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mScrollbarsSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mUASheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mUserChromeSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mUserContentSheet;
|
||||
RefPtr<mozilla::CSSStyleSheet> mXULSheet;
|
||||
mozilla::StyleBackendType mBackendType;
|
||||
mozilla::StyleSheetHandle::RefPtr mChromePreferenceSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mContentEditableSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mContentPreferenceSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mCounterStylesSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mDesignModeSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mFormsSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mHTMLSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mMathMLSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mMinimalXULSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mNoFramesSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mNoScriptSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mNumberControlSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mQuirkSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mSVGSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mScrollbarsSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mUASheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mUserChromeSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mUserContentSheet;
|
||||
mozilla::StyleSheetHandle::RefPtr mXULSheet;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "nsDeviceContext.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/StyleSheetHandle.h"
|
||||
#include "mozilla/StyleSheetHandleInlines.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -745,11 +745,15 @@ nsStyleSet::AddDocStyleSheet(CSSStyleSheet* aSheet, nsIDocument* aDocument)
|
||||
if (sheetDocIndex < 0) {
|
||||
if (sheetService) {
|
||||
auto& authorSheets = *sheetService->AuthorStyleSheets();
|
||||
if (authorSheets.IndexOf(sheet) != authorSheets.NoIndex) {
|
||||
StyleSheetHandle handle = sheet;
|
||||
if (authorSheets.IndexOf(handle) != authorSheets.NoIndex) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sheet == aDocument->FirstAdditionalAuthorSheet()) {
|
||||
MOZ_ASSERT(!aDocument->FirstAdditionalAuthorSheet() ||
|
||||
aDocument->FirstAdditionalAuthorSheet()->IsGecko(),
|
||||
"why do we have a ServoStyleSheet for an nsStyleSet?");
|
||||
if (sheet == aDocument->FirstAdditionalAuthorSheet()->GetAsGecko()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -764,6 +768,23 @@ nsStyleSet::AddDocStyleSheet(CSSStyleSheet* aSheet, nsIDocument* aDocument)
|
||||
return DirtyRuleProcessors(type);
|
||||
}
|
||||
|
||||
void
|
||||
nsStyleSet::AppendAllXBLStyleSheets(nsTArray<mozilla::CSSStyleSheet*>& aArray) const
|
||||
{
|
||||
if (mBindingManager) {
|
||||
// XXXheycam stylo: AppendAllSheets will need to be able to return either
|
||||
// CSSStyleSheets or ServoStyleSheets, on request (and then here requesting
|
||||
// CSSStyleSheets).
|
||||
AutoTArray<StyleSheetHandle, 32> sheets;
|
||||
mBindingManager->AppendAllSheets(sheets);
|
||||
for (StyleSheetHandle handle : sheets) {
|
||||
MOZ_ASSERT(handle->IsGecko(), "stylo: AppendAllSheets shouldn't give us "
|
||||
"ServoStyleSheets yet");
|
||||
aArray.AppendElement(handle->AsGecko());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsStyleSet::RemoveDocStyleSheet(CSSStyleSheet* aSheet)
|
||||
{
|
||||
@ -2497,7 +2518,16 @@ nsStyleSet::EnsureUniqueInnerOnCSSSheets()
|
||||
}
|
||||
|
||||
if (mBindingManager) {
|
||||
mBindingManager->AppendAllSheets(queue);
|
||||
AutoTArray<StyleSheetHandle, 32> sheets;
|
||||
// XXXheycam stylo: AppendAllSheets will need to be able to return either
|
||||
// CSSStyleSheets or ServoStyleSheets, on request (and then here requesting
|
||||
// CSSStyleSheets).
|
||||
mBindingManager->AppendAllSheets(sheets);
|
||||
for (StyleSheetHandle sheet : sheets) {
|
||||
MOZ_ASSERT(sheet->IsGecko(), "stylo: AppendAllSheets shouldn't give us "
|
||||
"ServoStyleSheets yet");
|
||||
queue.AppendElement(sheet->AsGecko());
|
||||
}
|
||||
}
|
||||
|
||||
while (!queue.IsEmpty()) {
|
||||
|
@ -338,11 +338,7 @@ class nsStyleSet final
|
||||
return mSheets[aType][aIndex];
|
||||
}
|
||||
|
||||
void AppendAllXBLStyleSheets(nsTArray<mozilla::CSSStyleSheet*>& aArray) const {
|
||||
if (mBindingManager) {
|
||||
mBindingManager->AppendAllSheets(aArray);
|
||||
}
|
||||
}
|
||||
void AppendAllXBLStyleSheets(nsTArray<mozilla::CSSStyleSheet*>& aArray) const;
|
||||
|
||||
nsresult RemoveDocStyleSheet(mozilla::CSSStyleSheet* aSheet);
|
||||
nsresult AddDocStyleSheet(mozilla::CSSStyleSheet* aSheet,
|
||||
|
Loading…
Reference in New Issue
Block a user