Bug 1049551 - Add a tab delay spinner that's visible if we switch tabs before the content has been drawn r=dao

This commit is contained in:
George Wright 2014-10-10 11:46:27 -04:00
parent 9b09624418
commit d0aa92a318
6 changed files with 47 additions and 2 deletions

View File

@ -74,3 +74,13 @@ tabpanels {
browser[pending] {
display: none;
}
browser[pendingpaint] {
opacity: 0;
}
tabbrowser[pendingpaint] {
background-image: url(chrome://global/skin/spinner.png);
background-repeat: no-repeat;
background-position: center center;
}

View File

@ -136,6 +136,10 @@
""
</field>
<field name="_contentWaitingCount">
0
</field>
<property name="_numPinnedTabs" readonly="true">
<getter><![CDATA[
for (var i = 0; i < this.tabs.length; i++) {
@ -3228,6 +3232,31 @@
</body>
</method>
<method name="_showBusySpinnerRemoteBrowser">
<parameter name="aBrowser"/>
<body><![CDATA[
aBrowser.setAttribute("pendingpaint", "true");
if (this._contentWaitingCount <= 0) {
// We are not currently spinning
this.setAttribute("pendingpaint", "true");
this._contentWaitingCount = 1;
} else {
this._contentWaitingCount++;
}
]]></body>
</method>
<method name="_hideBusySpinnerRemoteBrowser">
<parameter name="aBrowser"/>
<body><![CDATA[
aBrowser.removeAttribute("pendingpaint");
this._contentWaitingCount--;
if (this._contentWaitingCount <= 0) {
this.removeAttribute("pendingpaint");
}
]]></body>
</method>
<method name="_prepareForTabSwitch">
<parameter name="toTab"/>
<parameter name="fromTab"/>
@ -3266,16 +3295,19 @@
let timeoutPromise = new Promise((aResolve, aReject) => {
timeoutId = setTimeout(() => {
this._showBusySpinnerRemoteBrowser(toBrowser);
attemptTabSwitch(aResolve, aReject);
}, kTabSwitchTimeout);
});
let paintPromise = new Promise((aResolve, aReject) => {
toBrowser.addEventListener("MozAfterRemotePaint", function onRemotePaint() {
let onRemotePaint = () => {
toBrowser.removeEventListener("MozAfterRemotePaint", onRemotePaint);
this._hideBusySpinnerRemoteBrowser(toBrowser);
clearTimeout(timeoutId);
attemptTabSwitch(aResolve, aReject);
});
};
toBrowser.addEventListener("MozAfterRemotePaint", onRemotePaint);
toBrowser.QueryInterface(Ci.nsIFrameLoaderOwner)
.frameLoader
.requestNotifyAfterRemotePaint();

View File

@ -67,3 +67,4 @@ toolkit.jar:
skin/classic/global/in-content/sorter.png (../../shared/in-content/sorter.png)
skin/classic/global/in-content/sorter@2x.png (../../shared/in-content/sorter@2x.png)
+ skin/classic/global/toolbar/spring.png (toolbar/spring.png)
skin/classic/global/spinner.png (../../shared/spinner.png)

View File

@ -206,3 +206,4 @@ toolkit.jar:
skin/classic/global/tree/columnpicker.gif (tree/columnpicker.gif)
skin/classic/global/tree/folder.png (tree/folder.png)
skin/classic/global/tree/folder@2x.png (tree/folder@2x.png)
skin/classic/global/spinner.png (../../shared/spinner.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

View File

@ -201,6 +201,7 @@ toolkit.jar:
skin/classic/global/tree/sort-dsc-classic.png (tree/sort-dsc-classic.png)
skin/classic/global/tree/twisty-clsd.png (tree/twisty-clsd.png)
skin/classic/global/tree/twisty-open.png (tree/twisty-open.png)
skin/classic/global/spinner.png (../../shared/spinner.png)
#ifdef XP_WIN
toolkit.jar: