| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 this._blockIndentController = new WebInspector.CodeMirrorTextEditor.BlockInd
entController(this._codeMirror); | 132 this._blockIndentController = new WebInspector.CodeMirrorTextEditor.BlockInd
entController(this._codeMirror); |
| 133 this._fixWordMovement = new WebInspector.CodeMirrorTextEditor.FixWordMovemen
t(this._codeMirror); | 133 this._fixWordMovement = new WebInspector.CodeMirrorTextEditor.FixWordMovemen
t(this._codeMirror); |
| 134 this._selectNextOccurrenceController = new WebInspector.CodeMirrorTextEditor
.SelectNextOccurrenceController(this, this._codeMirror); | 134 this._selectNextOccurrenceController = new WebInspector.CodeMirrorTextEditor
.SelectNextOccurrenceController(this, this._codeMirror); |
| 135 | 135 |
| 136 this._codeMirror.on("changes", this._changes.bind(this)); | 136 this._codeMirror.on("changes", this._changes.bind(this)); |
| 137 this._codeMirror.on("gutterClick", this._gutterClick.bind(this)); | 137 this._codeMirror.on("gutterClick", this._gutterClick.bind(this)); |
| 138 this._codeMirror.on("cursorActivity", this._cursorActivity.bind(this)); | 138 this._codeMirror.on("cursorActivity", this._cursorActivity.bind(this)); |
| 139 this._codeMirror.on("beforeSelectionChange", this._beforeSelectionChange.bin
d(this)); | 139 this._codeMirror.on("beforeSelectionChange", this._beforeSelectionChange.bin
d(this)); |
| 140 this._codeMirror.on("scroll", this._scroll.bind(this)); | 140 this._codeMirror.on("scroll", this._scroll.bind(this)); |
| 141 this._codeMirror.on("focus", this._focus.bind(this)); | 141 this._codeMirror.on("focus", this._focus.bind(this)); |
| 142 this._codeMirror.on("contextmenu", this._contextMenu.bind(this)); | 142 this.element.addEventListener("contextmenu", this._contextMenu.bind(this), f
alse); |
| 143 /** | 143 /** |
| 144 * @this {WebInspector.CodeMirrorTextEditor} | 144 * @this {WebInspector.CodeMirrorTextEditor} |
| 145 */ | 145 */ |
| 146 function updateAnticipateJumpFlag(value) | 146 function updateAnticipateJumpFlag(value) |
| 147 { | 147 { |
| 148 this._isHandlingMouseDownEvent = value; | 148 this._isHandlingMouseDownEvent = value; |
| 149 } | 149 } |
| 150 this.element.addEventListener("mousedown", updateAnticipateJumpFlag.bind(thi
s, true), true); | 150 this.element.addEventListener("mousedown", updateAnticipateJumpFlag.bind(thi
s, true), true); |
| 151 this.element.addEventListener("mousedown", updateAnticipateJumpFlag.bind(thi
s, false), false); | 151 this.element.addEventListener("mousedown", updateAnticipateJumpFlag.bind(thi
s, false), false); |
| 152 | 152 |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 var bottomLineToReveal = Math.min(lineNumber + (linesPerScreen / 2)
- 1, this.linesCount - 1) | 0; | 714 var bottomLineToReveal = Math.min(lineNumber + (linesPerScreen / 2)
- 1, this.linesCount - 1) | 0; |
| 715 this._codeMirror.scrollIntoView(new CodeMirror.Pos(bottomLineToRevea
l, 0)); | 715 this._codeMirror.scrollIntoView(new CodeMirror.Pos(bottomLineToRevea
l, 0)); |
| 716 } | 716 } |
| 717 }, | 717 }, |
| 718 | 718 |
| 719 _gutterClick: function(instance, lineNumber, gutter, event) | 719 _gutterClick: function(instance, lineNumber, gutter, event) |
| 720 { | 720 { |
| 721 this.dispatchEventToListeners(WebInspector.TextEditor.Events.GutterClick
, { lineNumber: lineNumber, event: event }); | 721 this.dispatchEventToListeners(WebInspector.TextEditor.Events.GutterClick
, { lineNumber: lineNumber, event: event }); |
| 722 }, | 722 }, |
| 723 | 723 |
| 724 _contextMenu: function(codeMirror, event) | 724 _contextMenu: function(event) |
| 725 { | 725 { |
| 726 var contextMenu = new WebInspector.ContextMenu(event); | 726 var contextMenu = new WebInspector.ContextMenu(event); |
| 727 var target = event.target.enclosingNodeOrSelfWithClass("CodeMirror-gutte
r-elt"); | 727 var target = event.target.enclosingNodeOrSelfWithClass("CodeMirror-gutte
r-elt"); |
| 728 if (target) | 728 if (target) |
| 729 this._delegate.populateLineGutterContextMenu(contextMenu, parseInt(t
arget.textContent, 10) - 1); | 729 this._delegate.populateLineGutterContextMenu(contextMenu, parseInt(t
arget.textContent, 10) - 1); |
| 730 else | 730 else |
| 731 this._delegate.populateTextAreaContextMenu(contextMenu, 0); | 731 this._delegate.populateTextAreaContextMenu(contextMenu, 0); |
| 732 contextMenu.show(); | 732 contextMenu.show(); |
| 733 }, | 733 }, |
| 734 | 734 |
| (...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2123 var backgroundColorRule = backgroundColor ? ".CodeMirror .CodeMirror-selecte
d { background-color: " + backgroundColor + ";}" : ""; | 2123 var backgroundColorRule = backgroundColor ? ".CodeMirror .CodeMirror-selecte
d { background-color: " + backgroundColor + ";}" : ""; |
| 2124 var foregroundColor = InspectorFrontendHost.getSelectionForegroundColor(); | 2124 var foregroundColor = InspectorFrontendHost.getSelectionForegroundColor(); |
| 2125 var foregroundColorRule = foregroundColor ? ".CodeMirror .CodeMirror-selecte
dtext:not(.CodeMirror-persist-highlight) { color: " + foregroundColor + "!import
ant;}" : ""; | 2125 var foregroundColorRule = foregroundColor ? ".CodeMirror .CodeMirror-selecte
dtext:not(.CodeMirror-persist-highlight) { color: " + foregroundColor + "!import
ant;}" : ""; |
| 2126 if (!foregroundColorRule && !backgroundColorRule) | 2126 if (!foregroundColorRule && !backgroundColorRule) |
| 2127 return; | 2127 return; |
| 2128 | 2128 |
| 2129 var style = document.createElement("style"); | 2129 var style = document.createElement("style"); |
| 2130 style.textContent = backgroundColorRule + foregroundColorRule; | 2130 style.textContent = backgroundColorRule + foregroundColorRule; |
| 2131 document.head.appendChild(style); | 2131 document.head.appendChild(style); |
| 2132 })(); | 2132 })(); |
| OLD | NEW |