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

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

        Reviewed by Timothy Hatcher.

        Web Inspector: Improve SourceHTMLTokenizer so that it treats script tag well.

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

        * inspector/front-end/SourceHTMLTokenizer.js:
        (WebInspector.SourceHTMLTokenizer):
        (WebInspector.SourceHTMLTokenizer.prototype._isAttribute):
        (WebInspector.SourceHTMLTokenizer.prototype._isAttributeValue):
        (WebInspector.SourceHTMLTokenizer.prototype._setAttributeValue):
        (WebInspector.SourceHTMLTokenizer.prototype._setAttribute):
        (WebInspector.SourceHTMLTokenizer.prototype._stringToken):
        (WebInspector.SourceHTMLTokenizer.prototype.nextToken):
        * inspector/front-end/SourceHTMLTokenizer.re2js:


git-svn-id: svn://svn.chromium.org/blink/trunk@53916 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 1f7675d0
...@@ -2,6 +2,24 @@ ...@@ -2,6 +2,24 @@
Reviewed by Timothy Hatcher. Reviewed by Timothy Hatcher.
Web Inspector: Improve SourceHTMLTokenizer so that it treats script tag well.
https://bugs.webkit.org/show_bug.cgi?id=34177
* inspector/front-end/SourceHTMLTokenizer.js:
(WebInspector.SourceHTMLTokenizer):
(WebInspector.SourceHTMLTokenizer.prototype._isAttribute):
(WebInspector.SourceHTMLTokenizer.prototype._isAttributeValue):
(WebInspector.SourceHTMLTokenizer.prototype._setAttributeValue):
(WebInspector.SourceHTMLTokenizer.prototype._setAttribute):
(WebInspector.SourceHTMLTokenizer.prototype._stringToken):
(WebInspector.SourceHTMLTokenizer.prototype.nextToken):
* inspector/front-end/SourceHTMLTokenizer.re2js:
2010-01-26 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Timothy Hatcher.
Web Inspector: nuke quarantine wrappers. Web Inspector: nuke quarantine wrappers.
https://bugs.webkit.org/show_bug.cgi?id=34203 https://bugs.webkit.org/show_bug.cgi?id=34203
...@@ -56,7 +56,10 @@ WebInspector.SourceHTMLTokenizer = function() ...@@ -56,7 +56,10 @@ WebInspector.SourceHTMLTokenizer = function()
TAG: 1, TAG: 1,
ATTRIBUTE: 2, ATTRIBUTE: 2,
ATTRIBUTE_VALUE: 3, ATTRIBUTE_VALUE: 3,
DOCTYPE: 4 SCRIPT: 4,
SCRIPT_ATTRIBUTE: 5,
SCRIPT_ATTRIBUTE_VALUE: 6,
DOCTYPE: 7
}; };
this.case_INITIAL = 1000; this.case_INITIAL = 1000;
...@@ -68,12 +71,38 @@ WebInspector.SourceHTMLTokenizer = function() ...@@ -68,12 +71,38 @@ WebInspector.SourceHTMLTokenizer = function()
} }
WebInspector.SourceHTMLTokenizer.prototype = { WebInspector.SourceHTMLTokenizer.prototype = {
_isAttribute: function()
{
return this._parseCondition === this._parseConditions.ATTRIBUTE || this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE;
},
_isAttributeValue: function()
{
return this._parseCondition === this._parseConditions.ATTRIBUTE_VALUE || this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE_VALUE;
},
_setAttributeValue: 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;
},
_setAttribute: 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;
},
_stringToken: function(cursor, stringEnds) _stringToken: function(cursor, stringEnds)
{ {
if (this._parseCondition === this._parseConditions.ATTRIBUTE_VALUE) { if (this._isAttributeValue()) {
this.tokenType = "html-attr-value"; this.tokenType = "html-attr-value";
if (stringEnds) if (stringEnds)
this._parseCondition = this._parseConditions.ATTRIBUTE; this._setAttribute();
} else if (this._parseCondition === this._parseConditions.DOCTYPE) } else if (this._parseCondition === this._parseConditions.DOCTYPE)
this.tokenType = "html-doctype"; this.tokenType = "html-doctype";
else else
...@@ -105,13 +134,14 @@ WebInspector.SourceHTMLTokenizer.prototype = { ...@@ -105,13 +134,14 @@ WebInspector.SourceHTMLTokenizer.prototype = {
CommentStart = "<!--" CommentContent [\r\n]; CommentStart = "<!--" CommentContent [\r\n];
CommentEnd = CommentContent "-->"; CommentEnd = CommentContent "-->";
LT = "<" | "</";
DocTypeLT = "<!" [Dd] [Oo] [Cc] [Tt] [Yy] [Pp] [Ee]; DocTypeLT = "<!" [Dd] [Oo] [Cc] [Tt] [Yy] [Pp] [Ee];
ScriptStart = "<" [Ss] [Cc] [Rr] [Ii] [Pp] [Tt];
ScriptEnd = "</" [Ss] [Cc] [Rr] [Ii] [Pp] [Tt];
LT = "<" | "</";
GT = ">"; GT = ">";
EqualSign = "="; EqualSign = "=";
Letter = [_a-zA-Z\x80-\xFF];
DoubleStringContent = [^\r\n\"]*; DoubleStringContent = [^\r\n\"]*;
SingleStringContent = [^\r\n\']*; SingleStringContent = [^\r\n\']*;
StringLiteral = "\"" DoubleStringContent "\"" | "'" SingleStringContent "'"; StringLiteral = "\"" DoubleStringContent "\"" | "'" SingleStringContent "'";
...@@ -120,7 +150,7 @@ WebInspector.SourceHTMLTokenizer.prototype = { ...@@ -120,7 +150,7 @@ WebInspector.SourceHTMLTokenizer.prototype = {
SingleStringStart = "'" SingleStringContent [\r\n]; SingleStringStart = "'" SingleStringContent [\r\n];
SingleStringEnd = SingleStringContent "'"; SingleStringEnd = SingleStringContent "'";
Identifier = Letter+; Identifier = [_a-zA-Z\x80-\xFF]+;
<INITIAL> Comment { this.tokenType = "html-comment"; return cursor; } <INITIAL> Comment { this.tokenType = "html-comment"; return cursor; }
<INITIAL> CommentStart => COMMENT { this.tokenType = "html-comment"; return cursor; } <INITIAL> CommentStart => COMMENT { this.tokenType = "html-comment"; return cursor; }
...@@ -129,14 +159,32 @@ WebInspector.SourceHTMLTokenizer.prototype = { ...@@ -129,14 +159,32 @@ WebInspector.SourceHTMLTokenizer.prototype = {
<INITIAL> DocTypeLT => INITIAL <INITIAL> DocTypeLT => INITIAL
{ {
var token = this._line.substring(cursorOnEnter, cursor);
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
{
this.tokenType = "html-tag";
this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE;
return cursor;
}
<INITIAL> ScriptEnd => INITIAL
{
this.tokenType = "html-tag";
this._parseCondition = this._parseConditions.INITIAL;
return cursor;
}
<INITIAL> LT => INITIAL <INITIAL> LT => INITIAL
{ {
if (this._parseCondition === this._parseConditions.SCRIPT) {
this.tokenType = null;
return cursor;
}
this.tokenType = "html-tag"; this.tokenType = "html-tag";
this._parseCondition = this._parseConditions.TAG; this._parseCondition = this._parseConditions.TAG;
return cursor; return cursor;
...@@ -144,11 +192,20 @@ WebInspector.SourceHTMLTokenizer.prototype = { ...@@ -144,11 +192,20 @@ WebInspector.SourceHTMLTokenizer.prototype = {
<INITIAL> GT => INITIAL <INITIAL> GT => INITIAL
{ {
if (this._parseCondition === this._parseConditions.SCRIPT) {
this.tokenType = null;
return cursor;
}
if (this._parseCondition === this._parseConditions.DOCTYPE) if (this._parseCondition === this._parseConditions.DOCTYPE)
this.tokenType = "html-doctype"; this.tokenType = "html-doctype";
else else
this.tokenType = "html-tag"; this.tokenType = "html-tag";
this._parseCondition = this._parseConditions.INITIAL;
if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE)
this._parseCondition = this._parseConditions.SCRIPT;
else
this._parseCondition = this._parseConditions.INITIAL;
return cursor; return cursor;
} }
...@@ -162,9 +219,9 @@ WebInspector.SourceHTMLTokenizer.prototype = { ...@@ -162,9 +219,9 @@ WebInspector.SourceHTMLTokenizer.prototype = {
<INITIAL> EqualSign => INITIAL <INITIAL> EqualSign => INITIAL
{ {
if (this._parseCondition === this._parseConditions.ATTRIBUTE) { if (this._isAttribute()) {
this.tokenType = null; this.tokenType = null;
this._parseCondition = this._parseConditions.ATTRIBUTE_VALUE; this._setAttributeValue();
} else if (this._parseCondition === this._parseConditions.DOCTYPE) } else if (this._parseCondition === this._parseConditions.DOCTYPE)
this.tokenType = "html-doctype"; this.tokenType = "html-doctype";
else else
...@@ -174,16 +231,19 @@ WebInspector.SourceHTMLTokenizer.prototype = { ...@@ -174,16 +231,19 @@ WebInspector.SourceHTMLTokenizer.prototype = {
<INITIAL> Identifier <INITIAL> Identifier
{ {
if (this._parseCondition === this._parseConditions.SCRIPT) {
this.tokenType = null;
return cursor;
}
if (this._parseCondition === this._parseConditions.TAG) { if (this._parseCondition === this._parseConditions.TAG) {
this.tokenType = "html-tag"; this.tokenType = "html-tag";
this._parseCondition = this._parseConditions.ATTRIBUTE; this._parseCondition = this._parseConditions.ATTRIBUTE;
} else if (this._parseCondition === this._parseConditions.ATTRIBUTE) { } else if (this._isAttribute())
this.tokenType = "html-attr-name"; this.tokenType = "html-attr-name";
this._parseCondition = this._parseConditions.ATTRIBUTE; else if (this._isAttributeValue())
} else if (this._parseCondition === this._parseConditions.ATTRIBUTE_VALUE) {
this.tokenType = "html-attr-value"; this.tokenType = "html-attr-value";
this._parseCondition = this._parseConditions.ATTRIBUTE; else if (this._parseCondition === this._parseConditions.DOCTYPE)
} else if (this._parseCondition === this._parseConditions.DOCTYPE)
this.tokenType = "html-doctype"; this.tokenType = "html-doctype";
else else
this.tokenType = null; this.tokenType = null;
......
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