Commit 1e5ed305 authored by einbinder's avatar einbinder Committed by Commit bot

DevTools: Don't refresh CodeMirror if it is hidden

CodeMirror.refresh is expensive, and calling it when CodeMirror is hidden breaks the gutters.

BUG=none

Review-Url: https://codereview.chromium.org/2342643002
Cr-Commit-Position: refs/heads/master@{#418684}
parent 71bc70f5
......@@ -174,7 +174,7 @@ WebInspector.SourcesTextEditor.prototype = {
this._gutters.push(type);
this.codeMirror().setOption("gutters", this._gutters.slice());
this.codeMirror().refresh();
this.refresh();
},
/**
......@@ -182,9 +182,12 @@ WebInspector.SourcesTextEditor.prototype = {
*/
uninstallGutter: function(type)
{
this._gutters = this._gutters.filter(gutter => gutter !== type);
var index = this._gutters.indexOf(type);
if (index === -1)
return;
this._gutters.splice(index,1);
this.codeMirror().setOption("gutters", this._gutters.slice());
this.codeMirror().refresh();
this.refresh();
},
/**
......
......@@ -160,6 +160,9 @@ WebInspector.CodeMirrorTextEditor = function(options)
this.element.addEventListener("keydown", this._handleKeyDown.bind(this), true);
this.element.addEventListener("keydown", this._handlePostKeyDown.bind(this), false);
this.element.tabIndex = 0;
this._needsRefresh = true;
if (options.mimeType)
this.setMimeType(options.mimeType);
}
......@@ -527,10 +530,21 @@ WebInspector.CodeMirrorTextEditor.prototype = {
*/
wasShown: function()
{
if (this._wasOnceShown)
if (this._needsRefresh)
this.refresh();
},
/**
* @protected
*/
refresh: function()
{
if (this.isShowing()) {
this._codeMirror.refresh();
this._needsRefresh = false;
return;
this._wasOnceShown = true;
this._codeMirror.refresh();
}
this._needsRefresh = true;
},
/**
......
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