From 86651be7e1658c9301da3e1b0b5cfd74503ba43f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 16 Aug 2019 10:56:18 +0000 Subject: [PATCH] Bug 1571530 - Make PrepareSheet take a reference. r=heycam Differential Revision: https://phabricator.services.mozilla.com/D41561 --HG-- extra : moz-landing-system : lando --- layout/style/Loader.cpp | 18 ++++++++---------- layout/style/Loader.h | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index 54bddbcd684e..eeaf473d9c21 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -1100,11 +1100,9 @@ static Loader::MediaMatched MediaListMatches(const MediaList* aMediaList, * the sheet had "alternate" in its rel. */ Loader::MediaMatched Loader::PrepareSheet( - StyleSheet* aSheet, const nsAString& aTitle, const nsAString& aMediaString, + StyleSheet& aSheet, const nsAString& aTitle, const nsAString& aMediaString, MediaList* aMediaList, IsAlternate aIsAlternate, IsExplicitlyEnabled aIsExplicitlyEnabled) { - MOZ_ASSERT(aSheet, "Must have a sheet!"); - RefPtr mediaList(aMediaList); if (!aMediaString.IsEmpty()) { @@ -1113,10 +1111,10 @@ Loader::MediaMatched Loader::PrepareSheet( mediaList = MediaList::Create(aMediaString); } - aSheet->SetMedia(mediaList); + aSheet.SetMedia(mediaList); - aSheet->SetTitle(aTitle); - aSheet->SetEnabled(aIsAlternate == IsAlternate::No || + aSheet.SetTitle(aTitle); + aSheet.SetEnabled(aIsAlternate == IsAlternate::No || aIsExplicitlyEnabled == IsExplicitlyEnabled::Yes); return MediaListMatches(mediaList, mDocument); } @@ -1841,7 +1839,7 @@ Result Loader::LoadInlineStyle( LOG((" Sheet is alternate: %d", static_cast(isAlternate))); - auto matched = PrepareSheet(sheet, aInfo.mTitle, aInfo.mMedia, nullptr, + auto matched = PrepareSheet(*sheet, aInfo.mTitle, aInfo.mMedia, nullptr, isAlternate, aInfo.mIsExplicitlyEnabled); InsertSheetInTree(*sheet, aInfo.mContent); @@ -1943,7 +1941,7 @@ Result Loader::LoadStyleLink( LOG((" Sheet is alternate: %d", static_cast(isAlternate))); - auto matched = PrepareSheet(sheet, aInfo.mTitle, aInfo.mMedia, nullptr, + auto matched = PrepareSheet(*sheet, aInfo.mTitle, aInfo.mMedia, nullptr, isAlternate, aInfo.mIsExplicitlyEnabled); InsertSheetInTree(*sheet, aInfo.mContent); @@ -2105,7 +2103,7 @@ nsresult Loader::LoadChildSheet(StyleSheet& aParentSheet, CORS_NONE, aParentSheet.GetReferrerInfo(), EmptyString(), // integrity is only checked on main sheet aParentData ? aParentData->mSyncLoad : false); - PrepareSheet(sheet, EmptyString(), EmptyString(), aMedia, IsAlternate::No, + PrepareSheet(*sheet, EmptyString(), EmptyString(), aMedia, IsAlternate::No, IsExplicitlyEnabled::No); } @@ -2201,7 +2199,7 @@ Result, nsresult> Loader::InternalLoadNonDocumentSheet( CreateSheet(aURL, nullptr, aOriginPrincipal, aParsingMode, aCORSMode, aReferrerInfo, aIntegrity, syncLoad); - PrepareSheet(sheet, EmptyString(), EmptyString(), nullptr, IsAlternate::No, + PrepareSheet(*sheet, EmptyString(), EmptyString(), nullptr, IsAlternate::No, IsExplicitlyEnabled::No); if (state == SheetState::Complete) { diff --git a/layout/style/Loader.h b/layout/style/Loader.h index 741ccd861235..ee1f55a39293 100644 --- a/layout/style/Loader.h +++ b/layout/style/Loader.h @@ -353,8 +353,8 @@ class Loader final { // Pass in either a media string or the MediaList from the CSSParser. Don't // pass both. // - // This method will set the sheet's enabled state based on aIsAlternate - MediaMatched PrepareSheet(StyleSheet* aSheet, const nsAString& aTitle, + // This method will set the sheet's enabled state based on IsAlternate and co. + MediaMatched PrepareSheet(StyleSheet&, const nsAString& aTitle, const nsAString& aMediaString, dom::MediaList*, IsAlternate, IsExplicitlyEnabled);