mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 1640537 - Improve style sheet dumping in the layout debugger. r=TYLin
Make it show the contents of style sheets (as it used to before Stylo) and make it work in --disable-debug --enable-layout-debugger builds. Differential Revision: https://phabricator.services.mozilla.com/D76640
This commit is contained in:
parent
36563c2de3
commit
1e8189c0f1
@ -10201,13 +10201,20 @@ void PresShell::ListComputedStyles(FILE* out, int32_t aIndent) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG) || defined(MOZ_LAYOUT_DEBUGGER)
|
||||
void PresShell::ListStyleSheets(FILE* out, int32_t aIndent) {
|
||||
int32_t sheetCount = StyleSet()->SheetCount(StyleOrigin::Author);
|
||||
for (int32_t i = 0; i < sheetCount; ++i) {
|
||||
StyleSet()->SheetAt(StyleOrigin::Author, i)->List(out, aIndent);
|
||||
fputs("\n", out);
|
||||
}
|
||||
auto ListStyleSheetsAtOrigin = [this, out, aIndent](StyleOrigin origin) {
|
||||
int32_t sheetCount = StyleSet()->SheetCount(origin);
|
||||
for (int32_t i = 0; i < sheetCount; ++i) {
|
||||
StyleSet()->SheetAt(origin, i)->List(out, aIndent);
|
||||
}
|
||||
};
|
||||
|
||||
ListStyleSheetsAtOrigin(StyleOrigin::UserAgent);
|
||||
ListStyleSheetsAtOrigin(StyleOrigin::User);
|
||||
ListStyleSheetsAtOrigin(StyleOrigin::Author);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -748,12 +748,13 @@ class PresShell final : public nsStubDocumentObserver,
|
||||
bool IsPaintingFrameCounts();
|
||||
#endif // #ifdef MOZ_REFLOW_PERF
|
||||
|
||||
#ifdef DEBUG
|
||||
// Debugging hooks
|
||||
#ifdef DEBUG
|
||||
void ListComputedStyles(FILE* out, int32_t aIndent = 0);
|
||||
|
||||
#endif
|
||||
#if defined(DEBUG) || defined(MOZ_LAYOUT_DEBUGGER)
|
||||
void ListStyleSheets(FILE* out, int32_t aIndent = 0);
|
||||
#endif // #ifdef DEBUG
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Stop all active elements (plugins and the caret) in this presentation and
|
||||
|
@ -1004,34 +1004,75 @@ size_t StyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
|
||||
return n;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void StyleSheet::List(FILE* out, int32_t aIndent) const {
|
||||
int32_t index;
|
||||
|
||||
// Indent
|
||||
nsAutoCString str;
|
||||
for (index = aIndent; --index >= 0;) {
|
||||
str.AppendLiteral(" ");
|
||||
#if defined(DEBUG) || defined(MOZ_LAYOUT_DEBUGGER)
|
||||
void StyleSheet::List(FILE* aOut, int32_t aIndent) {
|
||||
for (StyleSheet* child : ChildSheets()) {
|
||||
child->List(aOut, aIndent);
|
||||
}
|
||||
|
||||
str.AppendLiteral("CSS Style Sheet: ");
|
||||
nsAutoCString urlSpec;
|
||||
nsresult rv = GetSheetURI()->GetSpec(urlSpec);
|
||||
if (NS_SUCCEEDED(rv) && !urlSpec.IsEmpty()) {
|
||||
str.Append(urlSpec);
|
||||
nsCString line;
|
||||
for (int i = 0; i < aIndent; ++i) {
|
||||
line.AppendLiteral(" ");
|
||||
}
|
||||
|
||||
line.AppendLiteral("/* ");
|
||||
|
||||
nsCString url;
|
||||
GetSheetURI()->GetSpec(url);
|
||||
if (url.IsEmpty()) {
|
||||
line.AppendLiteral("(no URL)");
|
||||
} else {
|
||||
line.Append(url);
|
||||
}
|
||||
|
||||
line.AppendLiteral(" (");
|
||||
|
||||
switch (GetOrigin()) {
|
||||
case StyleOrigin::UserAgent:
|
||||
line.AppendLiteral("User Agent");
|
||||
break;
|
||||
case StyleOrigin::User:
|
||||
line.AppendLiteral("User");
|
||||
break;
|
||||
case StyleOrigin::Author:
|
||||
line.AppendLiteral("Author");
|
||||
break;
|
||||
}
|
||||
|
||||
if (mMedia) {
|
||||
str.AppendLiteral(" media: ");
|
||||
nsAutoString buffer;
|
||||
nsString buffer;
|
||||
mMedia->GetText(buffer);
|
||||
AppendUTF16toUTF8(buffer, str);
|
||||
}
|
||||
str.Append('\n');
|
||||
fprintf_stderr(out, "%s", str.get());
|
||||
|
||||
for (const StyleSheet* child : ChildSheets()) {
|
||||
child->List(out, aIndent + 1);
|
||||
if (!buffer.IsEmpty()) {
|
||||
line.AppendLiteral(", ");
|
||||
AppendUTF16toUTF8(buffer, line);
|
||||
}
|
||||
}
|
||||
|
||||
line.AppendLiteral(") */");
|
||||
|
||||
fprintf_stderr(aOut, "%s\n\n", line.get());
|
||||
|
||||
nsCString newlineIndent;
|
||||
newlineIndent.Append('\n');
|
||||
for (int i = 0; i < aIndent; ++i) {
|
||||
newlineIndent.AppendLiteral(" ");
|
||||
}
|
||||
|
||||
ServoCSSRuleList* ruleList = GetCssRulesInternal();
|
||||
for (uint32_t i = 0, len = ruleList->Length(); i < len; ++i) {
|
||||
nsString cssText;
|
||||
css::Rule* rule = ruleList->GetRule(i);
|
||||
rule->GetCssText(cssText);
|
||||
|
||||
NS_ConvertUTF16toUTF8 s(cssText);
|
||||
s.ReplaceSubstring(NS_LITERAL_CSTRING("\n"), newlineIndent);
|
||||
|
||||
fprintf_stderr(aOut, "%s\n", s.get());
|
||||
}
|
||||
|
||||
if (ruleList->Length() != 0) {
|
||||
fprintf_stderr(aOut, "\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -333,8 +333,8 @@ class StyleSheet final : public nsICSSLoaderObserver, public nsWrapperCache {
|
||||
}
|
||||
|
||||
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
||||
#ifdef DEBUG
|
||||
void List(FILE* aOut = stdout, int32_t aIndex = 0) const;
|
||||
#if defined(DEBUG) || defined(MOZ_LAYOUT_DEBUGGER)
|
||||
void List(FILE* aOut = stdout, int32_t aIndex = 0);
|
||||
#endif
|
||||
|
||||
// WebIDL StyleSheet API
|
||||
|
@ -298,7 +298,7 @@ nsLayoutDebuggingTools::DumpViews() {
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDebuggingTools::DumpStyleSheets() {
|
||||
NS_ENSURE_TRUE(mDocShell, NS_ERROR_NOT_INITIALIZED);
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) || defined(MOZ_LAYOUT_DEBUGGER)
|
||||
FILE* out = stdout;
|
||||
if (PresShell* presShell = GetPresShell(mDocShell)) {
|
||||
presShell->ListStyleSheets(out);
|
||||
|
Loading…
Reference in New Issue
Block a user