Bug 1157292 - include XBL stylesheets in the inspector's list of stylesheets, r=dholbert,heycam

--HG--
extra : commitid : FaWwCEWPkKA
extra : rebase_source : 4d4568f1c30cb8d062106f71099e21a3c33f25ab
This commit is contained in:
Gijs Kruitbosch 2015-08-12 13:43:39 +01:00
parent aa7784428b
commit ecccf6ff1a
2 changed files with 19 additions and 2 deletions

View File

@ -73,12 +73,12 @@ inDOMUtils::GetAllStyleSheets(nsIDOMDocument *aDocument, uint32_t *aLength,
{
NS_ENSURE_ARG_POINTER(aDocument);
nsCOMArray<nsISupports> sheets;
nsCOMArray<nsIStyleSheet> sheets;
nsCOMPtr<nsIDocument> document = do_QueryInterface(aDocument);
MOZ_ASSERT(document);
// Get the agent, then user sheets in the style set.
// Get the agent, then user and finally xbl sheets in the style set.
nsIPresShell* presShell = document->GetShell();
if (presShell) {
nsStyleSet* styleSet = presShell->StyleSet();
@ -90,6 +90,17 @@ inDOMUtils::GetAllStyleSheets(nsIDOMDocument *aDocument, uint32_t *aLength,
for (int32_t i = 0; i < styleSet->SheetCount(sheetType); i++) {
sheets.AppendElement(styleSet->StyleSheetAt(sheetType, i));
}
nsAutoTArray<CSSStyleSheet*, 32> xblSheetArray;
styleSet->AppendAllXBLStyleSheets(xblSheetArray);
// The XBL stylesheet array will quite often be full of duplicates. Cope:
nsTHashtable<nsPtrHashKey<CSSStyleSheet>> sheetSet;
for (CSSStyleSheet* sheet : xblSheetArray) {
if (!sheetSet.Contains(sheet)) {
sheetSet.PutEntry(sheet);
sheets.AppendElement(sheet);
}
}
}
// Get the document sheets.

View File

@ -347,6 +347,12 @@ class nsStyleSet final
return mSheets[aType].ObjectAt(aIndex);
}
void AppendAllXBLStyleSheets(nsTArray<mozilla::CSSStyleSheet*>& aArray) const {
if (mBindingManager) {
mBindingManager->AppendAllSheets(aArray);
}
}
nsresult RemoveDocStyleSheet(nsIStyleSheet* aSheet);
nsresult AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument);