Changeset 50755 in webkit
- Timestamp:
- Nov 10, 2009 1:04:04 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r50754 r50755 1 2009-11-10 Keishi Hattori <casey.hattori@gmail.com> 2 3 Reviewed by Timothy Hatcher. 4 5 Web Inspector: Speed up syntax highlighter 6 https://bugs.webkit.org/show_bug.cgi?id=31291 7 8 * inspector/front-end/SourceFrame.js: 9 (WebInspector.SourceFrame.prototype._loaded): 10 (WebInspector.SourceSyntaxHighlighter.prototype.process.moveToNextLine): Replace the line content node. 11 (WebInspector.SourceSyntaxHighlighter.prototype.process): 12 (WebInspector.SourceSyntaxHighlighter.prototype.appendNonToken): 13 (WebInspector.SourceSyntaxHighlighter.prototype.syntaxHighlightNode): 14 (WebInspector.CSSSourceSyntaxHighlighter): 15 (WebInspector.JavaScriptSourceSyntaxHighlighter): 16 1 17 2009-11-09 Jeremy Orlow <jorlow@chromium.org> 2 18 -
trunk/WebCore/inspector/front-end/SourceFrame.js
r50664 r50755 265 265 this.element.contentWindow.Element.prototype.addStyleClass = Element.prototype.addStyleClass; 266 266 this.element.contentWindow.Element.prototype.removeStyleClass = Element.prototype.removeStyleClass; 267 this.element.contentWindow.Element.prototype.removeChildren = Element.prototype.removeChildren; 267 268 this.element.contentWindow.Element.prototype.positionAt = Element.prototype.positionAt; 268 269 this.element.contentWindow.Element.prototype.removeMatchingStyleClasses = Element.prototype.removeMatchingStyleClasses; … … 793 794 var row = rows[this.lineIndex]; 794 795 var line = row ? row.cells[1] : null; 795 if (line && this. lineFragment) {796 Element.prototype.removeChildren.call(line);796 if (line && this.newLine) { 797 line.removeChildren(); 797 798 798 line.appendChild(this.lineFragment);799 799 if (this.messageBubble) 800 line.appendChild(this.messageBubble); 801 this.lineFragment = null; 800 this.newLine.appendChild(this.messageBubble); 801 802 line.parentNode.insertBefore(this.newLine, line); 803 line.parentNode.removeChild(line); 804 805 this.newLine = null; 802 806 } 803 807 this.lineIndex++; … … 817 821 818 822 this.lineCode = line.textContent; 819 this. lineFragment = document.createDocumentFragment();823 this.newLine = line.cloneNode(false); 820 824 this.cursor = 0; 821 825 if (!line) … … 853 857 { 854 858 if (this.nonToken.length > 0) { 855 this. lineFragment.appendChild(document.createTextNode(this.nonToken));859 this.newLine.appendChild(document.createTextNode(this.nonToken)); 856 860 this.nonToken = ""; 857 861 } … … 861 865 { 862 866 this.lineCode = node.textContent; 863 this.lineFragment = document.createDocumentFragment(); 867 node.removeChildren(); 868 this.newLine = node; 864 869 this.cursor = 0; 865 870 while (true) { … … 869 874 this.cursor += codeFragment.length; 870 875 this.appendNonToken(); 871 while (node.firstChild) 872 node.removeChild(node.firstChild); 873 node.appendChild(this.lineFragment); 874 this.lineFragment =null; 876 this.newLine = null; 875 877 return; 876 878 } … … 901 903 this.lineIndex = -1; 902 904 this.lineCode = ""; 903 this. lineFragment= null;905 this.newLine = null; 904 906 this.lexState = this.LexState.Initial; 905 907 this.continueState = this.ContinueState.None; … … 1041 1043 { 1042 1044 this.cursor += token.length; 1043 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-comment"));1045 this.newLine.appendChild(this.createSpan(token, "webkit-css-comment")); 1044 1046 } 1045 1047 … … 1047 1049 { 1048 1050 this.cursor += token.length; 1049 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-comment"));1051 this.newLine.appendChild(this.createSpan(token, "webkit-css-comment")); 1050 1052 this.continueState = this.ContinueState.Comment; 1051 1053 } … … 1054 1056 { 1055 1057 this.cursor += token.length; 1056 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-comment"));1058 this.newLine.appendChild(this.createSpan(token, "webkit-css-comment")); 1057 1059 this.continueState = this.ContinueState.None; 1058 1060 } … … 1061 1063 { 1062 1064 this.cursor += token.length; 1063 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-comment"));1065 this.newLine.appendChild(this.createSpan(token, "webkit-css-comment")); 1064 1066 } 1065 1067 … … 1067 1069 { 1068 1070 this.cursor += token.length; 1069 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-selector"));1071 this.newLine.appendChild(this.createSpan(token, "webkit-css-selector")); 1070 1072 } 1071 1073 … … 1331 1333 if (token in propertyKeywords) { 1332 1334 this.appendNonToken.call(this); 1333 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-property"));1335 this.newLine.appendChild(this.createSpan(token, "webkit-css-property")); 1334 1336 } else 1335 1337 this.nonToken += token; … … 1731 1733 if (token in valueKeywords) { 1732 1734 this.appendNonToken.call(this); 1733 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-keyword"));1735 this.newLine.appendChild(this.createSpan(token, "webkit-css-keyword")); 1734 1736 } else 1735 1737 this.nonToken += token; … … 1739 1741 { 1740 1742 this.cursor += token.length; 1741 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-number"));1743 this.newLine.appendChild(this.createSpan(token, "webkit-css-number")); 1742 1744 } 1743 1745 … … 1752 1754 { 1753 1755 this.cursor += token.length; 1754 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-url"));1756 this.newLine.appendChild(this.createSpan(token, "webkit-css-url")); 1755 1757 } 1756 1758 … … 1758 1760 { 1759 1761 this.cursor += token.length; 1760 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-string"));1762 this.newLine.appendChild(this.createSpan(token, "webkit-css-string")); 1761 1763 } 1762 1764 … … 1764 1766 { 1765 1767 this.cursor += token.length; 1766 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-color"));1768 this.newLine.appendChild(this.createSpan(token, "webkit-css-color")); 1767 1769 } 1768 1770 … … 1770 1772 { 1771 1773 this.cursor += token.length; 1772 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-important"));1774 this.newLine.appendChild(this.createSpan(token, "webkit-css-important")); 1773 1775 } 1774 1776 … … 1776 1778 { 1777 1779 this.cursor += token.length; 1778 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-at-rule"));1780 this.newLine.appendChild(this.createSpan(token, "webkit-css-at-rule")); 1779 1781 this.lexState = this.LexState.AtMedia; 1780 1782 } … … 1790 1792 { 1791 1793 this.cursor += token.length; 1792 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-at-rule"));1794 this.newLine.appendChild(this.createSpan(token, "webkit-css-at-rule")); 1793 1795 this.lexState = this.LexState.AtKeyframes; 1794 1796 } … … 1803 1805 function atRuleAction(token) { 1804 1806 this.cursor += token.length; 1805 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-at-rule"));1807 this.newLine.appendChild(this.createSpan(token, "webkit-css-at-rule")); 1806 1808 this.lexState = this.LexState.AtRule; 1807 1809 } … … 1827 1829 else { 1828 1830 this.appendNonToken.call(this); 1829 this. lineFragment.appendChild(this.createSpan(token, "webkit-css-keyword"));1831 this.newLine.appendChild(this.createSpan(token, "webkit-css-keyword")); 1830 1832 } 1831 1833 } … … 1853 1855 this.lineIndex = -1; 1854 1856 this.lineCode = ""; 1855 this. lineFragment= null;1857 this.newLine = null; 1856 1858 this.lexState = this.LexState.Initial; 1857 1859 this.continueState = this.ContinueState.None; … … 1904 1906 }, { 1905 1907 pattern: /^(?:(?:[a-zA-Z]|[$_]|\\(?:u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]))(?:(?:[a-zA-Z]|[$_]|\\(?:u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]))|[0-9])*)/, 1906 action: identOrKeywordAction, 1907 dontAppendNonToken: true 1908 action: identOrKeywordAction 1908 1909 }, { 1909 1910 pattern: /^\)/, … … 1938 1939 { 1939 1940 this.cursor += token.length; 1940 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-comment"));1941 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-comment")); 1941 1942 } 1942 1943 … … 1944 1945 { 1945 1946 this.cursor += token.length; 1946 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-comment"));1947 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-comment")); 1947 1948 } 1948 1949 … … 1950 1951 { 1951 1952 this.cursor += token.length; 1952 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-comment"));1953 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-comment")); 1953 1954 this.continueState = this.ContinueState.Comment; 1954 1955 } … … 1957 1958 { 1958 1959 this.cursor += token.length; 1959 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-comment"));1960 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-comment")); 1960 1961 this.continueState = this.ContinueState.None; 1961 1962 } … … 1964 1965 { 1965 1966 this.cursor += token.length; 1966 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-comment"));1967 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-comment")); 1967 1968 } 1968 1969 … … 1970 1971 { 1971 1972 this.cursor += token.length; 1972 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-number"));1973 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-number")); 1973 1974 this.lexState = this.LexState.DivisionAllowed; 1974 1975 } … … 1977 1978 { 1978 1979 this.cursor += token.length; 1979 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-string"));1980 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-string")); 1980 1981 this.lexState = this.LexState.Initial; 1981 1982 } … … 1984 1985 { 1985 1986 this.cursor += token.length; 1986 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-string"));1987 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-string")); 1987 1988 this.continueState = this.ContinueState.SingleQuoteString; 1988 1989 } … … 1991 1992 { 1992 1993 this.cursor += token.length; 1993 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-string"));1994 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-string")); 1994 1995 this.continueState = this.ContinueState.None; 1995 1996 } … … 1998 1999 { 1999 2000 this.cursor += token.length; 2000 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-string"));2001 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-string")); 2001 2002 } 2002 2003 … … 2004 2005 { 2005 2006 this.cursor += token.length; 2006 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-string"));2007 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-string")); 2007 2008 this.continueState = this.ContinueState.DoubleQuoteString; 2008 2009 } … … 2011 2012 { 2012 2013 this.cursor += token.length; 2013 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-string"));2014 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-string")); 2014 2015 this.continueState = this.ContinueState.None; 2015 2016 } … … 2018 2019 { 2019 2020 this.cursor += token.length; 2020 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-string"));2021 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-string")); 2021 2022 } 2022 2023 … … 2024 2025 { 2025 2026 this.cursor += token.length; 2026 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-regexp"));2027 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-regexp")); 2027 2028 this.lexState = this.LexState.Initial; 2028 2029 } … … 2031 2032 { 2032 2033 this.cursor += token.length; 2033 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-regexp"));2034 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-regexp")); 2034 2035 this.continueState = this.ContinueState.RegExp; 2035 2036 } … … 2038 2039 { 2039 2040 this.cursor += token.length; 2040 this. lineFragment.appendChild(this.createSpan(token, "webkit-javascript-regexp"));2041 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-regexp")); 2041 2042 this.continueState = this.ContinueState.None; 2042 2043 } … … 2045 2046 { 2046 2047 this.cursor += token.length; 2047 this.lineFragment.appendChild(this.createSpan(token, "webkit-javascript-regexp")); 2048 } 2049 2048 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-regexp")); 2049 } 2050 2051 const keywords = { 2052 "null": true, 2053 "true": true, 2054 "false": true, 2055 "break": true, 2056 "case": true, 2057 "catch": true, 2058 "const": true, 2059 "default": true, 2060 "finally": true, 2061 "for": true, 2062 "instanceof": true, 2063 "new": true, 2064 "var": true, 2065 "continue": true, 2066 "function": true, 2067 "return": true, 2068 "void": true, 2069 "delete": true, 2070 "if": true, 2071 "this": true, 2072 "do": true, 2073 "while": true, 2074 "else": true, 2075 "in": true, 2076 "switch": true, 2077 "throw": true, 2078 "try": true, 2079 "typeof": true, 2080 "debugger": true, 2081 "class": true, 2082 "enum": true, 2083 "export": true, 2084 "extends": true, 2085 "import": true, 2086 "super": true, 2087 "get": true, 2088 "set": true 2089 }; 2050 2090 function identOrKeywordAction(token) 2051 2091 { 2052 const keywords = ["null", "true", "false", "break", "case", "catch", "const", "default", "finally", "for", "instanceof", "new", "var", "continue", "function", "return", "void", "delete", "if", "this", "do", "while", "else", "in", "switch", "throw", "try", "typeof", "with", "debugger", "class", "enum", "export", "extends", "import", "super", "get", "set"]; 2053 this.cursor += token.length; 2054 if (keywords.indexOf(token) === -1) { 2055 this.appendNonToken(); 2092 this.cursor += token.length; 2093 2094 if (token in keywords) { 2095 this.newLine.appendChild(this.createSpan(token, "webkit-javascript-keyword")); 2096 this.lexState = this.LexState.Initial; 2097 } else { 2056 2098 var identElement = this.createSpan(token, "webkit-javascript-ident"); 2057 2099 identElement.addEventListener("mouseover", showDatatip, false); 2058 this. lineFragment.appendChild(identElement);2100 this.newLine.appendChild(identElement); 2059 2101 this.lexState = this.LexState.DivisionAllowed; 2060 } else {2061 this.appendNonToken();2062 this.lineFragment.appendChild(this.createSpan(token, "webkit-javascript-keyword"));2063 this.lexState = this.LexState.Initial;2064 2102 } 2065 2103 }
Note: See TracChangeset
for help on using the changeset viewer.