Changeset 141257 in webkit


Ignore:
Timestamp:
Jan 30, 2013 4:43:51 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: implement highlight range API
https://bugs.webkit.org/show_bug.cgi?id=108317

Patch by Andrey Lushnikov <lushnikov@chromium.org> on 2013-01-30
Reviewed by Pavel Feldman.

Source/WebCore:

Test: inspector/editor/text-editor-highlight-api.html

Introduce RangeHighlightDescriptor class and implement Highlight Range
api.

  • inspector/front-end/DefaultTextEditor.js:

(WebInspector.DefaultTextEditor.prototype.removeHighlight):
(WebInspector.DefaultTextEditor.prototype.highlightRange):
(WebInspector.TextEditorMainPanel.prototype.removeHighlight):
(WebInspector.TextEditorMainPanel.prototype.highlightRange):
(WebInspector.TextEditorMainPanel.RangeHighlightDescriptor):
(WebInspector.TextEditorMainPanel.RangeHighlightDescriptor.prototype.affectsLine):
(WebInspector.TextEditorMainPanel.RangeHighlightDescriptor.prototype.rangesForLine):
(WebInspector.TextEditorMainPanel.RangeHighlightDescriptor.prototype.cssClass):
(WebInspector.TextEditorMainPanel.TokenHighlighter.prototype._removeHighlight):

  • inspector/front-end/TextEditor.js:

(WebInspector.TextEditor.prototype.highlightRange):
(WebInspector.TextEditor.prototype.removeHighlight):

LayoutTests:

Added test cases to the existed test to cover highlight range
functionality.

  • inspector/editor/text-editor-highlight-api-expected.txt: Added.
  • inspector/editor/text-editor-highlight-api.html: Added.
  • inspector/editor/text-editor-highlight-regexp-expected.txt: Removed.
  • inspector/editor/text-editor-highlight-regexp.html: Removed.
Location:
trunk
Files:
2 added
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r141256 r141257  
     12013-01-30  Andrey Lushnikov  <lushnikov@chromium.org>
     2
     3        Web Inspector: implement highlight range API
     4        https://bugs.webkit.org/show_bug.cgi?id=108317
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Added test cases to the existed test to cover highlight range
     9        functionality.
     10
     11        * inspector/editor/text-editor-highlight-api-expected.txt: Added.
     12        * inspector/editor/text-editor-highlight-api.html: Added.
     13        * inspector/editor/text-editor-highlight-regexp-expected.txt: Removed.
     14        * inspector/editor/text-editor-highlight-regexp.html: Removed.
     15
    1162013-01-30  Zan Dobersek  <zdobersek@igalia.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r141255 r141257  
     12013-01-30  Andrey Lushnikov  <lushnikov@chromium.org>
     2
     3        Web Inspector: implement highlight range API
     4        https://bugs.webkit.org/show_bug.cgi?id=108317
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Test: inspector/editor/text-editor-highlight-api.html
     9
     10        Introduce RangeHighlightDescriptor class and implement Highlight Range
     11        api.
     12
     13        * inspector/front-end/DefaultTextEditor.js:
     14        (WebInspector.DefaultTextEditor.prototype.removeHighlight):
     15        (WebInspector.DefaultTextEditor.prototype.highlightRange):
     16        (WebInspector.TextEditorMainPanel.prototype.removeHighlight):
     17        (WebInspector.TextEditorMainPanel.prototype.highlightRange):
     18        (WebInspector.TextEditorMainPanel.RangeHighlightDescriptor):
     19        (WebInspector.TextEditorMainPanel.RangeHighlightDescriptor.prototype.affectsLine):
     20        (WebInspector.TextEditorMainPanel.RangeHighlightDescriptor.prototype.rangesForLine):
     21        (WebInspector.TextEditorMainPanel.RangeHighlightDescriptor.prototype.cssClass):
     22        (WebInspector.TextEditorMainPanel.TokenHighlighter.prototype._removeHighlight):
     23        * inspector/front-end/TextEditor.js:
     24        (WebInspector.TextEditor.prototype.highlightRange):
     25        (WebInspector.TextEditor.prototype.removeHighlight):
     26
    1272013-01-30  Simon Hausmann  <simon.hausmann@digia.com>
    228
  • trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js

    r141245 r141257  
    124124     * @param {WebInspector.TextEditorMainPanel.HighlightDescriptor} highlightDescriptor
    125125     */
    126     removeRegexHighlight: function(highlightDescriptor)
    127     {
    128         this._mainPanel.removeRegexHighlight(highlightDescriptor);
     126    removeHighlight: function(highlightDescriptor)
     127    {
     128        this._mainPanel.removeHighlight(highlightDescriptor);
     129    },
     130
     131    /**
     132     * @param {WebInspector.TextRange} range
     133     * @param {string} cssClass
     134     */
     135    highlightRange: function(range, cssClass)
     136    {
     137        return this._mainPanel.highlightRange(range, cssClass);
    129138    },
    130139
     
    13891398     * @param {WebInspector.TextEditorMainPanel.HighlightDescriptor} highlightDescriptor
    13901399     */
    1391     removeRegexHighlight: function(highlightDescriptor)
     1400    removeHighlight: function(highlightDescriptor)
    13921401    {
    13931402        this._highlightDescriptors.remove(highlightDescriptor);
    13941403        this._repaintLineRowsAffectedByHighlightDescriptor(highlightDescriptor);
     1404    },
     1405
     1406    /**
     1407     * @param {WebInspector.TextRange} range
     1408     * @param {string} cssClass
     1409     */
     1410    highlightRange: function(range, cssClass)
     1411    {
     1412        var highlightDescriptor = new WebInspector.TextEditorMainPanel.RangeHighlightDescriptor(range, cssClass);
     1413        this._highlightDescriptors.push(highlightDescriptor);
     1414        this._repaintLineRowsAffectedByHighlightDescriptor(highlightDescriptor);
     1415        return highlightDescriptor;
    13951416    },
    13961417
     
    27552776/**
    27562777 * @constructor
     2778 * @implements {WebInspector.TextEditorMainPanel.HighlightDescriptor}
     2779 * @param {WebInspector.TextRange} range
     2780 * @param {string} cssClass
     2781 */
     2782WebInspector.TextEditorMainPanel.RangeHighlightDescriptor = function(range, cssClass)
     2783{
     2784    this._cssClass = cssClass;
     2785    this._range = range;
     2786}
     2787
     2788WebInspector.TextEditorMainPanel.RangeHighlightDescriptor.prototype = {
     2789    /**
     2790     * @param {number} lineNumber
     2791     * @param {string} line
     2792     * @return {boolean}
     2793     */
     2794    affectsLine: function(lineNumber, line)
     2795    {
     2796        return this._range.startLine <= lineNumber && lineNumber <= this._range.endLine && line.length > 0;
     2797    },
     2798
     2799    /**
     2800     * @param {number} lineNumber
     2801     * @param {string} line
     2802     * @return {Array.<{startColumn: number, endColumn: number}>}
     2803     */
     2804    rangesForLine: function(lineNumber, line)
     2805    {
     2806        if (!this.affectsLine(lineNumber, line))
     2807            return [];
     2808
     2809        var startColumn = lineNumber === this._range.startLine ? this._range.startColumn : 0;
     2810        var endColumn = lineNumber === this._range.endLine ? Math.max(this._range.endColumn, line.length) : line.length;
     2811        return [{
     2812            startColumn: startColumn,
     2813            endColumn: endColumn
     2814        }];
     2815    },
     2816
     2817    /**
     2818     * @return {string}
     2819     */
     2820    cssClass: function()
     2821    {
     2822        return this._cssClass;
     2823    }
     2824}
     2825
     2826/**
     2827 * @constructor
    27572828 * @param {Element} element
    27582829 */
     
    31003171    {
    31013172        if (this._selectedWord) {
    3102             this._mainPanel.removeRegexHighlight(this._highlightDescriptor);
     3173            this._mainPanel.removeHighlight(this._highlightDescriptor);
    31033174            delete this._selectedWord;
    31043175            delete this._highlightDescriptor;
  • trunk/Source/WebCore/inspector/front-end/TextEditor.js

    r141245 r141257  
    6969
    7070    /**
     71     * @param {WebInspector.TextRange} range
     72     * @param {string} cssClass
     73     */
     74    highlightRange: function(range, cssClass) { },
     75
     76    /**
    7177     * @param {WebInspector.TextEditorMainPanel.HighlightDescriptor} highlightDescriptor
    7278     */
    73     removeRegexHighlight: function(highlightDescriptor) { },
     79    removeHighlight: function(highlightDescriptor) { },
    7480
    7581    /**
Note: See TracChangeset for help on using the changeset viewer.