Bug 1618501 - Rewrite the dumping code to not recurse so much. r=botond

The HTTN dumping code recursed not only when going down the tree, but
also when traversing siblings. For "wide" trees this could result in
stack exhaustion. This patch rewrites that function to only recurse
when going down a level and uses iteration to walk the siblings at a
given level.

Depends on D64657

Differential Revision: https://phabricator.services.mozilla.com/D64658

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kartikaya Gupta 2020-02-28 15:37:17 +00:00
parent 1d2638f1bb
commit 35177e2a3e

View File

@ -414,9 +414,6 @@ bool HitTestingTreeNode::IsAsyncZoomContainer() const {
}
void HitTestingTreeNode::Dump(const char* aPrefix) const {
if (mPrevSibling) {
mPrevSibling->Dump(aPrefix);
}
MOZ_LOG(
sApzMgrLog, LogLevel::Debug,
("%sHitTestingTreeNode (%p) APZC (%p) g=(%s) %s%s%sr=(%s) t=(%s) "
@ -434,8 +431,21 @@ void HitTestingTreeNode::Dump(const char* aPrefix) const {
mClipRegion ? Stringify(mClipRegion.ref()).c_str() : "none",
mScrollbarData.mDirection.isSome() ? " scrollbar" : "",
IsScrollThumbNode() ? " scrollthumb" : ""));
if (mLastChild) {
mLastChild->Dump(nsPrintfCString("%s ", aPrefix).get());
if (!mLastChild) {
return;
}
// Dump the children in order from first child to last child
std::stack<HitTestingTreeNode*> children;
for (HitTestingTreeNode* child = mLastChild.get(); child;
child = child->mPrevSibling) {
children.push(child);
}
nsPrintfCString childPrefix("%s ", aPrefix);
while (!children.empty()) {
children.top()->Dump(childPrefix.get());
children.pop();
}
}