diff options
Diffstat (limited to 'WebCore/inspector/front-end')
18 files changed, 678 insertions, 586 deletions
diff --git a/WebCore/inspector/front-end/ElementsTreeOutline.js b/WebCore/inspector/front-end/ElementsTreeOutline.js index d38a7bb..8d8d5db 100644 --- a/WebCore/inspector/front-end/ElementsTreeOutline.js +++ b/WebCore/inspector/front-end/ElementsTreeOutline.js @@ -898,29 +898,18 @@ WebInspector.ElementsTreeElement.prototype = { if (!hrefValue || hrefValue.indexOf("://") > 0) return hrefValue; - var match; - var documentURL; for (var frameOwnerCandidate = node; frameOwnerCandidate; frameOwnerCandidate = frameOwnerCandidate.parentNode) { if (frameOwnerCandidate.documentURL) { - documentURL = frameOwnerCandidate.documentURL; + var result = WebInspector.completeURL(frameOwnerCandidate.documentURL, hrefValue); + if (result) + return result; break; } } - if (documentURL) { - match = documentURL.match(WebInspector.URLRegExp); - if (match) { - var path = hrefValue; - if (path.charAt(0) !== "/") { - var documentPath = match[4] || "/"; - path = documentPath.substring(0, documentPath.lastIndexOf("/")) + "/" + path; - } - return match[1] + "://" + match[2] + (match[3] ? (":" + match[3]) : "") + path; - } - } // documentURL not found or has bad value for (var url in WebInspector.resourceURLMap) { - match = url.match(WebInspector.URLRegExp); + var match = url.match(WebInspector.URLRegExp); if (match && match[4] === hrefValue) return url; } diff --git a/WebCore/inspector/front-end/InjectedScript.js b/WebCore/inspector/front-end/InjectedScript.js index 9389117..337628f 100644 --- a/WebCore/inspector/front-end/InjectedScript.js +++ b/WebCore/inspector/front-end/InjectedScript.js @@ -923,7 +923,7 @@ InjectedScript.openInInspectedWindow = function(url) return true; } -InjectedScript.getCallFrames = function() +InjectedScript.callFrames = function() { var callFrame = InjectedScriptHost.currentCallFrame(); if (!callFrame) diff --git a/WebCore/inspector/front-end/InspectorBackendStub.js b/WebCore/inspector/front-end/InspectorBackendStub.js index 5ddb74a..ed03f73 100644 --- a/WebCore/inspector/front-end/InspectorBackendStub.js +++ b/WebCore/inspector/front-end/InspectorBackendStub.js @@ -46,17 +46,6 @@ WebInspector.InspectorBackendStub.prototype = { return func; }, - platform: function() - { - return "mac-leopard"; - }, - - port: function() - { - return "unknown"; - }, - - closeWindow: function() { this._windowVisible = false; diff --git a/WebCore/inspector/front-end/InspectorFrontendHostStub.js b/WebCore/inspector/front-end/InspectorFrontendHostStub.js index dc7da61..f1decb6 100644 --- a/WebCore/inspector/front-end/InspectorFrontendHostStub.js +++ b/WebCore/inspector/front-end/InspectorFrontendHostStub.js @@ -35,10 +35,12 @@ WebInspector.InspectorFrontendHostStub = function() this._attachedWindowHeight = 0; } +WebInspector._platformFlavor = WebInspector.PlatformFlavor.MacLeopard; + WebInspector.InspectorFrontendHostStub.prototype = { platform: function() { - return "mac-leopard"; + return "mac"; }, port: function() diff --git a/WebCore/inspector/front-end/NativeTextViewer.js b/WebCore/inspector/front-end/NativeTextViewer.js index 53b213d..5e7db27 100644 --- a/WebCore/inspector/front-end/NativeTextViewer.js +++ b/WebCore/inspector/front-end/NativeTextViewer.js @@ -28,13 +28,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -WebInspector.NativeTextViewer = function(textModel, platform) +WebInspector.NativeTextViewer = function(textModel, platform, url) { WebInspector.TextEditor.call(this, textModel, platform); - this._sheet.className = "monospace"; this._sheet.tabIndex = 0; this._canvas.style.zIndex = 0; this._createLineDivs(); + this._url = url; + this._selectionColor = "rgb(241, 234, 0)"; } WebInspector.NativeTextViewer.prototype = { @@ -52,9 +53,13 @@ WebInspector.NativeTextViewer.prototype = { for (var i = 0; i < this._textModel.linesCount; ++i) { var lineDiv = document.createElement("div"); lineDiv.className = "native-text-editor-line"; - lineDiv.textContent = this._textModel.line(i); + var text = this._textModel.line(i); + lineDiv.textContent = text; + if (!text) + lineDiv.style.minHeight = this._textLineHeight + "px"; this._sheet.appendChild(lineDiv); this._textModel.setAttribute(i, "line-div", lineDiv); + this._textModel.removeAttribute(i, "div-highlighted"); } this._container.appendChild(this._sheet); }, @@ -68,7 +73,7 @@ WebInspector.NativeTextViewer.prototype = { var newLineNumberDigits = this._decimalDigits(this._textModel.linesCount); this._lineNumberWidth = (newLineNumberDigits + 2) * this._digitWidth; - this._sheet.style.paddingLeft = this._textWidth + this._lineNumberWidth + "px"; + this._container.style.left = this._lineNumberWidth + "px"; this._lineNumberDigits = newLineNumberDigits; this.repaintAll(); @@ -86,7 +91,8 @@ WebInspector.NativeTextViewer.prototype = { _registerMouseListeners: function() { - this._sheet.addEventListener("mousedown", this._mouseDown.bind(this), false); + this.element.addEventListener("contextmenu", this._contextMenu.bind(this), false); + this.element.addEventListener("mousedown", this._mouseDown.bind(this), false); }, _registerKeyboardListeners: function() @@ -99,44 +105,48 @@ WebInspector.NativeTextViewer.prototype = { // Noop - let browser take care of this. }, - _paintSelection: function() + _positionDivDecoration: function() { - // Noop - let browser take care of this. + // Div decorations have fixed positions in our case. }, - _positionDivDecoration: function() + _registerShortcuts: function() { - // Div decorations have fixed positions in our case. + // Noop. }, _mouseDown: function(e) { - if (e.offsetX + e.target.offsetTop >= this._lineNumberWidth && this._lineNumberDecorator) - return; - - if (e.button === 2 || (this._isMac && e.ctrlKey)) + if (e.target !== this.element || e.button === 2 || (this._isMac && e.ctrlKey)) return; - - var location = this._caretForMouseEvent(e); - this._lineNumberDecorator.mouseDown(location.line, e); + this._lineNumberDecorator.mouseDown(this._lineForMouseEvent(e), e); }, _contextMenu: function(e) { - // Override editor's implementation to add the line's offsets. - if (e.offsetX + e.target.offsetTop >= this._lineNumberWidth && this._lineNumberDecorator) + if (e.target !== this.element) return; + this._lineNumberDecorator.contextMenu(this._lineForMouseEvent(e), e); + }, - var location = this._caretForMouseEvent(e); - this._lineNumberDecorator.contextMenu(location.line, e); + _lineForMouseEvent: function(e) + { + return Math.max(0, this._offsetToLine(e.offsetY + this._scrollTop) - 1); }, - _caretForMouseEvent: function(e) + _lineHeight: function(lineNumber) { - // Override editor's implementation to add the line's offsets. - var lineNumber = Math.max(0, this._offsetToLine(e.offsetY + e.target.offsetTop) - 1); - var offset = e.offsetX + e.target.offsetLeft + this._scrollLeft - this._lineNumberWidth; - return { line: lineNumber, column: this._columnForOffset(lineNumber, offset) }; + // Use cached value first. + if (this._lineOffsetsCache[lineNumber + 1]) + return this._lineOffsetsCache[lineNumber + 1] - this._lineOffsetsCache[lineNumber]; + + // Get metrics from the browser. + var element = this._textModel.getAttribute(lineNumber, "line-div"); + if (lineNumber + 1 < this._textModel.linesCount) { + var nextElement = this._textModel.getAttribute(lineNumber + 1, "line-div"); + return nextElement.offsetTop - element.offsetTop; + } + return element.parentElement.offsetHeight - element.offsetTop; }, _paintLine: function(lineNumber, lineOffset) @@ -181,12 +191,41 @@ WebInspector.NativeTextViewer.prototype = { _createSpan: function(content, className) { + if (className === "html-resource-link" || className === "html-external-link") + return this._createLink(content, className === "html-external-link"); + var span = document.createElement("span"); span.className = "webkit-" + className; span.appendChild(document.createTextNode(content)); return span; }, + _createLink: function(content, isExternal) + { + var quote = content.charAt(0); + if (content.length > 1 && (quote === "\"" || quote === "'")) + content = content.substring(1, content.length - 1); + else + quote = null; + + var a = WebInspector.linkifyURLAsNode(this._rewriteHref(content), content, null, isExternal); + var span = document.createElement("span"); + span.className = "webkit-html-attribute-value"; + if (quote) + span.appendChild(document.createTextNode(quote)); + span.appendChild(a); + if (quote) + span.appendChild(document.createTextNode(quote)); + return span; + }, + + _rewriteHref: function(hrefValue, isExternal) + { + if (!this._url || !hrefValue || hrefValue.indexOf("://") > 0) + return hrefValue; + return WebInspector.completeURL(this._url, hrefValue); + }, + setDivDecoration: function(lineNumber, element) { var existingElement = this._textModel.getAttribute(lineNumber, "div-decoration"); @@ -203,6 +242,16 @@ WebInspector.NativeTextViewer.prototype = { this._textModel.setAttribute(lineNumber, "div-decoration", element); } this.revalidateDecorationsAndPaint(); + }, + + initFontMetrics: function() + { + WebInspector.TextEditor.prototype.initFontMetrics.call(this); + for (var i = 0; i < this._textModel.linesCount; ++i) { + var lineDiv = this._textModel.getAttribute(i, "line-div"); + if (!this._textModel.line(i)) + lineDiv.style.minHeight = this._textLineHeight + "px"; + } } } diff --git a/WebCore/inspector/front-end/ResourceView.js b/WebCore/inspector/front-end/ResourceView.js index 334847e..b7b01ac 100644 --- a/WebCore/inspector/front-end/ResourceView.js +++ b/WebCore/inspector/front-end/ResourceView.js @@ -183,6 +183,8 @@ WebInspector.ResourceView.prototype = { this.headersElement.addStyleClass("hidden"); if ("resize" in this) this.resize(); + if ("contentTabSelected" in this) + this.contentTabSelected(); }, _refreshURL: function() diff --git a/WebCore/inspector/front-end/ResourcesPanel.js b/WebCore/inspector/front-end/ResourcesPanel.js index e0c5521..40a380c 100644 --- a/WebCore/inspector/front-end/ResourcesPanel.js +++ b/WebCore/inspector/front-end/ResourcesPanel.js @@ -429,7 +429,7 @@ WebInspector.ResourcesPanel.prototype = { return; var newView = this._createResourceView(resource); - if (newView.prototype === resource._resourcesView.prototype) + if (newView.__proto__ === resource._resourcesView.__proto__) return; resource.warnings = 0; @@ -439,6 +439,7 @@ WebInspector.ResourcesPanel.prototype = { resource._itemsTreeElement.updateErrorsAndWarnings(); var oldView = resource._resourcesView; + var oldViewParentNode = oldView.visible ? oldView.element.parentNode : null; resource._resourcesView.detach(); delete resource._resourcesView; @@ -447,8 +448,8 @@ WebInspector.ResourcesPanel.prototype = { newView.headersVisible = oldView.headersVisible; - if (oldView.visible && oldView.element.parentNode) - newView.show(oldView.element.parentNode); + if (oldViewParentNode) + newView.show(oldViewParentNode); }, canShowSourceLineForURL: function(url) diff --git a/WebCore/inspector/front-end/Settings.js b/WebCore/inspector/front-end/Settings.js index 1838068..bc0daa5 100644 --- a/WebCore/inspector/front-end/Settings.js +++ b/WebCore/inspector/front-end/Settings.js @@ -39,7 +39,7 @@ var Preferences = { showMissingLocalizedStrings: false, samplingCPUProfiler: false, showColorNicknames: true, - useCanvasBasedEditor: true + useCanvasBasedEditor: false } WebInspector.populateFrontendSettings = function(settingsString) diff --git a/WebCore/inspector/front-end/SourceFrame.js b/WebCore/inspector/front-end/SourceFrame.js index 1e1bd0c..e30dbdb 100644 --- a/WebCore/inspector/front-end/SourceFrame.js +++ b/WebCore/inspector/front-end/SourceFrame.js @@ -123,11 +123,12 @@ WebInspector.SourceFrame.prototype = { this._editor.revalidateDecorationsAndPaint(); }, - setContent: function(mimeType, content) + setContent: function(mimeType, content, url) { this._loaded = true; this._textModel.setText(null, content); this._mimeType = mimeType; + this._url = url; this._createEditorIfNeeded(); }, @@ -137,13 +138,14 @@ WebInspector.SourceFrame.prototype = { return; var editorConstructor = Preferences.useCanvasBasedEditor ? WebInspector.TextEditor : WebInspector.NativeTextViewer; - this._editor = new editorConstructor(this._textModel, WebInspector.platform); + this._editor = new editorConstructor(this._textModel, WebInspector.platform, this._url); this._editor.lineNumberDecorator = new WebInspector.BreakpointLineNumberDecorator(this, this._editor.textModel); this._editor.lineDecorator = new WebInspector.ExecutionLineDecorator(this); this._editor.readOnly = true; this._element = this._editor.element; this._element.addEventListener("keydown", this._keyDown.bind(this), true); this._parentElement.appendChild(this._element); + this._editor.initFontMetrics(); this._editor.mimeType = this._mimeType; diff --git a/WebCore/inspector/front-end/SourceHTMLTokenizer.js b/WebCore/inspector/front-end/SourceHTMLTokenizer.js index 1212ffe..8856ff5 100644 --- a/WebCore/inspector/front-end/SourceHTMLTokenizer.js +++ b/WebCore/inspector/front-end/SourceHTMLTokenizer.js @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Thu Jan 28 20:49:22 2010 */ +/* Generated by re2c 0.13.5 on Tue Feb 2 00:44:38 2010 */ /* * Copyright (C) 2009 Google Inc. All rights reserved. * @@ -45,72 +45,81 @@ WebInspector.SourceHTMLTokenizer = function() { WebInspector.SourceTokenizer.call(this); + // The order is determined by the generated code. this._lexConditions = { INITIAL: 0, COMMENT: 1, - DSTRING: 2, - SSTRING: 3 + DOCTYPE: 2, + TAG: 3, + DSTRING: 4, + SSTRING: 5 }; + this.case_INITIAL = 1000; + this.case_COMMENT = 1001; + this.case_DOCTYPE = 1002; + this.case_TAG = 1003; + this.case_DSTRING = 1004; + this.case_SSTRING = 1005; this._parseConditions = { INITIAL: 0, - TAG: 1, - ATTRIBUTE: 2, - ATTRIBUTE_VALUE: 3, - SCRIPT: 4, - SCRIPT_ATTRIBUTE: 5, - SCRIPT_ATTRIBUTE_VALUE: 6, - DOCTYPE: 7 + ATTRIBUTE: 1, + ATTRIBUTE_VALUE: 2, + LINKIFY: 4, + A_NODE: 8, + SCRIPT: 16 }; - this.case_INITIAL = 1000; - this.case_COMMENT = 1001; - this.case_DSTRING = 1002; - this.case_SSTRING = 1003; - this.initialCondition = { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL }; } WebInspector.SourceHTMLTokenizer.prototype = { - _isAttribute: function() + _isExpectingAttribute: function() { - return this._parseCondition === this._parseConditions.ATTRIBUTE || this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE; + return this._parseCondition & this._parseConditions.ATTRIBUTE; }, - _isAttributeValue: function() + _isExpectingAttributeValue: function() { - return this._parseCondition === this._parseConditions.ATTRIBUTE_VALUE || this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE_VALUE; + return this._parseCondition & this._parseConditions.ATTRIBUTE_VALUE; }, - _setAttributeValue: function() + _setExpectingAttribute: function() { - if (this._parseCondition === this._parseConditions.ATTRIBUTE) - this._parseCondition = this._parseConditions.ATTRIBUTE_VALUE; - else if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE) - this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE_VALUE; + if (this._isExpectingAttributeValue()) + this._parseCondition ^= this._parseConditions.ATTRIBUTE_VALUE; + this._parseCondition |= this._parseConditions.ATTRIBUTE; }, - _setAttribute: function() + _setExpectingAttributeValue: function() { - if (this._parseCondition === this._parseConditions.ATTRIBUTE_VALUE) - this._parseCondition = this._parseConditions.ATTRIBUTE; - else if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE_VALUE) - this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE; + if (this._isExpectingAttribute()) + this._parseCondition ^= this._parseConditions.ATTRIBUTE; + this._parseCondition |= this._parseConditions.ATTRIBUTE_VALUE; }, _stringToken: function(cursor, stringEnds) { - if (this._isAttributeValue()) { - this.tokenType = "html-attr-value"; - if (stringEnds) - this._setAttribute(); - } else if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; - else + if (!this._isExpectingAttributeValue()) { this.tokenType = null; + return cursor; + } + this.tokenType = this._attrValueTokenType(); + if (stringEnds) + this._setExpectingAttribute(); return cursor; }, + _attrValueTokenType: function() + { + if (this._parseCondition & this._parseConditions.LINKIFY) { + if (this._parseCondition & this._parseConditions.A_NODE) + return "html-external-link"; + return "html-resource-link"; + } + return "html-attribute-value"; + }, + nextToken: function(cursor) { var cursorOnEnter = cursor; @@ -122,17 +131,25 @@ WebInspector.SourceHTMLTokenizer.prototype = { { case 1: var yych; var yyaccept = 0; - if (this.getLexCondition() < 2) { + if (this.getLexCondition() < 3) { if (this.getLexCondition() < 1) { { gotoCase = this.case_INITIAL; continue; }; } else { - { gotoCase = this.case_COMMENT; continue; }; + if (this.getLexCondition() < 2) { + { gotoCase = this.case_COMMENT; continue; }; + } else { + { gotoCase = this.case_DOCTYPE; continue; }; + } } } else { - if (this.getLexCondition() < 3) { - { gotoCase = this.case_DSTRING; continue; }; + if (this.getLexCondition() < 4) { + { gotoCase = this.case_TAG; continue; }; } else { - { gotoCase = this.case_SSTRING; continue; }; + if (this.getLexCondition() < 5) { + { gotoCase = this.case_DSTRING; continue; }; + } else { + { gotoCase = this.case_SSTRING; continue; }; + } } } /* *********************************** */ @@ -193,393 +210,438 @@ case 12: { gotoCase = 5; continue; }; } /* *********************************** */ -case this.case_DSTRING: +case this.case_DOCTYPE: yych = this._charAt(cursor); if (yych <= '\f') { if (yych == '\n') { gotoCase = 18; continue; }; { gotoCase = 17; continue; }; } else { if (yych <= '\r') { gotoCase = 18; continue; }; - if (yych == '"') { gotoCase = 20; continue; }; + if (yych == '>') { gotoCase = 20; continue; }; { gotoCase = 17; continue; }; } case 16: - { return this._stringToken(cursor); } + { this.tokenType = "html-doctype"; return cursor; } case 17: yych = this._charAt(++cursor); - { gotoCase = 24; continue; }; + { gotoCase = 23; continue; }; case 18: ++cursor; { this.tokenType = null; return cursor; } case 20: ++cursor; -case 21: this.setLexCondition(this._lexConditions.INITIAL); - { return this._stringToken(cursor, true); } + { this.tokenType = "html-doctype"; return cursor; } case 22: - yych = this._charAt(++cursor); - { gotoCase = 21; continue; }; -case 23: ++cursor; yych = this._charAt(cursor); -case 24: +case 23: if (yych <= '\f') { if (yych == '\n') { gotoCase = 16; continue; }; - { gotoCase = 23; continue; }; + { gotoCase = 22; continue; }; } else { if (yych <= '\r') { gotoCase = 16; continue; }; - if (yych == '"') { gotoCase = 22; continue; }; - { gotoCase = 23; continue; }; + if (yych == '>') { gotoCase = 16; continue; }; + { gotoCase = 22; continue; }; } /* *********************************** */ -case this.case_INITIAL: +case this.case_DSTRING: yych = this._charAt(cursor); - if (yych <= '=') { - if (yych <= '\'') { - if (yych == '"') { gotoCase = 29; continue; }; - if (yych >= '\'') { gotoCase = 30; continue; }; - } else { - if (yych <= '9') { - if (yych >= '0') { gotoCase = 31; continue; }; - } else { - if (yych <= ';') { gotoCase = 27; continue; }; - if (yych <= '<') { gotoCase = 33; continue; }; - { gotoCase = 35; continue; }; - } - } + if (yych <= '\f') { + if (yych == '\n') { gotoCase = 28; continue; }; + { gotoCase = 27; continue; }; } else { - if (yych <= '^') { - if (yych <= '>') { gotoCase = 37; continue; }; - if (yych <= '@') { gotoCase = 27; continue; }; - if (yych <= 'Z') { gotoCase = 31; continue; }; - } else { - if (yych <= '`') { - if (yych <= '_') { gotoCase = 31; continue; }; - } else { - if (yych <= 'z') { gotoCase = 31; continue; }; - if (yych >= 0x80) { gotoCase = 31; continue; }; - } - } + if (yych <= '\r') { gotoCase = 28; continue; }; + if (yych == '"') { gotoCase = 30; continue; }; + { gotoCase = 27; continue; }; } +case 26: + { return this._stringToken(cursor); } case 27: - ++cursor; + yych = this._charAt(++cursor); + { gotoCase = 34; continue; }; case 28: + ++cursor; { this.tokenType = null; return cursor; } -case 29: - yyaccept = 0; - yych = this._charAt(YYMARKER = ++cursor); - { gotoCase = 82; continue; }; case 30: - yyaccept = 0; - yych = this._charAt(YYMARKER = ++cursor); - { gotoCase = 76; continue; }; -case 31: ++cursor; - yych = this._charAt(cursor); - { gotoCase = 74; continue; }; +case 31: + this.setLexCondition(this._lexConditions.TAG); + { return this._stringToken(cursor, true); } case 32: - { - if (this._parseCondition === this._parseConditions.SCRIPT) { - this.tokenType = null; - return cursor; - } - - if (this._parseCondition === this._parseConditions.TAG) { - this.tokenType = "html-tag"; - this._parseCondition = this._parseConditions.ATTRIBUTE; - } else if (this._isAttribute()) - this.tokenType = "html-attr-name"; - else if (this._isAttributeValue()) - this.tokenType = "html-attr-value"; - else if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; - else - this.tokenType = null; - return cursor; - } + yych = this._charAt(++cursor); + { gotoCase = 31; continue; }; case 33: - yyaccept = 1; + ++cursor; + yych = this._charAt(cursor); +case 34: + if (yych <= '\f') { + if (yych == '\n') { gotoCase = 26; continue; }; + { gotoCase = 33; continue; }; + } else { + if (yych <= '\r') { gotoCase = 26; continue; }; + if (yych == '"') { gotoCase = 32; continue; }; + { gotoCase = 33; continue; }; + } +/* *********************************** */ +case this.case_INITIAL: + yych = this._charAt(cursor); + if (yych == '<') { gotoCase = 39; continue; }; + ++cursor; + { this.tokenType = null; return cursor; } +case 39: + yyaccept = 0; yych = this._charAt(YYMARKER = ++cursor); if (yych <= '/') { - if (yych == '!') { gotoCase = 42; continue; }; - if (yych >= '/') { gotoCase = 39; continue; }; + if (yych == '!') { gotoCase = 44; continue; }; + if (yych >= '/') { gotoCase = 41; continue; }; } else { if (yych <= 'S') { - if (yych >= 'S') { gotoCase = 40; continue; }; + if (yych >= 'S') { gotoCase = 42; continue; }; } else { - if (yych == 's') { gotoCase = 40; continue; }; + if (yych == 's') { gotoCase = 42; continue; }; } } -case 34: +case 40: + this.setLexCondition(this._lexConditions.TAG); { - if (this._parseCondition === this._parseConditions.SCRIPT) { + if (this._parseCondition & this._parseConditions.SCRIPT) { + // Do not tokenize script tag contents, keep lexer state although processing "<". + this.setLexCondition(this._lexConditions.INITIAL); this.tokenType = null; return cursor; } + this._parseCondition = this._parseConditions.INITIAL; this.tokenType = "html-tag"; - this._parseCondition = this._parseConditions.TAG; - return cursor; - } -case 35: - ++cursor; - { - if (this._isAttribute()) { - this.tokenType = null; - this._setAttributeValue(); - } else if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; - else - this.tokenType = null; - return cursor; - } -case 37: - ++cursor; - { - if (this._parseCondition === this._parseConditions.SCRIPT) { - this.tokenType = null; - return cursor; - } - - if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; - else - this.tokenType = "html-tag"; - - if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE) - this._parseCondition = this._parseConditions.SCRIPT; - else - this._parseCondition = this._parseConditions.INITIAL; return cursor; } -case 39: - yyaccept = 1; +case 41: + yyaccept = 0; yych = this._charAt(YYMARKER = ++cursor); - if (yych == 'S') { gotoCase = 66; continue; }; - if (yych == 's') { gotoCase = 66; continue; }; - { gotoCase = 34; continue; }; -case 40: + if (yych == 'S') { gotoCase = 68; continue; }; + if (yych == 's') { gotoCase = 68; continue; }; + { gotoCase = 40; continue; }; +case 42: yych = this._charAt(++cursor); - if (yych == 'C') { gotoCase = 60; continue; }; - if (yych == 'c') { gotoCase = 60; continue; }; -case 41: + if (yych == 'C') { gotoCase = 62; continue; }; + if (yych == 'c') { gotoCase = 62; continue; }; +case 43: cursor = YYMARKER; - if (yyaccept <= 0) { - { gotoCase = 28; continue; }; - } else { - { gotoCase = 34; continue; }; - } -case 42: + { gotoCase = 40; continue; }; +case 44: yych = this._charAt(++cursor); if (yych <= 'C') { - if (yych != '-') { gotoCase = 41; continue; }; + if (yych != '-') { gotoCase = 43; continue; }; } else { - if (yych <= 'D') { gotoCase = 44; continue; }; - if (yych == 'd') { gotoCase = 44; continue; }; - { gotoCase = 41; continue; }; + if (yych <= 'D') { gotoCase = 46; continue; }; + if (yych == 'd') { gotoCase = 46; continue; }; + { gotoCase = 43; continue; }; } yych = this._charAt(++cursor); - if (yych == '-') { gotoCase = 52; continue; }; - { gotoCase = 41; continue; }; -case 44: - yych = this._charAt(++cursor); - if (yych == 'O') { gotoCase = 45; continue; }; - if (yych != 'o') { gotoCase = 41; continue; }; -case 45: - yych = this._charAt(++cursor); - if (yych == 'C') { gotoCase = 46; continue; }; - if (yych != 'c') { gotoCase = 41; continue; }; + if (yych == '-') { gotoCase = 54; continue; }; + { gotoCase = 43; continue; }; case 46: yych = this._charAt(++cursor); - if (yych == 'T') { gotoCase = 47; continue; }; - if (yych != 't') { gotoCase = 41; continue; }; + if (yych == 'O') { gotoCase = 47; continue; }; + if (yych != 'o') { gotoCase = 43; continue; }; case 47: yych = this._charAt(++cursor); - if (yych == 'Y') { gotoCase = 48; continue; }; - if (yych != 'y') { gotoCase = 41; continue; }; + if (yych == 'C') { gotoCase = 48; continue; }; + if (yych != 'c') { gotoCase = 43; continue; }; case 48: yych = this._charAt(++cursor); - if (yych == 'P') { gotoCase = 49; continue; }; - if (yych != 'p') { gotoCase = 41; continue; }; + if (yych == 'T') { gotoCase = 49; continue; }; + if (yych != 't') { gotoCase = 43; continue; }; case 49: yych = this._charAt(++cursor); - if (yych == 'E') { gotoCase = 50; continue; }; - if (yych != 'e') { gotoCase = 41; continue; }; + if (yych == 'Y') { gotoCase = 50; continue; }; + if (yych != 'y') { gotoCase = 43; continue; }; case 50: - ++cursor; - { - this.tokenType = "html-doctype"; - this._parseCondition = this._parseConditions.DOCTYPE; - return cursor; - } + yych = this._charAt(++cursor); + if (yych == 'P') { gotoCase = 51; continue; }; + if (yych != 'p') { gotoCase = 43; continue; }; +case 51: + yych = this._charAt(++cursor); + if (yych == 'E') { gotoCase = 52; continue; }; + if (yych != 'e') { gotoCase = 43; continue; }; case 52: ++cursor; + this.setLexCondition(this._lexConditions.DOCTYPE); + { this.tokenType = "html-doctype"; return cursor; } +case 54: + ++cursor; yych = this._charAt(cursor); if (yych <= '\f') { - if (yych == '\n') { gotoCase = 55; continue; }; - { gotoCase = 52; continue; }; + if (yych == '\n') { gotoCase = 57; continue; }; + { gotoCase = 54; continue; }; } else { - if (yych <= '\r') { gotoCase = 55; continue; }; - if (yych != '-') { gotoCase = 52; continue; }; + if (yych <= '\r') { gotoCase = 57; continue; }; + if (yych != '-') { gotoCase = 54; continue; }; } ++cursor; yych = this._charAt(cursor); - if (yych == '-') { gotoCase = 57; continue; }; - { gotoCase = 41; continue; }; -case 55: + if (yych == '-') { gotoCase = 59; continue; }; + { gotoCase = 43; continue; }; +case 57: ++cursor; this.setLexCondition(this._lexConditions.COMMENT); { this.tokenType = "html-comment"; return cursor; } -case 57: +case 59: ++cursor; yych = this._charAt(cursor); - if (yych != '>') { gotoCase = 52; continue; }; + if (yych != '>') { gotoCase = 54; continue; }; ++cursor; { this.tokenType = "html-comment"; return cursor; } -case 60: - yych = this._charAt(++cursor); - if (yych == 'R') { gotoCase = 61; continue; }; - if (yych != 'r') { gotoCase = 41; continue; }; -case 61: - yych = this._charAt(++cursor); - if (yych == 'I') { gotoCase = 62; continue; }; - if (yych != 'i') { gotoCase = 41; continue; }; case 62: yych = this._charAt(++cursor); - if (yych == 'P') { gotoCase = 63; continue; }; - if (yych != 'p') { gotoCase = 41; continue; }; + if (yych == 'R') { gotoCase = 63; continue; }; + if (yych != 'r') { gotoCase = 43; continue; }; case 63: yych = this._charAt(++cursor); - if (yych == 'T') { gotoCase = 64; continue; }; - if (yych != 't') { gotoCase = 41; continue; }; + if (yych == 'I') { gotoCase = 64; continue; }; + if (yych != 'i') { gotoCase = 43; continue; }; case 64: + yych = this._charAt(++cursor); + if (yych == 'P') { gotoCase = 65; continue; }; + if (yych != 'p') { gotoCase = 43; continue; }; +case 65: + yych = this._charAt(++cursor); + if (yych == 'T') { gotoCase = 66; continue; }; + if (yych != 't') { gotoCase = 43; continue; }; +case 66: ++cursor; + this.setLexCondition(this._lexConditions.TAG); { this.tokenType = "html-tag"; - this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE; + this._parseCondition = this._parseConditions.SCRIPT; + this._setExpectingAttribute(); return cursor; } -case 66: - yych = this._charAt(++cursor); - if (yych == 'C') { gotoCase = 67; continue; }; - if (yych != 'c') { gotoCase = 41; continue; }; -case 67: - yych = this._charAt(++cursor); - if (yych == 'R') { gotoCase = 68; continue; }; - if (yych != 'r') { gotoCase = 41; continue; }; case 68: yych = this._charAt(++cursor); - if (yych == 'I') { gotoCase = 69; continue; }; - if (yych != 'i') { gotoCase = 41; continue; }; + if (yych == 'C') { gotoCase = 69; continue; }; + if (yych != 'c') { gotoCase = 43; continue; }; case 69: yych = this._charAt(++cursor); - if (yych == 'P') { gotoCase = 70; continue; }; - if (yych != 'p') { gotoCase = 41; continue; }; + if (yych == 'R') { gotoCase = 70; continue; }; + if (yych != 'r') { gotoCase = 43; continue; }; case 70: yych = this._charAt(++cursor); - if (yych == 'T') { gotoCase = 71; continue; }; - if (yych != 't') { gotoCase = 41; continue; }; + if (yych == 'I') { gotoCase = 71; continue; }; + if (yych != 'i') { gotoCase = 43; continue; }; case 71: + yych = this._charAt(++cursor); + if (yych == 'P') { gotoCase = 72; continue; }; + if (yych != 'p') { gotoCase = 43; continue; }; +case 72: + yych = this._charAt(++cursor); + if (yych == 'T') { gotoCase = 73; continue; }; + if (yych != 't') { gotoCase = 43; continue; }; +case 73: ++cursor; + this.setLexCondition(this._lexConditions.TAG); { this.tokenType = "html-tag"; this._parseCondition = this._parseConditions.INITIAL; return cursor; } -case 73: +/* *********************************** */ +case this.case_SSTRING: + yych = this._charAt(cursor); + if (yych <= '\f') { + if (yych == '\n') { gotoCase = 79; continue; }; + { gotoCase = 78; continue; }; + } else { + if (yych <= '\r') { gotoCase = 79; continue; }; + if (yych == '\'') { gotoCase = 81; continue; }; + { gotoCase = 78; continue; }; + } +case 77: + { return this._stringToken(cursor); } +case 78: + yych = this._charAt(++cursor); + { gotoCase = 85; continue; }; +case 79: + ++cursor; + { this.tokenType = null; return cursor; } +case 81: + ++cursor; +case 82: + this.setLexCondition(this._lexConditions.TAG); + { return this._stringToken(cursor, true); } +case 83: + yych = this._charAt(++cursor); + { gotoCase = 82; continue; }; +case 84: ++cursor; yych = this._charAt(cursor); -case 74: - if (yych <= '^') { - if (yych <= '9') { - if (yych <= '/') { gotoCase = 32; continue; }; - { gotoCase = 73; continue; }; +case 85: + if (yych <= '\f') { + if (yych == '\n') { gotoCase = 77; continue; }; + { gotoCase = 84; continue; }; + } else { + if (yych <= '\r') { gotoCase = 77; continue; }; + if (yych == '\'') { gotoCase = 83; continue; }; + { gotoCase = 84; continue; }; + } +/* *********************************** */ +case this.case_TAG: + yych = this._charAt(cursor); + if (yych <= '&') { + if (yych <= '\r') { + if (yych == '\n') { gotoCase = 90; continue; }; + if (yych >= '\r') { gotoCase = 90; continue; }; } else { - if (yych <= '@') { gotoCase = 32; continue; }; - if (yych <= 'Z') { gotoCase = 73; continue; }; - { gotoCase = 32; continue; }; + if (yych <= ' ') { + if (yych >= ' ') { gotoCase = 90; continue; }; + } else { + if (yych == '"') { gotoCase = 92; continue; }; + } } } else { - if (yych <= '`') { - if (yych <= '_') { gotoCase = 73; continue; }; - { gotoCase = 32; continue; }; + if (yych <= '>') { + if (yych <= ';') { + if (yych <= '\'') { gotoCase = 93; continue; }; + } else { + if (yych <= '<') { gotoCase = 90; continue; }; + if (yych <= '=') { gotoCase = 94; continue; }; + { gotoCase = 96; continue; }; + } } else { - if (yych <= 'z') { gotoCase = 73; continue; }; - if (yych <= 0x7F) { gotoCase = 32; continue; }; - { gotoCase = 73; continue; }; + if (yych <= '[') { + if (yych >= '[') { gotoCase = 90; continue; }; + } else { + if (yych == ']') { gotoCase = 90; continue; }; + } } } -case 75: ++cursor; yych = this._charAt(cursor); -case 76: + { gotoCase = 109; continue; }; +case 89: + { + if (this._parseCondition === this._parseConditions.SCRIPT) { + // Fall through if expecting attributes. + this.tokenType = null; + return cursor; + } + + if (this._parseCondition === this._parseConditions.INITIAL) { + this.tokenType = "html-tag"; + this._setExpectingAttribute(); + var token = this._line.substring(cursorOnEnter, cursor); + if (token === "a") + this._parseCondition |= this._parseConditions.A_NODE; + else if (this._parseCondition & this._parseConditions.A_NODE) + this._parseCondition ^= this._parseConditions.A_NODE; + } else if (this._isExpectingAttribute()) { + var token = this._line.substring(cursorOnEnter, cursor); + if (token === "href" || token === "src") + this._parseCondition |= this._parseConditions.LINKIFY; + else if (this._parseCondition |= this._parseConditions.LINKIFY) + this._parseCondition ^= this._parseConditions.LINKIFY; + this.tokenType = "html-attribute-name"; + } else if (this._isExpectingAttributeValue()) + this.tokenType = this._attrValueTokenType(); + else + this.tokenType = null; + return cursor; + } +case 90: + ++cursor; + { this.tokenType = null; return cursor; } +case 92: + yyaccept = 0; + yych = this._charAt(YYMARKER = ++cursor); + { gotoCase = 105; continue; }; +case 93: + yyaccept = 0; + yych = this._charAt(YYMARKER = ++cursor); + { gotoCase = 99; continue; }; +case 94: + ++cursor; + { + if (this._isExpectingAttribute()) + this._setExpectingAttributeValue(); + this.tokenType = null; + return cursor; + } +case 96: + ++cursor; + this.setLexCondition(this._lexConditions.INITIAL); + { + if (this._parseCondition & this._parseConditions.SCRIPT) { + // Do not tokenize script tag contents. + this.tokenType = null; + return cursor; + } + + this._parseCondition = this._parseConditions.INITIAL; + this.tokenType = "html-tag"; + return cursor; + } +case 98: + ++cursor; + yych = this._charAt(cursor); +case 99: if (yych <= '\f') { - if (yych != '\n') { gotoCase = 75; continue; }; + if (yych != '\n') { gotoCase = 98; continue; }; } else { - if (yych <= '\r') { gotoCase = 77; continue; }; - if (yych == '\'') { gotoCase = 79; continue; }; - { gotoCase = 75; continue; }; + if (yych <= '\r') { gotoCase = 100; continue; }; + if (yych == '\'') { gotoCase = 102; continue; }; + { gotoCase = 98; continue; }; } -case 77: +case 100: ++cursor; this.setLexCondition(this._lexConditions.SSTRING); { return this._stringToken(cursor); } -case 79: +case 102: ++cursor; { return this._stringToken(cursor, true); } -case 81: +case 104: ++cursor; yych = this._charAt(cursor); -case 82: +case 105: if (yych <= '\f') { - if (yych != '\n') { gotoCase = 81; continue; }; + if (yych != '\n') { gotoCase = 104; continue; }; } else { - if (yych <= '\r') { gotoCase = 83; continue; }; - if (yych == '"') { gotoCase = 79; continue; }; - { gotoCase = 81; continue; }; + if (yych <= '\r') { gotoCase = 106; continue; }; + if (yych == '"') { gotoCase = 102; continue; }; + { gotoCase = 104; continue; }; } -case 83: +case 106: ++cursor; this.setLexCondition(this._lexConditions.DSTRING); { return this._stringToken(cursor); } -/* *********************************** */ -case this.case_SSTRING: - yych = this._charAt(cursor); - if (yych <= '\f') { - if (yych == '\n') { gotoCase = 89; continue; }; - { gotoCase = 88; continue; }; - } else { - if (yych <= '\r') { gotoCase = 89; continue; }; - if (yych == '\'') { gotoCase = 91; continue; }; - { gotoCase = 88; continue; }; - } -case 87: - { return this._stringToken(cursor); } -case 88: - yych = this._charAt(++cursor); - { gotoCase = 95; continue; }; -case 89: - ++cursor; - { this.tokenType = null; return cursor; } -case 91: - ++cursor; -case 92: - this.setLexCondition(this._lexConditions.INITIAL); - { return this._stringToken(cursor, true); } -case 93: - yych = this._charAt(++cursor); - { gotoCase = 92; continue; }; -case 94: +case 108: ++cursor; yych = this._charAt(cursor); -case 95: - if (yych <= '\f') { - if (yych == '\n') { gotoCase = 87; continue; }; - { gotoCase = 94; continue; }; +case 109: + if (yych <= '"') { + if (yych <= '\r') { + if (yych == '\n') { gotoCase = 89; continue; }; + if (yych <= '\f') { gotoCase = 108; continue; }; + { gotoCase = 89; continue; }; + } else { + if (yych == ' ') { gotoCase = 89; continue; }; + if (yych <= '!') { gotoCase = 108; continue; }; + { gotoCase = 89; continue; }; + } } else { - if (yych <= '\r') { gotoCase = 87; continue; }; - if (yych == '\'') { gotoCase = 93; continue; }; - { gotoCase = 94; continue; }; + if (yych <= '>') { + if (yych == '\'') { gotoCase = 89; continue; }; + if (yych <= ';') { gotoCase = 108; continue; }; + { gotoCase = 89; continue; }; + } else { + if (yych <= '[') { + if (yych <= 'Z') { gotoCase = 108; continue; }; + { gotoCase = 89; continue; }; + } else { + if (yych == ']') { gotoCase = 89; continue; }; + { gotoCase = 108; continue; }; + } + } } } diff --git a/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js b/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js index e56f3ff..89c535a 100644 --- a/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js +++ b/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js @@ -44,72 +44,81 @@ WebInspector.SourceHTMLTokenizer = function() { WebInspector.SourceTokenizer.call(this); + // The order is determined by the generated code. this._lexConditions = { INITIAL: 0, COMMENT: 1, - DSTRING: 2, - SSTRING: 3 + DOCTYPE: 2, + TAG: 3, + DSTRING: 4, + SSTRING: 5 }; + this.case_INITIAL = 1000; + this.case_COMMENT = 1001; + this.case_DOCTYPE = 1002; + this.case_TAG = 1003; + this.case_DSTRING = 1004; + this.case_SSTRING = 1005; this._parseConditions = { INITIAL: 0, - TAG: 1, - ATTRIBUTE: 2, - ATTRIBUTE_VALUE: 3, - SCRIPT: 4, - SCRIPT_ATTRIBUTE: 5, - SCRIPT_ATTRIBUTE_VALUE: 6, - DOCTYPE: 7 + ATTRIBUTE: 1, + ATTRIBUTE_VALUE: 2, + LINKIFY: 4, + A_NODE: 8, + SCRIPT: 16 }; - this.case_INITIAL = 1000; - this.case_COMMENT = 1001; - this.case_DSTRING = 1002; - this.case_SSTRING = 1003; - this.initialCondition = { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL }; } WebInspector.SourceHTMLTokenizer.prototype = { - _isAttribute: function() + _isExpectingAttribute: function() { - return this._parseCondition === this._parseConditions.ATTRIBUTE || this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE; + return this._parseCondition & this._parseConditions.ATTRIBUTE; }, - _isAttributeValue: function() + _isExpectingAttributeValue: function() { - return this._parseCondition === this._parseConditions.ATTRIBUTE_VALUE || this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE_VALUE; + return this._parseCondition & this._parseConditions.ATTRIBUTE_VALUE; }, - _setAttributeValue: function() + _setExpectingAttribute: function() { - if (this._parseCondition === this._parseConditions.ATTRIBUTE) - this._parseCondition = this._parseConditions.ATTRIBUTE_VALUE; - else if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE) - this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE_VALUE; + if (this._isExpectingAttributeValue()) + this._parseCondition ^= this._parseConditions.ATTRIBUTE_VALUE; + this._parseCondition |= this._parseConditions.ATTRIBUTE; }, - _setAttribute: function() + _setExpectingAttributeValue: function() { - if (this._parseCondition === this._parseConditions.ATTRIBUTE_VALUE) - this._parseCondition = this._parseConditions.ATTRIBUTE; - else if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE_VALUE) - this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE; + if (this._isExpectingAttribute()) + this._parseCondition ^= this._parseConditions.ATTRIBUTE; + this._parseCondition |= this._parseConditions.ATTRIBUTE_VALUE; }, _stringToken: function(cursor, stringEnds) { - if (this._isAttributeValue()) { - this.tokenType = "html-attr-value"; - if (stringEnds) - this._setAttribute(); - } else if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; - else + if (!this._isExpectingAttributeValue()) { this.tokenType = null; + return cursor; + } + this.tokenType = this._attrValueTokenType(); + if (stringEnds) + this._setExpectingAttribute(); return cursor; }, + _attrValueTokenType: function() + { + if (this._parseCondition & this._parseConditions.LINKIFY) { + if (this._parseCondition & this._parseConditions.A_NODE) + return "html-external-link"; + return "html-resource-link"; + } + return "html-attribute-value"; + }, + nextToken: function(cursor) { var cursorOnEnter = cursor; @@ -134,7 +143,9 @@ WebInspector.SourceHTMLTokenizer.prototype = { CommentStart = "<!--" CommentContent [\r\n]; CommentEnd = CommentContent "-->"; - DocTypeLT = "<!" [Dd] [Oo] [Cc] [Tt] [Yy] [Pp] [Ee]; + DocTypeStart = "<!" [Dd] [Oo] [Cc] [Tt] [Yy] [Pp] [Ee]; + DocTypeContent = [^\r\n>]*; + ScriptStart = "<" [Ss] [Cc] [Rr] [Ii] [Pp] [Tt]; ScriptEnd = "</" [Ss] [Cc] [Rr] [Ii] [Pp] [Tt]; @@ -150,101 +161,100 @@ WebInspector.SourceHTMLTokenizer.prototype = { SingleStringStart = "'" SingleStringContent [\r\n]; SingleStringEnd = SingleStringContent "'"; - Identifier = [_a-zA-Z0-9\x80-\xFF]+; + Identifier = [^ \r\n"'<>\[\]=]+; <INITIAL> Comment { this.tokenType = "html-comment"; return cursor; } <INITIAL> CommentStart => COMMENT { this.tokenType = "html-comment"; return cursor; } <COMMENT> CommentContent => COMMENT { this.tokenType = "html-comment"; return cursor; } <COMMENT> CommentEnd => INITIAL { this.tokenType = "html-comment"; return cursor; } - <INITIAL> DocTypeLT => INITIAL - { - this.tokenType = "html-doctype"; - this._parseCondition = this._parseConditions.DOCTYPE; - return cursor; - } + <INITIAL> DocTypeStart => DOCTYPE { this.tokenType = "html-doctype"; return cursor; } + <DOCTYPE> DocTypeContent => DOCTYPE { this.tokenType = "html-doctype"; return cursor; } + <DOCTYPE> GT => INITIAL { this.tokenType = "html-doctype"; return cursor; } - <INITIAL> ScriptStart => INITIAL + <INITIAL> ScriptStart => TAG { this.tokenType = "html-tag"; - this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE; + this._parseCondition = this._parseConditions.SCRIPT; + this._setExpectingAttribute(); return cursor; } - <INITIAL> ScriptEnd => INITIAL + <INITIAL> ScriptEnd => TAG { this.tokenType = "html-tag"; this._parseCondition = this._parseConditions.INITIAL; return cursor; } - <INITIAL> LT => INITIAL + <INITIAL> LT => TAG { - if (this._parseCondition === this._parseConditions.SCRIPT) { + if (this._parseCondition & this._parseConditions.SCRIPT) { + // Do not tokenize script tag contents, keep lexer state although processing "<". + this.setLexCondition(this._lexConditions.INITIAL); this.tokenType = null; return cursor; } + this._parseCondition = this._parseConditions.INITIAL; this.tokenType = "html-tag"; - this._parseCondition = this._parseConditions.TAG; return cursor; } - <INITIAL> GT => INITIAL + <TAG> GT => INITIAL { - if (this._parseCondition === this._parseConditions.SCRIPT) { + if (this._parseCondition & this._parseConditions.SCRIPT) { + // Do not tokenize script tag contents. this.tokenType = null; return cursor; } - if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; - else - this.tokenType = "html-tag"; - - if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE) - this._parseCondition = this._parseConditions.SCRIPT; - else - this._parseCondition = this._parseConditions.INITIAL; + this._parseCondition = this._parseConditions.INITIAL; + this.tokenType = "html-tag"; return cursor; } - <INITIAL> StringLiteral { return this._stringToken(cursor, true); } - <INITIAL> DoubleStringStart => DSTRING { return this._stringToken(cursor); } + <TAG> StringLiteral { return this._stringToken(cursor, true); } + <TAG> DoubleStringStart => DSTRING { return this._stringToken(cursor); } <DSTRING> DoubleStringContent => DSTRING { return this._stringToken(cursor); } - <DSTRING> DoubleStringEnd => INITIAL { return this._stringToken(cursor, true); } - <INITIAL> SingleStringStart => SSTRING { return this._stringToken(cursor); } + <DSTRING> DoubleStringEnd => TAG { return this._stringToken(cursor, true); } + <TAG> SingleStringStart => SSTRING { return this._stringToken(cursor); } <SSTRING> SingleStringContent => SSTRING { return this._stringToken(cursor); } - <SSTRING> SingleStringEnd => INITIAL { return this._stringToken(cursor, true); } + <SSTRING> SingleStringEnd => TAG { return this._stringToken(cursor, true); } - <INITIAL> EqualSign => INITIAL + <TAG> EqualSign => TAG { - if (this._isAttribute()) { - this.tokenType = null; - this._setAttributeValue(); - } else if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; - else - this.tokenType = null; + if (this._isExpectingAttribute()) + this._setExpectingAttributeValue(); + this.tokenType = null; return cursor; } - <INITIAL> Identifier + <TAG> Identifier { if (this._parseCondition === this._parseConditions.SCRIPT) { + // Fall through if expecting attributes. this.tokenType = null; return cursor; } - if (this._parseCondition === this._parseConditions.TAG) { + if (this._parseCondition === this._parseConditions.INITIAL) { this.tokenType = "html-tag"; - this._parseCondition = this._parseConditions.ATTRIBUTE; - } else if (this._isAttribute()) - this.tokenType = "html-attr-name"; - else if (this._isAttributeValue()) - this.tokenType = "html-attr-value"; - else if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; + this._setExpectingAttribute(); + var token = this._line.substring(cursorOnEnter, cursor); + if (token === "a") + this._parseCondition |= this._parseConditions.A_NODE; + else if (this._parseCondition & this._parseConditions.A_NODE) + this._parseCondition ^= this._parseConditions.A_NODE; + } else if (this._isExpectingAttribute()) { + var token = this._line.substring(cursorOnEnter, cursor); + if (token === "href" || token === "src") + this._parseCondition |= this._parseConditions.LINKIFY; + else if (this._parseCondition |= this._parseConditions.LINKIFY) + this._parseCondition ^= this._parseConditions.LINKIFY; + this.tokenType = "html-attribute-name"; + } else if (this._isExpectingAttributeValue()) + this.tokenType = this._attrValueTokenType(); else this.tokenType = null; return cursor; diff --git a/WebCore/inspector/front-end/SourceView.js b/WebCore/inspector/front-end/SourceView.js index 292b8af..7fc8499 100644 --- a/WebCore/inspector/front-end/SourceView.js +++ b/WebCore/inspector/front-end/SourceView.js @@ -41,7 +41,6 @@ WebInspector.SourceView.prototype = { show: function(parentElement) { WebInspector.ResourceView.prototype.show.call(this, parentElement); - this.setupSourceFrameIfNeeded(); this.sourceFrame.visible = true; this.resize(); }, @@ -79,10 +78,15 @@ WebInspector.SourceView.prototype = { delete this._frameNeedsSetup; WebInspector.getResourceContent(this.resource.identifier, this._contentLoaded.bind(this)); }, - + + contentTabSelected: function() + { + this.setupSourceFrameIfNeeded(); + }, + _contentLoaded: function(content) { - this.sourceFrame.setContent(this.resource.mimeType, content); + this.sourceFrame.setContent(this.resource.mimeType, content, this.resource.url); this._sourceFrameSetupFinished(); }, diff --git a/WebCore/inspector/front-end/TextEditor.js b/WebCore/inspector/front-end/TextEditor.js index afa97c1..9268280 100644 --- a/WebCore/inspector/front-end/TextEditor.js +++ b/WebCore/inspector/front-end/TextEditor.js @@ -35,7 +35,8 @@ WebInspector.TextEditor = function(textModel, platform) this._highlighter = new WebInspector.TextEditorHighlighter(this._textModel, this._highlightChanged.bind(this)); this.element = document.createElement("div"); - this.element.className = "text-editor"; + this.element.className = "text-editor monospace"; + this.element.tabIndex = 0; this._canvas = document.createElement("canvas"); this._canvas.className = "text-editor-canvas"; @@ -43,7 +44,6 @@ WebInspector.TextEditor = function(textModel, platform) this._container = document.createElement("div"); this._container.className = "text-editor-container"; - this._container.tabIndex = 0; this.element.appendChild(this._container); this._sheet = document.createElement("div"); @@ -55,7 +55,6 @@ WebInspector.TextEditor = function(textModel, platform) this._cursor = new WebInspector.TextCursor(cursorElement); this._container.addEventListener("scroll", this._scroll.bind(this), false); - this._sheet.addEventListener("contextmenu", this._contextMenu.bind(this), false); this._registerMouseListeners(); this._registerKeyboardListeners(); @@ -69,9 +68,6 @@ WebInspector.TextEditor = function(textModel, platform) this._selection = new WebInspector.TextSelectionModel(this._selectionChanged.bind(this)); this._isMac = platform && (platform.indexOf("mac") === 0); - - this._initFont(); - this._paintCoalescingLevel = 0; this._registerShortcuts(); @@ -84,6 +80,7 @@ WebInspector.TextEditor = function(textModel, platform) this._lineOffsetsCache = [0]; this._readOnly = false; + this._selectionColor = "rgb(181, 213, 255)"; } WebInspector.TextEditor.prototype = { @@ -152,11 +149,12 @@ WebInspector.TextEditor.prototype = { _registerMouseListeners: function() { - this._sheet.addEventListener("mouseup", this._mouseUp.bind(this), false); - this._sheet.addEventListener("mousedown", this._mouseDown.bind(this), false); - this._sheet.addEventListener("mousemove", this._mouseMove.bind(this), false); - this._sheet.addEventListener("mouseout", this._mouseOut.bind(this), false); - this._sheet.addEventListener("dblclick", this._dblClick.bind(this), false); + this.element.addEventListener("contextmenu", this._contextMenu.bind(this), false); + this.element.addEventListener("mouseup", this._mouseUp.bind(this), false); + this.element.addEventListener("mousedown", this._mouseDown.bind(this), false); + this.element.addEventListener("mousemove", this._mouseMove.bind(this), false); + this.element.addEventListener("mouseout", this._mouseOut.bind(this), false); + this.element.addEventListener("dblclick", this._dblClick.bind(this), false); }, _registerKeyboardListeners: function() @@ -180,7 +178,7 @@ WebInspector.TextEditor.prototype = { if (offset > this._lineOffsetsCache[this._lineOffsetsCache.length - 1]) { // Seeking outside cached area. Fill the cache. var lineNumber = this._lineOffsetsCache.length; - while (this._lineToOffset(lineNumber) < offset) + while (lineNumber < this._textModel.linesCount && this._lineToOffset(lineNumber) < offset) lineNumber++; return lineNumber; } @@ -217,6 +215,10 @@ WebInspector.TextEditor.prototype = { _lineHeight: function(lineNumber) { + // Use cached value first. + if (this._lineOffsetsCache[lineNumber + 1]) + return this._lineOffsetsCache[lineNumber + 1] - this._lineOffsetsCache[lineNumber]; + var element = this._textModel.getAttribute(lineNumber, "div-decoration"); if (element) return 2 * this._textLineHeight + element.clientHeight; @@ -225,6 +227,9 @@ WebInspector.TextEditor.prototype = { reveal: function(line, column) { + this._scrollTop = this._container.scrollTop; + this._scrollLeft = this._container.scrollLeft; + var maxScrollTop = this._lineToOffset(line); var minScrollTop = maxScrollTop + this._lineHeight(line) - this._canvas.height; if (this._scrollTop > maxScrollTop) @@ -237,8 +242,10 @@ WebInspector.TextEditor.prototype = { var minScrollLeft = maxScrollLeft - this._container.clientWidth + this._lineNumberWidth; if (this._scrollLeft < minScrollLeft) this._container.scrollLeft = minScrollLeft + 100; - if (this._scrollLeft > maxScrollLeft) + else if (this._scrollLeft > maxScrollLeft) this._container.scrollLeft = maxScrollLeft; + else if (minScrollLeft < 0 && maxScrollLeft > 0) + this._container.scrollLeft = 0; }, // WebInspector.TextModel listener @@ -326,8 +333,9 @@ WebInspector.TextEditor.prototype = { var newLineNumberDigits = this._decimalDigits(this._textModel.linesCount); this._lineNumberWidth = (newLineNumberDigits + 2) * this._digitWidth; + this._container.style.left = this._lineNumberWidth + "px"; - var newWidth = this._textWidth + this._lineNumberWidth + "px"; + var newWidth = this._textWidth + "px"; var newHeight = this._lineToOffset(this._textModel.linesCount) + "px"; this._sheet.style.width = newWidth; this._sheet.style.height = newHeight; @@ -345,7 +353,7 @@ WebInspector.TextEditor.prototype = { resize: function() { if (this._canvas.width !== this._container.clientWidth || this._canvas.height !== this._container.clientHeight) { - this._canvas.width = this._container.clientWidth; + this._canvas.width = this._container.clientWidth + this._lineNumberWidth; this._canvas.height = this._container.clientHeight; this.repaintAll(); } @@ -376,16 +384,20 @@ WebInspector.TextEditor.prototype = { _paint: function() { + this._scrollTop = this._container.scrollTop; + this._scrollLeft = this._container.scrollLeft; + if (this._paintCoalescingLevel) return; + this._updateDivDecorations(); + this.paintLineNumbers(); for (var i = 0; this._damage && i < this._damage.length; ++i) this._paintLines(this._damage[i].startLine, this._damage[i].endLine); delete this._damage; - this._updateDivDecorations(); this._updateCursor(this._selection.endLine, this._selection.endColumn); }, @@ -556,7 +568,7 @@ WebInspector.TextEditor.prototype = { var location = this._caretForMouseEvent(e); - if (e.offsetX < this._lineNumberWidth && this._lineNumberDecorator) { + if (e.target === this.element && this._lineNumberDecorator) { if (this._lineNumberDecorator.mouseDown(location.line, e)) return; } @@ -590,7 +602,7 @@ WebInspector.TextEditor.prototype = { _contextMenu: function(e) { - if (e.offsetX < this._lineNumberWidth && this._lineNumberDecorator) { + if (e.target === this.element && this._lineNumberDecorator) { var location = this._caretForMouseEvent(e); if (this._lineNumberDecorator.contextMenu(location.line, e)) return; @@ -607,8 +619,8 @@ WebInspector.TextEditor.prototype = { _caretForMouseEvent: function(e) { - var lineNumber = Math.max(0, this._offsetToLine(e.offsetY) - 1); - var offset = e.offsetX + this._scrollLeft - this._lineNumberWidth; + var lineNumber = Math.max(0, this._offsetToLine(e.offsetY + (e.target === this.element ? this._scrollTop : 0)) - 1); + var offset = e.offsetX + this._scrollLeft; return { line: lineNumber, column: this._columnForOffset(lineNumber, offset) }; }, @@ -811,8 +823,10 @@ WebInspector.TextEditor.prototype = { var linesCount = this._textModel.linesCount; for (var i = 0; i < linesCount; ++i) { var element = this._textModel.getAttribute(i, "div-decoration"); - if (element) + if (element) { + this._lineOffsetsCache.length = Math.min(this._lineOffsetsCache.length, i + 1); this._positionDivDecoration(i, element, i > firstLine && i < lastLine); + } } }, @@ -848,7 +862,7 @@ WebInspector.TextEditor.prototype = { if (this._selection.isEmpty()) return; var range = this._selection.range(); - this._ctx.fillStyle = "rgb(181, 213, 255)"; + this._ctx.fillStyle = this._selectionColor; firstLine = Math.max(firstLine, range.startLine); endLine = Math.min(lastLine, range.endLine + 1); @@ -962,34 +976,14 @@ WebInspector.TextEditor.prototype = { this._updateCursor(this._selection.endLine, this._selection.endColumn); }, - _initFont: function(sansSerif) + initFontMetrics: function() { - if (!WebInspector.TextEditor.PlatformFonts) { - WebInspector.TextEditor.PlatformFonts = {}; - WebInspector.TextEditor.PlatformFonts[WebInspector.OS.Windows] = {size: 12, face: "Lucida Console"}; - WebInspector.TextEditor.PlatformFonts[WebInspector.OS.WindowsVistaOrLater] = {size: 12, face: "Courier"}; - WebInspector.TextEditor.PlatformFonts[WebInspector.OS.MacSnowLeopard] = {size: 11, face: "Menlo"}; - WebInspector.TextEditor.PlatformFonts[WebInspector.OS.MacLeopard] = {size: 10, face: "Monaco"}; - WebInspector.TextEditor.PlatformFonts[WebInspector.OS.MacTiger] = {size: 10, face: "Monaco"}; - } - - if (sansSerif) { - this._isMonospace = false; - this._fontSize = 11; - this._font = this._fontSize + "px sans-serif"; - } else { - this._isMonospace = true; - const platform = WebInspector.platform; - const fontInfo = WebInspector.TextEditor.PlatformFonts[platform] || {size: 10, face: "monospace"}; - this._fontSize = fontInfo.size; - this._font = this._fontSize + "px " + fontInfo.face; - } + var computedStyle = window.getComputedStyle(this.element); + this._font = computedStyle.fontSize + " " + computedStyle.fontFamily; this._ctx.font = this._font; this._digitWidth = this._ctx.measureText("0").width; - - this._textLineHeight = Math.floor(this._fontSize * 1.4); + this._textLineHeight = Math.floor(parseInt(this._ctx.font) * 1.4); this._cursor.setTextLineHeight(this._textLineHeight); - this._lineOffsetsCache = [0]; }, _registerShortcuts: function() @@ -999,15 +993,11 @@ WebInspector.TextEditor.prototype = { this._shortcuts[WebInspector.KeyboardShortcut.makeKey("z", this._isMac ? modifiers.Meta : modifiers.Ctrl)] = this._handleUndo.bind(this); this._shortcuts[WebInspector.KeyboardShortcut.makeKey("z", modifiers.Shift | (this._isMac ? modifiers.Meta : modifiers.Ctrl))] = this._handleRedo.bind(this); this._shortcuts[WebInspector.KeyboardShortcut.makeKey("a", this._isMac ? modifiers.Meta : modifiers.Ctrl)] = this._selectAll.bind(this); - this._shortcuts[WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.Plus, this._isMac ? modifiers.Meta : modifiers.Ctrl)] = this._handleZoomIn.bind(this); - this._shortcuts[WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.Minus, this._isMac ? modifiers.Meta : modifiers.Ctrl)] = this._handleZoomOut.bind(this); - this._shortcuts[WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.Zero, this._isMac ? modifiers.Meta : modifiers.Ctrl)] = this._handleZoomReset.bind(this); if (this._isMac) this._shortcuts[WebInspector.KeyboardShortcut.makeKey("d", modifiers.Ctrl)] = this._handleDeleteKey.bind(this); this._shortcuts[WebInspector.KeyboardShortcut.makeKey("d", modifiers.Ctrl | modifiers.Alt)] = this._handleToggleDebugMode.bind(this); this._shortcuts[WebInspector.KeyboardShortcut.makeKey("h", modifiers.Ctrl | modifiers.Alt)] = this._handleToggleHighlightMode.bind(this); - this._shortcuts[WebInspector.KeyboardShortcut.makeKey("m", modifiers.Ctrl | modifiers.Alt)] = this._handleToggleMonospaceMode.bind(this); }, _handleUndo: function() @@ -1065,34 +1055,6 @@ WebInspector.TextEditor.prototype = { this._debugMode = !this._debugMode; }, - _handleZoomIn: function() - { - if (this._fontSize < 25) - this._changeFont(!this._isMonospace, this._fontSize + 1); - }, - - _handleZoomOut: function() - { - if (this._fontSize > 1) - this._changeFont(!this._isMonospace, this._fontSize - 1); - }, - - _handleZoomReset: function() - { - this._changeFont(!this._isMonospace); - }, - - _handleToggleMonospaceMode: function() - { - this._changeFont(this._isMonospace, this._fontSize); - }, - - _changeFont: function(sansSerif, fontSize) { - this._initFont(sansSerif, fontSize); - this._updatePreferredSize(0, this._textModel.linesCount); - this.repaintAll(); - }, - _handleToggleHighlightMode: function() { this._highlightingEnabled = !this._highlightingEnabled; diff --git a/WebCore/inspector/front-end/TextEditorHighlighter.js b/WebCore/inspector/front-end/TextEditorHighlighter.js index 9a7a050..c73e036 100644 --- a/WebCore/inspector/front-end/TextEditorHighlighter.js +++ b/WebCore/inspector/front-end/TextEditorHighlighter.js @@ -47,10 +47,12 @@ WebInspector.TextEditorHighlighter = function(textModel, damageCallback) /* Keep this in sync with inspector.css and view-source.css */ this._styles["html-tag"] = "rgb(136, 18, 128)"; - this._styles["html-attr-name"] = "rgb(153, 69, 0)"; - this._styles["html-attr-value"] = "rgb(26, 26, 166)"; + this._styles["html-attribute-name"] = "rgb(153, 69, 0)"; + this._styles["html-attribute-value"] = "rgb(26, 26, 166)"; this._styles["html-comment"] = "rgb(35, 110, 37)"; this._styles["html-doctype"] = "rgb(192, 192, 192)"; + this._styles["html-external-link"] = "#00e"; + this._styles["html-resource-link"] = "#00e"; this._styles["javascript-comment"] = "rgb(0, 116, 0)"; this._styles["javascript-string"] = "rgb(196, 26, 22)"; diff --git a/WebCore/inspector/front-end/inspector.css b/WebCore/inspector/front-end/inspector.css index 501915d..45b8ec3 100644 --- a/WebCore/inspector/front-end/inspector.css +++ b/WebCore/inspector/front-end/inspector.css @@ -246,13 +246,11 @@ body.attached.port-qt .toolbar-item.close-left, body.attached.port-qt .toolbar-i display: none; } -body.platform-mac-tiger .toolbar-item.close-right, -body.platform-mac-leopard .toolbar-item.close-right, -body.platform-mac-snowleopard .toolbar-item.close-right { +body.platform-mac .toolbar-item.close-right { display: none; } -body:not(.platform-mac-tiger):not(.platform-mac-leopard):not(.platform-mac-snowleopard) .toolbar-item.close-left { +body:not(.platform-mac) .toolbar-item.close-left { display: none; } @@ -503,20 +501,18 @@ body.drawer-visible #drawer { font-family: monospace; } -body.platform-mac-tiger .monospace, body.platform-mac-leopard .monospace, -body.platform-mac-tiger .source-code, body.platform-mac-leopard .source-code { - font-size: 10px; +body.platform-mac .monospace, body.platform-mac .source-code { font-family: Monaco, monospace; } -body.platform-mac-snowleopard .monospace, -body.platform-mac-snowleopard .source-code { +/* Keep .platform-mac to make the rule more specific than the general one above. */ +body.platform-mac.platform-mac-snowleopard .monospace, +body.platform-mac.platform-mac-snowleopard .source-code { font-size: 11px; font-family: Menlo, monospace; } -body.platform-windows .monospace, body.platform-windows-vista-or-later .monospace, -body.platform-windows .source-code, body.platform-windows-vista-or-later .source-code { +body.platform-windows .monospace, body.platform-windows .source-code { font-size: 12px; font-family: Consolas, Lucida Console, monospace; } @@ -1188,46 +1184,6 @@ body.platform-windows .source-code, body.platform-windows-vista-or-later .source display: block; } -.webkit-html-comment { - /* Keep this in sync with view-source.css (.webkit-html-comment) */ - color: rgb(35, 110, 37); -} - -.webkit-html-tag { - /* Keep this in sync with view-source.css (.webkit-html-tag) */ - color: rgb(136, 18, 128); -} - -.webkit-html-doctype { - /* Keep this in sync with view-source.css (.webkit-html-doctype) */ - color: rgb(192, 192, 192); -} - -.webkit-html-attribute-name { - /* Keep this in sync with view-source.css (.webkit-html-attribute-name) */ - color: rgb(153, 69, 0); -} - -.webkit-html-attribute-value { - /* Keep this in sync with view-source.css (.webkit-html-attribute-value) */ - color: rgb(26, 26, 166); -} - -.webkit-html-external-link, .webkit-html-resource-link { - /* Keep this in sync with view-source.css (.webkit-html-external-link, .webkit-html-resource-link) */ - color: #00e; -} - -.webkit-html-external-link { - /* Keep this in sync with view-source.css (.webkit-html-external-link) */ - text-decoration: none; -} - -.webkit-html-external-link:hover { - /* Keep this in sync with view-source.css (.webkit-html-external-link:hover) */ - text-decoration: underline; -} - .add-attribute { margin-left: 1px; margin-right: 1px; diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js index c637f37..de20739 100644 --- a/WebCore/inspector/front-end/inspector.js +++ b/WebCore/inspector/front-end/inspector.js @@ -67,37 +67,44 @@ var WebInspector = { get platform() { if (!("_platform" in this)) - this._platform = this._detectPlatform(); + this._platform = InspectorFrontendHost.platform(); return this._platform; }, - _detectPlatform: function() + get platformFlavor() + { + if (!("_platformFlavor" in this)) + this._platformFlavor = this._detectPlatformFlavor(); + + return this._platformFlavor; + }, + + _detectPlatformFlavor: function() { const userAgent = navigator.userAgent; - var nativePlatform = InspectorFrontendHost.platform(); - if (nativePlatform === "windows") { + if (this.platform === "windows") { var match = userAgent.match(/Windows NT (\d+)\.(?:\d+)/); if (match && match[1] >= 6) - return WebInspector.OS.WindowsVistaOrLater; - return WebInspector.OS.Windows; - } else if (nativePlatform === "mac") { + return WebInspector.PlatformFlavor.WindowsVista; + return null; + } else if (this.platform === "mac") { var match = userAgent.match(/Mac OS X\s*(?:(\d+)_(\d+))?/); if (!match || match[1] != 10) - return WebInspector.OS.MacSnowLeopard; + return WebInspector.PlatformFlavor.MacSnowLeopard; switch (Number(match[2])) { case 4: - return WebInspector.OS.MacTiger; + return WebInspector.PlatformFlavor.MacTiger; case 5: - return WebInspector.OS.MacLeopard; + return WebInspector.PlatformFlavor.MacLeopard; case 6: default: - return WebInspector.OS.MacSnowLeopard; + return WebInspector.PlatformFlavor.MacSnowLeopard; } } - return nativePlatform; + return null; }, get port() @@ -415,9 +422,8 @@ var WebInspector = { } } -WebInspector.OS = { - Windows: "windows", - WindowsVistaOrLater: "windows-vista-or-later", +WebInspector.PlatformFlavor = { + WindowsVista: "windows-vista", MacTiger: "mac-tiger", MacLeopard: "mac-leopard", MacSnowLeopard: "mac-snowleopard" @@ -429,6 +435,9 @@ WebInspector.loaded = function() var platform = WebInspector.platform; document.body.addStyleClass("platform-" + platform); + var flavor = WebInspector.platformFlavor; + if (flavor) + document.body.addStyleClass("platform-" + flavor); var port = WebInspector.port; document.body.addStyleClass("port-" + port); @@ -871,7 +880,7 @@ WebInspector.toggleAttach = function() WebInspector.toolbarDragStart = function(event) { - if ((!WebInspector.attached && WebInspector.platform !== "mac-leopard") || WebInspector.port == "qt") + if ((!WebInspector.attached && WebInspector.platformFlavor !== WebInspector.PlatformFlavor.MacLeopard && WebInspector.platformFlavor !== WebInspector.PlatformFlavor.MacSnowLeopard) || WebInspector.port == "qt") return; var target = event.target; @@ -1528,6 +1537,20 @@ WebInspector.linkifyURL = function(url, linkText, classes, isExternal, tooltipTe return WebInspector.linkifyURLAsNode(url, linkText, classes, isExternal, tooltipText).outerHTML; } +WebInspector.completeURL = function(baseURL, href) +{ + var match = baseURL.match(WebInspector.URLRegExp); + if (match) { + var path = href; + if (path.charAt(0) !== "/") { + var basePath = match[4] || "/"; + path = basePath.substring(0, basePath.lastIndexOf("/")) + "/" + path; + } + return match[1] + "://" + match[2] + (match[3] ? (":" + match[3]) : "") + path; + } + return null; +} + WebInspector.addMainEventListeners = function(doc) { doc.defaultView.addEventListener("focus", this.windowFocused.bind(this), false); @@ -1685,7 +1708,7 @@ WebInspector.UIString = function(string) WebInspector.isMac = function() { if (!("_isMac" in this)) - this._isMac = WebInspector.platform.indexOf("mac-") === 0; + this._isMac = WebInspector.platform === "mac"; return this._isMac; } diff --git a/WebCore/inspector/front-end/inspectorSyntaxHighlight.css b/WebCore/inspector/front-end/inspectorSyntaxHighlight.css index e3e3074..1292f00 100644 --- a/WebCore/inspector/front-end/inspectorSyntaxHighlight.css +++ b/WebCore/inspector/front-end/inspectorSyntaxHighlight.css @@ -65,3 +65,43 @@ .webkit-javascript-string, .webkit-javascript-regexp { color: rgb(196, 26, 22); } + +.webkit-html-comment { + /* Keep this in sync with view-source.css (.webkit-html-comment) */ + color: rgb(35, 110, 37); +} + +.webkit-html-tag { + /* Keep this in sync with view-source.css (.webkit-html-tag) */ + color: rgb(136, 18, 128); +} + +.webkit-html-doctype { + /* Keep this in sync with view-source.css (.webkit-html-doctype) */ + color: rgb(192, 192, 192); +} + +.webkit-html-attribute-name { + /* Keep this in sync with view-source.css (.webkit-html-attribute-name) */ + color: rgb(153, 69, 0); +} + +.webkit-html-attribute-value { + /* Keep this in sync with view-source.css (.webkit-html-attribute-value) */ + color: rgb(26, 26, 166); +} + +.webkit-html-external-link, .webkit-html-resource-link { + /* Keep this in sync with view-source.css (.webkit-html-external-link, .webkit-html-resource-link) */ + color: #00e; +} + +.webkit-html-external-link { + /* Keep this in sync with view-source.css (.webkit-html-external-link) */ + text-decoration: none; +} + +.webkit-html-external-link:hover { + /* Keep this in sync with view-source.css (.webkit-html-external-link:hover) */ + text-decoration: underline; +} diff --git a/WebCore/inspector/front-end/textEditor.css b/WebCore/inspector/front-end/textEditor.css index 9629a07..93495f2 100644 --- a/WebCore/inspector/front-end/textEditor.css +++ b/WebCore/inspector/front-end/textEditor.css @@ -45,7 +45,6 @@ } .native-text-editor-line { - height: 14px; white-space: pre; } |