Issue #2241 - Part 4.3: Move devtools over to getBounds().

This leaves getAdjustedQuads alone because it lives in its own world and its
result gets sent over IPC. That leaves things in a bit of an intermediate state,
but that should be OK for now.

Backported from Mozilla bug 1186265.
This commit is contained in:
Job Bautista 2023-05-12 11:54:35 +08:00 committed by roytam1
commit 69e45fd84e
8 changed files with 32 additions and 23 deletions

View file

@ -175,6 +175,11 @@ exports.getFrameOffsets = getFrameOffsets;
/**
* Get box quads adjusted for iframes and zoom level.
*
* Warning: this function returns things that look like DOMQuad objects but
* aren't (they resemble an old version of the spec). Unlike the return value
* of node.getBoxQuads, they have a .bounds property and not a .getBounds()
* method.
*
* @param {DOMWindow} boundaryWindow
* The window where to stop to iterate. If `null` is given, the top
* window is used.
@ -206,6 +211,7 @@ function getAdjustedQuads(boundaryWindow, node, region) {
let adjustedQuads = [];
for (let quad of quads) {
let bounds = quad.getBounds();
adjustedQuads.push({
p1: {
w: quad.p1.w * scale,
@ -232,14 +238,14 @@ function getAdjustedQuads(boundaryWindow, node, region) {
z: quad.p4.z * scale
},
bounds: {
bottom: quad.bounds.bottom * scale + yOffset,
height: quad.bounds.height * scale,
left: quad.bounds.left * scale + xOffset,
right: quad.bounds.right * scale + xOffset,
top: quad.bounds.top * scale + yOffset,
width: quad.bounds.width * scale,
x: quad.bounds.x * scale + xOffset,
y: quad.bounds.y * scale + yOffset
bottom: bounds.bottom * scale + yOffset,
height: bounds.height * scale,
left: bounds.left * scale + xOffset,
right: bounds.right * scale + xOffset,
top: bounds.top * scale + yOffset,
width: bounds.width * scale,
x: bounds.x * scale + xOffset,
y: bounds.y * scale + yOffset
}
});
}