Changeset 17583 in webkit


Ignore:
Timestamp:
Nov 3, 2006 4:09:46 PM (17 years ago)
Author:
thatcher
Message:

Reviewed by Tim H.

Fixes: http://bugs.webkit.org/show_bug.cgi?id=9596
Bug 9596: [Drosera] add a function popup to the source pane

  • Drosera/debugger.css: Added styles for function popup
  • Drosera/debugger.html: Added function popup button and select
  • Drosera/debugger.js: Added function popup functionality
Location:
trunk/WebKitTools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r17575 r17583  
     12006-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
    1122006-11-03  Michael Emmel  <mike.emmel@gmail.com>
    213
  • trunk/WebKitTools/Drosera/debugger.css

    r16984 r17583  
    103103}
    104104
    105 #files {
     105#files, #functions {
    106106    opacity: 0;
    107107    position: absolute;
     
    130130}
    131131
    132 #filesPopupButtonContent {
     132#filesPopupButtonContent, #functionButtonContent {
    133133    overflow: hidden;
    134134    text-overflow: ellipsis;
  • trunk/WebKitTools/Drosera/debugger.html

    r16984 r17583  
    8282<button id="navFileLeftButton" class="nav left" disabled onclick="navFilePrevious(this)"></button><button id="navFileRightButton" class="nav right" disabled onclick="navFileNext(this)"></button>
    8383<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">&lt;No selected symbol&gt;</span></div></button>
    8485</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>
    8687<div class="footer"></div>
    8788</div>
  • trunk/WebKitTools/Drosera/debugger.js

    r17469 r17583  
    376376}
    377377
     378Element.prototype.removeChildren = function()
     379{
     380    while (this.firstChild)
     381        this.removeChild(this.firstChild);       
     382}
     383
    378384function breakpointAction(event)
    379385{
     
    666672}
    667673
    668 function syntaxHighlight(code)
     674function syntaxHighlight(code, file)
    669675{
    670676    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 };
     
    794800
    795801            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               
    798840                continue;
    799841            }
     
    802844        echoChar(c);
    803845    }
    804 
     846       
    805847    return result;
    806848}
     
    884926}
    885927
     928function 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">&lt;No selected symbol&gt;</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
    886950function loadFile(fileIndex, manageNavLists)
    887951{
     
    905969
    906970        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");
    908972        for( var i = 0; i < lines.length; i++ ) {
    909973            var tr = sourcesDocument.createElement("tr");
     
    922986            table.appendChild(tr);
    923987        }
    924 
     988       
    925989        file.loaded = true;
    926990    }
     
    9371001        }
    9381002    }
    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";
    9401025   
    9411026    if (manageNavLists) {
     
    11031188        file.scripts = new Array();
    11041189        file.breakpoints = new Array();
     1190        file.functionNames = new Array();
    11051191        file.source = (fileSource.length ? fileSource : source);
    11061192        file.url = (url.length ? url : null);
Note: See TracChangeset for help on using the changeset viewer.