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

Side by Side Diff: Source/devtools/front_end/SourceFrame.js

Issue 18341003: DevTools: [CodeMirror] Add syntax highlighting for some other languages. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaselined Created 7 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 this._innerScrollToLineIfNeeded(); 311 this._innerScrollToLineIfNeeded();
312 }, 312 },
313 313
314 onTextChanged: function(oldRange, newRange) 314 onTextChanged: function(oldRange, newRange)
315 { 315 {
316 if (!this._isReplacing) 316 if (!this._isReplacing)
317 WebInspector.searchController.cancelSearch(); 317 WebInspector.searchController.cancelSearch();
318 this.clearMessages(); 318 this.clearMessages();
319 }, 319 },
320 320
321 _simplifyMimeType: function(mimeType) 321 _simplifyMimeType: function(content, mimeType)
322 { 322 {
323 if (!mimeType) 323 if (!mimeType)
324 return ""; 324 return "";
325 if (mimeType.indexOf("javascript") >= 0 || 325 if (mimeType.indexOf("javascript") >= 0 ||
326 mimeType.indexOf("jscript") >= 0 || 326 mimeType.indexOf("jscript") >= 0 ||
327 mimeType.indexOf("ecmascript") >= 0) 327 mimeType.indexOf("ecmascript") >= 0)
328 return "text/javascript"; 328 return "text/javascript";
329 // A hack around the fact that files with "php" extension might be eithe r standalone or html embedded php scripts.
330 if (mimeType === "text/x-php" && content.match(/\<\?.*\?\>/g))
331 return "application/x-httpd-php";
329 return mimeType; 332 return mimeType;
330 }, 333 },
331 334
332 /** 335 /**
333 * @param {?string} content 336 * @param {?string} content
334 * @param {boolean} contentEncoded 337 * @param {boolean} contentEncoded
335 * @param {string} mimeType 338 * @param {string} mimeType
336 */ 339 */
337 setContent: function(content, contentEncoded, mimeType) 340 setContent: function(content, contentEncoded, mimeType)
338 { 341 {
339 if (!this._loaded) { 342 if (!this._loaded) {
340 this._loaded = true; 343 this._loaded = true;
341 this._textEditor.setText(content || ""); 344 this._textEditor.setText(content || "");
342 this._textEditor.markClean(); 345 this._textEditor.markClean();
343 } else 346 } else
344 this._textEditor.editRange(this._textEditor.range(), content || ""); 347 this._textEditor.editRange(this._textEditor.range(), content || "");
345 348
346 this._textEditor.mimeType = this._simplifyMimeType(mimeType); 349 this._textEditor.mimeType = this._simplifyMimeType(content, mimeType);
347 350
348 this._textEditor.beginUpdates(); 351 this._textEditor.beginUpdates();
349 352
350 this._setTextEditorDecorations(); 353 this._setTextEditorDecorations();
351 354
352 this._wasShownOrLoaded(); 355 this._wasShownOrLoaded();
353 356
354 if (this._delayedFindSearchMatches) { 357 if (this._delayedFindSearchMatches) {
355 this._delayedFindSearchMatches(); 358 this._delayedFindSearchMatches();
356 delete this._delayedFindSearchMatches; 359 delete this._delayedFindSearchMatches;
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 * @return {Element} 815 * @return {Element}
813 */ 816 */
814 createLink: function(hrefValue, isExternal) 817 createLink: function(hrefValue, isExternal)
815 { 818 {
816 var targetLocation = WebInspector.ParsedURL.completeURL(this._sourceFram e._url, hrefValue); 819 var targetLocation = WebInspector.ParsedURL.completeURL(this._sourceFram e._url, hrefValue);
817 return WebInspector.linkifyURLAsNode(targetLocation || hrefValue, hrefVa lue, undefined, isExternal); 820 return WebInspector.linkifyURLAsNode(targetLocation || hrefValue, hrefVa lue, undefined, isExternal);
818 }, 821 },
819 822
820 __proto__: WebInspector.TextEditorDelegate.prototype 823 __proto__: WebInspector.TextEditorDelegate.prototype
821 } 824 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698