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