зеркало из https://github.com/mozilla/gecko-dev.git
Bug 990250 - Fold nsIStyleSheet into CSSStyleSheet. r=dbaron
This commit is contained in:
Родитель
2322e84c59
Коммит
fd2fba0c73
|
@ -401,14 +401,12 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindow* aWindow)
|
|||
nsCOMPtr<nsIPresShell> shell = document->GetShell();
|
||||
if (shell) {
|
||||
// Reload only the chrome URL agent style sheets.
|
||||
nsCOMArray<nsIStyleSheet> agentSheets;
|
||||
nsTArray<RefPtr<CSSStyleSheet>> agentSheets;
|
||||
rv = shell->GetAgentStyleSheets(agentSheets);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMArray<nsIStyleSheet> newAgentSheets;
|
||||
for (int32_t l = 0; l < agentSheets.Count(); ++l) {
|
||||
nsIStyleSheet *sheet = agentSheets[l];
|
||||
|
||||
nsTArray<RefPtr<CSSStyleSheet>> newAgentSheets;
|
||||
for (CSSStyleSheet* sheet : agentSheets) {
|
||||
nsIURI* uri = sheet->GetSheetURI();
|
||||
|
||||
if (IsChromeURI(uri)) {
|
||||
|
@ -418,12 +416,12 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindow* aWindow)
|
|||
getter_AddRefs(newSheet));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (newSheet) {
|
||||
rv = newAgentSheets.AppendObject(newSheet) ? NS_OK : NS_ERROR_FAILURE;
|
||||
rv = newAgentSheets.AppendElement(newSheet) ? NS_OK : NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
else { // Just use the same sheet.
|
||||
rv = newAgentSheets.AppendObject(sheet) ? NS_OK : NS_ERROR_FAILURE;
|
||||
rv = newAgentSheets.AppendElement(sheet) ? NS_OK : NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
|
@ -432,27 +430,22 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindow* aWindow)
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Build an array of nsIURIs of style sheets we need to load.
|
||||
nsCOMArray<nsIStyleSheet> oldSheets;
|
||||
nsCOMArray<nsIStyleSheet> newSheets;
|
||||
|
||||
int32_t count = document->GetNumberOfStyleSheets();
|
||||
|
||||
// Iterate over the style sheets.
|
||||
int32_t i;
|
||||
for (i = 0; i < count; i++) {
|
||||
// Get the style sheet
|
||||
nsIStyleSheet *styleSheet = document->GetStyleSheetAt(i);
|
||||
// Build an array of style sheets we need to reload.
|
||||
nsTArray<RefPtr<CSSStyleSheet>> oldSheets(count);
|
||||
nsTArray<RefPtr<CSSStyleSheet>> newSheets(count);
|
||||
|
||||
if (!oldSheets.AppendObject(styleSheet)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
// Iterate over the style sheets.
|
||||
for (int32_t i = 0; i < count; i++) {
|
||||
// Get the style sheet
|
||||
CSSStyleSheet* 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 (i = 0; i < count; i++) {
|
||||
RefPtr<CSSStyleSheet> sheet = do_QueryObject(oldSheets[i]);
|
||||
for (CSSStyleSheet* sheet : oldSheets) {
|
||||
nsIURI* uri = sheet ? sheet->GetOriginalURI() : nullptr;
|
||||
|
||||
if (uri && IsChromeURI(uri)) {
|
||||
|
@ -462,11 +455,10 @@ nsresult nsChromeRegistry::RefreshWindow(nsPIDOMWindow* aWindow)
|
|||
// only works by sheer dumb luck.
|
||||
document->LoadChromeSheetSync(uri, false, getter_AddRefs(newSheet));
|
||||
// Even if it's null, we put in in there.
|
||||
newSheets.AppendObject(newSheet);
|
||||
}
|
||||
else {
|
||||
newSheets.AppendElement(newSheet);
|
||||
} else {
|
||||
// Just use the same sheet.
|
||||
newSheets.AppendObject(sheet);
|
||||
newSheets.AppendElement(sheet);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,6 @@
|
|||
#include "mozilla/Preferences.h"
|
||||
#include "nsIContentIterator.h"
|
||||
#include "nsIDOMStyleSheet.h"
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "nsIStyleSheetService.h"
|
||||
#include "nsContentPermissionHelper.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
@ -3244,7 +3243,7 @@ nsDOMWindowUtils::AddSheet(nsIDOMStyleSheet *aSheet, uint32_t aSheetType)
|
|||
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
||||
|
||||
nsIDocument::additionalSheetType type = convertSheetType(aSheetType);
|
||||
nsCOMPtr<nsIStyleSheet> sheet = do_QueryInterface(aSheet);
|
||||
RefPtr<CSSStyleSheet> sheet = do_QueryObject(aSheet);
|
||||
NS_ENSURE_TRUE(sheet, NS_ERROR_FAILURE);
|
||||
if (sheet->GetOwningDocument()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
|
|
@ -725,15 +725,6 @@ nsDOMStyleSheetList::Length()
|
|||
// been added or removed.
|
||||
if (-1 == mLength) {
|
||||
mLength = mDocument->GetNumberOfStyleSheets();
|
||||
|
||||
#ifdef DEBUG
|
||||
int32_t i;
|
||||
for (i = 0; i < mLength; i++) {
|
||||
nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(i);
|
||||
nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(sheet));
|
||||
NS_ASSERTION(domss, "All \"normal\" sheets implement nsIDOMStyleSheet");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return mLength;
|
||||
}
|
||||
|
@ -747,7 +738,7 @@ nsDOMStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
|||
}
|
||||
|
||||
aFound = true;
|
||||
nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(aIndex);
|
||||
CSSStyleSheet* sheet = mDocument->GetStyleSheetAt(aIndex);
|
||||
NS_ASSERTION(sheet, "Must have a sheet");
|
||||
|
||||
return static_cast<CSSStyleSheet*>(sheet);
|
||||
|
@ -761,27 +752,21 @@ nsDOMStyleSheetList::NodeWillBeDestroyed(const nsINode *aNode)
|
|||
|
||||
void
|
||||
nsDOMStyleSheetList::StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
CSSStyleSheet* aStyleSheet,
|
||||
bool aDocumentSheet)
|
||||
{
|
||||
if (aDocumentSheet && -1 != mLength) {
|
||||
nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(aStyleSheet));
|
||||
if (domss) {
|
||||
mLength++;
|
||||
}
|
||||
mLength++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMStyleSheetList::StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
CSSStyleSheet* aStyleSheet,
|
||||
bool aDocumentSheet)
|
||||
{
|
||||
if (aDocumentSheet && -1 != mLength) {
|
||||
nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(aStyleSheet));
|
||||
if (domss) {
|
||||
mLength--;
|
||||
}
|
||||
mLength--;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1347,7 +1332,7 @@ nsDOMStyleSheetSetList::EnsureFresh()
|
|||
int32_t count = mDocument->GetNumberOfStyleSheets();
|
||||
nsAutoString title;
|
||||
for (int32_t index = 0; index < count; index++) {
|
||||
nsIStyleSheet* sheet = mDocument->GetStyleSheetAt(index);
|
||||
CSSStyleSheet* sheet = mDocument->GetStyleSheetAt(index);
|
||||
NS_ASSERTION(sheet, "Null sheet in sheet list!");
|
||||
sheet->GetTitle(title);
|
||||
if (!title.IsEmpty() && !mNames.Contains(title) && !Add(title)) {
|
||||
|
@ -1624,9 +1609,7 @@ nsDocument::~nsDocument()
|
|||
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
|
||||
int32_t indx; // must be signed
|
||||
uint32_t count = mChildren.ChildCount();
|
||||
for (indx = int32_t(count) - 1; indx >= 0; --indx) {
|
||||
for (uint32_t indx = mChildren.ChildCount(); indx-- != 0; ) {
|
||||
mChildren.ChildAt(indx)->UnbindFromTree();
|
||||
mChildren.RemoveChildAt(indx);
|
||||
}
|
||||
|
@ -1634,9 +1617,8 @@ nsDocument::~nsDocument()
|
|||
mCachedRootElement = nullptr;
|
||||
|
||||
// Let the stylesheets know we're going away
|
||||
indx = mStyleSheets.Count();
|
||||
while (--indx >= 0) {
|
||||
mStyleSheets[indx]->SetOwningDocument(nullptr);
|
||||
for (CSSStyleSheet* sheet : mStyleSheets) {
|
||||
sheet->SetOwningDocument(nullptr);
|
||||
}
|
||||
if (mAttrStyleSheet) {
|
||||
mAttrStyleSheet->SetOwningDocument(nullptr);
|
||||
|
@ -2296,9 +2278,7 @@ void
|
|||
nsDocument::RemoveDocStyleSheetsFromStyleSets()
|
||||
{
|
||||
// The stylesheets should forget us
|
||||
int32_t indx = mStyleSheets.Count();
|
||||
while (--indx >= 0) {
|
||||
nsIStyleSheet* sheet = mStyleSheets[indx];
|
||||
for (CSSStyleSheet* sheet : Reversed(mStyleSheets)) {
|
||||
sheet->SetOwningDocument(nullptr);
|
||||
|
||||
if (sheet->IsApplicable()) {
|
||||
|
@ -2312,12 +2292,12 @@ nsDocument::RemoveDocStyleSheetsFromStyleSets()
|
|||
}
|
||||
|
||||
void
|
||||
nsDocument::RemoveStyleSheetsFromStyleSets(nsCOMArray<nsIStyleSheet>& aSheets, SheetType aType)
|
||||
nsDocument::RemoveStyleSheetsFromStyleSets(
|
||||
nsTArray<RefPtr<CSSStyleSheet>>& aSheets,
|
||||
SheetType aType)
|
||||
{
|
||||
// The stylesheets should forget us
|
||||
int32_t indx = aSheets.Count();
|
||||
while (--indx >= 0) {
|
||||
nsIStyleSheet* sheet = aSheets[indx];
|
||||
for (CSSStyleSheet* sheet : Reversed(aSheets)) {
|
||||
sheet->SetOwningDocument(nullptr);
|
||||
|
||||
if (sheet->IsApplicable()) {
|
||||
|
@ -2326,10 +2306,8 @@ nsDocument::RemoveStyleSheetsFromStyleSets(nsCOMArray<nsIStyleSheet>& aSheets, S
|
|||
shell->StyleSet()->RemoveStyleSheet(aType, sheet);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX Tell observers?
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2379,21 +2357,13 @@ nsDocument::ResetStylesheetsToURI(nsIURI* aURI)
|
|||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
AppendAuthorSheet(nsIStyleSheet *aSheet, void *aData)
|
||||
{
|
||||
nsStyleSet *styleSet = static_cast<nsStyleSet*>(aData);
|
||||
styleSet->AppendStyleSheet(SheetType::Doc, aSheet);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
AppendSheetsToStyleSet(nsStyleSet* aStyleSet,
|
||||
const nsCOMArray<nsIStyleSheet>& aSheets,
|
||||
const nsTArray<RefPtr<CSSStyleSheet>>& aSheets,
|
||||
SheetType aType)
|
||||
{
|
||||
for (int32_t i = aSheets.Count() - 1; i >= 0; --i) {
|
||||
aStyleSet->AppendStyleSheet(aType, aSheets[i]);
|
||||
for (CSSStyleSheet* sheet : Reversed(aSheets)) {
|
||||
aStyleSet->AppendStyleSheet(aType, sheet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2405,9 +2375,7 @@ nsDocument::FillStyleSet(nsStyleSet* aStyleSet)
|
|||
NS_PRECONDITION(aStyleSet->SheetCount(SheetType::Doc) == 0,
|
||||
"Style set already has document sheets?");
|
||||
|
||||
int32_t i;
|
||||
for (i = mStyleSheets.Count() - 1; i >= 0; --i) {
|
||||
nsIStyleSheet* sheet = mStyleSheets[i];
|
||||
for (CSSStyleSheet* sheet : Reversed(mStyleSheets)) {
|
||||
if (sheet->IsApplicable()) {
|
||||
aStyleSet->AddDocStyleSheet(sheet, this);
|
||||
}
|
||||
|
@ -2415,13 +2383,13 @@ nsDocument::FillStyleSet(nsStyleSet* aStyleSet)
|
|||
|
||||
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
||||
if (sheetService) {
|
||||
sheetService->AuthorStyleSheets()->EnumerateForwards(AppendAuthorSheet,
|
||||
aStyleSet);
|
||||
for (CSSStyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
|
||||
aStyleSet->AppendStyleSheet(SheetType::Doc, sheet);
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate backwards to maintain order
|
||||
for (i = mOnDemandBuiltInUASheets.Count() - 1; i >= 0; --i) {
|
||||
nsIStyleSheet* sheet = mOnDemandBuiltInUASheets[i];
|
||||
for (CSSStyleSheet* sheet : Reversed(mOnDemandBuiltInUASheets)) {
|
||||
if (sheet->IsApplicable()) {
|
||||
aStyleSet->PrependStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
|
@ -4017,8 +3985,7 @@ nsDocument::RemoveChildAt(uint32_t aIndex, bool aNotify)
|
|||
void
|
||||
nsDocument::EnsureOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
|
||||
{
|
||||
// Contains() takes nsISupport*, so annoyingly we have to cast here
|
||||
if (mOnDemandBuiltInUASheets.Contains(static_cast<nsIStyleSheet*>(aSheet))) {
|
||||
if (mOnDemandBuiltInUASheets.Contains(aSheet)) {
|
||||
return;
|
||||
}
|
||||
BeginUpdate(UPDATE_STYLE);
|
||||
|
@ -4029,8 +3996,7 @@ nsDocument::EnsureOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
|
|||
void
|
||||
nsDocument::AddOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
|
||||
{
|
||||
// Contains() takes nsISupport*, so annoyingly we have to cast here
|
||||
MOZ_ASSERT(!mOnDemandBuiltInUASheets.Contains(static_cast<nsIStyleSheet*>(aSheet)));
|
||||
MOZ_ASSERT(!mOnDemandBuiltInUASheets.Contains(aSheet));
|
||||
|
||||
// Prepend here so that we store the sheets in mOnDemandBuiltInUASheets in
|
||||
// the same order that they should end up in the style set.
|
||||
|
@ -4054,24 +4020,23 @@ nsDocument::AddOnDemandBuiltInUASheet(CSSStyleSheet* aSheet)
|
|||
int32_t
|
||||
nsDocument::GetNumberOfStyleSheets() const
|
||||
{
|
||||
return mStyleSheets.Count();
|
||||
return mStyleSheets.Length();
|
||||
}
|
||||
|
||||
nsIStyleSheet*
|
||||
CSSStyleSheet*
|
||||
nsDocument::GetStyleSheetAt(int32_t aIndex) const
|
||||
{
|
||||
NS_ENSURE_TRUE(0 <= aIndex && aIndex < mStyleSheets.Count(), nullptr);
|
||||
return mStyleSheets[aIndex];
|
||||
return mStyleSheets.SafeElementAt(aIndex, nullptr);
|
||||
}
|
||||
|
||||
int32_t
|
||||
nsDocument::GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const
|
||||
nsDocument::GetIndexOfStyleSheet(CSSStyleSheet* aSheet) const
|
||||
{
|
||||
return mStyleSheets.IndexOf(aSheet);
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::AddStyleSheetToStyleSets(nsIStyleSheet* aSheet)
|
||||
nsDocument::AddStyleSheetToStyleSets(CSSStyleSheet* aSheet)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell = GetShell();
|
||||
if (shell) {
|
||||
|
@ -4081,15 +4046,10 @@ nsDocument::AddStyleSheetToStyleSets(nsIStyleSheet* aSheet)
|
|||
|
||||
#define DO_STYLESHEET_NOTIFICATION(className, type, memberName, argName) \
|
||||
do { \
|
||||
RefPtr<CSSStyleSheet> cssSheet = do_QueryObject(aSheet); \
|
||||
if (!cssSheet) { \
|
||||
return; \
|
||||
} \
|
||||
\
|
||||
className##Init init; \
|
||||
init.mBubbles = true; \
|
||||
init.mCancelable = true; \
|
||||
init.mStylesheet = cssSheet; \
|
||||
init.mStylesheet = aSheet; \
|
||||
init.memberName = argName; \
|
||||
\
|
||||
RefPtr<className> event = \
|
||||
|
@ -4103,7 +4063,7 @@ nsDocument::AddStyleSheetToStyleSets(nsIStyleSheet* aSheet)
|
|||
} while (0);
|
||||
|
||||
void
|
||||
nsDocument::NotifyStyleSheetAdded(nsIStyleSheet* aSheet, bool aDocumentSheet)
|
||||
nsDocument::NotifyStyleSheetAdded(CSSStyleSheet* aSheet, bool aDocumentSheet)
|
||||
{
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleSheetAdded, (this, aSheet, aDocumentSheet));
|
||||
|
||||
|
@ -4116,7 +4076,7 @@ nsDocument::NotifyStyleSheetAdded(nsIStyleSheet* aSheet, bool aDocumentSheet)
|
|||
}
|
||||
|
||||
void
|
||||
nsDocument::NotifyStyleSheetRemoved(nsIStyleSheet* aSheet, bool aDocumentSheet)
|
||||
nsDocument::NotifyStyleSheetRemoved(CSSStyleSheet* aSheet, bool aDocumentSheet)
|
||||
{
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleSheetRemoved, (this, aSheet, aDocumentSheet));
|
||||
|
||||
|
@ -4129,10 +4089,10 @@ nsDocument::NotifyStyleSheetRemoved(nsIStyleSheet* aSheet, bool aDocumentSheet)
|
|||
}
|
||||
|
||||
void
|
||||
nsDocument::AddStyleSheet(nsIStyleSheet* aSheet)
|
||||
nsDocument::AddStyleSheet(CSSStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null arg");
|
||||
mStyleSheets.AppendObject(aSheet);
|
||||
mStyleSheets.AppendElement(aSheet);
|
||||
aSheet->SetOwningDocument(this);
|
||||
|
||||
if (aSheet->IsApplicable()) {
|
||||
|
@ -4143,7 +4103,7 @@ nsDocument::AddStyleSheet(nsIStyleSheet* aSheet)
|
|||
}
|
||||
|
||||
void
|
||||
nsDocument::RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet)
|
||||
nsDocument::RemoveStyleSheetFromStyleSets(CSSStyleSheet* aSheet)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell = GetShell();
|
||||
if (shell) {
|
||||
|
@ -4152,12 +4112,12 @@ nsDocument::RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet)
|
|||
}
|
||||
|
||||
void
|
||||
nsDocument::RemoveStyleSheet(nsIStyleSheet* aSheet)
|
||||
nsDocument::RemoveStyleSheet(CSSStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null arg");
|
||||
nsCOMPtr<nsIStyleSheet> sheet = aSheet; // hold ref so it won't die too soon
|
||||
RefPtr<CSSStyleSheet> sheet = aSheet; // hold ref so it won't die too soon
|
||||
|
||||
if (!mStyleSheets.RemoveObject(aSheet)) {
|
||||
if (!mStyleSheets.RemoveElement(aSheet)) {
|
||||
NS_ASSERTION(mInUnlinkOrDeletion, "stylesheet not found");
|
||||
return;
|
||||
}
|
||||
|
@ -4174,17 +4134,17 @@ nsDocument::RemoveStyleSheet(nsIStyleSheet* aSheet)
|
|||
}
|
||||
|
||||
void
|
||||
nsDocument::UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
|
||||
nsCOMArray<nsIStyleSheet>& aNewSheets)
|
||||
nsDocument::UpdateStyleSheets(nsTArray<RefPtr<CSSStyleSheet>>& aOldSheets,
|
||||
nsTArray<RefPtr<CSSStyleSheet>>& aNewSheets)
|
||||
{
|
||||
BeginUpdate(UPDATE_STYLE);
|
||||
|
||||
// XXX Need to set the sheet on the ownernode, if any
|
||||
NS_PRECONDITION(aOldSheets.Count() == aNewSheets.Count(),
|
||||
NS_PRECONDITION(aOldSheets.Length() == aNewSheets.Length(),
|
||||
"The lists must be the same length!");
|
||||
int32_t count = aOldSheets.Count();
|
||||
int32_t count = aOldSheets.Length();
|
||||
|
||||
nsCOMPtr<nsIStyleSheet> oldSheet;
|
||||
RefPtr<CSSStyleSheet> oldSheet;
|
||||
int32_t i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
oldSheet = aOldSheets[i];
|
||||
|
@ -4195,9 +4155,9 @@ nsDocument::UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
|
|||
RemoveStyleSheet(oldSheet); // This does the right notifications
|
||||
|
||||
// Now put the new one in its place. If it's null, just ignore it.
|
||||
nsIStyleSheet* newSheet = aNewSheets[i];
|
||||
CSSStyleSheet* newSheet = aNewSheets[i];
|
||||
if (newSheet) {
|
||||
mStyleSheets.InsertObjectAt(newSheet, oldIndex);
|
||||
mStyleSheets.InsertElementAt(oldIndex, newSheet);
|
||||
newSheet->SetOwningDocument(this);
|
||||
if (newSheet->IsApplicable()) {
|
||||
AddStyleSheetToStyleSets(newSheet);
|
||||
|
@ -4211,10 +4171,11 @@ nsDocument::UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
|
|||
}
|
||||
|
||||
void
|
||||
nsDocument::InsertStyleSheetAt(nsIStyleSheet* aSheet, int32_t aIndex)
|
||||
nsDocument::InsertStyleSheetAt(CSSStyleSheet* aSheet, int32_t aIndex)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null ptr");
|
||||
mStyleSheets.InsertObjectAt(aSheet, aIndex);
|
||||
|
||||
mStyleSheets.InsertElementAt(aIndex, aSheet);
|
||||
|
||||
aSheet->SetOwningDocument(this);
|
||||
|
||||
|
@ -4227,13 +4188,13 @@ nsDocument::InsertStyleSheetAt(nsIStyleSheet* aSheet, int32_t aIndex)
|
|||
|
||||
|
||||
void
|
||||
nsDocument::SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
|
||||
nsDocument::SetStyleSheetApplicableState(CSSStyleSheet* aSheet,
|
||||
bool aApplicable)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null arg");
|
||||
|
||||
// If we're actually in the document style sheet list
|
||||
if (-1 != mStyleSheets.IndexOf(aSheet)) {
|
||||
if (mStyleSheets.IndexOf(aSheet) != mStyleSheets.NoIndex) {
|
||||
if (aApplicable) {
|
||||
AddStyleSheetToStyleSets(aSheet);
|
||||
} else {
|
||||
|
@ -4294,9 +4255,9 @@ ConvertAdditionalSheetType(nsIDocument::additionalSheetType aType)
|
|||
}
|
||||
|
||||
static int32_t
|
||||
FindSheet(const nsCOMArray<nsIStyleSheet>& aSheets, nsIURI* aSheetURI)
|
||||
FindSheet(const nsTArray<RefPtr<CSSStyleSheet>>& aSheets, nsIURI* aSheetURI)
|
||||
{
|
||||
for (int32_t i = aSheets.Count() - 1; i >= 0; i-- ) {
|
||||
for (int32_t i = aSheets.Length() - 1; i >= 0; i-- ) {
|
||||
bool bEqual;
|
||||
nsIURI* uri = aSheets[i]->GetSheetURI();
|
||||
|
||||
|
@ -4350,7 +4311,7 @@ nsDocument::LoadAdditionalStyleSheet(additionalSheetType aType,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsDocument::AddAdditionalStyleSheet(additionalSheetType aType, nsIStyleSheet* aSheet)
|
||||
nsDocument::AddAdditionalStyleSheet(additionalSheetType aType, CSSStyleSheet* aSheet)
|
||||
{
|
||||
if (mAdditionalSheets[aType].Contains(aSheet))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
@ -4358,7 +4319,7 @@ nsDocument::AddAdditionalStyleSheet(additionalSheetType aType, nsIStyleSheet* aS
|
|||
if (!aSheet->IsApplicable())
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
mAdditionalSheets[aType].AppendObject(aSheet);
|
||||
mAdditionalSheets[aType].AppendElement(aSheet);
|
||||
|
||||
BeginUpdate(UPDATE_STYLE);
|
||||
nsCOMPtr<nsIPresShell> shell = GetShell();
|
||||
|
@ -4379,12 +4340,12 @@ nsDocument::RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheet
|
|||
{
|
||||
MOZ_ASSERT(aSheetURI);
|
||||
|
||||
nsCOMArray<nsIStyleSheet>& sheets = mAdditionalSheets[aType];
|
||||
nsTArray<RefPtr<CSSStyleSheet>>& sheets = mAdditionalSheets[aType];
|
||||
|
||||
int32_t i = FindSheet(mAdditionalSheets[aType], aSheetURI);
|
||||
if (i >= 0) {
|
||||
nsCOMPtr<nsIStyleSheet> sheetRef = sheets[i];
|
||||
sheets.RemoveObjectAt(i);
|
||||
RefPtr<CSSStyleSheet> sheetRef = sheets[i];
|
||||
sheets.RemoveElementAt(i);
|
||||
|
||||
BeginUpdate(UPDATE_STYLE);
|
||||
if (!mIsGoingAway) {
|
||||
|
@ -4405,10 +4366,10 @@ nsDocument::RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheet
|
|||
}
|
||||
}
|
||||
|
||||
nsIStyleSheet*
|
||||
CSSStyleSheet*
|
||||
nsDocument::FirstAdditionalAuthorSheet()
|
||||
{
|
||||
return mAdditionalSheets[eAuthorSheet].SafeObjectAt(0);
|
||||
return mAdditionalSheets[eAuthorSheet].SafeElementAt(0, nullptr);
|
||||
}
|
||||
|
||||
nsIGlobalObject*
|
||||
|
@ -5155,7 +5116,7 @@ nsDocument::DocumentStatesChanged(EventStates aStateMask)
|
|||
}
|
||||
|
||||
void
|
||||
nsDocument::StyleRuleChanged(nsIStyleSheet* aSheet,
|
||||
nsDocument::StyleRuleChanged(CSSStyleSheet* aSheet,
|
||||
css::Rule* aOldStyleRule,
|
||||
css::Rule* aNewStyleRule)
|
||||
{
|
||||
|
@ -5173,7 +5134,7 @@ nsDocument::StyleRuleChanged(nsIStyleSheet* aSheet,
|
|||
}
|
||||
|
||||
void
|
||||
nsDocument::StyleRuleAdded(nsIStyleSheet* aSheet,
|
||||
nsDocument::StyleRuleAdded(CSSStyleSheet* aSheet,
|
||||
css::Rule* aStyleRule)
|
||||
{
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleRuleAdded,
|
||||
|
@ -5189,7 +5150,7 @@ nsDocument::StyleRuleAdded(nsIStyleSheet* aSheet,
|
|||
}
|
||||
|
||||
void
|
||||
nsDocument::StyleRuleRemoved(nsIStyleSheet* aSheet,
|
||||
nsDocument::StyleRuleRemoved(CSSStyleSheet* aSheet,
|
||||
css::Rule* aStyleRule)
|
||||
{
|
||||
NS_DOCUMENT_NOTIFY_OBSERVERS(StyleRuleRemoved,
|
||||
|
@ -6428,13 +6389,11 @@ nsIDocument::GetSelectedStyleSheetSet(nsAString& aSheetSet)
|
|||
int32_t count = GetNumberOfStyleSheets();
|
||||
nsAutoString title;
|
||||
for (int32_t index = 0; index < count; index++) {
|
||||
nsIStyleSheet* sheet = GetStyleSheetAt(index);
|
||||
CSSStyleSheet* sheet = GetStyleSheetAt(index);
|
||||
NS_ASSERTION(sheet, "Null sheet in sheet list!");
|
||||
|
||||
nsCOMPtr<nsIDOMStyleSheet> domSheet = do_QueryInterface(sheet);
|
||||
NS_ASSERTION(domSheet, "Sheet must QI to nsIDOMStyleSheet");
|
||||
bool disabled;
|
||||
domSheet->GetDisabled(&disabled);
|
||||
sheet->GetDisabled(&disabled);
|
||||
if (disabled) {
|
||||
// Disabled sheets don't affect the currently selected set
|
||||
continue;
|
||||
|
@ -6544,7 +6503,7 @@ nsDocument::EnableStyleSheetsForSetInternal(const nsAString& aSheetSet,
|
|||
int32_t count = GetNumberOfStyleSheets();
|
||||
nsAutoString title;
|
||||
for (int32_t index = 0; index < count; index++) {
|
||||
nsIStyleSheet* sheet = GetStyleSheetAt(index);
|
||||
CSSStyleSheet* sheet = GetStyleSheetAt(index);
|
||||
NS_ASSERTION(sheet, "Null sheet in sheet list!");
|
||||
sheet->GetTitle(title);
|
||||
if (!title.IsEmpty()) {
|
||||
|
@ -10173,7 +10132,7 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
|
|||
|
||||
int32_t sheetsCount = GetNumberOfStyleSheets();
|
||||
for (int32_t i = 0; i < sheetsCount; ++i) {
|
||||
RefPtr<CSSStyleSheet> sheet = do_QueryObject(GetStyleSheetAt(i));
|
||||
RefPtr<CSSStyleSheet> sheet = GetStyleSheetAt(i);
|
||||
if (sheet) {
|
||||
if (sheet->IsApplicable()) {
|
||||
RefPtr<CSSStyleSheet> clonedSheet =
|
||||
|
@ -10186,11 +10145,8 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
|
|||
}
|
||||
}
|
||||
|
||||
sheetsCount = thisAsDoc->mOnDemandBuiltInUASheets.Count();
|
||||
// Iterate backwards to maintain order
|
||||
for (int32_t i = sheetsCount - 1; i >= 0; --i) {
|
||||
RefPtr<CSSStyleSheet> sheet =
|
||||
do_QueryObject(thisAsDoc->mOnDemandBuiltInUASheets[i]);
|
||||
for (CSSStyleSheet* sheet : Reversed(thisAsDoc->mOnDemandBuiltInUASheets)) {
|
||||
if (sheet) {
|
||||
if (sheet->IsApplicable()) {
|
||||
RefPtr<CSSStyleSheet> clonedSheet =
|
||||
|
@ -12278,7 +12234,7 @@ nsDocument::OnAppThemeChanged()
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < GetNumberOfStyleSheets(); i++) {
|
||||
RefPtr<CSSStyleSheet> sheet = do_QueryObject(GetStyleSheetAt(i));
|
||||
RefPtr<CSSStyleSheet> sheet = GetStyleSheetAt(i);
|
||||
if (!sheet) {
|
||||
continue;
|
||||
}
|
||||
|
@ -12645,15 +12601,19 @@ nsIDocument::DocAddSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const
|
|||
}
|
||||
|
||||
static size_t
|
||||
SizeOfStyleSheetsElementIncludingThis(nsIStyleSheet* aStyleSheet,
|
||||
MallocSizeOf aMallocSizeOf,
|
||||
void* aData)
|
||||
SizeOfOwnedSheetArrayExcludingThis(const nsTArray<RefPtr<CSSStyleSheet>>& aSheets,
|
||||
MallocSizeOf aMallocSizeOf)
|
||||
{
|
||||
if (!aStyleSheet->GetOwningDocument()) {
|
||||
// Avoid over-reporting shared sheets.
|
||||
return 0;
|
||||
size_t n = 0;
|
||||
n += aSheets.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
||||
for (CSSStyleSheet* sheet : aSheets) {
|
||||
if (!sheet->GetOwningDocument()) {
|
||||
// Avoid over-reporting shared sheets.
|
||||
continue;
|
||||
}
|
||||
n += sheet->SizeOfIncludingThis(aMallocSizeOf);
|
||||
}
|
||||
return aStyleSheet->SizeOfIncludingThis(aMallocSizeOf);
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t
|
||||
|
@ -12704,26 +12664,18 @@ nsDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
|
|||
}
|
||||
|
||||
aWindowSizes->mStyleSheetsSize +=
|
||||
mStyleSheets.SizeOfExcludingThis(SizeOfStyleSheetsElementIncludingThis,
|
||||
aWindowSizes->mMallocSizeOf);
|
||||
SizeOfOwnedSheetArrayExcludingThis(mStyleSheets,
|
||||
aWindowSizes->mMallocSizeOf);
|
||||
// Note that we do not own the sheets pointed to by mOnDemandBuiltInUASheets
|
||||
// (the nsLayoutStyleSheetCache singleton does) so pass nullptr as the
|
||||
// aSizeOfElementIncludingThis callback argument.
|
||||
// (the nsLayoutStyleSheetCache singleton does).
|
||||
aWindowSizes->mStyleSheetsSize +=
|
||||
mOnDemandBuiltInUASheets.SizeOfExcludingThis(nullptr,
|
||||
aWindowSizes->mMallocSizeOf);
|
||||
aWindowSizes->mStyleSheetsSize +=
|
||||
mAdditionalSheets[eAgentSheet].
|
||||
SizeOfExcludingThis(SizeOfStyleSheetsElementIncludingThis,
|
||||
aWindowSizes->mMallocSizeOf);
|
||||
aWindowSizes->mStyleSheetsSize +=
|
||||
mAdditionalSheets[eUserSheet].
|
||||
SizeOfExcludingThis(SizeOfStyleSheetsElementIncludingThis,
|
||||
aWindowSizes->mMallocSizeOf);
|
||||
aWindowSizes->mStyleSheetsSize +=
|
||||
mAdditionalSheets[eAuthorSheet].
|
||||
SizeOfExcludingThis(SizeOfStyleSheetsElementIncludingThis,
|
||||
aWindowSizes->mMallocSizeOf);
|
||||
mOnDemandBuiltInUASheets.ShallowSizeOfExcludingThis(
|
||||
aWindowSizes->mMallocSizeOf);
|
||||
for (auto& sheetArray : mAdditionalSheets) {
|
||||
aWindowSizes->mStyleSheetsSize +=
|
||||
SizeOfOwnedSheetArrayExcludingThis(sheetArray,
|
||||
aWindowSizes->mMallocSizeOf);
|
||||
}
|
||||
// Lumping in the loader with the style-sheets size is not ideal,
|
||||
// but most of the things in there are in fact stylesheets, so it
|
||||
// doesn't seem worthwhile to separate it out.
|
||||
|
|
|
@ -801,24 +801,29 @@ public:
|
|||
* These are ordered, highest priority last
|
||||
*/
|
||||
virtual int32_t GetNumberOfStyleSheets() const override;
|
||||
virtual nsIStyleSheet* GetStyleSheetAt(int32_t aIndex) const override;
|
||||
virtual int32_t GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const override;
|
||||
virtual void AddStyleSheet(nsIStyleSheet* aSheet) override;
|
||||
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet) 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 void UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
|
||||
nsCOMArray<nsIStyleSheet>& aNewSheets) override;
|
||||
virtual void AddStyleSheetToStyleSets(nsIStyleSheet* aSheet);
|
||||
virtual void RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet);
|
||||
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);
|
||||
|
||||
virtual void InsertStyleSheetAt(nsIStyleSheet* aSheet, int32_t aIndex) override;
|
||||
virtual void SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
|
||||
virtual void InsertStyleSheetAt(mozilla::CSSStyleSheet* aSheet,
|
||||
int32_t aIndex) override;
|
||||
virtual void SetStyleSheetApplicableState(mozilla::CSSStyleSheet* aSheet,
|
||||
bool aApplicable) override;
|
||||
|
||||
virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheetURI) override;
|
||||
virtual nsresult AddAdditionalStyleSheet(additionalSheetType aType, nsIStyleSheet* aSheet) override;
|
||||
virtual void RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* sheetURI) override;
|
||||
virtual nsIStyleSheet* FirstAdditionalAuthorSheet() override;
|
||||
virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType,
|
||||
nsIURI* aSheetURI) override;
|
||||
virtual nsresult AddAdditionalStyleSheet(additionalSheetType aType,
|
||||
mozilla::CSSStyleSheet* aSheet) override;
|
||||
virtual void RemoveAdditionalStyleSheet(additionalSheetType aType,
|
||||
nsIURI* sheetURI) override;
|
||||
virtual mozilla::CSSStyleSheet* FirstAdditionalAuthorSheet() override;
|
||||
|
||||
virtual nsIChannel* GetChannel() const override {
|
||||
return mChannel;
|
||||
|
@ -878,12 +883,12 @@ public:
|
|||
virtual void DocumentStatesChanged(
|
||||
mozilla::EventStates aStateMask) override;
|
||||
|
||||
virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleChanged(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
mozilla::css::Rule* aOldStyleRule,
|
||||
mozilla::css::Rule* aNewStyleRule) override;
|
||||
virtual void StyleRuleAdded(nsIStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleAdded(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) override;
|
||||
virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleRemoved(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) override;
|
||||
|
||||
virtual void FlushPendingNotifications(mozFlushType aType) override;
|
||||
|
@ -1494,8 +1499,9 @@ protected:
|
|||
nsCompatibility aCompatMode);
|
||||
|
||||
void RemoveDocStyleSheetsFromStyleSets();
|
||||
void RemoveStyleSheetsFromStyleSets(nsCOMArray<nsIStyleSheet>& aSheets,
|
||||
mozilla::SheetType aType);
|
||||
void RemoveStyleSheetsFromStyleSets(
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aSheets,
|
||||
mozilla::SheetType aType);
|
||||
void ResetStylesheetsToURI(nsIURI* aURI);
|
||||
void FillStyleSet(nsStyleSet* aStyleSet);
|
||||
|
||||
|
@ -1548,9 +1554,9 @@ protected:
|
|||
// EndLoad() has already happened.
|
||||
nsWeakPtr mWeakSink;
|
||||
|
||||
nsCOMArray<nsIStyleSheet> mStyleSheets;
|
||||
nsCOMArray<nsIStyleSheet> mOnDemandBuiltInUASheets;
|
||||
nsCOMArray<nsIStyleSheet> mAdditionalSheets[AdditionalSheetTypeCount];
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mStyleSheets;
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mOnDemandBuiltInUASheets;
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mAdditionalSheets[AdditionalSheetTypeCount];
|
||||
|
||||
// Array of observers
|
||||
nsTObserverArray<nsIDocumentObserver*> mObservers;
|
||||
|
@ -1709,8 +1715,8 @@ private:
|
|||
friend class nsUnblockOnloadEvent;
|
||||
// Recomputes the visibility state but doesn't set the new value.
|
||||
mozilla::dom::VisibilityState GetVisibilityState() const;
|
||||
void NotifyStyleSheetAdded(nsIStyleSheet* aSheet, bool aDocumentSheet);
|
||||
void NotifyStyleSheetRemoved(nsIStyleSheet* aSheet, bool aDocumentSheet);
|
||||
void NotifyStyleSheetAdded(mozilla::CSSStyleSheet* aSheet, bool aDocumentSheet);
|
||||
void NotifyStyleSheetRemoved(mozilla::CSSStyleSheet* aSheet, bool aDocumentSheet);
|
||||
|
||||
void PostUnblockOnloadEvent();
|
||||
void DoUnblockOnload();
|
||||
|
|
|
@ -72,7 +72,6 @@ class nsIRequest;
|
|||
class nsIRunnable;
|
||||
class nsIStreamListener;
|
||||
class nsIStructuredCloneContainer;
|
||||
class nsIStyleSheet;
|
||||
class nsIURI;
|
||||
class nsIVariant;
|
||||
class nsLocation;
|
||||
|
@ -156,8 +155,8 @@ typedef CallbackObjectHolder<NodeFilter, nsIDOMNodeFilter> NodeFilterHolder;
|
|||
} // namespace mozilla
|
||||
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0x4307abe8, 0x5386, 0x4024, \
|
||||
{ 0xa2, 0xfe, 0x4a, 0x80, 0xe8, 0x47, 0x46, 0x90 } }
|
||||
{ 0xecc9e376, 0x6c31, 0x4f04, \
|
||||
{ 0xbe, 0xde, 0xd6, 0x27, 0x61, 0xd7, 0x00, 0x84 } }
|
||||
|
||||
// Enum for requesting a particular type of document when creating a doc
|
||||
enum DocumentFlavor {
|
||||
|
@ -925,7 +924,7 @@ public:
|
|||
* @return the stylesheet at aIndex. Null if aIndex is out of range.
|
||||
* @throws no exceptions
|
||||
*/
|
||||
virtual nsIStyleSheet* GetStyleSheetAt(int32_t aIndex) const = 0;
|
||||
virtual mozilla::CSSStyleSheet* GetStyleSheetAt(int32_t aIndex) const = 0;
|
||||
|
||||
/**
|
||||
* Insert a sheet at a particular spot in the stylesheet list (zero-based)
|
||||
|
@ -934,7 +933,8 @@ public:
|
|||
* adjusted for the "special" sheets.
|
||||
* @throws no exceptions
|
||||
*/
|
||||
virtual void InsertStyleSheetAt(nsIStyleSheet* aSheet, int32_t aIndex) = 0;
|
||||
virtual void InsertStyleSheetAt(mozilla::CSSStyleSheet* aSheet,
|
||||
int32_t aIndex) = 0;
|
||||
|
||||
/**
|
||||
* Get the index of a particular stylesheet. This will _always_
|
||||
|
@ -942,7 +942,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(nsIStyleSheet* aSheet) const = 0;
|
||||
virtual int32_t GetIndexOfStyleSheet(mozilla::CSSStyleSheet* aSheet) const = 0;
|
||||
|
||||
/**
|
||||
* Replace the stylesheets in aOldSheets with the stylesheets in
|
||||
|
@ -952,24 +952,25 @@ public:
|
|||
* may be null; if so the corresponding sheets in the first list
|
||||
* will simply be removed.
|
||||
*/
|
||||
virtual void UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
|
||||
nsCOMArray<nsIStyleSheet>& aNewSheets) = 0;
|
||||
virtual void UpdateStyleSheets(
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aOldSheets,
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aNewSheets) = 0;
|
||||
|
||||
/**
|
||||
* Add a stylesheet to the document
|
||||
*/
|
||||
virtual void AddStyleSheet(nsIStyleSheet* aSheet) = 0;
|
||||
virtual void AddStyleSheet(mozilla::CSSStyleSheet* aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Remove a stylesheet from the document
|
||||
*/
|
||||
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet) = 0;
|
||||
virtual void RemoveStyleSheet(mozilla::CSSStyleSheet* 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(nsIStyleSheet* aSheet,
|
||||
virtual void SetStyleSheetApplicableState(mozilla::CSSStyleSheet* aSheet,
|
||||
bool aApplicable) = 0;
|
||||
|
||||
enum additionalSheetType {
|
||||
|
@ -979,10 +980,13 @@ public:
|
|||
AdditionalSheetTypeCount
|
||||
};
|
||||
|
||||
virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheetURI) = 0;
|
||||
virtual nsresult AddAdditionalStyleSheet(additionalSheetType aType, nsIStyleSheet* aSheet) = 0;
|
||||
virtual void RemoveAdditionalStyleSheet(additionalSheetType aType, nsIURI* sheetURI) = 0;
|
||||
virtual nsIStyleSheet* FirstAdditionalAuthorSheet() = 0;
|
||||
virtual nsresult LoadAdditionalStyleSheet(additionalSheetType aType,
|
||||
nsIURI* aSheetURI) = 0;
|
||||
virtual nsresult AddAdditionalStyleSheet(additionalSheetType aType,
|
||||
mozilla::CSSStyleSheet* aSheet) = 0;
|
||||
virtual void RemoveAdditionalStyleSheet(additionalSheetType aType,
|
||||
nsIURI* sheetURI) = 0;
|
||||
virtual mozilla::CSSStyleSheet* FirstAdditionalAuthorSheet() = 0;
|
||||
|
||||
/**
|
||||
* Get this document's CSSLoader. This is guaranteed to not return null.
|
||||
|
@ -1285,12 +1289,12 @@ public:
|
|||
|
||||
// Observation hooks for style data to propagate notifications
|
||||
// to document observers
|
||||
virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleChanged(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
mozilla::css::Rule* aOldStyleRule,
|
||||
mozilla::css::Rule* aNewStyleRule) = 0;
|
||||
virtual void StyleRuleAdded(nsIStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleAdded(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) = 0;
|
||||
virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
|
||||
virtual void StyleRuleRemoved(mozilla::CSSStyleSheet* aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) = 0;
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,18 +11,18 @@
|
|||
#include "nsIMutationObserver.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIStyleSheet;
|
||||
class nsIDocument;
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
namespace css {
|
||||
class Rule;
|
||||
} // namespace css
|
||||
} // namespace mozilla
|
||||
|
||||
#define NS_IDOCUMENT_OBSERVER_IID \
|
||||
{ 0xce1d53d0, 0x4739, 0x44e5, \
|
||||
{ 0xb4, 0xae, 0x60, 0xe8, 0x82, 0xcb, 0x73, 0x1b } }
|
||||
{ 0x21c8ad67, 0x3a7d, 0x4881, \
|
||||
{ 0xa5, 0x43, 0xcb, 0xa9, 0xbb, 0xe4, 0x9e, 0x39 } }
|
||||
|
||||
typedef uint32_t nsUpdateType;
|
||||
|
||||
|
@ -102,7 +102,7 @@ public:
|
|||
* false if sheet is not (i.e., UA or user sheet)
|
||||
*/
|
||||
virtual void StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
mozilla::CSSStyleSheet* aStyleSheet,
|
||||
bool aDocumentSheet) = 0;
|
||||
|
||||
/**
|
||||
|
@ -117,7 +117,7 @@ public:
|
|||
* false if sheet is not (i.e., UA or user sheet)
|
||||
*/
|
||||
virtual void StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
mozilla::CSSStyleSheet* aStyleSheet,
|
||||
bool aDocumentSheet) = 0;
|
||||
|
||||
/**
|
||||
|
@ -133,7 +133,7 @@ public:
|
|||
* it is not applicable
|
||||
*/
|
||||
virtual void StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
mozilla::CSSStyleSheet* aStyleSheet,
|
||||
bool aApplicable) = 0;
|
||||
|
||||
/**
|
||||
|
@ -160,7 +160,7 @@ public:
|
|||
* @param aNewStyleRule The rule being added.
|
||||
*/
|
||||
virtual void StyleRuleChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
mozilla::CSSStyleSheet* aStyleSheet,
|
||||
mozilla::css::Rule* aOldStyleRule,
|
||||
mozilla::css::Rule* aNewStyleRule) = 0;
|
||||
|
||||
|
@ -176,7 +176,7 @@ public:
|
|||
* @param aStyleRule the rule that was added
|
||||
*/
|
||||
virtual void StyleRuleAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
mozilla::CSSStyleSheet* aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) = 0;
|
||||
|
||||
/**
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
* @param aStyleRule the rule that was removed
|
||||
*/
|
||||
virtual void StyleRuleRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
mozilla::CSSStyleSheet* aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule) = 0;
|
||||
};
|
||||
|
||||
|
@ -221,33 +221,34 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
|
|||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED \
|
||||
virtual void StyleSheetAdded(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
bool aDocumentSheet) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED \
|
||||
virtual void StyleSheetRemoved(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
bool aDocumentSheet) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETAPPLICABLESTATECHANGED \
|
||||
virtual void StyleSheetApplicableStateChanged(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet,\
|
||||
bool aApplicable) override;
|
||||
virtual void StyleSheetApplicableStateChanged( \
|
||||
nsIDocument* aDocument, \
|
||||
mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
bool aApplicable) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULECHANGED \
|
||||
virtual void StyleRuleChanged(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
mozilla::css::Rule* aOldStyleRule, \
|
||||
mozilla::css::Rule* aNewStyleRule) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEADDED \
|
||||
virtual void StyleRuleAdded(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
mozilla::css::Rule* aStyleRule) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEREMOVED \
|
||||
virtual void StyleRuleRemoved(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
mozilla::css::Rule* aStyleRule) override;
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER \
|
||||
|
@ -307,38 +308,38 @@ NS_IMPL_NSIMUTATIONOBSERVER_CONTENT(_class)
|
|||
#define NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(_class) \
|
||||
void \
|
||||
_class::StyleSheetAdded(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
bool aDocumentSheet) \
|
||||
mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
bool aDocumentSheet) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleSheetRemoved(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
bool aDocumentSheet) \
|
||||
mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
bool aDocumentSheet) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleSheetApplicableStateChanged(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
bool aApplicable) \
|
||||
mozilla::CSSStyleSheet* aStyleSheet,\
|
||||
bool aApplicable) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleRuleChanged(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
mozilla::css::Rule* aOldStyleRule, \
|
||||
mozilla::css::Rule* aNewStyleRule) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleRuleAdded(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
mozilla::css::Rule* aStyleRule) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleRuleRemoved(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
mozilla::CSSStyleSheet* aStyleSheet, \
|
||||
mozilla::css::Rule* aStyleRule) \
|
||||
{ \
|
||||
}
|
||||
|
|
|
@ -288,17 +288,6 @@ UpdateIsElementInStyleScopeFlagOnSubtree(Element* aElement)
|
|||
}
|
||||
}
|
||||
|
||||
static Element*
|
||||
GetScopeElement(nsIStyleSheet* aSheet)
|
||||
{
|
||||
RefPtr<CSSStyleSheet> cssStyleSheet = do_QueryObject(aSheet);
|
||||
if (!cssStyleSheet) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return cssStyleSheet->GetScopeElement();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
|
||||
ShadowRoot* aOldShadowRoot,
|
||||
|
@ -330,7 +319,8 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
Element* oldScopeElement = GetScopeElement(mStyleSheet);
|
||||
Element* oldScopeElement =
|
||||
mStyleSheet ? mStyleSheet->GetScopeElement() : nullptr;
|
||||
|
||||
if (mStyleSheet && (aOldDocument || aOldShadowRoot)) {
|
||||
MOZ_ASSERT(!(aOldDocument && aOldShadowRoot),
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMStyleSheet.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "nsIStyleSheetLinkingElement.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "nsGkAtoms.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIDOMStyleSheet.h"
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
|
|
@ -2641,12 +2641,12 @@ nsHTMLDocument::TearingDownEditor(nsIEditor *aEditor)
|
|||
if (!presShell)
|
||||
return;
|
||||
|
||||
nsCOMArray<nsIStyleSheet> agentSheets;
|
||||
nsTArray<RefPtr<CSSStyleSheet>> agentSheets;
|
||||
presShell->GetAgentStyleSheets(agentSheets);
|
||||
|
||||
agentSheets.RemoveObject(nsLayoutStylesheetCache::ContentEditableSheet());
|
||||
agentSheets.RemoveElement(nsLayoutStylesheetCache::ContentEditableSheet());
|
||||
if (oldState == eDesignMode)
|
||||
agentSheets.RemoveObject(nsLayoutStylesheetCache::DesignModeSheet());
|
||||
agentSheets.RemoveElement(nsLayoutStylesheetCache::DesignModeSheet());
|
||||
|
||||
presShell->SetAgentStyleSheets(agentSheets);
|
||||
|
||||
|
@ -2780,18 +2780,15 @@ 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.
|
||||
nsCOMArray<nsIStyleSheet> agentSheets;
|
||||
nsTArray<RefPtr<CSSStyleSheet>> agentSheets;
|
||||
rv = presShell->GetAgentStyleSheets(agentSheets);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
CSSStyleSheet* contentEditableSheet =
|
||||
nsLayoutStylesheetCache::ContentEditableSheet();
|
||||
|
||||
bool result;
|
||||
|
||||
if (!agentSheets.Contains(contentEditableSheet)) {
|
||||
bool result = agentSheets.AppendObject(contentEditableSheet);
|
||||
NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
|
||||
agentSheets.AppendElement(contentEditableSheet);
|
||||
}
|
||||
|
||||
// Should we update the editable state of all the nodes in the document? We
|
||||
|
@ -2802,8 +2799,7 @@ nsHTMLDocument::EditingStateChanged()
|
|||
CSSStyleSheet* designModeSheet =
|
||||
nsLayoutStylesheetCache::DesignModeSheet();
|
||||
if (!agentSheets.Contains(designModeSheet)) {
|
||||
result = agentSheets.AppendObject(designModeSheet);
|
||||
NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
|
||||
agentSheets.AppendElement(designModeSheet);
|
||||
}
|
||||
|
||||
updateState = true;
|
||||
|
@ -2811,7 +2807,7 @@ nsHTMLDocument::EditingStateChanged()
|
|||
}
|
||||
else if (oldState == eDesignMode) {
|
||||
// designMode is being turned off (contentEditable is still on).
|
||||
agentSheets.RemoveObject(nsLayoutStylesheetCache::DesignModeSheet());
|
||||
agentSheets.RemoveElement(nsLayoutStylesheetCache::DesignModeSheet());
|
||||
updateState = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "imgIContainer.h"
|
||||
#include "mozIApplication.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/CSSStyleSheet.h"
|
||||
#include "mozilla/DataStorage.h"
|
||||
#include "mozilla/devtools/HeapSnapshotTempFileHelperParent.h"
|
||||
#include "mozilla/docshell/OfflineCacheUpdateParent.h"
|
||||
|
@ -142,7 +143,6 @@
|
|||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsISiteSecurityService.h"
|
||||
#include "nsISpellChecker.h"
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsISystemMessagesInternal.h"
|
||||
#include "nsITimer.h"
|
||||
|
@ -2576,24 +2576,21 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
|
|||
// This looks like a lot of work, but in a normal browser session we just
|
||||
// send two loads.
|
||||
|
||||
nsCOMArray<nsIStyleSheet>& agentSheets = *sheetService->AgentStyleSheets();
|
||||
for (uint32_t i = 0; i < agentSheets.Length(); i++) {
|
||||
for (CSSStyleSheet* sheet : *sheetService->AgentStyleSheets()) {
|
||||
URIParams uri;
|
||||
SerializeURI(agentSheets[i]->GetSheetURI(), uri);
|
||||
SerializeURI(sheet->GetSheetURI(), uri);
|
||||
Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AGENT_SHEET);
|
||||
}
|
||||
|
||||
nsCOMArray<nsIStyleSheet>& userSheets = *sheetService->UserStyleSheets();
|
||||
for (uint32_t i = 0; i < userSheets.Length(); i++) {
|
||||
for (CSSStyleSheet* sheet : *sheetService->UserStyleSheets()) {
|
||||
URIParams uri;
|
||||
SerializeURI(userSheets[i]->GetSheetURI(), uri);
|
||||
SerializeURI(sheet->GetSheetURI(), uri);
|
||||
Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::USER_SHEET);
|
||||
}
|
||||
|
||||
nsCOMArray<nsIStyleSheet>& authorSheets = *sheetService->AuthorStyleSheets();
|
||||
for (uint32_t i = 0; i < authorSheets.Length(); i++) {
|
||||
for (CSSStyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
|
||||
URIParams uri;
|
||||
SerializeURI(authorSheets[i]->GetSheetURI(), uri);
|
||||
SerializeURI(sheet->GetSheetURI(), uri);
|
||||
Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,6 @@
|
|||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "mozilla/css/StyleRule.h"
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsViewManager.h"
|
||||
#include "nsIWidget.h"
|
||||
|
|
|
@ -19,10 +19,8 @@
|
|||
|
||||
using namespace mozilla;
|
||||
|
||||
class nsIStyleSheet;
|
||||
|
||||
static void
|
||||
AddStyleSheet(nsIEditor* aEditor, nsIStyleSheet* aSheet)
|
||||
AddStyleSheet(nsIEditor* aEditor, CSSStyleSheet* aSheet)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
aEditor->GetDocument(getter_AddRefs(domDoc));
|
||||
|
@ -35,7 +33,7 @@ AddStyleSheet(nsIEditor* aEditor, nsIStyleSheet* aSheet)
|
|||
}
|
||||
|
||||
static void
|
||||
RemoveStyleSheet(nsIEditor *aEditor, nsIStyleSheet *aSheet)
|
||||
RemoveStyleSheet(nsIEditor* aEditor, CSSStyleSheet* aSheet)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
aEditor->GetDocument(getter_AddRefs(domDoc));
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "nsIOutputStream.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsITransport.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
|
|
|
@ -2136,22 +2136,6 @@ nsDocumentViewer::RequestWindowClose(bool* aCanClose)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static bool
|
||||
AppendAgentSheet(nsIStyleSheet *aSheet, void *aData)
|
||||
{
|
||||
nsStyleSet *styleSet = static_cast<nsStyleSet*>(aData);
|
||||
styleSet->AppendStyleSheet(SheetType::Agent, aSheet);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
PrependUserSheet(nsIStyleSheet *aSheet, void *aData)
|
||||
{
|
||||
nsStyleSet *styleSet = static_cast<nsStyleSet*>(aData);
|
||||
styleSet->PrependStyleSheet(SheetType::User, aSheet);
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
||||
nsStyleSet** aStyleSet)
|
||||
|
@ -2315,12 +2299,14 @@ nsDocumentViewer::CreateStyleSet(nsIDocument* aDocument,
|
|||
}
|
||||
}
|
||||
|
||||
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
||||
nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
|
||||
if (sheetService) {
|
||||
sheetService->AgentStyleSheets()->EnumerateForwards(AppendAgentSheet,
|
||||
styleSet);
|
||||
sheetService->UserStyleSheets()->EnumerateBackwards(PrependUserSheet,
|
||||
styleSet);
|
||||
for (CSSStyleSheet* sheet : *sheetService->AgentStyleSheets()) {
|
||||
styleSet->AppendStyleSheet(SheetType::Agent, sheet);
|
||||
}
|
||||
for (CSSStyleSheet* sheet : Reversed(*sheetService->UserStyleSheets())) {
|
||||
styleSet->PrependStyleSheet(SheetType::User, sheet);
|
||||
}
|
||||
}
|
||||
|
||||
// Caller will handle calling EndUpdate, per contract.
|
||||
|
|
|
@ -62,6 +62,7 @@ class nsAString;
|
|||
class nsCaret;
|
||||
namespace mozilla {
|
||||
class AccessibleCaretEventHub;
|
||||
class CSSStyleSheet;
|
||||
class TouchCaret;
|
||||
class SelectionCarets;
|
||||
} // namespace mozilla
|
||||
|
@ -70,7 +71,6 @@ class nsFrameManager;
|
|||
class nsILayoutHistoryState;
|
||||
class nsIReflowCallback;
|
||||
class nsIDOMNode;
|
||||
class nsIStyleSheet;
|
||||
class nsCSSFrameConstructor;
|
||||
class nsISelection;
|
||||
template<class E> class nsCOMArray;
|
||||
|
@ -140,10 +140,10 @@ typedef struct CapturingContentInfo {
|
|||
mozilla::StaticRefPtr<nsIContent> mContent;
|
||||
} CapturingContentInfo;
|
||||
|
||||
// ae50e013-b2f1-4d4e-94c7-77cbcdab1c23
|
||||
// cf2a1f1f-ed15-42bd-b1ea-59e5d4602118
|
||||
#define NS_IPRESSHELL_IID \
|
||||
{ 0xae50e013, 0xb2f1, 0x4d4e, \
|
||||
{ 0x94, 0xc7, 0x77, 0xcb, 0xcd, 0xab, 0x1c, 0x23 } }
|
||||
{ 0xcf2a1f1f, 0xed15, 0x42bd, \
|
||||
{ 0xb1, 0xea, 0x59, 0xe5, 0xd4, 0x60, 0x21, 0x18 } }
|
||||
|
||||
// debug VerifyReflow flags
|
||||
#define VERIFY_REFLOW_ON 0x01
|
||||
|
@ -958,22 +958,24 @@ public:
|
|||
/**
|
||||
* Get the set of agent style sheets for this presentation
|
||||
*/
|
||||
virtual nsresult GetAgentStyleSheets(nsCOMArray<nsIStyleSheet>& aSheets) = 0;
|
||||
virtual nsresult GetAgentStyleSheets(
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aSheets) = 0;
|
||||
|
||||
/**
|
||||
* Replace the set of agent style sheets
|
||||
*/
|
||||
virtual nsresult SetAgentStyleSheets(const nsCOMArray<nsIStyleSheet>& aSheets) = 0;
|
||||
virtual nsresult SetAgentStyleSheets(
|
||||
const nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aSheets) = 0;
|
||||
|
||||
/**
|
||||
* Add an override style sheet for this presentation
|
||||
*/
|
||||
virtual nsresult AddOverrideStyleSheet(nsIStyleSheet *aSheet) = 0;
|
||||
virtual nsresult AddOverrideStyleSheet(mozilla::CSSStyleSheet* aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Remove an override style sheet
|
||||
*/
|
||||
virtual nsresult RemoveOverrideStyleSheet(nsIStyleSheet *aSheet) = 0;
|
||||
virtual nsresult RemoveOverrideStyleSheet(mozilla::CSSStyleSheet* aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Reconstruct frames for all elements in the document
|
||||
|
|
|
@ -1426,19 +1426,18 @@ PresShell::AddUserSheet(nsISupports* aSheet)
|
|||
|
||||
mStyleSet->BeginUpdate();
|
||||
|
||||
nsStyleSheetService *sheetService = nsStyleSheetService::gInstance;
|
||||
nsCOMArray<nsIStyleSheet> & userSheets = *sheetService->UserStyleSheets();
|
||||
int32_t i;
|
||||
nsStyleSheetService* sheetService = nsStyleSheetService::gInstance;
|
||||
nsTArray<RefPtr<CSSStyleSheet>>& userSheets = *sheetService->UserStyleSheets();
|
||||
// Iterate forwards when removing so the searches for RemoveStyleSheet are as
|
||||
// short as possible.
|
||||
for (i = 0; i < userSheets.Count(); ++i) {
|
||||
mStyleSet->RemoveStyleSheet(SheetType::User, userSheets[i]);
|
||||
for (CSSStyleSheet* 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 (i = userSheets.Count() - 1; i >= 0; --i) {
|
||||
mStyleSet->PrependStyleSheet(SheetType::User, userSheets[i]);
|
||||
for (CSSStyleSheet* sheet : Reversed(userSheets)) {
|
||||
mStyleSet->PrependStyleSheet(SheetType::User, sheet);
|
||||
}
|
||||
|
||||
mStyleSet->EndUpdate();
|
||||
|
@ -1451,7 +1450,7 @@ PresShell::AddAgentSheet(nsISupports* aSheet)
|
|||
{
|
||||
// Make sure this does what nsDocumentViewer::CreateStyleSet does
|
||||
// wrt ordering.
|
||||
nsCOMPtr<nsIStyleSheet> sheet = do_QueryInterface(aSheet);
|
||||
RefPtr<CSSStyleSheet> sheet = do_QueryObject(aSheet);
|
||||
if (!sheet) {
|
||||
return;
|
||||
}
|
||||
|
@ -1463,14 +1462,14 @@ PresShell::AddAgentSheet(nsISupports* aSheet)
|
|||
void
|
||||
PresShell::AddAuthorSheet(nsISupports* aSheet)
|
||||
{
|
||||
nsCOMPtr<nsIStyleSheet> sheet = do_QueryInterface(aSheet);
|
||||
RefPtr<CSSStyleSheet> sheet = do_QueryObject(aSheet);
|
||||
if (!sheet) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Document specific "additional" Author sheets should be stronger than the ones
|
||||
// added with the StyleSheetService.
|
||||
nsIStyleSheet* firstAuthorSheet = mDocument->FirstAdditionalAuthorSheet();
|
||||
CSSStyleSheet* firstAuthorSheet = mDocument->FirstAdditionalAuthorSheet();
|
||||
if (firstAuthorSheet) {
|
||||
mStyleSet->InsertStyleSheetBefore(SheetType::Doc, sheet, firstAuthorSheet);
|
||||
} else {
|
||||
|
@ -1483,7 +1482,7 @@ PresShell::AddAuthorSheet(nsISupports* aSheet)
|
|||
void
|
||||
PresShell::RemoveSheet(SheetType aType, nsISupports* aSheet)
|
||||
{
|
||||
nsCOMPtr<nsIStyleSheet> sheet = do_QueryInterface(aSheet);
|
||||
RefPtr<CSSStyleSheet> sheet = do_QueryObject(aSheet);
|
||||
if (!sheet) {
|
||||
return;
|
||||
}
|
||||
|
@ -4501,7 +4500,7 @@ nsIPresShell::ReconstructStyleDataExternal()
|
|||
}
|
||||
|
||||
void
|
||||
PresShell::RecordStyleSheetChange(nsIStyleSheet* aStyleSheet)
|
||||
PresShell::RecordStyleSheetChange(CSSStyleSheet* aStyleSheet)
|
||||
{
|
||||
// too bad we can't check that the update is UPDATE_STYLE
|
||||
NS_ASSERTION(mUpdateCount != 0, "must be in an update");
|
||||
|
@ -4522,8 +4521,8 @@ PresShell::RecordStyleSheetChange(nsIStyleSheet* aStyleSheet)
|
|||
}
|
||||
|
||||
void
|
||||
PresShell::StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PresShell::StyleSheetAdded(nsIDocument* aDocument,
|
||||
CSSStyleSheet* aStyleSheet,
|
||||
bool aDocumentSheet)
|
||||
{
|
||||
// We only care when enabled sheets are added
|
||||
|
@ -4535,8 +4534,8 @@ PresShell::StyleSheetAdded(nsIDocument *aDocument,
|
|||
}
|
||||
|
||||
void
|
||||
PresShell::StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PresShell::StyleSheetRemoved(nsIDocument* aDocument,
|
||||
CSSStyleSheet* aStyleSheet,
|
||||
bool aDocumentSheet)
|
||||
{
|
||||
// We only care when enabled sheets are removed
|
||||
|
@ -4548,8 +4547,8 @@ PresShell::StyleSheetRemoved(nsIDocument *aDocument,
|
|||
}
|
||||
|
||||
void
|
||||
PresShell::StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PresShell::StyleSheetApplicableStateChanged(nsIDocument* aDocument,
|
||||
CSSStyleSheet* aStyleSheet,
|
||||
bool aApplicable)
|
||||
{
|
||||
if (aStyleSheet->HasRules()) {
|
||||
|
@ -4558,8 +4557,8 @@ PresShell::StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
|||
}
|
||||
|
||||
void
|
||||
PresShell::StyleRuleChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PresShell::StyleRuleChanged(nsIDocument* aDocument,
|
||||
CSSStyleSheet* aStyleSheet,
|
||||
mozilla::css::Rule* aOldStyleRule,
|
||||
mozilla::css::Rule* aNewStyleRule)
|
||||
{
|
||||
|
@ -4567,16 +4566,16 @@ PresShell::StyleRuleChanged(nsIDocument *aDocument,
|
|||
}
|
||||
|
||||
void
|
||||
PresShell::StyleRuleAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PresShell::StyleRuleAdded(nsIDocument* aDocument,
|
||||
CSSStyleSheet* aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule)
|
||||
{
|
||||
RecordStyleSheetChange(aStyleSheet);
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::StyleRuleRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PresShell::StyleRuleRemoved(nsIDocument* aDocument,
|
||||
CSSStyleSheet* aStyleSheet,
|
||||
mozilla::css::Rule* aStyleRule)
|
||||
{
|
||||
RecordStyleSheetChange(aStyleSheet);
|
||||
|
@ -8602,34 +8601,37 @@ PresShell::IsVisible()
|
|||
}
|
||||
|
||||
nsresult
|
||||
PresShell::GetAgentStyleSheets(nsCOMArray<nsIStyleSheet>& aSheets)
|
||||
PresShell::GetAgentStyleSheets(nsTArray<RefPtr<CSSStyleSheet>>& aSheets)
|
||||
{
|
||||
aSheets.Clear();
|
||||
int32_t sheetCount = mStyleSet->SheetCount(SheetType::Agent);
|
||||
|
||||
if (!aSheets.SetCapacity(sheetCount, fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < sheetCount; ++i) {
|
||||
nsIStyleSheet *sheet = mStyleSet->StyleSheetAt(SheetType::Agent, i);
|
||||
if (!aSheets.AppendObject(sheet))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
CSSStyleSheet* sheet = mStyleSet->StyleSheetAt(SheetType::Agent, i);
|
||||
aSheets.AppendElement(sheet);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresShell::SetAgentStyleSheets(const nsCOMArray<nsIStyleSheet>& aSheets)
|
||||
PresShell::SetAgentStyleSheets(const nsTArray<RefPtr<CSSStyleSheet>>& aSheets)
|
||||
{
|
||||
return mStyleSet->ReplaceSheets(SheetType::Agent, aSheets);
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresShell::AddOverrideStyleSheet(nsIStyleSheet *aSheet)
|
||||
PresShell::AddOverrideStyleSheet(CSSStyleSheet* aSheet)
|
||||
{
|
||||
return mStyleSet->PrependStyleSheet(SheetType::Override, aSheet);
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresShell::RemoveOverrideStyleSheet(nsIStyleSheet *aSheet)
|
||||
PresShell::RemoveOverrideStyleSheet(CSSStyleSheet* aSheet)
|
||||
{
|
||||
return mStyleSet->RemoveStyleSheet(SheetType::Override, aSheet);
|
||||
}
|
||||
|
@ -9732,7 +9734,7 @@ PresShell::CloneStyleSet(nsStyleSet* aSet)
|
|||
|
||||
int32_t i, n = aSet->SheetCount(SheetType::Override);
|
||||
for (i = 0; i < n; i++) {
|
||||
nsIStyleSheet* ss = aSet->StyleSheetAt(SheetType::Override, i);
|
||||
CSSStyleSheet* ss = aSet->StyleSheetAt(SheetType::Override, i);
|
||||
if (ss)
|
||||
clone->AppendStyleSheet(SheetType::Override, ss);
|
||||
}
|
||||
|
@ -9741,7 +9743,7 @@ PresShell::CloneStyleSet(nsStyleSet* aSet)
|
|||
#if 0
|
||||
n = aSet->SheetCount(SheetType::Doc);
|
||||
for (i = 0; i < n; i++) {
|
||||
nsIStyleSheet* ss = aSet->StyleSheetAt(SheetType::Doc, i);
|
||||
CSSStyleSheet* ss = aSet->StyleSheetAt(SheetType::Doc, i);
|
||||
if (ss)
|
||||
clone->AddDocStyleSheet(ss, mDocument);
|
||||
}
|
||||
|
@ -9749,14 +9751,14 @@ PresShell::CloneStyleSet(nsStyleSet* aSet)
|
|||
|
||||
n = aSet->SheetCount(SheetType::User);
|
||||
for (i = 0; i < n; i++) {
|
||||
nsIStyleSheet* ss = aSet->StyleSheetAt(SheetType::User, i);
|
||||
CSSStyleSheet* ss = aSet->StyleSheetAt(SheetType::User, i);
|
||||
if (ss)
|
||||
clone->AppendStyleSheet(SheetType::User, ss);
|
||||
}
|
||||
|
||||
n = aSet->SheetCount(SheetType::Agent);
|
||||
for (i = 0; i < n; i++) {
|
||||
nsIStyleSheet* ss = aSet->StyleSheetAt(SheetType::Agent, i);
|
||||
CSSStyleSheet* ss = aSet->StyleSheetAt(SheetType::Agent, i);
|
||||
if (ss)
|
||||
clone->AppendStyleSheet(SheetType::Agent, ss);
|
||||
}
|
||||
|
|
|
@ -161,11 +161,13 @@ public:
|
|||
|
||||
virtual void UnsuppressPainting() override;
|
||||
|
||||
virtual nsresult GetAgentStyleSheets(nsCOMArray<nsIStyleSheet>& aSheets) override;
|
||||
virtual nsresult SetAgentStyleSheets(const nsCOMArray<nsIStyleSheet>& aSheets) override;
|
||||
virtual nsresult GetAgentStyleSheets(
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aSheets) override;
|
||||
virtual nsresult SetAgentStyleSheets(
|
||||
const nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aSheets) override;
|
||||
|
||||
virtual nsresult AddOverrideStyleSheet(nsIStyleSheet *aSheet) override;
|
||||
virtual nsresult RemoveOverrideStyleSheet(nsIStyleSheet *aSheet) override;
|
||||
virtual nsresult AddOverrideStyleSheet(mozilla::CSSStyleSheet* aSheet) override;
|
||||
virtual nsresult RemoveOverrideStyleSheet(mozilla::CSSStyleSheet* aSheet) override;
|
||||
|
||||
virtual nsresult HandleEventWithTarget(
|
||||
mozilla::WidgetEvent* aEvent,
|
||||
|
@ -516,7 +518,7 @@ protected:
|
|||
void ShowEventTargetDebug();
|
||||
#endif
|
||||
|
||||
void RecordStyleSheetChange(nsIStyleSheet* aStyleSheet);
|
||||
void RecordStyleSheetChange(mozilla::CSSStyleSheet* aStyleSheet);
|
||||
|
||||
void RemovePreferenceStyles();
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
/* implementation of interface for managing user and user-agent style sheets */
|
||||
|
||||
#include "nsStyleSheetService.h"
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "mozilla/CSSStyleSheet.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
@ -79,14 +78,14 @@ nsStyleSheetService::RegisterFromEnumerator(nsICategoryManager *aManager,
|
|||
}
|
||||
|
||||
int32_t
|
||||
nsStyleSheetService::FindSheetByURI(const nsCOMArray<nsIStyleSheet> &sheets,
|
||||
nsIURI *sheetURI)
|
||||
nsStyleSheetService::FindSheetByURI(const nsTArray<RefPtr<CSSStyleSheet>>& aSheets,
|
||||
nsIURI* aSheetURI)
|
||||
{
|
||||
for (int32_t i = sheets.Count() - 1; i >= 0; i-- ) {
|
||||
for (int32_t i = aSheets.Length() - 1; i >= 0; i-- ) {
|
||||
bool bEqual;
|
||||
nsIURI* uri = sheets[i]->GetSheetURI();
|
||||
nsIURI* uri = aSheets[i]->GetSheetURI();
|
||||
if (uri
|
||||
&& NS_SUCCEEDED(uri->Equals(sheetURI, &bEqual))
|
||||
&& NS_SUCCEEDED(uri->Equals(aSheetURI, &bEqual))
|
||||
&& bEqual) {
|
||||
return i;
|
||||
}
|
||||
|
@ -153,8 +152,9 @@ nsStyleSheetService::LoadAndRegisterSheet(nsIURI *aSheetURI,
|
|||
if (serv) {
|
||||
// We're guaranteed that the new sheet is the last sheet in
|
||||
// mSheets[aSheetType]
|
||||
const nsCOMArray<nsIStyleSheet> & sheets = mSheets[aSheetType];
|
||||
serv->NotifyObservers(sheets[sheets.Count() - 1], message, nullptr);
|
||||
CSSStyleSheet* sheet = mSheets[aSheetType].LastElement();
|
||||
serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, sheet),
|
||||
message, nullptr);
|
||||
}
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
|
@ -208,9 +208,7 @@ nsStyleSheetService::LoadAndRegisterSheetInternal(nsIURI *aSheetURI,
|
|||
getter_AddRefs(sheet));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!mSheets[aSheetType].AppendObject(sheet)) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mSheets[aSheetType].AppendElement(sheet);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -275,8 +273,8 @@ nsStyleSheetService::UnregisterSheet(nsIURI *aSheetURI, uint32_t aSheetType)
|
|||
|
||||
int32_t foundIndex = FindSheetByURI(mSheets[aSheetType], aSheetURI);
|
||||
NS_ENSURE_TRUE(foundIndex >= 0, NS_ERROR_INVALID_ARG);
|
||||
nsCOMPtr<nsIStyleSheet> sheet = mSheets[aSheetType][foundIndex];
|
||||
mSheets[aSheetType].RemoveObjectAt(foundIndex);
|
||||
RefPtr<CSSStyleSheet> sheet = mSheets[aSheetType][foundIndex];
|
||||
mSheets[aSheetType].RemoveElementAt(foundIndex);
|
||||
|
||||
const char* message;
|
||||
switch (aSheetType) {
|
||||
|
@ -292,8 +290,10 @@ nsStyleSheetService::UnregisterSheet(nsIURI *aSheetURI, uint32_t aSheetType)
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> serv = services::GetObserverService();
|
||||
if (serv)
|
||||
serv->NotifyObservers(sheet, message, nullptr);
|
||||
if (serv) {
|
||||
serv->NotifyObservers(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, sheet),
|
||||
message, nullptr);
|
||||
}
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
nsTArray<dom::ContentParent*> children;
|
||||
|
@ -329,13 +329,6 @@ nsStyleSheetService::GetInstance()
|
|||
return gInstance;
|
||||
}
|
||||
|
||||
static size_t
|
||||
SizeOfElementIncludingThis(nsIStyleSheet* aElement,
|
||||
MallocSizeOf aMallocSizeOf, void *aData)
|
||||
{
|
||||
return aElement->SizeOfIncludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
MOZ_DEFINE_MALLOC_SIZE_OF(StyleSheetServiceMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -352,13 +345,11 @@ size_t
|
|||
nsStyleSheetService::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
size_t n = aMallocSizeOf(this);
|
||||
n += mSheets[AGENT_SHEET].SizeOfExcludingThis(SizeOfElementIncludingThis,
|
||||
aMallocSizeOf);
|
||||
n += mSheets[USER_SHEET].SizeOfExcludingThis(SizeOfElementIncludingThis,
|
||||
aMallocSizeOf);
|
||||
n += mSheets[AUTHOR_SHEET].SizeOfExcludingThis(SizeOfElementIncludingThis,
|
||||
aMallocSizeOf);
|
||||
for (auto& sheetArray : mSheets) {
|
||||
n += sheetArray.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
||||
for (CSSStyleSheet* sheet : sheetArray) {
|
||||
n += sheet->SizeOfIncludingThis(aMallocSizeOf);
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,13 +16,16 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
}
|
||||
class nsICategoryManager;
|
||||
class nsIMemoryReporter;
|
||||
class nsISimpleEnumerator;
|
||||
class nsIStyleSheet;
|
||||
|
||||
#define NS_STYLESHEETSERVICE_CID \
|
||||
{0xfcca6f83, 0x9f7d, 0x44e4, {0xa7, 0x4b, 0xb5, 0x94, 0x33, 0xe6, 0xc8, 0xc3}}
|
||||
{ 0x3b55e72e, 0xab7e, 0x431b, \
|
||||
{ 0x89, 0xc0, 0x3b, 0x06, 0xa8, 0xb1, 0x40, 0x16 } }
|
||||
|
||||
#define NS_STYLESHEETSERVICE_CONTRACTID \
|
||||
"@mozilla.org/content/style-sheet-service;1"
|
||||
|
@ -40,9 +43,18 @@ class nsStyleSheetService final
|
|||
|
||||
nsresult Init();
|
||||
|
||||
nsCOMArray<nsIStyleSheet>* AgentStyleSheets() { return &mSheets[AGENT_SHEET]; }
|
||||
nsCOMArray<nsIStyleSheet>* UserStyleSheets() { return &mSheets[USER_SHEET]; }
|
||||
nsCOMArray<nsIStyleSheet>* AuthorStyleSheets() { return &mSheets[AUTHOR_SHEET]; }
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>* AgentStyleSheets()
|
||||
{
|
||||
return &mSheets[AGENT_SHEET];
|
||||
}
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>* UserStyleSheets()
|
||||
{
|
||||
return &mSheets[USER_SHEET];
|
||||
}
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>* AuthorStyleSheets()
|
||||
{
|
||||
return &mSheets[AUTHOR_SHEET];
|
||||
}
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
|
||||
|
@ -57,15 +69,15 @@ class nsStyleSheetService final
|
|||
nsISimpleEnumerator *aEnumerator,
|
||||
uint32_t aSheetType);
|
||||
|
||||
int32_t FindSheetByURI(const nsCOMArray<nsIStyleSheet> &sheets,
|
||||
nsIURI *sheetURI);
|
||||
int32_t FindSheetByURI(const nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aSheets,
|
||||
nsIURI* aSheetURI);
|
||||
|
||||
// Like LoadAndRegisterSheet, but doesn't notify. If successful, the
|
||||
// new sheet will be the last sheet in mSheets[aSheetType].
|
||||
nsresult LoadAndRegisterSheetInternal(nsIURI *aSheetURI,
|
||||
uint32_t aSheetType);
|
||||
|
||||
nsCOMArray<nsIStyleSheet> mSheets[3];
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>> mSheets[3];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -74,7 +74,7 @@ inDOMUtils::GetAllStyleSheets(nsIDOMDocument *aDocument, uint32_t *aLength,
|
|||
{
|
||||
NS_ENSURE_ARG_POINTER(aDocument);
|
||||
|
||||
nsCOMArray<nsIStyleSheet> sheets;
|
||||
nsTArray<RefPtr<CSSStyleSheet>> sheets;
|
||||
|
||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(aDocument);
|
||||
MOZ_ASSERT(document);
|
||||
|
@ -109,14 +109,14 @@ inDOMUtils::GetAllStyleSheets(nsIDOMDocument *aDocument, uint32_t *aLength,
|
|||
sheets.AppendElement(document->GetStyleSheetAt(i));
|
||||
}
|
||||
|
||||
nsISupports** ret = static_cast<nsISupports**>(moz_xmalloc(sheets.Count() *
|
||||
nsISupports** ret = static_cast<nsISupports**>(moz_xmalloc(sheets.Length() *
|
||||
sizeof(nsISupports*)));
|
||||
|
||||
for (int32_t i = 0; i < sheets.Count(); i++) {
|
||||
NS_ADDREF(ret[i] = sheets[i]);
|
||||
for (size_t i = 0; i < sheets.Length(); i++) {
|
||||
NS_ADDREF(ret[i] = NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, sheets[i]));
|
||||
}
|
||||
|
||||
*aLength = sheets.Count();
|
||||
*aLength = sheets.Length();
|
||||
*aSheets = ret;
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -1253,7 +1253,7 @@ CSSStyleSheet::TraverseInner(nsCycleCollectionTraversalCallback &cb)
|
|||
RefPtr<CSSStyleSheet>* childSheetSlot = &mInner->mFirstChild;
|
||||
while (*childSheetSlot) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "child sheet");
|
||||
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIStyleSheet*, childSheetSlot->get()));
|
||||
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, childSheetSlot->get()));
|
||||
childSheetSlot = &(*childSheetSlot)->mNext;
|
||||
}
|
||||
|
||||
|
@ -1267,11 +1267,10 @@ CSSStyleSheet::TraverseInner(nsCycleCollectionTraversalCallback &cb)
|
|||
// QueryInterface implementation for CSSStyleSheet
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSStyleSheet)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStyleSheet)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMStyleSheet)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleSheet)
|
||||
NS_INTERFACE_MAP_ENTRY(nsICSSLoaderObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleSheet)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMCSSStyleSheet)
|
||||
if (aIID.Equals(NS_GET_IID(CSSStyleSheet)))
|
||||
foundInterface = reinterpret_cast<nsISupports*>(this);
|
||||
else
|
||||
|
@ -1371,19 +1370,19 @@ CSSStyleSheet::SetPrincipal(nsIPrincipal* aPrincipal)
|
|||
}
|
||||
}
|
||||
|
||||
/* virtual */ nsIURI*
|
||||
nsIURI*
|
||||
CSSStyleSheet::GetSheetURI() const
|
||||
{
|
||||
return mInner->mSheetURI;
|
||||
}
|
||||
|
||||
/* virtual */ nsIURI*
|
||||
nsIURI*
|
||||
CSSStyleSheet::GetBaseURI() const
|
||||
{
|
||||
return mInner->mBaseURI;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
void
|
||||
CSSStyleSheet::GetType(nsString& aType) const
|
||||
{
|
||||
aType.AssignLiteral("text/css");
|
||||
|
@ -1406,19 +1405,19 @@ CSSStyleSheet::SetMedia(nsMediaList* aMedia)
|
|||
mMedia = aMedia;
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
bool
|
||||
CSSStyleSheet::HasRules() const
|
||||
{
|
||||
return StyleRuleCount() != 0;
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
bool
|
||||
CSSStyleSheet::IsApplicable() const
|
||||
{
|
||||
return !mDisabled && mInner->mComplete;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
void
|
||||
CSSStyleSheet::SetEnabled(bool aEnabled)
|
||||
{
|
||||
// Internal method, so callers must handle BeginUpdate/EndUpdate
|
||||
|
@ -1434,13 +1433,13 @@ CSSStyleSheet::SetEnabled(bool aEnabled)
|
|||
}
|
||||
}
|
||||
|
||||
/* virtual */ bool
|
||||
bool
|
||||
CSSStyleSheet::IsComplete() const
|
||||
{
|
||||
return mInner->mComplete;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
void
|
||||
CSSStyleSheet::SetComplete()
|
||||
{
|
||||
NS_ASSERTION(!mDirty, "Can't set a dirty sheet complete!");
|
||||
|
@ -1460,19 +1459,19 @@ CSSStyleSheet::SetComplete()
|
|||
}
|
||||
}
|
||||
|
||||
/* virtual */ nsIStyleSheet*
|
||||
CSSStyleSheet*
|
||||
CSSStyleSheet::GetParentSheet() const
|
||||
{
|
||||
return mParent;
|
||||
}
|
||||
|
||||
/* virtual */ nsIDocument*
|
||||
nsIDocument*
|
||||
CSSStyleSheet::GetOwningDocument() const
|
||||
{
|
||||
return mDocument;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
void
|
||||
CSSStyleSheet::SetOwningDocument(nsIDocument* aDocument)
|
||||
{ // not ref counted
|
||||
mDocument = aDocument;
|
||||
|
@ -1500,12 +1499,9 @@ CSSStyleSheet::FindOwningWindowInnerID() const
|
|||
}
|
||||
|
||||
if (windowID == 0 && mOwnerRule) {
|
||||
nsCOMPtr<nsIStyleSheet> sheet = static_cast<css::Rule*>(mOwnerRule)->GetStyleSheet();
|
||||
RefPtr<CSSStyleSheet> sheet = static_cast<css::Rule*>(mOwnerRule)->GetStyleSheet();
|
||||
if (sheet) {
|
||||
RefPtr<CSSStyleSheet> cssSheet = do_QueryObject(sheet);
|
||||
if (cssSheet) {
|
||||
windowID = cssSheet->FindOwningWindowInnerID();
|
||||
}
|
||||
windowID = sheet->FindOwningWindowInnerID();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1638,7 +1634,7 @@ struct ListEnumData {
|
|||
int32_t mIndent;
|
||||
};
|
||||
|
||||
/* virtual */ void
|
||||
void
|
||||
CSSStyleSheet::List(FILE* out, int32_t aIndent) const
|
||||
{
|
||||
|
||||
|
@ -1831,7 +1827,7 @@ CSSStyleSheet::GetHref(nsAString& aHref)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
void
|
||||
CSSStyleSheet::GetTitle(nsString& aTitle) const
|
||||
{
|
||||
aTitle = mTitle;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "nscore.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "nsIDOMCSSStyleSheet.h"
|
||||
#include "nsICSSLoaderObserver.h"
|
||||
#include "nsTArrayForwardDeclare.h"
|
||||
|
@ -112,14 +111,13 @@ private:
|
|||
//
|
||||
|
||||
// CID for the CSSStyleSheet class
|
||||
// ca926f30-2a7e-477e-8467-803fb32af20a
|
||||
// 7985c7ac-9ddc-444d-9899-0c86ec122f54
|
||||
#define NS_CSS_STYLE_SHEET_IMPL_CID \
|
||||
{ 0xca926f30, 0x2a7e, 0x477e, \
|
||||
{ 0x84, 0x67, 0x80, 0x3f, 0xb3, 0x2a, 0xf2, 0x0a } }
|
||||
{ 0x7985c7ac, 0x9ddc, 0x444d, \
|
||||
{ 0x98, 0x99, 0x0c, 0x86, 0xec, 0x12, 0x2f, 0x54 } }
|
||||
|
||||
|
||||
class CSSStyleSheet final : public nsIStyleSheet,
|
||||
public nsIDOMCSSStyleSheet,
|
||||
class CSSStyleSheet final : public nsIDOMCSSStyleSheet,
|
||||
public nsICSSLoaderObserver,
|
||||
public nsWrapperCache
|
||||
{
|
||||
|
@ -131,28 +129,50 @@ public:
|
|||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(CSSStyleSheet,
|
||||
nsIStyleSheet)
|
||||
nsIDOMCSSStyleSheet)
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_CSS_STYLE_SHEET_IMPL_CID)
|
||||
|
||||
// nsIStyleSheet interface
|
||||
virtual nsIURI* GetSheetURI() const override;
|
||||
virtual nsIURI* GetBaseURI() const override;
|
||||
virtual void GetTitle(nsString& aTitle) const override;
|
||||
virtual void GetType(nsString& aType) const override;
|
||||
virtual bool HasRules() const override;
|
||||
virtual bool IsApplicable() const override;
|
||||
virtual void SetEnabled(bool aEnabled) override;
|
||||
virtual bool IsComplete() const override;
|
||||
virtual void SetComplete() override;
|
||||
virtual nsIStyleSheet* GetParentSheet() const override; // may be null
|
||||
virtual nsIDocument* GetOwningDocument() const override; // may be null
|
||||
virtual void SetOwningDocument(nsIDocument* aDocument) override;
|
||||
nsIURI* GetSheetURI() const;
|
||||
nsIURI* GetBaseURI() const;
|
||||
void GetTitle(nsString& aTitle) const;
|
||||
void GetType(nsString& aType) const;
|
||||
bool HasRules() const;
|
||||
|
||||
/**
|
||||
* Whether the sheet is applicable. A sheet that is not applicable
|
||||
* should never be inserted into a style set. A sheet may not be
|
||||
* applicable for a variety of reasons including being disabled and
|
||||
* being incomplete.
|
||||
*/
|
||||
bool IsApplicable() const;
|
||||
|
||||
/**
|
||||
* Set the stylesheet to be enabled. This may or may not make it
|
||||
* applicable. Note that this WILL inform the sheet's document of
|
||||
* its new applicable state if the state changes but WILL NOT call
|
||||
* BeginUpdate() or EndUpdate() on the document -- calling those is
|
||||
* the caller's responsibility. This allows use of SetEnabled when
|
||||
* batched updates are desired. If you want updates handled for
|
||||
* you, see nsIDOMStyleSheet::SetDisabled().
|
||||
*/
|
||||
void SetEnabled(bool aEnabled);
|
||||
|
||||
/**
|
||||
* Whether the sheet is complete.
|
||||
*/
|
||||
bool IsComplete() const;
|
||||
void SetComplete();
|
||||
|
||||
// style sheet owner info
|
||||
CSSStyleSheet* GetParentSheet() const; // may be null
|
||||
nsIDocument* GetOwningDocument() const; // may be null
|
||||
void SetOwningDocument(nsIDocument* aDocument);
|
||||
|
||||
// Find the ID of the owner inner window.
|
||||
uint64_t FindOwningWindowInnerID() const;
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
|
||||
void List(FILE* out = stdout, int32_t aIndent = 0) const;
|
||||
#endif
|
||||
|
||||
void AppendStyleSheet(CSSStyleSheet* aSheet);
|
||||
|
@ -250,7 +270,7 @@ public:
|
|||
// list after we clone a unique inner for ourselves.
|
||||
static bool RebuildChildList(css::Rule* aRule, void* aBuilder);
|
||||
|
||||
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
|
||||
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
||||
|
||||
// Get this style sheet's CORS mode
|
||||
CORSMode GetCORSMode() const { return mInner->mCORSMode; }
|
||||
|
@ -268,7 +288,7 @@ public:
|
|||
}
|
||||
|
||||
// WebIDL StyleSheet API
|
||||
// Our nsIStyleSheet::GetType is a const method, so it ends up
|
||||
// Our CSSStyleSheet::GetType is a const method, so it ends up
|
||||
// ambiguous with with the XPCOM version. Just disambiguate.
|
||||
void GetType(nsString& aType) {
|
||||
const_cast<const CSSStyleSheet*>(this)->GetType(aType);
|
||||
|
@ -276,7 +296,7 @@ public:
|
|||
// Our XPCOM GetHref is fine for WebIDL
|
||||
nsINode* GetOwnerNode() const { return mOwningNode; }
|
||||
CSSStyleSheet* GetParentStyleSheet() const { return mParent; }
|
||||
// Our nsIStyleSheet::GetTitle is a const method, so it ends up
|
||||
// Our CSSStyleSheet::GetTitle is a const method, so it ends up
|
||||
// ambiguous with with the XPCOM version. Just disambiguate.
|
||||
void GetTitle(nsString& aTitle) {
|
||||
const_cast<const CSSStyleSheet*>(this)->GetTitle(aTitle);
|
||||
|
@ -307,7 +327,7 @@ public:
|
|||
return dom::ParentObject(mOwningNode);
|
||||
}
|
||||
|
||||
return dom::ParentObject(static_cast<nsIStyleSheet*>(mParent), mParent);
|
||||
return dom::ParentObject(static_cast<nsIDOMCSSStyleSheet*>(mParent), mParent);
|
||||
}
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
|
|
|
@ -1348,12 +1348,10 @@ Loader::InsertSheetInDoc(CSSStyleSheet* aSheet,
|
|||
*/
|
||||
int32_t insertionPoint;
|
||||
for (insertionPoint = sheetCount - 1; insertionPoint >= 0; --insertionPoint) {
|
||||
nsIStyleSheet *curSheet = aDocument->GetStyleSheetAt(insertionPoint);
|
||||
CSSStyleSheet* curSheet = aDocument->GetStyleSheetAt(insertionPoint);
|
||||
NS_ASSERTION(curSheet, "There must be a sheet here!");
|
||||
nsCOMPtr<nsIDOMStyleSheet> domSheet = do_QueryInterface(curSheet);
|
||||
NS_ASSERTION(domSheet, "All the \"normal\" sheets implement nsIDOMStyleSheet");
|
||||
nsCOMPtr<nsIDOMNode> sheetOwner;
|
||||
domSheet->GetOwnerNode(getter_AddRefs(sheetOwner));
|
||||
curSheet->GetOwnerNode(getter_AddRefs(sheetOwner));
|
||||
if (sheetOwner && !aLinkingContent) {
|
||||
// Keep moving; all sheets with a sheetOwner come after all
|
||||
// sheets without a linkingNode
|
||||
|
@ -2608,7 +2606,7 @@ 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(nsIStyleSheet*, iter.UserData()));
|
||||
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, iter.UserData()));
|
||||
}
|
||||
}
|
||||
nsTObserverArray<nsCOMPtr<nsICSSLoaderObserver>>::ForwardIterator
|
||||
|
|
|
@ -62,7 +62,6 @@ EXPORTS += [
|
|||
'nsICSSStyleRuleDOMWrapper.h',
|
||||
'nsIStyleRule.h',
|
||||
'nsIStyleRuleProcessor.h',
|
||||
'nsIStyleSheet.h',
|
||||
'nsLayoutStylesheetCache.h',
|
||||
'nsRuleData.h',
|
||||
'nsRuleNode.h',
|
||||
|
|
|
@ -292,9 +292,8 @@ nsDOMCSSDeclaration::RemoveProperty(const nsAString& aPropertyName,
|
|||
nsDOMCSSDeclaration::GetCSSParsingEnvironmentForRule(css::Rule* aRule,
|
||||
CSSParsingEnvironment& aCSSParseEnv)
|
||||
{
|
||||
nsIStyleSheet* sheet = aRule ? aRule->GetStyleSheet() : nullptr;
|
||||
RefPtr<CSSStyleSheet> cssSheet(do_QueryObject(sheet));
|
||||
if (!cssSheet) {
|
||||
CSSStyleSheet* sheet = aRule ? aRule->GetStyleSheet() : nullptr;
|
||||
if (!sheet) {
|
||||
aCSSParseEnv.mPrincipal = nullptr;
|
||||
return;
|
||||
}
|
||||
|
@ -302,7 +301,7 @@ nsDOMCSSDeclaration::GetCSSParsingEnvironmentForRule(css::Rule* aRule,
|
|||
nsIDocument* document = sheet->GetOwningDocument();
|
||||
aCSSParseEnv.mSheetURI = sheet->GetSheetURI();
|
||||
aCSSParseEnv.mBaseURI = sheet->GetBaseURI();
|
||||
aCSSParseEnv.mPrincipal = cssSheet->Principal();
|
||||
aCSSParseEnv.mPrincipal = sheet->Principal();
|
||||
aCSSParseEnv.mCSSLoader = document ? document->CSSLoader() : nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; 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/. */
|
||||
|
||||
/*
|
||||
* interface representing a collection of style data attached to a
|
||||
* document, which may be or be combined into a style rule processor
|
||||
*/
|
||||
|
||||
#ifndef nsIStyleSheet_h___
|
||||
#define nsIStyleSheet_h___
|
||||
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include <stdio.h>
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsString;
|
||||
class nsIURI;
|
||||
class nsIDocument;
|
||||
|
||||
// IID for the nsIStyleSheet interface
|
||||
// 3eb34a60-04bd-41d9-9f60-882694e61c38
|
||||
#define NS_ISTYLE_SHEET_IID \
|
||||
{ 0x3eb34a60, 0x04bd, 0x41d9, \
|
||||
{ 0x9f, 0x60, 0x88, 0x26, 0x94, 0xe6, 0x1c, 0x38 } }
|
||||
|
||||
/**
|
||||
* A style sheet is a thing associated with a document that has style
|
||||
* rules. Those style rules can be reached in one of two ways, depending
|
||||
* on which level of the nsStyleSet it is in:
|
||||
* 1) It can be |QueryInterface|d to nsIStyleRuleProcessor
|
||||
* 2) It can be |QueryInterface|d to CSSStyleSheet, with which the
|
||||
* |nsStyleSet| uses an |nsCSSRuleProcessor| to access the rules.
|
||||
*/
|
||||
class nsIStyleSheet : public nsISupports {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLE_SHEET_IID)
|
||||
|
||||
// basic style sheet data
|
||||
virtual nsIURI* GetSheetURI() const = 0;
|
||||
virtual nsIURI* GetBaseURI() const = 0;
|
||||
virtual void GetTitle(nsString& aTitle) const = 0;
|
||||
virtual void GetType(nsString& aType) const = 0;
|
||||
virtual bool HasRules() const = 0;
|
||||
|
||||
/**
|
||||
* Whether the sheet is applicable. A sheet that is not applicable
|
||||
* should never be inserted into a style set. A sheet may not be
|
||||
* applicable for a variety of reasons including being disabled and
|
||||
* being incomplete.
|
||||
*
|
||||
*/
|
||||
virtual bool IsApplicable() const = 0;
|
||||
|
||||
/**
|
||||
* Set the stylesheet to be enabled. This may or may not make it
|
||||
* applicable. Note that this WILL inform the sheet's document of
|
||||
* its new applicable state if the state changes but WILL NOT call
|
||||
* BeginUpdate() or EndUpdate() on the document -- calling those is
|
||||
* the caller's responsibility. This allows use of SetEnabled when
|
||||
* batched updates are desired. If you want updates handled for
|
||||
* you, see nsIDOMStyleSheet::SetDisabled().
|
||||
*/
|
||||
virtual void SetEnabled(bool aEnabled) = 0;
|
||||
|
||||
/**
|
||||
* Whether the sheet is complete.
|
||||
*/
|
||||
virtual bool IsComplete() const = 0;
|
||||
virtual void SetComplete() = 0;
|
||||
|
||||
// style sheet owner info
|
||||
virtual nsIStyleSheet* GetParentSheet() const = 0; // may be null
|
||||
virtual nsIDocument* GetOwningDocument() const = 0; // may be null
|
||||
virtual void SetOwningDocument(nsIDocument* aDocument) = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const = 0;
|
||||
#endif
|
||||
|
||||
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleSheet, NS_ISTYLE_SHEET_IID)
|
||||
|
||||
#endif /* nsIStyleSheet_h___ */
|
|
@ -197,8 +197,8 @@ nsStyleSet::nsStyleSet()
|
|||
nsStyleSet::~nsStyleSet()
|
||||
{
|
||||
for (SheetType type : gCSSSheetTypes) {
|
||||
for (uint32_t i = 0, n = mSheets[type].Length(); i < n; i++) {
|
||||
static_cast<CSSStyleSheet*>(mSheets[type][i])->DropStyleSet(this);
|
||||
for (CSSStyleSheet* sheet : mSheets[type]) {
|
||||
sheet->DropStyleSet(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,12 +234,9 @@ nsStyleSet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
|||
n += mRuleProcessors[type]->SizeOfIncludingThis(aMallocSizeOf);
|
||||
}
|
||||
}
|
||||
// mSheets is a C-style array of nsCOMArrays. We do not own the sheets in
|
||||
// the nsCOMArrays (either the nsLayoutStyleSheetCache singleton or our
|
||||
// document owns them) so we do not count the sheets here (we pass nullptr
|
||||
// as the aSizeOfElementIncludingThis argument). All we're doing here is
|
||||
// counting the size of the nsCOMArrays' buffers.
|
||||
n += mSheets[type].SizeOfExcludingThis(nullptr, aMallocSizeOf);
|
||||
// We don't own the sheets (either the nsLayoutStyleSheetCache singleton
|
||||
// or our document owns them).
|
||||
n += mSheets[type].ShallowSizeOfExcludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++) {
|
||||
|
@ -450,8 +447,7 @@ nsStyleSet::GatherRuleProcessors(SheetType aType)
|
|||
return NS_OK;
|
||||
}
|
||||
switch (aType) {
|
||||
// handle the types for which have a rule processor that does not
|
||||
// implement the style sheet interface.
|
||||
// levels that do not contain CSS style sheets
|
||||
case SheetType::Animation:
|
||||
MOZ_ASSERT(mSheets[aType].IsEmpty());
|
||||
mRuleProcessors[aType] = PresContext()->AnimationManager();
|
||||
|
@ -478,17 +474,16 @@ nsStyleSet::GatherRuleProcessors(SheetType aType)
|
|||
// keep going
|
||||
break;
|
||||
}
|
||||
MOZ_ASSERT(IsCSSSheetType(aType));
|
||||
if (aType == SheetType::ScopedDoc) {
|
||||
// Create a rule processor for each scope.
|
||||
uint32_t count = mSheets[SheetType::ScopedDoc].Count();
|
||||
uint32_t count = mSheets[SheetType::ScopedDoc].Length();
|
||||
if (count) {
|
||||
// Gather the scoped style sheets into an array as
|
||||
// CSSStyleSheets, and mark all of their scope elements
|
||||
// as scoped style roots.
|
||||
nsTArray<CSSStyleSheet*> sheets(count);
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
RefPtr<CSSStyleSheet> sheet =
|
||||
do_QueryObject(mSheets[SheetType::ScopedDoc].ObjectAt(i));
|
||||
for (CSSStyleSheet* sheet : mSheets[SheetType::ScopedDoc]) {
|
||||
sheets.AppendElement(sheet);
|
||||
|
||||
Element* scope = sheet->GetScopeElement();
|
||||
|
@ -537,27 +532,20 @@ nsStyleSet::GatherRuleProcessors(SheetType aType)
|
|||
}
|
||||
return NS_OK;
|
||||
}
|
||||
if (mSheets[aType].Count()) {
|
||||
if (!mSheets[aType].IsEmpty()) {
|
||||
switch (aType) {
|
||||
case SheetType::Agent:
|
||||
case SheetType::User: {
|
||||
// levels containing non-scoped CSS style sheets whose rule processors
|
||||
// we want to re-use
|
||||
nsCOMArray<nsIStyleSheet>& sheets = mSheets[aType];
|
||||
nsTArray<RefPtr<CSSStyleSheet>> cssSheets(sheets.Count());
|
||||
for (int32_t i = 0, i_end = sheets.Count(); i < i_end; ++i) {
|
||||
RefPtr<CSSStyleSheet> cssSheet = do_QueryObject(sheets[i]);
|
||||
NS_ASSERTION(cssSheet, "not a CSS sheet");
|
||||
cssSheets.AppendElement(cssSheet);
|
||||
}
|
||||
nsTArray<CSSStyleSheet*> cssSheetsRaw(cssSheets.Length());
|
||||
for (int32_t i = 0, i_end = cssSheets.Length(); i < i_end; ++i) {
|
||||
cssSheetsRaw.AppendElement(cssSheets[i]);
|
||||
nsTArray<CSSStyleSheet*> sheets(mSheets[aType].Length());
|
||||
for (CSSStyleSheet* sheet : mSheets[aType]) {
|
||||
sheets.AppendElement(sheet);
|
||||
}
|
||||
nsCSSRuleProcessor* rp =
|
||||
RuleProcessorCache::GetRuleProcessor(cssSheetsRaw, PresContext());
|
||||
RuleProcessorCache::GetRuleProcessor(sheets, PresContext());
|
||||
if (!rp) {
|
||||
rp = new nsCSSRuleProcessor(cssSheets, aType, nullptr,
|
||||
rp = new nsCSSRuleProcessor(mSheets[aType], aType, nullptr,
|
||||
static_cast<nsCSSRuleProcessor*>(
|
||||
oldRuleProcessor.get()),
|
||||
true /* aIsShared */);
|
||||
|
@ -565,7 +553,7 @@ nsStyleSet::GatherRuleProcessors(SheetType aType)
|
|||
nsDocumentRuleResultCacheKey cacheKey;
|
||||
rp->TakeDocumentRulesAndCacheKey(PresContext(),
|
||||
documentRules, cacheKey);
|
||||
RuleProcessorCache::PutRuleProcessor(cssSheetsRaw,
|
||||
RuleProcessorCache::PutRuleProcessor(sheets,
|
||||
Move(documentRules),
|
||||
cacheKey, rp);
|
||||
}
|
||||
|
@ -577,23 +565,14 @@ nsStyleSet::GatherRuleProcessors(SheetType aType)
|
|||
case SheetType::Override: {
|
||||
// levels containing non-scoped CSS stylesheets whose rule processors
|
||||
// we don't want to re-use
|
||||
nsCOMArray<nsIStyleSheet>& sheets = mSheets[aType];
|
||||
nsTArray<RefPtr<CSSStyleSheet>> cssSheets(sheets.Count());
|
||||
for (int32_t i = 0, i_end = sheets.Count(); i < i_end; ++i) {
|
||||
RefPtr<CSSStyleSheet> cssSheet = do_QueryObject(sheets[i]);
|
||||
NS_ASSERTION(cssSheet, "not a CSS sheet");
|
||||
cssSheets.AppendElement(cssSheet);
|
||||
}
|
||||
mRuleProcessors[aType] =
|
||||
new nsCSSRuleProcessor(cssSheets, aType, nullptr,
|
||||
new nsCSSRuleProcessor(mSheets[aType], aType, nullptr,
|
||||
static_cast<nsCSSRuleProcessor*>(
|
||||
oldRuleProcessor.get()));
|
||||
} break;
|
||||
|
||||
default:
|
||||
// levels containing non-CSS stylesheets
|
||||
NS_ASSERTION(mSheets[aType].Count() == 1, "only one sheet per level");
|
||||
mRuleProcessors[aType] = do_QueryInterface(mSheets[aType][0]);
|
||||
MOZ_ASSERT_UNREACHABLE("non-CSS sheet types should be handled above");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -601,58 +580,47 @@ nsStyleSet::GatherRuleProcessors(SheetType aType)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static bool
|
||||
IsScopedStyleSheet(nsIStyleSheet* aSheet)
|
||||
{
|
||||
RefPtr<CSSStyleSheet> cssSheet = do_QueryObject(aSheet);
|
||||
NS_ASSERTION(cssSheet, "expected aSheet to be a CSSStyleSheet");
|
||||
|
||||
return cssSheet->GetScopeElement();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsStyleSet::AppendStyleSheet(SheetType aType, nsIStyleSheet *aSheet)
|
||||
nsStyleSet::AppendStyleSheet(SheetType aType, CSSStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null arg");
|
||||
NS_ASSERTION(aSheet->IsApplicable(),
|
||||
"Inapplicable sheet being placed in style set");
|
||||
bool present = mSheets[aType].RemoveObject(aSheet);
|
||||
if (!mSheets[aType].AppendObject(aSheet))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
bool present = mSheets[aType].RemoveElement(aSheet);
|
||||
mSheets[aType].AppendElement(aSheet);
|
||||
|
||||
if (!present && IsCSSSheetType(aType)) {
|
||||
static_cast<CSSStyleSheet*>(aSheet)->AddStyleSet(this);
|
||||
aSheet->AddStyleSet(this);
|
||||
}
|
||||
|
||||
return DirtyRuleProcessors(aType);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsStyleSet::PrependStyleSheet(SheetType aType, nsIStyleSheet *aSheet)
|
||||
nsStyleSet::PrependStyleSheet(SheetType aType, CSSStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null arg");
|
||||
NS_ASSERTION(aSheet->IsApplicable(),
|
||||
"Inapplicable sheet being placed in style set");
|
||||
bool present = mSheets[aType].RemoveObject(aSheet);
|
||||
if (!mSheets[aType].InsertObjectAt(aSheet, 0))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
bool present = mSheets[aType].RemoveElement(aSheet);
|
||||
mSheets[aType].InsertElementAt(0, aSheet);
|
||||
|
||||
if (!present && IsCSSSheetType(aType)) {
|
||||
static_cast<CSSStyleSheet*>(aSheet)->AddStyleSet(this);
|
||||
aSheet->AddStyleSet(this);
|
||||
}
|
||||
|
||||
return DirtyRuleProcessors(aType);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsStyleSet::RemoveStyleSheet(SheetType aType, nsIStyleSheet *aSheet)
|
||||
nsStyleSet::RemoveStyleSheet(SheetType aType, CSSStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null arg");
|
||||
NS_ASSERTION(aSheet->IsComplete(),
|
||||
"Incomplete sheet being removed from style set");
|
||||
if (mSheets[aType].RemoveObject(aSheet)) {
|
||||
if (mSheets[aType].RemoveElement(aSheet)) {
|
||||
if (IsCSSSheetType(aType)) {
|
||||
static_cast<CSSStyleSheet*>(aSheet)->DropStyleSet(this);
|
||||
aSheet->DropStyleSet(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -661,22 +629,21 @@ nsStyleSet::RemoveStyleSheet(SheetType aType, nsIStyleSheet *aSheet)
|
|||
|
||||
nsresult
|
||||
nsStyleSet::ReplaceSheets(SheetType aType,
|
||||
const nsCOMArray<nsIStyleSheet> &aNewSheets)
|
||||
const nsTArray<RefPtr<CSSStyleSheet>>& aNewSheets)
|
||||
{
|
||||
bool cssSheetType = IsCSSSheetType(aType);
|
||||
if (cssSheetType) {
|
||||
for (uint32_t i = 0, n = mSheets[aType].Length(); i < n; i++) {
|
||||
static_cast<CSSStyleSheet*>(mSheets[aType][i])->DropStyleSet(this);
|
||||
for (CSSStyleSheet* sheet : mSheets[aType]) {
|
||||
sheet->DropStyleSet(this);
|
||||
}
|
||||
}
|
||||
|
||||
mSheets[aType].Clear();
|
||||
if (!mSheets[aType].AppendObjects(aNewSheets))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
mSheets[aType].AppendElements(aNewSheets);
|
||||
|
||||
if (cssSheetType) {
|
||||
for (uint32_t i = 0, n = mSheets[aType].Length(); i < n; i++) {
|
||||
static_cast<CSSStyleSheet*>(mSheets[aType][i])->AddStyleSet(this);
|
||||
for (CSSStyleSheet* sheet : mSheets[aType]) {
|
||||
sheet->AddStyleSet(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -684,23 +651,22 @@ nsStyleSet::ReplaceSheets(SheetType aType,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsStyleSet::InsertStyleSheetBefore(SheetType aType, nsIStyleSheet *aNewSheet,
|
||||
nsIStyleSheet *aReferenceSheet)
|
||||
nsStyleSet::InsertStyleSheetBefore(SheetType aType, CSSStyleSheet* aNewSheet,
|
||||
CSSStyleSheet* aReferenceSheet)
|
||||
{
|
||||
NS_PRECONDITION(aNewSheet && aReferenceSheet, "null arg");
|
||||
NS_ASSERTION(aNewSheet->IsApplicable(),
|
||||
"Inapplicable sheet being placed in style set");
|
||||
|
||||
bool present = mSheets[aType].RemoveObject(aNewSheet);
|
||||
bool present = mSheets[aType].RemoveElement(aNewSheet);
|
||||
int32_t idx = mSheets[aType].IndexOf(aReferenceSheet);
|
||||
if (idx < 0)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
if (!mSheets[aType].InsertObjectAt(aNewSheet, idx))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
mSheets[aType].InsertElementAt(idx, aNewSheet);
|
||||
|
||||
if (!present && IsCSSSheetType(aType)) {
|
||||
static_cast<CSSStyleSheet*>(aNewSheet)->AddStyleSet(this);
|
||||
aNewSheet->AddStyleSet(this);
|
||||
}
|
||||
|
||||
return DirtyRuleProcessors(aType);
|
||||
|
@ -745,27 +711,27 @@ nsStyleSet::SetAuthorStyleDisabled(bool aStyleDisabled)
|
|||
// -------- Doc Sheets
|
||||
|
||||
nsresult
|
||||
nsStyleSet::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument)
|
||||
nsStyleSet::AddDocStyleSheet(CSSStyleSheet* aSheet, nsIDocument* aDocument)
|
||||
{
|
||||
NS_PRECONDITION(aSheet && aDocument, "null arg");
|
||||
NS_ASSERTION(aSheet->IsApplicable(),
|
||||
"Inapplicable sheet being placed in style set");
|
||||
|
||||
SheetType type = IsScopedStyleSheet(aSheet) ?
|
||||
SheetType type = aSheet->GetScopeElement() ?
|
||||
SheetType::ScopedDoc :
|
||||
SheetType::Doc;
|
||||
nsCOMArray<nsIStyleSheet>& sheets = mSheets[type];
|
||||
nsTArray<RefPtr<CSSStyleSheet>>& sheets = mSheets[type];
|
||||
|
||||
bool present = sheets.RemoveObject(aSheet);
|
||||
bool present = sheets.RemoveElement(aSheet);
|
||||
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
||||
|
||||
// lowest index first
|
||||
int32_t newDocIndex = aDocument->GetIndexOfStyleSheet(aSheet);
|
||||
|
||||
int32_t count = sheets.Count();
|
||||
int32_t count = sheets.Length();
|
||||
int32_t index;
|
||||
for (index = 0; index < count; index++) {
|
||||
nsIStyleSheet* sheet = sheets.ObjectAt(index);
|
||||
CSSStyleSheet* sheet = sheets[index];
|
||||
int32_t sheetDocIndex = aDocument->GetIndexOfStyleSheet(sheet);
|
||||
if (sheetDocIndex > newDocIndex)
|
||||
break;
|
||||
|
@ -774,27 +740,32 @@ nsStyleSet::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument)
|
|||
// sheet registered at nsStyleSheetService or an additional author
|
||||
// sheet on the document, which means the new
|
||||
// doc sheet should end up before it.
|
||||
if (sheetDocIndex < 0 &&
|
||||
((sheetService &&
|
||||
sheetService->AuthorStyleSheets()->IndexOf(sheet) >= 0) ||
|
||||
sheet == aDocument->FirstAdditionalAuthorSheet()))
|
||||
if (sheetDocIndex < 0) {
|
||||
if (sheetService) {
|
||||
auto& authorSheets = *sheetService->AuthorStyleSheets();
|
||||
if (authorSheets.IndexOf(sheet) != authorSheets.NoIndex) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sheet == aDocument->FirstAdditionalAuthorSheet()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!sheets.InsertObjectAt(aSheet, index))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
sheets.InsertElementAt(index, aSheet);
|
||||
|
||||
if (!present) {
|
||||
static_cast<CSSStyleSheet*>(aSheet)->AddStyleSet(this);
|
||||
aSheet->AddStyleSet(this);
|
||||
}
|
||||
|
||||
return DirtyRuleProcessors(type);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsStyleSet::RemoveDocStyleSheet(nsIStyleSheet *aSheet)
|
||||
nsStyleSet::RemoveDocStyleSheet(CSSStyleSheet* aSheet)
|
||||
{
|
||||
RefPtr<CSSStyleSheet> cssSheet = do_QueryObject(aSheet);
|
||||
bool isScoped = cssSheet && cssSheet->GetScopeElement();
|
||||
bool isScoped = aSheet->GetScopeElement();
|
||||
return RemoveStyleSheet(isScoped ? SheetType::ScopedDoc : SheetType::Doc,
|
||||
aSheet);
|
||||
}
|
||||
|
@ -2496,10 +2467,8 @@ bool
|
|||
nsStyleSet::EnsureUniqueInnerOnCSSSheets()
|
||||
{
|
||||
nsAutoTArray<CSSStyleSheet*, 32> queue;
|
||||
for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
|
||||
nsCOMArray<nsIStyleSheet> &sheets = mSheets[gCSSSheetTypes[i]];
|
||||
for (uint32_t j = 0, j_end = sheets.Count(); j < j_end; ++j) {
|
||||
CSSStyleSheet* sheet = static_cast<CSSStyleSheet*>(sheets[j]);
|
||||
for (SheetType type : gCSSSheetTypes) {
|
||||
for (CSSStyleSheet* sheet : mSheets[type]) {
|
||||
queue.AppendElement(sheet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ struct nsFontFaceRuleContainer;
|
|||
struct TreeMatchContext;
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
class EventStates;
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -311,25 +312,29 @@ class nsStyleSet final
|
|||
|
||||
// APIs to manipulate the style sheet lists. The sheets in each
|
||||
// list are stored with the most significant sheet last.
|
||||
nsresult AppendStyleSheet(mozilla::SheetType aType, nsIStyleSheet *aSheet);
|
||||
nsresult PrependStyleSheet(mozilla::SheetType aType, nsIStyleSheet *aSheet);
|
||||
nsresult RemoveStyleSheet(mozilla::SheetType aType, nsIStyleSheet *aSheet);
|
||||
nsresult AppendStyleSheet(mozilla::SheetType aType,
|
||||
mozilla::CSSStyleSheet* aSheet);
|
||||
nsresult PrependStyleSheet(mozilla::SheetType aType,
|
||||
mozilla::CSSStyleSheet* aSheet);
|
||||
nsresult RemoveStyleSheet(mozilla::SheetType aType,
|
||||
mozilla::CSSStyleSheet* aSheet);
|
||||
nsresult ReplaceSheets(mozilla::SheetType aType,
|
||||
const nsCOMArray<nsIStyleSheet> &aNewSheets);
|
||||
const nsTArray<RefPtr<mozilla::CSSStyleSheet>>& aNewSheets);
|
||||
nsresult InsertStyleSheetBefore(mozilla::SheetType aType,
|
||||
nsIStyleSheet *aNewSheet,
|
||||
nsIStyleSheet *aReferenceSheet);
|
||||
mozilla::CSSStyleSheet* aNewSheet,
|
||||
mozilla::CSSStyleSheet* aReferenceSheet);
|
||||
|
||||
// Enable/Disable entire author style level (Doc, ScopedDoc & PresHint levels)
|
||||
bool GetAuthorStyleDisabled();
|
||||
nsresult SetAuthorStyleDisabled(bool aStyleDisabled);
|
||||
|
||||
int32_t SheetCount(mozilla::SheetType aType) const {
|
||||
return mSheets[aType].Count();
|
||||
return mSheets[aType].Length();
|
||||
}
|
||||
|
||||
nsIStyleSheet* StyleSheetAt(mozilla::SheetType aType, int32_t aIndex) const {
|
||||
return mSheets[aType].ObjectAt(aIndex);
|
||||
mozilla::CSSStyleSheet* StyleSheetAt(mozilla::SheetType aType,
|
||||
int32_t aIndex) const {
|
||||
return mSheets[aType][aIndex];
|
||||
}
|
||||
|
||||
void AppendAllXBLStyleSheets(nsTArray<mozilla::CSSStyleSheet*>& aArray) const {
|
||||
|
@ -338,8 +343,9 @@ class nsStyleSet final
|
|||
}
|
||||
}
|
||||
|
||||
nsresult RemoveDocStyleSheet(nsIStyleSheet* aSheet);
|
||||
nsresult AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument);
|
||||
nsresult RemoveDocStyleSheet(mozilla::CSSStyleSheet* aSheet);
|
||||
nsresult AddDocStyleSheet(mozilla::CSSStyleSheet* aSheet,
|
||||
nsIDocument* aDocument);
|
||||
|
||||
void BeginUpdate();
|
||||
nsresult EndUpdate();
|
||||
|
@ -473,7 +479,7 @@ private:
|
|||
// eAnimationSheet and eSVGAttrAnimationSheet are always empty.
|
||||
// (FIXME: We should reduce the storage needed for them.)
|
||||
mozilla::EnumeratedArray<mozilla::SheetType, mozilla::SheetType::Count,
|
||||
nsCOMArray<nsIStyleSheet>> mSheets;
|
||||
nsTArray<RefPtr<mozilla::CSSStyleSheet>>> mSheets;
|
||||
|
||||
// mRuleProcessors[eScopedDocSheet] is always null; rule processors
|
||||
// for scoped style sheets are stored in mScopedDocSheetRuleProcessors.
|
||||
|
|
Загрузка…
Ссылка в новой задаче