Changeset 17583 in webkit
- Timestamp:
- Nov 3, 2006 4:09:46 PM (17 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r17575 r17583 1 2006-11-03 Vladimir Olexa <vladimir.olexa@gmail.com> 2 3 Reviewed by Tim H. 4 5 Fixes: http://bugs.webkit.org/show_bug.cgi?id=9596 6 Bug 9596: [Drosera] add a function popup to the source pane 7 8 * Drosera/debugger.css: Added styles for function popup 9 * Drosera/debugger.html: Added function popup button and select 10 * Drosera/debugger.js: Added function popup functionality 11 1 12 2006-11-03 Michael Emmel <mike.emmel@gmail.com> 2 13 -
trunk/WebKitTools/Drosera/debugger.css
r16984 r17583 103 103 } 104 104 105 #files {105 #files, #functions { 106 106 opacity: 0; 107 107 position: absolute; … … 130 130 } 131 131 132 #filesPopupButtonContent {132 #filesPopupButtonContent, #functionButtonContent { 133 133 overflow: hidden; 134 134 text-overflow: ellipsis; -
trunk/WebKitTools/Drosera/debugger.html
r16984 r17583 82 82 <button id="navFileLeftButton" class="nav left" disabled onclick="navFilePrevious(this)"></button><button id="navFileRightButton" class="nav right" disabled onclick="navFileNext(this)"></button> 83 83 <button class="popup"><select size="1" id="files" onchange="switchFile()"></select><div id="filesPopupButtonContent"><span class="placeholder">no files loaded</span></div></button> 84 <button class="popup" id="functionNamesPopup" style="display: none"><select size="1" id="functions" onchange="switchFunction(this.selectedIndex)"></select><div id="functionPopupButtonContent"><span class="placeholder"><No selected symbol></span></div></button> 84 85 </div> 85 <div id="sourcesContainer"><iframe id="sources" src="viewer.html"></iframe></div>86 <div id="sourcesContainer"><iframe name="sourcesFrame" id="sources" src="viewer.html"></iframe></div> 86 87 <div class="footer"></div> 87 88 </div> -
trunk/WebKitTools/Drosera/debugger.js
r17469 r17583 376 376 } 377 377 378 Element.prototype.removeChildren = function() 379 { 380 while (this.firstChild) 381 this.removeChild(this.firstChild); 382 } 383 378 384 function breakpointAction(event) 379 385 { … … 666 672 } 667 673 668 function syntaxHighlight(code )674 function syntaxHighlight(code, file) 669 675 { 670 676 var keywords = { 'abstract': 1, 'boolean': 1, 'break': 1, 'byte': 1, 'case': 1, 'catch': 1, 'char': 1, 'class': 1, 'const': 1, 'continue': 1, 'debugger': 1, 'default': 1, 'delete': 1, 'do': 1, 'double': 1, 'else': 1, 'enum': 1, 'export': 1, 'extends': 1, 'false': 1, 'final': 1, 'finally': 1, 'float': 1, 'for': 1, 'function': 1, 'goto': 1, 'if': 1, 'implements': 1, 'import': 1, 'in': 1, 'instanceof': 1, 'int': 1, 'interface': 1, 'long': 1, 'native': 1, 'new': 1, 'null': 1, 'package': 1, 'private': 1, 'protected': 1, 'public': 1, 'return': 1, 'short': 1, 'static': 1, 'super': 1, 'switch': 1, 'synchronized': 1, 'this': 1, 'throw': 1, 'throws': 1, 'transient': 1, 'true': 1, 'try': 1, 'typeof': 1, 'var': 1, 'void': 1, 'volatile': 1, 'while': 1, 'with': 1 }; … … 794 800 795 801 if (keywords[keyword]) { 796 result += "<span class=\"keyword\">" + keyword + "</span>"; 797 i += keyword.length - 1; 802 var functionName = ""; 803 if (keyword == "function") { 804 var functionKeywordOffset = 8; 805 var functionNameChar = ""; 806 807 if (code.charAt(i + functionKeywordOffset) == " ") { 808 functionNameChar = code.charAt(i + functionKeywordOffset + 1); 809 functionKeywordOffset++; 810 } else 811 functionNameChar = code.charAt(i + functionKeywordOffset); 812 813 if (functionNameChar == "(") { 814 functionName = "function"; 815 file.functionNames.push(functionName); 816 } else { 817 while (functionNameChar != "(") { 818 functionName += functionNameChar; 819 functionKeywordOffset++; 820 functionNameChar = code.charAt(i + functionKeywordOffset); 821 if ((i + functionKeywordOffset) >= code.length || functionNameChar == " " || functionNameChar == "\n") break; 822 } 823 } 824 } 825 826 var fileIndex = filesLookup[file.url]; 827 828 if (functionName == "function") 829 result += "<span class=\"keyword\"><a name=\"function-" + fileIndex + "-" + file.functionNames.length + "\" id=\"" + fileIndex + "-" + file.functionNames.length + "\">" + keyword + "</a></span>"; 830 else 831 result += "<span class=\"keyword\">" + keyword + "</span>"; 832 833 if (functionName.length > 0 && functionName != "function") { 834 file.functionNames.push(functionName); 835 result += " <a name=\"function-" + fileIndex + "-" + file.functionNames.length + "\" id=\"" + fileIndex + "-" + file.functionNames.length + "\">" + functionName + "</a>"; 836 i += keyword.length + functionName.length; 837 } else 838 i += keyword.length - 1; 839 798 840 continue; 799 841 } … … 802 844 echoChar(c); 803 845 } 804 846 805 847 return result; 806 848 } … … 884 926 } 885 927 928 function switchFunction(index, shouldResetPopup) 929 { 930 if (shouldResetPopup === undefined) shouldResetPopup = false; 931 var sourcesFrame = window.frames['sourcesFrame']; 932 933 if (shouldResetPopup || index == 0) { 934 document.getElementById("functionPopupButtonContent").innerHTML = '<span class="placeholder"><No selected symbol></span>'; 935 return; 936 } 937 938 var functionSelect = document.getElementById("functions"); 939 var selectedFunction = functionSelect.childNodes[index]; 940 var selection = sourcesFrame.getSelection(); 941 var currentFunction = selectedFunction.value; 942 var currentFunctionElement = sourcesFrame.document.getElementById(currentFunction); 943 944 sourcesFrame.focus(); 945 selection.setBaseAndExtent(currentFunctionElement, 0, currentFunctionElement, 1); 946 sourcesFrame.location.hash = "#function-" + selectedFunction.value; 947 document.getElementById("functionPopupButtonContent").innerText = selectedFunction.innerText; 948 } 949 886 950 function loadFile(fileIndex, manageNavLists) 887 951 { … … 905 969 906 970 var normalizedSource = file.source.replace(/\r\n|\r/, "\n"); // normalize line endings 907 var lines = syntaxHighlight(normalizedSource ).split("\n");971 var lines = syntaxHighlight(normalizedSource, file).split("\n"); 908 972 for( var i = 0; i < lines.length; i++ ) { 909 973 var tr = sourcesDocument.createElement("tr"); … … 922 986 table.appendChild(tr); 923 987 } 924 988 925 989 file.loaded = true; 926 990 } … … 937 1001 } 938 1002 } 939 1003 1004 // Populate the function names pop-up 1005 if (file.functionNames.length > 0) { 1006 var functionSelect = document.getElementById("functions"); 1007 var functionOption = document.createElement("option"); 1008 1009 document.getElementById("functionNamesPopup").style.display = "inline"; 1010 switchFunction(0, true); 1011 1012 functionSelect.removeChildren(); 1013 functionOption.value = null; 1014 functionOption.text = "< no selected symbol >"; 1015 functionSelect.appendChild(functionOption); 1016 1017 for (var i = 0; i < file.functionNames.length; i++) { 1018 functionOption = document.createElement("option"); 1019 functionOption.value = fileIndex + "-" + (i+1); 1020 functionOption.text = file.functionNames[i] + "()"; 1021 functionSelect.appendChild(functionOption); 1022 } 1023 } else 1024 document.getElementById("functionNamesPopup").style.display = "none"; 940 1025 941 1026 if (manageNavLists) { … … 1103 1188 file.scripts = new Array(); 1104 1189 file.breakpoints = new Array(); 1190 file.functionNames = new Array(); 1105 1191 file.source = (fileSource.length ? fileSource : source); 1106 1192 file.url = (url.length ? url : null);
Note: See TracChangeset
for help on using the changeset viewer.