Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: Source/devtools/front_end/source_frame/CodeMirrorTextEditor.js

Issue 667163002: DevTools: Do not toggle line styles unless necessary in script editor. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/devtools/front_end/sources/JavaScriptSourceFrame.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 delete this._executionLine; 1063 delete this._executionLine;
1064 }, 1064 },
1065 1065
1066 /** 1066 /**
1067 * @param {number} lineNumber 1067 * @param {number} lineNumber
1068 * @param {string} className 1068 * @param {string} className
1069 * @param {boolean} toggled 1069 * @param {boolean} toggled
1070 */ 1070 */
1071 toggleLineClass: function(lineNumber, className, toggled) 1071 toggleLineClass: function(lineNumber, className, toggled)
1072 { 1072 {
1073 if (this.hasLineClass(lineNumber, className) === toggled)
1074 return;
1073 var lineHandle = this._codeMirror.getLineHandle(lineNumber); 1075 var lineHandle = this._codeMirror.getLineHandle(lineNumber);
1074 if (!lineHandle) 1076 if (!lineHandle)
1075 return; 1077 return;
1076 if (toggled) 1078 if (toggled)
1077 this._codeMirror.addLineClass(lineHandle, "wrap", className); 1079 this._codeMirror.addLineClass(lineHandle, "wrap", className);
1078 else 1080 else
1079 this._codeMirror.removeLineClass(lineHandle, "wrap", className); 1081 this._codeMirror.removeLineClass(lineHandle, "wrap", className);
1080 }, 1082 },
1081 1083
1082 /** 1084 /**
1083 * @param {number} lineNumber 1085 * @param {number} lineNumber
1086 * @param {string} className
1087 * @return {boolean}
1088 */
1089 hasLineClass: function(lineNumber, className)
1090 {
1091 var lineInfo = this._codeMirror.lineInfo(lineNumber);
1092 var wrapClass = lineInfo.wrapClass || "";
1093 var classNames = wrapClass.split(" ");
1094 return classNames.indexOf(className) !== -1
1095 },
1096
1097 /**
1098 * @param {number} lineNumber
1084 * @param {!Element} element 1099 * @param {!Element} element
1085 */ 1100 */
1086 addDecoration: function(lineNumber, element) 1101 addDecoration: function(lineNumber, element)
1087 { 1102 {
1088 var widget = this._codeMirror.addLineWidget(lineNumber, element); 1103 var widget = this._codeMirror.addLineWidget(lineNumber, element);
1089 this._elementToWidget.set(element, widget); 1104 this._elementToWidget.set(element, widget);
1090 }, 1105 },
1091 1106
1092 /** 1107 /**
1093 * @param {number} lineNumber 1108 * @param {number} lineNumber
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
2456 function tokenOverride(superToken, stream, state) 2471 function tokenOverride(superToken, stream, state)
2457 { 2472 {
2458 var token = superToken(stream, state); 2473 var token = superToken(stream, state);
2459 return token ? tokenPrefix + token.split(/ +/).join(" " + tokenPrefix) : token; 2474 return token ? tokenPrefix + token.split(/ +/).join(" " + tokenPrefix) : token;
2460 } 2475 }
2461 } 2476 }
2462 2477
2463 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("css", "css-") ; 2478 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("css", "css-") ;
2464 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("javascript", "js-"); 2479 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("javascript", "js-");
2465 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("xml", "xml-") ; 2480 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("xml", "xml-") ;
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/sources/JavaScriptSourceFrame.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698