зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1232806 - Change mouse events' target to window in the markup view to keep track of the dragging even when the cursor is outside the window. r=jdescottes
Add some tests in the `mousemove` handler to keep the dragged node inside the markup panel. MozReview-Commit-ID: LSlzTeJyc9D --HG-- extra : transplant_source : %D0%08%CC4%CE%F5%14%3C%98%1F%9A%FF%1A%80%DDR%CA%C1%F9%C8
This commit is contained in:
Родитель
d0c0684cc7
Коммит
af21d42527
|
@ -130,7 +130,7 @@ function MarkupView(inspector, frame, controllerWindow) {
|
|||
this._elt.addEventListener("click", this._onMouseClick, false);
|
||||
this._elt.addEventListener("mousemove", this._onMouseMove, false);
|
||||
this._elt.addEventListener("mouseleave", this._onMouseLeave, false);
|
||||
this.doc.body.addEventListener("mouseup", this._onMouseUp);
|
||||
this.win.addEventListener("mouseup", this._onMouseUp);
|
||||
this.win.addEventListener("keydown", this._onKeyDown, false);
|
||||
this.win.addEventListener("copy", this._onCopy);
|
||||
this._frame.addEventListener("focus", this._onFocus, false);
|
||||
|
@ -1621,7 +1621,7 @@ MarkupView.prototype = {
|
|||
this._elt.removeEventListener("click", this._onMouseClick, false);
|
||||
this._elt.removeEventListener("mousemove", this._onMouseMove, false);
|
||||
this._elt.removeEventListener("mouseleave", this._onMouseLeave, false);
|
||||
this.doc.body.removeEventListener("mouseup", this._onMouseUp);
|
||||
this.win.removeEventListener("mouseup", this._onMouseUp);
|
||||
this.win.removeEventListener("keydown", this._onKeyDown, false);
|
||||
this.win.removeEventListener("copy", this._onCopy);
|
||||
this._frame.removeEventListener("focus", this._onFocus, false);
|
||||
|
@ -1793,8 +1793,8 @@ MarkupContainer.prototype = {
|
|||
|
||||
// Binding event listeners
|
||||
this.elt.addEventListener("mousedown", this._onMouseDown, false);
|
||||
this.markup.doc.body.addEventListener("mouseup", this._onMouseUp, true);
|
||||
this.markup.doc.body.addEventListener("mousemove", this._onMouseMove, true);
|
||||
this.win.addEventListener("mouseup", this._onMouseUp, true);
|
||||
this.win.addEventListener("mousemove", this._onMouseMove, true);
|
||||
this.elt.addEventListener("dblclick", this._onToggle, false);
|
||||
if (this.expander) {
|
||||
this.expander.addEventListener("click", this._onToggle, false);
|
||||
|
@ -2057,11 +2057,20 @@ MarkupContainer.prototype = {
|
|||
}
|
||||
|
||||
if (this.isDragging) {
|
||||
let diff = event.pageY - this._dragStartY;
|
||||
let x = 0;
|
||||
let y = event.pageY - this.win.scrollY;
|
||||
|
||||
// Ensure we keep the dragged element within the markup view.
|
||||
if (y < 0) {
|
||||
y = 0;
|
||||
} else if (y >= this.markup.doc.body.offsetHeight - this.win.scrollY) {
|
||||
y = this.markup.doc.body.offsetHeight - this.win.scrollY - 1;
|
||||
}
|
||||
|
||||
let diff = y - this._dragStartY + this.win.scrollY;
|
||||
this.elt.style.top = diff + "px";
|
||||
|
||||
let el = this.markup.doc.elementFromPoint(event.pageX - this.win.scrollX,
|
||||
event.pageY - this.win.scrollY);
|
||||
let el = this.markup.doc.elementFromPoint(x, y);
|
||||
this.markup.indicateDropTarget(el);
|
||||
}
|
||||
},
|
||||
|
@ -2190,9 +2199,10 @@ MarkupContainer.prototype = {
|
|||
// Remove event listeners
|
||||
this.elt.removeEventListener("mousedown", this._onMouseDown, false);
|
||||
this.elt.removeEventListener("dblclick", this._onToggle, false);
|
||||
this.markup.doc.body.removeEventListener("mouseup", this._onMouseUp, true);
|
||||
this.markup.doc.body.removeEventListener("mousemove",
|
||||
this._onMouseMove, true);
|
||||
if (this.win) {
|
||||
this.win.removeEventListener("mouseup", this._onMouseUp, true);
|
||||
this.win.removeEventListener("mousemove", this._onMouseMove, true);
|
||||
}
|
||||
|
||||
this.win = null;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче