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

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

Issue 182113004: DevTools: Get rid of Element.prototype.enableStyleClass (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaselined Created 6 years, 9 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) 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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 582
583 _disableLongLinesMode: function() 583 _disableLongLinesMode: function()
584 { 584 {
585 this._codeMirror.setOption("styleSelectedText", true); 585 this._codeMirror.setOption("styleSelectedText", true);
586 this._longLinesMode = false; 586 this._longLinesMode = false;
587 }, 587 },
588 588
589 _updateCodeMirrorMode: function() 589 _updateCodeMirrorMode: function()
590 { 590 {
591 var showWhitespaces = WebInspector.settings.showWhitespacesInEditor.get( ); 591 var showWhitespaces = WebInspector.settings.showWhitespacesInEditor.get( );
592 this.element.enableStyleClass("show-whitespaces", showWhitespaces); 592 this.element.classList.toggle("show-whitespaces", showWhitespaces);
593 this._codeMirror.setOption("mode", showWhitespaces ? this._whitespaceOve rlayMode(this._mimeType) : this._mimeType); 593 this._codeMirror.setOption("mode", showWhitespaces ? this._whitespaceOve rlayMode(this._mimeType) : this._mimeType);
594 }, 594 },
595 595
596 /** 596 /**
597 * @param {string} mimeType 597 * @param {string} mimeType
598 */ 598 */
599 setMimeType: function(mimeType) 599 setMimeType: function(mimeType)
600 { 600 {
601 this._mimeType = mimeType; 601 this._mimeType = mimeType;
602 if (this._hasLongLines()) 602 if (this._hasLongLines())
603 this._enableLongLinesMode(); 603 this._enableLongLinesMode();
604 else 604 else
605 this._disableLongLinesMode(); 605 this._disableLongLinesMode();
606 this._updateCodeMirrorMode(); 606 this._updateCodeMirrorMode();
607 }, 607 },
608 608
609 /** 609 /**
610 * @param {boolean} readOnly 610 * @param {boolean} readOnly
611 */ 611 */
612 setReadOnly: function(readOnly) 612 setReadOnly: function(readOnly)
613 { 613 {
614 this.element.enableStyleClass("CodeMirror-readonly", readOnly) 614 this.element.classList.toggle("CodeMirror-readonly", readOnly)
615 this._codeMirror.setOption("readOnly", readOnly); 615 this._codeMirror.setOption("readOnly", readOnly);
616 }, 616 },
617 617
618 /** 618 /**
619 * @return {boolean} 619 * @return {boolean}
620 */ 620 */
621 readOnly: function() 621 readOnly: function()
622 { 622 {
623 return !!this._codeMirror.getOption("readOnly"); 623 return !!this._codeMirror.getOption("readOnly");
624 }, 624 },
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 var backgroundColorRule = backgroundColor ? ".CodeMirror .CodeMirror-selecte d { background-color: " + backgroundColor + ";}" : ""; 1709 var backgroundColorRule = backgroundColor ? ".CodeMirror .CodeMirror-selecte d { background-color: " + backgroundColor + ";}" : "";
1710 var foregroundColor = InspectorFrontendHost.getSelectionForegroundColor(); 1710 var foregroundColor = InspectorFrontendHost.getSelectionForegroundColor();
1711 var foregroundColorRule = foregroundColor ? ".CodeMirror .CodeMirror-selecte dtext:not(.CodeMirror-persist-highlight) { color: " + foregroundColor + "!import ant;}" : ""; 1711 var foregroundColorRule = foregroundColor ? ".CodeMirror .CodeMirror-selecte dtext:not(.CodeMirror-persist-highlight) { color: " + foregroundColor + "!import ant;}" : "";
1712 if (!foregroundColorRule && !backgroundColorRule) 1712 if (!foregroundColorRule && !backgroundColorRule)
1713 return; 1713 return;
1714 1714
1715 var style = document.createElement("style"); 1715 var style = document.createElement("style");
1716 style.textContent = backgroundColorRule + foregroundColorRule; 1716 style.textContent = backgroundColorRule + foregroundColorRule;
1717 document.head.appendChild(style); 1717 document.head.appendChild(style);
1718 })(); 1718 })();
OLDNEW
« no previous file with comments | « Source/devtools/front_end/CanvasProfileView.js ('k') | Source/devtools/front_end/ConsoleView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698