diff --git a/devtools/client/sourceeditor/editor.js b/devtools/client/sourceeditor/editor.js index 640c574d91a..a29fdeb0d7d 100644 --- a/devtools/client/sourceeditor/editor.js +++ b/devtools/client/sourceeditor/editor.js @@ -302,6 +302,30 @@ Editor.prototype = { // context menus won't work). cm = win.CodeMirror(win.document.body, this.config); + + // Disable APZ for source editors. It currently causes the line numbers to + // "tear off" and swim around on top of the content. Bug 1160601 tracks + // finding a solution that allows APZ to work with CodeMirror. + cm.getScrollerElement().addEventListener("wheel", ev => { + // By handling the wheel events ourselves, we force the platform to + // scroll synchronously, like it did before APZ. However, we lose smooth + // scrolling for users with mouse wheels. This seems acceptible vs. + // doing nothing and letting the gutter slide around. + ev.preventDefault(); + + let { deltaX, deltaY } = ev; + + if (ev.deltaMode == ev.DOM_DELTA_LINE) { + deltaX *= cm.defaultCharWidth(); + deltaY *= cm.defaultTextHeight(); + } else if (ev.deltaMode == ev.DOM_DELTA_PAGE) { + deltaX *= cm.getWrapperElement().clientWidth; + deltaY *= cm.getWrapperElement().clientHeight; + } + + cm.getScrollerElement().scrollBy(deltaX, deltaY); + }); + cm.getWrapperElement().addEventListener("contextmenu", ev => { ev.preventDefault();