зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1194311 - Reusing dnd panel and canvas. r=jimm
This commit is contained in:
Родитель
957ad16ed7
Коммит
71d06b19cf
|
@ -5454,23 +5454,30 @@
|
||||||
// to get a full-resolution drag image for use on HiDPI displays.
|
// to get a full-resolution drag image for use on HiDPI displays.
|
||||||
let windowUtils = window.getInterface(Ci.nsIDOMWindowUtils);
|
let windowUtils = window.getInterface(Ci.nsIDOMWindowUtils);
|
||||||
let scale = windowUtils.screenPixelsPerCSSPixel / windowUtils.fullZoom;
|
let scale = windowUtils.screenPixelsPerCSSPixel / windowUtils.fullZoom;
|
||||||
let canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
|
let canvas = this._dndCanvas ? this._dndCanvas
|
||||||
|
: document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
|
||||||
canvas.mozOpaque = true;
|
canvas.mozOpaque = true;
|
||||||
canvas.width = 160 * scale;
|
canvas.width = 160 * scale;
|
||||||
canvas.height = 90 * scale;
|
canvas.height = 90 * scale;
|
||||||
let toDrag;
|
let toDrag;
|
||||||
if (gMultiProcessBrowser) {
|
if (gMultiProcessBrowser) {
|
||||||
|
var context = canvas.getContext('2d');
|
||||||
|
context.fillStyle = "white";
|
||||||
|
context.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
// Create a panel to use it in setDragImage
|
// Create a panel to use it in setDragImage
|
||||||
// which will tell xul to render a panel that follows
|
// which will tell xul to render a panel that follows
|
||||||
// the pointer while a dnd session is on.
|
// the pointer while a dnd session is on.
|
||||||
var panel = document.createElement("panel");
|
if (!this._dndPanel) {
|
||||||
panel.setAttribute("type", "drag");
|
this._dndCanvas = canvas;
|
||||||
panel.appendChild(canvas);
|
this._dndPanel = document.createElement("panel");
|
||||||
document.documentElement.appendChild(panel);
|
this._dndPanel.setAttribute("type", "drag");
|
||||||
|
this._dndPanel.appendChild(canvas);
|
||||||
|
document.documentElement.appendChild(this._dndPanel);
|
||||||
|
}
|
||||||
// PageThumb is async with e10s but that's fine
|
// PageThumb is async with e10s but that's fine
|
||||||
// since we can update the panel during the dnd.
|
// since we can update the panel during the dnd.
|
||||||
PageThumbs.captureToCanvas(browser, canvas);
|
PageThumbs.captureToCanvas(browser, canvas);
|
||||||
toDrag = panel;
|
toDrag = this._dndPanel;
|
||||||
} else {
|
} else {
|
||||||
// For the non e10s case we can just use PageThumbs
|
// For the non e10s case we can just use PageThumbs
|
||||||
// sync. No need for xul magic, the native dnd will
|
// sync. No need for xul magic, the native dnd will
|
||||||
|
|
Загрузка…
Ссылка в новой задаче