Commit de8bd143 authored by apavlov@chromium.org's avatar apavlov@chromium.org

DevTools: Always construct CodeMirror explicitly, via "new"

This patch also cleans up and fixes a bunch of codemirror-related externs

R=lushnikov
NOTRY=true

Review URL: https://codereview.chromium.org/334393004

git-svn-id: svn://svn.chromium.org/blink/trunk@176332 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent ccc26348
......@@ -33,19 +33,12 @@
/** @type {boolean} */
Event.prototype.isMetaOrCtrlForTest;
/**
* @constructor
* @extends {KeyboardEvent}
* @param {string} eventType
* @param {!Object=} properties
*/
window.KeyboardEvent = function(eventType, properties) {}
/**
* @type {number}
*/
KeyboardEvent.DOM_KEY_LOCATION_NUMPAD;
// FIXME: Remove after the Closure compiler roll.
/** @param {*} message */
function postMessage(message) {}
......@@ -315,11 +308,23 @@ difflib.SequenceMatcher = function(baseText, newText) { }
difflib.SequenceMatcher.prototype.get_opcodes = function() { return []; }
/** @constructor */
var CodeMirror = function() { }
var Doc = function() { }
Doc.prototype = {
/** @type {number} */
scrollLeft: 0,
/** @type {number} */
scrollTop: 0
}
/** @constructor */
var CodeMirror = function(element, config) { }
CodeMirror.on = function(obj, type, handler) { }
CodeMirror.prototype = {
/** @type {!Doc} */
doc: null,
addKeyMap: function(map) { },
addLineClass: function(handle, where, cls) { },
/** @param {?Object=} options */
addLineWidget: function(handle, node, options) { },
/**
* @param {string|!Object} spec
......@@ -331,11 +336,17 @@ CodeMirror.prototype = {
clearGutter: function(gutterID) { },
clearHistory: function() { },
clipPos: function(pos) { },
/** @param {string=} mode */
coordsChar: function(coords, mode) { },
/** @param {string=} mode */
cursorCoords: function(start, mode) { },
defaultCharWidth: function() { },
defaultTextHeight: function() { },
deleteH: function(dir, unit) { },
/**
* @param {*=} to
* @param {*=} op
*/
eachLine: function(from, to, op) { },
execCommand: function(cmd) { },
extendSelection: function(from, to) { },
......@@ -360,6 +371,7 @@ CodeMirror.prototype = {
getLineNumber: function(line) { },
getMode: function() { },
getOption: function(option) { },
/** @param {*=} lineSep */
getRange: function(from, to, lineSep) { },
/**
* @return {!{left: number, top: number, width: number, height: number, clientWidth: number, clientHeight: number}}
......@@ -370,6 +382,7 @@ CodeMirror.prototype = {
getSelections: function() { },
getStateAfter: function(line) { },
getTokenAt: function(pos) { },
/** @param {*=} lineSep */
getValue: function(lineSep) { },
getViewport: function() { },
getWrapperElement: function() { },
......@@ -405,8 +418,10 @@ CodeMirror.prototype = {
removeLineClass: function(handle, where, cls) { },
removeLineWidget: function(widget) { },
removeOverlay: function(spec) { },
/** @param {*=} origin */
replaceRange: function(code, from, to, origin) { },
replaceSelection: function(code, collapse, origin) { },
/** @param {*=} margin */
scrollIntoView: function(pos, margin) { },
scrollTo: function(x, y) { },
setBookmark: function(pos, options) { },
......@@ -417,7 +432,11 @@ CodeMirror.prototype = {
setLine: function(line, text) { },
setOption: function(option, value) { },
setSelection: function(anchor, head) { },
setSelections: function(selections) { },
/**
* @param {number=} primaryIndex
* @param {?Object=} config
*/
setSelections: function(selections, primaryIndex, config) { },
setSize: function(width, height) { },
setValue: function(code) { },
somethingSelected: function() { },
......@@ -427,6 +446,7 @@ CodeMirror.prototype = {
}
/** @type {!{cursorDiv: Element}} */
CodeMirror.prototype.display;
/** @type {!Object} */
CodeMirror.Pass;
CodeMirror.showHint = function(codeMirror, hintintFunction) { };
CodeMirror.commands = {};
......@@ -439,9 +459,9 @@ CodeMirror.startState = function(mode) { };
/** @constructor */
CodeMirror.Pos = function(line, ch) { }
/** type {number} */
/** @type {number} */
CodeMirror.Pos.prototype.line;
/** type {number} */
/** @type {number} */
CodeMirror.Pos.prototype.ch;
/** @constructor */
......
......@@ -44,7 +44,7 @@ WebInspector.CodeMirrorTextEditor = function(url, delegate)
this.registerRequiredCSS("cm/codemirror.css");
this.registerRequiredCSS("cm/cmdevtools.css");
this._codeMirror = window.CodeMirror(this.element, {
this._codeMirror = new window.CodeMirror(this.element, {
lineNumbers: true,
gutters: ["CodeMirror-linenumbers"],
matchBrackets: true,
......
......@@ -84,7 +84,7 @@ WebInspector.CodeMirrorUtils.prototype = {
editingContext.cssLoadView.show(element);
WebInspector.setCurrentFocusElement(element);
element.addEventListener("copy", this._consumeCopy, false);
var codeMirror = window.CodeMirror(element, {
var codeMirror = new window.CodeMirror(element, {
mode: config.mode,
lineWrapping: config.lineWrapping,
smartIndent: config.smartIndent,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment