1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 13:58:49 +00:00

Issue #2488 - Part 6: Define and declare CSSStyleSheet cast functions directly in StyleSheet

This renames AsGecko calls to AsConcrete and removes the header containing leftover Stylo macros.
This commit is contained in:
FranklinDM
2024-03-29 16:30:12 +08:00
committed by roytam1
parent 81f77f18a0
commit f0116f51db
18 changed files with 109 additions and 134 deletions
+1 -1
View File
@@ -110,7 +110,7 @@ ShadowRoot::CloneInternalDataFrom(ShadowRoot* aOther)
StyleSheet* sheet = aOther->SheetAt(i);
if (sheet && sheet->IsApplicable()) {
RefPtr<CSSStyleSheet> clonedSheet =
sheet->AsGecko()->Clone(nullptr, nullptr, nullptr, nullptr);
sheet->AsConcrete()->Clone(nullptr, nullptr, nullptr, nullptr);
if (clonedSheet) {
AppendStyleSheet(*clonedSheet);
}
+19 -19
View File
@@ -1150,7 +1150,7 @@ nsDOMStyleSheetSetList::EnsureFresh()
for (size_t index = 0; index < count; index++) {
StyleSheet* sheet = mDocument->SheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
sheet->AsGecko()->GetTitle(title);
sheet->AsConcrete()->GetTitle(title);
if (!title.IsEmpty() && !mNames.Contains(title) && !Add(title)) {
return;
}
@@ -2071,7 +2071,7 @@ nsDocument::RemoveDocStyleSheetsFromStyleSets()
if (sheet->IsApplicable()) {
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
shell->StyleSet()->RemoveDocStyleSheet(sheet->AsGecko());
shell->StyleSet()->RemoveDocStyleSheet(sheet->AsConcrete());
}
}
// XXX Tell observers?
@@ -2090,7 +2090,7 @@ nsDocument::RemoveStyleSheetsFromStyleSets(
if (sheet->IsApplicable()) {
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
shell->StyleSet()->RemoveStyleSheet(aType, sheet->AsGecko());
shell->StyleSet()->RemoveStyleSheet(aType, sheet->AsConcrete());
}
}
// XXX Tell observers?
@@ -2161,7 +2161,7 @@ AppendSheetsToStyleSet(nsStyleSet* aStyleSet,
SheetType aType)
{
for (StyleSheet* sheet : Reversed(aSheets)) {
aStyleSet->AppendStyleSheet(aType, sheet->AsGecko());
aStyleSet->AppendStyleSheet(aType, sheet->AsConcrete());
}
}
@@ -2177,21 +2177,21 @@ nsDocument::FillStyleSet(nsStyleSet* aStyleSet)
for (StyleSheet* sheet : Reversed(mStyleSheets)) {
if (sheet->IsApplicable()) {
aStyleSet->AddDocStyleSheet(sheet->AsGecko(), this);
aStyleSet->AddDocStyleSheet(sheet->AsConcrete(), this);
}
}
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
for (StyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
aStyleSet->AppendStyleSheet(SheetType::Doc, sheet->AsGecko());
aStyleSet->AppendStyleSheet(SheetType::Doc, sheet->AsConcrete());
}
}
// Iterate backwards to maintain order
for (StyleSheet* sheet : Reversed(mOnDemandBuiltInUASheets)) {
if (sheet->IsApplicable()) {
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet->AsGecko());
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet->AsConcrete());
}
}
@@ -3807,7 +3807,7 @@ nsDocument::AddOnDemandBuiltInUASheet(StyleSheet* aSheet)
// do not override Firefox OS/Mobile's content.css sheet. Maybe we should
// have an insertion point to match the order of
// nsDocumentViewer::CreateStyleSet though?
shell->StyleSet()->PrependStyleSheet(SheetType::Agent, aSheet->AsGecko());
shell->StyleSet()->PrependStyleSheet(SheetType::Agent, aSheet->AsConcrete());
}
}
@@ -3819,7 +3819,7 @@ nsDocument::AddStyleSheetToStyleSets(StyleSheet* aSheet)
{
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
shell->StyleSet()->AddDocStyleSheet(aSheet->AsGecko(), this);
shell->StyleSet()->AddDocStyleSheet(aSheet->AsConcrete(), this);
}
}
@@ -3828,7 +3828,7 @@ nsDocument::AddStyleSheetToStyleSets(StyleSheet* aSheet)
className##Init init; \
init.mBubbles = true; \
init.mCancelable = true; \
init.mStylesheet = aSheet->AsGecko(); \
init.mStylesheet = aSheet->AsConcrete(); \
init.memberName = argName; \
\
RefPtr<className> event = \
@@ -3886,7 +3886,7 @@ nsDocument::RemoveStyleSheetFromStyleSets(StyleSheet* aSheet)
{
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
shell->StyleSet()->RemoveDocStyleSheet(aSheet->AsGecko());
shell->StyleSet()->RemoveDocStyleSheet(aSheet->AsConcrete());
}
}
@@ -4102,7 +4102,7 @@ nsDocument::AddAdditionalStyleSheet(additionalSheetType aType, StyleSheet* aShee
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
SheetType type = ConvertAdditionalSheetType(aType);
shell->StyleSet()->AppendStyleSheet(type, aSheet->AsGecko());
shell->StyleSet()->AppendStyleSheet(type, aSheet->AsConcrete());
}
// Passing false, so documet.styleSheets.length will not be affected by
@@ -4130,7 +4130,7 @@ nsDocument::RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheet
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
SheetType type = ConvertAdditionalSheetType(aType);
shell->StyleSet()->RemoveStyleSheet(type, sheetRef->AsGecko());
shell->StyleSet()->RemoveStyleSheet(type, sheetRef->AsConcrete());
}
}
@@ -5598,13 +5598,13 @@ nsIDocument::GetSelectedStyleSheetSet(nsAString& aSheetSet)
NS_ASSERTION(sheet, "Null sheet in sheet list!");
bool disabled;
sheet->AsGecko()->GetDisabled(&disabled);
sheet->AsConcrete()->GetDisabled(&disabled);
if (disabled) {
// Disabled sheets don't affect the currently selected set
continue;
}
sheet->AsGecko()->GetTitle(title);
sheet->AsConcrete()->GetTitle(title);
if (aSheetSet.IsEmpty()) {
aSheetSet = title;
@@ -5711,9 +5711,9 @@ nsDocument::EnableStyleSheetsForSetInternal(const nsAString& aSheetSet,
StyleSheet* sheet = SheetAt(index);
NS_ASSERTION(sheet, "Null sheet in sheet list!");
sheet->AsGecko()->GetTitle(title);
sheet->AsConcrete()->GetTitle(title);
if (!title.IsEmpty()) {
sheet->AsGecko()->SetEnabled(title.Equals(aSheetSet));
sheet->AsConcrete()->SetEnabled(title.Equals(aSheetSet));
}
}
if (aUpdateCSSLoader) {
@@ -9434,7 +9434,7 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
if (sheet) {
if (sheet->IsApplicable()) {
RefPtr<CSSStyleSheet> clonedSheet =
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
sheet->AsConcrete()->Clone(nullptr, nullptr, clonedDoc, nullptr);
NS_WARNING_ASSERTION(clonedSheet,
"Cloning a stylesheet didn't work!");
if (clonedSheet) {
@@ -9449,7 +9449,7 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
if (sheet) {
if (sheet->IsApplicable()) {
RefPtr<CSSStyleSheet> clonedSheet =
sheet->AsGecko()->Clone(nullptr, nullptr, clonedDoc, nullptr);
sheet->AsConcrete()->Clone(nullptr, nullptr, clonedDoc, nullptr);
NS_WARNING_ASSERTION(clonedSheet,
"Cloning a stylesheet didn't work!");
if (clonedSheet) {
+2 -2
View File
@@ -321,7 +321,7 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
Element* oldScopeElement = nullptr;
if (mStyleSheet) {
oldScopeElement = mStyleSheet->AsGecko()->GetScopeElement();
oldScopeElement = mStyleSheet->AsConcrete()->GetScopeElement();
}
if (mStyleSheet && (aOldDocument || aOldShadowRoot)) {
@@ -483,7 +483,7 @@ nsStyleLinkElement::UpdateStyleSheetScopedness(bool aIsNowScoped)
return;
}
CSSStyleSheet* sheet = mStyleSheet->AsGecko();
CSSStyleSheet* sheet = mStyleSheet->AsConcrete();
nsCOMPtr<nsIContent> thisContent;
CallQueryInterface(this, getter_AddRefs(thisContent));
+1 -1
View File
@@ -147,7 +147,7 @@ nsXBLPrototypeResources::GatherRuleProcessor()
{
nsTArray<RefPtr<CSSStyleSheet>> sheets(mStyleSheetList.Length());
for (StyleSheet* sheet : mStyleSheetList) {
sheets.AppendElement(sheet->AsGecko());
sheets.AppendElement(sheet->AsConcrete());
}
mRuleProcessor = new nsCSSRuleProcessor(Move(sheets),
SheetType::Doc,
+2 -2
View File
@@ -2907,7 +2907,7 @@ HTMLEditor::EnableStyleSheet(const nsAString& aURL,
nsCOMPtr<nsIDocument> document = GetDocument();
sheet->SetAssociatedDocument(document, StyleSheet::NotOwnedByDocument);
return sheet->AsGecko()->SetDisabled(!aEnable);
return sheet->AsConcrete()->SetDisabled(!aEnable);
}
bool
@@ -2924,7 +2924,7 @@ HTMLEditor::EnableExistingStyleSheet(const nsAString& aURL)
nsCOMPtr<nsIDocument> document = GetDocument();
sheet->SetAssociatedDocument(document, StyleSheet::NotOwnedByDocument);
sheet->AsGecko()->SetDisabled(false);
sheet->AsConcrete()->SetDisabled(false);
return true;
}
+15 -15
View File
@@ -2306,7 +2306,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument)
}
if (sheet)
styleSet->AppendStyleSheet(SheetType::User, sheet->AsGecko());
styleSet->AppendStyleSheet(SheetType::User, sheet->AsConcrete());
// Append chrome sheets (scrollbars + forms).
bool shouldOverride = false;
@@ -2342,7 +2342,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument)
cssLoader->LoadSheetSync(uri, &chromeSheet);
if (!chromeSheet) continue;
styleSet->PrependStyleSheet(SheetType::Agent, chromeSheet->AsGecko());
styleSet->PrependStyleSheet(SheetType::Agent, chromeSheet->AsConcrete());
shouldOverride = true;
}
free(str);
@@ -2353,7 +2353,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument)
if (!shouldOverride) {
sheet = cache->ScrollbarsSheet();
if (sheet) {
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsGecko());
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsConcrete());
}
}
@@ -2369,12 +2369,12 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument)
sheet = cache->NumberControlSheet();
if (sheet) {
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsGecko());
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsConcrete());
}
sheet = cache->FormsSheet();
if (sheet) {
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsGecko());
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsConcrete());
}
if (aDocument->LoadsFullXULStyleSheetUpFront()) {
@@ -2382,7 +2382,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument)
// up-front here.
sheet = cache->XULSheet();
if (sheet) {
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsGecko());
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsConcrete());
}
}
@@ -2390,25 +2390,25 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument)
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->AsGecko());
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsConcrete());
}
sheet = cache->CounterStylesSheet();
if (sheet) {
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsGecko());
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsConcrete());
}
if (nsLayoutUtils::ShouldUseNoScriptSheet(aDocument)) {
sheet = cache->NoScriptSheet();
if (sheet) {
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsGecko());
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsConcrete());
}
}
if (nsLayoutUtils::ShouldUseNoFramesSheet(aDocument)) {
sheet = cache->NoFramesSheet();
if (sheet) {
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsGecko());
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsConcrete());
}
}
@@ -2417,26 +2417,26 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument)
sheet = cache->HTMLSheet();
if (sheet) {
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsGecko());
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsConcrete());
}
styleSet->PrependStyleSheet(SheetType::Agent,
cache->UASheet()->AsGecko());
cache->UASheet()->AsConcrete());
} else {
// SVG documents may have scrollbars and need the scrollbar styling.
sheet = cache->MinimalXULSheet();
if (sheet) {
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsGecko());
styleSet->PrependStyleSheet(SheetType::Agent, sheet->AsConcrete());
}
}
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
for (StyleSheet* sheet : *sheetService->AgentStyleSheets()) {
styleSet->AppendStyleSheet(SheetType::Agent, sheet->AsGecko());
styleSet->AppendStyleSheet(SheetType::Agent, sheet->AsConcrete());
}
for (StyleSheet* sheet : Reversed(*sheetService->UserStyleSheets())) {
styleSet->PrependStyleSheet(SheetType::User, sheet->AsGecko());
styleSet->PrependStyleSheet(SheetType::User, sheet->AsConcrete());
}
}
+2 -2
View File
@@ -1146,11 +1146,11 @@ nsPresContext::CompatibilityModeChanged()
if (needsQuirkSheet) {
// quirk.css needs to come after html.css; we just keep it at the end.
DebugOnly<nsresult> rv =
styleSet->AppendStyleSheet(SheetType::Agent, sheet->AsGecko());
styleSet->AppendStyleSheet(SheetType::Agent, sheet->AsConcrete());
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "failed to insert quirk.css");
} else {
DebugOnly<nsresult> rv =
styleSet->RemoveStyleSheet(SheetType::Agent, sheet->AsGecko());
styleSet->RemoveStyleSheet(SheetType::Agent, sheet->AsConcrete());
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "failed to remove quirk.css");
}
+12 -12
View File
@@ -1397,7 +1397,7 @@ PresShell::UpdatePreferenceStyles()
RemovePreferenceStyles();
mStyleSet->AppendStyleSheet(SheetType::User, newPrefSheet->AsGecko());
mStyleSet->AppendStyleSheet(SheetType::User, newPrefSheet->AsConcrete());
mPrefStyleSheet = newPrefSheet;
mStyleSet->EndUpdate();
@@ -1407,7 +1407,7 @@ void
PresShell::RemovePreferenceStyles()
{
if (mPrefStyleSheet) {
mStyleSet->RemoveStyleSheet(SheetType::User, mPrefStyleSheet->AsGecko());
mStyleSet->RemoveStyleSheet(SheetType::User, mPrefStyleSheet->AsConcrete());
mPrefStyleSheet = nullptr;
}
}
@@ -1430,13 +1430,13 @@ PresShell::AddUserSheet(nsISupports* aSheet)
// Iterate forwards when removing so the searches for RemoveStyleSheet are as
// short as possible.
for (StyleSheet* sheet : userSheets) {
mStyleSet->RemoveStyleSheet(SheetType::User, sheet->AsGecko());
mStyleSet->RemoveStyleSheet(SheetType::User, sheet->AsConcrete());
}
// 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 (StyleSheet* sheet : Reversed(userSheets)) {
mStyleSet->PrependStyleSheet(SheetType::User, sheet->AsGecko());
mStyleSet->PrependStyleSheet(SheetType::User, sheet->AsConcrete());
}
mStyleSet->EndUpdate();
@@ -1454,7 +1454,7 @@ PresShell::AddAgentSheet(nsISupports* aSheet)
return;
}
mStyleSet->AppendStyleSheet(SheetType::Agent, sheet->AsGecko());
mStyleSet->AppendStyleSheet(SheetType::Agent, sheet->AsConcrete());
RestyleForCSSRuleChanges();
}
@@ -1471,9 +1471,9 @@ PresShell::AddAuthorSheet(nsISupports* aSheet)
StyleSheet* firstAuthorSheet =
mDocument->GetFirstAdditionalAuthorSheet();
if (firstAuthorSheet) {
mStyleSet->InsertStyleSheetBefore(SheetType::Doc, sheet->AsGecko(), firstAuthorSheet->AsGecko());
mStyleSet->InsertStyleSheetBefore(SheetType::Doc, sheet->AsConcrete(), firstAuthorSheet->AsConcrete());
} else {
mStyleSet->AppendStyleSheet(SheetType::Doc, sheet->AsGecko());
mStyleSet->AppendStyleSheet(SheetType::Doc, sheet->AsConcrete());
}
RestyleForCSSRuleChanges();
@@ -1487,7 +1487,7 @@ PresShell::RemoveSheet(SheetType aType, nsISupports* aSheet)
return;
}
mStyleSet->RemoveStyleSheet(aType, sheet->AsGecko());
mStyleSet->RemoveStyleSheet(aType, sheet->AsConcrete());
RestyleForCSSRuleChanges();
}
@@ -4471,7 +4471,7 @@ PresShell::RecordStyleSheetChange(StyleSheet* aStyleSheet)
if (mStylesHaveChanged)
return;
Element* scopeElement = aStyleSheet->AsGecko()->GetScopeElement();
Element* scopeElement = aStyleSheet->AsConcrete()->GetScopeElement();
if (scopeElement) {
mChangedScopeStyleRoots.AppendElement(scopeElement);
return;
@@ -8771,7 +8771,7 @@ PresShell::SetAgentStyleSheets(const nsTArray<RefPtr<StyleSheet>>& aSheets)
{
nsTArray<RefPtr<CSSStyleSheet>> newSheets(aSheets.Length());
for (auto& sheet : aSheets) {
newSheets.AppendElement(sheet->AsGecko());
newSheets.AppendElement(sheet->AsConcrete());
}
return mStyleSet->ReplaceSheets(SheetType::Agent, newSheets);
}
@@ -8779,13 +8779,13 @@ PresShell::SetAgentStyleSheets(const nsTArray<RefPtr<StyleSheet>>& aSheets)
nsresult
PresShell::AddOverrideStyleSheet(StyleSheet* aSheet)
{
return mStyleSet->PrependStyleSheet(SheetType::Override, aSheet->AsGecko());
return mStyleSet->PrependStyleSheet(SheetType::Override, aSheet->AsConcrete());
}
nsresult
PresShell::RemoveOverrideStyleSheet(StyleSheet* aSheet)
{
return mStyleSet->RemoveStyleSheet(SheetType::Override, aSheet->AsGecko());
return mStyleSet->RemoveStyleSheet(SheetType::Override, aSheet->AsConcrete());
}
static void
+3 -3
View File
@@ -177,7 +177,7 @@ nsStyleSheetService::LoadAndRegisterSheet(nsIURI *aSheetURI,
// mSheets[aSheetType]
StyleSheet* sheet = mSheets[aSheetType].LastElement();
CSSStyleSheet* cssSheet = sheet->AsGecko();
CSSStyleSheet* cssSheet = sheet->AsConcrete();
serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, cssSheet),
message, nullptr);
}
@@ -283,7 +283,7 @@ nsStyleSheetService::PreloadSheet(nsIURI *aSheetURI, uint32_t aSheetType,
nsresult rv = loader->LoadSheetSync(aSheetURI, parsingMode, true, &sheet);
NS_ENSURE_SUCCESS(rv, rv);
RefPtr<CSSStyleSheet> cssSheet = sheet->AsGecko();
RefPtr<CSSStyleSheet> cssSheet = sheet->AsConcrete();
cssSheet.forget(aSheet);
return NS_OK;
@@ -317,7 +317,7 @@ nsStyleSheetService::UnregisterSheet(nsIURI *aSheetURI, uint32_t aSheetType)
nsCOMPtr<nsIObserverService> serv = services::GetObserverService();
if (serv) {
CSSStyleSheet* cssSheet = sheet->AsGecko();
CSSStyleSheet* cssSheet = sheet->AsConcrete();
serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, cssSheet),
message, nullptr);
}
+1 -1
View File
@@ -1929,7 +1929,7 @@ CSSStyleSheet::StyleSheetLoaded(StyleSheet* aSheet,
bool aWasAlternate,
nsresult aStatus)
{
CSSStyleSheet* sheet = aSheet->AsGecko();
CSSStyleSheet* sheet = aSheet->AsConcrete();
if (sheet->GetParentSheet() == nullptr) {
return NS_OK; // ignore if sheet has been detached already (see parseSheet)
-33
View File
@@ -1,33 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* some deprecated utilities */
#ifndef mozilla_DeprecatedUtils_h
#define mozilla_DeprecatedUtils_h
#include "mozilla/TypeTraits.h"
/**
* Macro used in a base class of |geckotype_|.
*/
#define MOZ_DECL_DEPRECATED_METHODS(geckotype_) \
inline geckotype_* AsGecko(); \
inline const geckotype_* AsGecko() const;
/**
* Macro used in inline header of class |type_| with its Gecko
* subclass named |geckotype_| for implementing the inline methods
* defined by MOZ_DECL_DEPRECATED_METHODS.
*/
#define MOZ_DEFINE_DEPRECATED_METHODS(type_, geckotype_) \
geckotype_* type_::AsGecko() { \
return static_cast<geckotype_*>(this); \
} \
const geckotype_* type_::AsGecko() const { \
return static_cast<const geckotype_*>(this); \
}
#endif // mozilla_DeprecatedUtils_h
+18 -18
View File
@@ -1130,11 +1130,11 @@ Loader::CreateSheet(nsIURI* aURI,
if (sheet) {
// This sheet came from the XUL cache or our per-document hashtable; it
// better be a complete sheet.
NS_ASSERTION(sheet->AsGecko()->IsComplete(),
NS_ASSERTION(sheet->AsConcrete()->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->AsGecko()->IsModified()) {
if (sheet->AsConcrete()->IsModified()) {
LOG((" Not cloning completed sheet %p because it's been modified",
sheet.get()));
sheet = nullptr;
@@ -1187,25 +1187,25 @@ Loader::CreateSheet(nsIURI* aURI,
if (sheet) {
// The sheet we have now should be either incomplete or unmodified
NS_ASSERTION(!sheet->AsGecko()->IsModified() ||
!sheet->AsGecko()->IsComplete(),
NS_ASSERTION(!sheet->AsConcrete()->IsModified() ||
!sheet->AsConcrete()->IsComplete(),
"Unexpected modified complete sheet");
NS_ASSERTION(sheet->AsGecko()->IsComplete() ||
NS_ASSERTION(sheet->AsConcrete()->IsComplete() ||
aSheetState != eSheetComplete,
"Sheet thinks it's not complete while we think it is");
RefPtr<CSSStyleSheet> clonedSheet =
sheet->AsGecko()->Clone(nullptr, nullptr, nullptr, nullptr);
sheet->AsConcrete()->Clone(nullptr, nullptr, nullptr, nullptr);
*aSheet = Move(clonedSheet);
if (*aSheet && fromCompleteSheets &&
!sheet->AsGecko()->GetOwnerNode() &&
!sheet->AsGecko()->GetParentSheet()) {
!sheet->AsConcrete()->GetOwnerNode() &&
!sheet->AsConcrete()->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)->AsGecko()->IsComplete(),
NS_ASSERTION((*aSheet)->AsConcrete()->IsComplete(),
"Should only be caching complete sheets");
mSheets->mCompleteSheets.Put(&key, *aSheet);
}
@@ -1270,7 +1270,7 @@ Loader::PrepareSheet(StyleSheet* aSheet,
{
NS_PRECONDITION(aSheet, "Must have a sheet!");
CSSStyleSheet* sheet = aSheet->AsGecko();
CSSStyleSheet* sheet = aSheet->AsConcrete();
RefPtr<nsMediaList> mediaList(aMediaList);
@@ -1397,10 +1397,10 @@ Loader::InsertChildSheet(StyleSheet* aSheet,
// child sheets should always start out enabled, even if they got
// cloned off of top-level sheets which were disabled
aSheet->AsGecko()->SetEnabled(true);
aSheet->AsConcrete()->SetEnabled(true);
aParentSheet->AppendStyleSheet(aSheet);
aParentRule->SetSheet(aSheet->AsGecko()); // This sets the ownerRule on the sheet
aParentRule->SetSheet(aSheet->AsConcrete()); // This sets the ownerRule on the sheet
LOG((" Inserting into parent sheet"));
// LOG((" Inserting into parent sheet at position %d", insertionPoint));
@@ -1741,7 +1741,7 @@ Loader::ParseSheet(const nsAString& aInput,
nsresult rv;
nsCSSParser parser(this, aLoadData->mSheet->AsGecko());
nsCSSParser parser(this, aLoadData->mSheet->AsConcrete());
rv = parser.ParseSheet(aInput, sheetURI, baseURI,
aLoadData->mSheet->Principal(),
aLoadData->mLineNumber);
@@ -1857,7 +1857,7 @@ 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->AsGecko()->IsModified(),
MOZ_ASSERT(!data->mSheet->AsConcrete()->IsModified(),
"should not get marked modified during parsing");
data->mSheet->SetComplete();
data->ScheduleLoadEventIfNeeded(aStatus);
@@ -1899,10 +1899,10 @@ Loader::DoSheetComplete(SheetLoadData* aLoadData, nsresult aStatus,
// 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->AsGecko();
CSSStyleSheet* sheet = aLoadData->mSheet->AsConcrete();
while (data) {
if (data->mSheet->GetParentSheet() || data->mSheet->GetOwnerNode()) {
sheet = data->mSheet->AsGecko();
sheet = data->mSheet->AsConcrete();
break;
}
data = data->mNext;
@@ -2216,7 +2216,7 @@ Loader::LoadChildSheet(StyleSheet* 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->AsGecko();
observer = aParentSheet->AsConcrete();
}
// Now that we know it's safe to load this (passes security check and not a
@@ -2583,7 +2583,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Loader)
!iter.Done();
iter.Next()) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "Sheet cache nsCSSLoader");
CSSStyleSheet* sheet = iter.UserData()->AsGecko();
CSSStyleSheet* sheet = iter.UserData()->AsConcrete();
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, sheet));
}
}
+6 -6
View File
@@ -79,7 +79,7 @@ StyleSheet::IsComplete() const
void
StyleSheet::SetComplete()
{
NS_ASSERTION(!AsGecko()->mDirty,
NS_ASSERTION(!AsConcrete()->mDirty,
"Can't set a dirty sheet complete!");
SheetInfo().mComplete = true;
if (mDocument && !mDisabled) {
@@ -135,7 +135,7 @@ StyleSheet::SetDisabled(bool aDisabled)
{
// DOM method, so handle BeginUpdate/EndUpdate
MOZ_AUTO_DOC_UPDATE(mDocument, UPDATE_STYLE, true);
AsGecko()->SetEnabled(!aDisabled);
AsConcrete()->SetEnabled(!aDisabled);
return NS_OK;
}
@@ -229,7 +229,7 @@ StyleSheet::GetCssRules(nsIPrincipal& aSubjectPrincipal,
if (!AreRulesAvailable(aSubjectPrincipal, aRv)) {
return nullptr;
}
return AsGecko()->GetCssRulesInternal(aRv);
return AsConcrete()->GetCssRulesInternal(aRv);
}
uint32_t
@@ -240,7 +240,7 @@ StyleSheet::InsertRule(const nsAString& aRule, uint32_t aIndex,
if (!AreRulesAvailable(aSubjectPrincipal, aRv)) {
return 0;
}
return AsGecko()->InsertRuleInternal(aRule, aIndex, aRv);
return AsConcrete()->InsertRuleInternal(aRule, aIndex, aRv);
}
void
@@ -251,7 +251,7 @@ StyleSheet::DeleteRule(uint32_t aIndex,
if (!AreRulesAvailable(aSubjectPrincipal, aRv)) {
return;
}
AsGecko()->DeleteRuleInternal(aIndex, aRv);
AsConcrete()->DeleteRuleInternal(aIndex, aRv);
}
int32_t
@@ -275,7 +275,7 @@ StyleSheet::AddRule(const nsAString& aSelector, const nsAString& aBlock,
auto index =
aIndex.WasPassed() ? aIndex.Value() : GetCssRules(aSubjectPrincipal, aRv)->Length();
return AsGecko()->InsertRuleInternal(rule, index, aRv);
return AsConcrete()->InsertRuleInternal(rule, index, aRv);
// As per Microsoft documentation, always return -1.
return -1;
}
+2 -2
View File
@@ -10,7 +10,6 @@
#include "mozilla/dom/CSSStyleSheetBinding.h"
#include "mozilla/net/ReferrerPolicy.h"
#include "mozilla/CORSMode.h"
#include "mozilla/DeprecatedUtils.h"
#include "nsIDOMCSSStyleSheet.h"
#include "nsWrapperCache.h"
@@ -64,7 +63,8 @@ public:
bool IsComplete() const;
void SetComplete();
MOZ_DECL_DEPRECATED_METHODS(CSSStyleSheet)
inline CSSStyleSheet* AsConcrete();
inline const CSSStyleSheet* AsConcrete() const;
// Whether the sheet is for an inline <style> element.
inline bool IsInline() const;
+22 -12
View File
@@ -11,18 +11,28 @@
namespace mozilla {
MOZ_DEFINE_DEPRECATED_METHODS(StyleSheet, CSSStyleSheet)
CSSStyleSheet*
StyleSheet::AsConcrete()
{
return static_cast<CSSStyleSheet*>(this);
}
const CSSStyleSheet*
StyleSheet::AsConcrete() const
{
return static_cast<const CSSStyleSheet*>(this);
}
StyleSheetInfo&
StyleSheet::SheetInfo()
{
return *AsGecko()->mInner;
return *AsConcrete()->mInner;
}
const StyleSheetInfo&
StyleSheet::SheetInfo() const
{
return *AsGecko()->mInner;
return *AsConcrete()->mInner;
}
bool
@@ -71,7 +81,7 @@ StyleSheet::IsApplicable() const
bool
StyleSheet::HasRules() const
{
return AsGecko()->HasRules();
return AsConcrete()->HasRules();
}
void
@@ -79,19 +89,19 @@ StyleSheet::SetAssociatedDocument(nsIDocument* aDocument,
DocumentAssociationMode aAssociationMode)
{
MOZ_ASSERT(aDocument);
AsGecko()->SetAssociatedDocument(aDocument, aAssociationMode);
AsConcrete()->SetAssociatedDocument(aDocument, aAssociationMode);
}
void
StyleSheet::ClearAssociatedDocument()
{
AsGecko()->SetAssociatedDocument(nullptr, NotOwnedByDocument);
AsConcrete()->SetAssociatedDocument(nullptr, NotOwnedByDocument);
}
StyleSheet*
StyleSheet::GetParentSheet() const
{
return AsGecko()->GetParentSheet();
return AsConcrete()->GetParentSheet();
}
StyleSheet*
@@ -112,7 +122,7 @@ StyleSheet::GetParentObject() const
void
StyleSheet::AppendStyleSheet(StyleSheet* aSheet)
{
AsGecko()->AppendStyleSheet(aSheet->AsGecko());
AsConcrete()->AppendStyleSheet(aSheet->AsConcrete());
}
nsIPrincipal*
@@ -155,19 +165,19 @@ StyleSheet::GetIntegrity(dom::SRIMetadata& aResult) const
size_t
StyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
return AsGecko()->SizeOfIncludingThis(aMallocSizeOf);
return AsConcrete()->SizeOfIncludingThis(aMallocSizeOf);
}
#ifdef DEBUG
void
StyleSheet::List(FILE* aOut, int32_t aIndex) const
{
AsGecko()->List(aOut, aIndex);
AsConcrete()->List(aOut, aIndex);
}
#endif
void StyleSheet::WillDirty() { AsGecko()->WillDirty(); }
void StyleSheet::DidDirty() { AsGecko()->DidDirty(); }
void StyleSheet::WillDirty() { AsConcrete()->WillDirty(); }
void StyleSheet::DidDirty() { AsConcrete()->DidDirty(); }
}
-1
View File
@@ -79,7 +79,6 @@ EXPORTS.mozilla += [
'CSSVariableDeclarations.h',
'CSSVariableResolver.h',
'CSSVariableValues.h',
'DeprecatedUtils.h',
'IncrementalClearCOMRuleArray.h',
'LayerAnimationInfo.h',
'RuleNodeCacheConditions.h',
+1 -2
View File
@@ -491,7 +491,6 @@ nsLayoutStylesheetCache::InvalidateSheet(RefPtr<StyleSheet>* aSheet)
{
MOZ_ASSERT(gCSSLoader, "pref changed before we loaded a sheet?");
// TODO: this redundant check goes away once we get rid of AsGecko.
const bool hasSheet = aSheet && *aSheet;
if (hasSheet && gCSSLoader) {
nsIURI* uri = (*aSheet)->GetSheetURI();
@@ -628,7 +627,7 @@ nsLayoutStylesheetCache::BuildPreferenceSheet(RefPtr<StyleSheet>* aSheet,
"kPreallocSize should be big enough to build preference style "
"sheet without reallocation");
sheet->AsGecko()->ReparseSheet(sheetText);
sheet->AsConcrete()->ReparseSheet(sheetText);
#undef NS_GET_R_G_B
}
+2 -2
View File
@@ -750,7 +750,7 @@ nsStyleSet::AppendAllXBLStyleSheets(nsTArray<mozilla::CSSStyleSheet*>& aArray) c
AutoTArray<StyleSheet*, 32> sheets;
mBindingManager->AppendAllSheets(sheets);
for (StyleSheet* handle : sheets) {
aArray.AppendElement(handle->AsGecko());
aArray.AppendElement(handle->AsConcrete());
}
}
}
@@ -2466,7 +2466,7 @@ nsStyleSet::EnsureUniqueInnerOnCSSSheets()
AutoTArray<StyleSheet*, 32> sheets;
mBindingManager->AppendAllSheets(sheets);
for (StyleSheet* sheet : sheets) {
queue.AppendElement(sheet->AsGecko());
queue.AppendElement(sheet->AsConcrete());
}
}