Chromium Code Reviews

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

Issue 1264133002: Devtools: [WIP] Implement enhanced devtools extension language APIs Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Small cleanups - prefer URIs to contentURLs, revert protocol unifications, remove lambdas Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 582 matching lines...)
593 var messageBucket = this._rowMessageBuckets[lineNumber]; 593 var messageBucket = this._rowMessageBuckets[lineNumber];
594 if (!messageBucket) 594 if (!messageBucket)
595 return; 595 return;
596 messageBucket.removeMessage(message); 596 messageBucket.removeMessage(message);
597 if (!messageBucket.uniqueMessagesCount()) { 597 if (!messageBucket.uniqueMessagesCount()) {
598 messageBucket.detachFromEditor(); 598 messageBucket.detachFromEditor();
599 delete this._rowMessageBuckets[lineNumber]; 599 delete this._rowMessageBuckets[lineNumber];
600 } 600 }
601 }, 601 },
602 602
603 populateLineGutterContextMenu: function(contextMenu, lineNumber) 603 setMessagesForSource: function(messages) {
604 { 604 this.clearMessages();
605 }, 605 for (var index = 0; index < messages.length; index++) {
606 606 var message = messages[index];
607 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber) 607 this.addMessageToSource(message);
608 { 608 }
609 }, 609 },
610 610
611 /** 611 /**
612 * @return {!Promise}
613 */
614 populateLineGutterContextMenu: function(contextMenu, lineNumber)
615 {
616 return Promise.resolve();
617 },
618
619 /**
620 * @return {!Promise}
621 */
622 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber)
623 {
624 return Promise.resolve();
625 },
626
627 /**
612 * @param {?WebInspector.TextRange} from 628 * @param {?WebInspector.TextRange} from
613 * @param {?WebInspector.TextRange} to 629 * @param {?WebInspector.TextRange} to
614 */ 630 */
615 onJumpToPosition: function(from, to) 631 onJumpToPosition: function(from, to)
616 { 632 {
617 this.dispatchEventToListeners(WebInspector.SourceFrame.Events.JumpHappen ed, { 633 this.dispatchEventToListeners(WebInspector.SourceFrame.Events.JumpHappen ed, {
618 from: from, 634 from: from,
619 to: to 635 to: to
620 }); 636 });
621 }, 637 },
(...skipping 55 matching lines...)
677 e.consume(true); 693 e.consume(true);
678 }, 694 },
679 695
680 __proto__: WebInspector.VBox.prototype 696 __proto__: WebInspector.VBox.prototype
681 } 697 }
682 698
683 /** 699 /**
684 * @constructor 700 * @constructor
685 * @param {string} messageText 701 * @param {string} messageText
686 * @param {!WebInspector.SourceFrameMessage.Level} level 702 * @param {!WebInspector.SourceFrameMessage.Level} level
687 * @param {number} lineNumber 703 * @param {{line: number, column: (number|undefined)}} start
688 * @param {number=} columnNumber 704 * @param {{line: number, column: (number|undefined)}} end
689 */ 705 */
690 WebInspector.SourceFrameMessage = function(messageText, level, lineNumber, colum nNumber) 706 WebInspector.SourceFrameMessage = function(messageText, level, start, end)
691 { 707 {
692 this._messageText = messageText; 708 this._messageText = messageText;
693 this._level = level; 709 this._level = level;
694 this._lineNumber = lineNumber; 710 this._start = {
695 this._columnNumber = columnNumber; 711 line: start.line,
712 column: start.column
713 };
714 this._end = {
715 line: end.line,
716 column: end.column
717 };
696 } 718 }
697 719
698 /** 720 /**
699 * @enum {string} 721 * @enum {string}
700 */ 722 */
701 WebInspector.SourceFrameMessage.Level = { 723 WebInspector.SourceFrameMessage.Level = {
702 Error: "Error", 724 Error: "Error",
703 Warning: "Warning" 725 Warning: "Warning"
704 } 726 }
705 727
706 /** 728 /**
707 * @param {!WebInspector.ConsoleMessage} consoleMessage 729 * @param {!WebInspector.ConsoleMessage} consoleMessage
708 * @param {number} lineNumber 730 * @param {number} lineNumber
709 * @param {number} columnNumber 731 * @param {number} columnNumber
710 * @return {!WebInspector.SourceFrameMessage} 732 * @return {!WebInspector.SourceFrameMessage}
711 */ 733 */
712 WebInspector.SourceFrameMessage.fromConsoleMessage = function(consoleMessage, li neNumber, columnNumber) 734 WebInspector.SourceFrameMessage.fromConsoleMessage = function(consoleMessage, li neNumber, columnNumber)
713 { 735 {
714 console.assert(consoleMessage.level === WebInspector.ConsoleMessage.MessageL evel.Error || consoleMessage.level === WebInspector.ConsoleMessage.MessageLevel. Warning); 736 console.assert(consoleMessage.level === WebInspector.ConsoleMessage.MessageL evel.Error || consoleMessage.level === WebInspector.ConsoleMessage.MessageLevel. Warning);
715 var level = consoleMessage.level === WebInspector.ConsoleMessage.MessageLeve l.Error ? WebInspector.SourceFrameMessage.Level.Error : WebInspector.SourceFrame Message.Level.Warning; 737 var level = consoleMessage.level === WebInspector.ConsoleMessage.MessageLeve l.Error ? WebInspector.SourceFrameMessage.Level.Error : WebInspector.SourceFrame Message.Level.Warning;
716 return new WebInspector.SourceFrameMessage(consoleMessage.messageText, level , lineNumber, columnNumber); 738 var location = {line: lineNumber, column: columnNumber};
739 return new WebInspector.SourceFrameMessage(consoleMessage.messageText, level , location, location);
717 } 740 }
718 741
719 WebInspector.SourceFrameMessage.prototype = { 742 WebInspector.SourceFrameMessage.prototype = {
720 /** 743 /**
721 * @return {string} 744 * @return {string}
722 */ 745 */
723 messageText: function() 746 messageText: function()
724 { 747 {
725 return this._messageText; 748 return this._messageText;
726 }, 749 },
727 750
728 /** 751 /**
729 * @return {!WebInspector.SourceFrameMessage.Level} 752 * @return {!WebInspector.SourceFrameMessage.Level}
730 */ 753 */
731 level: function() 754 level: function()
732 { 755 {
733 return this._level; 756 return this._level;
734 }, 757 },
735 758
736 /** 759 /**
760 * @return {{line: number, column: (number|undefined)}}
761 */
762 start: function() {
763 return this._start;
764 },
765
766 /**
767 * @return {{line: number, column: (number|undefined)}}
768 */
769 end: function() {
770 return this._end;
771 },
772
773 /**
737 * @return {number} 774 * @return {number}
738 */ 775 */
739 lineNumber: function() 776 lineNumber: function()
740 { 777 {
741 return this._lineNumber; 778 return this._start.line;
742 }, 779 },
743 780
744 /** 781 /**
745 * @return {(number|undefined)} 782 * @return {(number|undefined)}
746 */ 783 */
747 columnNumber: function() 784 columnNumber: function()
748 { 785 {
749 return this._columnNumber; 786 return this._start.column;
750 }, 787 },
751 788
752 /** 789 /**
753 * @param {!WebInspector.SourceFrameMessage} another 790 * @param {!WebInspector.SourceFrameMessage} another
754 * @return {boolean} 791 * @return {boolean}
755 */ 792 */
756 isEqual: function(another) 793 isEqual: function(another)
757 { 794 {
758 return this.messageText() === another.messageText() && this.level() === another.level() && this.lineNumber() === another.lineNumber() && this.columnNumb er() === another.columnNumber(); 795 return this.messageText() === another.messageText() &&
796 this.level() === another.level() &&
797 this.lineNumber() === another.lineNumber() &&
798 this.columnNumber() === another.columnNumber() &&
799 this.end().line === another.end().line &&
800 this.end().column === another.end().column;
759 } 801 }
760 } 802 }
761 803
762 WebInspector.SourceFrame._iconClassPerLevel = {}; 804 WebInspector.SourceFrame._iconClassPerLevel = {};
763 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Error] = "error-icon"; 805 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Error] = "error-icon";
764 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Warning] = "warning-icon"; 806 WebInspector.SourceFrame._iconClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Warning] = "warning-icon";
765 807
766 WebInspector.SourceFrame._lineClassPerLevel = {}; 808 WebInspector.SourceFrame._lineClassPerLevel = {};
767 WebInspector.SourceFrame._lineClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Error] = "text-editor-line-with-error"; 809 WebInspector.SourceFrame._lineClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Error] = "text-editor-line-with-error";
768 WebInspector.SourceFrame._lineClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Warning] = "text-editor-line-with-warning"; 810 WebInspector.SourceFrame._lineClassPerLevel[WebInspector.SourceFrameMessage.Leve l.Warning] = "text-editor-line-with-warning";
(...skipping 82 matching lines...)
851 * @param {number} lineNumber 893 * @param {number} lineNumber
852 * @param {number} columnNumber 894 * @param {number} columnNumber
853 */ 895 */
854 _updateWavePosition: function(lineNumber, columnNumber) 896 _updateWavePosition: function(lineNumber, columnNumber)
855 { 897 {
856 var lineText = this._textEditor.line(lineNumber); 898 var lineText = this._textEditor.line(lineNumber);
857 var lineIndent = WebInspector.TextUtils.lineIndent(lineText).length; 899 var lineIndent = WebInspector.TextUtils.lineIndent(lineText).length;
858 var base = this._textEditor.cursorPositionToCoordinates(lineNumber, 0); 900 var base = this._textEditor.cursorPositionToCoordinates(lineNumber, 0);
859 901
860 var start = this._textEditor.cursorPositionToCoordinates(lineNumber, Mat h.max(columnNumber - 1, lineIndent)); 902 var start = this._textEditor.cursorPositionToCoordinates(lineNumber, Mat h.max(columnNumber - 1, lineIndent));
903 if (!start) {
904 return; //stale data - columnNumber is already gone, wait for future update and for UI to settle
905 }
861 var end = this._textEditor.cursorPositionToCoordinates(lineNumber, lineT ext.length); 906 var end = this._textEditor.cursorPositionToCoordinates(lineNumber, lineT ext.length);
862 /** @const */ 907 /** @const */
863 var codeMirrorLinesLeftPadding = 4; 908 var codeMirrorLinesLeftPadding = 4;
864 this._wave.style.left = (start.x - base.x + codeMirrorLinesLeftPadding) + "px"; 909 this._wave.style.left = (start.x - base.x + codeMirrorLinesLeftPadding) + "px";
865 this._wave.style.width = (end.x - start.x) + "px"; 910 this._wave.style.width = (end.x - start.x) + "px";
866 }, 911 },
867 912
868 /** 913 /**
869 * @return {!Element} 914 * @return {!Element}
870 */ 915 */
(...skipping 132 matching lines...)
1003 /** 1048 /**
1004 * @override 1049 * @override
1005 */ 1050 */
1006 editorFocused: function() 1051 editorFocused: function()
1007 { 1052 {
1008 this._sourceFrame._editorFocused(); 1053 this._sourceFrame._editorFocused();
1009 }, 1054 },
1010 1055
1011 /** 1056 /**
1012 * @override 1057 * @override
1058 * @param {!WebInspector.ContextMenu} contextMenu
1059 * @param {number} lineNumber
1060 * @return {!Promise}
1013 */ 1061 */
1014 populateLineGutterContextMenu: function(contextMenu, lineNumber) 1062 populateLineGutterContextMenu: function(contextMenu, lineNumber)
1015 { 1063 {
1016 this._sourceFrame.populateLineGutterContextMenu(contextMenu, lineNumber) ; 1064 return this._sourceFrame.populateLineGutterContextMenu(contextMenu, line Number);
1017 }, 1065 },
1018 1066
1019 /** 1067 /**
1020 * @override 1068 * @override
1069 * @param {!WebInspector.ContextMenu} contextMenu
1070 * @param {number} lineNumber
1071 * @param {number} columnNumber
1072 * @return {!Promise}
1021 */ 1073 */
1022 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber) 1074 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber)
1023 { 1075 {
1024 this._sourceFrame.populateTextAreaContextMenu(contextMenu, lineNumber, c olumnNumber); 1076 return this._sourceFrame.populateTextAreaContextMenu(contextMenu, lineNu mber, columnNumber);
1025 }, 1077 },
1026 1078
1027 /** 1079 /**
1028 * @override 1080 * @override
1029 * @param {?WebInspector.TextRange} from 1081 * @param {?WebInspector.TextRange} from
1030 * @param {?WebInspector.TextRange} to 1082 * @param {?WebInspector.TextRange} to
1031 */ 1083 */
1032 onJumpToPosition: function(from, to) 1084 onJumpToPosition: function(from, to)
1033 { 1085 {
1034 this._sourceFrame.onJumpToPosition(from, to); 1086 this._sourceFrame.onJumpToPosition(from, to);
1035 } 1087 }
1036 } 1088 }
1037 1089
1038 WebInspector.SourceFrameMessage._messageLevelPriority = { 1090 WebInspector.SourceFrameMessage._messageLevelPriority = {
1039 "Warning": 3, 1091 "Warning": 3,
1040 "Error": 4 1092 "Error": 4
1041 }; 1093 };
1042 1094
1043 /** 1095 /**
1044 * @param {!WebInspector.SourceFrameMessage} a 1096 * @param {!WebInspector.SourceFrameMessage} a
1045 * @param {!WebInspector.SourceFrameMessage} b 1097 * @param {!WebInspector.SourceFrameMessage} b
1046 * @return {number} 1098 * @return {number}
1047 */ 1099 */
1048 WebInspector.SourceFrameMessage.messageLevelComparator = function(a, b) 1100 WebInspector.SourceFrameMessage.messageLevelComparator = function(a, b)
1049 { 1101 {
1050 return WebInspector.SourceFrameMessage._messageLevelPriority[a.level()] - We bInspector.SourceFrameMessage._messageLevelPriority[b.level()]; 1102 return WebInspector.SourceFrameMessage._messageLevelPriority[a.level()] - We bInspector.SourceFrameMessage._messageLevelPriority[b.level()];
1051 } 1103 }
OLDNEW

Powered by Google App Engine