зеркало из https://github.com/mozilla/gecko-dev.git
Bug 936380 - Fix gcli screenshot size calculations. r=jwalker
This commit is contained in:
Родитель
7ca6c123d2
Коммит
381737f521
|
@ -109,30 +109,36 @@ exports.items = [
|
|||
let currentX = window.scrollX;
|
||||
let currentY = window.scrollY;
|
||||
|
||||
if (!fullpage) {
|
||||
if (!node) {
|
||||
left = window.scrollX;
|
||||
top = window.scrollY;
|
||||
width = window.innerWidth;
|
||||
height = window.innerHeight;
|
||||
} else {
|
||||
let lh = new LayoutHelpers(window);
|
||||
let rect = lh.getRect(node, window);
|
||||
top = rect.top;
|
||||
left = rect.left;
|
||||
width = rect.width;
|
||||
height = rect.height;
|
||||
}
|
||||
} else {
|
||||
// Bug 961832: GCLI screenshot shows fixed position element in wrong position if
|
||||
// we don't scroll to top
|
||||
if (fullpage) {
|
||||
// Bug 961832: GCLI screenshot shows fixed position element in wrong
|
||||
// position if we don't scroll to top
|
||||
window.scrollTo(0,0);
|
||||
width = window.innerWidth + window.scrollMaxX;
|
||||
height = window.innerHeight + window.scrollMaxY;
|
||||
} else if (node) {
|
||||
let lh = new LayoutHelpers(window);
|
||||
let rect = lh.getRect(node, window);
|
||||
top = rect.top;
|
||||
left = rect.left;
|
||||
width = rect.width;
|
||||
height = rect.height;
|
||||
} else {
|
||||
left = window.scrollX;
|
||||
top = window.scrollY;
|
||||
width = window.innerWidth;
|
||||
height = window.innerHeight;
|
||||
}
|
||||
|
||||
let winUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
let scrollbarHeight = {};
|
||||
let scrollbarWidth = {};
|
||||
winUtils.getScrollbarSize(false, scrollbarWidth, scrollbarHeight);
|
||||
width -= scrollbarWidth.value;
|
||||
height -= scrollbarHeight.value;
|
||||
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
|
||||
let ctx = canvas.getContext("2d");
|
||||
ctx.drawWindow(window, left, top, width, height, "#fff");
|
||||
let data = canvas.toDataURL("image/png", "");
|
||||
|
|
Загрузка…
Ссылка в новой задаче