Bug 1809505 - Extract counter list dumping. r=jwatt

This was useful for debugging.

Differential Revision: https://phabricator.services.mozilla.com/D238538
This commit is contained in:
Emilio Cobos Álvarez
2025-02-18 09:34:01 +00:00
parent 64819713fe
commit 549b9abd07
2 changed files with 26 additions and 16 deletions

View File

@@ -333,6 +333,27 @@ bool nsCounterList::SetScopeByWalkingBackwardThroughList(
return false;
}
#if defined(DEBUG) || defined(MOZ_LAYOUT_DEBUGGER)
void nsCounterList::Dump() {
int32_t i = 0;
for (auto* node = First(); node; node = Next(node)) {
const char* types[] = {"RESET", "INCREMENT", "SET", "USE"};
printf(
" Node #%d @%p frame=%p index=%d type=%s valAfter=%d\n"
" scope-start=%p scope-prev=%p",
i++, (void*)node, (void*)node->mPseudoFrame, node->mContentIndex,
types[node->mType], node->mValueAfter, (void*)node->mScopeStart,
(void*)node->mScopePrev);
if (node->mType == nsCounterNode::USE) {
nsAutoString text;
node->UseNode()->GetText(text);
printf(" text=%s", NS_ConvertUTF16toUTF8(text).get());
}
printf("\n");
}
}
#endif
void nsCounterList::RecalcAll() {
AutoRestore<bool> restoreRecalculatingAll(mRecalculatingAll);
mRecalculatingAll = true;
@@ -535,22 +556,7 @@ void nsCounterManager::Dump() const {
printf("Counter named \"%s\":\n", nsAtomCString(entry.GetKey()).get());
nsCounterList* list = entry.GetWeak();
int32_t i = 0;
for (nsCounterNode* node = list->First(); node; node = list->Next(node)) {
const char* types[] = {"RESET", "INCREMENT", "SET", "USE"};
printf(
" Node #%d @%p frame=%p index=%d type=%s valAfter=%d\n"
" scope-start=%p scope-prev=%p",
i++, (void*)node, (void*)node->mPseudoFrame, node->mContentIndex,
types[node->mType], node->mValueAfter, (void*)node->mScopeStart,
(void*)node->mScopePrev);
if (node->mType == nsCounterNode::USE) {
nsAutoString text;
node->UseNode()->GetText(text);
printf(" text=%s", NS_ConvertUTF16toUTF8(text).get());
}
printf("\n");
}
list->Dump();
}
printf("\n\n");
}

View File

@@ -219,6 +219,10 @@ class nsCounterList : public nsGenConList {
MOZ_ASSERT(aScope);
}
#if defined(DEBUG) || defined(MOZ_LAYOUT_DEBUGGER)
void Dump();
#endif
// Return the first node for aFrame on this list, or nullptr.
nsCounterNode* GetFirstNodeFor(nsIFrame* aFrame) const {
return static_cast<nsCounterNode*>(nsGenConList::GetFirstNodeFor(aFrame));