Web Inspector: Make showing a content view work in the tab world
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Views / SourceCodeTextEditor.js
1 /*
2  * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 WebInspector.SourceCodeTextEditor = class SourceCodeTextEditor extends WebInspector.TextEditor
27 {
28     constructor(sourceCode)
29     {
30         console.assert(sourceCode instanceof WebInspector.SourceCode);
31
32         super();
33
34         this.delegate = this;
35
36         this._sourceCode = sourceCode;
37         this._breakpointMap = {};
38         this._issuesLineNumberMap = new Map;
39         this._widgetMap = new Map;
40         this._contentPopulated = false;
41         this._invalidLineNumbers = {0: true};
42         this._ignoreContentDidChange = 0;
43
44         this._typeTokenScrollHandler = null;
45         this._typeTokenAnnotator = null;
46         this._basicBlockAnnotator = null;
47
48         this._isProbablyMinified = false;
49
50         // FIXME: Currently this just jumps between resources and related source map resources. It doesn't "jump to symbol" yet.
51         this._updateTokenTrackingControllerState();
52
53         this.element.classList.add("source-code");
54
55         if (this._supportsDebugging) {
56             WebInspector.Breakpoint.addEventListener(WebInspector.Breakpoint.Event.DisabledStateDidChange, this._breakpointStatusDidChange, this);
57             WebInspector.Breakpoint.addEventListener(WebInspector.Breakpoint.Event.AutoContinueDidChange, this._breakpointStatusDidChange, this);
58             WebInspector.Breakpoint.addEventListener(WebInspector.Breakpoint.Event.ResolvedStateDidChange, this._breakpointStatusDidChange, this);
59             WebInspector.Breakpoint.addEventListener(WebInspector.Breakpoint.Event.LocationDidChange, this._updateBreakpointLocation, this);
60
61             WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.BreakpointsEnabledDidChange, this._breakpointsEnabledDidChange, this);
62             WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.BreakpointAdded, this._breakpointAdded, this);
63             WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.BreakpointRemoved, this._breakpointRemoved, this);
64             WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ActiveCallFrameDidChange, this._activeCallFrameDidChange, this);
65
66             WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.Paused, this._debuggerDidPause, this);
67             WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.Resumed, this._debuggerDidResume, this);
68             if (WebInspector.debuggerManager.activeCallFrame)
69                 this._debuggerDidPause();
70
71             this._activeCallFrameDidChange();
72         }
73
74         WebInspector.issueManager.addEventListener(WebInspector.IssueManager.Event.IssueWasAdded, this._issueWasAdded, this);
75
76         if (this._sourceCode instanceof WebInspector.SourceMapResource || this._sourceCode.sourceMaps.length > 0)
77             WebInspector.notifications.addEventListener(WebInspector.Notification.GlobalModifierKeysDidChange, this._updateTokenTrackingControllerState, this);
78         else
79             this._sourceCode.addEventListener(WebInspector.SourceCode.Event.SourceMapAdded, this._sourceCodeSourceMapAdded, this);
80
81         sourceCode.requestContent().then(this._contentAvailable.bind(this));
82
83         // FIXME: Cmd+L shorcut doesn't actually work.
84         new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.Command, "L", this.showGoToLineDialog.bind(this), this.element);
85         new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.Control, "G", this.showGoToLineDialog.bind(this), this.element);
86     }
87
88     // Public
89
90     get sourceCode()
91     {
92         return this._sourceCode;
93     }
94
95     shown()
96     {
97         WebInspector.TextEditor.prototype.shown.call(this);
98
99         if (WebInspector.showJavaScriptTypeInformationSetting.value) {
100             if (this._typeTokenAnnotator)
101                 this._typeTokenAnnotator.resume();
102             if (this._basicBlockAnnotator)
103                 this._basicBlockAnnotator.resume();
104             if (!this._typeTokenScrollHandler && (this._typeTokenAnnotator || this._basicBlockAnnotator))
105                 this._enableScrollEventsForTypeTokenAnnotator();
106         } else {
107             if (this._typeTokenAnnotator || this._basicBlockAnnotator)
108                 this._setTypeTokenAnnotatorEnabledState(false);
109         }
110     }
111
112     hidden()
113     {
114         WebInspector.TextEditor.prototype.hidden.call(this);
115
116         this.tokenTrackingController.removeHighlightedRange();
117
118         this._dismissPopover();
119
120         this._dismissEditingController(true);
121
122         if (this._typeTokenAnnotator)
123             this._typeTokenAnnotator.pause();
124         if (this._basicBlockAnnotator)
125             this._basicBlockAnnotator.pause();
126     }
127
128     close()
129     {
130         if (this._supportsDebugging) {
131             WebInspector.Breakpoint.removeEventListener(WebInspector.Breakpoint.Event.DisabledStateDidChange, this._breakpointStatusDidChange, this);
132             WebInspector.Breakpoint.removeEventListener(WebInspector.Breakpoint.Event.AutoContinueDidChange, this._breakpointStatusDidChange, this);
133             WebInspector.Breakpoint.removeEventListener(WebInspector.Breakpoint.Event.ResolvedStateDidChange, this._breakpointStatusDidChange, this);
134             WebInspector.Breakpoint.removeEventListener(WebInspector.Breakpoint.Event.LocationDidChange, this._updateBreakpointLocation, this);
135
136             WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.BreakpointsEnabledDidChange, this._breakpointsEnabledDidChange, this);
137             WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.BreakpointAdded, this._breakpointAdded, this);
138             WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.BreakpointRemoved, this._breakpointRemoved, this);
139             WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.ActiveCallFrameDidChange, this._activeCallFrameDidChange, this);
140
141             if (this._activeCallFrameSourceCodeLocation) {
142                 this._activeCallFrameSourceCodeLocation.removeEventListener(WebInspector.SourceCodeLocation.Event.LocationChanged, this._activeCallFrameSourceCodeLocationChanged, this);
143                 delete this._activeCallFrameSourceCodeLocation;
144             }
145         }
146
147         WebInspector.issueManager.removeEventListener(WebInspector.IssueManager.Event.IssueWasAdded, this._issueWasAdded, this);
148
149         WebInspector.notifications.removeEventListener(WebInspector.Notification.GlobalModifierKeysDidChange, this._updateTokenTrackingControllerState, this);
150         this._sourceCode.removeEventListener(WebInspector.SourceCode.Event.SourceMapAdded, this._sourceCodeSourceMapAdded, this);
151     }
152
153     canBeFormatted()
154     {
155         // Currently we assume that source map resources are formatted how the author wants it.
156         // We could allow source map resources to be formatted, we would then need to make
157         // SourceCodeLocation watch listen for mappedResource's formatting changes, and keep
158         // a formatted location alongside the regular mapped location.
159         if (this._sourceCode instanceof WebInspector.SourceMapResource)
160             return false;
161
162         return WebInspector.TextEditor.prototype.canBeFormatted.call(this);
163     }
164
165     canShowTypeAnnotations()
166     {
167         return !!this._typeTokenAnnotator;
168     }
169
170     customPerformSearch(query)
171     {
172         function searchResultCallback(error, matches)
173         {
174             // Bail if the query changed since we started.
175             if (this.currentSearchQuery !== query)
176                 return;
177
178             if (error || !matches || !matches.length) {
179                 // Report zero matches.
180                 this.dispatchEventToListeners(WebInspector.TextEditor.Event.NumberOfSearchResultsDidChange);
181                 return;
182             }
183
184             var queryRegex = new RegExp(query.escapeForRegExp(), "gi");
185             var searchResults = [];
186
187             for (var i = 0; i < matches.length; ++i) {
188                 var matchLineNumber = matches[i].lineNumber;
189                 var line = this.line(matchLineNumber);
190                 if (!line)
191                     return;
192
193                 // Reset the last index to reuse the regex on a new line.
194                 queryRegex.lastIndex = 0;
195
196                 // Search the line and mark the ranges.
197                 var lineMatch = null;
198                 while (queryRegex.lastIndex + query.length <= line.length && (lineMatch = queryRegex.exec(line))) {
199                     var resultTextRange = new WebInspector.TextRange(matchLineNumber, lineMatch.index, matchLineNumber, queryRegex.lastIndex);
200                     searchResults.push(resultTextRange);
201                 }
202             }
203
204             this.addSearchResults(searchResults);
205
206             this.dispatchEventToListeners(WebInspector.TextEditor.Event.NumberOfSearchResultsDidChange);
207         }
208
209         if (this.hasEdits())
210             return false;
211
212         if (this._sourceCode instanceof WebInspector.SourceMapResource)
213             return false;
214
215         if (this._sourceCode instanceof WebInspector.Resource)
216             PageAgent.searchInResource(this._sourceCode.parentFrame.id, this._sourceCode.url, query, false, false, searchResultCallback.bind(this));
217         else if (this._sourceCode instanceof WebInspector.Script)
218             DebuggerAgent.searchInContent(this._sourceCode.id, query, false, false, searchResultCallback.bind(this));
219         return true;
220     }
221
222     showGoToLineDialog()
223     {
224         if (!this._goToLineDialog) {
225             this._goToLineDialog = new WebInspector.GoToLineDialog;
226             this._goToLineDialog.delegate = this;
227         }
228
229         this._goToLineDialog.present(this.element);
230     }
231
232     isGoToLineDialogValueValid(goToLineDialog, lineNumber)
233     {
234         return !isNaN(lineNumber) && lineNumber > 0 && lineNumber <= this.lineCount;
235     }
236
237     goToLineDialogValueWasValidated(goToLineDialog, lineNumber)
238     {
239         var position = new WebInspector.SourceCodePosition(lineNumber - 1, 0);
240         var range = new WebInspector.TextRange(lineNumber - 1, 0, lineNumber, 0);
241         this.revealPosition(position, range, false, true);
242     }
243
244     goToLineDialogWasDismissed()
245     {
246         this.focus();
247     }
248
249     contentDidChange(replacedRanges, newRanges)
250     {
251         super.contentDidChange(replacedRanges, newRanges);
252
253         if (this._ignoreContentDidChange > 0)
254             return;
255
256         for (var range of newRanges)
257             this._updateEditableMarkers(range);
258
259         if (this._typeTokenAnnotator || this._basicBlockAnnotator) {
260             this._setTypeTokenAnnotatorEnabledState(false);
261             this._typeTokenAnnotator = null;
262             this._basicBlockAnnotator = null;
263         }
264     }
265
266     toggleTypeAnnotations()
267     {
268         if (!this._typeTokenAnnotator)
269             return false;
270
271         var newActivatedState = !this._typeTokenAnnotator.isActive();
272         if (newActivatedState && this._isProbablyMinified && !this.formatted)
273             this.formatted = true;
274
275         this._setTypeTokenAnnotatorEnabledState(newActivatedState);
276         return newActivatedState;
277     }
278
279     showPopoverForTypes(types, bounds, title)
280     {
281         var content = document.createElement("div");
282         content.className = "object expandable";
283
284         var titleElement = document.createElement("div");
285         titleElement.className = "title";
286         titleElement.textContent = title;
287         content.appendChild(titleElement);
288
289         var section = new WebInspector.TypePropertiesSection(types);
290         section.expanded = true;
291         section.element.classList.add("body");
292         content.appendChild(section.element);
293
294         this._showPopover(content, bounds);
295     }
296
297     // Protected
298
299     prettyPrint(pretty)
300     {
301         // The annotators must be cleared before pretty printing takes place and resumed
302         // after so that they clear their annotations in a known state and insert new annotations
303         // in the new state.
304         var shouldResumeTypeTokenAnnotator = this._typeTokenAnnotator && this._typeTokenAnnotator.isActive();
305         var shouldResumeBasicBlockAnnotator = this._basicBlockAnnotator && this._basicBlockAnnotator.isActive();
306         if (shouldResumeTypeTokenAnnotator || shouldResumeBasicBlockAnnotator)
307             this._setTypeTokenAnnotatorEnabledState(false);
308
309         super.prettyPrint(pretty);
310
311         if (pretty || !this._isProbablyMinified) {
312             if (shouldResumeTypeTokenAnnotator || shouldResumeBasicBlockAnnotator)
313                 this._setTypeTokenAnnotatorEnabledState(true);
314         } else {
315             console.assert(!pretty && this._isProbablyMinified);
316             if (this._typeTokenAnnotator || this._basicBlockAnnotator)
317                 this._setTypeTokenAnnotatorEnabledState(false);
318         }
319     }
320
321     // Private
322
323     _unformattedLineInfoForEditorLineInfo(lineInfo)
324     {
325         if (this.formatterSourceMap)
326             return this.formatterSourceMap.formattedToOriginal(lineInfo.lineNumber, lineInfo.columnNumber);
327         return lineInfo;
328     }
329
330     _sourceCodeLocationForEditorPosition(position)
331     {
332         var lineInfo = {lineNumber: position.line, columnNumber: position.ch};
333         var unformattedLineInfo = this._unformattedLineInfoForEditorLineInfo(lineInfo);
334         return this.sourceCode.createSourceCodeLocation(unformattedLineInfo.lineNumber, unformattedLineInfo.columnNumber);
335     }
336
337     _editorLineInfoForSourceCodeLocation(sourceCodeLocation)
338     {
339         if (this._sourceCode instanceof WebInspector.SourceMapResource)
340             return {lineNumber: sourceCodeLocation.displayLineNumber, columnNumber: sourceCodeLocation.displayColumnNumber};
341         return {lineNumber: sourceCodeLocation.formattedLineNumber, columnNumber: sourceCodeLocation.formattedColumnNumber};
342     }
343
344     _breakpointForEditorLineInfo(lineInfo)
345     {
346         if (!this._breakpointMap[lineInfo.lineNumber])
347             return null;
348         return this._breakpointMap[lineInfo.lineNumber][lineInfo.columnNumber];
349     }
350
351     _addBreakpointWithEditorLineInfo(breakpoint, lineInfo)
352     {
353         if (!this._breakpointMap[lineInfo.lineNumber])
354             this._breakpointMap[lineInfo.lineNumber] = {};
355
356         this._breakpointMap[lineInfo.lineNumber][lineInfo.columnNumber] = breakpoint;
357     }
358
359     _removeBreakpointWithEditorLineInfo(breakpoint, lineInfo)
360     {
361         console.assert(breakpoint === this._breakpointMap[lineInfo.lineNumber][lineInfo.columnNumber]);
362
363         delete this._breakpointMap[lineInfo.lineNumber][lineInfo.columnNumber];
364
365         if (isEmptyObject(this._breakpointMap[lineInfo.lineNumber]))
366             delete this._breakpointMap[lineInfo.lineNumber];
367     }
368
369     _contentWillPopulate(content)
370     {
371         this.dispatchEventToListeners(WebInspector.SourceCodeTextEditor.Event.ContentWillPopulate);
372
373         // We only do the rest of this work before the first populate.
374         if (this._contentPopulated)
375             return;
376
377         if (this._supportsDebugging) {
378             this._breakpointMap = {};
379
380             var breakpoints = WebInspector.debuggerManager.breakpointsForSourceCode(this._sourceCode);
381             for (var i = 0; i < breakpoints.length; ++i) {
382                 var breakpoint = breakpoints[i];
383                 console.assert(this._matchesBreakpoint(breakpoint));
384                 var lineInfo = this._editorLineInfoForSourceCodeLocation(breakpoint.sourceCodeLocation);
385                 this._addBreakpointWithEditorLineInfo(breakpoint, lineInfo);
386                 this.setBreakpointInfoForLineAndColumn(lineInfo.lineNumber, lineInfo.columnNumber, this._breakpointInfoForBreakpoint(breakpoint));
387             }
388         }
389
390         if (this._sourceCode instanceof WebInspector.Resource)
391             this.mimeType = this._sourceCode.syntheticMIMEType;
392         else if (this._sourceCode instanceof WebInspector.Script)
393             this.mimeType = "text/javascript";
394
395         // Automatically format the content if it looks minified and it can be formatted.
396         console.assert(!this.formatted);
397         if (this.canBeFormatted()) {
398             var lastNewlineIndex = 0;
399             while (true) {
400                 var nextNewlineIndex = content.indexOf("\n", lastNewlineIndex);
401                 if (nextNewlineIndex === -1) {
402                     if (content.length - lastNewlineIndex > WebInspector.SourceCodeTextEditor.AutoFormatMinimumLineLength) {
403                         this.autoFormat = true;
404                         this._isProbablyMinified = true;
405                     }
406                     break;
407                 }
408
409                 if (nextNewlineIndex - lastNewlineIndex > WebInspector.SourceCodeTextEditor.AutoFormatMinimumLineLength) {
410                     this.autoFormat = true;
411                     this._isProbablyMinified = true;
412                     break;
413                 }
414
415                 lastNewlineIndex = nextNewlineIndex + 1;
416             }
417         }
418     }
419
420     _contentDidPopulate()
421     {
422         this._contentPopulated = true;
423
424         this.dispatchEventToListeners(WebInspector.SourceCodeTextEditor.Event.ContentDidPopulate);
425
426         // We add the issues each time content is populated. This is needed because lines might not exist
427         // if we tried added them before when the full content wasn't available. (When populating with
428         // partial script content this can be called multiple times.)
429
430         this._reinsertAllIssues();
431
432         this._updateEditableMarkers();
433     }
434
435     _populateWithContent(content)
436     {
437         content = content || "";
438
439         this._contentWillPopulate(content);
440         this.string = content;
441
442         this._makeTypeTokenAnnotator();
443         this._makeBasicBlockAnnotator();
444
445         if (WebInspector.showJavaScriptTypeInformationSetting.value) {
446             if (this._basicBlockAnnotator || this._typeTokenAnnotator)
447                 this._setTypeTokenAnnotatorEnabledState(true);
448         }
449
450         this._contentDidPopulate();
451     }
452
453     _contentAvailable(parameters)
454     {
455         // Return if resource is not available.
456         if (parameters.error)
457             return;
458
459         var sourceCode = parameters.sourceCode;
460         var content = parameters.content;
461         var base64Encoded = parameters.base64Encoded;
462
463         console.assert(sourceCode === this._sourceCode);
464         console.assert(!base64Encoded);
465
466         // Abort if the full content populated while waiting for this async callback.
467         if (this._fullContentPopulated)
468             return;
469
470         this._fullContentPopulated = true;
471         this._invalidLineNumbers = {};
472
473         this._populateWithContent(content);
474     }
475
476     _breakpointStatusDidChange(event)
477     {
478         this._updateBreakpointStatus(event.target);
479     }
480
481     _breakpointsEnabledDidChange()
482     {
483         console.assert(this._supportsDebugging);
484
485         var breakpoints = WebInspector.debuggerManager.breakpointsForSourceCode(this._sourceCode);
486         for (var breakpoint of breakpoints)
487             this._updateBreakpointStatus(breakpoint);
488     }
489
490     _updateBreakpointStatus(breakpoint)
491     {
492         console.assert(this._supportsDebugging);
493
494         if (!this._contentPopulated)
495             return;
496
497         if (!this._matchesBreakpoint(breakpoint))
498             return;
499
500         var lineInfo = this._editorLineInfoForSourceCodeLocation(breakpoint.sourceCodeLocation);
501         this.setBreakpointInfoForLineAndColumn(lineInfo.lineNumber, lineInfo.columnNumber, this._breakpointInfoForBreakpoint(breakpoint));
502     }
503
504     _updateBreakpointLocation(event)
505     {
506         console.assert(this._supportsDebugging);
507
508         if (!this._contentPopulated)
509             return;
510
511         var breakpoint = event.target;
512         if (!this._matchesBreakpoint(breakpoint))
513             return;
514
515         if (this._ignoreAllBreakpointLocationUpdates)
516             return;
517
518         if (breakpoint === this._ignoreLocationUpdateBreakpoint)
519             return;
520
521         var sourceCodeLocation = breakpoint.sourceCodeLocation;
522
523         if (this._sourceCode instanceof WebInspector.SourceMapResource) {
524             // Update our breakpoint location if the display location changed.
525             if (sourceCodeLocation.displaySourceCode !== this._sourceCode)
526                 return;
527             var oldLineInfo = {lineNumber: event.data.oldDisplayLineNumber, columnNumber: event.data.oldDisplayColumnNumber};
528             var newLineInfo = {lineNumber: sourceCodeLocation.displayLineNumber, columnNumber: sourceCodeLocation.displayColumnNumber};
529         } else {
530             // Update our breakpoint location if the original location changed.
531             if (sourceCodeLocation.sourceCode !== this._sourceCode)
532                 return;
533             var oldLineInfo = {lineNumber: event.data.oldFormattedLineNumber, columnNumber: event.data.oldFormattedColumnNumber};
534             var newLineInfo = {lineNumber: sourceCodeLocation.formattedLineNumber, columnNumber: sourceCodeLocation.formattedColumnNumber};
535         }
536
537         var existingBreakpoint = this._breakpointForEditorLineInfo(oldLineInfo);
538         if (!existingBreakpoint)
539             return;
540
541         console.assert(breakpoint === existingBreakpoint);
542
543         this.setBreakpointInfoForLineAndColumn(oldLineInfo.lineNumber, oldLineInfo.columnNumber, null);
544         this.setBreakpointInfoForLineAndColumn(newLineInfo.lineNumber, newLineInfo.columnNumber, this._breakpointInfoForBreakpoint(breakpoint));
545
546         this._removeBreakpointWithEditorLineInfo(breakpoint, oldLineInfo);
547         this._addBreakpointWithEditorLineInfo(breakpoint, newLineInfo);
548     }
549
550     _breakpointAdded(event)
551     {
552         console.assert(this._supportsDebugging);
553
554         if (!this._contentPopulated)
555             return;
556
557         var breakpoint = event.data.breakpoint;
558         if (!this._matchesBreakpoint(breakpoint))
559             return;
560
561         if (breakpoint === this._ignoreBreakpointAddedBreakpoint)
562             return;
563
564         var lineInfo = this._editorLineInfoForSourceCodeLocation(breakpoint.sourceCodeLocation);
565         this._addBreakpointWithEditorLineInfo(breakpoint, lineInfo);
566         this.setBreakpointInfoForLineAndColumn(lineInfo.lineNumber, lineInfo.columnNumber, this._breakpointInfoForBreakpoint(breakpoint));
567     }
568
569     _breakpointRemoved(event)
570     {
571         console.assert(this._supportsDebugging);
572
573         if (!this._contentPopulated)
574             return;
575
576         var breakpoint = event.data.breakpoint;
577         if (!this._matchesBreakpoint(breakpoint))
578             return;
579
580         if (breakpoint === this._ignoreBreakpointRemovedBreakpoint)
581             return;
582
583         var lineInfo = this._editorLineInfoForSourceCodeLocation(breakpoint.sourceCodeLocation);
584         this._removeBreakpointWithEditorLineInfo(breakpoint, lineInfo);
585         this.setBreakpointInfoForLineAndColumn(lineInfo.lineNumber, lineInfo.columnNumber, null);
586     }
587
588     _activeCallFrameDidChange()
589     {
590         console.assert(this._supportsDebugging);
591
592         if (this._activeCallFrameSourceCodeLocation) {
593             this._activeCallFrameSourceCodeLocation.removeEventListener(WebInspector.SourceCodeLocation.Event.LocationChanged, this._activeCallFrameSourceCodeLocationChanged, this);
594             delete this._activeCallFrameSourceCodeLocation;
595         }
596
597         var activeCallFrame = WebInspector.debuggerManager.activeCallFrame;
598         if (!activeCallFrame || !this._matchesSourceCodeLocation(activeCallFrame.sourceCodeLocation)) {
599             this.executionLineNumber = NaN;
600             this.executionColumnNumber = NaN;
601             return;
602         }
603
604         this._dismissPopover();
605
606         this._activeCallFrameSourceCodeLocation = activeCallFrame.sourceCodeLocation;
607         this._activeCallFrameSourceCodeLocation.addEventListener(WebInspector.SourceCodeLocation.Event.LocationChanged, this._activeCallFrameSourceCodeLocationChanged, this);
608
609         // Don't return early if the line number didn't change. The execution state still
610         // could have changed (e.g. continuing in a loop with a breakpoint inside).
611
612         var lineInfo = this._editorLineInfoForSourceCodeLocation(activeCallFrame.sourceCodeLocation);
613         this.executionLineNumber = lineInfo.lineNumber;
614         this.executionColumnNumber = lineInfo.columnNumber;
615
616         // If we have full content or this source code isn't a Resource we can return early.
617         // Script source code populates from the request started in the constructor.
618         if (this._fullContentPopulated || !(this._sourceCode instanceof WebInspector.Resource) || this._requestingScriptContent)
619             return;
620
621         // Since we are paused in the debugger we need to show some content, and since the Resource
622         // content hasn't populated yet we need to populate with content from the Scripts by URL.
623         // Document resources will attempt to populate the scripts as inline (in <script> tags.)
624         // Other resources are assumed to be full scripts (JavaScript resources).
625         if (this._sourceCode.type === WebInspector.Resource.Type.Document)
626             this._populateWithInlineScriptContent();
627         else
628             this._populateWithScriptContent();
629     }
630
631     _activeCallFrameSourceCodeLocationChanged(event)
632     {
633         console.assert(!isNaN(this.executionLineNumber));
634         if (isNaN(this.executionLineNumber))
635             return;
636
637         console.assert(WebInspector.debuggerManager.activeCallFrame);
638         console.assert(this._activeCallFrameSourceCodeLocation === WebInspector.debuggerManager.activeCallFrame.sourceCodeLocation);
639
640         var lineInfo = this._editorLineInfoForSourceCodeLocation(this._activeCallFrameSourceCodeLocation);
641         this.executionLineNumber = lineInfo.lineNumber;
642         this.executionColumnNumber = lineInfo.columnNumber;
643     }
644
645     _populateWithInlineScriptContent()
646     {
647         console.assert(this._sourceCode instanceof WebInspector.Resource);
648         console.assert(!this._fullContentPopulated);
649         console.assert(!this._requestingScriptContent);
650
651         var scripts = this._sourceCode.scripts;
652         console.assert(scripts.length);
653         if (!scripts.length)
654             return;
655
656         var pendingRequestCount = scripts.length;
657
658         // If the number of scripts hasn't change since the last populate, then there is nothing to do.
659         if (this._inlineScriptContentPopulated === pendingRequestCount)
660             return;
661
662         this._inlineScriptContentPopulated = pendingRequestCount;
663
664         function scriptContentAvailable(parameters)
665         {
666             // Return early if we are still waiting for content from other scripts.
667             if (--pendingRequestCount)
668                 return;
669
670             delete this._requestingScriptContent;
671
672             // Abort if the full content populated while waiting for these async callbacks.
673             if (this._fullContentPopulated)
674                 return;
675
676             var scriptOpenTag = "<script>";
677             var scriptCloseTag = "</script>";
678
679             var content = "";
680             var lineNumber = 0;
681             var columnNumber = 0;
682
683             this._invalidLineNumbers = {};
684
685             for (var i = 0; i < scripts.length; ++i) {
686                 // Fill the line gap with newline characters.
687                 for (var newLinesCount = scripts[i].range.startLine - lineNumber; newLinesCount > 0; --newLinesCount) {
688                     if (!columnNumber)
689                         this._invalidLineNumbers[scripts[i].range.startLine - newLinesCount] = true;
690                     columnNumber = 0;
691                     content += "\n";
692                 }
693
694                 // Fill the column gap with space characters.
695                 for (var spacesCount = scripts[i].range.startColumn - columnNumber - scriptOpenTag.length; spacesCount > 0; --spacesCount)
696                     content += " ";
697
698                 // Add script tags and content.
699                 content += scriptOpenTag;
700                 content += scripts[i].content;
701                 content += scriptCloseTag;
702
703                 lineNumber = scripts[i].range.endLine;
704                 columnNumber = scripts[i].range.endColumn + scriptCloseTag.length;
705             }
706
707             this._populateWithContent(content);
708         }
709
710         this._requestingScriptContent = true;
711
712         var boundScriptContentAvailable = scriptContentAvailable.bind(this);
713         for (var i = 0; i < scripts.length; ++i)
714             scripts[i].requestContent().then(boundScriptContentAvailable);
715     }
716
717     _populateWithScriptContent()
718     {
719         console.assert(this._sourceCode instanceof WebInspector.Resource);
720         console.assert(!this._fullContentPopulated);
721         console.assert(!this._requestingScriptContent);
722
723         // We can assume this resource only has one script that starts at line/column 0.
724         var scripts = this._sourceCode.scripts;
725         console.assert(scripts.length === 1);
726         if (!scripts.length)
727             return;
728
729         console.assert(scripts[0].range.startLine === 0);
730         console.assert(scripts[0].range.startColumn === 0);
731
732         function scriptContentAvailable(parameters)
733         {
734             var content = parameters.content;
735             delete this._requestingScriptContent;
736
737             // Abort if the full content populated while waiting for this async callback.
738             if (this._fullContentPopulated)
739                 return;
740
741             // This is the full content.
742             this._fullContentPopulated = true;
743
744             this._populateWithContent(content);
745         }
746
747         this._requestingScriptContent = true;
748
749         scripts[0].requestContent().then(scriptContentAvailable.bind(this));
750     }
751
752     _matchesSourceCodeLocation(sourceCodeLocation)
753     {
754         if (this._sourceCode instanceof WebInspector.SourceMapResource)
755             return sourceCodeLocation.displaySourceCode === this._sourceCode;
756         if (this._sourceCode instanceof WebInspector.Resource)
757             return sourceCodeLocation.sourceCode.url === this._sourceCode.url;
758         if (this._sourceCode instanceof WebInspector.Script)
759             return sourceCodeLocation.sourceCode === this._sourceCode;
760         return false;
761     }
762
763     _matchesBreakpoint(breakpoint)
764     {
765         console.assert(this._supportsDebugging);
766         if (this._sourceCode instanceof WebInspector.SourceMapResource)
767             return breakpoint.sourceCodeLocation.displaySourceCode === this._sourceCode;
768         if (this._sourceCode instanceof WebInspector.Resource)
769             return breakpoint.url === this._sourceCode.url;
770         if (this._sourceCode instanceof WebInspector.Script)
771             return breakpoint.url === this._sourceCode.url || breakpoint.scriptIdentifier === this._sourceCode.id;
772         return false;
773     }
774
775     _matchesIssue(issue)
776     {
777         if (this._sourceCode instanceof WebInspector.Resource)
778             return issue.url === this._sourceCode.url;
779         // FIXME: Support issues for Scripts based on id, not only by URL.
780         if (this._sourceCode instanceof WebInspector.Script)
781             return issue.url === this._sourceCode.url;
782         return false;
783     }
784
785     _issueWasAdded(event)
786     {
787         var issue = event.data.issue;
788         if (!this._matchesIssue(issue))
789             return;
790
791         this._addIssue(issue);
792     }
793
794     _addIssue(issue)
795     {
796         // FIXME: Issue should have a SourceCodeLocation.
797         var sourceCodeLocation = this._sourceCode.createSourceCodeLocation(issue.lineNumber, issue.columnNumber);
798         var lineNumber = sourceCodeLocation.formattedLineNumber;
799
800         var lineNumberIssues = this._issuesLineNumberMap.get(lineNumber);
801         if (!lineNumberIssues) {
802             lineNumberIssues = [];
803             this._issuesLineNumberMap.set(lineNumber, lineNumberIssues);
804         }
805
806         // Avoid displaying duplicate issues on the same line.
807         for (var existingIssue of lineNumberIssues) {
808             if (existingIssue.columnNumber === issue.columnNumber && existingIssue.text === issue.text)
809                 return;
810         }
811
812         lineNumberIssues.push(issue);
813
814         if (issue.level === WebInspector.IssueMessage.Level.Error)
815             this.addStyleClassToLine(lineNumber, WebInspector.SourceCodeTextEditor.LineErrorStyleClassName);
816         else if (issue.level === WebInspector.IssueMessage.Level.Warning)
817             this.addStyleClassToLine(lineNumber, WebInspector.SourceCodeTextEditor.LineWarningStyleClassName);
818         else
819             console.error("Unknown issue level");
820
821         var widget = this._issueWidgetForLine(lineNumber);
822         if (widget) {
823             if (issue.level === WebInspector.IssueMessage.Level.Error)
824                 widget.widgetElement.classList.add(WebInspector.SourceCodeTextEditor.LineErrorStyleClassName);
825             else if (issue.level === WebInspector.IssueMessage.Level.Warning)
826                 widget.widgetElement.classList.add(WebInspector.SourceCodeTextEditor.LineWarningStyleClassName);
827
828             this._updateIssueWidgetForIssues(widget, lineNumberIssues);
829         }
830     }
831
832     _issueWidgetForLine(lineNumber)
833     {
834         var widget = this._widgetMap.get(lineNumber);
835         if (widget)
836             return widget;
837
838         widget = this.createWidgetForLine(lineNumber);
839         if (!widget)
840             return null;
841
842         var widgetElement = widget.widgetElement;
843         widgetElement.classList.add("issue-widget", "inline");
844         widgetElement.addEventListener("click", this._handleWidgetClick.bind(this, widget, lineNumber));
845
846         this._widgetMap.set(lineNumber, widget);
847
848         return widget;
849     }
850
851     _iconClassNameForIssueLevel(level)
852     {
853         if (level === WebInspector.IssueMessage.Level.Warning)
854             return "icon-warning";
855
856         console.assert(level === WebInspector.IssueMessage.Level.Error);
857         return "icon-error";
858     }
859
860     _updateIssueWidgetForIssues(widget, issues)
861     {
862         var widgetElement = widget.widgetElement;
863         widgetElement.removeChildren();
864
865         if (widgetElement.classList.contains("inline") || issues.length === 1) {
866             var arrowElement = widgetElement.appendChild(document.createElement("span"));
867             arrowElement.className = "arrow";
868
869             var iconElement = widgetElement.appendChild(document.createElement("span"));
870             iconElement.className = "icon";
871
872             var textElement = widgetElement.appendChild(document.createElement("span"));
873             textElement.className = "text";
874
875             if (issues.length === 1) {
876                 iconElement.classList.add(this._iconClassNameForIssueLevel(issues[0].level));
877                 textElement.textContent = issues[0].text;
878             } else {
879                 var errorsCount = 0;
880                 var warningsCount = 0;
881                 for (var issue of issues) {
882                     if (issue.level === WebInspector.IssueMessage.Level.Error)
883                         ++errorsCount;
884                     else if (issue.level === WebInspector.IssueMessage.Level.Warning)
885                         ++warningsCount;
886                 }
887
888                 if (warningsCount && errorsCount) {
889                     iconElement.classList.add(this._iconClassNameForIssueLevel(issue.level));
890                     textElement.textContent = WebInspector.UIString("%d Errors, %d Warnings").format(errorsCount, warningsCount);
891                 } else if (errorsCount) {
892                     iconElement.classList.add(this._iconClassNameForIssueLevel(issue.level));
893                     textElement.textContent = WebInspector.UIString("%d Errors").format(errorsCount);
894                 } else if (warningsCount) {
895                     iconElement.classList.add(this._iconClassNameForIssueLevel(issue.level));
896                     textElement.textContent = WebInspector.UIString("%d Warnings").format(warningsCount);
897                 }
898
899                 widget[WebInspector.SourceCodeTextEditor.WidgetContainsMultipleIssuesSymbol] = true;
900             }
901         } else {
902             for (var issue of issues) {
903                 var iconElement = widgetElement.appendChild(document.createElement("span"));
904                 iconElement.className = "icon";
905                 iconElement.classList.add(this._iconClassNameForIssueLevel(issue.level));
906
907                 var textElement = widgetElement.appendChild(document.createElement("span"));
908                 textElement.className = "text";
909                 textElement.textContent = issue.text;
910
911                 widgetElement.appendChild(document.createElement("br"));
912             }
913         }
914
915         widget.update();
916     }
917
918     _isWidgetToggleable(widget)
919     {
920         if (widget[WebInspector.SourceCodeTextEditor.WidgetContainsMultipleIssuesSymbol])
921             return true;
922
923         if (!widget.widgetElement.classList.contains("inline"))
924             return true;
925
926         var textElement = widget.widgetElement.lastChild;
927         if (textElement.offsetWidth !== textElement.scrollWidth)
928             return true;
929
930         return false;
931     }
932
933     _handleWidgetClick(widget, lineNumber, event)
934     {
935         if (!this._isWidgetToggleable(widget))
936             return;
937
938         widget.widgetElement.classList.toggle("inline");
939
940         var lineNumberIssues = this._issuesLineNumberMap.get(lineNumber);
941         this._updateIssueWidgetForIssues(widget, lineNumberIssues);
942     }
943
944     _breakpointInfoForBreakpoint(breakpoint)
945     {
946         return {resolved: breakpoint.resolved, disabled: breakpoint.disabled, autoContinue: breakpoint.autoContinue};
947     }
948
949     get _supportsDebugging()
950     {
951         if (this._sourceCode instanceof WebInspector.Resource)
952             return this._sourceCode.type === WebInspector.Resource.Type.Document || this._sourceCode.type === WebInspector.Resource.Type.Script;
953         if (this._sourceCode instanceof WebInspector.Script)
954             return true;
955         return false;
956     }
957
958     // TextEditor Delegate
959
960     textEditorBaseURL(textEditor)
961     {
962         return this._sourceCode.url;
963     }
964
965     textEditorShouldHideLineNumber(textEditor, lineNumber)
966     {
967         return lineNumber in this._invalidLineNumbers;
968     }
969
970     textEditorGutterContextMenu(textEditor, lineNumber, columnNumber, editorBreakpoints, event)
971     {
972         if (!this._supportsDebugging)
973             return;
974
975         event.preventDefault();
976
977         function continueToLocation()
978         {
979             WebInspector.debuggerManager.continueToLocation(script.id, sourceCodeLocation.lineNumber, sourceCodeLocation.columnNumber);
980         }
981
982         function addBreakpoint()
983         {
984             var data = this.textEditorBreakpointAdded(this, lineNumber, columnNumber);
985             this.setBreakpointInfoForLineAndColumn(data.lineNumber, data.columnNumber, data.breakpointInfo);
986         }
987
988         function revealInSidebar()
989         {
990             WebInspector.debuggerSidebarPanel.show();
991             var treeElement = WebInspector.debuggerSidebarPanel.treeElementForRepresentedObject(breakpoint);
992             if (treeElement)
993                 treeElement.revealAndSelect();
994         }
995
996         var contextMenu = new WebInspector.ContextMenu(event);
997
998         // Paused. Add Continue to Here option only if we have a script identifier for the location.
999         if (WebInspector.debuggerManager.paused) {
1000             var editorLineInfo = {lineNumber, columnNumber};
1001             var unformattedLineInfo = this._unformattedLineInfoForEditorLineInfo(editorLineInfo);
1002             var sourceCodeLocation = this._sourceCode.createSourceCodeLocation(unformattedLineInfo.lineNumber, unformattedLineInfo.columnNumber);
1003
1004             if (sourceCodeLocation.sourceCode instanceof WebInspector.Script)
1005                 var script = sourceCodeLocation.sourceCode;
1006             else if (sourceCodeLocation.sourceCode instanceof WebInspector.Resource)
1007                 var script = sourceCodeLocation.sourceCode.scriptForLocation(sourceCodeLocation);
1008
1009             if (script) {
1010
1011                 contextMenu.appendItem(WebInspector.UIString("Continue to Here"), continueToLocation);
1012                 contextMenu.appendSeparator();
1013             }
1014         }
1015
1016         var breakpoints = [];
1017         for (var i = 0; i < editorBreakpoints.length; ++i) {
1018             var lineInfo = editorBreakpoints[i];
1019             var breakpoint = this._breakpointForEditorLineInfo(lineInfo);
1020             console.assert(breakpoint);
1021             if (breakpoint)
1022                 breakpoints.push(breakpoint);
1023         }
1024
1025         // No breakpoints.
1026         if (!breakpoints.length) {
1027
1028             contextMenu.appendItem(WebInspector.UIString("Add Breakpoint"), addBreakpoint.bind(this));
1029             contextMenu.show();
1030             return;
1031         }
1032
1033         // Single breakpoint.
1034         if (breakpoints.length === 1) {
1035             var breakpoint = breakpoints[0];
1036
1037             breakpoint.appendContextMenuItems(contextMenu, event.target);
1038             contextMenu.appendSeparator();
1039             contextMenu.appendItem(WebInspector.UIString("Reveal in Debugger Navigation Sidebar"), revealInSidebar);
1040             contextMenu.show();
1041             return;
1042         }
1043
1044         // Multiple breakpoints.
1045         var shouldDisable = false;
1046         for (var i = 0; i < breakpoints.length; ++i) {
1047             if (!breakpoints[i].disabled) {
1048                 shouldDisable = true;
1049                 break;
1050             }
1051         }
1052
1053         function removeBreakpoints()
1054         {
1055             for (var i = 0; i < breakpoints.length; ++i) {
1056                 var breakpoint = breakpoints[i];
1057                 if (WebInspector.debuggerManager.isBreakpointRemovable(breakpoint))
1058                     WebInspector.debuggerManager.removeBreakpoint(breakpoint);
1059             }
1060         }
1061
1062         function toggleBreakpoints()
1063         {
1064             for (var i = 0; i < breakpoints.length; ++i)
1065                 breakpoints[i].disabled = shouldDisable;
1066         }
1067
1068         if (shouldDisable)
1069             contextMenu.appendItem(WebInspector.UIString("Disable Breakpoints"), toggleBreakpoints.bind(this));
1070         else
1071             contextMenu.appendItem(WebInspector.UIString("Enable Breakpoints"), toggleBreakpoints.bind(this));
1072         contextMenu.appendItem(WebInspector.UIString("Delete Breakpoints"), removeBreakpoints.bind(this));
1073         contextMenu.show();
1074     }
1075
1076     textEditorBreakpointAdded(textEditor, lineNumber, columnNumber)
1077     {
1078         if (!this._supportsDebugging)
1079             return null;
1080
1081         var editorLineInfo = {lineNumber, columnNumber};
1082         var unformattedLineInfo = this._unformattedLineInfoForEditorLineInfo(editorLineInfo);
1083         var sourceCodeLocation = this._sourceCode.createSourceCodeLocation(unformattedLineInfo.lineNumber, unformattedLineInfo.columnNumber);
1084         var breakpoint = new WebInspector.Breakpoint(sourceCodeLocation);
1085
1086         var lineInfo = this._editorLineInfoForSourceCodeLocation(breakpoint.sourceCodeLocation);
1087         this._addBreakpointWithEditorLineInfo(breakpoint, lineInfo);
1088
1089         this._ignoreBreakpointAddedBreakpoint = breakpoint;
1090
1091         var shouldSkipEventDispatch = false;
1092         var shouldSpeculativelyResolveBreakpoint = true;
1093         WebInspector.debuggerManager.addBreakpoint(breakpoint, shouldSkipEventDispatch, shouldSpeculativelyResolveBreakpoint);
1094         delete this._ignoreBreakpointAddedBreakpoint;
1095
1096         // Return the more accurate location and breakpoint info.
1097         return {
1098             breakpointInfo: this._breakpointInfoForBreakpoint(breakpoint),
1099             lineNumber: lineInfo.lineNumber,
1100             columnNumber: lineInfo.columnNumber
1101         };
1102     }
1103
1104     textEditorBreakpointRemoved(textEditor, lineNumber, columnNumber)
1105     {
1106         console.assert(this._supportsDebugging);
1107         if (!this._supportsDebugging)
1108             return;
1109
1110         var lineInfo = {lineNumber, columnNumber};
1111         var breakpoint = this._breakpointForEditorLineInfo(lineInfo);
1112         console.assert(breakpoint);
1113         if (!breakpoint)
1114             return;
1115
1116         this._removeBreakpointWithEditorLineInfo(breakpoint, lineInfo);
1117
1118         this._ignoreBreakpointRemovedBreakpoint = breakpoint;
1119         WebInspector.debuggerManager.removeBreakpoint(breakpoint);
1120         delete this._ignoreBreakpointAddedBreakpoint;
1121     }
1122
1123     textEditorBreakpointMoved(textEditor, oldLineNumber, oldColumnNumber, newLineNumber, newColumnNumber)
1124     {
1125         console.assert(this._supportsDebugging);
1126         if (!this._supportsDebugging)
1127             return;
1128
1129         var oldLineInfo = {lineNumber: oldLineNumber, columnNumber: oldColumnNumber};
1130         var breakpoint = this._breakpointForEditorLineInfo(oldLineInfo);
1131         console.assert(breakpoint);
1132         if (!breakpoint)
1133             return;
1134
1135         this._removeBreakpointWithEditorLineInfo(breakpoint, oldLineInfo);
1136
1137         var newLineInfo = {lineNumber: newLineNumber, columnNumber: newColumnNumber};
1138         var unformattedNewLineInfo = this._unformattedLineInfoForEditorLineInfo(newLineInfo);
1139         this._ignoreLocationUpdateBreakpoint = breakpoint;
1140         breakpoint.sourceCodeLocation.update(this._sourceCode, unformattedNewLineInfo.lineNumber, unformattedNewLineInfo.columnNumber);
1141         delete this._ignoreLocationUpdateBreakpoint;
1142
1143         var accurateNewLineInfo = this._editorLineInfoForSourceCodeLocation(breakpoint.sourceCodeLocation);
1144         this._addBreakpointWithEditorLineInfo(breakpoint, accurateNewLineInfo);
1145
1146         if (accurateNewLineInfo.lineNumber !== newLineInfo.lineNumber || accurateNewLineInfo.columnNumber !== newLineInfo.columnNumber)
1147             this.updateBreakpointLineAndColumn(newLineInfo.lineNumber, newLineInfo.columnNumber, accurateNewLineInfo.lineNumber, accurateNewLineInfo.columnNumber);
1148     }
1149
1150     textEditorBreakpointClicked(textEditor, lineNumber, columnNumber)
1151     {
1152         console.assert(this._supportsDebugging);
1153         if (!this._supportsDebugging)
1154             return;
1155
1156         var breakpoint = this._breakpointForEditorLineInfo({lineNumber, columnNumber});
1157         console.assert(breakpoint);
1158         if (!breakpoint)
1159             return;
1160
1161         breakpoint.cycleToNextMode();
1162     }
1163
1164     textEditorUpdatedFormatting(textEditor)
1165     {
1166         this._ignoreAllBreakpointLocationUpdates = true;
1167         this._sourceCode.formatterSourceMap = this.formatterSourceMap;
1168         delete this._ignoreAllBreakpointLocationUpdates;
1169
1170         // Always put the source map on both the Script and Resource if both exist. For example,
1171         // if this SourceCode is a Resource, then there might also be a Script. In the debugger,
1172         // the backend identifies call frames with Script line and column information, and the
1173         // Script needs the formatter source map to produce the proper display line and column.
1174         if (this._sourceCode instanceof WebInspector.Resource && !(this._sourceCode instanceof WebInspector.SourceMapResource)) {
1175             var scripts = this._sourceCode.scripts;
1176             for (var i = 0; i < scripts.length; ++i)
1177                 scripts[i].formatterSourceMap = this.formatterSourceMap;
1178         } else if (this._sourceCode instanceof WebInspector.Script) {
1179             if (this._sourceCode.resource)
1180                 this._sourceCode.resource.formatterSourceMap = this.formatterSourceMap;
1181         }
1182
1183         // Some breakpoints / issues may have moved, some might not have. Just go through
1184         // and remove and reinsert all the breakpoints / issues.
1185
1186         var oldBreakpointMap = this._breakpointMap;
1187         this._breakpointMap = {};
1188
1189         for (var lineNumber in oldBreakpointMap) {
1190             for (var columnNumber in oldBreakpointMap[lineNumber]) {
1191                 var breakpoint = oldBreakpointMap[lineNumber][columnNumber];
1192                 var newLineInfo = this._editorLineInfoForSourceCodeLocation(breakpoint.sourceCodeLocation);
1193                 this._addBreakpointWithEditorLineInfo(breakpoint, newLineInfo);
1194                 this.setBreakpointInfoForLineAndColumn(lineNumber, columnNumber, null);
1195                 this.setBreakpointInfoForLineAndColumn(newLineInfo.lineNumber, newLineInfo.columnNumber, this._breakpointInfoForBreakpoint(breakpoint));
1196             }
1197         }
1198
1199         this._reinsertAllIssues();
1200     }
1201
1202     _clearWidgets()
1203     {
1204         for (var widget of this._widgetMap.values())
1205             widget.clear();
1206
1207         this._widgetMap.clear();
1208     }
1209
1210     _reinsertAllIssues()
1211     {
1212         this._issuesLineNumberMap.clear();
1213         this._clearWidgets();
1214
1215         var issues = WebInspector.issueManager.issuesForSourceCode(this._sourceCode);
1216         for (var issue of issues) {
1217             console.assert(this._matchesIssue(issue));
1218             this._addIssue(issue);
1219         }
1220     }
1221
1222     _debuggerDidPause(event)
1223     {
1224         this._updateTokenTrackingControllerState();
1225         if (this._typeTokenAnnotator && this._typeTokenAnnotator.isActive())
1226             this._typeTokenAnnotator.refresh();
1227         if (this._basicBlockAnnotator && this._basicBlockAnnotator.isActive())
1228             this._basicBlockAnnotator.refresh();
1229     }
1230
1231     _debuggerDidResume(event)
1232     {
1233         this._updateTokenTrackingControllerState();
1234         this._dismissPopover();
1235         if (this._typeTokenAnnotator && this._typeTokenAnnotator.isActive())
1236             this._typeTokenAnnotator.refresh();
1237         if (this._basicBlockAnnotator && this._basicBlockAnnotator.isActive())
1238             this._basicBlockAnnotator.refresh();
1239     }
1240
1241     _sourceCodeSourceMapAdded(event)
1242     {
1243         WebInspector.notifications.addEventListener(WebInspector.Notification.GlobalModifierKeysDidChange, this._updateTokenTrackingControllerState, this);
1244         this._sourceCode.removeEventListener(WebInspector.SourceCode.Event.SourceMapAdded, this._sourceCodeSourceMapAdded, this);
1245
1246         this._updateTokenTrackingControllerState();
1247     }
1248
1249     _updateTokenTrackingControllerState()
1250     {
1251         var mode = WebInspector.CodeMirrorTokenTrackingController.Mode.None;
1252         if (WebInspector.debuggerManager.paused)
1253             mode = WebInspector.CodeMirrorTokenTrackingController.Mode.JavaScriptExpression;
1254         else if (this._typeTokenAnnotator && this._typeTokenAnnotator.isActive())
1255             mode = WebInspector.CodeMirrorTokenTrackingController.Mode.JavaScriptTypeInformation;
1256         else if (this._hasColorMarkers())
1257             mode = WebInspector.CodeMirrorTokenTrackingController.Mode.MarkedTokens;
1258         else if ((this._sourceCode instanceof WebInspector.SourceMapResource || this._sourceCode.sourceMaps.length !== 0) && WebInspector.modifierKeys.metaKey && !WebInspector.modifierKeys.altKey && !WebInspector.modifierKeys.shiftKey)
1259             mode = WebInspector.CodeMirrorTokenTrackingController.Mode.NonSymbolTokens;
1260
1261         this.tokenTrackingController.enabled = mode !== WebInspector.CodeMirrorTokenTrackingController.Mode.None;
1262
1263         if (mode === this.tokenTrackingController.mode)
1264             return;
1265
1266         switch (mode) {
1267         case WebInspector.CodeMirrorTokenTrackingController.Mode.MarkedTokens:
1268             this.tokenTrackingController.mouseOverDelayDuration = 0;
1269             this.tokenTrackingController.mouseOutReleaseDelayDuration = 0;
1270             break;
1271         case WebInspector.CodeMirrorTokenTrackingController.Mode.NonSymbolTokens:
1272             this.tokenTrackingController.mouseOverDelayDuration = 0;
1273             this.tokenTrackingController.mouseOutReleaseDelayDuration = 0;
1274             this.tokenTrackingController.classNameForHighlightedRange = WebInspector.CodeMirrorTokenTrackingController.JumpToSymbolHighlightStyleClassName;
1275             this._dismissPopover();
1276             break;
1277         case WebInspector.CodeMirrorTokenTrackingController.Mode.JavaScriptExpression:
1278         case WebInspector.CodeMirrorTokenTrackingController.Mode.JavaScriptTypeInformation:
1279             this.tokenTrackingController.mouseOverDelayDuration = WebInspector.SourceCodeTextEditor.DurationToMouseOverTokenToMakeHoveredToken;
1280             this.tokenTrackingController.mouseOutReleaseDelayDuration = WebInspector.SourceCodeTextEditor.DurationToMouseOutOfHoveredTokenToRelease;
1281             this.tokenTrackingController.classNameForHighlightedRange = WebInspector.SourceCodeTextEditor.HoveredExpressionHighlightStyleClassName;
1282             break;
1283         }
1284
1285         this.tokenTrackingController.mode = mode;
1286     }
1287
1288     _hasColorMarkers()
1289     {
1290         for (var marker of this.markers) {
1291             if (marker.type === WebInspector.TextMarker.Type.Color)
1292                 return true;
1293         }
1294         return false;
1295     }
1296
1297     // CodeMirrorTokenTrackingController Delegate
1298
1299     tokenTrackingControllerCanReleaseHighlightedRange(tokenTrackingController, element)
1300     {
1301         if (!this._popover)
1302             return true;
1303
1304         if (!window.getSelection().isCollapsed && this._popover.element.contains(window.getSelection().anchorNode))
1305             return false;
1306
1307         return true;
1308     }
1309
1310     tokenTrackingControllerHighlightedRangeReleased(tokenTrackingController)
1311     {
1312         if (!this._mouseIsOverPopover)
1313             this._dismissPopover();
1314     }
1315
1316     tokenTrackingControllerHighlightedRangeWasClicked(tokenTrackingController)
1317     {
1318         if (this.tokenTrackingController.mode !== WebInspector.CodeMirrorTokenTrackingController.Mode.NonSymbolTokens)
1319             return;
1320
1321         // Links are handled by TextEditor.
1322         if (/\blink\b/.test(this.tokenTrackingController.candidate.hoveredToken.type))
1323             return;
1324
1325         var sourceCodeLocation = this._sourceCodeLocationForEditorPosition(this.tokenTrackingController.candidate.hoveredTokenRange.start);
1326         if (this.sourceCode instanceof WebInspector.SourceMapResource)
1327             WebInspector.showOriginalOrFormattedSourceCodeLocation(sourceCodeLocation);
1328         else
1329             WebInspector.showSourceCodeLocation(sourceCodeLocation);
1330     }
1331
1332     tokenTrackingControllerNewHighlightCandidate(tokenTrackingController, candidate)
1333     {
1334         if (this.tokenTrackingController.mode === WebInspector.CodeMirrorTokenTrackingController.Mode.NonSymbolTokens) {
1335             this.tokenTrackingController.highlightRange(candidate.hoveredTokenRange);
1336             return;
1337         }
1338
1339         if (this.tokenTrackingController.mode === WebInspector.CodeMirrorTokenTrackingController.Mode.JavaScriptExpression) {
1340             this._tokenTrackingControllerHighlightedJavaScriptExpression(candidate);
1341             return;
1342         }
1343
1344         if (this.tokenTrackingController.mode === WebInspector.CodeMirrorTokenTrackingController.Mode.JavaScriptTypeInformation) {
1345             this._tokenTrackingControllerHighlightedJavaScriptTypeInformation(candidate);
1346             return;
1347         }
1348
1349         if (this.tokenTrackingController.mode === WebInspector.CodeMirrorTokenTrackingController.Mode.MarkedTokens) {
1350             var markers = this.markersAtPosition(candidate.hoveredTokenRange.start);
1351             if (markers.length > 0)
1352                 this._tokenTrackingControllerHighlightedMarkedExpression(candidate, markers);
1353             else
1354                 this._dismissEditingController();
1355         }
1356     }
1357
1358     tokenTrackingControllerMouseOutOfHoveredMarker(tokenTrackingController, hoveredMarker)
1359     {
1360         this._dismissEditingController();
1361     }
1362
1363     _tokenTrackingControllerHighlightedJavaScriptExpression(candidate)
1364     {
1365         console.assert(candidate.expression);
1366
1367         function populate(error, result, wasThrown)
1368         {
1369             if (error || wasThrown)
1370                 return;
1371
1372             if (candidate !== this.tokenTrackingController.candidate)
1373                 return;
1374
1375             var data = WebInspector.RemoteObject.fromPayload(result);
1376             switch (data.type) {
1377             case "function":
1378                 this._showPopoverForFunction(data);
1379                 break;
1380             case "object":
1381                 if (data.subtype === "null" || data.subtype === "regexp")
1382                     this._showPopoverWithFormattedValue(data);
1383                 else
1384                     this._showPopoverForObject(data);
1385                 break;
1386             case "string":
1387             case "number":
1388             case "boolean":
1389             case "undefined":
1390             case "symbol":
1391                 this._showPopoverWithFormattedValue(data);
1392                 break;
1393             }
1394         }
1395
1396         if (WebInspector.debuggerManager.activeCallFrame) {
1397             DebuggerAgent.evaluateOnCallFrame.invoke({callFrameId: WebInspector.debuggerManager.activeCallFrame.id, expression: candidate.expression, objectGroup: "popover", doNotPauseOnExceptionsAndMuteConsole: true}, populate.bind(this));
1398             return;
1399         }
1400
1401         // No call frame available. Use the main page's context.
1402         RuntimeAgent.evaluate.invoke({expression: candidate.expression, objectGroup: "popover", doNotPauseOnExceptionsAndMuteConsole: true}, populate.bind(this));
1403     }
1404
1405     _tokenTrackingControllerHighlightedJavaScriptTypeInformation(candidate)
1406     {
1407         console.assert(candidate.expression);
1408
1409         var sourceCode = this._sourceCode;
1410         var sourceID = sourceCode instanceof WebInspector.Script ? sourceCode.id : sourceCode.scripts[0].id;
1411         var range = candidate.hoveredTokenRange;
1412         var offset = this.currentPositionToOriginalOffset({line: range.start.line, ch: range.start.ch});
1413
1414         var allRequests = [{
1415             typeInformationDescriptor: WebInspector.ScriptSyntaxTree.TypeProfilerSearchDescriptor.NormalExpression,
1416             sourceID,
1417             divot: offset
1418         }];
1419
1420         function handler(error, allTypes) {
1421             if (error)
1422                 return;
1423
1424             if (candidate !== this.tokenTrackingController.candidate)
1425                 return;
1426
1427             console.assert(allTypes.length === 1);
1428             if (!allTypes.length)
1429                 return;
1430             var types = allTypes[0];
1431             if (types.isValid) {
1432                 var popoverTitle = WebInspector.TypeTokenView.titleForPopover(WebInspector.TypeTokenView.TitleType.Variable, candidate.expression);
1433                 this.showPopoverForTypes(types, null, popoverTitle);
1434             }
1435         }
1436
1437         RuntimeAgent.getRuntimeTypesForVariablesAtOffsets(allRequests, handler.bind(this));
1438     }
1439
1440     _showPopover(content, bounds)
1441     {
1442         console.assert(this.tokenTrackingController.candidate || bounds);
1443
1444         var shouldHighlightRange = false;
1445         var candidate = this.tokenTrackingController.candidate;
1446         // If bounds is falsey, this is a popover introduced from a hover event.
1447         // Otherwise, this is called from TypeTokenAnnotator.
1448         if (!bounds) {
1449             if (!candidate)
1450                 return;
1451
1452             var rects = this.rectsForRange(candidate.hoveredTokenRange);
1453             bounds = WebInspector.Rect.unionOfRects(rects);
1454
1455             shouldHighlightRange = true;
1456         }
1457
1458         content.classList.add(WebInspector.SourceCodeTextEditor.PopoverDebuggerContentStyleClassName);
1459
1460         this._popover = this._popover || new WebInspector.Popover(this);
1461         this._popover.presentNewContentWithFrame(content, bounds.pad(5), [WebInspector.RectEdge.MIN_Y, WebInspector.RectEdge.MAX_Y, WebInspector.RectEdge.MAX_X]);
1462         if (shouldHighlightRange)
1463             this.tokenTrackingController.highlightRange(candidate.expressionRange);
1464
1465         this._trackPopoverEvents();
1466     }
1467
1468     _showPopoverForFunction(data)
1469     {
1470         var candidate = this.tokenTrackingController.candidate;
1471
1472         function didGetDetails(error, response)
1473         {
1474             if (error) {
1475                 console.error(error);
1476                 this._dismissPopover();
1477                 return;
1478             }
1479
1480             // Nothing to do if the token has changed since the time we
1481             // asked for the function details from the backend.
1482             if (candidate !== this.tokenTrackingController.candidate)
1483                 return;
1484
1485             var wrapper = document.createElement("div");
1486             wrapper.className = "body formatted-function";
1487             wrapper.textContent = data.description;
1488
1489             var content = document.createElement("div");
1490             content.className = "function";
1491
1492             var title = content.appendChild(document.createElement("div"));
1493             title.className = "title";
1494             title.textContent = response.name || response.inferredName || response.displayName || WebInspector.UIString("(anonymous function)");
1495
1496             content.appendChild(wrapper);
1497
1498             this._showPopover(content);
1499         }
1500         DebuggerAgent.getFunctionDetails(data.objectId, didGetDetails.bind(this));
1501     }
1502
1503     _showPopoverForObject(data)
1504     {
1505         var content = document.createElement("div");
1506         content.className = "object expandable";
1507
1508         var titleElement = document.createElement("div");
1509         titleElement.className = "title";
1510         titleElement.textContent = data.description;
1511         content.appendChild(titleElement);
1512
1513         // FIXME: If this is a variable, it would be nice to put the variable name in the PropertyPath.
1514         var objectTree = new WebInspector.ObjectTreeView(data);
1515         objectTree.showOnlyProperties();
1516         objectTree.expand();
1517
1518         var bodyElement = content.appendChild(document.createElement("div"));
1519         bodyElement.className = "body";
1520         bodyElement.appendChild(objectTree.element);
1521
1522         this._showPopover(content);
1523     }
1524
1525     _showPopoverWithFormattedValue(remoteObject)
1526     {
1527         var content = WebInspector.FormattedValue.createElementForRemoteObject(remoteObject);
1528         this._showPopover(content);
1529     }
1530
1531     willDismissPopover(popover)
1532     {
1533         this.tokenTrackingController.removeHighlightedRange();
1534
1535         RuntimeAgent.releaseObjectGroup("popover");
1536     }
1537
1538     _dismissPopover()
1539     {
1540         if (!this._popover)
1541             return;
1542
1543         this._popover.dismiss();
1544
1545         if (this._popoverEventListeners && this._popoverEventListenersAreRegistered) {
1546             this._popoverEventListenersAreRegistered = false;
1547             this._popoverEventListeners.unregister();
1548         }
1549     }
1550
1551     _trackPopoverEvents()
1552     {
1553         if (!this._popoverEventListeners)
1554             this._popoverEventListeners = new WebInspector.EventListenerSet(this, "Popover listeners");
1555         if (!this._popoverEventListenersAreRegistered) {
1556             this._popoverEventListenersAreRegistered = true;
1557             this._popoverEventListeners.register(this._popover.element, "mouseover", this._popoverMouseover);
1558             this._popoverEventListeners.register(this._popover.element, "mouseout", this._popoverMouseout);
1559             this._popoverEventListeners.install();
1560         }
1561     }
1562
1563     _popoverMouseover(event)
1564     {
1565         this._mouseIsOverPopover = true;
1566     }
1567
1568     _popoverMouseout(event)
1569     {
1570         this._mouseIsOverPopover = this._popover.element.contains(event.relatedTarget);
1571     }
1572
1573     _updateEditableMarkers(range)
1574     {
1575         this.createColorMarkers(range);
1576         this.createGradientMarkers(range);
1577
1578         this._updateTokenTrackingControllerState();
1579     }
1580
1581     _tokenTrackingControllerHighlightedMarkedExpression(candidate, markers)
1582     {
1583         // Look for the outermost editable marker.
1584         var editableMarker;
1585         for (var marker of markers) {
1586             if (!marker.range || (marker.type !== WebInspector.TextMarker.Type.Color && marker.type !== WebInspector.TextMarker.Type.Gradient))
1587                 continue;
1588
1589             if (!editableMarker || (marker.range.startLine < editableMarker.range.startLine || (marker.range.startLine === editableMarker.range.startLine && marker.range.startColumn < editableMarker.range.startColumn)))
1590                 editableMarker = marker;
1591         }
1592
1593         if (!editableMarker) {
1594             this.tokenTrackingController.hoveredMarker = null;
1595             return;
1596         }
1597
1598         if (this.tokenTrackingController.hoveredMarker === editableMarker)
1599             return;
1600
1601         this._dismissEditingController();
1602
1603         this.tokenTrackingController.hoveredMarker = editableMarker;
1604
1605         this._editingController = this.editingControllerForMarker(editableMarker);
1606
1607         if (marker.type === WebInspector.TextMarker.Type.Color) {
1608             var color = this._editingController.value;
1609             if (!color || !color.valid) {
1610                 editableMarker.clear();
1611                 delete this._editingController;
1612                 return;
1613             }
1614         }
1615
1616         this._editingController.delegate = this;
1617         this._editingController.presentHoverMenu();
1618     }
1619
1620     _dismissEditingController(discrete)
1621     {
1622         if (this._editingController)
1623             this._editingController.dismissHoverMenu(discrete);
1624
1625         this.tokenTrackingController.hoveredMarker = null;
1626         delete this._editingController;
1627     }
1628
1629     // CodeMirrorEditingController Delegate
1630
1631     editingControllerDidStartEditing(editingController)
1632     {
1633         // We can pause the token tracking controller during editing, it will be reset
1634         // to the expected state by calling _updateEditableMarkers() in the
1635         // editingControllerDidFinishEditing delegate.
1636         this.tokenTrackingController.enabled = false;
1637
1638         // We clear the marker since we'll reset it after editing.
1639         editingController.marker.clear();
1640
1641         // We ignore content changes made as a result of color editing.
1642         this._ignoreContentDidChange++;
1643     }
1644
1645     editingControllerDidFinishEditing(editingController)
1646     {
1647         this._updateEditableMarkers(editingController.range);
1648
1649         this._ignoreContentDidChange--;
1650
1651         delete this._editingController;
1652     }
1653
1654     _setTypeTokenAnnotatorEnabledState(shouldActivate)
1655     {
1656         console.assert(this._typeTokenAnnotator);
1657         if (!this._typeTokenAnnotator)
1658             return;
1659
1660         if (shouldActivate) {
1661             RuntimeAgent.enableTypeProfiler();
1662
1663             this._typeTokenAnnotator.reset();
1664             if (this._basicBlockAnnotator) {
1665                 console.assert(!this._basicBlockAnnotator.isActive());
1666                 this._basicBlockAnnotator.reset();
1667             }
1668
1669             if (!this._typeTokenScrollHandler)
1670                 this._enableScrollEventsForTypeTokenAnnotator();
1671         } else {
1672             // Because we disable type profiling when exiting the inspector, there is no need to call
1673             // RuntimeAgent.disableTypeProfiler() here.  If we were to call it here, JavaScriptCore would
1674             // compile out all the necessary type profiling information, so if a user were to quickly press then
1675             // unpress the type profiling button, we wouldn't be able to re-show type information which would
1676             // provide a confusing user experience.
1677
1678             this._typeTokenAnnotator.clear();
1679             if (this._basicBlockAnnotator)
1680                 this._basicBlockAnnotator.clear();
1681
1682             if (this._typeTokenScrollHandler)
1683                 this._disableScrollEventsForTypeTokenAnnotator();
1684         }
1685
1686         WebInspector.showJavaScriptTypeInformationSetting.value = shouldActivate;
1687
1688         this._updateTokenTrackingControllerState();
1689     }
1690
1691     _getAssociatedScript()
1692     {
1693         var script = null;
1694         // FIXME: This needs to me modified to work with HTML files with inline script tags.
1695         if (this._sourceCode instanceof WebInspector.Script)
1696             script = this._sourceCode;
1697         else if (this._sourceCode instanceof WebInspector.Resource && this._sourceCode.type === WebInspector.Resource.Type.Script && this._sourceCode.scripts.length)
1698             script = this._sourceCode.scripts[0];
1699         return script;
1700     }
1701
1702     _makeTypeTokenAnnotator()
1703     {
1704         if (!RuntimeAgent.getRuntimeTypesForVariablesAtOffsets)
1705             return;
1706
1707         var script = this._getAssociatedScript();
1708         if (!script)
1709             return;
1710
1711         this._typeTokenAnnotator = new WebInspector.TypeTokenAnnotator(this, script);
1712     }
1713
1714     _makeBasicBlockAnnotator()
1715     {
1716         if (!RuntimeAgent.getBasicBlocks)
1717             return;
1718
1719         var script = this._getAssociatedScript();
1720         if (!script)
1721             return;
1722
1723         this._basicBlockAnnotator = new WebInspector.BasicBlockAnnotator(this, script);
1724     }
1725
1726     _enableScrollEventsForTypeTokenAnnotator()
1727     {
1728         // Pause updating type tokens while scrolling to prevent frame loss.
1729         console.assert(!this._typeTokenScrollHandler);
1730         this._typeTokenScrollHandler = this._makeTypeTokenScrollEventHandler();
1731         this.addScrollHandler(this._typeTokenScrollHandler);
1732     }
1733
1734     _disableScrollEventsForTypeTokenAnnotator()
1735     {
1736         console.assert(this._typeTokenScrollHandler);
1737         this.removeScrollHandler(this._typeTokenScrollHandler);
1738         this._typeTokenScrollHandler = null;
1739     }
1740
1741     _makeTypeTokenScrollEventHandler()
1742     {
1743         var timeoutIdentifier = null;
1744         function scrollHandler()
1745         {
1746             if (timeoutIdentifier)
1747                 clearTimeout(timeoutIdentifier);
1748             else {
1749                 if (this._typeTokenAnnotator)
1750                     this._typeTokenAnnotator.pause();
1751                 if (this._basicBlockAnnotator)
1752                     this._basicBlockAnnotator.pause();
1753             }
1754
1755             timeoutIdentifier = setTimeout(function() {
1756                 timeoutIdentifier = null;
1757                 if (this._typeTokenAnnotator)
1758                     this._typeTokenAnnotator.resume();
1759                 if (this._basicBlockAnnotator)
1760                     this._basicBlockAnnotator.resume();
1761             }.bind(this), WebInspector.SourceCodeTextEditor.DurationToUpdateTypeTokensAfterScrolling);
1762         }
1763
1764         return scrollHandler.bind(this);
1765     }
1766 };
1767
1768 WebInspector.SourceCodeTextEditor.LineErrorStyleClassName = "error";
1769 WebInspector.SourceCodeTextEditor.LineWarningStyleClassName = "warning";
1770 WebInspector.SourceCodeTextEditor.PopoverDebuggerContentStyleClassName = "debugger-popover-content";
1771 WebInspector.SourceCodeTextEditor.HoveredExpressionHighlightStyleClassName = "hovered-expression-highlight";
1772 WebInspector.SourceCodeTextEditor.DurationToMouseOverTokenToMakeHoveredToken = 500;
1773 WebInspector.SourceCodeTextEditor.DurationToMouseOutOfHoveredTokenToRelease = 1000;
1774 WebInspector.SourceCodeTextEditor.DurationToUpdateTypeTokensAfterScrolling = 100;
1775 WebInspector.SourceCodeTextEditor.AutoFormatMinimumLineLength = 500;
1776 WebInspector.SourceCodeTextEditor.WidgetContainsMultipleIssuesSymbol = Symbol("source-code-widget-contains-multiple-issues");
1777
1778 WebInspector.SourceCodeTextEditor.Event = {
1779     ContentWillPopulate: "source-code-text-editor-content-will-populate",
1780     ContentDidPopulate: "source-code-text-editor-content-did-populate"
1781 };