in frontend/src/components/jfr/flame-graph.js [625:723]
this.draw = function (x, y, w, h) {
this.x = x;
this.y = y;
this.fg.$maxY = Math.max(y + h, this.fg.$maxY);
this.width = w;
this.height = h;
this.drawSelf();
if (this.children) {
if (this.fg.$pinned && this === this.fg.$pinnedFrame) {
this.fg.$drawingChildrenOfPinnedFrame = true;
}
let xGap = this.fg.$xGap;
let childY = this.fg.downward ? y + h + this.fg.$yGap : y - h - this.fg.$yGap;
if (
!this.fg.$pinned ||
this === this.fg.$pinnedFrame ||
this.fg.$drawingChildrenOfPinnedFrame
) {
const space = this.children.length - 1;
let leftWidth = w;
if ((space * xGap) / w > this.fg.$xGapThreashold) {
xGap = 0;
} else {
leftWidth = leftWidth - space * xGap;
}
let endX = x + w;
let nextX = x;
for (let i = 0; i < this.children.length; i++) {
let cw = 0;
if (i === this.children.length - 1 && this.selfWeight === 0) {
cw = endX - nextX;
} else {
cw = (leftWidth * this.children[i].weight) / this.weight;
}
this.children[i].draw(nextX, childY, cw, h);
nextX += cw + xGap;
}
} else {
let sideWidth = 15;
if (this === this.fg.$pinnedFrameLeft || this === this.fg.$pinnedFrameRight) {
this.fg.$drawingChildrenOfSideFrame = true;
this.fg.$drawingLeftSide = this === this.fg.$pinnedFrameLeft;
}
if (this.fg.$drawingChildrenOfSideFrame) {
if (!this.fg.$drawingLeftSide || this.selfWeight === 0) {
for (let i = 0; i < this.children.length; i++) {
if (
(this.fg.$drawingLeftSide && i === this.children.length - 1) ||
(!this.fg.$drawingLeftSide && i === 0)
) {
this.children[i].draw(x, childY, sideWidth, h);
} else {
this.children[i].resetPosition();
}
}
} else {
for (let i = 0; i < this.children.length; i++) {
this.children[i].resetPosition();
}
}
} else {
for (let i = 0; i < this.children.length; i++) {
let xGap = this.fg.$xGap;
if ((xGap * 2) / w > this.fg.$xGapThreashold) {
xGap = 0;
}
if (this.children[i].pinned) {
let cx = x;
let cw = w;
if (this.hasLeftSide) {
cx += sideWidth + xGap;
cw -= sideWidth + xGap;
}
if (this.hasRightSide) {
cw -= sideWidth + xGap;
} else if (this.selfWeight > 0 && this.fg.$pinnedFrame.parent === this) {
cw -= sideWidth;
}
this.children[i].draw(cx, childY, cw, h);
} else if (this.children[i] === this.fg.$pinnedFrameLeft) {
this.children[i].draw(x, childY, sideWidth, h);
} else if (this.children[i] === this.fg.$pinnedFrameRight) {
this.children[i].draw(x + w - sideWidth, childY, sideWidth, h);
} else {
this.children[i].resetPosition();
}
}
}
if (this === this.fg.$pinnedFrameLeft || this === this.fg.$pinnedFrameRight) {
this.fg.$drawingChildrenOfSideFrame = false;
}
}
if (this.fg.$pinned && this === this.fg.$pinnedFrame) {
this.fg.$drawingChildrenOfPinnedFrame = false;
}
}
};