зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1427419 - Part 2: Move nsIDOMUtils.getAllStyleSheets to InspectorUtils. r=bz
MozReview-Commit-ID: J6lIx4uvMlS
This commit is contained in:
Родитель
563e7a0e4a
Коммит
04c11b322d
|
@ -16,6 +16,7 @@ const {mediaRuleSpec, styleSheetSpec,
|
|||
styleSheetsSpec} = require("devtools/shared/specs/stylesheets");
|
||||
const {
|
||||
addPseudoClassLock, removePseudoClassLock } = require("devtools/server/actors/highlighters/utils/markup");
|
||||
const InspectorUtils = require("InspectorUtils");
|
||||
|
||||
loader.lazyRequireGetter(this, "CssLogic", "devtools/shared/inspector/css-logic");
|
||||
loader.lazyRequireGetter(this, "addPseudoClassLock",
|
||||
|
@ -805,7 +806,8 @@ var StyleSheetsActor = protocol.ActorClassWithSpec(styleSheetsSpec, {
|
|||
doc.styleSheetChangeEventsEnabled = true;
|
||||
|
||||
let isChrome = Services.scriptSecurityManager.isSystemPrincipal(doc.nodePrincipal);
|
||||
let styleSheets = isChrome ? DOMUtils.getAllStyleSheets(doc) : doc.styleSheets;
|
||||
let styleSheets =
|
||||
isChrome ? InspectorUtils.getAllStyleSheets(doc) : doc.styleSheets;
|
||||
let actors = [];
|
||||
for (let i = 0; i < styleSheets.length; i++) {
|
||||
let sheet = styleSheets[i];
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
const authorUrl = "chrome://mochikit/content/tests/SimpleTest/test.css";
|
||||
|
||||
let results = [];
|
||||
for (let sheet of domutils.getAllStyleSheets(document)) {
|
||||
for (let sheet of InspectorUtils.getAllStyleSheets(document)) {
|
||||
if (sheet.href === agentUrl) {
|
||||
is(sheet.parsingMode, "agent", "agent sheet has expected mode");
|
||||
results[sss.AGENT_SHEET] = 1;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
[ChromeOnly]
|
||||
namespace InspectorUtils {
|
||||
sequence<StyleSheet> getAllStyleSheets(Document document);
|
||||
};
|
||||
|
||||
dictionary InspectorRGBTriple {
|
||||
|
|
|
@ -8,6 +8,14 @@
|
|||
#ifndef mozilla_dom_InspectorUtils_h
|
||||
#define mozilla_dom_InspectorUtils_h
|
||||
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
|
||||
class nsIDocument;
|
||||
|
||||
namespace mozilla {
|
||||
class StyleSheet;
|
||||
} // namespace mozilla
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
@ -16,6 +24,10 @@ namespace dom {
|
|||
*/
|
||||
class InspectorUtils
|
||||
{
|
||||
public:
|
||||
static void GetAllStyleSheets(GlobalObject& aGlobal,
|
||||
nsIDocument& aDocument,
|
||||
nsTArray<RefPtr<StyleSheet>>& aResult);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "mozilla/ServoStyleRule.h"
|
||||
#include "mozilla/ServoStyleRuleMap.h"
|
||||
#include "mozilla/ServoCSSParser.h"
|
||||
#include "mozilla/dom/InspectorUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::css;
|
||||
|
@ -74,29 +75,26 @@ NS_IMPL_ISUPPORTS(inDOMUtils, inIDOMUtils)
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// inIDOMUtils
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDOMUtils::GetAllStyleSheets(nsIDOMDocument *aDocument, uint32_t *aLength,
|
||||
nsISupports ***aSheets)
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/* static */ void
|
||||
InspectorUtils::GetAllStyleSheets(GlobalObject& aGlobalObject,
|
||||
nsIDocument& aDocument,
|
||||
nsTArray<RefPtr<StyleSheet>>& aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDocument);
|
||||
|
||||
nsTArray<RefPtr<StyleSheet>> sheets;
|
||||
|
||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(aDocument);
|
||||
MOZ_ASSERT(document);
|
||||
|
||||
// Get the agent, then user and finally xbl sheets in the style set.
|
||||
nsIPresShell* presShell = document->GetShell();
|
||||
nsIPresShell* presShell = aDocument.GetShell();
|
||||
|
||||
if (presShell) {
|
||||
StyleSetHandle styleSet = presShell->StyleSet();
|
||||
SheetType sheetType = SheetType::Agent;
|
||||
for (int32_t i = 0; i < styleSet->SheetCount(sheetType); i++) {
|
||||
sheets.AppendElement(styleSet->StyleSheetAt(sheetType, i));
|
||||
aResult.AppendElement(styleSet->StyleSheetAt(sheetType, i));
|
||||
}
|
||||
sheetType = SheetType::User;
|
||||
for (int32_t i = 0; i < styleSet->SheetCount(sheetType); i++) {
|
||||
sheets.AppendElement(styleSet->StyleSheetAt(sheetType, i));
|
||||
aResult.AppendElement(styleSet->StyleSheetAt(sheetType, i));
|
||||
}
|
||||
|
||||
AutoTArray<StyleSheet*, 32> xblSheetArray;
|
||||
|
@ -107,29 +105,20 @@ inDOMUtils::GetAllStyleSheets(nsIDOMDocument *aDocument, uint32_t *aLength,
|
|||
for (StyleSheet* sheet : xblSheetArray) {
|
||||
if (!sheetSet.Contains(sheet)) {
|
||||
sheetSet.PutEntry(sheet);
|
||||
sheets.AppendElement(sheet);
|
||||
aResult.AppendElement(sheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the document sheets.
|
||||
for (size_t i = 0; i < document->SheetCount(); i++) {
|
||||
sheets.AppendElement(document->SheetAt(i));
|
||||
for (size_t i = 0; i < aDocument.SheetCount(); i++) {
|
||||
aResult.AppendElement(aDocument.SheetAt(i));
|
||||
}
|
||||
|
||||
nsISupports** ret = static_cast<nsISupports**>(moz_xmalloc(sheets.Length() *
|
||||
sizeof(nsISupports*)));
|
||||
|
||||
for (size_t i = 0; i < sheets.Length(); i++) {
|
||||
NS_ADDREF(ret[i] = NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, sheets[i]));
|
||||
}
|
||||
|
||||
*aLength = sheets.Length();
|
||||
*aSheets = ret;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDOMUtils::IsIgnorableWhitespace(nsIDOMCharacterData *aDataNode,
|
||||
bool *aReturn)
|
||||
|
|
|
@ -20,10 +20,6 @@ interface nsIDOMCSSStyleSheet;
|
|||
[scriptable, uuid(362e98c3-82c2-4ad8-8dcb-00e8e4eab497)]
|
||||
interface inIDOMUtils : nsISupports
|
||||
{
|
||||
// CSS utilities
|
||||
void getAllStyleSheets (in nsIDOMDocument aDoc,
|
||||
[optional] out unsigned long aLength,
|
||||
[array, size_is (aLength), retval] out nsISupports aSheets);
|
||||
nsIArrayExtensions getCSSStyleRules(in nsIDOMElement aElement, [optional] in DOMString aPseudo);
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,12 +12,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=734861
|
|||
|
||||
/** Test for Bug 734861 **/
|
||||
|
||||
const InspectorUtils = SpecialPowers.InspectorUtils;
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest() {
|
||||
var utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
|
||||
.getService(SpecialPowers.Ci.inIDOMUtils);
|
||||
var res = utils.getAllStyleSheets(document);
|
||||
var res = InspectorUtils.getAllStyleSheets(document);
|
||||
|
||||
var foundUA = false;
|
||||
for (var i = 0; i < res.length; i++) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче