Bug 1724880 - Add a layout-debugger menu item that dumps CounterManager data. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D122210
This commit is contained in:
Mats Palmgren 2021-08-10 23:15:31 +00:00
parent 3355c934ef
commit 05d79d0404
10 changed files with 47 additions and 28 deletions

View File

@ -334,8 +334,9 @@ class nsCSSFrameConstructor final : public nsFrameManager {
void AddSizeOfIncludingThis(nsWindowSizes& aSizes) const;
#ifdef ACCESSIBILITY
// Exposed only for nsLayoutUtils::GetMarkerSpokenText to use.
#if defined(ACCESSIBILITY) || defined(MOZ_LAYOUT_DEBUGGER)
// Exposed only for nsLayoutUtils::GetMarkerSpokenText and
// nsLayoutDebuggingTools to use.
const nsCounterManager* CounterManager() const { return &mCounterManager; }
#endif

View File

@ -392,8 +392,8 @@ void nsCounterManager::GetSpokenCounterText(nsIFrame* aFrame,
}
#endif
#ifdef DEBUG
void nsCounterManager::Dump() {
#if defined(DEBUG) || defined(MOZ_LAYOUT_DEBUGGER)
void nsCounterManager::Dump() const {
printf("\n\nCounter Manager Lists:\n");
for (const auto& entry : mNames) {
printf("Counter named \"%s\":\n", nsAtomCString(entry.GetKey()).get());

View File

@ -246,8 +246,8 @@ class nsCounterManager {
void GetSpokenCounterText(nsIFrame* aFrame, nsAString& aText) const;
#endif
#ifdef DEBUG
void Dump();
#if defined(DEBUG) || defined(MOZ_LAYOUT_DEBUGGER)
void Dump() const;
#endif
static int32_t IncrementCounter(int32_t aOldValue, int32_t aIncrement) {

View File

@ -10,6 +10,29 @@
#include "nsLayoutUtils.h"
#include "nsIContent.h"
void nsGenConNode::CheckFrameAssertions() {
NS_ASSERTION(
mContentIndex < int32_t(mPseudoFrame->StyleContent()->ContentCount()) ||
// Special-case for the USE node created for the legacy markers,
// which don't use the content property.
mContentIndex == 0,
"index out of range");
// We allow negative values of mContentIndex for 'counter-reset' and
// 'counter-increment'.
NS_ASSERTION(mContentIndex < 0 ||
mPseudoFrame->Style()->GetPseudoType() ==
mozilla::PseudoStyleType::before ||
mPseudoFrame->Style()->GetPseudoType() ==
mozilla::PseudoStyleType::after ||
mPseudoFrame->Style()->GetPseudoType() ==
mozilla::PseudoStyleType::marker,
"not CSS generated content and not counter change");
NS_ASSERTION(mContentIndex < 0 ||
mPseudoFrame->HasAnyStateBits(NS_FRAME_GENERATED_CONTENT),
"not generated content and not counter change");
}
void nsGenConList::Clear() {
// Delete entire list.
mNodes.Clear();

View File

@ -61,28 +61,7 @@ struct nsGenConNode : public mozilla::LinkedListElement<nsGenConNode> {
virtual ~nsGenConNode() = default; // XXX Avoid, perhaps?
protected:
void CheckFrameAssertions() {
NS_ASSERTION(
mContentIndex < int32_t(mPseudoFrame->StyleContent()->ContentCount()) ||
// Special-case for the USE node created for the legacy markers,
// which don't use the content property.
mContentIndex == 0,
"index out of range");
// We allow negative values of mContentIndex for 'counter-reset' and
// 'counter-increment'.
NS_ASSERTION(mContentIndex < 0 ||
mPseudoFrame->Style()->GetPseudoType() ==
mozilla::PseudoStyleType::before ||
mPseudoFrame->Style()->GetPseudoType() ==
mozilla::PseudoStyleType::after ||
mPseudoFrame->Style()->GetPseudoType() ==
mozilla::PseudoStyleType::marker,
"not CSS generated content and not counter change");
NS_ASSERTION(mContentIndex < 0 ||
mPseudoFrame->HasAnyStateBits(NS_FRAME_GENERATED_CONTENT),
"not generated content and not counter change");
}
void CheckFrameAssertions();
};
class nsGenConList {

View File

@ -37,6 +37,7 @@ interface nsILayoutDebuggingTools : nsISupports
void dumpFramesInCSSPixels();
void dumpTextRuns();
void dumpViews();
void dumpCounterManager();
void dumpStyleSheets();
void dumpMatchedRules();

View File

@ -17,6 +17,8 @@
#include "nsIContent.h"
#include "nsCounterManager.h"
#include "nsCSSFrameConstructor.h"
#include "nsViewManager.h"
#include "nsIFrame.h"
@ -249,6 +251,15 @@ nsLayoutDebuggingTools::DumpViews() {
return NS_OK;
}
NS_IMETHODIMP
nsLayoutDebuggingTools::DumpCounterManager() {
NS_ENSURE_TRUE(mDocShell, NS_ERROR_NOT_INITIALIZED);
if (PresShell* presShell = GetPresShell(mDocShell)) {
presShell->FrameConstructor()->CounterManager()->Dump();
}
return NS_OK;
}
NS_IMETHODIMP
nsLayoutDebuggingTools::DumpStyleSheets() {
NS_ENSURE_TRUE(mDocShell, NS_ERROR_NOT_INITIALIZED);

View File

@ -38,6 +38,7 @@ const COMMANDS = [
"dumpFramesInCSSPixels",
"dumpTextRuns",
"dumpViews",
"dumpCounterManager",
"dumpStyleSheets",
"dumpMatchedRules",
"dumpComputedStyles",

View File

@ -96,6 +96,7 @@
<menuitem id="menu_dumpFramesInCSSPixels" label="&ldb.dumpFramesInCSSPixels.label;" accesskey="&ldb.dumpFramesInCSSPixels.accesskey;" oncommand="gDebugger.dumpFramesInCSSPixels();" />
<menuitem id="menu_dumpTextRuns" label="&ldb.dumpTextRuns.label;" accesskey="&ldb.dumpTextRuns.accesskey;" oncommand="gDebugger.dumpTextRuns();" />
<menuitem id="menu_dumpViews" label="&ldb.dumpViews.label;" accesskey="&ldb.dumpViews.accesskey;" oncommand="gDebugger.dumpViews();" />
<menuitem id="menu_dumpCounterManager" label="&ldb.dumpCounterManager.label;" accesskey="&ldb.dumpCounterManager.accesskey;" oncommand="gDebugger.dumpCounterManager();" />
<menuseparator />
<menuitem id="menu_dumpStyleSheets" label="&ldb.dumpStyleSheets.label;" accesskey="&ldb.dumpStyleSheets.accesskey;" oncommand="gDebugger.dumpStyleSheets();" />
<menuitem id="menu_dumpMatchedRules" label="&ldb.dumpMatchedRules.label;" accesskey="&ldb.dumpMatchedRules.accesskey;" oncommand="gDebugger.dumpMatchedRules();" />

View File

@ -49,6 +49,8 @@
<!ENTITY ldb.dumpTextRuns.accesskey "T">
<!ENTITY ldb.dumpViews.label "Views and Widgets">
<!ENTITY ldb.dumpViews.accesskey "V">
<!ENTITY ldb.dumpCounterManager.label "CSS Counters">
<!ENTITY ldb.dumpCounterManager.accesskey "N">
<!ENTITY ldb.dumpStyleSheets.label "Style Sheets">
<!ENTITY ldb.dumpStyleSheets.accesskey "S">
<!ENTITY ldb.dumpMatchedRules.label "Matched CSS Rules">