summaryrefslogtreecommitdiff
path: root/devtools
diff options
context:
space:
mode:
authorJob Bautista <jobbautista9@aol.com>2023-05-12 11:54:35 +0800
committerJob Bautista <jobbautista9@aol.com>2023-05-12 16:26:05 +0800
commit0adb8cc71fba46afe05a85ac89d92a3586346ea1 (patch)
treeb290f275e0b5d96cb57b992be2542f778303870d /devtools
parent286e18e40ca01418725b978e4cd140f085b63079 (diff)
downloaduxp-0adb8cc71fba46afe05a85ac89d92a3586346ea1.tar.gz
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.
Diffstat (limited to 'devtools')
-rw-r--r--devtools/client/inspector/rules/test/browser_rules_completion-new-property_multiline.js6
-rw-r--r--devtools/client/shared/autocomplete-popup.js2
-rw-r--r--devtools/client/shared/test/browser_html_tooltip_arrow-01.js6
-rw-r--r--devtools/client/shared/test/browser_html_tooltip_arrow-02.js6
-rw-r--r--devtools/client/shared/test/browser_inplace-editor_autocomplete_offset.js2
-rw-r--r--devtools/client/shared/widgets/tooltip/HTMLTooltip.js6
-rw-r--r--devtools/server/actors/inspector.js5
-rw-r--r--devtools/shared/layout/utils.js22
8 files changed, 32 insertions, 23 deletions
diff --git a/devtools/client/inspector/rules/test/browser_rules_completion-new-property_multiline.js b/devtools/client/inspector/rules/test/browser_rules_completion-new-property_multiline.js
index f29de54a44..a4fafa2c1b 100644
--- a/devtools/client/inspector/rules/test/browser_rules_completion-new-property_multiline.js
+++ b/devtools/client/inspector/rules/test/browser_rules_completion-new-property_multiline.js
@@ -39,14 +39,14 @@ add_task(function* () {
// Calculate offsets to click in the middle of the first box quad.
let rect = prop.editor.valueSpan.getBoundingClientRect();
- let firstQuad = prop.editor.valueSpan.getBoxQuads()[0];
+ let firstQuadBounds = prop.editor.valueSpan.getBoxQuads()[0].getBounds();
// For a multiline value, the first quad left edge is not aligned with the
// bounding rect left edge. The offsets expected by focusEditableField are
// relative to the bouding rectangle, so we need to translate the x-offset.
- let x = firstQuad.bounds.left - rect.left + firstQuad.bounds.width / 2;
+ let x = firstQuadBounds.left - rect.left + firstQuadBounds.width / 2;
// The first quad top edge is aligned with the bounding top edge, no
// translation needed here.
- let y = firstQuad.bounds.height / 2;
+ let y = firstQuadBounds.height / 2;
info("Focusing the css property editable value");
let editor = yield focusEditableField(view, prop.editor.valueSpan, x, y);
diff --git a/devtools/client/shared/autocomplete-popup.js b/devtools/client/shared/autocomplete-popup.js
index b22de4d992..e848f6c1fd 100644
--- a/devtools/client/shared/autocomplete-popup.js
+++ b/devtools/client/shared/autocomplete-popup.js
@@ -283,7 +283,7 @@ AutocompletePopup.prototype = {
return;
}
- let {top, height} = quads[0].bounds;
+ let {top, height} = quads[0].getBounds();
let containerHeight = this._tooltip.panel.getBoundingClientRect().height;
if (top < 0) {
// Element is above container.
diff --git a/devtools/client/shared/test/browser_html_tooltip_arrow-01.js b/devtools/client/shared/test/browser_html_tooltip_arrow-01.js
index a20c67529a..4c3b332d26 100644
--- a/devtools/client/shared/test/browser_html_tooltip_arrow-01.js
+++ b/devtools/client/shared/test/browser_html_tooltip_arrow-01.js
@@ -85,9 +85,9 @@ function* runTests(doc) {
ok(arrow, "Tooltip has an arrow");
// Get the geometry of the anchor, the tooltip panel & arrow.
- let arrowBounds = arrow.getBoxQuads({relativeTo: doc})[0].bounds;
- let panelBounds = tooltip.panel.getBoxQuads({relativeTo: doc})[0].bounds;
- let anchorBounds = el.getBoxQuads({relativeTo: doc})[0].bounds;
+ let arrowBounds = arrow.getBoxQuads({relativeTo: doc})[0].getBounds();
+ let panelBounds = tooltip.panel.getBoxQuads({relativeTo: doc})[0].getBounds();
+ let anchorBounds = el.getBoxQuads({relativeTo: doc})[0].getBounds();
let intersects = arrowBounds.left <= anchorBounds.right &&
arrowBounds.right >= anchorBounds.left;
diff --git a/devtools/client/shared/test/browser_html_tooltip_arrow-02.js b/devtools/client/shared/test/browser_html_tooltip_arrow-02.js
index 098f1ac7bf..5bf13e911e 100644
--- a/devtools/client/shared/test/browser_html_tooltip_arrow-02.js
+++ b/devtools/client/shared/test/browser_html_tooltip_arrow-02.js
@@ -78,9 +78,9 @@ function* runTests(doc) {
ok(arrow, "Tooltip has an arrow");
// Get the geometry of the anchor, the tooltip panel & arrow.
- let arrowBounds = arrow.getBoxQuads({relativeTo: doc})[0].bounds;
- let panelBounds = tooltip.panel.getBoxQuads({relativeTo: doc})[0].bounds;
- let anchorBounds = el.getBoxQuads({relativeTo: doc})[0].bounds;
+ let arrowBounds = arrow.getBoxQuads({relativeTo: doc})[0].getBounds();
+ let panelBounds = tooltip.panel.getBoxQuads({relativeTo: doc})[0].getBounds();
+ let anchorBounds = el.getBoxQuads({relativeTo: doc})[0].getBounds();
let intersects = arrowBounds.left <= anchorBounds.right &&
arrowBounds.right >= anchorBounds.left;
diff --git a/devtools/client/shared/test/browser_inplace-editor_autocomplete_offset.js b/devtools/client/shared/test/browser_inplace-editor_autocomplete_offset.js
index 2734125bd1..e5ce45b280 100644
--- a/devtools/client/shared/test/browser_inplace-editor_autocomplete_offset.js
+++ b/devtools/client/shared/test/browser_inplace-editor_autocomplete_offset.js
@@ -114,5 +114,5 @@ let runAutocompletionTest = Task.async(function* (editor) {
*/
function getPopupOffset({popup, input}) {
let popupQuads = popup._panel.getBoxQuads({relativeTo: input});
- return popupQuads[0].bounds.left;
+ return popupQuads[0].getBounds().left;
}
diff --git a/devtools/client/shared/widgets/tooltip/HTMLTooltip.js b/devtools/client/shared/widgets/tooltip/HTMLTooltip.js
index 9eb7910303..6cc12a53a4 100644
--- a/devtools/client/shared/widgets/tooltip/HTMLTooltip.js
+++ b/devtools/client/shared/widgets/tooltip/HTMLTooltip.js
@@ -176,9 +176,9 @@ const getRelativeRect = function (node, relativeTo) {
// Width and Height can be taken from the rect.
let {width, height} = node.getBoundingClientRect();
- let quads = node.getBoxQuads({relativeTo});
- let top = quads[0].bounds.top;
- let left = quads[0].bounds.left;
+ let quadBounds = node.getBoxQuads({relativeTo})[0].getBounds();
+ let top = quadBounds.top;
+ let left = quadBounds.left;
// Compute right and bottom coordinates using the rest of the data.
let right = left + width;
diff --git a/devtools/server/actors/inspector.js b/devtools/server/actors/inspector.js
index 883809b6cf..ba9393de58 100644
--- a/devtools/server/actors/inspector.js
+++ b/devtools/server/actors/inspector.js
@@ -3071,7 +3071,10 @@ function nodeHasSize(node) {
}
let quads = node.getBoxQuads();
- return quads.length && quads.some(quad => quad.bounds.width && quad.bounds.height);
+ return quads.some(quad => {
+ let bounds = quad.getBounds();
+ return bounds.width && bounds.height;
+ });
}
/**
diff --git a/devtools/shared/layout/utils.js b/devtools/shared/layout/utils.js
index 1e6ab5075a..bbe6df4c85 100644
--- a/devtools/shared/layout/utils.js
+++ b/devtools/shared/layout/utils.js
@@ -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
}
});
}