зеркало из https://github.com/mozilla/gecko-dev.git
Add method to nsStyleSet to call EnsureUniqueInner on all CSS sheets. (Bug 536379) r=bzbarsky
This commit is contained in:
Родитель
6eb5acc201
Коммит
305a488187
|
@ -1488,6 +1488,18 @@ nsCSSStyleSheet::EnsureUniqueInner()
|
|||
return eUniqueInner_ClonedInner;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsCSSStyleSheet::AppendAllChildSheets(nsTArray<nsCSSStyleSheet*>& aArray)
|
||||
{
|
||||
for (nsCSSStyleSheet* child = mInner->mFirstChild; child;
|
||||
child = child->mNext) {
|
||||
if (!aArray.AppendElement(child)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCSSStyleSheet::Clone(nsICSSStyleSheet* aCloneParent,
|
||||
nsICSSImportRule* aCloneOwnerRule,
|
||||
|
|
|
@ -183,6 +183,10 @@ public:
|
|||
};
|
||||
EnsureUniqueInnerResult EnsureUniqueInner();
|
||||
|
||||
// Append all of this sheet's child sheets to aArray. Return PR_TRUE
|
||||
// on success and PR_FALSE on allocation failure.
|
||||
PRBool AppendAllChildSheets(nsTArray<nsCSSStyleSheet*>& aArray);
|
||||
|
||||
PRBool UseForPresentation(nsPresContext* aPresContext,
|
||||
nsMediaQueryResultCacheKey& aKey) const;
|
||||
|
||||
|
|
|
@ -1161,3 +1161,41 @@ nsStyleSet::MediumFeaturesChanged(nsPresContext* aPresContext)
|
|||
|
||||
return stylesChanged;
|
||||
}
|
||||
|
||||
nsCSSStyleSheet::EnsureUniqueInnerResult
|
||||
nsStyleSet::EnsureUniqueInnerOnCSSSheets()
|
||||
{
|
||||
nsAutoTArray<nsCSSStyleSheet*, 32> queue;
|
||||
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(gCSSSheetTypes); ++i) {
|
||||
nsCOMArray<nsIStyleSheet> &sheets = mSheets[gCSSSheetTypes[i]];
|
||||
for (PRUint32 j = 0, j_end = sheets.Count(); j < j_end; ++j) {
|
||||
nsCSSStyleSheet *sheet = static_cast<nsCSSStyleSheet*>(sheets[j]);
|
||||
if (!queue.AppendElement(sheet)) {
|
||||
return nsCSSStyleSheet::eUniqueInner_CloneFailed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCSSStyleSheet::EnsureUniqueInnerResult res =
|
||||
nsCSSStyleSheet::eUniqueInner_AlreadyUnique;
|
||||
while (!queue.IsEmpty()) {
|
||||
PRUint32 idx = queue.Length() - 1;
|
||||
nsCSSStyleSheet *sheet = queue[idx];
|
||||
queue.RemoveElementAt(idx);
|
||||
|
||||
nsCSSStyleSheet::EnsureUniqueInnerResult sheetRes =
|
||||
sheet->EnsureUniqueInner();
|
||||
if (sheetRes == nsCSSStyleSheet::eUniqueInner_CloneFailed) {
|
||||
return sheetRes;
|
||||
}
|
||||
if (sheetRes == nsCSSStyleSheet::eUniqueInner_ClonedInner) {
|
||||
res = sheetRes;
|
||||
}
|
||||
|
||||
// Enqueue all the sheet's children.
|
||||
if (!sheet->AppendAllChildSheets(queue)) {
|
||||
return nsCSSStyleSheet::eUniqueInner_CloneFailed;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#define nsStyleSet_h_
|
||||
|
||||
#include "nsIStyleRuleProcessor.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsCSSStyleSheet.h"
|
||||
#include "nsBindingManager.h"
|
||||
#include "nsRuleNode.h"
|
||||
#include "nsTArray.h"
|
||||
|
@ -277,7 +277,9 @@ class nsStyleSet
|
|||
void RuleNodeInUse() {
|
||||
--mUnusedRuleNodeCount;
|
||||
}
|
||||
|
||||
|
||||
nsCSSStyleSheet::EnsureUniqueInnerResult EnsureUniqueInnerOnCSSSheets();
|
||||
|
||||
private:
|
||||
// Not to be implemented
|
||||
nsStyleSet(const nsStyleSet& aCopy);
|
||||
|
|
Загрузка…
Ссылка в новой задаче