From ecccf6ff1ab757d50f6f430d1f6d27352f19a1e4 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Wed, 12 Aug 2015 13:43:39 +0100 Subject: [PATCH] Bug 1157292 - include XBL stylesheets in the inspector's list of stylesheets, r=dholbert,heycam --HG-- extra : commitid : FaWwCEWPkKA extra : rebase_source : 4d4568f1c30cb8d062106f71099e21a3c33f25ab --- layout/inspector/inDOMUtils.cpp | 15 +++++++++++++-- layout/style/nsStyleSet.h | 6 ++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/layout/inspector/inDOMUtils.cpp b/layout/inspector/inDOMUtils.cpp index 9989be817f3d..3eb5b151297a 100644 --- a/layout/inspector/inDOMUtils.cpp +++ b/layout/inspector/inDOMUtils.cpp @@ -73,12 +73,12 @@ inDOMUtils::GetAllStyleSheets(nsIDOMDocument *aDocument, uint32_t *aLength, { NS_ENSURE_ARG_POINTER(aDocument); - nsCOMArray sheets; + nsCOMArray sheets; nsCOMPtr 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 xblSheetArray; + styleSet->AppendAllXBLStyleSheets(xblSheetArray); + + // The XBL stylesheet array will quite often be full of duplicates. Cope: + nsTHashtable> sheetSet; + for (CSSStyleSheet* sheet : xblSheetArray) { + if (!sheetSet.Contains(sheet)) { + sheetSet.PutEntry(sheet); + sheets.AppendElement(sheet); + } + } } // Get the document sheets. diff --git a/layout/style/nsStyleSet.h b/layout/style/nsStyleSet.h index 7d3e85a6dcd5..ff041525f13e 100644 --- a/layout/style/nsStyleSet.h +++ b/layout/style/nsStyleSet.h @@ -347,6 +347,12 @@ class nsStyleSet final return mSheets[aType].ObjectAt(aIndex); } + void AppendAllXBLStyleSheets(nsTArray& aArray) const { + if (mBindingManager) { + mBindingManager->AppendAllSheets(aArray); + } + } + nsresult RemoveDocStyleSheet(nsIStyleSheet* aSheet); nsresult AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument);