Skip to content

Commit

Permalink
update paintedRect iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilliams720 committed May 21, 2024
1 parent e942ffe commit 01cd463
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,6 @@ class ContainerPerformanceObserver {
this.nativePerformanceObserver.disconnect();
}

takeRecords() {
return this.nativePerformanceObserver.takeRecords();
}

/**
* This algorithm collects the paints which have happened within the nearest container and emits the largest rectangle
* that is the union of all painted elements. Due to the nature of the underlying `element-timing` algorithm only new areas
Expand Down Expand Up @@ -326,16 +322,12 @@ class ContainerPerformanceObserver {
};
}

// Check for overlaps
let overlap = false;
resolvedRootData.paintedRects.forEach((rect) => {
// TODO: We should look into better ways to combine rectangles or detect overlapping rectangles
// Such as R-Tree or Quad Tree algorithms
for (const rect of resolvedRootData.paintedRects) {
if (ContainerPerformanceObserver.overlaps(entry.intersectionRect, rect)) {
overlap = true;
return;
}
});

if (overlap) {
return;
}

resolvedRootData.renderTime = entry.renderTime;
Expand Down

0 comments on commit 01cd463

Please sign in to comment.