Bug 850163 - use mozRequestAnimationFrame to start the tab opening animation asynchronously but without missing the next possible frame. r=ttaubert

--HG--
extra : rebase_source : 5274b1f1a8b5b5d0e4b7f3d369b0a91f3fb0655d
This commit is contained in:
Dão Gottwald 2013-04-03 16:05:56 +02:00
parent f04a7ceb34
commit c3d508a9c5
2 changed files with 13 additions and 10 deletions

View File

@ -1454,17 +1454,18 @@
} }
if (animate) { if (animate) {
this.tabContainer._handleTabTelemetryStart(t, aURI); mozRequestAnimationFrame(function () {
this.tabContainer._handleTabTelemetryStart(t, aURI);
// kick the animation off // kick the animation off
t.clientTop; t.setAttribute("fadein", "true");
t.setAttribute("fadein", "true");
// This call to adjustTabstrip is redundant but needed so that // This call to adjustTabstrip is redundant but needed so that
// when opening a second tab, the first tab's close buttons // when opening a second tab, the first tab's close buttons
// appears immediately rather than when the transition ends. // appears immediately rather than when the transition ends.
if (this.tabContainer.childNodes.length == 2) if (this.tabContainer.childNodes.length == 2)
this.tabContainer.adjustTabstrip(); this.tabContainer.adjustTabstrip();
}.bind(this));
} }
return t; return t;

View File

@ -4,13 +4,15 @@ function test() {
waitForExplicitFinish(); waitForExplicitFinish();
tab = gBrowser.addTab(); tab = gBrowser.addTab();
is(tab.getAttribute("fadein"), "true", "tab opening animation initiated"); isnot(tab.getAttribute("fadein"), "true", "newly opened tab is yet to fade in");
// Try to remove the tab right before the opening animation's first frame // Try to remove the tab right before the opening animation's first frame
window.mozRequestAnimationFrame(checkAnimationState); window.mozRequestAnimationFrame(checkAnimationState);
} }
function checkAnimationState() { function checkAnimationState() {
is(tab.getAttribute("fadein"), "true", "tab opening animation initiated");
info(window.getComputedStyle(tab).maxWidth); info(window.getComputedStyle(tab).maxWidth);
gBrowser.removeTab(tab, { animate: true }); gBrowser.removeTab(tab, { animate: true });
if (!tab.parentNode) { if (!tab.parentNode) {