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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/source_frame/SourceFrame.js

Issue 1416793005: Devtools: API To set the red/yellow squiggles for a file via DI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update API with feedback from cl Created 5 years, 1 month 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/sources/JavaScriptCompiler.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) 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 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 if (handler && handler()) 682 if (handler && handler())
683 e.consume(true); 683 e.consume(true);
684 }, 684 },
685 685
686 __proto__: WebInspector.VBox.prototype 686 __proto__: WebInspector.VBox.prototype
687 } 687 }
688 688
689 /** 689 /**
690 * @constructor 690 * @constructor
691 * @param {string} messageText 691 * @param {string} messageText
692 * @param {!WebInspector.SourceFrameMessage.Level} level 692 * @param {!WebInspector.UISourceCodeMessage.Level} level
693 * @param {number} lineNumber 693 * @param {!WebInspector.TextRange} range
694 * @param {number=} columnNumber
695 */ 694 */
696 WebInspector.SourceFrameMessage = function(messageText, level, lineNumber, colum nNumber) 695 WebInspector.SourceFrameMessage = function(messageText, level, range)
697 { 696 {
698 this._messageText = messageText; 697 this._messageText = messageText;
699 this._level = level; 698 this._level = level;
700 this._lineNumber = lineNumber; 699 this._range = range;
701 this._columnNumber = columnNumber;
702 } 700 }
703 701
704 /** 702 /**
705 * @enum {string}
706 */
707 WebInspector.SourceFrameMessage.Level = {
708 Error: "Error",
709 Warning: "Warning"
710 }
711
712 /**
713 * @param {!WebInspector.ConsoleMessage} consoleMessage 703 * @param {!WebInspector.ConsoleMessage} consoleMessage
714 * @param {number} lineNumber 704 * @param {number} lineNumber
715 * @param {number} columnNumber 705 * @param {number} columnNumber
716 * @return {!WebInspector.SourceFrameMessage} 706 * @return {!WebInspector.SourceFrameMessage}
717 */ 707 */
718 WebInspector.SourceFrameMessage.fromConsoleMessage = function(consoleMessage, li neNumber, columnNumber) 708 WebInspector.SourceFrameMessage.fromConsoleMessage = function(consoleMessage, li neNumber, columnNumber)
719 { 709 {
720 console.assert(consoleMessage.level === WebInspector.ConsoleMessage.MessageL evel.Error || consoleMessage.level === WebInspector.ConsoleMessage.MessageLevel. Warning); 710 console.assert(consoleMessage.level === WebInspector.ConsoleMessage.MessageL evel.Error || consoleMessage.level === WebInspector.ConsoleMessage.MessageLevel. Warning);
721 var level = consoleMessage.level === WebInspector.ConsoleMessage.MessageLeve l.Error ? WebInspector.SourceFrameMessage.Level.Error : WebInspector.SourceFrame Message.Level.Warning; 711 var level = consoleMessage.level === WebInspector.ConsoleMessage.MessageLeve l.Error ? WebInspector.UISourceCodeMessage.Level.Error : WebInspector.UISourceCo deMessage.Level.Warning;
722 return new WebInspector.SourceFrameMessage(consoleMessage.messageText, level , lineNumber, columnNumber); 712 var location = new WebInspector.TextRange(lineNumber, columnNumber, lineNumb er, columnNumber);
713 return new WebInspector.SourceFrameMessage(consoleMessage.messageText, level , location);
723 } 714 }
724 715
725 WebInspector.SourceFrameMessage.prototype = { 716 WebInspector.SourceFrameMessage.prototype = {
726 /** 717 /**
727 * @return {string} 718 * @return {string}
728 */ 719 */
729 messageText: function() 720 messageText: function()
730 { 721 {
731 return this._messageText; 722 return this._messageText;
732 }, 723 },
733 724
734 /** 725 /**
735 * @return {!WebInspector.SourceFrameMessage.Level} 726 * @return {!WebInspector.UISourceCodeMessage.Level}
736 */ 727 */
737 level: function() 728 level: function()
738 { 729 {
739 return this._level; 730 return this._level;
740 }, 731 },
741 732
742 /** 733 /**
734 * @return {!WebInspector.TextRange}
735 */
736 range: function()
737 {
738 return this._range;
739 },
740
741 /**
743 * @return {number} 742 * @return {number}
744 */ 743 */
745 lineNumber: function() 744 lineNumber: function()
746 { 745 {
747 return this._lineNumber; 746 return this._range.startLine;
748 }, 747 },
749 748
750 /** 749 /**
751 * @return {(number|undefined)} 750 * @return {(number|undefined)}
752 */ 751 */
753 columnNumber: function() 752 columnNumber: function()
754 { 753 {
755 return this._columnNumber; 754 return this._range.startColumn;
756 }, 755 },
757 756
758 /** 757 /**
759 * @param {!WebInspector.SourceFrameMessage} another 758 * @param {!WebInspector.SourceFrameMessage} another
760 * @return {boolean} 759 * @return {boolean}
761 */ 760 */
762 isEqual: function(another) 761 isEqual: function(another)
763 { 762 {
764 return this.messageText() === another.messageText() && this.level() === another.level() && this.lineNumber() === another.lineNumber() && this.columnNumb er() === another.columnNumber(); 763 return this.messageText() === another.messageText() &&
764 this.level() === another.level() &&
765 this.range().equal(another.range());
765 } 766 }
766 } 767 }
767 768
768 WebInspector.SourceFrame._iconClassPerLevel = {}; 769 WebInspector.SourceFrame._iconClassPerLevel = {};
769 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Error] = "error-icon"; 770 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.UISourceCodeMessage.Lev el.Error] = "error-icon";
770 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Warning] = "warning-icon"; 771 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.UISourceCodeMessage.Lev el.Warning] = "warning-icon";
771 772
772 WebInspector.SourceFrame._lineClassPerLevel = {}; 773 WebInspector.SourceFrame._lineClassPerLevel = {};
773 WebInspector.SourceFrame._lineClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Error] = "text-editor-line-with-error"; 774 WebInspector.SourceFrame._lineClassPerLevel[WebInspector.UISourceCodeMessage.Lev el.Error] = "text-editor-line-with-error";
774 WebInspector.SourceFrame._lineClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Warning] = "text-editor-line-with-warning"; 775 WebInspector.SourceFrame._lineClassPerLevel[WebInspector.UISourceCodeMessage.Lev el.Warning] = "text-editor-line-with-warning";
775 776
776 /** 777 /**
777 * @constructor 778 * @constructor
778 * @param {!WebInspector.SourceFrameMessage} message 779 * @param {!WebInspector.SourceFrameMessage} message
779 */ 780 */
780 WebInspector.SourceFrame.RowMessage = function(message) 781 WebInspector.SourceFrame.RowMessage = function(message)
781 { 782 {
782 this._message = message; 783 this._message = message;
783 this._repeatCount = 1; 784 this._repeatCount = 1;
784 this.element = createElementWithClass("div", "text-editor-row-message"); 785 this.element = createElementWithClass("div", "text-editor-row-message");
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 */ 860 */
860 _updateWavePosition: function(lineNumber, columnNumber) 861 _updateWavePosition: function(lineNumber, columnNumber)
861 { 862 {
862 lineNumber = Math.min(lineNumber, this._textEditor.linesCount - 1); 863 lineNumber = Math.min(lineNumber, this._textEditor.linesCount - 1);
863 var lineText = this._textEditor.line(lineNumber); 864 var lineText = this._textEditor.line(lineNumber);
864 columnNumber = Math.min(columnNumber, lineText.length); 865 columnNumber = Math.min(columnNumber, lineText.length);
865 var lineIndent = WebInspector.TextUtils.lineIndent(lineText).length; 866 var lineIndent = WebInspector.TextUtils.lineIndent(lineText).length;
866 var base = this._textEditor.cursorPositionToCoordinates(lineNumber, 0); 867 var base = this._textEditor.cursorPositionToCoordinates(lineNumber, 0);
867 868
868 var start = this._textEditor.cursorPositionToCoordinates(lineNumber, Mat h.max(columnNumber - 1, lineIndent)); 869 var start = this._textEditor.cursorPositionToCoordinates(lineNumber, Mat h.max(columnNumber - 1, lineIndent));
870 if (!start)
871 return; //stale data - columnNumber is already gone, wait for future update and for UI to settle
869 var end = this._textEditor.cursorPositionToCoordinates(lineNumber, lineT ext.length); 872 var end = this._textEditor.cursorPositionToCoordinates(lineNumber, lineT ext.length);
870 /** @const */ 873 /** @const */
871 var codeMirrorLinesLeftPadding = 4; 874 var codeMirrorLinesLeftPadding = 4;
872 this._wave.style.left = (start.x - base.x + codeMirrorLinesLeftPadding) + "px"; 875 this._wave.style.left = (start.x - base.x + codeMirrorLinesLeftPadding) + "px";
873 this._wave.style.width = (end.x - start.x) + "px"; 876 this._wave.style.width = (end.x - start.x) + "px";
874 }, 877 },
875 878
876 /** 879 /**
877 * @return {!Element} 880 * @return {!Element}
878 */ 881 */
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 1053
1051 /** 1054 /**
1052 * @param {!WebInspector.SourceFrameMessage} a 1055 * @param {!WebInspector.SourceFrameMessage} a
1053 * @param {!WebInspector.SourceFrameMessage} b 1056 * @param {!WebInspector.SourceFrameMessage} b
1054 * @return {number} 1057 * @return {number}
1055 */ 1058 */
1056 WebInspector.SourceFrameMessage.messageLevelComparator = function(a, b) 1059 WebInspector.SourceFrameMessage.messageLevelComparator = function(a, b)
1057 { 1060 {
1058 return WebInspector.SourceFrameMessage._messageLevelPriority[a.level()] - We bInspector.SourceFrameMessage._messageLevelPriority[b.level()]; 1061 return WebInspector.SourceFrameMessage._messageLevelPriority[a.level()] - We bInspector.SourceFrameMessage._messageLevelPriority[b.level()];
1059 } 1062 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/sources/JavaScriptCompiler.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698