FF4/JetPack上的HTML5画布绘制窗口错误
我借用了thumbnail.js的代码,并对其进行了修改,这样就可以截取整个页面的屏幕(至少这是我的想法) 但我有个错误FF4/JetPack上的HTML5画布绘制窗口错误,html,canvas,firefox-addon-sdk,firefox4,Html,Canvas,Firefox Addon Sdk,Firefox4,我借用了thumbnail.js的代码,并对其进行了修改,这样就可以截取整个页面的屏幕(至少这是我的想法) 但我有个错误 Code: Traceback (most recent call last): File "resource://jid0-qpxlmo42unizthqqbyuvdjhd59y-api-utils-lib/timer.js", line 64, in notifyOnTimeout this._callback.apply(null
Code:
Traceback (most recent call last):
File "resource://jid0-qpxlmo42unizthqqbyuvdjhd59y-api-utils-lib/timer.js", line 64, in notifyOnTimeout
this._callback.apply(null, this._params);
File "resource://jid0-qpxlmo42unizthqqbyuvdjhd59y-api-utils-lib/content/worker.js", line 64, in emitter
emit.apply(scope, params);
File "resource://jid0-qpxlmo42unizthqqbyuvdjhd59y-api-utils-lib/events.js", line 147, in _emit
return this._emitOnObject.apply(this, args);
File "resource://jid0-qpxlmo42unizthqqbyuvdjhd59y-api-utils-lib/events.js", line 177, in _emitOnObject
listener.apply(targetObj, params);
File "resource://jid0-qpxlmo42unizthqqbyuvdjhd59y-addon-kit-lib/context-menu.js", line 609, in workerOnMessage
item.onMessage(msg);see error
File "resource://jid0-qpxlmo42unizthqqbyuvdjhd59y-what-inspires-me-lib/main.js", line 27, in null
var imgdata = takeScreenshot(tabs.activeTab.window);
File "resource://jid0-qpxlmo42unizthqqbyuvdjhd59y-what-inspires-me-lib/main.js", line 18, in takeScreenshot
ctx.drawWindow(window, 0, 0, 500, 500, "rgb(255,255,255)");
[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMCanvasRenderingContext2D.draw
Window]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: resource://jid0-qpxlmo42unizthqqbyuvdj
hd59y-api-utils-lib/securable-module.js -> resource://jid0-qpxlmo42unizthqqbyuvdjhd59y-what-inspires-me-lib/main.j
s :: takeScreenshot :: line 18" data: no]
有什么问题吗?这可能太老了,但万一有人发现了。下面的代码适用于我在FF3.0到FF6测试版之间的版本
// Mostly taken from
// http://wiki.github.com/bard/mozrepl/interactor-screenshot-server
function (tab,rect) {
var browserWindow = Components.classes['@mozilla.org/appshell/window-mediator;1']
.getService(Components.interfaces.nsIWindowMediator)
.getMostRecentWindow('navigator:browser');
var canvas = browserWindow
.document
.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');
var browser = tab.linkedBrowser;
var win = browser.contentWindow;
var left = rect.left || 0;
var top = rect.top || 0;
var width = rect.width || win.document.body.clientWidth;
var height = rect.height || win.document.body.clientHeight;
canvas.width = width;
canvas.height = height;
var ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, width, height);
ctx.save();
ctx.scale(1.0, 1.0);
ctx.drawWindow(win, left, top, width, height, 'rgb(255,255,255)');
ctx.restore();
//return atob(
return canvas
.toDataURL('image/png', '')
.split(',')[1]
// );
}
// Mostly taken from
// http://wiki.github.com/bard/mozrepl/interactor-screenshot-server
function (tab,rect) {
var browserWindow = Components.classes['@mozilla.org/appshell/window-mediator;1']
.getService(Components.interfaces.nsIWindowMediator)
.getMostRecentWindow('navigator:browser');
var canvas = browserWindow
.document
.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');
var browser = tab.linkedBrowser;
var win = browser.contentWindow;
var left = rect.left || 0;
var top = rect.top || 0;
var width = rect.width || win.document.body.clientWidth;
var height = rect.height || win.document.body.clientHeight;
canvas.width = width;
canvas.height = height;
var ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, width, height);
ctx.save();
ctx.scale(1.0, 1.0);
ctx.drawWindow(win, left, top, width, height, 'rgb(255,255,255)');
ctx.restore();
//return atob(
return canvas
.toDataURL('image/png', '')
.split(',')[1]
// );
}