Changeset 76132 in webkit
- Timestamp:
- Jan 19, 2011 9:57:36 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r76129 r76132 1 2011-01-18 Pavel Podivilov <podivilov@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: add UglifyJS parser and formatter files 6 https://bugs.webkit.org/show_bug.cgi?id=51702 7 8 * WebCore.gypi: 9 * WebCore.vcproj/WebCore.vcproj: 10 * inspector/front-end/ScriptFormatter.js: 11 (WebInspector.ScriptFormatter.positionToLocation): 12 (WebInspector.ScriptFormatter.prototype.format.messageHandler): 13 (WebInspector.ScriptFormatter.prototype.format): 14 (WebInspector.ScriptFormatter.prototype._buildMapping): 15 (WebInspector.ScriptFormatter.prototype._convertPosition): 16 * inspector/front-end/SourceFrame.js: 17 (WebInspector.SourceFrame.prototype.formatSource.didFormat): 18 (WebInspector.SourceFrame.prototype.formatSource): 19 * inspector/front-end/WebKit.qrc: 20 * inspector/front-end/parse-js.js: Added. UglifyJS parser. 21 * inspector/front-end/process.js: Added. UglifyJS formatter. 22 * inspector/front-end/scriptFormatterWorker.js: Added. Worker script that wraps UglifyJS code. 23 (onmessage): 24 (beautify): 25 (loadModule): 26 (require): 27 * inspector/front-end/utilities.js: 28 (): 29 1 30 2011-01-19 Pavel Podivilov <podivilov@chromium.org> 2 31 -
trunk/Source/WebCore/WebCore.gypi
r76105 r76132 4679 4679 'inspector/front-end/Script.js', 4680 4680 'inspector/front-end/ScriptFormatter.js', 4681 'inspector/front-end/ScriptFormatterWorker.js', 4681 4682 'inspector/front-end/ScriptsPanel.js', 4682 4683 'inspector/front-end/ScriptView.js', … … 4712 4713 'inspector/front-end/WelcomeView.js', 4713 4714 'inspector/front-end/WorkersSidebarPane.js', 4715 'inspector/front-end/UglifyJS/parse-js.js', 4716 'inspector/front-end/UglifyJS/process.js', 4714 4717 'inspector/front-end/audits.css', 4715 4718 'inspector/front-end/goToLineDialog.css', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r76105 r76132 65602 65602 </File> 65603 65603 <File 65604 RelativePath="..\inspector\front-end\scriptFormatterWorker.js" 65605 > 65606 </File> 65607 <File 65604 65608 RelativePath="..\inspector\front-end\ScriptsPanel.js" 65605 65609 > … … 65735 65739 <File 65736 65740 RelativePath="..\inspector\front-end\WorkersSidebarPane.js" 65741 > 65742 </File> 65743 <File 65744 RelativePath="..\inspector\front-end\UglifyJS\parse-js.js" 65745 > 65746 </File> 65747 <File 65748 RelativePath="..\inspector\front-end\UglifyJS\process.js" 65737 65749 > 65738 65750 </File> -
trunk/Source/WebCore/inspector/front-end/ScriptFormatter.js
r76009 r76132 45 45 { 46 46 var location = {}; 47 location.line = WebInspector.ScriptFormatter.upperBound(lineEndings,position - 1);47 location.line = lineEndings.upperBound(position - 1); 48 48 if (!location.line) 49 49 location.column = position; … … 53 53 } 54 54 55 WebInspector.ScriptFormatter.upperBound = function(array, number) 56 { 57 var first = 0; 58 var count = array.length; 59 while (count > 0) { 60 var step = count >> 1; 61 var middle = first + step; 62 if (number >= array[middle]) { 63 first = middle + 1; 64 count -= step + 1; 65 } else 66 count = step; 67 } 68 return first; 69 } 55 WebInspector.ScriptFormatter.prototype = { 56 format: function(callback) 57 { 58 var worker = new Worker("scriptFormatterWorker.js"); 59 function messageHandler(event) 60 { 61 var formattedSource = event.data; 62 this._formatted = true; 63 this._formattedSource = formattedSource; 64 this._formattedLineEndings = formattedSource.findAll("\n"); 65 this._formattedLineEndings.push(formattedSource.length); 66 this._buildMapping(); 67 callback(formattedSource); 68 } 69 worker.onmessage = messageHandler.bind(this); 70 worker.postMessage(this._originalSource); 71 }, 70 72 71 WebInspector.ScriptFormatter.prototype = { 72 format: function() 73 _buildMapping: function() 73 74 { 74 this._formatted = true;75 this._formattedSource = this._originalSource.replace(/;/g, ";\n");76 this._formattedLineEndings = this._formattedSource.findAll("\n");77 this._formattedLineEndings.push(this._formattedSource.length);78 79 75 this._originalSymbolPositions = []; 80 76 this._formattedSymbolPositions = []; … … 94 90 this._originalSymbolPositions.push(this._originalSource.length); 95 91 this._formattedSymbolPositions.push(this._formattedSource.length); 96 97 return this._formattedSource;98 92 }, 99 93 … … 133 127 _convertPosition: function(symbolPositions1, symbolPositions2, position) 134 128 { 135 var index = WebInspector.ScriptFormatter.upperBound(symbolPositions1,position);129 var index = symbolPositions1.upperBound(position); 136 130 if (index === symbolPositions2.length - 1) 137 131 return symbolPositions2[index] - 1; -
trunk/Source/WebCore/inspector/front-end/SourceFrame.js
r76009 r76132 787 787 return; 788 788 789 this._textModel.setText(null, this._formatter.format()); 790 this._setTextViewerDecorations(); 789 function didFormat(source) 790 { 791 this._textModel.setText(null, source); 792 this._setTextViewerDecorations(); 793 } 794 this._formatter.format(didFormat.bind(this)); 791 795 }, 792 796 -
trunk/Source/WebCore/inspector/front-end/WebKit.qrc
r76105 r76132 82 82 <file>Script.js</file> 83 83 <file>ScriptFormatter.js</file> 84 <file>ScriptFormatterWorker.js</file> 84 85 <file>ScriptsPanel.js</file> 85 86 <file>ScriptView.js</file> … … 115 116 <file>WelcomeView.js</file> 116 117 <file>WorkersSidebarPane.js</file> 118 <file>UglifyJS/parse-js.js</file> 119 <file>UglifyJS/process.js</file> 117 120 <file>audits.css</file> 118 121 <file>goToLineDialog.css</file> -
trunk/Source/WebCore/inspector/front-end/utilities.js
r75795 r76132 746 746 }}); 747 747 748 Object.defineProperty(Array.prototype, "upperBound", { value: function(value) 749 { 750 var first = 0; 751 var count = this.length; 752 while (count > 0) { 753 var step = count >> 1; 754 var middle = first + step; 755 if (value >= this[middle]) { 756 first = middle + 1; 757 count -= step + 1; 758 } else 759 count = step; 760 } 761 return first; 762 }}); 763 748 764 Array.diff = function(left, right) 749 765 {
Note: See TracChangeset
for help on using the changeset viewer.