Commit ab0fd135 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

2010-02-01 Pavel Feldman <pfeldman@chromium.org>

        Reviewed by Timothy Hatcher.

        Web Inspector: Syntax highlighting in source view of
        Resources pane stops half-way.

        There were two problems here: (1) styles for html highlighter were not
        added into the css file (they used to be injected manually in the
        SourceFrame before). (2) 'Tag' needed to be lexer's state, not parser's.
        Otherwise unbalanced quotes in the text nodes were matching too match
        into the string tokens.

        https://bugs.webkit.org/show_bug.cgi?id=34359

        * inspector/front-end/NativeTextViewer.js:
        (WebInspector.NativeTextViewer.prototype._createLineDivs):
        (WebInspector.NativeTextViewer.prototype._lineHeight):
        (WebInspector.NativeTextViewer.prototype.initFontMetrics):
        * inspector/front-end/SourceFrame.js:
        (WebInspector.SourceFrame.prototype._createEditorIfNeeded):
        * inspector/front-end/SourceHTMLTokenizer.js:
        (WebInspector.SourceHTMLTokenizer):
        (WebInspector.SourceHTMLTokenizer.prototype.nextToken):
        * inspector/front-end/SourceHTMLTokenizer.re2js:
        * inspector/front-end/TextEditor.js:
        (WebInspector.TextEditor.prototype.initFontMetrics):
        (WebInspector.TextEditor.prototype._registerShortcuts):
        * inspector/front-end/inspectorSyntaxHighlight.css:


git-svn-id: svn://svn.chromium.org/blink/trunk@54139 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent f18574d2
2010-02-01 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Timothy Hatcher.
Web Inspector: Syntax highlighting in source view of
Resources pane stops half-way.
There were two problems here: (1) styles for html highlighter were not
added into the css file (they used to be injected manually in the
SourceFrame before). (2) 'Tag' needed to be lexer's state, not parser's.
Otherwise unbalanced quotes in the text nodes were matching too match
into the string tokens.
https://bugs.webkit.org/show_bug.cgi?id=34359
* inspector/front-end/NativeTextViewer.js:
(WebInspector.NativeTextViewer.prototype._createLineDivs):
(WebInspector.NativeTextViewer.prototype._lineHeight):
(WebInspector.NativeTextViewer.prototype.initFontMetrics):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame.prototype._createEditorIfNeeded):
* inspector/front-end/SourceHTMLTokenizer.js:
(WebInspector.SourceHTMLTokenizer):
(WebInspector.SourceHTMLTokenizer.prototype.nextToken):
* inspector/front-end/SourceHTMLTokenizer.re2js:
* inspector/front-end/TextEditor.js:
(WebInspector.TextEditor.prototype.initFontMetrics):
(WebInspector.TextEditor.prototype._registerShortcuts):
* inspector/front-end/inspectorSyntaxHighlight.css:
2010-02-01 Ben Murdoch <benm@google.com> 2010-02-01 Ben Murdoch <benm@google.com>
Reviewed by Darin Adler. Reviewed by Darin Adler.
......
...@@ -58,6 +58,7 @@ WebInspector.NativeTextViewer.prototype = { ...@@ -58,6 +58,7 @@ WebInspector.NativeTextViewer.prototype = {
lineDiv.style.minHeight = this._textLineHeight + "px"; lineDiv.style.minHeight = this._textLineHeight + "px";
this._sheet.appendChild(lineDiv); this._sheet.appendChild(lineDiv);
this._textModel.setAttribute(i, "line-div", lineDiv); this._textModel.setAttribute(i, "line-div", lineDiv);
this._textModel.removeAttribute(i, "div-highlighted");
} }
this._container.appendChild(this._sheet); this._container.appendChild(this._sheet);
}, },
...@@ -143,8 +144,8 @@ WebInspector.NativeTextViewer.prototype = { ...@@ -143,8 +144,8 @@ WebInspector.NativeTextViewer.prototype = {
if (lineNumber + 1 < this._textModel.linesCount) { if (lineNumber + 1 < this._textModel.linesCount) {
var nextElement = this._textModel.getAttribute(lineNumber + 1, "line-div"); var nextElement = this._textModel.getAttribute(lineNumber + 1, "line-div");
return nextElement.offsetTop - element.offsetTop; return nextElement.offsetTop - element.offsetTop;
} else }
return element.parentElement.offsetHeight - element.offsetTop; return element.parentElement.offsetHeight - element.offsetTop;
}, },
_paintLine: function(lineNumber, lineOffset) _paintLine: function(lineNumber, lineOffset)
...@@ -213,9 +214,9 @@ WebInspector.NativeTextViewer.prototype = { ...@@ -213,9 +214,9 @@ WebInspector.NativeTextViewer.prototype = {
this.revalidateDecorationsAndPaint(); this.revalidateDecorationsAndPaint();
}, },
_initFontMetrics: function() initFontMetrics: function()
{ {
WebInspector.TextEditor.prototype._initFontMetrics.call(this); WebInspector.TextEditor.prototype.initFontMetrics.call(this);
for (var i = 0; i < this._textModel.linesCount; ++i) { for (var i = 0; i < this._textModel.linesCount; ++i) {
var lineDiv = this._textModel.getAttribute(i, "line-div"); var lineDiv = this._textModel.getAttribute(i, "line-div");
if (!this._textModel.line(i)) if (!this._textModel.line(i))
......
...@@ -144,7 +144,7 @@ WebInspector.SourceFrame.prototype = { ...@@ -144,7 +144,7 @@ WebInspector.SourceFrame.prototype = {
this._element = this._editor.element; this._element = this._editor.element;
this._element.addEventListener("keydown", this._keyDown.bind(this), true); this._element.addEventListener("keydown", this._keyDown.bind(this), true);
this._parentElement.appendChild(this._element); this._parentElement.appendChild(this._element);
this._editor._initFontMetrics(); this._editor.initFontMetrics();
this._editor.mimeType = this._mimeType; this._editor.mimeType = this._mimeType;
......
/* Generated by re2c 0.13.5 on Thu Jan 28 20:49:22 2010 */ /* Generated by re2c 0.13.5 on Mon Feb 1 19:13:12 2010 */
/* /*
* Copyright (C) 2009 Google Inc. All rights reserved. * Copyright (C) 2009 Google Inc. All rights reserved.
* *
...@@ -45,29 +45,30 @@ WebInspector.SourceHTMLTokenizer = function() ...@@ -45,29 +45,30 @@ WebInspector.SourceHTMLTokenizer = function()
{ {
WebInspector.SourceTokenizer.call(this); WebInspector.SourceTokenizer.call(this);
// The order is determined by the generated code.
this._lexConditions = { this._lexConditions = {
INITIAL: 0, INITIAL: 0,
COMMENT: 1, COMMENT: 1,
DSTRING: 2, TAG: 2,
SSTRING: 3 DSTRING: 4,
SSTRING: 5
}; };
this.case_INITIAL = 1000;
this.case_COMMENT = 1001;
this.case_TAG = 1002;
this.case_DSTRING = 1004;
this.case_SSTRING = 1005;
this._parseConditions = { this._parseConditions = {
INITIAL: 0, INITIAL: 0,
TAG: 1, ATTRIBUTE: 1,
ATTRIBUTE: 2, ATTRIBUTE_VALUE: 2,
ATTRIBUTE_VALUE: 3, SCRIPT: 3,
SCRIPT: 4, SCRIPT_ATTRIBUTE: 4,
SCRIPT_ATTRIBUTE: 5, SCRIPT_ATTRIBUTE_VALUE: 5,
SCRIPT_ATTRIBUTE_VALUE: 6, DOCTYPE: 6
DOCTYPE: 7
}; };
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 }; this.initialCondition = { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL };
} }
...@@ -130,9 +131,13 @@ WebInspector.SourceHTMLTokenizer.prototype = { ...@@ -130,9 +131,13 @@ WebInspector.SourceHTMLTokenizer.prototype = {
} }
} else { } else {
if (this.getLexCondition() < 3) { if (this.getLexCondition() < 3) {
{ gotoCase = this.case_DSTRING; continue; }; { gotoCase = this.case_TAG; continue; };
} else { } else {
{ gotoCase = this.case_SSTRING; continue; }; if (this.getLexCondition() < 4) {
{ gotoCase = this.case_DSTRING; continue; };
} else {
{ gotoCase = this.case_SSTRING; continue; };
}
} }
} }
/* *********************************** */ /* *********************************** */
...@@ -214,7 +219,7 @@ case 18: ...@@ -214,7 +219,7 @@ case 18:
case 20: case 20:
++cursor; ++cursor;
case 21: case 21:
this.setLexCondition(this._lexConditions.INITIAL); this.setLexCondition(this._lexConditions.TAG);
{ return this._stringToken(cursor, true); } { return this._stringToken(cursor, true); }
case 22: case 22:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
...@@ -234,353 +239,356 @@ case 24: ...@@ -234,353 +239,356 @@ case 24:
/* *********************************** */ /* *********************************** */
case this.case_INITIAL: case this.case_INITIAL:
yych = this._charAt(cursor); yych = this._charAt(cursor);
if (yych <= '=') { if (yych == '<') { gotoCase = 29; continue; };
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; };
}
}
} 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; };
}
}
}
case 27:
++cursor; ++cursor;
case 28:
{ this.tokenType = null; return cursor; } { this.tokenType = null; return cursor; }
case 29: case 29:
yyaccept = 0; yyaccept = 0;
yych = this._charAt(YYMARKER = ++cursor); 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 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;
}
case 33:
yyaccept = 1;
yych = this._charAt(YYMARKER = ++cursor);
if (yych <= '/') { if (yych <= '/') {
if (yych == '!') { gotoCase = 42; continue; }; if (yych == '!') { gotoCase = 34; continue; };
if (yych >= '/') { gotoCase = 39; continue; }; if (yych >= '/') { gotoCase = 31; continue; };
} else { } else {
if (yych <= 'S') { if (yych <= 'S') {
if (yych >= 'S') { gotoCase = 40; continue; }; if (yych >= 'S') { gotoCase = 32; continue; };
} else { } else {
if (yych == 's') { gotoCase = 40; continue; }; if (yych == 's') { gotoCase = 32; continue; };
} }
} }
case 34: case 30:
{
if (this._parseCondition === this._parseConditions.SCRIPT) {
this.tokenType = null;
return cursor;
}
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) { if (this._parseCondition === this._parseConditions.SCRIPT) {
this.tokenType = null; this.tokenType = null;
return cursor; return cursor;
} }
if (this._parseCondition === this._parseConditions.DOCTYPE) this.setLexCondition(this._lexConditions.TAG);
this.tokenType = "html-doctype";
else
this.tokenType = "html-tag";
if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE) this.tokenType = "html-tag";
this._parseCondition = this._parseConditions.SCRIPT; this._parseCondition = this._parseConditions.INITIAL;
else
this._parseCondition = this._parseConditions.INITIAL;
return cursor; return cursor;
} }
case 39: case 31:
yyaccept = 1; yyaccept = 0;
yych = this._charAt(YYMARKER = ++cursor); yych = this._charAt(YYMARKER = ++cursor);
if (yych == 'S') { gotoCase = 66; continue; }; if (yych == 'S') { gotoCase = 58; continue; };
if (yych == 's') { gotoCase = 66; continue; }; if (yych == 's') { gotoCase = 58; continue; };
{ gotoCase = 34; continue; }; { gotoCase = 30; continue; };
case 40: case 32:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'C') { gotoCase = 60; continue; }; if (yych == 'C') { gotoCase = 52; continue; };
if (yych == 'c') { gotoCase = 60; continue; }; if (yych == 'c') { gotoCase = 52; continue; };
case 41: case 33:
cursor = YYMARKER; cursor = YYMARKER;
if (yyaccept <= 0) { { gotoCase = 30; continue; };
{ gotoCase = 28; continue; }; case 34:
} else {
{ gotoCase = 34; continue; };
}
case 42:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych <= 'C') { if (yych <= 'C') {
if (yych != '-') { gotoCase = 41; continue; }; if (yych != '-') { gotoCase = 33; continue; };
} else { } else {
if (yych <= 'D') { gotoCase = 44; continue; }; if (yych <= 'D') { gotoCase = 36; continue; };
if (yych == 'd') { gotoCase = 44; continue; }; if (yych == 'd') { gotoCase = 36; continue; };
{ gotoCase = 41; continue; }; { gotoCase = 33; continue; };
} }
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == '-') { gotoCase = 52; continue; }; if (yych == '-') { gotoCase = 44; continue; };
{ gotoCase = 41; continue; }; { gotoCase = 33; continue; };
case 44: case 36:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'O') { gotoCase = 45; continue; }; if (yych == 'O') { gotoCase = 37; continue; };
if (yych != 'o') { gotoCase = 41; continue; }; if (yych != 'o') { gotoCase = 33; continue; };
case 45: case 37:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'C') { gotoCase = 46; continue; }; if (yych == 'C') { gotoCase = 38; continue; };
if (yych != 'c') { gotoCase = 41; continue; }; if (yych != 'c') { gotoCase = 33; continue; };
case 46: case 38:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'T') { gotoCase = 47; continue; }; if (yych == 'T') { gotoCase = 39; continue; };
if (yych != 't') { gotoCase = 41; continue; }; if (yych != 't') { gotoCase = 33; continue; };
case 47: case 39:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'Y') { gotoCase = 48; continue; }; if (yych == 'Y') { gotoCase = 40; continue; };
if (yych != 'y') { gotoCase = 41; continue; }; if (yych != 'y') { gotoCase = 33; continue; };
case 48: case 40:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'P') { gotoCase = 49; continue; }; if (yych == 'P') { gotoCase = 41; continue; };
if (yych != 'p') { gotoCase = 41; continue; }; if (yych != 'p') { gotoCase = 33; continue; };
case 49: case 41:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'E') { gotoCase = 50; continue; }; if (yych == 'E') { gotoCase = 42; continue; };
if (yych != 'e') { gotoCase = 41; continue; }; if (yych != 'e') { gotoCase = 33; continue; };
case 50: case 42:
++cursor; ++cursor;
this.setLexCondition(this._lexConditions.TAG);
{ {
this.tokenType = "html-doctype"; this.tokenType = "html-doctype";
this._parseCondition = this._parseConditions.DOCTYPE; this._parseCondition = this._parseConditions.DOCTYPE;
return cursor; return cursor;
} }
case 52: case 44:
++cursor; ++cursor;
yych = this._charAt(cursor); yych = this._charAt(cursor);
if (yych <= '\f') { if (yych <= '\f') {
if (yych == '\n') { gotoCase = 55; continue; }; if (yych == '\n') { gotoCase = 47; continue; };
{ gotoCase = 52; continue; }; { gotoCase = 44; continue; };
} else { } else {
if (yych <= '\r') { gotoCase = 55; continue; }; if (yych <= '\r') { gotoCase = 47; continue; };
if (yych != '-') { gotoCase = 52; continue; }; if (yych != '-') { gotoCase = 44; continue; };
} }
++cursor; ++cursor;
yych = this._charAt(cursor); yych = this._charAt(cursor);
if (yych == '-') { gotoCase = 57; continue; }; if (yych == '-') { gotoCase = 49; continue; };
{ gotoCase = 41; continue; }; { gotoCase = 33; continue; };
case 55: case 47:
++cursor; ++cursor;
this.setLexCondition(this._lexConditions.COMMENT); this.setLexCondition(this._lexConditions.COMMENT);
{ this.tokenType = "html-comment"; return cursor; } { this.tokenType = "html-comment"; return cursor; }
case 57: case 49:
++cursor; ++cursor;
yych = this._charAt(cursor); yych = this._charAt(cursor);
if (yych != '>') { gotoCase = 52; continue; }; if (yych != '>') { gotoCase = 44; continue; };
++cursor; ++cursor;
{ this.tokenType = "html-comment"; return cursor; } { this.tokenType = "html-comment"; return cursor; }
case 60: case 52:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'R') { gotoCase = 61; continue; }; if (yych == 'R') { gotoCase = 53; continue; };
if (yych != 'r') { gotoCase = 41; continue; }; if (yych != 'r') { gotoCase = 33; continue; };
case 61: case 53:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'I') { gotoCase = 62; continue; }; if (yych == 'I') { gotoCase = 54; continue; };
if (yych != 'i') { gotoCase = 41; continue; }; if (yych != 'i') { gotoCase = 33; continue; };
case 62: case 54:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'P') { gotoCase = 63; continue; }; if (yych == 'P') { gotoCase = 55; continue; };
if (yych != 'p') { gotoCase = 41; continue; }; if (yych != 'p') { gotoCase = 33; continue; };
case 63: case 55:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'T') { gotoCase = 64; continue; }; if (yych == 'T') { gotoCase = 56; continue; };
if (yych != 't') { gotoCase = 41; continue; }; if (yych != 't') { gotoCase = 33; continue; };
case 64: case 56:
++cursor; ++cursor;
this.setLexCondition(this._lexConditions.TAG);
{ {
this.tokenType = "html-tag"; this.tokenType = "html-tag";
this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE; this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE;
return cursor; return cursor;
} }
case 66: case 58:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'C') { gotoCase = 67; continue; }; if (yych == 'C') { gotoCase = 59; continue; };
if (yych != 'c') { gotoCase = 41; continue; }; if (yych != 'c') { gotoCase = 33; continue; };
case 67: case 59:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'R') { gotoCase = 68; continue; }; if (yych == 'R') { gotoCase = 60; continue; };
if (yych != 'r') { gotoCase = 41; continue; }; if (yych != 'r') { gotoCase = 33; continue; };
case 68: case 60:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'I') { gotoCase = 69; continue; }; if (yych == 'I') { gotoCase = 61; continue; };
if (yych != 'i') { gotoCase = 41; continue; }; if (yych != 'i') { gotoCase = 33; continue; };
case 69: case 61:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'P') { gotoCase = 70; continue; }; if (yych == 'P') { gotoCase = 62; continue; };
if (yych != 'p') { gotoCase = 41; continue; }; if (yych != 'p') { gotoCase = 33; continue; };
case 70: case 62:
yych = this._charAt(++cursor); yych = this._charAt(++cursor);
if (yych == 'T') { gotoCase = 71; continue; }; if (yych == 'T') { gotoCase = 63; continue; };
if (yych != 't') { gotoCase = 41; continue; }; if (yych != 't') { gotoCase = 33; continue; };
case 71: case 63:
++cursor; ++cursor;
this.setLexCondition(this._lexConditions.TAG);
{ {
this.tokenType = "html-tag"; this.tokenType = "html-tag";
this._parseCondition = this._parseConditions.INITIAL; this._parseCondition = this._parseConditions.INITIAL;
return cursor; return cursor;
} }
/* *********************************** */
case this.case_SSTRING:
yych = this._charAt(cursor);
if (yych <= '\f') {
if (yych == '\n') { gotoCase = 69; continue; };
{ gotoCase = 68; continue; };
} else {
if (yych <= '\r') { gotoCase = 69; continue; };
if (yych == '\'') { gotoCase = 71; continue; };
{ gotoCase = 68; continue; };
}
case 67:
{ return this._stringToken(cursor); }
case 68:
yych = this._charAt(++cursor);
{ gotoCase = 75; continue; };
case 69:
++cursor;
{ this.tokenType = null; return cursor; }
case 71:
++cursor;
case 72:
this.setLexCondition(this._lexConditions.TAG);
{ return this._stringToken(cursor, true); }
case 73: case 73:
yych = this._charAt(++cursor);
{ gotoCase = 72; continue; };
case 74:
++cursor; ++cursor;
yych = this._charAt(cursor); yych = this._charAt(cursor);
case 74: case 75:
if (yych <= '^') { if (yych <= '\f') {
if (yych <= '9') { if (yych == '\n') { gotoCase = 67; continue; };
if (yych <= '/') { gotoCase = 32; continue; }; { gotoCase = 74; continue; };
{ gotoCase = 73; continue; }; } else {
if (yych <= '\r') { gotoCase = 67; continue; };
if (yych == '\'') { gotoCase = 73; continue; };
{ gotoCase = 74; continue; };
}
/* *********************************** */
case this.case_TAG:
yych = this._charAt(cursor);
if (yych <= '=') {
if (yych <= '\'') {
if (yych == '"') { gotoCase = 80; continue; };
if (yych >= '\'') { gotoCase = 81; continue; };
} else { } else {
if (yych <= '@') { gotoCase = 32; continue; }; if (yych <= '/') { gotoCase = 78; continue; };
if (yych <= 'Z') { gotoCase = 73; continue; }; if (yych <= '9') { gotoCase = 82; continue; };
{ gotoCase = 32; continue; }; if (yych >= '=') { gotoCase = 84; continue; };
} }
} else { } else {
if (yych <= '`') { if (yych <= '^') {
if (yych <= '_') { gotoCase = 73; continue; }; if (yych <= '>') { gotoCase = 86; continue; };
{ gotoCase = 32; continue; }; if (yych <= '@') { gotoCase = 78; continue; };
if (yych <= 'Z') { gotoCase = 82; continue; };
} else { } else {
if (yych <= 'z') { gotoCase = 73; continue; }; if (yych <= '`') {
if (yych <= 0x7F) { gotoCase = 32; continue; }; if (yych <= '_') { gotoCase = 82; continue; };
{ gotoCase = 73; continue; }; } else {
if (yych <= 'z') { gotoCase = 82; continue; };
if (yych >= 0x80) { gotoCase = 82; continue; };
}
} }
} }
case 75: case 78:
++cursor;
{ this.tokenType = null; return cursor; }
case 80:
yyaccept = 0;
yych = this._charAt(YYMARKER = ++cursor);
{ gotoCase = 97; continue; };
case 81:
yyaccept = 0;
yych = this._charAt(YYMARKER = ++cursor);
{ gotoCase = 91; continue; };
case 82:
++cursor; ++cursor;
yych = this._charAt(cursor); yych = this._charAt(cursor);
case 76: { gotoCase = 89; continue; };
if (yych <= '\f') { case 83:
if (yych != '\n') { gotoCase = 75; continue; }; {
} else { if (this._parseCondition === this._parseConditions.SCRIPT) {
if (yych <= '\r') { gotoCase = 77; continue; }; this.tokenType = null;
if (yych == '\'') { gotoCase = 79; continue; }; return cursor;
{ gotoCase = 75; continue; }; }
}
case 77: 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";
else
this.tokenType = null;
return cursor;
}
case 84:
++cursor; ++cursor;
this.setLexCondition(this._lexConditions.SSTRING); {
{ return this._stringToken(cursor); } if (this._isAttribute()) {
case 79: this.tokenType = null;
this._setAttributeValue();
} else if (this._parseCondition === this._parseConditions.DOCTYPE)
this.tokenType = "html-doctype";
else
this.tokenType = null;
return cursor;
}
case 86:
++cursor; ++cursor;
{ return this._stringToken(cursor, true); } this.setLexCondition(this._lexConditions.INITIAL);
case 81: {
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 88:
++cursor; ++cursor;
yych = this._charAt(cursor); yych = this._charAt(cursor);
case 82: case 89:
if (yych <= '\f') { if (yych <= '^') {
if (yych != '\n') { gotoCase = 81; continue; }; if (yych <= '9') {
if (yych <= '/') { gotoCase = 83; continue; };
{ gotoCase = 88; continue; };
} else {
if (yych <= '@') { gotoCase = 83; continue; };
if (yych <= 'Z') { gotoCase = 88; continue; };
{ gotoCase = 83; continue; };
}
} else { } else {
if (yych <= '\r') { gotoCase = 83; continue; }; if (yych <= '`') {
if (yych == '"') { gotoCase = 79; continue; }; if (yych <= '_') { gotoCase = 88; continue; };
{ gotoCase = 81; continue; }; { gotoCase = 83; continue; };
} else {
if (yych <= 'z') { gotoCase = 88; continue; };
if (yych <= 0x7F) { gotoCase = 83; continue; };
{ gotoCase = 88; continue; };
}
} }
case 83: case 90:
++cursor; ++cursor;
this.setLexCondition(this._lexConditions.DSTRING);
{ return this._stringToken(cursor); }
/* *********************************** */
case this.case_SSTRING:
yych = this._charAt(cursor); yych = this._charAt(cursor);
case 91:
if (yych <= '\f') { if (yych <= '\f') {
if (yych == '\n') { gotoCase = 89; continue; }; if (yych != '\n') { gotoCase = 90; continue; };
{ gotoCase = 88; continue; };
} else { } else {
if (yych <= '\r') { gotoCase = 89; continue; }; if (yych <= '\r') { gotoCase = 92; continue; };
if (yych == '\'') { gotoCase = 91; continue; }; if (yych == '\'') { gotoCase = 94; continue; };
{ gotoCase = 88; continue; }; { gotoCase = 90; continue; };
} }
case 87: case 92:
{ return this._stringToken(cursor); }
case 88:
yych = this._charAt(++cursor);
{ gotoCase = 95; continue; };
case 89:
++cursor; ++cursor;
{ this.tokenType = null; return cursor; } this.setLexCondition(this._lexConditions.SSTRING);
case 91: { return this._stringToken(cursor); }
case 94:
++cursor; ++cursor;
case 92:
this.setLexCondition(this._lexConditions.INITIAL);
{ return this._stringToken(cursor, true); } { return this._stringToken(cursor, true); }
case 93: case 96:
yych = this._charAt(++cursor);
{ gotoCase = 92; continue; };
case 94:
++cursor; ++cursor;
yych = this._charAt(cursor); yych = this._charAt(cursor);
case 95: case 97:
if (yych <= '\f') { if (yych <= '\f') {
if (yych == '\n') { gotoCase = 87; continue; }; if (yych != '\n') { gotoCase = 96; continue; };
{ gotoCase = 94; continue; };
} else { } else {
if (yych <= '\r') { gotoCase = 87; continue; }; if (yych <= '\r') { gotoCase = 98; continue; };
if (yych == '\'') { gotoCase = 93; continue; }; if (yych == '"') { gotoCase = 94; continue; };
{ gotoCase = 94; continue; }; { gotoCase = 96; continue; };
} }
case 98:
++cursor;
this.setLexCondition(this._lexConditions.DSTRING);
{ return this._stringToken(cursor); }
} }
} }
......
...@@ -44,29 +44,30 @@ WebInspector.SourceHTMLTokenizer = function() ...@@ -44,29 +44,30 @@ WebInspector.SourceHTMLTokenizer = function()
{ {
WebInspector.SourceTokenizer.call(this); WebInspector.SourceTokenizer.call(this);
// The order is determined by the generated code.
this._lexConditions = { this._lexConditions = {
INITIAL: 0, INITIAL: 0,
COMMENT: 1, COMMENT: 1,
DSTRING: 2, TAG: 2,
SSTRING: 3 DSTRING: 4,
SSTRING: 5
}; };
this.case_INITIAL = 1000;
this.case_COMMENT = 1001;
this.case_TAG = 1002;
this.case_DSTRING = 1004;
this.case_SSTRING = 1005;
this._parseConditions = { this._parseConditions = {
INITIAL: 0, INITIAL: 0,
TAG: 1, ATTRIBUTE: 1,
ATTRIBUTE: 2, ATTRIBUTE_VALUE: 2,
ATTRIBUTE_VALUE: 3, SCRIPT: 3,
SCRIPT: 4, SCRIPT_ATTRIBUTE: 4,
SCRIPT_ATTRIBUTE: 5, SCRIPT_ATTRIBUTE_VALUE: 5,
SCRIPT_ATTRIBUTE_VALUE: 6, DOCTYPE: 6
DOCTYPE: 7
}; };
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 }; this.initialCondition = { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL };
} }
...@@ -157,40 +158,43 @@ WebInspector.SourceHTMLTokenizer.prototype = { ...@@ -157,40 +158,43 @@ WebInspector.SourceHTMLTokenizer.prototype = {
<COMMENT> CommentContent => 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; } <COMMENT> CommentEnd => INITIAL { this.tokenType = "html-comment"; return cursor; }
<INITIAL> DocTypeLT => INITIAL <INITIAL> DocTypeLT => TAG
{ {
this.tokenType = "html-doctype"; this.tokenType = "html-doctype";
this._parseCondition = this._parseConditions.DOCTYPE; this._parseCondition = this._parseConditions.DOCTYPE;
return cursor; return cursor;
} }
<INITIAL> ScriptStart => INITIAL <INITIAL> ScriptStart => TAG
{ {
this.tokenType = "html-tag"; this.tokenType = "html-tag";
this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE; this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE;
return cursor; return cursor;
} }
<INITIAL> ScriptEnd => INITIAL <INITIAL> ScriptEnd => TAG
{ {
this.tokenType = "html-tag"; this.tokenType = "html-tag";
this._parseCondition = this._parseConditions.INITIAL; this._parseCondition = this._parseConditions.INITIAL;
return cursor; return cursor;
} }
<INITIAL> LT => INITIAL <INITIAL> LT
{ {
if (this._parseCondition === this._parseConditions.SCRIPT) { if (this._parseCondition === this._parseConditions.SCRIPT) {
this.tokenType = null; this.tokenType = null;
return cursor; return cursor;
} }
// Only make lexer transition if not in script tag.
this.setLexCondition(this._lexConditions.TAG);
this.tokenType = "html-tag"; this.tokenType = "html-tag";
this._parseCondition = this._parseConditions.TAG; this._parseCondition = this._parseConditions.INITIAL;
return cursor; return cursor;
} }
<INITIAL> GT => INITIAL <TAG> GT => INITIAL
{ {
if (this._parseCondition === this._parseConditions.SCRIPT) { if (this._parseCondition === this._parseConditions.SCRIPT) {
this.tokenType = null; this.tokenType = null;
...@@ -209,15 +213,15 @@ WebInspector.SourceHTMLTokenizer.prototype = { ...@@ -209,15 +213,15 @@ WebInspector.SourceHTMLTokenizer.prototype = {
return cursor; return cursor;
} }
<INITIAL> StringLiteral { return this._stringToken(cursor, true); } <TAG> StringLiteral { return this._stringToken(cursor, true); }
<INITIAL> DoubleStringStart => DSTRING { return this._stringToken(cursor); } <TAG> DoubleStringStart => DSTRING { return this._stringToken(cursor); }
<DSTRING> DoubleStringContent => DSTRING { return this._stringToken(cursor); } <DSTRING> DoubleStringContent => DSTRING { return this._stringToken(cursor); }
<DSTRING> DoubleStringEnd => INITIAL { return this._stringToken(cursor, true); } <DSTRING> DoubleStringEnd => TAG { return this._stringToken(cursor, true); }
<INITIAL> SingleStringStart => SSTRING { return this._stringToken(cursor); } <TAG> SingleStringStart => SSTRING { return this._stringToken(cursor); }
<SSTRING> SingleStringContent => 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()) { if (this._isAttribute()) {
this.tokenType = null; this.tokenType = null;
...@@ -229,14 +233,14 @@ WebInspector.SourceHTMLTokenizer.prototype = { ...@@ -229,14 +233,14 @@ WebInspector.SourceHTMLTokenizer.prototype = {
return cursor; return cursor;
} }
<INITIAL> Identifier <TAG> Identifier
{ {
if (this._parseCondition === this._parseConditions.SCRIPT) { if (this._parseCondition === this._parseConditions.SCRIPT) {
this.tokenType = null; this.tokenType = null;
return cursor; return cursor;
} }
if (this._parseCondition === this._parseConditions.TAG) { if (this._parseCondition === this._parseConditions.INITIAL) {
this.tokenType = "html-tag"; this.tokenType = "html-tag";
this._parseCondition = this._parseConditions.ATTRIBUTE; this._parseCondition = this._parseConditions.ATTRIBUTE;
} else if (this._isAttribute()) } else if (this._isAttribute())
......
...@@ -976,7 +976,7 @@ WebInspector.TextEditor.prototype = { ...@@ -976,7 +976,7 @@ WebInspector.TextEditor.prototype = {
this._updateCursor(this._selection.endLine, this._selection.endColumn); this._updateCursor(this._selection.endLine, this._selection.endColumn);
}, },
_initFontMetrics: function() initFontMetrics: function()
{ {
var computedStyle = window.getComputedStyle(this.element); var computedStyle = window.getComputedStyle(this.element);
this._font = computedStyle.fontSize + " " + computedStyle.fontFamily; this._font = computedStyle.fontSize + " " + computedStyle.fontFamily;
...@@ -998,7 +998,6 @@ WebInspector.TextEditor.prototype = { ...@@ -998,7 +998,6 @@ WebInspector.TextEditor.prototype = {
this._shortcuts[WebInspector.KeyboardShortcut.makeKey("d", modifiers.Ctrl | modifiers.Alt)] = this._handleToggleDebugMode.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("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() _handleUndo: function()
......
...@@ -65,3 +65,24 @@ ...@@ -65,3 +65,24 @@
.webkit-javascript-string, .webkit-javascript-regexp { .webkit-javascript-string, .webkit-javascript-regexp {
color: rgb(196, 26, 22); color: rgb(196, 26, 22);
} }
/* Keep this in sync with view-source.css */
.webkit-html-tag {
color: rgb(136, 18, 128);
}
.webkit-html-attr-name {
color: rgb(153, 69, 0);
}
.webkit-html-attr-value {
color: rgb(26, 26, 166);
}
.webkit-html-comment {
color: rgb(35, 110, 37);
}
.webkit-html-doctype {
color: rgb(192, 192, 192);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment