DevTools: [CodeMirrro] defer autocomplete controller initialization

Autocompletion controller intialization makes almost half of the time
of SourceFrame initialization.

In order to render editor as fast as possible, this patch defers
autocompletion initialization until the first need.

BUG=425550
R=vsevik

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

git-svn-id: svn://svn.chromium.org/blink/trunk@184263 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c274d3da
...@@ -16,6 +16,7 @@ function test() ...@@ -16,6 +16,7 @@ function test()
var completionDictionary = new WebInspector.SampleCompletionDictionary(); var completionDictionary = new WebInspector.SampleCompletionDictionary();
textEditor.setCompletionDictionary(completionDictionary); textEditor.setCompletionDictionary(completionDictionary);
textEditor._autocompleteController._initializeIfNeeded();
InspectorTest.runTestSuite([ InspectorTest.runTestSuite([
function testSetInitialText(next) function testSetInitialText(next)
......
...@@ -1975,17 +1975,12 @@ WebInspector.CodeMirrorTextEditor.AutocompleteController = function(textEditor, ...@@ -1975,17 +1975,12 @@ WebInspector.CodeMirrorTextEditor.AutocompleteController = function(textEditor,
this._changes = this._changes.bind(this); this._changes = this._changes.bind(this);
this._beforeChange = this._beforeChange.bind(this); this._beforeChange = this._beforeChange.bind(this);
this._blur = this._blur.bind(this); this._blur = this._blur.bind(this);
this._codeMirror.on("scroll", this._onScroll);
this._codeMirror.on("cursorActivity", this._onCursorActivity);
this._codeMirror.on("changes", this._changes);
this._codeMirror.on("beforeChange", this._beforeChange);
this._codeMirror.on("blur", this._blur);
this._additionalWordChars = WebInspector.CodeMirrorTextEditor._NoAdditionalWordChars; this._additionalWordChars = WebInspector.CodeMirrorTextEditor._NoAdditionalWordChars;
this._enabled = true; this._enabled = true;
this._dictionary = dictionary; this._dictionary = dictionary;
this._addTextToCompletionDictionary(this._textEditor.text()); this._initialized = false;
} }
WebInspector.CodeMirrorTextEditor.AutocompleteController.Dummy = new WebInspector.CodeMirrorTextEditor.DummyAutocompleteController(); WebInspector.CodeMirrorTextEditor.AutocompleteController.Dummy = new WebInspector.CodeMirrorTextEditor.DummyAutocompleteController();
...@@ -1993,8 +1988,23 @@ WebInspector.CodeMirrorTextEditor._NoAdditionalWordChars = {}; ...@@ -1993,8 +1988,23 @@ WebInspector.CodeMirrorTextEditor._NoAdditionalWordChars = {};
WebInspector.CodeMirrorTextEditor._CSSAdditionalWordChars = { ".": true, "-": true }; WebInspector.CodeMirrorTextEditor._CSSAdditionalWordChars = { ".": true, "-": true };
WebInspector.CodeMirrorTextEditor.AutocompleteController.prototype = { WebInspector.CodeMirrorTextEditor.AutocompleteController.prototype = {
_initializeIfNeeded: function()
{
if (this._initialized)
return;
this._initialized = true;
this._codeMirror.on("scroll", this._onScroll);
this._codeMirror.on("cursorActivity", this._onCursorActivity);
this._codeMirror.on("changes", this._changes);
this._codeMirror.on("beforeChange", this._beforeChange);
this._codeMirror.on("blur", this._blur);
this._addTextToCompletionDictionary(this._textEditor.text());
},
dispose: function() dispose: function()
{ {
if (!this._initialized)
return;
this._codeMirror.off("scroll", this._onScroll); this._codeMirror.off("scroll", this._onScroll);
this._codeMirror.off("cursorActivity", this._onCursorActivity); this._codeMirror.off("cursorActivity", this._onCursorActivity);
this._codeMirror.off("changes", this._changes); this._codeMirror.off("changes", this._changes);
...@@ -2157,6 +2167,7 @@ WebInspector.CodeMirrorTextEditor.AutocompleteController.prototype = { ...@@ -2157,6 +2167,7 @@ WebInspector.CodeMirrorTextEditor.AutocompleteController.prototype = {
autocomplete: function() autocomplete: function()
{ {
this._initializeIfNeeded();
var dictionary = this._dictionary; var dictionary = this._dictionary;
if (this._codeMirror.somethingSelected()) { if (this._codeMirror.somethingSelected()) {
this.finishAutocomplete(); this.finishAutocomplete();
......
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