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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 ConsoleMessagesCleared: "console-messages-cleared", | 61 ConsoleMessagesCleared: "console-messages-cleared", |
62 BreakpointAdded: "breakpoint-added", | 62 BreakpointAdded: "breakpoint-added", |
63 BreakpointRemoved: "breakpoint-removed", | 63 BreakpointRemoved: "breakpoint-removed", |
64 DebuggerPaused: "debugger-paused", | 64 DebuggerPaused: "debugger-paused", |
65 DebuggerResumed: "debugger-resumed", | 65 DebuggerResumed: "debugger-resumed", |
66 CallFrameSelected: "call-frame-selected", | 66 CallFrameSelected: "call-frame-selected", |
67 ExecutionLineChanged: "execution-line-changed" | 67 ExecutionLineChanged: "execution-line-changed" |
68 } | 68 } |
69 | 69 |
70 WebInspector.DebuggerPresentationModel.prototype = { | 70 WebInspector.DebuggerPresentationModel.prototype = { |
71 createLinkifier: function() | 71 /** |
| 72 * @param {WebInspector.DebuggerPresentationModel.LinkifierFormatter=} forma
tter |
| 73 */ |
| 74 createLinkifier: function(formatter) |
72 { | 75 { |
73 return new WebInspector.DebuggerPresentationModel.Linkifier(this); | 76 return new WebInspector.DebuggerPresentationModel.Linkifier(this, format
ter); |
74 }, | 77 }, |
75 | 78 |
76 /** | 79 /** |
77 * @param {WebInspector.PresentationCallFrame} callFrame | 80 * @param {WebInspector.PresentationCallFrame} callFrame |
78 * @return {WebInspector.Placard} | 81 * @return {WebInspector.Placard} |
79 */ | 82 */ |
80 createPlacard: function(callFrame) | 83 createPlacard: function(callFrame) |
81 { | 84 { |
82 var title = callFrame._callFrame.functionName || WebInspector.UIString("
(anonymous function)"); | 85 var title = callFrame._callFrame.functionName || WebInspector.UIString("
(anonymous function)"); |
83 var placard = new WebInspector.Placard(title, ""); | 86 var placard = new WebInspector.Placard(title, ""); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Eve
nts.ConsoleMessagesCleared); | 358 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Eve
nts.ConsoleMessagesCleared); |
356 }, | 359 }, |
357 | 360 |
358 /** | 361 /** |
359 * @param {WebInspector.UISourceCode} uiSourceCode | 362 * @param {WebInspector.UISourceCode} uiSourceCode |
360 * @param {number} lineNumber | 363 * @param {number} lineNumber |
361 */ | 364 */ |
362 continueToLine: function(uiSourceCode, lineNumber) | 365 continueToLine: function(uiSourceCode, lineNumber) |
363 { | 366 { |
364 // FIXME: use RawSourceCode.uiLocationToRawLocation. | 367 // FIXME: use RawSourceCode.uiLocationToRawLocation. |
365 var rawLocation = uiSourceCode.rawSourceCode.sourceMapping.uiLocationToR
awLocation(uiSourceCode, lineNumber); | 368 var rawLocation = uiSourceCode.rawSourceCode.sourceMapping.uiLocationToR
awLocation(uiSourceCode, lineNumber, 0); |
366 WebInspector.debuggerModel.continueToLocation(rawLocation); | 369 WebInspector.debuggerModel.continueToLocation(rawLocation); |
367 }, | 370 }, |
368 | 371 |
369 /** | 372 /** |
370 * @param {WebInspector.UISourceCode} uiSourceCode | 373 * @param {WebInspector.UISourceCode} uiSourceCode |
371 * @return {Array.<WebInspector.Breakpoint>} | 374 * @return {Array.<WebInspector.Breakpoint>} |
372 */ | 375 */ |
373 breakpointsForUISourceCode: function(uiSourceCode) | 376 breakpointsForUISourceCode: function(uiSourceCode) |
374 { | 377 { |
375 var breakpointsMap = this._breakpointManager.breakpointsForUISourceCode(
uiSourceCode); | 378 var breakpointsMap = this._breakpointManager.breakpointsForUISourceCode(
uiSourceCode); |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 if (userCallback) | 759 if (userCallback) |
757 userCallback(error); | 760 userCallback(error); |
758 if (!error) | 761 if (!error) |
759 this._presentationModel._updateBreakpointsAfterLiveEdit(uiSource
Code, oldContent, content); | 762 this._presentationModel._updateBreakpointsAfterLiveEdit(uiSource
Code, oldContent, content); |
760 } | 763 } |
761 this._presentationModel.setScriptSource(uiSourceCode, content, callback.
bind(this)); | 764 this._presentationModel.setScriptSource(uiSourceCode, content, callback.
bind(this)); |
762 } | 765 } |
763 } | 766 } |
764 | 767 |
765 /** | 768 /** |
| 769 * @interface |
| 770 */ |
| 771 WebInspector.DebuggerPresentationModel.LinkifierFormatter = function() |
| 772 { |
| 773 } |
| 774 |
| 775 WebInspector.DebuggerPresentationModel.LinkifierFormatter.prototype = { |
| 776 /** |
| 777 * @param {WebInspector.RawSourceCode} rawSourceCode |
| 778 * @param {Element} anchor |
| 779 */ |
| 780 formatRawSourceCodeAnchor: function(rawSourceCode, anchor) { }, |
| 781 } |
| 782 |
| 783 /** |
766 * @constructor | 784 * @constructor |
| 785 * @implements {WebInspector.DebuggerPresentationModel.LinkifierFormatter} |
| 786 * @param {number=} maxLength |
| 787 */ |
| 788 WebInspector.DebuggerPresentationModel.DefaultLinkifierFormatter = function(maxL
ength) |
| 789 { |
| 790 this._maxLength = maxLength; |
| 791 } |
| 792 |
| 793 WebInspector.DebuggerPresentationModel.DefaultLinkifierFormatter.prototype = { |
| 794 /** |
| 795 * @param {WebInspector.RawSourceCode} rawSourceCode |
| 796 * @param {Element} anchor |
| 797 */ |
| 798 formatRawSourceCodeAnchor: function(rawSourceCode, anchor) |
| 799 { |
| 800 var uiLocation = rawSourceCode.sourceMapping.rawLocationToUILocation(anc
hor.rawLocation); |
| 801 |
| 802 anchor.textContent = WebInspector.formatLinkText(uiLocation.uiSourceCode
.url, uiLocation.lineNumber); |
| 803 |
| 804 var text = WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLo
cation.lineNumber); |
| 805 if (this._maxLength) |
| 806 text = text.trimMiddle(this._maxLength); |
| 807 anchor.textContent = text; |
| 808 } |
| 809 } |
| 810 |
| 811 WebInspector.DebuggerPresentationModel.DefaultLinkifierFormatter.prototype.__pro
to__ = WebInspector.DebuggerPresentationModel.LinkifierFormatter.prototype; |
| 812 |
| 813 /** |
| 814 * @constructor |
767 * @param {WebInspector.DebuggerPresentationModel} model | 815 * @param {WebInspector.DebuggerPresentationModel} model |
| 816 * @param {WebInspector.DebuggerPresentationModel.LinkifierFormatter=} formatter |
768 */ | 817 */ |
769 WebInspector.DebuggerPresentationModel.Linkifier = function(model) | 818 WebInspector.DebuggerPresentationModel.Linkifier = function(model, formatter) |
770 { | 819 { |
771 this._model = model; | 820 this._model = model; |
| 821 this._formatter = formatter || new WebInspector.DebuggerPresentationModel.De
faultLinkifierFormatter(); |
772 this._anchorsForRawSourceCode = {}; | 822 this._anchorsForRawSourceCode = {}; |
773 } | 823 } |
774 | 824 |
775 WebInspector.DebuggerPresentationModel.Linkifier.prototype = { | 825 WebInspector.DebuggerPresentationModel.Linkifier.prototype = { |
776 /** | 826 /** |
777 * @param {string} sourceURL | 827 * @param {string} sourceURL |
778 * @param {number=} lineNumber | 828 * @param {number=} lineNumber |
779 * @param {number=} columnNumber | 829 * @param {number=} columnNumber |
780 * @param {string=} classes | 830 * @param {string=} classes |
781 */ | 831 */ |
782 linkifyLocation: function(sourceURL, lineNumber, columnNumber, classes) | 832 linkifyLocation: function(sourceURL, lineNumber, columnNumber, classes) |
783 { | 833 { |
| 834 var rawSourceCode = this._model._rawSourceCodeForScriptWithURL(sourceURL
); |
| 835 if (!rawSourceCode) |
| 836 return this.linkifyResource(sourceURL, lineNumber, classes); |
| 837 |
| 838 return this.linkifyRawSourceCode(rawSourceCode, lineNumber, columnNumber
, classes); |
| 839 }, |
| 840 |
| 841 /** |
| 842 * @param {string} sourceURL |
| 843 * @param {number=} lineNumber |
| 844 * @param {string=} classes |
| 845 */ |
| 846 linkifyResource: function(sourceURL, lineNumber, classes) |
| 847 { |
784 var linkText = WebInspector.formatLinkText(sourceURL, lineNumber); | 848 var linkText = WebInspector.formatLinkText(sourceURL, lineNumber); |
785 var anchor = WebInspector.linkifyURLAsNode(sourceURL, linkText, classes,
false); | 849 var anchor = WebInspector.linkifyURLAsNode(sourceURL, linkText, classes,
false); |
| 850 anchor.setAttribute("preferred_panel", "resources"); |
| 851 anchor.setAttribute("line_number", lineNumber); |
| 852 return anchor; |
| 853 }, |
| 854 |
| 855 /** |
| 856 * @param {WebInspector.RawSourceCode} rawSourceCode |
| 857 * @param {number=} lineNumber |
| 858 * @param {number=} columnNumber |
| 859 * @param {string=} classes |
| 860 */ |
| 861 linkifyRawSourceCode: function(rawSourceCode, lineNumber, columnNumber, clas
ses) |
| 862 { |
| 863 var anchor = WebInspector.linkifyURLAsNode(rawSourceCode.url, "", classe
s, false); |
786 anchor.rawLocation = { lineNumber: lineNumber, columnNumber: columnNumbe
r }; | 864 anchor.rawLocation = { lineNumber: lineNumber, columnNumber: columnNumbe
r }; |
787 | 865 |
788 var rawSourceCode = this._model._rawSourceCodeForScriptWithURL(sourceURL
); | |
789 if (!rawSourceCode) { | |
790 anchor.setAttribute("preferred_panel", "resources"); | |
791 anchor.setAttribute("line_number", lineNumber); | |
792 return anchor; | |
793 } | |
794 | |
795 var anchors = this._anchorsForRawSourceCode[rawSourceCode.id]; | 866 var anchors = this._anchorsForRawSourceCode[rawSourceCode.id]; |
796 if (!anchors) { | 867 if (!anchors) { |
797 anchors = []; | 868 anchors = []; |
798 this._anchorsForRawSourceCode[rawSourceCode.id] = anchors; | 869 this._anchorsForRawSourceCode[rawSourceCode.id] = anchors; |
799 rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.Sou
rceMappingUpdated, this._updateSourceAnchors, this); | 870 rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.Sou
rceMappingUpdated, this._updateSourceAnchors, this); |
800 } | 871 } |
801 | 872 |
802 if (rawSourceCode.sourceMapping) | 873 if (rawSourceCode.sourceMapping) |
803 this._updateAnchor(rawSourceCode, anchor); | 874 this._updateAnchor(rawSourceCode, anchor); |
804 anchors.push(anchor); | 875 anchors.push(anchor); |
(...skipping 20 matching lines...) Expand all Loading... |
825 this._updateAnchor(rawSourceCode, anchors[i]); | 896 this._updateAnchor(rawSourceCode, anchors[i]); |
826 }, | 897 }, |
827 | 898 |
828 /** | 899 /** |
829 * @param {WebInspector.RawSourceCode} rawSourceCode | 900 * @param {WebInspector.RawSourceCode} rawSourceCode |
830 * @param {Element} anchor | 901 * @param {Element} anchor |
831 */ | 902 */ |
832 _updateAnchor: function(rawSourceCode, anchor) | 903 _updateAnchor: function(rawSourceCode, anchor) |
833 { | 904 { |
834 var uiLocation = rawSourceCode.sourceMapping.rawLocationToUILocation(anc
hor.rawLocation); | 905 var uiLocation = rawSourceCode.sourceMapping.rawLocationToUILocation(anc
hor.rawLocation); |
835 anchor.textContent = WebInspector.formatLinkText(uiLocation.uiSourceCode
.url, uiLocation.lineNumber); | |
836 anchor.setAttribute("preferred_panel", "scripts"); | 906 anchor.setAttribute("preferred_panel", "scripts"); |
837 anchor.uiSourceCode = uiLocation.uiSourceCode; | 907 anchor.uiSourceCode = uiLocation.uiSourceCode; |
838 anchor.lineNumber = uiLocation.lineNumber; | 908 anchor.lineNumber = uiLocation.lineNumber; |
| 909 |
| 910 this._formatter.formatRawSourceCodeAnchor(rawSourceCode, anchor); |
839 } | 911 } |
840 } | 912 } |
841 | 913 |
842 WebInspector.DebuggerPresentationModelResourceBinding.prototype.__proto__ = WebI
nspector.ResourceDomainModelBinding.prototype; | 914 WebInspector.DebuggerPresentationModelResourceBinding.prototype.__proto__ = WebI
nspector.ResourceDomainModelBinding.prototype; |
843 | 915 |
844 /** | 916 /** |
845 * @type {?WebInspector.DebuggerPresentationModel} | 917 * @type {?WebInspector.DebuggerPresentationModel} |
846 */ | 918 */ |
847 WebInspector.debuggerPresentationModel = null; | 919 WebInspector.debuggerPresentationModel = null; |
OLD | NEW |