Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 var pathComponents = WebInspector.ParsedURL.splitURLIntoPathComponents(url); | 45 var pathComponents = WebInspector.ParsedURL.splitURLIntoPathComponents(url); |
| 46 this._origin = pathComponents[0]; | 46 this._origin = pathComponents[0]; |
| 47 this._parentURL = pathComponents.slice(0, -1).join("/"); | 47 this._parentURL = pathComponents.slice(0, -1).join("/"); |
| 48 this._name = pathComponents[pathComponents.length - 1]; | 48 this._name = pathComponents[pathComponents.length - 1]; |
| 49 | 49 |
| 50 this._contentType = contentType; | 50 this._contentType = contentType; |
| 51 /** @type {?function(?string)} */ | 51 /** @type {?function(?string)} */ |
| 52 this._requestContentCallback = null; | 52 this._requestContentCallback = null; |
| 53 /** @type {?Promise<?string>} */ | 53 /** @type {?Promise<?string>} */ |
| 54 this._requestContentPromise = null; | 54 this._requestContentPromise = null; |
| 55 /** @type {?Array<!WebInspector.UISourceCode.LineMarker>} */ | |
| 56 this._lineMarkers = null; | |
| 55 | 57 |
| 56 /** @type {!Array.<!WebInspector.Revision>} */ | 58 /** @type {!Array.<!WebInspector.Revision>} */ |
| 57 this.history = []; | 59 this.history = []; |
| 58 this._hasUnsavedCommittedChanges = false; | 60 this._hasUnsavedCommittedChanges = false; |
| 59 | 61 |
| 60 /** @type {!Array<!WebInspector.UISourceCode.Message>} */ | 62 /** @type {!Array<!WebInspector.UISourceCode.Message>} */ |
| 61 this._messages = []; | 63 this._messages = []; |
| 62 } | 64 } |
| 63 | 65 |
| 64 /** | 66 /** |
| 65 * @enum {string} | 67 * @enum {string} |
| 66 */ | 68 */ |
| 67 WebInspector.UISourceCode.Events = { | 69 WebInspector.UISourceCode.Events = { |
| 68 WorkingCopyChanged: "WorkingCopyChanged", | 70 WorkingCopyChanged: "WorkingCopyChanged", |
| 69 WorkingCopyCommitted: "WorkingCopyCommitted", | 71 WorkingCopyCommitted: "WorkingCopyCommitted", |
| 70 TitleChanged: "TitleChanged", | 72 TitleChanged: "TitleChanged", |
| 71 SourceMappingChanged: "SourceMappingChanged", | 73 SourceMappingChanged: "SourceMappingChanged", |
| 72 MessageAdded: "MessageAdded", | 74 MessageAdded: "MessageAdded", |
| 73 MessageRemoved: "MessageRemoved", | 75 MessageRemoved: "MessageRemoved", |
| 76 LineMarkersChanged: "LineMarkersChanged" | |
|
pfeldman
2016/03/02 19:48:59
MarkersChanged
alph
2016/03/03 02:02:52
Acknowledged.
| |
| 74 } | 77 } |
| 75 | 78 |
| 76 WebInspector.UISourceCode.prototype = { | 79 WebInspector.UISourceCode.prototype = { |
| 77 /** | 80 /** |
| 78 * @return {string} | 81 * @return {string} |
| 79 */ | 82 */ |
| 80 name: function() | 83 name: function() |
| 81 { | 84 { |
| 82 return this._name; | 85 return this._name; |
| 83 }, | 86 }, |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 637 }, | 640 }, |
| 638 | 641 |
| 639 removeAllMessages: function() | 642 removeAllMessages: function() |
| 640 { | 643 { |
| 641 var messages = this._messages; | 644 var messages = this._messages; |
| 642 this._messages = []; | 645 this._messages = []; |
| 643 for (var message of messages) | 646 for (var message of messages) |
| 644 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.Messa geRemoved, message); | 647 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.Messa geRemoved, message); |
| 645 }, | 648 }, |
| 646 | 649 |
| 650 /** | |
| 651 * @param {number} lineNumber | |
| 652 * @param {function(number):!{text:string, color:string}} decorator | |
| 653 */ | |
| 654 addLineMarker: function(lineNumber, decorator) | |
|
pfeldman
2016/03/02 19:48:59
Decorator is from the UI world, while the marker i
alph
2016/03/03 02:02:52
Done.
| |
| 655 { | |
| 656 if (!this._lineMarkers) | |
| 657 this._lineMarkers = []; | |
|
pfeldman
2016/03/02 19:48:59
Bucket by type?
alph
2016/03/03 02:02:52
Done.
| |
| 658 var marker = new WebInspector.UISourceCode.LineMarker(lineNumber, decora tor); | |
| 659 this._lineMarkers.push(marker); | |
|
pfeldman
2016/03/02 19:48:59
There should be a way to fetch markers by type.
alph
2016/03/03 02:02:52
Done.
| |
| 660 // Batch LineMarkersChanged events. | |
| 661 if (this._lineMarkersChanged) | |
| 662 return; | |
| 663 this._lineMarkersChanged = true; | |
| 664 setImmediate(() => { | |
| 665 this._lineMarkersChanged = false; | |
| 666 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.LineM arkersChanged); | |
|
pfeldman
2016/03/02 19:48:59
pass typeString as the data so that you were not
alph
2016/03/03 02:02:52
Done.
| |
| 667 }); | |
| 668 }, | |
| 669 | |
| 670 removeAllLineMarkers: function() | |
|
pfeldman
2016/03/02 19:48:59
There should be a way to clear all "message" marke
alph
2016/03/03 02:02:52
Done.
| |
| 671 { | |
| 672 this._lineMarkers = null; | |
| 673 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.LineMarke rsChanged); | |
| 674 }, | |
| 675 | |
| 676 /** | |
| 677 * @return {?Array<!WebInspector.UISourceCode.LineMarker>} | |
| 678 */ | |
| 679 lineMarkers: function() | |
| 680 { | |
| 681 return this._lineMarkers; | |
| 682 }, | |
| 683 | |
| 647 __proto__: WebInspector.Object.prototype | 684 __proto__: WebInspector.Object.prototype |
| 648 } | 685 } |
| 649 | 686 |
| 650 /** | 687 /** |
| 651 * @constructor | 688 * @constructor |
| 652 * @param {!WebInspector.UISourceCode} uiSourceCode | 689 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 653 * @param {number} lineNumber | 690 * @param {number} lineNumber |
| 654 * @param {number} columnNumber | 691 * @param {number} columnNumber |
| 655 */ | 692 */ |
| 656 WebInspector.UILocation = function(uiSourceCode, lineNumber, columnNumber) | 693 WebInspector.UILocation = function(uiSourceCode, lineNumber, columnNumber) |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 830 * @return {string} | 867 * @return {string} |
| 831 */ | 868 */ |
| 832 text: function() | 869 text: function() |
| 833 { | 870 { |
| 834 return this._text; | 871 return this._text; |
| 835 }, | 872 }, |
| 836 | 873 |
| 837 /** | 874 /** |
| 838 * @return {!WebInspector.TextRange} | 875 * @return {!WebInspector.TextRange} |
| 839 */ | 876 */ |
| 840 range: function() { | 877 range: function() |
| 878 { | |
| 841 return this._range; | 879 return this._range; |
| 842 }, | 880 }, |
| 843 | 881 |
| 844 /** | 882 /** |
| 845 * @return {number} | 883 * @return {number} |
| 846 */ | 884 */ |
| 847 lineNumber: function() | 885 lineNumber: function() |
| 848 { | 886 { |
| 849 return this._range.startLine; | 887 return this._range.startLine; |
| 850 }, | 888 }, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 864 isEqual: function(another) | 902 isEqual: function(another) |
| 865 { | 903 { |
| 866 return this._uiSourceCode === another._uiSourceCode && this.text() === a nother.text() && this.level() === another.level() && this.range().equal(another. range()); | 904 return this._uiSourceCode === another._uiSourceCode && this.text() === a nother.text() && this.level() === another.level() && this.range().equal(another. range()); |
| 867 }, | 905 }, |
| 868 | 906 |
| 869 remove: function() | 907 remove: function() |
| 870 { | 908 { |
| 871 this._uiSourceCode.removeMessage(this); | 909 this._uiSourceCode.removeMessage(this); |
| 872 } | 910 } |
| 873 } | 911 } |
| 912 | |
| 913 /** | |
| 914 * @constructor | |
| 915 * @param {number} line | |
| 916 * @param {function(number):!{text:string, color:string}} decorator | |
| 917 */ | |
| 918 WebInspector.UISourceCode.LineMarker = function(line, decorator) | |
|
pfeldman
2016/03/02 19:48:59
You will only have line and opaque object here, no
alph
2016/03/03 02:02:52
Done.
| |
| 919 { | |
| 920 this._line = line; | |
| 921 this._decorator = decorator; | |
| 922 } | |
| 923 | |
| 924 WebInspector.UISourceCode.LineMarker.prototype = { | |
| 925 /** | |
| 926 * @return {number} | |
| 927 */ | |
| 928 line: function() | |
| 929 { | |
| 930 return this._line; | |
| 931 }, | |
| 932 | |
| 933 /** | |
| 934 * @return {string} | |
| 935 */ | |
| 936 text: function() | |
| 937 { | |
| 938 return this._decorator(this._line).text; | |
| 939 }, | |
| 940 | |
| 941 /** | |
| 942 * @return {string} | |
| 943 */ | |
| 944 color: function() | |
| 945 { | |
| 946 return this._decorator(this._line).color; | |
| 947 } | |
| 948 } | |
| OLD | NEW |