Changeset 55248 in webkit


Ignore:
Timestamp:
Feb 25, 2010 10:46:18 AM (14 years ago)
Author:
pfeldman@chromium.org
Message:

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

Reviewed by Timothy Hatcher.

Web Inspector: evaluate-on-hover does not work on HTML files.

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

  • inspector/front-end/SourceCSSTokenizer.re2js:
  • inspector/front-end/SourceHTMLTokenizer.js: (WebInspector.SourceHTMLTokenizer): (WebInspector.SourceHTMLTokenizer.prototype.set line): (WebInspector.SourceHTMLTokenizer.prototype._isExpectingAttribute): (WebInspector.SourceHTMLTokenizer.prototype._isExpectingAttributeValue): (WebInspector.SourceHTMLTokenizer.prototype._setExpectingAttribute): (WebInspector.SourceHTMLTokenizer.prototype._setExpectingAttributeValue): (WebInspector.SourceHTMLTokenizer.prototype._attrValueTokenType): (WebInspector.SourceHTMLTokenizer.prototype.nextToken):
  • inspector/front-end/SourceHTMLTokenizer.re2js:
  • inspector/front-end/SourceJavaScriptTokenizer.js: (WebInspector.SourceJavaScriptTokenizer):
  • inspector/front-end/SourceJavaScriptTokenizer.re2js:
  • inspector/front-end/SourceTokenizer.js: (WebInspector.SourceTokenizer.prototype.set condition): (WebInspector.SourceTokenizer.prototype.get condition): (WebInspector.SourceTokenizer.prototype.get subTokenizer): (WebInspector.SourceTokenizer.prototype.getLexCondition): (WebInspector.SourceTokenizer.prototype.setLexCondition):
  • inspector/front-end/TextEditorHighlighter.js: (WebInspector.TextEditorHighlighter): (WebInspector.TextEditorHighlighter.prototype.set mimeType): (WebInspector.TextEditorHighlighter.prototype.highlight): (WebInspector.TextEditorHighlighter.prototype._highlightInChunks): (WebInspector.TextEditorHighlighter.prototype._highlightLines): (WebInspector.TextEditorHighlighter.prototype._highlightLine):
  • inspector/front-end/TextViewer.js: (WebInspector.TextViewer.prototype._paintLine):
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r55230 r55248  
     12010-02-25  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Web Inspector: evaluate-on-hover does not work on HTML files.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=35378
     6
     7        * inspector/syntax-highlight-html-expected.txt:
     8
    192010-02-25  Ben Murdoch  <benm@google.com>
    210
  • trunk/LayoutTests/inspector/syntax-highlight-html-expected.txt

    r54780 r55248  
    77<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">: webkit-html-doctype,webkit-html-doctype,webkit-html-doctype
    88<!--div><div foobar-->: webkit-html-comment
    9 <script></script><!--div-->: webkit-html-tag,*,webkit-html-tag,webkit-html-tag,webkit-html-comment
    10 <script type="text/javascript">document.write('<script type="text/javascript"></' + 'script>');</script>: webkit-html-tag,*,webkit-html-attribute-name,*,webkit-html-attribute-value,*,webkit-html-tag,webkit-html-tag
     9<script></script><!--div-->: webkit-html-tag,webkit-html-tag,webkit-html-tag,webkit-html-tag,webkit-html-comment
     10<script type="text/javascript">document.write('<script type="text/javascript"></' + 'script>');</script>: webkit-html-tag,*,webkit-html-attribute-name,*,webkit-html-attribute-value,webkit-html-tag,webkit-javascript-ident,*,webkit-javascript-ident,*,webkit-javascript-string,*,webkit-javascript-string,*,webkit-html-tag,webkit-html-tag
    1111
  • trunk/WebCore/ChangeLog

    r55244 r55248  
     12010-02-25  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Web Inspector: evaluate-on-hover does not work on HTML files.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=35378
     8
     9        * inspector/front-end/SourceCSSTokenizer.re2js:
     10        * inspector/front-end/SourceHTMLTokenizer.js:
     11        (WebInspector.SourceHTMLTokenizer):
     12        (WebInspector.SourceHTMLTokenizer.prototype.set line):
     13        (WebInspector.SourceHTMLTokenizer.prototype._isExpectingAttribute):
     14        (WebInspector.SourceHTMLTokenizer.prototype._isExpectingAttributeValue):
     15        (WebInspector.SourceHTMLTokenizer.prototype._setExpectingAttribute):
     16        (WebInspector.SourceHTMLTokenizer.prototype._setExpectingAttributeValue):
     17        (WebInspector.SourceHTMLTokenizer.prototype._attrValueTokenType):
     18        (WebInspector.SourceHTMLTokenizer.prototype.nextToken):
     19        * inspector/front-end/SourceHTMLTokenizer.re2js:
     20        * inspector/front-end/SourceJavaScriptTokenizer.js:
     21        (WebInspector.SourceJavaScriptTokenizer):
     22        * inspector/front-end/SourceJavaScriptTokenizer.re2js:
     23        * inspector/front-end/SourceTokenizer.js:
     24        (WebInspector.SourceTokenizer.prototype.set condition):
     25        (WebInspector.SourceTokenizer.prototype.get condition):
     26        (WebInspector.SourceTokenizer.prototype.get subTokenizer):
     27        (WebInspector.SourceTokenizer.prototype.getLexCondition):
     28        (WebInspector.SourceTokenizer.prototype.setLexCondition):
     29        * inspector/front-end/TextEditorHighlighter.js:
     30        (WebInspector.TextEditorHighlighter):
     31        (WebInspector.TextEditorHighlighter.prototype.set mimeType):
     32        (WebInspector.TextEditorHighlighter.prototype.highlight):
     33        (WebInspector.TextEditorHighlighter.prototype._highlightInChunks):
     34        (WebInspector.TextEditorHighlighter.prototype._highlightLines):
     35        (WebInspector.TextEditorHighlighter.prototype._highlightLine):
     36        * inspector/front-end/TextViewer.js:
     37        (WebInspector.TextViewer.prototype._paintLine):
     38
    1392010-02-25  Xan Lopez  <xlopez@igalia.com>
    240
  • trunk/WebCore/inspector/front-end/SourceCSSTokenizer.js

    r54053 r55248  
    1 /* Generated by re2c 0.13.5 on Thu Jan 28 20:49:22 2010 */
     1/* Generated by re2c 0.13.5 on Thu Feb 25 21:44:55 2010 */
    22/*
    33 * Copyright (C) 2009 Google Inc. All rights reserved.
     
    100100    this._valueKeywords = [
    101101        "above", "absolute", "activeborder", "activecaption", "afar", "after-white-space", "ahead", "alias", "all", "all-scroll",
    102         "alternate", "always","amharic", "amharic-abegede", "antialiased", "appworkspace", "aqua", "armenian", "auto", "avoid",
    103         "background", "backwards", "baseline", "below", "bidi-override", "black", "blink", "block", "block-axis", "blue", "bold",
    104         "bolder", "border", "border-box", "both", "bottom", "break-all", "break-word", "button", "button-bevel", "buttonface",
    105         "buttonhighlight", "buttonshadow", "buttontext", "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret", "cell",
    106         "center", "checkbox", "circle", "cjk-earthly-branch", "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
    107         "col-resize", "collapse", "compact", "condensed", "contain", "content", "content-box", "context-menu", "continuous", "copy",
    108         "cover", "crop", "cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal", "decimal-leading-zero", "default",
    109         "default-button", "destination-atop", "destination-in", "destination-out", "destination-over", "disc", "discard", "document",
     102        "alternate", "always","amharic", "amharic-abegede", "antialiased", "appworkspace", "aqua", "arabic-indic", "armenian",
     103        "auto", "avoid", "background", "backwards", "baseline", "below", "bidi-override", "binary", "bengali", "black", "blink",
     104        "block", "block-axis", "blue", "bold", "bolder", "border", "border-box", "both", "bottom", "break-all", "break-word", "button",
     105        "button-bevel", "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian", "capitalize", "caps-lock-indicator",
     106        "caption", "captiontext", "caret", "cell", "center", "checkbox", "circle", "cjk-earthly-branch", "cjk-heavenly-stem", "cjk-ideographic",
     107        "clear", "clip", "close-quote", "col-resize", "collapse", "compact", "condensed", "contain", "content", "content-box", "context-menu",
     108        "continuous", "copy", "cover", "crop", "cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal", "decimal-leading-zero", "default",
     109        "default-button", "destination-atop", "destination-in", "destination-out", "destination-over", "devanagari", "disc", "discard", "document",
    110110        "dot-dash", "dot-dot-dash", "dotted", "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out", "element",
    111111        "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede", "ethiopic-abegede-am-et", "ethiopic-abegede-gez",
     
    114114        "ethiopic-halehame-so-et", "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig", "ew-resize", "expanded",
    115115        "extra-condensed", "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "forwards", "from", "fuchsia", "geometricPrecision",
    116         "georgian", "gray", "graytext", "green", "grey", "groove", "hand", "hangul", "hangul-consonant", "hebrew", "help", "hidden", "hide",
    117         "higher", "highlight", "highlighttext", "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore",
     116        "georgian", "gray", "graytext", "green", "grey", "groove", "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew", "help",
     117        "hidden", "hide", "higher", "highlight", "highlighttext", "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore",
    118118        "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", "infobackground", "infotext", "inherit", "initial", "inline",
    119         "inline-axis", "inline-block", "inline-table", "inset", "inside", "intrinsic", "invert", "italic", "justify", "katakana",
    120         "katakana-iroha", "landscape", "large", "larger", "left", "level", "lighter", "lime", "line-through", "linear", "lines",
    121         "list-button", "list-item", "listbox", "listitem", "local", "logical", "loud", "lower", "lower-alpha", "lower-greek", "lower-latin",
    122         "lower-norwegian", "lower-roman", "lowercase", "ltr", "maroon", "match", "media-controls-background", "media-current-time-display",
     119        "inline-axis", "inline-block", "inline-table", "inset", "inside", "intrinsic", "invert", "italic", "justify", "kannada", "katakana",
     120        "katakana-iroha", "khmer", "landscape", "lao", "large", "larger", "left", "level", "lighter", "lime", "line-through", "linear", "lines",
     121        "list-button", "list-item", "listbox", "listitem", "local", "logical", "loud", "lower", "lower-alpha", "lower-greek", "lower-hexadecimal", "lower-latin",
     122        "lower-norwegian", "lower-roman", "lowercase", "ltr", "malayalam", "maroon", "match", "media-controls-background", "media-current-time-display",
    123123        "media-fullscreen-button", "media-mute-button", "media-play-button", "media-return-to-realtime-button", "media-rewind-button",
    124124        "media-seek-back-button", "media-seek-forward-button", "media-slider", "media-sliderthumb", "media-time-remaining-display",
    125125        "media-volume-slider", "media-volume-slider-container", "media-volume-sliderthumb", "medium", "menu", "menulist", "menulist-button",
    126         "menulist-text", "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic", "mix", "monospace", "move", "multiple",
    127         "n-resize", "narrower", "navy", "ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none",
    128         "normal", "not-allowed", "nowrap", "ns-resize", "nw-resize", "nwse-resize", "oblique", "olive", "open-quote", "optimizeLegibility",
    129         "optimizeSpeed", "orange", "oromo", "outset", "outside", "overlay", "overline", "padding", "padding-box", "painted", "paused",
    130         "plus-darker", "plus-lighter", "pointer", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "purple",
     126        "menulist-text", "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic", "mix", "mongolian", "monospace", "move", "multiple",
     127        "myanmar", "n-resize", "narrower", "navy", "ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none",
     128        "normal", "not-allowed", "nowrap", "ns-resize", "nw-resize", "nwse-resize", "oblique", "octal", "olive", "open-quote", "optimizeLegibility",
     129        "optimizeSpeed", "orange", "oriya", "oromo", "outset", "outside", "overlay", "overline", "padding", "padding-box", "painted", "paused",
     130        "persian", "plus-darker", "plus-lighter", "pointer", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "purple",
    131131        "push-button", "radio", "read-only", "read-write", "read-write-plaintext-only", "red", "relative", "repeat", "repeat-x",
    132132        "repeat-y", "reset", "reverse", "rgb", "rgba", "ridge", "right", "round", "row-resize", "rtl", "run-in", "running", "s-resize", "sans-serif",
     
    137137        "space", "square", "square-button", "start", "static", "status-bar", "stretch", "stroke", "sub", "subpixel-antialiased", "super",
    138138        "sw-resize", "table", "table-caption", "table-cell", "table-column", "table-column-group", "table-footer-group", "table-header-group",
    139         "table-row", "table-row-group", "teal", "text", "text-bottom", "text-top", "textarea", "textfield", "thick", "thin", "threeddarkshadow",
    140         "threedface", "threedhighlight", "threedlightshadow", "threedshadow", "tigre", "tigrinya-er", "tigrinya-er-abegede", "tigrinya-et",
    141         "tigrinya-et-abegede", "to", "top", "transparent", "ultra-condensed", "ultra-expanded", "underline", "up", "upper-alpha", "upper-greek",
    142         "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "url", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
    143         "visibleStroke", "visual", "w-resize", "wait", "wave", "white", "wider", "window", "windowframe", "windowtext", "x-large", "x-small",
    144         "xor", "xx-large", "xx-small", "yellow", "-wap-marquee", "-webkit-activelink", "-webkit-auto", "-webkit-baseline-middle", "-webkit-body",
    145         "-webkit-box", "-webkit-center", "-webkit-control", "-webkit-focus-ring-color", "-webkit-grab", "-webkit-grabbing", "-webkit-gradient", "-webkit-inline-box",
    146         "-webkit-left", "-webkit-link", "-webkit-marquee", "-webkit-mini-control", "-webkit-nowrap", "-webkit-right", "-webkit-small-control",
    147         "-webkit-text", "-webkit-xxx-large", "-webkit-zoom-in", "-webkit-zoom-out",
     139        "table-row", "table-row-group", "teal", "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai", "thick", "thin",
     140        "threeddarkshadow", "threedface", "threedhighlight", "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er", "tigrinya-er-abegede",
     141        "tigrinya-et", "tigrinya-et-abegede", "to", "top", "transparent", "ultra-condensed", "ultra-expanded", "underline", "up", "upper-alpha", "upper-greek",
     142        "upper-hexadecimal", "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url", "vertical", "vertical-text", "visible",
     143        "visibleFill", "visiblePainted", "visibleStroke", "visual", "w-resize", "wait", "wave", "white", "wider", "window", "windowframe", "windowtext",
     144        "x-large", "x-small", "xor", "xx-large", "xx-small", "yellow", "-wap-marquee", "-webkit-activelink", "-webkit-auto", "-webkit-baseline-middle",
     145        "-webkit-body", "-webkit-box", "-webkit-center", "-webkit-control", "-webkit-focus-ring-color", "-webkit-grab", "-webkit-grabbing",
     146        "-webkit-gradient", "-webkit-inline-box", "-webkit-left", "-webkit-link", "-webkit-marquee", "-webkit-mini-control", "-webkit-nowrap", "-webkit-right",
     147        "-webkit-small-control", "-webkit-text", "-webkit-xxx-large", "-webkit-zoom-in", "-webkit-zoom-out",
    148148    ].keySet();
    149149
     
    184184    _isPropertyValue: function()
    185185    {
    186         return this._parseCondition === this._parseConditions.PROPERTY_VALUE || this._parseCondition === this._parseConditions.AT_RULE;
     186        return this._condition.parseCondition === this._parseConditions.PROPERTY_VALUE || this._condition.parseCondition === this._parseConditions.AT_RULE;
    187187    },
    188188
     
    424424            {
    425425                    var token = this._line.substring(cursorOnEnter, cursor);
    426                     if (this._parseCondition === this._parseConditions.INITIAL) {
     426                    if (this._condition.parseCondition === this._parseConditions.INITIAL) {
    427427                        if (token === "@import" || token === "@media") {
    428428                            this.tokenType = "css-at-rule";
    429                             this._parseCondition = this._parseConditions.AT_RULE;
     429                            this._condition.parseCondition = this._parseConditions.AT_RULE;
    430430                        } else if (token.indexOf("@") === 0)
    431431                            this.tokenType = "css-at-rule";
     
    433433                            this.tokenType = "css-selector";
    434434                    }
    435                     else if (this._parseCondition === this._parseConditions.AT_RULE && token in this._mediaTypes)
     435                    else if (this._condition.parseCondition === this._parseConditions.AT_RULE && token in this._mediaTypes)
    436436                        this.tokenType = "css-keyword";
    437                     else if (this._parseCondition === this._parseConditions.PROPERTY && token in this._propertyKeywords)
     437                    else if (this._condition.parseCondition === this._parseConditions.PROPERTY && token in this._propertyKeywords)
    438438                        this.tokenType = "css-property";
    439439                    else if (this._isPropertyValue() && token in this._valueKeywords)
     
    648648            {
    649649                    this.tokenType = null;
    650                     if (this._parseCondition === this._parseConditions.PROPERTY)
    651                         this._parseCondition = this._parseConditions.PROPERTY_VALUE;
     650                    if (this._condition.parseCondition === this._parseConditions.PROPERTY)
     651                        this._condition.parseCondition = this._parseConditions.PROPERTY_VALUE;
    652652                    return cursor;
    653653                }
     
    656656            {
    657657                    this.tokenType = null;
    658                     if (this._parseCondition === this._parseConditions.AT_RULE)
    659                         this._parseCondition = this._parseConditions.INITIAL;
     658                    if (this._condition.parseCondition === this._parseConditions.AT_RULE)
     659                        this._condition.parseCondition = this._parseConditions.INITIAL;
    660660                    else
    661                         this._parseCondition = this._parseConditions.PROPERTY;
     661                        this._condition.parseCondition = this._parseConditions.PROPERTY;
    662662                    return cursor;
    663663                }
     
    666666            {
    667667                    this.tokenType = null;
    668                     if (this._parseCondition === this._parseConditions.AT_RULE)
    669                         this._parseCondition = this._parseConditions.INITIAL;
     668                    if (this._condition.parseCondition === this._parseConditions.AT_RULE)
     669                        this._condition.parseCondition = this._parseConditions.INITIAL;
    670670                    else
    671                         this._parseCondition = this._parseConditions.PROPERTY;
     671                        this._condition.parseCondition = this._parseConditions.PROPERTY;
    672672                    return cursor;
    673673                }
     
    676676            {
    677677                    this.tokenType = null;
    678                     this._parseCondition = this._parseConditions.INITIAL;
     678                    this._condition.parseCondition = this._parseConditions.INITIAL;
    679679                    return cursor;
    680680                }
  • trunk/WebCore/inspector/front-end/SourceCSSTokenizer.re2js

    r54472 r55248  
    183183    _isPropertyValue: function()
    184184    {
    185         return this._parseCondition === this._parseConditions.PROPERTY_VALUE || this._parseCondition === this._parseConditions.AT_RULE;
     185        return this._condition.parseCondition === this._parseConditions.PROPERTY_VALUE || this._condition.parseCondition === this._parseConditions.AT_RULE;
    186186    },
    187187
     
    245245                {
    246246                    this.tokenType = null;
    247                     if (this._parseCondition === this._parseConditions.AT_RULE)
    248                         this._parseCondition = this._parseConditions.INITIAL;
     247                    if (this._condition.parseCondition === this._parseConditions.AT_RULE)
     248                        this._condition.parseCondition = this._parseConditions.INITIAL;
    249249                    else
    250                         this._parseCondition = this._parseConditions.PROPERTY;
     250                        this._condition.parseCondition = this._parseConditions.PROPERTY;
    251251                    return cursor;
    252252                }
     
    255255                {
    256256                    this.tokenType = null;
    257                     this._parseCondition = this._parseConditions.INITIAL;
     257                    this._condition.parseCondition = this._parseConditions.INITIAL;
    258258                    return cursor;
    259259                }
     
    262262                {
    263263                    this.tokenType = null;
    264                     if (this._parseCondition === this._parseConditions.PROPERTY)
    265                         this._parseCondition = this._parseConditions.PROPERTY_VALUE;
     264                    if (this._condition.parseCondition === this._parseConditions.PROPERTY)
     265                        this._condition.parseCondition = this._parseConditions.PROPERTY_VALUE;
    266266                    return cursor;
    267267                }
     
    270270                {
    271271                    this.tokenType = null;
    272                     if (this._parseCondition === this._parseConditions.AT_RULE)
    273                         this._parseCondition = this._parseConditions.INITIAL;
     272                    if (this._condition.parseCondition === this._parseConditions.AT_RULE)
     273                        this._condition.parseCondition = this._parseConditions.INITIAL;
    274274                    else
    275                         this._parseCondition = this._parseConditions.PROPERTY;
     275                        this._condition.parseCondition = this._parseConditions.PROPERTY;
    276276                    return cursor;
    277277                }
     
    289289                {
    290290                    var token = this._line.substring(cursorOnEnter, cursor);
    291                     if (this._parseCondition === this._parseConditions.INITIAL) {
     291                    if (this._condition.parseCondition === this._parseConditions.INITIAL) {
    292292                        if (token === "@import" || token === "@media") {
    293293                            this.tokenType = "css-at-rule";
    294                             this._parseCondition = this._parseConditions.AT_RULE;
     294                            this._condition.parseCondition = this._parseConditions.AT_RULE;
    295295                        } else if (token.indexOf("@") === 0)
    296296                            this.tokenType = "css-at-rule";
     
    298298                            this.tokenType = "css-selector";
    299299                    }
    300                     else if (this._parseCondition === this._parseConditions.AT_RULE && token in this._mediaTypes)
     300                    else if (this._condition.parseCondition === this._parseConditions.AT_RULE && token in this._mediaTypes)
    301301                        this.tokenType = "css-keyword";
    302                     else if (this._parseCondition === this._parseConditions.PROPERTY && token in this._propertyKeywords)
     302                    else if (this._condition.parseCondition === this._parseConditions.PROPERTY && token in this._propertyKeywords)
    303303                        this.tokenType = "css-property";
    304304                    else if (this._isPropertyValue() && token in this._valueKeywords)
  • trunk/WebCore/inspector/front-end/SourceHTMLTokenizer.js

    r54780 r55248  
    1 /* Generated by re2c 0.13.5 on Mon Feb 15 19:30:21 2010 */
     1/* Generated by re2c 0.13.5 on Thu Feb 25 21:44:55 2010 */
    22/*
    33 * Copyright (C) 2009 Google Inc. All rights reserved.
     
    7272
    7373    this.initialCondition = { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL };
     74    this.condition = this.initialCondition;
    7475}
    7576
    7677WebInspector.SourceHTMLTokenizer.prototype = {
     78    set line(line) {
     79        if (this._internalJavaScriptTokenizer) {
     80            var match = /<\/script/i.exec(line);
     81            if (match) {
     82                this._internalJavaScriptTokenizer.line = line.substring(0, match.index);
     83            } else
     84                this._internalJavaScriptTokenizer.line = line;
     85        }
     86        this._line = line;
     87    },
     88
    7789    _isExpectingAttribute: function()
    7890    {
    79         return this._parseCondition & this._parseConditions.ATTRIBUTE;
     91        return this._condition.parseCondition & this._parseConditions.ATTRIBUTE;
    8092    },
    8193
    8294    _isExpectingAttributeValue: function()
    8395    {
    84         return this._parseCondition & this._parseConditions.ATTRIBUTE_VALUE;
     96        return this._condition.parseCondition & this._parseConditions.ATTRIBUTE_VALUE;
    8597    },
    8698
     
    88100    {
    89101        if (this._isExpectingAttributeValue())
    90             this._parseCondition ^= this._parseConditions.ATTRIBUTE_VALUE;
    91         this._parseCondition |= this._parseConditions.ATTRIBUTE;
     102            this._condition.parseCondition ^= this._parseConditions.ATTRIBUTE_VALUE;
     103        this._condition.parseCondition |= this._parseConditions.ATTRIBUTE;
    92104    },
    93105
     
    95107    {
    96108        if (this._isExpectingAttribute())
    97             this._parseCondition ^= this._parseConditions.ATTRIBUTE;
    98         this._parseCondition |= this._parseConditions.ATTRIBUTE_VALUE;
     109            this._condition.parseCondition ^= this._parseConditions.ATTRIBUTE;
     110        this._condition.parseCondition |= this._parseConditions.ATTRIBUTE_VALUE;
    99111    },
    100112
     
    113125    _attrValueTokenType: function()
    114126    {
    115         if (this._parseCondition & this._parseConditions.LINKIFY) {
    116             if (this._parseCondition & this._parseConditions.A_NODE)
     127        if (this._condition.parseCondition & this._parseConditions.LINKIFY) {
     128            if (this._condition.parseCondition & this._parseConditions.A_NODE)
    117129                return "html-external-link";
    118130            return "html-resource-link";
     
    123135    nextToken: function(cursor)
    124136    {
     137        if (this._internalJavaScriptTokenizer) {
     138            // Re-set line to force </script> detection first.
     139            this.line = this._line;
     140            if (cursor !== this._internalJavaScriptTokenizer._line.length) {
     141                // Tokenizer is stateless, so restore its condition before tokenizing and save it after.
     142                this._internalJavaScriptTokenizer.condition = this._condition.internalJavaScriptTokenizerCondition;
     143                var result = this._internalJavaScriptTokenizer.nextToken(cursor);
     144                this.tokenType = this._internalJavaScriptTokenizer.tokenType;
     145                this._condition.internalJavaScriptTokenizerCondition = this._internalJavaScriptTokenizer.condition;
     146                return result;
     147            } else if (cursor !== this._line.length)
     148                delete this._internalJavaScriptTokenizer;
     149        }
     150
    125151        var cursorOnEnter = cursor;
    126152        var gotoCase = 1;
     
    306332            this.setLexCondition(this._lexConditions.TAG);
    307333            {
    308                     if (this._parseCondition & this._parseConditions.SCRIPT) {
     334                    if (this._condition.parseCondition & this._parseConditions.SCRIPT) {
    309335                        // Do not tokenize script tag contents, keep lexer state although processing "<".
    310336                        this.setLexCondition(this._lexConditions.INITIAL);
     
    313339                    }
    314340
    315                     this._parseCondition = this._parseConditions.INITIAL;
     341                    this._condition.parseCondition = this._parseConditions.INITIAL;
    316342                    this.tokenType = "html-tag";
    317343                    return cursor;
     
    414440            this.setLexCondition(this._lexConditions.TAG);
    415441            {
    416                     if (this._parseCondition & this._parseConditions.SCRIPT) {
     442                    if (this._condition.parseCondition & this._parseConditions.SCRIPT) {
    417443                        // Do not tokenize script tag contents, keep lexer state although processing "<".
    418444                        this.setLexCondition(this._lexConditions.INITIAL);
     
    421447                    }
    422448                    this.tokenType = "html-tag";
    423                     this._parseCondition = this._parseConditions.SCRIPT;
     449                    this._condition.parseCondition = this._parseConditions.SCRIPT;
    424450                    this._setExpectingAttribute();
    425451                    return cursor;
     
    450476            {
    451477                    this.tokenType = "html-tag";
    452                     this._parseCondition = this._parseConditions.INITIAL;
     478                    this._condition.parseCondition = this._parseConditions.INITIAL;
    453479                    return cursor;
    454480                }
     
    528554case 89:
    529555            {
    530                     if (this._parseCondition === this._parseConditions.SCRIPT) {
     556                    if (this._condition.parseCondition === this._parseConditions.SCRIPT) {
    531557                        // Fall through if expecting attributes.
    532558                        this.tokenType = null;
     
    534560                    }
    535561
    536                     if (this._parseCondition === this._parseConditions.INITIAL) {
     562                    if (this._condition.parseCondition === this._parseConditions.INITIAL) {
    537563                        this.tokenType = "html-tag";
    538564                        this._setExpectingAttribute();
    539565                        var token = this._line.substring(cursorOnEnter, cursor);
    540566                        if (token === "a")
    541                             this._parseCondition |= this._parseConditions.A_NODE;
    542                         else if (this._parseCondition & this._parseConditions.A_NODE)
    543                             this._parseCondition ^= this._parseConditions.A_NODE;
     567                            this._condition.parseCondition |= this._parseConditions.A_NODE;
     568                        else if (this._condition.parseCondition & this._parseConditions.A_NODE)
     569                            this._condition.parseCondition ^= this._parseConditions.A_NODE;
    544570                    } else if (this._isExpectingAttribute()) {
    545571                        var token = this._line.substring(cursorOnEnter, cursor);
    546572                        if (token === "href" || token === "src")
    547                             this._parseCondition |= this._parseConditions.LINKIFY;
    548                         else if (this._parseCondition |= this._parseConditions.LINKIFY)
    549                             this._parseCondition ^= this._parseConditions.LINKIFY;
     573                            this._condition.parseCondition |= this._parseConditions.LINKIFY;
     574                        else if (this._condition.parseCondition |= this._parseConditions.LINKIFY)
     575                            this._condition.parseCondition ^= this._parseConditions.LINKIFY;
    550576                        this.tokenType = "html-attribute-name";
    551577                    } else if (this._isExpectingAttributeValue())
     
    578604            this.setLexCondition(this._lexConditions.INITIAL);
    579605            {
    580                     if (this._parseCondition & this._parseConditions.SCRIPT) {
     606                    this.tokenType = "html-tag";
     607                    if (this._condition.parseCondition & this._parseConditions.SCRIPT) {
     608                        if (!this._internalJavaScriptTokenizer) {
     609                            this._internalJavaScriptTokenizer = WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/javascript");
     610                            this._condition.internalJavaScriptTokenizerCondition = this._internalJavaScriptTokenizer.initialCondition;
     611                        }
    581612                        // Do not tokenize script tag contents.
    582                         this.tokenType = null;
    583613                        return cursor;
    584614                    }
    585615
    586                     this._parseCondition = this._parseConditions.INITIAL;
    587                     this.tokenType = "html-tag";
     616                    this._condition.parseCondition = this._parseConditions.INITIAL;
    588617                    return cursor;
    589618                }
  • trunk/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js

    r54780 r55248  
    7171
    7272    this.initialCondition = { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL };
     73    this.condition = this.initialCondition;
    7374}
    7475
    7576WebInspector.SourceHTMLTokenizer.prototype = {
     77    set line(line) {
     78        if (this._internalJavaScriptTokenizer) {
     79            var match = /<\/script/i.exec(line);
     80            if (match) {
     81                this._internalJavaScriptTokenizer.line = line.substring(0, match.index);
     82            } else
     83                this._internalJavaScriptTokenizer.line = line;
     84        }
     85        this._line = line;
     86    },
     87
    7688    _isExpectingAttribute: function()
    7789    {
    78         return this._parseCondition & this._parseConditions.ATTRIBUTE;
     90        return this._condition.parseCondition & this._parseConditions.ATTRIBUTE;
    7991    },
    8092
    8193    _isExpectingAttributeValue: function()
    8294    {
    83         return this._parseCondition & this._parseConditions.ATTRIBUTE_VALUE;
     95        return this._condition.parseCondition & this._parseConditions.ATTRIBUTE_VALUE;
    8496    },
    8597
     
    8799    {
    88100        if (this._isExpectingAttributeValue())
    89             this._parseCondition ^= this._parseConditions.ATTRIBUTE_VALUE;
    90         this._parseCondition |= this._parseConditions.ATTRIBUTE;
     101            this._condition.parseCondition ^= this._parseConditions.ATTRIBUTE_VALUE;
     102        this._condition.parseCondition |= this._parseConditions.ATTRIBUTE;
    91103    },
    92104
     
    94106    {
    95107        if (this._isExpectingAttribute())
    96             this._parseCondition ^= this._parseConditions.ATTRIBUTE;
    97         this._parseCondition |= this._parseConditions.ATTRIBUTE_VALUE;
     108            this._condition.parseCondition ^= this._parseConditions.ATTRIBUTE;
     109        this._condition.parseCondition |= this._parseConditions.ATTRIBUTE_VALUE;
    98110    },
    99111
     
    112124    _attrValueTokenType: function()
    113125    {
    114         if (this._parseCondition & this._parseConditions.LINKIFY) {
    115             if (this._parseCondition & this._parseConditions.A_NODE)
     126        if (this._condition.parseCondition & this._parseConditions.LINKIFY) {
     127            if (this._condition.parseCondition & this._parseConditions.A_NODE)
    116128                return "html-external-link";
    117129            return "html-resource-link";
     
    122134    nextToken: function(cursor)
    123135    {
     136        if (this._internalJavaScriptTokenizer) {
     137            // Re-set line to force </script> detection first.
     138            this.line = this._line;
     139            if (cursor !== this._internalJavaScriptTokenizer._line.length) {
     140                // Tokenizer is stateless, so restore its condition before tokenizing and save it after.
     141                this._internalJavaScriptTokenizer.condition = this._condition.internalJavaScriptTokenizerCondition;
     142                var result = this._internalJavaScriptTokenizer.nextToken(cursor);
     143                this.tokenType = this._internalJavaScriptTokenizer.tokenType;
     144                this._condition.internalJavaScriptTokenizerCondition = this._internalJavaScriptTokenizer.condition;
     145                return result;
     146            } else if (cursor !== this._line.length)
     147                delete this._internalJavaScriptTokenizer;
     148        }
     149
    124150        var cursorOnEnter = cursor;
    125151        var gotoCase = 1;
     
    175201                <INITIAL> ScriptStart => TAG
    176202                {
    177                     if (this._parseCondition & this._parseConditions.SCRIPT) {
     203                    if (this._condition.parseCondition & this._parseConditions.SCRIPT) {
    178204                        // Do not tokenize script tag contents, keep lexer state although processing "<".
    179205                        this.setLexCondition(this._lexConditions.INITIAL);
     
    182208                    }
    183209                    this.tokenType = "html-tag";
    184                     this._parseCondition = this._parseConditions.SCRIPT;
     210                    this._condition.parseCondition = this._parseConditions.SCRIPT;
    185211                    this._setExpectingAttribute();
    186212                    return cursor;
     
    190216                {
    191217                    this.tokenType = "html-tag";
    192                     this._parseCondition = this._parseConditions.INITIAL;
     218                    this._condition.parseCondition = this._parseConditions.INITIAL;
    193219                    return cursor;
    194220                }
     
    196222                <INITIAL> LT => TAG
    197223                {
    198                     if (this._parseCondition & this._parseConditions.SCRIPT) {
     224                    if (this._condition.parseCondition & this._parseConditions.SCRIPT) {
    199225                        // Do not tokenize script tag contents, keep lexer state although processing "<".
    200226                        this.setLexCondition(this._lexConditions.INITIAL);
     
    203229                    }
    204230
    205                     this._parseCondition = this._parseConditions.INITIAL;
     231                    this._condition.parseCondition = this._parseConditions.INITIAL;
    206232                    this.tokenType = "html-tag";
    207233                    return cursor;
    208234                }
    209 
     235 
    210236                <TAG> GT => INITIAL
    211237                {
    212                     if (this._parseCondition & this._parseConditions.SCRIPT) {
     238                    this.tokenType = "html-tag";
     239                    if (this._condition.parseCondition & this._parseConditions.SCRIPT) {
     240                        if (!this._internalJavaScriptTokenizer) {
     241                            this._internalJavaScriptTokenizer = WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/javascript");
     242                            this._condition.internalJavaScriptTokenizerCondition = this._internalJavaScriptTokenizer.initialCondition;
     243                        }
    213244                        // Do not tokenize script tag contents.
    214                         this.tokenType = null;
    215245                        return cursor;
    216246                    }
    217247
    218                     this._parseCondition = this._parseConditions.INITIAL;
    219                     this.tokenType = "html-tag";
     248                    this._condition.parseCondition = this._parseConditions.INITIAL;
    220249                    return cursor;
    221250                }
     
    239268                <TAG> Identifier
    240269                {
    241                     if (this._parseCondition === this._parseConditions.SCRIPT) {
     270                    if (this._condition.parseCondition === this._parseConditions.SCRIPT) {
    242271                        // Fall through if expecting attributes.
    243272                        this.tokenType = null;
     
    245274                    }
    246275
    247                     if (this._parseCondition === this._parseConditions.INITIAL) {
     276                    if (this._condition.parseCondition === this._parseConditions.INITIAL) {
    248277                        this.tokenType = "html-tag";
    249278                        this._setExpectingAttribute();
    250279                        var token = this._line.substring(cursorOnEnter, cursor);
    251280                        if (token === "a")
    252                             this._parseCondition |= this._parseConditions.A_NODE;
    253                         else if (this._parseCondition & this._parseConditions.A_NODE)
    254                             this._parseCondition ^= this._parseConditions.A_NODE;
     281                            this._condition.parseCondition |= this._parseConditions.A_NODE;
     282                        else if (this._condition.parseCondition & this._parseConditions.A_NODE)
     283                            this._condition.parseCondition ^= this._parseConditions.A_NODE;
    255284                    } else if (this._isExpectingAttribute()) {
    256285                        var token = this._line.substring(cursorOnEnter, cursor);
    257286                        if (token === "href" || token === "src")
    258                             this._parseCondition |= this._parseConditions.LINKIFY;
    259                         else if (this._parseCondition |= this._parseConditions.LINKIFY)
    260                             this._parseCondition ^= this._parseConditions.LINKIFY;
     287                            this._condition.parseCondition |= this._parseConditions.LINKIFY;
     288                        else if (this._condition.parseCondition |= this._parseConditions.LINKIFY)
     289                            this._condition.parseCondition ^= this._parseConditions.LINKIFY;
    261290                        this.tokenType = "html-attribute-name";
    262291                    } else if (this._isExpectingAttributeValue())
  • trunk/WebCore/inspector/front-end/SourceJavaScriptTokenizer.js

    r54979 r55248  
    1 /* Generated by re2c 0.13.5 on Thu Jan 28 20:49:23 2010 */
     1/* Generated by re2c 0.13.5 on Thu Feb 25 21:44:55 2010 */
    22/*
    33 * Copyright (C) 2009 Google Inc. All rights reserved.
     
    7070
    7171    this.initialCondition = { lexCondition: this._lexConditions.NODIV }
     72    this.condition = this.initialCondition;
    7273}
    7374
  • trunk/WebCore/inspector/front-end/SourceJavaScriptTokenizer.re2js

    r54979 r55248  
    6969
    7070    this.initialCondition = { lexCondition: this._lexConditions.NODIV }
     71    this.condition = this.initialCondition;
    7172}
    7273
  • trunk/WebCore/inspector/front-end/SourceTokenizer.js

    r54872 r55248  
    4141    set condition(condition)
    4242    {
    43         this._lexCondition = condition.lexCondition;
    44         this._parseCondition = condition.parseCondition;
     43        this._condition = condition;
    4544    },
    4645
    4746    get condition()
    4847    {
    49         return { lexCondition: this._lexCondition, parseCondition: this._parseCondition };
     48        return this._condition;
    5049    },
    5150
    52     hasCondition: function(condition)
     51    get subTokenizer()
    5352    {
    54         return this._lexCondition === condition.lexCondition && this._parseCondition === condition.parseCondition;
     53        return this._condition.subTokenizer;
    5554    },
    5655
    5756    getLexCondition: function()
    5857    {
    59         return this._lexCondition;
     58        return this.condition.lexCondition;
    6059    },
    6160
    6261    setLexCondition: function(lexCondition)
    6362    {
    64         this._lexCondition = lexCondition;
     63        this.condition.lexCondition = lexCondition;
    6564    },
    6665
  • trunk/WebCore/inspector/front-end/TextEditorHighlighter.js

    r54962 r55248  
    3535    this._tokenizer = WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/html");
    3636    this._damageCallback = damageCallback;
     37    this._lastHighlightedLine = 0;
    3738}
    3839
     
    4142    {
    4243        var tokenizer = WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer(mimeType);
    43         if (tokenizer)
     44        if (tokenizer) {
    4445            this._tokenizer = tokenizer;
     46            this._tokenizerCondition = this._tokenizer.initialCondition;
     47        }
    4548    },
    4649
     
    4851    {
    4952        // First check if we have work to do.
    50         var state = this._textModel.getAttribute(endLine - 1, "highlighter-state")
    51         if (state && !state.outOfDate) {
    52             // Last line is highlighted, just exit.
     53        if (endLine <= this._lastHighlightedLine)
    5354            return;
    54         }
    5555
    5656        this._requestedEndLine = endLine;
     
    6161        }
    6262
    63         // We will be highlighting. First rewind to the last highlighted line to gain proper highlighter context.
    64         var startLine = endLine;
    65         while (startLine > 0) {
    66             var state = this._textModel.getAttribute(startLine - 1, "highlighter-state");
    67             if (state && !state.outOfDate)
    68                 break;
    69             startLine--;
    70         }
    71 
    7263        // Do small highlight synchronously. This will provide instant highlight on PageUp / PageDown, gentle scrolling.
    73         var toLine = Math.min(startLine + 200, endLine);
    74         this._highlightInChunks(startLine, toLine);
     64        var toLine = Math.min(this._lastHighlightedLine + 200, endLine);
     65        this._highlightInChunks(this._lastHighlightedLine, toLine);
    7566
    7667        // Schedule tail highlight if necessary.
     
    8475
    8576        // First we always check if we have work to do. Could be that user scrolled back and we can quit.
    86         var state = this._textModel.getAttribute(this._requestedEndLine - 1, "highlighter-state");
    87         if (state && !state.outOfDate)
     77        if (this._requestedEndLine <= this._lastHighlightedLine)
    8878            return;
    8979
     
    10393    },
    10494
    105     updateHighlight: function(startLine, endLine)
     95    _highlightLines: function(startLine, endLine)
    10696    {
    107         // Start line was edited, we should highlight everything until endLine synchronously.
    108         if (startLine) {
    109             var state = this._textModel.getAttribute(startLine - 1, "highlighter-state");
    110             if (!state || state.outOfDate) {
    111                 // Highlighter did not reach this point yet, nothing to update. It will reach it on subsequent timer tick and do the job.
    112                 return;
    113             }
    114         }
     97        // Tokenizer is stateless and reused accross viewers, restore its condition before highlight and save it after.
     98        this._tokenizer.condition = this._tokenizerCondition;
     99        for (var i = startLine; i < endLine; ++i)
     100            this._highlightLine(i);
     101        this._lastHighlightedLine = endLine;
     102        this._tokenizerCondition = this._tokenizer.condition;
    115103
    116         var restored = this._highlightLines(startLine, endLine);
    117 
    118         // Set invalidated flag to the subsequent lines.
    119         for (var i = endLine; i < this._textModel.linesCount; ++i) {
    120             var highlighterState = this._textModel.getAttribute(i, "highlighter-state");
    121             if (highlighterState)
    122                 highlighterState.outOfDate = !restored;
    123             else
    124                 return;
    125         }
     104        this._damageCallback(startLine, endLine);
    126105    },
    127106
    128     _highlightLines: function(startLine, endLine)
    129     {
    130         // Restore highlighter context taken from previous line.
    131         var state = this._textModel.getAttribute(startLine - 1, "highlighter-state");
    132         if (state)
    133             this._tokenizer.condition = state.postCondition;
    134         else
    135             this._tokenizer.condition = this._tokenizer.initialCondition;
    136 
    137         for (var i = startLine; i < endLine; ++i) {
    138             state = {};
    139             state.preCondition = this._tokenizer.condition;
    140             state.attributes = {};
    141 
    142             this._lex(this._textModel.line(i), i, state.attributes);
    143 
    144             state.postCondition = this._tokenizer.condition;
    145             this._textModel.setAttribute(i, "highlighter-state", state);
    146 
    147             var nextLineState = this._textModel.getAttribute(i + 1, "highlighter-state");
    148             if (nextLineState && this._tokenizer.hasCondition(nextLineState.preCondition)) {
    149                 // Following lines are up to date, no need re-highlight.
    150                 this._damageCallback(startLine, i + 1);
    151                 return true;
    152             }
    153         }
    154         this._damageCallback(startLine, endLine);
    155         return false;
    156     },
    157 
    158     _lex: function(line, lineNumber, attributes) {
    159          this._tokenizer.line = line;
    160          var column = 0;
    161          do {
    162              var newColumn = this._tokenizer.nextToken(column);
    163              var tokenType = this._tokenizer.tokenType;
    164              if (tokenType)
    165                  attributes[column] = { length: newColumn - column, tokenType: tokenType };
    166              column = newColumn;
    167          } while (column < line.length)
     107    _highlightLine: function(lineNumber) {
     108        var line = this._textModel.line(lineNumber);
     109        var attributes = {};
     110        this._tokenizer.line = line;
     111        var column = 0;
     112        do {
     113            var newColumn = this._tokenizer.nextToken(column);
     114            var tokenType = this._tokenizer.tokenType;
     115            if (tokenType)
     116                attributes[column] = { length: newColumn - column, tokenType: tokenType, subTokenizer: this._tokenizer.subTokenizer };
     117            column = newColumn;
     118        } while (column < line.length)
     119        this._textModel.setAttribute(lineNumber, "highlight", attributes);
    168120    }
    169121}
  • trunk/WebCore/inspector/front-end/TextViewer.js

    r54962 r55248  
    331331    {
    332332        var element = lineRow.lastChild;
    333         var highlighterState = this._textModel.getAttribute(lineNumber, "highlighter-state");
    334         var line = this._textModel.line(lineNumber);
    335 
    336         if (!highlighterState) {
     333        var highlight = this._textModel.getAttribute(lineNumber, "highlight");
     334        if (!highlight) {
    337335            if (this._rangeToMark && this._rangeToMark.startLine === lineNumber)
    338336                this._markedRangeElement = highlightSearchResult(element, this._rangeToMark.startColumn, this._rangeToMark.endColumn - this._rangeToMark.startColumn);
     
    341339
    342340        element.removeChildren();
     341        var line = this._textModel.line(lineNumber);
    343342
    344343        var plainTextStart = -1;
     
    349348                break;
    350349            }
    351             var attribute = highlighterState && highlighterState.attributes[j];
     350            var attribute = highlight[j];
    352351            if (!attribute || !attribute.tokenType) {
    353352                if (plainTextStart === -1)
Note: See TracChangeset for help on using the changeset viewer.