Bug 1374230 - Wrong tooltip position after resizing browser window r=mconley

MozReview-Commit-ID: GYPjtzRTQdf

--HG--
extra : rebase_source : f2cf7612b4284ff0aa73cf0b9acc1a4c808d1d12
This commit is contained in:
Ricky Chien 2017-06-19 17:38:57 +08:00
Родитель 3734bfa016
Коммит 3e45d87394
1 изменённых файлов: 19 добавлений и 0 удалений

Просмотреть файл

@ -18,6 +18,19 @@ var gSearchResultsPane = {
if (!this.searchInput.hidden) {
this.searchInput.addEventListener("command", this);
this.searchInput.addEventListener("focus", this);
// Throttling the resize event to reduce the callback frequency
let callbackId;
window.addEventListener("resize", () => {
if (!callbackId) {
callbackId = window.requestAnimationFrame(() => {
this.listSearchTooltips.forEach((anchorNode) => {
this.calculateTooltipPosition(anchorNode);
});
callbackId = null;
});
}
});
}
},
@ -398,6 +411,12 @@ var gSearchResultsPane = {
anchorNode.parentElement.classList.add("search-tooltip-parent");
anchorNode.parentElement.appendChild(searchTooltip);
this.calculateTooltipPosition(anchorNode);
},
calculateTooltipPosition(anchorNode) {
let searchTooltip = anchorNode.parentElement.querySelector(":scope > .search-tooltip");
// In order to get the up-to-date position of each of the nodes that we're
// putting tooltips on, we have to flush layout intentionally, and that
// this is the result of a XUL limitation (bug 1363730).