Changeset 109328 in webkit
- Timestamp:
- Mar 1, 2012 2:28:55 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r109321 r109328 1 2012-02-29 Pavel Podivilov <podivilov@chromium.org> 2 3 Web Inspector: abstract out the common pattern of creating auto-updated locations. 4 https://bugs.webkit.org/show_bug.cgi?id=79906 5 6 Reviewed by Vsevolod Vlasov. 7 8 * inspector/debugger/linkifier.html: 9 1 10 2012-02-29 Shinya Kawanaka <shinyak@chromium.org> 2 11 -
trunk/LayoutTests/inspector/debugger/linkifier.html
r101126 r109328 44 44 InspectorTest.addResult("original location: " + link.textContent); 45 45 46 InspectorTest.addSniffer(linkifier , "_updateAnchor", linkUpdated);46 InspectorTest.addSniffer(linkifier._formatter, "formatLiveAnchor", linkUpdated); 47 47 WebInspector.debuggerPresentationModel.setFormatSource(true); 48 48 } … … 51 51 { 52 52 InspectorTest.addResult("pretty printed location: " + link.textContent); 53 InspectorTest.addSniffer(linkifier , "_updateAnchor", linkReverted);53 InspectorTest.addSniffer(linkifier._formatter, "formatLiveAnchor", linkReverted); 54 54 WebInspector.debuggerPresentationModel.setFormatSource(false); 55 55 } … … 76 76 count += listenersArray.length; 77 77 } 78 return count; 78 return count; 79 79 } 80 80 } -
trunk/Source/WebCore/ChangeLog
r109327 r109328 1 2012-02-29 Pavel Podivilov <podivilov@chromium.org> 2 3 Web Inspector: abstract out the common pattern of creating auto-updated locations. 4 https://bugs.webkit.org/show_bug.cgi?id=79906 5 6 Reviewed by Vsevolod Vlasov. 7 8 * inspector/front-end/DebuggerPresentationModel.js: 9 (WebInspector.PresentationCallFrame.prototype.uiLocation): 10 (WebInspector.DebuggerPresentationModel.CallFramePlacard): 11 (WebInspector.DebuggerPresentationModel.CallFramePlacard.prototype.discard): 12 (WebInspector.DebuggerPresentationModel.CallFramePlacard.prototype._update): 13 (WebInspector.DebuggerPresentationModel.LinkifierFormatter.prototype.formatRawSourceCodeAnchor): 14 (WebInspector.DebuggerPresentationModel.DefaultLinkifierFormatter.prototype.formatRawSourceCodeAnchor): 15 (WebInspector.DebuggerPresentationModel.Linkifier): 16 (WebInspector.DebuggerPresentationModel.Linkifier.prototype.linkifyRawSourceCode): 17 (WebInspector.DebuggerPresentationModel.Linkifier.prototype.reset): 18 (WebInspector.DebuggerPresentationModel.Linkifier.prototype._updateAnchor): 19 * inspector/front-end/RawSourceCode.js: 20 (WebInspector.RawSourceCode.prototype.createLiveLocation): 21 (WebInspector.RawSourceCode.LiveLocation): 22 (WebInspector.RawSourceCode.LiveLocation.prototype.init): 23 (WebInspector.RawSourceCode.LiveLocation.prototype.dispose): 24 (WebInspector.RawSourceCode.LiveLocation.prototype._update): 25 1 26 2012-03-01 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 27 -
trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js
r109323 r109328 750 750 uiLocation: function(callback) 751 751 { 752 function uiSourceCodeListChanged()752 function locationUpdated(uiLocation) 753 753 { 754 callback(this._rawSourceCode.rawLocationToUILocation(this._callFrame.location));755 this._rawSourceCode.removeEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, uiSourceCodeListChanged, this);756 }757 var uiLocation = this._rawSourceCode.rawLocationToUILocation(this._callFrame.location);758 if (uiLocation)759 754 callback(uiLocation); 760 else 761 this._rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, uiSourceCodeListChanged, this); 755 liveLocation.dispose(); 756 } 757 var liveLocation = this._rawSourceCode.createLiveLocation(this._callFrame.location, locationUpdated.bind(this)); 758 liveLocation.init(); 762 759 } 763 760 } … … 771 768 { 772 769 WebInspector.Placard.call(this, callFrame._callFrame.functionName || WebInspector.UIString("(anonymous function)"), ""); 773 this._callFrame = callFrame; 774 this._update(); 775 this._callFrame._rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, this._update, this); 770 this._liveLocation = callFrame._rawSourceCode.createLiveLocation(callFrame._callFrame.location, this._update.bind(this)); 771 this._liveLocation.init(); 776 772 } 777 773 … … 779 775 discard: function() 780 776 { 781 this._callFrame._rawSourceCode.removeEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, this._update, this); 782 }, 783 784 _update: function() 785 { 786 var rawSourceCode = this._callFrame._rawSourceCode; 787 var uiLocation = rawSourceCode.rawLocationToUILocation(this._callFrame._callFrame.location); 788 if (uiLocation) 789 this.subtitle = WebInspector.displayNameForURL(uiLocation.uiSourceCode.url) + ":" + (uiLocation.lineNumber + 1); 777 this._liveLocation.dispose(); 778 }, 779 780 _update: function(uiLocation) 781 { 782 this.subtitle = WebInspector.displayNameForURL(uiLocation.uiSourceCode.url) + ":" + (uiLocation.lineNumber + 1); 790 783 } 791 784 } … … 860 853 } 861 854 855 WebInspector.DebuggerPresentationModelResourceBinding.prototype.__proto__ = WebInspector.ResourceDomainModelBinding.prototype; 856 862 857 /** 863 858 * @interface … … 869 864 WebInspector.DebuggerPresentationModel.LinkifierFormatter.prototype = { 870 865 /** 871 * @param {WebInspector.RawSourceCode} rawSourceCode872 866 * @param {Element} anchor 873 */ 874 formatRawSourceCodeAnchor: function(rawSourceCode, anchor) { }, 867 * @param {WebInspector.UILocation} uiLocation 868 */ 869 formatLiveAnchor: function(anchor, uiLocation) { }, 875 870 } 876 871 … … 887 882 WebInspector.DebuggerPresentationModel.DefaultLinkifierFormatter.prototype = { 888 883 /** 889 * @param {WebInspector.RawSourceCode} rawSourceCode890 884 * @param {Element} anchor 891 */ 892 formatRawSourceCodeAnchor: function(rawSourceCode, anchor) 893 { 894 var uiLocation = rawSourceCode.rawLocationToUILocation(anchor.rawLocation); 895 if (!uiLocation) 896 return; 897 885 * @param {WebInspector.UILocation} uiLocation 886 */ 887 formatLiveAnchor: function(anchor, uiLocation) 888 { 898 889 anchor.textContent = WebInspector.formatLinkText(uiLocation.uiSourceCode.url, uiLocation.lineNumber); 899 890 … … 916 907 this._model = model; 917 908 this._formatter = formatter || new WebInspector.DebuggerPresentationModel.DefaultLinkifierFormatter(); 918 this._ anchorsForRawSourceCode = {};909 this._liveLocations = []; 919 910 } 920 911 … … 944 935 { 945 936 var anchor = WebInspector.linkifyURLAsNode(rawSourceCode.url, "", classes, false); 946 anchor.rawLocation = { lineNumber: lineNumber, columnNumber: columnNumber }; 947 948 var anchors = this._anchorsForRawSourceCode[rawSourceCode.id]; 949 if (!anchors) { 950 anchors = []; 951 this._anchorsForRawSourceCode[rawSourceCode.id] = anchors; 952 rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, this._updateSourceAnchors, this); 953 } 954 955 this._updateAnchor(rawSourceCode, anchor); 956 anchors.push(anchor); 937 var rawLocation = { lineNumber: lineNumber, columnNumber: columnNumber }; 938 var liveLocation = rawSourceCode.createLiveLocation(rawLocation, this._updateAnchor.bind(this, anchor)); 939 liveLocation.init(); 940 this._liveLocations.push(liveLocation); 957 941 return anchor; 958 942 }, … … 968 952 reset: function() 969 953 { 970 for (var id in this._anchorsForRawSourceCode) { 971 if (this._model._rawSourceCodeForScriptId[id]) // In case of navigation the list of rawSourceCodes is empty. 972 this._model._rawSourceCodeForScriptId[id].removeEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, this._updateSourceAnchors, this); 973 } 974 this._anchorsForRawSourceCode = {}; 975 }, 976 977 /** 978 * @param {WebInspector.Event} event 979 */ 980 _updateSourceAnchors: function(event) 981 { 982 var rawSourceCode = /** @type {WebInspector.RawSourceCode} */ event.target; 983 var anchors = this._anchorsForRawSourceCode[rawSourceCode.id]; 984 for (var i = 0; i < anchors.length; ++i) 985 this._updateAnchor(rawSourceCode, anchors[i]); 986 }, 987 988 /** 989 * @param {WebInspector.RawSourceCode} rawSourceCode 954 for (var i = 0; i < this._liveLocations.length; ++i) 955 this._liveLocations[i].dispose(); 956 this._liveLocations = []; 957 }, 958 959 /** 990 960 * @param {Element} anchor 991 */ 992 _updateAnchor: function(rawSourceCode, anchor) 993 { 994 var uiLocation = rawSourceCode.rawLocationToUILocation(anchor.rawLocation); 995 if (!uiLocation) 996 return; 997 961 * @param {WebInspector.UILocation} uiLocation 962 */ 963 _updateAnchor: function(anchor, uiLocation) 964 { 998 965 anchor.preferredPanel = "scripts"; 999 966 anchor.uiSourceCode = uiLocation.uiSourceCode; 1000 967 anchor.lineNumber = uiLocation.lineNumber; 1001 1002 this._formatter.formatRawSourceCodeAnchor(rawSourceCode, anchor); 968 this._formatter.formatLiveAnchor(anchor, uiLocation); 1003 969 } 1004 970 } 1005 1006 WebInspector.DebuggerPresentationModelResourceBinding.prototype.__proto__ = WebInspector.ResourceDomainModelBinding.prototype;1007 971 1008 972 /** -
trunk/Source/WebCore/inspector/front-end/RawSourceCode.js
r109323 r109328 110 110 }, 111 111 112 createLiveLocation: function(rawLocation, updateDelegate) 113 { 114 return new WebInspector.RawSourceCode.LiveLocation(this, rawLocation, updateDelegate); 115 }, 116 112 117 /** 113 118 * @param {boolean} formatted … … 281 286 282 287 /** 288 * @constructor 289 * @param {WebInspector.RawSourceCode} rawSourceCode 290 * @param {DebuggerAgent.Location} rawLocation 291 * @param {function(WebInspector.UILocation)} updateDelegate 292 */ 293 WebInspector.RawSourceCode.LiveLocation = function(rawSourceCode, rawLocation, updateDelegate) 294 { 295 this._rawSourceCode = rawSourceCode; 296 this._rawLocation = rawLocation; 297 this._updateDelegate = updateDelegate; 298 } 299 300 WebInspector.RawSourceCode.LiveLocation.prototype = { 301 init: function() 302 { 303 this._rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, this._update, this); 304 this._update(); 305 }, 306 307 dispose: function() 308 { 309 this._rawSourceCode.removeEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, this._update, this); 310 }, 311 312 _update: function() 313 { 314 var uiLocation = this._rawSourceCode.rawLocationToUILocation(this._rawLocation); 315 if (uiLocation) 316 this._updateDelegate(uiLocation); 317 } 318 } 319 320 /** 283 321 * @interface 284 322 */ -
trunk/Source/WebCore/inspector/front-end/ScriptsSearchScope.js
r108971 r109328 177 177 WebInspector.ScriptsSearchResultsPane.LinkifierFormatter.prototype = { 178 178 /** 179 * @param {WebInspector.RawSourceCode} rawSourceCode180 179 * @param {Element} anchor 180 * @param {WebInspector.UILocation} uiLocation 181 181 */ 182 format RawSourceCodeAnchor: function(rawSourceCode, anchor)182 formatLiveAnchor: function(anchor, uiLocation) 183 183 { 184 184 // Empty because we don't want to ever update anchor contents after creation.
Note: See TracChangeset
for help on using the changeset viewer.