[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9

pfeldman at chromium.org pfeldman at chromium.org
Thu Feb 4 21:28:08 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 51192141290f246ee8ee6e7d3173bdc1582e034e
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jan 26 16:39:19 2010 +0000

    2010-01-26  Pavel Feldman  <pfeldman at chromium.org>
    
            Reviewed by Timothy Hatcher.
    
            Web Inspector: add support for breakpoints, messages and search into the SourceFrame2.
    
            https://bugs.webkit.org/show_bug.cgi?id=34165
    
            * inspector/front-end/SourceFrame2.js:
            (WebInspector.SourceFrame2):
            (WebInspector.SourceFrame2.prototype.get executionLine):
            (WebInspector.SourceFrame2.prototype.set executionLine):
            (WebInspector.SourceFrame2.prototype.revealLine):
            (WebInspector.SourceFrame2.prototype.addBreakpoint):
            (WebInspector.SourceFrame2.prototype.removeBreakpoint):
            (WebInspector.SourceFrame2.prototype.sizeToFitContentHeight):
            (WebInspector.SourceFrame2.prototype.setContent):
            (WebInspector.SourceFrame2.prototype.findSearchMatches):
            (WebInspector.SourceFrame2.prototype.setSelection):
            (WebInspector.SourceFrame2.prototype._addMessageToSource):
            (WebInspector.SourceFrame2.prototype._addExistingBreakpointsToSource):
            (WebInspector.SourceFrame2.prototype._addBreakpointToSource):
            (WebInspector.SourceFrame2.prototype._removeBreakpointFromSource):
            (WebInspector.SourceFrame2.prototype._contextMenu.addConditionalBreakpoint):
            (WebInspector.SourceFrame2.prototype._contextMenu):
            (WebInspector.SourceFrame2.prototype._toggleBreakpoint):
            (WebInspector.SourceFrame2.prototype._editBreakpointCondition.committed):
            (WebInspector.SourceFrame2.prototype._editBreakpointCondition.dismissed):
            (WebInspector.SourceFrame2.prototype._editBreakpointCondition):
            (WebInspector.SourceFrame2.prototype._showBreakpointConditionPopup):
            (WebInspector.SourceFrame2.prototype._createConditionElement):
            (WebInspector.SourceFrame2.prototype._keyDown):
            (WebInspector.SourceFrame2.prototype._evalSelectionInCallFrame):
            (WebInspector.SourceFrame2.prototype._breakpointChanged):
            (WebInspector.SourceFrame2.prototype.resize):
            (WebInspector.BreakpointLineNumberDecorator.prototype.decorate):
            (WebInspector.BreakpointLineNumberDecorator.prototype._paintBreakpoint):
            (WebInspector.BreakpointLineNumberDecorator.prototype.mouseDown):
            (WebInspector.BreakpointLineNumberDecorator.prototype.contextMenu):
            (WebInspector.ExecutionLineDecorator.prototype.decorate):
            * inspector/front-end/TextEditor.js:
            (WebInspector.TextEditor):
            (WebInspector.TextEditor.prototype.set mimeType):
            (WebInspector.TextEditor.prototype.set readOnly):
            (WebInspector.TextEditor.prototype.setDivDecoration):
            (WebInspector.TextEditor.prototype.reveal):
            (WebInspector.TextEditor.prototype.packAndRepaintAll):
            (WebInspector.TextEditor.prototype._updateSize):
            (WebInspector.TextEditor.prototype.updateCanvasSize):
            (WebInspector.TextEditor.prototype.repaintAll):
            (WebInspector.TextEditor.prototype._paintLinesContinuation):
            (WebInspector.TextEditor.prototype._repaintOnScroll):
            (WebInspector.TextEditor.prototype._mouseDown):
            (WebInspector.TextEditor.prototype._contextMenu):
            (WebInspector.TextEditor.prototype._caretForMouseEvent):
            (WebInspector.TextEditor.prototype._columnForOffset):
            (WebInspector.TextEditor.prototype._handleNavigationKey):
            (WebInspector.TextEditor.prototype._positionDivDecoration):
            (WebInspector.TextEditor.prototype._replaceSelectionWith):
            (WebInspector.TextEditor.prototype.setCoalescingUpdate):
            (WebInspector.TextEditor.prototype._handleUndo):
            (WebInspector.TextEditor.prototype._handleRedo):
            (WebInspector.TextEditor.prototype._changeFont):
            * inspector/front-end/TextEditorHighlighter.js:
            (WebInspector.TextEditorHighlighter):
            (WebInspector.TextEditorHighlighter.prototype.set mimeType):
            * inspector/front-end/inspector.css:
            * inspector/front-end/textEditor.css:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53856 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f8aba32..f0767ee 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,6 +1,75 @@
 2010-01-26  Pavel Feldman  <pfeldman at chromium.org>
 
-        Reviewed by Timothy Hather.
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: add support for breakpoints, messages and search into the SourceFrame2.
+
+        https://bugs.webkit.org/show_bug.cgi?id=34165
+
+        * inspector/front-end/SourceFrame2.js:
+        (WebInspector.SourceFrame2):
+        (WebInspector.SourceFrame2.prototype.get executionLine):
+        (WebInspector.SourceFrame2.prototype.set executionLine):
+        (WebInspector.SourceFrame2.prototype.revealLine):
+        (WebInspector.SourceFrame2.prototype.addBreakpoint):
+        (WebInspector.SourceFrame2.prototype.removeBreakpoint):
+        (WebInspector.SourceFrame2.prototype.sizeToFitContentHeight):
+        (WebInspector.SourceFrame2.prototype.setContent):
+        (WebInspector.SourceFrame2.prototype.findSearchMatches):
+        (WebInspector.SourceFrame2.prototype.setSelection):
+        (WebInspector.SourceFrame2.prototype._addMessageToSource):
+        (WebInspector.SourceFrame2.prototype._addExistingBreakpointsToSource):
+        (WebInspector.SourceFrame2.prototype._addBreakpointToSource):
+        (WebInspector.SourceFrame2.prototype._removeBreakpointFromSource):
+        (WebInspector.SourceFrame2.prototype._contextMenu.addConditionalBreakpoint):
+        (WebInspector.SourceFrame2.prototype._contextMenu):
+        (WebInspector.SourceFrame2.prototype._toggleBreakpoint):
+        (WebInspector.SourceFrame2.prototype._editBreakpointCondition.committed):
+        (WebInspector.SourceFrame2.prototype._editBreakpointCondition.dismissed):
+        (WebInspector.SourceFrame2.prototype._editBreakpointCondition):
+        (WebInspector.SourceFrame2.prototype._showBreakpointConditionPopup):
+        (WebInspector.SourceFrame2.prototype._createConditionElement):
+        (WebInspector.SourceFrame2.prototype._keyDown):
+        (WebInspector.SourceFrame2.prototype._evalSelectionInCallFrame):
+        (WebInspector.SourceFrame2.prototype._breakpointChanged):
+        (WebInspector.SourceFrame2.prototype.resize):
+        (WebInspector.BreakpointLineNumberDecorator.prototype.decorate):
+        (WebInspector.BreakpointLineNumberDecorator.prototype._paintBreakpoint):
+        (WebInspector.BreakpointLineNumberDecorator.prototype.mouseDown):
+        (WebInspector.BreakpointLineNumberDecorator.prototype.contextMenu):
+        (WebInspector.ExecutionLineDecorator.prototype.decorate):
+        * inspector/front-end/TextEditor.js:
+        (WebInspector.TextEditor):
+        (WebInspector.TextEditor.prototype.set mimeType):
+        (WebInspector.TextEditor.prototype.set readOnly):
+        (WebInspector.TextEditor.prototype.setDivDecoration):
+        (WebInspector.TextEditor.prototype.reveal):
+        (WebInspector.TextEditor.prototype.packAndRepaintAll):
+        (WebInspector.TextEditor.prototype._updateSize):
+        (WebInspector.TextEditor.prototype.updateCanvasSize):
+        (WebInspector.TextEditor.prototype.repaintAll):
+        (WebInspector.TextEditor.prototype._paintLinesContinuation):
+        (WebInspector.TextEditor.prototype._repaintOnScroll):
+        (WebInspector.TextEditor.prototype._mouseDown):
+        (WebInspector.TextEditor.prototype._contextMenu):
+        (WebInspector.TextEditor.prototype._caretForMouseEvent):
+        (WebInspector.TextEditor.prototype._columnForOffset):
+        (WebInspector.TextEditor.prototype._handleNavigationKey):
+        (WebInspector.TextEditor.prototype._positionDivDecoration):
+        (WebInspector.TextEditor.prototype._replaceSelectionWith):
+        (WebInspector.TextEditor.prototype.setCoalescingUpdate):
+        (WebInspector.TextEditor.prototype._handleUndo):
+        (WebInspector.TextEditor.prototype._handleRedo):
+        (WebInspector.TextEditor.prototype._changeFont):
+        * inspector/front-end/TextEditorHighlighter.js:
+        (WebInspector.TextEditorHighlighter):
+        (WebInspector.TextEditorHighlighter.prototype.set mimeType):
+        * inspector/front-end/inspector.css:
+        * inspector/front-end/textEditor.css:
+
+2010-01-26  Pavel Feldman  <pfeldman at chromium.org>
+
+        Reviewed by Timothy Hatcher.
 
         Web Inspector: add methods for getting resource content from within frontend.
 
diff --git a/WebCore/inspector/front-end/SourceFrame2.js b/WebCore/inspector/front-end/SourceFrame2.js
index f8bbef1..49bf98e 100644
--- a/WebCore/inspector/front-end/SourceFrame2.js
+++ b/WebCore/inspector/front-end/SourceFrame2.js
@@ -28,7 +28,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-WebInspector.SourceFrame2 = function()
+WebInspector.SourceFrame2 = function(addBreakpointDelegate)
 {
     this._editor = new WebInspector.TextEditor(WebInspector.platform);
     this._textModel = this._editor.textModel;
@@ -38,13 +38,54 @@ WebInspector.SourceFrame2 = function()
     this._messages = [];
     this._rowMessages = {};
     this._messageBubbles = {};
+    this.breakpoints = [];
+    this._shortcuts = {};
     this.element = this._editor.element;
+    this.element.addEventListener("keydown", this._keyDown.bind(this), true);
+    this._loaded = false;
+
+    this.addBreakpointDelegate = addBreakpointDelegate;
 }
 
 WebInspector.SourceFrame2.prototype = {
-    set text(text)
+
+    get executionLine()
+    {
+        return this._executionLine;
+    },
+
+    set executionLine(x)
     {
-        this._editor.text = text;
+        if (this._executionLine === x)
+            return;
+        this._executionLine = x;
+        this._editor.repaintAll();
+    },
+
+    revealLine: function(lineNumber)
+    {
+        if (!this._loaded)
+            this._lineNumberToReveal = lineNumber;
+        else
+            this._editor.reveal(lineNumber - 1, 0);
+    },
+
+    addBreakpoint: function(breakpoint)
+    {
+        this.breakpoints.push(breakpoint);
+        breakpoint.addEventListener("enabled", this._breakpointChanged, this);
+        breakpoint.addEventListener("disabled", this._breakpointChanged, this);
+        breakpoint.addEventListener("condition-changed", this._breakpointChanged, this);
+        this._addBreakpointToSource(breakpoint);
+    },
+
+    removeBreakpoint: function(breakpoint)
+    {
+        this.breakpoints.remove(breakpoint);
+        breakpoint.removeEventListener("enabled", null, this);
+        breakpoint.removeEventListener("disabled", null, this);
+        breakpoint.removeEventListener("condition-changed", null, this);
+        this._removeBreakpointFromSource(breakpoint);
     },
 
     addMessage: function(msg)
@@ -69,6 +110,50 @@ WebInspector.SourceFrame2.prototype = {
         this._editor.packAndRepaintAll();
     },
 
+    sizeToFitContentHeight: function()
+    {
+        this._editor.packAndRepaintAll();
+    },
+
+    setContent: function(mimeType, content)
+    {
+        this._loaded = true;
+        this._editor.mimeType = mimeType;
+        this._editor.text = content;
+
+        this._addExistingMessagesToSource();
+        this._addExistingBreakpointsToSource();
+        if (this._executionLine)
+            this.revealLine(this._executionLine);
+
+        if (this._lineNumberToReveal) {
+            this.revealLine(this._lineNumberToReveal);
+            delete this._lineNumberToReveal;
+        }
+        this._editor.setCoalescingUpdate(true);
+        this._editor.updateCanvasSize();
+        this._editor.packAndRepaintAll();
+        this._editor.setCoalescingUpdate(false);
+    },
+
+    findSearchMatches: function(query)
+    {
+        var ranges = [];
+        for (var i = 0; i < this._textModel.linesCount; ++i) {
+            var line = this._textModel.line(i);
+            var column = line.indexOf(query);
+            if (column === -1)
+                continue;
+            ranges.push(new WebInspector.TextRange(i, column, i, column + query.length));
+        }
+        return ranges;
+    },
+
+    setSelection: function(range)
+    {
+        this._editor.setSelection(range.startLine, range.startColumn, range.endLine, range.endColumn);
+    },
+
     _incrementMessageRepeatCount: function(msg, repeatDelta)
     {
         if (!msg._resourceMessageLineElement)
@@ -101,7 +186,7 @@ WebInspector.SourceFrame2.prototype = {
             messageBubbleElement = document.createElement("div");
             messageBubbleElement.className = "webkit-html-message-bubble";
             this._messageBubbles[msg.line] = messageBubbleElement;
-            this._editor.setDivDecoration(msg.line, messageBubbleElement);
+            this._editor.setDivDecoration(msg.line - 1, messageBubbleElement);
         }
 
         var rowMessages = this._rowMessages[msg.line];
@@ -148,33 +233,159 @@ WebInspector.SourceFrame2.prototype = {
         this._editor.packAndRepaintAll();
     },
 
-    get executionLine()
+    _addExistingBreakpointsToSource: function()
     {
-        return this._executionLine;
+        var length = this.breakpoints.length;
+        for (var i = 0; i < length; ++i)
+            this._addBreakpointToSource(this.breakpoints[i]);
     },
 
-    set executionLine(x)
+    _addBreakpointToSource: function(breakpoint)
     {
-        this._executionLine = x;
+        this._textModel.setAttribute(breakpoint.line - 1, "breakpoint", breakpoint);
+        this._editor.paintLineNumbers();
     },
 
-    revealLine: function(lineNumber)
+    _removeBreakpointFromSource: function(breakpoint)
     {
-        this._editor.reveal(lineNumber, 0);
+        this._textModel.removeAttribute(breakpoint.line - 1, "breakpoint");
+        this._editor.paintLineNumbers();
     },
 
-    _toggleBreakpoint: function(lineNumber)
+    _contextMenu: function(lineNumber, event)
+    {
+        if (!this.addBreakpointDelegate)
+            return;
+
+        var contextMenu = new WebInspector.ContextMenu();
+
+        var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
+        if (!breakpoint) {
+            // This row doesn't have a breakpoint: We want to show Add Breakpoint and Add and Edit Breakpoint.
+            contextMenu.appendItem(WebInspector.UIString("Add Breakpoint"), this.addBreakpointDelegate.bind(this, lineNumber + 1));
+
+            function addConditionalBreakpoint() 
+            {
+                this.addBreakpointDelegate(lineNumber + 1);
+                var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
+                if (breakpoint)
+                    this._editBreakpointCondition(breakpoint);
+            }
+
+            contextMenu.appendItem(WebInspector.UIString("Add Conditional Breakpoint..."), addConditionalBreakpoint.bind(this));
+        } else {
+            // This row has a breakpoint, we want to show edit and remove breakpoint, and either disable or enable.
+            contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), WebInspector.panels.scripts.removeBreakpoint.bind(WebInspector.panels.scripts, breakpoint));
+            contextMenu.appendItem(WebInspector.UIString("Edit Breakpoint..."), this._editBreakpointCondition.bind(this, breakpoint));
+            if (breakpoint.enabled)
+                contextMenu.appendItem(WebInspector.UIString("Disable Breakpoint"), function() { breakpoint.enabled = false; });
+            else
+                contextMenu.appendItem(WebInspector.UIString("Enable Breakpoint"), function() { breakpoint.enabled = true; });
+        }
+        contextMenu.show(event);
+    },
+
+    _toggleBreakpoint: function(lineNumber, event)
+    {
+        if (event.button != 0 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
+            return;
+        var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
+        if (breakpoint)
+            WebInspector.panels.scripts.removeBreakpoint(breakpoint);
+        else if (this.addBreakpointDelegate)
+            this.addBreakpointDelegate(lineNumber + 1);
+        event.preventDefault();
+    },
+
+    _editBreakpointCondition: function(breakpoint)
+    {
+        this._showBreakpointConditionPopup(breakpoint.line);
+
+        function committed(element, newText)
+        {
+            breakpoint.condition = newText;
+            this._editor.paintLineNumbers();
+            dismissed.call(this);
+        }
+
+        function dismissed()
+        {
+            this._editor.setDivDecoration(breakpoint.line - 1, null);
+            delete this._conditionEditorElement;
+        }
+
+        var dismissedHandler = dismissed.bind(this);
+        this._conditionEditorElement.addEventListener("blur", dismissedHandler, false);
+
+        WebInspector.startEditing(this._conditionEditorElement, committed.bind(this), dismissedHandler);
+        this._conditionEditorElement.value = breakpoint.condition;
+        this._conditionEditorElement.select();
+    },
+
+    _showBreakpointConditionPopup: function(lineNumber)
+    {
+        var conditionElement = this._createConditionElement(lineNumber);
+        this._editor.setDivDecoration(lineNumber - 1, conditionElement);
+    },
+
+    _createConditionElement: function(lineNumber)
+    {
+        var conditionElement = document.createElement("div");
+        conditionElement.className = "source-breakpoint-condition";
+
+        var labelElement = document.createElement("label");
+        labelElement.className = "source-breakpoint-message";
+        labelElement.htmlFor = "source-breakpoint-condition";
+        labelElement.appendChild(document.createTextNode(WebInspector.UIString("The breakpoint on line %d will stop only if this expression is true:", lineNumber)));
+        conditionElement.appendChild(labelElement);
+
+        var editorElement = document.createElement("input");
+        editorElement.id = "source-breakpoint-condition";
+        editorElement.type = "text"
+        conditionElement.appendChild(editorElement);
+        this._conditionEditorElement = editorElement;
+
+        return conditionElement;
+    },
+
+    _keyDown: function(event)
+    {
+        var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event);
+        var handler = this._shortcuts[shortcut];
+        if (handler) {
+            handler(event);
+            event.preventDefault();
+        } else {
+            WebInspector.documentKeyDown(event);
+        }
+    },
+
+    _evalSelectionInCallFrame: function(event)
+    {
+        if (!WebInspector.panels.scripts || !WebInspector.panels.scripts.paused)
+            return;
+
+        var selection = this.element.contentWindow.getSelection();
+        if (!selection.rangeCount)
+            return;
+
+        var expression = selection.getRangeAt(0).toString().trimWhitespace();
+        WebInspector.panels.scripts.evaluateInSelectedCallFrame(expression, false, "console", function(result, exception) {
+            WebInspector.showConsole();
+            var commandMessage = new WebInspector.ConsoleCommand(expression);
+            WebInspector.console.addMessage(commandMessage);
+            WebInspector.console.addMessage(new WebInspector.ConsoleCommandResult(result, exception, commandMessage));
+        });
+    },
+
+    _breakpointChanged: function(event)
     {
-        if (this._textModel.getAttribute(lineNumber, "breakpoint"))
-            this._textModel.removeAttribute(lineNumber, "breakpoint");
-        else
-            this._textModel.setAttribute(lineNumber, "breakpoint", { disabled: false, conditional: false });
         this._editor.paintLineNumbers();
     },
 
     resize: function()
     {
-        this._editor.packAndRepaintAll();
+        this._editor.updateCanvasSize();
     }
 }
 
@@ -190,7 +401,7 @@ WebInspector.BreakpointLineNumberDecorator.prototype = {
     decorate: function(lineNumber, ctx, x, y, width, height, lineHeight)
     {
         var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
-        var isExecutionLine = lineNumber === this._sourceFrame._executionLine;
+        var isExecutionLine = lineNumber + 1 === this._sourceFrame._executionLine;
         if (breakpoint || isExecutionLine) {
             ctx.save();
             ctx.translate(x + 4, y + 2);
@@ -198,7 +409,7 @@ WebInspector.BreakpointLineNumberDecorator.prototype = {
             var breakpointHeight = lineHeight - 4;
     
             if (breakpoint)
-                this._paintBreakpoint(ctx, breakpointWidth, breakpointHeight, breakpoint.conditional, breakpoint.disabled);
+                this._paintBreakpoint(ctx, breakpointWidth, breakpointHeight, breakpoint);
     
             if (isExecutionLine)
                 this._paintProgramCounter(ctx, breakpointWidth, breakpointHeight, false);
@@ -215,7 +426,7 @@ WebInspector.BreakpointLineNumberDecorator.prototype = {
         return false;
     },
 
-    _paintBreakpoint: function(ctx, width, height, conditional, disabled)
+    _paintBreakpoint: function(ctx, width, height, breakpoint)
     {
         ctx.beginPath();
         ctx.moveTo(0, 2);
@@ -226,8 +437,8 @@ WebInspector.BreakpointLineNumberDecorator.prototype = {
         ctx.lineTo(2, height);
         ctx.lineTo(0, height - 2);
         ctx.closePath();
-        ctx.fillStyle = conditional ? "rgb(217, 142, 1)" : "rgb(1, 142, 217)";
-        ctx.strokeStyle = conditional ? "rgb(205, 103, 0)" : "rgb(0, 103, 205)";
+        ctx.fillStyle = breakpoint.condition ? "rgb(217, 142, 1)" : "rgb(1, 142, 217)";
+        ctx.strokeStyle = breakpoint.condition ? "rgb(205, 103, 0)" : "rgb(0, 103, 205)";
         ctx.lineWidth = 3;
         ctx.fill();
 
@@ -236,11 +447,11 @@ WebInspector.BreakpointLineNumberDecorator.prototype = {
         ctx.stroke();
         ctx.restore();
 
-        if (disabled) {
+        if (!breakpoint.enabled) {
             ctx.save();
             ctx.globalCompositeOperation = "destination-out";
             ctx.fillStyle = "rgba(0, 0, 0, 0.5)";
-            ctx.fillRect(0, 0, breakpointWidth, breakpointHeight);
+            ctx.fillRect(0, 0, width, height);
             ctx.restore();
         }
     },
@@ -275,7 +486,13 @@ WebInspector.BreakpointLineNumberDecorator.prototype = {
 
     mouseDown: function(lineNumber, e)
     {
-        this._sourceFrame._toggleBreakpoint(lineNumber);
+        this._sourceFrame._toggleBreakpoint(lineNumber, e);
+        return true;
+    },
+
+    contextMenu: function(lineNumber, e)
+    {
+        this._sourceFrame._contextMenu(lineNumber, e);
         return true;
     }
 }
@@ -288,7 +505,7 @@ WebInspector.ExecutionLineDecorator = function(sourceFrame)
 WebInspector.ExecutionLineDecorator.prototype = {
     decorate: function(lineNumber, ctx, x, y, width, height, lineHeight)
     {
-        if (this._sourceFrame._executionLine !== lineNumber)
+        if (this._sourceFrame._executionLine !== lineNumber + 1)
             return;
         ctx.save();
         ctx.fillStyle = "rgb(171, 191, 254)";
diff --git a/WebCore/inspector/front-end/TextEditor.js b/WebCore/inspector/front-end/TextEditor.js
index 7fa2716..46f0d55 100644
--- a/WebCore/inspector/front-end/TextEditor.js
+++ b/WebCore/inspector/front-end/TextEditor.js
@@ -64,6 +64,7 @@ WebInspector.TextEditor = function(platform)
     this._sheet.addEventListener("mousemove", this._mouseMove.bind(this), false);
     this._sheet.addEventListener("mouseout", this._mouseOut.bind(this), false);
     this._sheet.addEventListener("dblclick", this._dblClick.bind(this), false);
+    this._sheet.addEventListener("contextmenu", this._contextMenu.bind(this), false);
     this.element.addEventListener("keydown", this._keyDown.bind(this), false);
     this.element.addEventListener("textInput", this._textInput.bind(this), false);
     this.element.addEventListener("beforecopy", this._beforeCopy.bind(this), false);
@@ -110,6 +111,11 @@ WebInspector.TextEditor.prototype = {
         this._setCaretLocation(0, 0);
     },
 
+    set mimeType(mimeType)
+    {
+        this._highlighter.mimeType = mimeType;
+    },
+
     get textModel()
     {
         return this._textModel;
@@ -118,6 +124,10 @@ WebInspector.TextEditor.prototype = {
     set readOnly(readOnly)
     {
         this._readOnly = readOnly;
+        if (readOnly)
+            this.element.addStyleClass("text-editor-readonly")
+        else
+            this.element.removeStyleClass("text-editor-readonly")
     },
 
     set lineNumberDecorator(lineNumberDecorator)
@@ -142,11 +152,15 @@ WebInspector.TextEditor.prototype = {
         var divDecoration = this._textModel.getAttribute(lineNumber, "div-decoration");
         if (divDecoration && divDecoration.element && divDecoration.element.parentNode)
             divDecoration.element.parentNode.removeChild(divDecoration.element);
+        this._textModel.removeAttribute(lineNumber, "div-decoration");
 
-        divDecoration = { element: element };
-        this.element.appendChild(element);
+        if (element) {
+            divDecoration = { element: element };
+            this.element.appendChild(element);
+    
+            this._textModel.setAttribute(lineNumber, "div-decoration", divDecoration);
+        }
 
-        this._textModel.setAttribute(lineNumber, "div-decoration", divDecoration);
         this.packAndRepaintAll();
     },
 
@@ -202,9 +216,9 @@ WebInspector.TextEditor.prototype = {
         var maxScrollTop = this._lineToOffset(line);
         var minScrollTop = maxScrollTop + this._lineHeight(line) - this._canvas.height;
         if (this._scrollTop > maxScrollTop)
-            this._container.scrollTop = maxScrollTop;
+            this._container.scrollTop = maxScrollTop - this._textLineHeight * 2;
         else if (this._scrollTop < minScrollTop)
-            this._container.scrollTop = minScrollTop;
+            this._container.scrollTop = minScrollTop + this._textLineHeight * 2;
 
         var firstColumn = this._columnForOffset(line, this._scrollLeft);
         var maxScrollLeft = this._columnToOffset(line, column);
@@ -264,16 +278,16 @@ WebInspector.TextEditor.prototype = {
 
     packAndRepaintAll: function()
     {
-        this._setCoalescingUpdate(true);
+        this.setCoalescingUpdate(true);
         this._lineOffsetsCache = [0];
         this._updateSize(0, this._textModel.linesCount);
-        this._repaintAll();
-        this._setCoalescingUpdate(false);
+        this.repaintAll();
+        this.setCoalescingUpdate(false);
     },
 
     _updateSize: function(startLine, endLine)
     {
-        this._setCoalescingUpdate(true);
+        this.setCoalescingUpdate(true);
         var guardedEndLine = Math.min(this._textModel.linesCount, endLine + 1);
         var newMaximum = false;
         for (var i = startLine; i < guardedEndLine; ++i) {
@@ -307,12 +321,12 @@ WebInspector.TextEditor.prototype = {
 
         if (newLineNumberDigits !== this._lineNumberDigits) {
             this._lineNumberDigits = newLineNumberDigits;
-            this._repaintAll();
+            this.repaintAll();
         }
 
         // Changes to size can change the client area (scrollers can appear/disappear)
         this.updateCanvasSize();
-        this._setCoalescingUpdate(false);
+        this.setCoalescingUpdate(false);
     },
 
     updateCanvasSize: function()
@@ -320,11 +334,11 @@ WebInspector.TextEditor.prototype = {
         if (this._canvas.width !== this._container.clientWidth || this._canvas.height !== this._container.clientHeight) {
             this._canvas.width = this._container.clientWidth;
             this._canvas.height = this._container.clientHeight;
-            this._repaintAll();
+            this.repaintAll();
         }
     },
 
-    _repaintAll: function()
+    repaintAll: function()
     {
         this._invalidateLines(0, this._textModel.linesCount);
         this._paint();
@@ -429,10 +443,21 @@ WebInspector.TextEditor.prototype = {
                 continue;
             }
 
+            if (line.length > 1000) {
+                // Optimization: no need to paint decorations outside visible area.
+                var firstColumn = this._columnForOffset(i, this._scrollLeft);
+                var lastColumn = this._columnForOffset(i, this._scrollLeft + this._canvas.width);
+            }
             var highlighterState = this._textModel.getAttribute(i, "highlighter-state");
             var plainTextStart = -1;
             for (var j = 0; j < line.length;) {
                 var attribute = highlighterState && highlighterState.attributes[j];
+                if (attribute && firstColumn && j + attribute.length < firstColumn) {
+                    j += attribute.length;
+                    continue;
+                }
+                if (attribute && lastColumn && j > lastColumn)
+                    break;
                 if (!attribute || !attribute.style) {
                     if (plainTextStart === -1)
                         plainTextStart = j;
@@ -450,7 +475,7 @@ WebInspector.TextEditor.prototype = {
             }
             if (plainTextStart !== -1) {
                 this._ctx.fillStyle = "rgb(0,0,0)";
-                this._ctx.fillText(line.substring(plainTextStart, line.length), this._lineNumberWidth - this._scrollLeft + this._columnToOffset(i, plainTextStart), lineOffset + this._textLineHeight);
+                this._ctx.fillText(line.substring(plainTextStart, j), this._lineNumberWidth - this._scrollLeft + this._columnToOffset(i, plainTextStart), lineOffset + this._textLineHeight);
             }
         }
         this._ctx.restore();
@@ -497,7 +522,7 @@ WebInspector.TextEditor.prototype = {
         if (this._scrollTop !== this._container.scrollTop || this._scrollLeft !== this._container.scrollLeft) {
             this._scrollTop = this._container.scrollTop;
             this._scrollLeft = this._container.scrollLeft;
-            this._repaintAll();
+            this.repaintAll();
         }
     },
 
@@ -510,7 +535,7 @@ WebInspector.TextEditor.prototype = {
     {
         var location = this._caretForMouseEvent(e);
 
-        if (e.x < this._lineNumberWidth && this._lineNumberDecorator) {
+        if (e.offsetX < this._lineNumberWidth && this._lineNumberDecorator) {
             if (this._lineNumberDecorator.mouseDown(location.line, e))            
                 return;
         }
@@ -542,20 +567,32 @@ WebInspector.TextEditor.prototype = {
         this.setSelection(range.startLine, range.startColumn, range.endLine, range.endColumn);
     },
 
+    _contextMenu: function(e)
+    {
+        if (e.offsetX < this._lineNumberWidth && this._lineNumberDecorator) {
+            var location = this._caretForMouseEvent(e);
+            var line = location.line;
+            if (this._lineNumberDecorator.contextMenu(location.line, e))
+                return;
+        }
+    },
+
     _caretForMouseEvent: function(e)
     {
-        var lineNumber = Math.max(0, this._offsetToLine(e.y + this._scrollTop) - 1);
+        var lineNumber = Math.max(0, this._offsetToLine(e.offsetY) - 1);
         var line = this._textModel.line(lineNumber);
-        var offset = e.x + this._scrollLeft - this._lineNumberWidth - this._digitWidth;
+        var offset = e.offsetX + this._scrollLeft - this._lineNumberWidth - this._digitWidth;
         return { line: lineNumber, column: this._columnForOffset(lineNumber, offset) };
     },
 
     _columnForOffset: function(lineNumber, offset)
     {
+        var length = 0;
         var line = this._textModel.line(lineNumber);
         for (var column = 0; column < line.length; ++column) {
-            if (this._ctx.measureText(line.substring(0, column)).width > offset)
+            if (length > offset)
                 break;
+            length += this._ctx.measureText(line.charAt(column)).width;
         }
         return column;
     },
@@ -646,6 +683,18 @@ WebInspector.TextEditor.prototype = {
                     }
                 }
                 break;
+            case keyCodes.Home:
+                if (this._isMetaCtrl(e))
+                    arrowAction.call(this, 0, 0, true);
+                else
+                    arrowAction.call(this, this._selection.endLine, 0);
+                break;
+            case keyCodes.End:
+                if (this._isMetaCtrl(e))
+                    arrowAction.call(this, this._textModel.linesCount - 1, this._textModel.lineLength(this._textModel.linesCount - 1), true);
+                else
+                    arrowAction.call(this, this._selection.endLine, this._textModel.lineLength(this._selection.endLine));
+                break;
             case keyCodes.Left:
                 if (!e.shiftKey && !e.metaKey && !this._isAltCtrl(e) && !this._selection.isEmpty()) {
                     // Reset selection
@@ -734,7 +783,7 @@ WebInspector.TextEditor.prototype = {
         divDecoration.element.style.position = "absolute";
         divDecoration.element.style.top = this._lineToOffset(lineNumber) - this._scrollTop + this._textLineHeight + "px";
         divDecoration.element.style.left = this._lineNumberWidth + "px";
-        divDecoration.element.style.setProperty("max-width", (this._canvas.width - 200) + "px");
+        divDecoration.element.style.setProperty("max-width", this._canvas.width + "px");
     },
 
     _updateCursor: function(line, column)
@@ -839,13 +888,13 @@ WebInspector.TextEditor.prototype = {
     _replaceSelectionWith: function(newText, overrideRange)
     {
         var range = overrideRange || this._selection.range();
-        this._setCoalescingUpdate(true);
+        this.setCoalescingUpdate(true);
         var newRange = this._textModel.setText(range, newText);
         this._setCaretLocation(newRange.endLine, newRange.endColumn);
-        this._setCoalescingUpdate(false);
+        this.setCoalescingUpdate(false);
     },
 
-    _setCoalescingUpdate: function(enabled)
+    setCoalescingUpdate: function(enabled)
     {
         if (enabled)
             this._paintCoalescingLevel++;
@@ -907,20 +956,20 @@ WebInspector.TextEditor.prototype = {
 
     _handleUndo: function()
     {
-        this._setCoalescingUpdate(true);
+        this.setCoalescingUpdate(true);
         var range = this._textModel.undo();
         if (range)
             this._setCaretLocation(range.endLine, range.endColumn);
-        this._setCoalescingUpdate(false);
+        this.setCoalescingUpdate(false);
     },
 
     _handleRedo: function()
     {
-        this._setCoalescingUpdate(true);
+        this.setCoalescingUpdate(true);
         var range = this._textModel.redo();
         if (range)
             this._setCaretLocation(range.endLine, range.endColumn);
-        this._setCoalescingUpdate(false);
+        this.setCoalescingUpdate(false);
     },
 
     _handleDeleteKey: function()
@@ -985,7 +1034,7 @@ WebInspector.TextEditor.prototype = {
     _changeFont: function(sansSerif, fontSize) {
         this._initFont(sansSerif, fontSize);
         this._updateSize(0, this._textModel.linesCount);
-        this._repaintAll();
+        this.repaintAll();
     },
 
     _handleToggleHighlightMode: function()
diff --git a/WebCore/inspector/front-end/TextEditorHighlighter.js b/WebCore/inspector/front-end/TextEditorHighlighter.js
index 602fe68..ea0ed3b 100644
--- a/WebCore/inspector/front-end/TextEditorHighlighter.js
+++ b/WebCore/inspector/front-end/TextEditorHighlighter.js
@@ -32,7 +32,6 @@
 WebInspector.TextEditorHighlighter = function(textModel, damageCallback)
 {
     this._textModel = textModel;
-    this._tokenizer = new WebInspector.SourceCSSTokenizer();
 
     this._styles = [];
 
@@ -59,10 +58,29 @@ WebInspector.TextEditorHighlighter = function(textModel, damageCallback)
     this._styles["js-keyword"] = "rgb(170, 13, 145)";
     this._styles["js-number"] = "rgb(28, 0, 207)";
 
+    this._tokenizers = {};
+    this._tokenizerConstructors = {
+        "text/css": WebInspector.SourceCSSTokenizer,
+        "text/html": WebInspector.SourceHTMLTokenizer,
+        "text/javascript": WebInspector.SourceJavaScriptTokenizer
+    };
+
+    this.mimeType = "text/html";
     this._damageCallback = damageCallback;    
 }
 
 WebInspector.TextEditorHighlighter.prototype = {
+    set mimeType(mimeType)
+    {
+        if (!this._tokenizerConstructors[mimeType])
+            return;
+        this._tokenizer = this._tokenizers[mimeType];
+        if (!this._tokenizer) {
+            this._tokenizer = new this._tokenizerConstructors[mimeType]();
+            this._tokenizers[mimeType] = this._tokenizer;
+        }
+    },
+
     highlight: function(endLine)
     {
         // First check if we have work to do.
diff --git a/WebCore/inspector/front-end/inspector.css b/WebCore/inspector/front-end/inspector.css
index e0fd2ee..b9a4155 100644
--- a/WebCore/inspector/front-end/inspector.css
+++ b/WebCore/inspector/front-end/inspector.css
@@ -3800,52 +3800,34 @@ ol.breakpoint-list {
     white-space: pre;
 }
 
-.text-editor {
+.source-breakpoint-condition {
     position: absolute;
-    top:0;
-    left:0;
-    right:0;
-    bottom:0;
-    -webkit-user-select: text;
-    -webkit-user-modify: read-write-plaintext-only;
-}
-
-.text-editor-canvas {
-    position: absolute;
-    top:0;
-    left:0;
-    right:0;
-    bottom:0;
-    z-index: 10;
-    pointer-events: none;
-}
-
-.text-editor-container {
-    position: absolute;
-    top:0;
-    left:0;
-    right:0;
-    bottom:0;
-    overflow: auto;
+    z-index: 30;
+    padding: 4px;
+    background-color: rgb(203, 226, 255);
+    -webkit-border-radius: 7px;
+    border: 2px solid rgb(169, 172, 203); 
+    width: 90%; 
 }
 
-.text-editor-clip {
-    opacity: 0;
-    position: absolute;
-    top:0;
-    left:0;
-    pointer-events: none;
+.source-breakpoint-message {
+    background-color: transparent;
+    font-family: Lucida Grande, sans-serif; 
+    font-weight: normal;
+    font-size: 11px;
+    text-align: left;
+    text-shadow: none;
+    color: rgb(85, 85, 85);
+    cursor: default;
+    margin: 0 0 2px 0; 
 }
 
-.text-editor-cursor {
-    -webkit-user-select: none;
-    -webkit-user-modify: none;
-    position: absolute;
-    top:0;
-    left:0;
-    width:1px;
-    height: 14px;
-    z-index: 20;
-    background-color: black;
-    pointer-events: none;
+#source-breakpoint-condition {
+    font-family: monospace;
+    margin: 0;
+    border: 1px inset rgb(190, 190, 190) !important;
+    width: 100%;
+    box-shadow: none !important;
+    outline: none !important;
+    -webkit-user-modify: read-write;
 }
diff --git a/WebCore/inspector/front-end/textEditor.css b/WebCore/inspector/front-end/textEditor.css
index e060a80..daa12c0 100644
--- a/WebCore/inspector/front-end/textEditor.css
+++ b/WebCore/inspector/front-end/textEditor.css
@@ -1,3 +1,57 @@
+.text-editor {
+    position: absolute;
+    top:0;
+    left:0;
+    right:0;
+    bottom:0;
+    -webkit-user-select: text;
+    -webkit-user-modify: read-write-plaintext-only;
+}
+
+.text-editor-readonly {
+    -webkit-user-modify: read-only;
+}
+
+.text-editor-canvas {
+    position: absolute;
+    top:0;
+    left:0;
+    right:0;
+    bottom:0;
+    z-index: 10;
+    pointer-events: none;
+}
+
+.text-editor-container {
+    position: absolute;
+    top:0;
+    left:0;
+    right:0;
+    bottom:0;
+    overflow: auto;
+}
+
+.text-editor-clip {
+    opacity: 0;
+    position: absolute;
+    top:0;
+    left:0;
+    pointer-events: none;
+}
+
+.text-editor-cursor {
+    -webkit-user-select: none;
+    -webkit-user-modify: none;
+    position: absolute;
+    top:0;
+    left:0;
+    width:1px;
+    height: 14px;
+    z-index: 20;
+    background-color: black;
+    pointer-events: none;
+}
+
 .webkit-html-message-bubble {
     -webkit-box-shadow: black 0px 2px 5px;
     -webkit-border-radius: 9px;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list