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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/SourceFrame.js
diff --git a/Source/devtools/front_end/SourceFrame.js b/Source/devtools/front_end/SourceFrame.js
index 659825c0ac42bc1c2bf765fa32f5e56e0ed3f011..3907b64a1ca923f813b409fca9bc7727909bfdf4 100644
--- a/Source/devtools/front_end/SourceFrame.js
+++ b/Source/devtools/front_end/SourceFrame.js
@@ -318,7 +318,7 @@ WebInspector.SourceFrame.prototype = {
this.clearMessages();
},
- _simplifyMimeType: function(mimeType)
+ _simplifyMimeType: function(content, mimeType)
{
if (!mimeType)
return "";
@@ -326,6 +326,9 @@ WebInspector.SourceFrame.prototype = {
mimeType.indexOf("jscript") >= 0 ||
mimeType.indexOf("ecmascript") >= 0)
return "text/javascript";
+ // A hack around the fact that files with "php" extension might be either standalone or html embedded php scripts.
+ if (mimeType === "text/x-php" && content.match(/\<\?.*\?\>/g))
+ return "application/x-httpd-php";
return mimeType;
},
@@ -343,7 +346,7 @@ WebInspector.SourceFrame.prototype = {
} else
this._textEditor.editRange(this._textEditor.range(), content || "");
- this._textEditor.mimeType = this._simplifyMimeType(mimeType);
+ this._textEditor.mimeType = this._simplifyMimeType(content, mimeType);
this._textEditor.beginUpdates();

Powered by Google App Engine
This is Rietveld 408576698