[Pkg-mozext-commits] [tabmixplus] 04/48: Start using getBoundsWithoutFlushing instead of getBoundingClientRect when the information does not change between paint
David Prévot
taffit at moszumanska.debian.org
Sun Aug 20 03:14:34 UTC 2017
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit 2769c3fdc66ade9a7ccfe3b821cae44ba500b52f
Author: onemen <tabmix.onemen at gmail.com>
Date: Fri Jun 30 10:09:16 2017 +0300
Start using getBoundsWithoutFlushing instead of getBoundingClientRect when the information does not change between paint
---
chrome/content/minit/minit.js | 16 ++++++++++------
chrome/content/session/session.js | 2 +-
chrome/content/session/sessionStore.js | 2 +-
chrome/content/tab/scrollbox.xml | 2 +-
chrome/content/tab/tabbrowser_4.xml | 2 +-
chrome/content/tabmix.js | 8 ++++----
chrome/content/utils.js | 18 ++++++++++++++++++
7 files changed, 36 insertions(+), 14 deletions(-)
diff --git a/chrome/content/minit/minit.js b/chrome/content/minit/minit.js
index 5bc8a9f..ae06818 100644
--- a/chrome/content/minit/minit.js
+++ b/chrome/content/minit/minit.js
@@ -137,10 +137,14 @@ var TMP_tabDNDObserver = {
tabBar._tabDropIndicator.style.MozTransform = "translate(0px, 0px)";
if (Tabmix.isVersion(280)) {
- let t = document.getElementById("TabsToolbar").parentNode.getBoundingClientRect();
- let r = gBrowser.tabContainer.getBoundingClientRect();
- let c = document.getElementById("content-deck").getBoundingClientRect();
- this.onLastToolbar = Math.abs(t.bottom - r.bottom) < 2 && Math.abs(r.bottom - c.top) < 2;
+ window.requestAnimationFrame(() => {
+ window.requestAnimationFrame(() => {
+ let t = Tabmix.getBoundsWithoutFlushing(document.getElementById("TabsToolbar").parentNode);
+ let r = Tabmix.getBoundsWithoutFlushing(gBrowser.tabContainer);
+ let c = Tabmix.getBoundsWithoutFlushing(document.getElementById("content-deck"));
+ this.onLastToolbar = Math.abs(t.bottom - r.bottom) < 2 && Math.abs(r.bottom - c.top) < 2;
+ });
+ });
}
},
@@ -443,11 +447,11 @@ var TMP_tabDNDObserver = {
let tabIndex = draggedTab._tPos;
if (dropIndex > tabIndex) {
for (let i = tabIndex + 1; i <= dropIndex; i++) {
- newTranslateX += gBrowser.tabs[i].getBoundingClientRect().width;
+ newTranslateX += Tabmix.getBoundsWithoutFlushing(gBrowser.tabs[i]).width;
}
} else if (dropIndex < tabIndex) {
for (let i = dropIndex; i < tabIndex; i++) {
- newTranslateX -= gBrowser.tabs[i].getBoundingClientRect().width;
+ newTranslateX -= Tabmix.getBoundsWithoutFlushing(gBrowser.tabs[i]).width;
}
}
}
diff --git a/chrome/content/session/session.js b/chrome/content/session/session.js
index 65655a4..4cfc633 100644
--- a/chrome/content/session/session.js
+++ b/chrome/content/session/session.js
@@ -3536,7 +3536,7 @@ TabmixSessionManager = {
}
if (TabmixTabbar.hideMode != 2 && TabmixTabbar.widthFitTitle && !aTab.hasAttribute("width"))
- aTab.setAttribute("width", aTab.getBoundingClientRect().width);
+ aTab.setAttribute("width", Tabmix.getBoundsWithoutFlushing(aTab).width);
// if we need to remove extra tabs make sure they are not protected
let attributes = ["protected", "fixed-label", "label-uri", "tabmix_bookmarkId",
diff --git a/chrome/content/session/sessionStore.js b/chrome/content/session/sessionStore.js
index ed9b892..c37555a 100644
--- a/chrome/content/session/sessionStore.js
+++ b/chrome/content/session/sessionStore.js
@@ -349,7 +349,7 @@ var TMP_ClosedTabs = {
return false;
if (keepWidth && !aPopup.hasAttribute("width")) {
- const width = aPopup.getBoundingClientRect().width;
+ const width = Tabmix.getBoundsWithoutFlushing(aPopup).width;
aPopup.setAttribute("width", width);
}
diff --git a/chrome/content/tab/scrollbox.xml b/chrome/content/tab/scrollbox.xml
index a3776a1..9bd0c4e 100644
--- a/chrome/content/tab/scrollbox.xml
+++ b/chrome/content/tab/scrollbox.xml
@@ -332,7 +332,7 @@
else
tab = Tabmix.visibleTabs.previous(element);
if (tab) {
- offset = Math.min(this.minOffset, this.offsetRatio * tab.getBoundingClientRect().width);
+ offset = Math.min(this.minOffset, this.offsetRatio * Tabmix.getBoundsWithoutFlushing(tab).width);
if (!isScrollingLeft)
offset = Math.min(this.scrollPosition, offset);
}
diff --git a/chrome/content/tab/tabbrowser_4.xml b/chrome/content/tab/tabbrowser_4.xml
index 91732d4..f26131e 100644
--- a/chrome/content/tab/tabbrowser_4.xml
+++ b/chrome/content/tab/tabbrowser_4.xml
@@ -214,7 +214,7 @@
if (aTab.mIsHover && aTab.getAttribute("showbutton") != "on" &&
!aTab.hasAttribute("dragged")) {
if (TabmixTabbar.widthFitTitle)
- aTab.style.setProperty("width", aTab.getBoundingClientRect().width + "px", "important");
+ aTab.style.setProperty("width", Tabmix.getBoundsWithoutFlushing(aTab).width + "px", "important");
aTab.setAttribute("showbutton", "on");
aTab.parentNode.__showbuttonTab = aTab;
}
diff --git a/chrome/content/tabmix.js b/chrome/content/tabmix.js
index a3bed0e..2c9d48c 100644
--- a/chrome/content/tabmix.js
+++ b/chrome/content/tabmix.js
@@ -105,7 +105,7 @@ Tabmix.getButtonsHeight = function(setDefault) {
let stripIsHidden = TabmixTabbar.hideMode !== 0 && !tabBar.visible;
if (stripIsHidden)
tabBar.visible = true;
- this._buttonsHeight = Tabmix.visibleTabs.first.getBoundingClientRect().height;
+ this._buttonsHeight = Tabmix.getBoundsWithoutFlushing(Tabmix.visibleTabs.first).height;
if (stripIsHidden)
tabBar.visible = false;
@@ -134,7 +134,7 @@ Tabmix.getAfterTabsButtonsWidth = function TMP_getAfterTabsButtonsWidth() {
this.tabsNewtabButton =
document.getAnonymousElementByAttribute(tabBar, "command", "cmd_newNavigatorTab");
this.tabsNewtabButton.setAttribute("force-display", true);
- let openNewTabRect = this.tabsNewtabButton.getBoundingClientRect();
+ let openNewTabRect = Tabmix.getBoundsWithoutFlushing(this.tabsNewtabButton);
let style = window.getComputedStyle(this.tabsNewtabButton);
let marginStart = style.getPropertyValue("margin-left");
// it doesn't work when marginEnd add to buttonWidth
@@ -151,7 +151,7 @@ Tabmix.getAfterTabsButtonsWidth = function TMP_getAfterTabsButtonsWidth() {
// the right button
let openNewPrivateTab = document.getElementById("privateTab-afterTabs-openNewPrivateTab");
if (openNewPrivateTab) {
- let openNewPrivateTabRect = openNewPrivateTab.getBoundingClientRect();
+ let openNewPrivateTabRect = Tabmix.getBoundsWithoutFlushing(openNewPrivateTab);
this.afterTabsButtonsWidth.push(openNewPrivateTabRect.width);
if (openNewPrivateTabRect.right > openNewTabRect.right)
this.tabsNewtabButton = openNewPrivateTab;
@@ -931,7 +931,7 @@ var TMP_eventListener = {
if (TabmixTabbar.hideMode != 2 && TabmixTabbar.widthFitTitle &&
!tab.hasAttribute("width") && tab.hasAttribute("pending")) {
- tab.setAttribute("width", tab.getBoundingClientRect().width);
+ tab.setAttribute("width", Tabmix.getBoundsWithoutFlushing(tab).width);
}
// for ColorfulTabs 6.0+
diff --git a/chrome/content/utils.js b/chrome/content/utils.js
index ae34a72..7a69ae8 100644
--- a/chrome/content/utils.js
+++ b/chrome/content/utils.js
@@ -58,6 +58,24 @@ var Tabmix = {
elem.removeAttribute(aAttr);
},
+ getBoundsWithoutFlushing(element) {
+ if (!("_DOMWindowUtils" in this)) {
+ try {
+ this._DOMWindowUtils =
+ window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindowUtils);
+ if (!this._DOMWindowUtils.getBoundsWithoutFlushing) {
+ this._DOMWindowUtils = null;
+ }
+ } catch (ex) {
+ this._DOMWindowUtils = null;
+ }
+ }
+ return this._DOMWindowUtils ?
+ this._DOMWindowUtils.getBoundsWithoutFlushing(element) :
+ element.getBoundingClientRect();
+ },
+
getTopWin() {
return Services.wm.getMostRecentWindow("navigator:browser");
},
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git
More information about the Pkg-mozext-commits
mailing list