--- a/browser/components/preferences/in-content/findInPage.js
+++ b/browser/components/preferences/in-content/findInPage.js
@@ -1,14 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* import-globals-from preferences.js */
+const DOMUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindowUtils);
+
var gSearchResultsPane = {
findSelection: null,
listSearchTooltips: [],
searchResultsCategory: null,
searchInput: null,
init() {
let controller = this.getSelectionController();
@@ -340,28 +343,26 @@ var gSearchResultsPane = {
* Then calculation the offsets to position the tooltip in the correct place.
*
* @param Node currentNode
* DOM Element
* @param String query
* Word or words that are being searched for
*/
createSearchTooltip(currentNode, query) {
- // Getting position of the current node
- let rect = currentNode.getBoundingClientRect();
-
currentNode.parentElement.classList.add("search-tooltip-parent");
let searchTooltip = document.createElement("span");
searchTooltip.setAttribute("class", "search-tooltip");
searchTooltip.textContent = query;
currentNode.parentElement.appendChild(searchTooltip);
- let tooltipRect = searchTooltip.getBoundingClientRect();
+ let rect = DOMUtils.getBoundsWithoutFlushing(currentNode);
+ let tooltipRect = DOMUtils.getBoundsWithoutFlushing(searchTooltip);
let offSet = (rect.width / 2) - (tooltipRect.width / 2);
- let parentRect = currentNode.parentElement.getBoundingClientRect();
+ let parentRect = DOMUtils.getBoundsWithoutFlushing(currentNode.parentElement);
let relativeOffset = rect.left - parentRect.left;
offSet += relativeOffset > 0 ? relativeOffset : 0;
searchTooltip.style.setProperty("left", `${offSet}px`);
}
}