Bug 831440 - Switch back to static thumbnails for the tab bar

--HG--
extra : rebase_source : 6af90594890ca7ae30fecfe3234e009845e6404c
This commit is contained in:
Rodrigo Silveira 2013-08-07 10:51:43 -07:00
parent 7941dea3ee
commit 1a0d4f30d2
4 changed files with 49 additions and 13 deletions

View File

@ -134,7 +134,6 @@ const WebProgress = {
browser.messageManager.removeMessageListener(aMessage.name, arguments.callee);
aTab._firstPaint = true;
aTab.scrolledAreaChanged(true);
aTab.updateThumbnailSource();
});
},

View File

@ -17,7 +17,7 @@
<binding id="documenttab">
<content observes="bcast_urlbarState">
<xul:stack class="documenttab-container">
<xul:box anonid="thumbnail" class="documenttab-thumbnail" />
<html:canvas anonid="thumbnail-canvas" class="documenttab-thumbnail" />
<xul:image anonid="favicon" class="documenttab-favicon"
observes="bcast_urlbarState" width="26" height="26"/>
@ -36,12 +36,19 @@
</handlers>
<implementation>
<field name="_thumbnail" readonly="true">document.getAnonymousElementByAttribute(this, "anonid", "thumbnail");</field>
<field name="thumbnailCanvas" readonly="true">document.getAnonymousElementByAttribute(this, "anonid", "thumbnail-canvas");</field>
<field name="_close" readonly="true">document.getAnonymousElementByAttribute(this, "anonid", "close");</field>
<field name="_title" readonly="true">document.getAnonymousElementByAttribute(this, "anonid", "title");</field>
<field name="_favicon" readonly="true">document.getAnonymousElementByAttribute(this, "anonid", "favicon");</field>
<field name="_container" readonly="true">this.parentNode;</field>
<constructor>
<![CDATA[
this.thumbnailCanvas.mozOpaque = true;
this.thumbnailCanvas.mozImageSmoothingEnabled = true;
]]>
</constructor>
<method name="_onClick">
<body>
<![CDATA[
@ -90,14 +97,6 @@
</body>
</method>
<method name="updateThumbnailSource">
<parameter name="browser"/>
<body>
<![CDATA[
this._thumbnail.style.backgroundImage = "-moz-element(#" + browser.id + ")";
]]>
</body>
</method>
</implementation>
</binding>

View File

@ -8,6 +8,8 @@ let Ci = Components.interfaces;
let Cu = Components.utils;
let Cr = Components.results;
Cu.import("resource://gre/modules/PageThumbs.jsm");
const kBrowserViewZoomLevelPrecision = 10000;
// allow panning after this timeout on pages with registered touch listeners
@ -16,6 +18,8 @@ const kSetInactiveStateTimeout = 100;
const kDefaultMetadata = { autoSize: false, allowZoom: true, autoScale: true };
const kTabThumbnailDelayCapture = 500;
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
// Override sizeToContent in the main window. It breaks things (bug 565887)
@ -1454,6 +1458,7 @@ function Tab(aURI, aParams, aOwner) {
this._chromeTab = null;
this._metadata = null;
this._eventDeferred = null;
this._updateThumbnailTimeout = null;
this.owner = aOwner || null;
@ -1603,13 +1608,45 @@ Tab.prototype = {
self._eventDeferred = null;
}
browser.addEventListener("pageshow", onPageShowEvent, true);
browser.messageManager.addMessageListener("Content:StateChange", this);
Services.obs.addObserver(this, "metro_viewstate_changed", false);
if (aOwner)
this._copyHistoryFrom(aOwner);
this._loadUsingParams(browser, aURI, aParams);
},
receiveMessage: function(aMessage) {
switch (aMessage.name) {
case "Content:StateChange":
// update the thumbnail now...
this.updateThumbnail();
// ...and in a little while to capture page after load.
if (aMessage.json.stateFlags & Ci.nsIWebProgressListener.STATE_STOP) {
clearTimeout(this._updateThumbnailTimeout);
this._updateThumbnailTimeout = setTimeout(() => {
this.updateThumbnail();
}, kTabThumbnailDelayCapture);
}
break;
}
},
observe: function BrowserUI_observe(aSubject, aTopic, aData) {
switch (aTopic) {
case "metro_viewstate_changed":
if (aData !== "snapped") {
this.updateThumbnail();
}
break;
}
},
destroy: function destroy() {
this._browser.messageManager.removeMessageListener("Content:StateChange", this);
Services.obs.removeObserver(this, "metro_viewstate_changed", false);
clearTimeout(this._updateThumbnailTimeout);
Elements.tabList.removeTab(this._chromeTab);
this._chromeTab = null;
this._destroyBrowser();
@ -1818,8 +1855,8 @@ Tab.prototype = {
return this.metadata.allowZoom && !Util.isURLEmpty(this.browser.currentURI.spec);
},
updateThumbnailSource: function updateThumbnailSource() {
this._chromeTab.updateThumbnailSource(this._browser);
updateThumbnail: function updateThumbnail() {
PageThumbs.captureToCanvas(this.browser.contentWindow, this._chromeTab.thumbnailCanvas);
},
updateFavicon: function updateFavicon() {

View File

@ -127,6 +127,7 @@ documenttab[closing] > .documenttab-container {
margin: @metro_spacing_normal@ @metro_spacing_snormal@;
background: white none center top no-repeat;
background-size: cover;
min-width: @thumbnail_width@;
width: @thumbnail_width@;
height: @thumbnail_height@;
}