[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:33:35 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 1d1613372b76db34651bfb065da870f1c3ee32e1
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Jan 31 16:36:39 2010 +0000

    2010-01-31  Pavel Feldman  <pfeldman at chromium.org>
    
            Reviewed by Timothy Hatcher.
    
            Web Inspector: Introduce NativeTextViewer.
    
            This change handles rendering highlighted text, using browser's
            selection/drag/drop/click logic. Breakpoint decorations and
            program counter is working.
    
            Todo: line numbers are painted 'under' the text when scrolling
            horizontally, search is not yet implemented.
    
            https://bugs.webkit.org/show_bug.cgi?id=34391
    
            * WebCore.gypi:
            * WebCore.vcproj/WebCore.vcproj:
            * inspector/front-end/DivBasedTextViewer.js: Added.
            (WebInspector.DivBasedTextViewer):
            (WebInspector.DivBasedTextViewer.prototype._textChanged):
            (WebInspector.DivBasedTextViewer.prototype._createLineDivs):
            (WebInspector.DivBasedTextViewer.prototype._updatePreferredSize):
            (WebInspector.DivBasedTextViewer.prototype._scroll):
            (WebInspector.DivBasedTextViewer.prototype._registerMouseListeners):
            (WebInspector.DivBasedTextViewer.prototype._registerKeyboardListeners):
            (WebInspector.DivBasedTextViewer.prototype._registerClipboardListeners):
            (WebInspector.DivBasedTextViewer.prototype._paintSelection):
            (WebInspector.DivBasedTextViewer.prototype._positionDivDecoration):
            (WebInspector.DivBasedTextViewer.prototype._mouseDown):
            (WebInspector.DivBasedTextViewer.prototype._contextMenu):
            (WebInspector.DivBasedTextViewer.prototype._caretForMouseEvent):
            (WebInspector.DivBasedTextViewer.prototype._paintLine):
            (WebInspector.DivBasedTextViewer.prototype._createSpan):
            * inspector/front-end/Settings.js:
            * inspector/front-end/SourceFrame.js:
            (WebInspector.SourceFrame.prototype.clearMessages):
            (WebInspector.SourceFrame.prototype.sizeToFitContentHeight):
            (WebInspector.SourceFrame.prototype._createEditorIfNeeded):
            (WebInspector.SourceFrame.prototype._addMessageToSource):
            (WebInspector.SourceFrame.prototype.resize):
            * inspector/front-end/TextEditor.js:
            (WebInspector.TextEditor):
            (WebInspector.TextEditor.prototype.setDivDecoration):
            (WebInspector.TextEditor.prototype._registerMouseListeners):
            (WebInspector.TextEditor.prototype._registerKeyboardListeners):
            (WebInspector.TextEditor.prototype._registerClipboardListeners):
            (WebInspector.TextEditor.prototype.reveal):
            (WebInspector.TextEditor.prototype._textChanged):
            (WebInspector.TextEditor.prototype.revalidateDecorationsAndPaint):
            (WebInspector.TextEditor.prototype._updatePreferredSize):
            (WebInspector.TextEditor.prototype.resize):
            (WebInspector.TextEditor.prototype._paintLinesContinuation):
            (WebInspector.TextEditor.prototype._paintLine):
            (WebInspector.TextEditor.prototype._contextMenu):
            (WebInspector.TextEditor.prototype._caretForMouseEvent):
            (WebInspector.TextEditor.prototype._changeFont):
            * inspector/front-end/TextEditorHighlighter.js:
            (WebInspector.TextEditorHighlighter.prototype._lex):
            * inspector/front-end/WebKit.qrc:
            * inspector/front-end/inspector.html:
            * inspector/front-end/textEditor.css:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54110 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index db9d718..f35e261 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,65 @@
+2010-01-31  Pavel Feldman  <pfeldman at chromium.org>
+
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: Introduce NativeTextViewer.
+
+        This change handles rendering highlighted text, using browser's
+        selection/drag/drop/click logic. Breakpoint decorations and
+        program counter is working.
+
+        Todo: line numbers are painted 'under' the text when scrolling
+        horizontally, search is not yet implemented.
+
+        https://bugs.webkit.org/show_bug.cgi?id=34391
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/front-end/DivBasedTextViewer.js: Added.
+        (WebInspector.DivBasedTextViewer):
+        (WebInspector.DivBasedTextViewer.prototype._textChanged):
+        (WebInspector.DivBasedTextViewer.prototype._createLineDivs):
+        (WebInspector.DivBasedTextViewer.prototype._updatePreferredSize):
+        (WebInspector.DivBasedTextViewer.prototype._scroll):
+        (WebInspector.DivBasedTextViewer.prototype._registerMouseListeners):
+        (WebInspector.DivBasedTextViewer.prototype._registerKeyboardListeners):
+        (WebInspector.DivBasedTextViewer.prototype._registerClipboardListeners):
+        (WebInspector.DivBasedTextViewer.prototype._paintSelection):
+        (WebInspector.DivBasedTextViewer.prototype._positionDivDecoration):
+        (WebInspector.DivBasedTextViewer.prototype._mouseDown):
+        (WebInspector.DivBasedTextViewer.prototype._contextMenu):
+        (WebInspector.DivBasedTextViewer.prototype._caretForMouseEvent):
+        (WebInspector.DivBasedTextViewer.prototype._paintLine):
+        (WebInspector.DivBasedTextViewer.prototype._createSpan):
+        * inspector/front-end/Settings.js:
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame.prototype.clearMessages):
+        (WebInspector.SourceFrame.prototype.sizeToFitContentHeight):
+        (WebInspector.SourceFrame.prototype._createEditorIfNeeded):
+        (WebInspector.SourceFrame.prototype._addMessageToSource):
+        (WebInspector.SourceFrame.prototype.resize):
+        * inspector/front-end/TextEditor.js:
+        (WebInspector.TextEditor):
+        (WebInspector.TextEditor.prototype.setDivDecoration):
+        (WebInspector.TextEditor.prototype._registerMouseListeners):
+        (WebInspector.TextEditor.prototype._registerKeyboardListeners):
+        (WebInspector.TextEditor.prototype._registerClipboardListeners):
+        (WebInspector.TextEditor.prototype.reveal):
+        (WebInspector.TextEditor.prototype._textChanged):
+        (WebInspector.TextEditor.prototype.revalidateDecorationsAndPaint):
+        (WebInspector.TextEditor.prototype._updatePreferredSize):
+        (WebInspector.TextEditor.prototype.resize):
+        (WebInspector.TextEditor.prototype._paintLinesContinuation):
+        (WebInspector.TextEditor.prototype._paintLine):
+        (WebInspector.TextEditor.prototype._contextMenu):
+        (WebInspector.TextEditor.prototype._caretForMouseEvent):
+        (WebInspector.TextEditor.prototype._changeFont):
+        * inspector/front-end/TextEditorHighlighter.js:
+        (WebInspector.TextEditorHighlighter.prototype._lex):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+        * inspector/front-end/textEditor.css:
+
 2010-01-31  Benjamin Poulain  <benjamin.poulain at nokia.com>
 
         Reviewed by Eric Seidel.
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 3b757c4..c4f64c7 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -3716,6 +3716,7 @@
             'inspector/front-end/inspector.js',
             'inspector/front-end/KeyboardShortcut.js',
             'inspector/front-end/MetricsSidebarPane.js',
+            'inspector/front-end/NativeTextViewer.js',
             'inspector/front-end/Object.js',
             'inspector/front-end/ObjectProxy.js',
             'inspector/front-end/ObjectPropertiesSection.js',
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index c83c874..31a86de 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -42816,6 +42816,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\inspector\front-end\NativeTextViewer.js"
+					>
+				</File>
+				<File
 					RelativePath="..\inspector\front-end\Object.js"
 					>
 				</File>
diff --git a/WebCore/inspector/front-end/NativeTextViewer.js b/WebCore/inspector/front-end/NativeTextViewer.js
new file mode 100644
index 0000000..53b213d
--- /dev/null
+++ b/WebCore/inspector/front-end/NativeTextViewer.js
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.NativeTextViewer = function(textModel, platform)
+{
+    WebInspector.TextEditor.call(this, textModel, platform);
+    this._sheet.className = "monospace";
+    this._sheet.tabIndex = 0;
+    this._canvas.style.zIndex = 0;
+    this._createLineDivs();
+}
+
+WebInspector.NativeTextViewer.prototype = {
+    // WebInspector.TextModel listener
+    _textChanged: function(oldRange, newRange, oldText, newText)
+    {
+        this._createLineDivs();
+        WebInspector.TextEditor.prototype._textChanged.call(this, oldRange, newRange, oldText, newText);
+    },
+
+    _createLineDivs: function()
+    {
+        this._container.removeChild(this._sheet);
+        this._sheet.removeChildren();
+        for (var i = 0; i < this._textModel.linesCount; ++i) {
+            var lineDiv = document.createElement("div");
+            lineDiv.className = "native-text-editor-line";
+            lineDiv.textContent = this._textModel.line(i);
+            this._sheet.appendChild(lineDiv);
+            this._textModel.setAttribute(i, "line-div", lineDiv);
+        }
+        this._container.appendChild(this._sheet);
+    },
+
+    _updatePreferredSize: function(startLine, endLine)
+    {
+        // Preferred size is automatically calculated based on the line divs.
+        // Only handle line numbers here.
+        
+        this.setCoalescingUpdate(true);
+        var newLineNumberDigits = this._decimalDigits(this._textModel.linesCount);
+        this._lineNumberWidth = (newLineNumberDigits + 2) * this._digitWidth;
+
+        this._sheet.style.paddingLeft = this._textWidth + this._lineNumberWidth + "px";
+
+        this._lineNumberDigits = newLineNumberDigits;
+        this.repaintAll();
+
+        // Changes to size can change the client area (scrollers can appear/disappear)
+        this.resize();
+        this.setCoalescingUpdate(false);
+    },
+
+    _scroll: function(e)
+    {
+        // Do instant repaint so that offset of canvas was in sync with the sheet.
+        this._repaintOnScroll();
+    },
+
+    _registerMouseListeners: function()
+    {
+        this._sheet.addEventListener("mousedown", this._mouseDown.bind(this), false);
+    },
+
+    _registerKeyboardListeners: function()
+    {
+        // Noop - let browser take care of this.
+    },
+
+    _registerClipboardListeners: function()
+    {
+        // Noop - let browser take care of this.
+    },
+
+    _paintSelection: function()
+    {
+        // Noop - let browser take care of this.
+    },
+
+    _positionDivDecoration: function()
+    {
+        // Div decorations have fixed positions in our case.
+    },
+
+    _mouseDown: function(e)
+    {
+        if (e.offsetX + e.target.offsetTop >= this._lineNumberWidth && this._lineNumberDecorator)
+            return;
+
+        if (e.button === 2 || (this._isMac && e.ctrlKey))
+            return;
+
+        var location = this._caretForMouseEvent(e);
+        this._lineNumberDecorator.mouseDown(location.line, e);
+    },
+
+    _contextMenu: function(e)
+    {
+        // Override editor's implementation to add the line's offsets.
+        if (e.offsetX + e.target.offsetTop >= this._lineNumberWidth && this._lineNumberDecorator)
+            return;
+
+        var location = this._caretForMouseEvent(e);
+        this._lineNumberDecorator.contextMenu(location.line, e);
+    },
+
+    _caretForMouseEvent: function(e)
+    {
+        // Override editor's implementation to add the line's offsets.
+        var lineNumber = Math.max(0, this._offsetToLine(e.offsetY + e.target.offsetTop) - 1);
+        var offset = e.offsetX + e.target.offsetLeft + this._scrollLeft - this._lineNumberWidth;
+        return { line: lineNumber, column: this._columnForOffset(lineNumber, offset) };
+    },
+
+    _paintLine: function(lineNumber, lineOffset)
+    {
+        var divHighlighted = this._textModel.getAttribute(lineNumber, "div-highlighted");
+        if (divHighlighted)
+            return;
+
+        var highlighterState = this._textModel.getAttribute(lineNumber, "highlighter-state");
+        if (!highlighterState)
+            return;
+
+        var line = this._textModel.line(lineNumber);
+        var element = this._textModel.getAttribute(lineNumber, "line-div");
+        element.removeChildren();
+ 
+        var plainTextStart = -1;
+        for (var j = 0; j < line.length;) {
+            if (j > 1000) {
+                // This line is too long - do not waste cycles on minified js highlighting.
+                break;
+            }
+            var attribute = highlighterState && highlighterState.attributes[j];
+            if (!attribute || !attribute.style) {
+                if (plainTextStart === -1)
+                    plainTextStart = j;
+                j++;
+            } else {
+                if (plainTextStart !== -1) {
+                    element.appendChild(document.createTextNode(line.substring(plainTextStart, j)));
+                    plainTextStart = -1;
+                }
+                element.appendChild(this._createSpan(line.substring(j, j + attribute.length), attribute.tokenType));
+                j += attribute.length;
+            }
+        }
+        if (plainTextStart !== -1)
+            element.appendChild(document.createTextNode(line.substring(plainTextStart, line.length)));
+
+        this._textModel.setAttribute(lineNumber, "div-highlighted", true);
+    },
+
+    _createSpan: function(content, className)
+    {
+        var span = document.createElement("span");
+        span.className = "webkit-" + className;
+        span.appendChild(document.createTextNode(content));
+        return span;
+    },
+
+    setDivDecoration: function(lineNumber, element)
+    {
+        var existingElement = this._textModel.getAttribute(lineNumber, "div-decoration");
+        if (existingElement && existingElement.parentNode)
+            existingElement.parentNode.removeChild(existingElement);
+        this._textModel.removeAttribute(lineNumber, "div-decoration");
+
+        if (element) {
+            if (lineNumber < this._textModel.linesCount - 1) {
+                var lineDiv = this._textModel.getAttribute(lineNumber + 1, "line-div");
+                this._sheet.insertBefore(element, lineDiv);
+            } else
+                this._sheet.appendChild(element);
+            this._textModel.setAttribute(lineNumber, "div-decoration", element);
+        }
+        this.revalidateDecorationsAndPaint();
+    }
+}
+
+WebInspector.NativeTextViewer.prototype.__proto__ = WebInspector.TextEditor.prototype;
diff --git a/WebCore/inspector/front-end/Settings.js b/WebCore/inspector/front-end/Settings.js
index 85aecd5..1838068 100644
--- a/WebCore/inspector/front-end/Settings.js
+++ b/WebCore/inspector/front-end/Settings.js
@@ -38,7 +38,8 @@ var Preferences = {
     styleRulesExpandedState: {},
     showMissingLocalizedStrings: false,
     samplingCPUProfiler: false,
-    showColorNicknames: true
+    showColorNicknames: true,
+    useCanvasBasedEditor: true
 }
 
 WebInspector.populateFrontendSettings = function(settingsString)
diff --git a/WebCore/inspector/front-end/SourceFrame.js b/WebCore/inspector/front-end/SourceFrame.js
index ff823cd..20f3f07 100644
--- a/WebCore/inspector/front-end/SourceFrame.js
+++ b/WebCore/inspector/front-end/SourceFrame.js
@@ -114,13 +114,13 @@ WebInspector.SourceFrame.prototype = {
         this._rowMessages = {};
         this._messageBubbles = {};
         if (this._editor)
-            this._editor.packAndRepaintAll();
+            this._editor.revalidateDecorationsAndPaint();
     },
 
     sizeToFitContentHeight: function()
     {
         if (this._editor)
-            this._editor.packAndRepaintAll();
+            this._editor.revalidateDecorationsAndPaint();
     },
 
     setContent: function(mimeType, content)
@@ -136,7 +136,8 @@ WebInspector.SourceFrame.prototype = {
         if (!this._visible || !this._loaded || this._editor)
             return;
 
-        this._editor = new WebInspector.TextEditor(this._textModel, WebInspector.platform);
+        var editorConstructor = Preferences.useCanvasBasedEditor ? WebInspector.TextEditor : WebInspector.NativeTextViewer;
+        this._editor = new editorConstructor(this._textModel, WebInspector.platform);
         this._editor.lineNumberDecorator = new WebInspector.BreakpointLineNumberDecorator(this, this._editor.textModel);
         this._editor.lineDecorator = new WebInspector.ExecutionLineDecorator(this);
         this._editor.readOnly = true;
@@ -150,8 +151,8 @@ WebInspector.SourceFrame.prototype = {
         this._addExistingBreakpointsToSource();
 
         this._editor.setCoalescingUpdate(true);
-        this._editor.updateCanvasSize();
-        this._editor.packAndRepaintAll();
+        this._editor.resize();
+        this._editor.revalidateDecorationsAndPaint();
 
         if (this._executionLine)
             this.revealLine(this._executionLine);
@@ -272,7 +273,7 @@ WebInspector.SourceFrame.prototype = {
         for (var i = 0; i < rowMessages.length; ++i) {
             if (rowMessages[i].isEqual(msg, true)) {
                 this._incrementMessageRepeatCount(rowMessages[i], msg.repeatDelta);
-                this._editor.packAndRepaintAll();
+                this._editor.revalidateDecorationsAndPaint();
                 return;
             }
         }
@@ -304,7 +305,7 @@ WebInspector.SourceFrame.prototype = {
 
         msg._resourceMessageLineElement = messageLineElement;
 
-        this._editor.packAndRepaintAll();
+        this._editor.revalidateDecorationsAndPaint();
     },
 
     _addExistingBreakpointsToSource: function()
@@ -461,7 +462,7 @@ WebInspector.SourceFrame.prototype = {
     resize: function()
     {
         if (this._editor)
-            this._editor.updateCanvasSize();
+            this._editor.resize();
     }
 }
 
diff --git a/WebCore/inspector/front-end/TextEditor.js b/WebCore/inspector/front-end/TextEditor.js
index 5554365..afa97c1 100644
--- a/WebCore/inspector/front-end/TextEditor.js
+++ b/WebCore/inspector/front-end/TextEditor.js
@@ -36,7 +36,6 @@ WebInspector.TextEditor = function(textModel, platform)
 
     this.element = document.createElement("div");
     this.element.className = "text-editor";
-    this.element.tabIndex = 0;
 
     this._canvas = document.createElement("canvas");
     this._canvas.className = "text-editor-canvas";
@@ -44,10 +43,10 @@ WebInspector.TextEditor = function(textModel, platform)
 
     this._container = document.createElement("div");
     this._container.className = "text-editor-container";
+    this._container.tabIndex = 0;
     this.element.appendChild(this._container);
 
     this._sheet = document.createElement("div");
-    this._sheet.className = "text-editor-sheet";
     this._container.appendChild(this._sheet);
 
     var cursorElement = document.createElement("div");
@@ -56,20 +55,11 @@ WebInspector.TextEditor = function(textModel, platform)
     this._cursor = new WebInspector.TextCursor(cursorElement);
 
     this._container.addEventListener("scroll", this._scroll.bind(this), false);
-    this._sheet.addEventListener("mouseup", this._mouseUp.bind(this), false);
-    this._sheet.addEventListener("mousedown", this._mouseDown.bind(this), false);
-    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);
-    this.element.addEventListener("copy", this._copy.bind(this), false);
-    this.element.addEventListener("beforecut", this._beforeCut.bind(this), false);
-    this.element.addEventListener("cut", this._cut.bind(this), false);
-    this.element.addEventListener("beforepaste", this._beforePaste.bind(this), false);
-    this.element.addEventListener("paste", this._paste.bind(this), false);
+
+    this._registerMouseListeners();
+    this._registerKeyboardListeners();
+    this._registerClipboardListeners();
 
     this._desiredCaretColumn = 0;
     this._scrollLeft = 0;
@@ -148,19 +138,41 @@ WebInspector.TextEditor.prototype = {
 
     setDivDecoration: function(lineNumber, element)
     {
-        var divDecoration = this._textModel.getAttribute(lineNumber, "div-decoration");
-        if (divDecoration && divDecoration.element && divDecoration.element.parentNode)
-            divDecoration.element.parentNode.removeChild(divDecoration.element);
+        var existingElement = this._textModel.getAttribute(lineNumber, "div-decoration");
+        if (existingElement && existingElement.parentNode)
+            existingElement.parentNode.removeChild(existingElement);
         this._textModel.removeAttribute(lineNumber, "div-decoration");
 
         if (element) {
-            divDecoration = { element: element };
             this.element.appendChild(element);
-    
-            this._textModel.setAttribute(lineNumber, "div-decoration", divDecoration);
+            this._textModel.setAttribute(lineNumber, "div-decoration", element);
         }
+        this.revalidateDecorationsAndPaint();
+    },
+
+    _registerMouseListeners: function()
+    {
+        this._sheet.addEventListener("mouseup", this._mouseUp.bind(this), false);
+        this._sheet.addEventListener("mousedown", this._mouseDown.bind(this), false);
+        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);
+    },
+
+    _registerKeyboardListeners: function()
+    {
+        this._container.addEventListener("keydown", this._keyDown.bind(this), false);
+        this._container.addEventListener("textInput", this._textInput.bind(this), false);
+    },
 
-        this.packAndRepaintAll();
+    _registerClipboardListeners: function()
+    {
+        this._container.addEventListener("beforecopy", this._beforeCopy.bind(this), false);
+        this._container.addEventListener("copy", this._copy.bind(this), false);
+        this._container.addEventListener("beforecut", this._beforeCut.bind(this), false);
+        this._container.addEventListener("cut", this._cut.bind(this), false);
+        this._container.addEventListener("beforepaste", this._beforePaste.bind(this), false);
+        this._container.addEventListener("paste", this._paste.bind(this), false);
     },
 
     _offsetToLine: function(offset)
@@ -205,13 +217,14 @@ WebInspector.TextEditor.prototype = {
 
     _lineHeight: function(lineNumber)
     {
-        var divDecoration = this._textModel.getAttribute(lineNumber, "div-decoration");
-        if (divDecoration)
-            return 2 * this._textLineHeight + divDecoration.element.clientHeight;
+        var element = this._textModel.getAttribute(lineNumber, "div-decoration");
+        if (element)
+            return 2 * this._textLineHeight + element.clientHeight;
         return this._textLineHeight;
     },
 
-    reveal: function(line, column) {
+    reveal: function(line, column)
+    {
         var maxScrollTop = this._lineToOffset(line);
         var minScrollTop = maxScrollTop + this._lineHeight(line) - this._canvas.height;
         if (this._scrollTop > maxScrollTop)
@@ -242,7 +255,7 @@ WebInspector.TextEditor.prototype = {
             this._highlighter.updateHighlight(newRange.startLine, lastVisibleLine);
         }
 
-        this._updateSize(newRange.startLine, Math.max(newRange.endLine, oldRange.endLine));
+        this._updatePreferredSize(newRange.startLine, Math.max(newRange.endLine, oldRange.endLine));
         if (oldRange.linesCount !== newRange.linesCount) {
             // Invalidate offset cache.
             this._lineOffsetsCache.length = oldRange.startLine + 1;
@@ -275,17 +288,18 @@ WebInspector.TextEditor.prototype = {
         this._paint();
     },
 
-    packAndRepaintAll: function()
+    revalidateDecorationsAndPaint: function()
     {
         this.setCoalescingUpdate(true);
         this._lineOffsetsCache = [0];
-        this._updateSize(0, this._textModel.linesCount);
+        this._updatePreferredSize(0, this._textModel.linesCount);
         this.repaintAll();
         this.setCoalescingUpdate(false);
     },
 
-    _updateSize: function(startLine, endLine)
+    _updatePreferredSize: function(startLine, endLine)
     {
+        this._ctx.font = this._font;
         this.setCoalescingUpdate(true);
         var guardedEndLine = Math.min(this._textModel.linesCount, endLine + 1);
         var newMaximum = false;
@@ -324,11 +338,11 @@ WebInspector.TextEditor.prototype = {
         }
 
         // Changes to size can change the client area (scrollers can appear/disappear)
-        this.updateCanvasSize();
+        this.resize();
         this.setCoalescingUpdate(false);
     },
 
-    updateCanvasSize: function()
+    resize: function()
     {
         if (this._canvas.width !== this._container.clientWidth || this._canvas.height !== this._container.clientHeight) {
             this._canvas.width = this._container.clientWidth;
@@ -426,58 +440,63 @@ WebInspector.TextEditor.prototype = {
             delete this._muteHighlightListener;
         }
         for (var i = firstLine; i < lastLine; ++i) {
-            var line = this._textModel.line(i);
             var lineOffset = this._lineToOffset(i) - this._scrollTop;
 
             if (this._lineDecorator)
                 this._lineDecorator.decorate(i, this._ctx, this._lineNumberWidth - 1, lineOffset, this._canvas.width - this._lineNumberWidth + 1, this._lineHeight(i), this._textLineHeight);
 
-            var divDecoration = this._textModel.getAttribute(i, "div-decoration");
-            if (divDecoration)
-                this._positionDivDecoration(i, divDecoration, true);
+            var element = this._textModel.getAttribute(i, "div-decoration");
+            if (element)
+                this._positionDivDecoration(i, element, true);
 
-            if (!this._highlightingEnabled) {
-                this._ctx.fillStyle = "rgb(0,0,0)";
-                this._ctx.fillText(line, this._lineNumberWidth - this._scrollLeft, lineOffset + this._textLineHeight);
-                continue;
-            }
+            this._paintLine(i, lineOffset);
+        }
+        this._ctx.restore();
+    },
+
+    _paintLine: function(lineNumber, lineOffset)
+    {
+        var line = this._textModel.line(lineNumber);
+        if (!this._highlightingEnabled) {
+            this._ctx.fillStyle = "rgb(0,0,0)";
+            this._ctx.fillText(line, this._lineNumberWidth - this._scrollLeft, lineOffset + this._textLineHeight);
+            return;
+        }
 
-            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);
+        if (line.length > 1000) {
+            // Optimization: no need to paint decorations outside visible area.
+            var firstColumn = this._columnForOffset(lineNumber, this._scrollLeft);
+            var lastColumn = this._columnForOffset(lineNumber, this._scrollLeft + this._canvas.width);
+        }
+        var highlighterState = this._textModel.getAttribute(lineNumber, "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;
             }
-            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;
-                    j++;
-                } else {
-                    if (plainTextStart !== -1) {
-                        this._ctx.fillStyle = "rgb(0,0,0)";
-                        this._ctx.fillText(line.substring(plainTextStart, j), this._lineNumberWidth - this._scrollLeft + this._columnToOffset(i, plainTextStart), lineOffset + this._textLineHeight);
-                        plainTextStart = -1;
-                    }
-                    this._ctx.fillStyle = attribute.style;
-                    this._ctx.fillText(line.substring(j, j + attribute.length), this._lineNumberWidth - this._scrollLeft + this._columnToOffset(i, j), lineOffset + this._textLineHeight);
-                    j += attribute.length;
+            if (attribute && lastColumn && j > lastColumn)
+                break;
+            if (!attribute || !attribute.style) {
+                if (plainTextStart === -1)
+                    plainTextStart = j;
+                j++;
+            } else {
+                if (plainTextStart !== -1) {
+                    this._ctx.fillStyle = "rgb(0,0,0)";
+                    this._ctx.fillText(line.substring(plainTextStart, j), this._lineNumberWidth - this._scrollLeft + this._columnToOffset(lineNumber, plainTextStart), lineOffset + this._textLineHeight);
+                    plainTextStart = -1;
                 }
-            }
-            if (plainTextStart !== -1) {
-                this._ctx.fillStyle = "rgb(0,0,0)";
-                this._ctx.fillText(line.substring(plainTextStart, j), this._lineNumberWidth - this._scrollLeft + this._columnToOffset(i, plainTextStart), lineOffset + this._textLineHeight);
+                this._ctx.fillStyle = attribute.style;
+                this._ctx.fillText(line.substring(j, j + attribute.length), this._lineNumberWidth - this._scrollLeft + this._columnToOffset(lineNumber, j), lineOffset + this._textLineHeight);
+                j += attribute.length;
             }
         }
-        this._ctx.restore();
+        if (plainTextStart !== -1) {
+            this._ctx.fillStyle = "rgb(0,0,0)";
+            this._ctx.fillText(line.substring(plainTextStart, j), this._lineNumberWidth - this._scrollLeft + this._columnToOffset(lineNumber, plainTextStart), lineOffset + this._textLineHeight);
+        }
     },
 
     paintLineNumbers: function()
@@ -573,7 +592,6 @@ WebInspector.TextEditor.prototype = {
     {
         if (e.offsetX < this._lineNumberWidth && this._lineNumberDecorator) {
             var location = this._caretForMouseEvent(e);
-            var line = location.line;
             if (this._lineNumberDecorator.contextMenu(location.line, e))
                 return;
         } else {
@@ -590,7 +608,6 @@ WebInspector.TextEditor.prototype = {
     _caretForMouseEvent: function(e)
     {
         var lineNumber = Math.max(0, this._offsetToLine(e.offsetY) - 1);
-        var line = this._textModel.line(lineNumber);
         var offset = e.offsetX + this._scrollLeft - this._lineNumberWidth;
         return { line: lineNumber, column: this._columnForOffset(lineNumber, offset) };
     },
@@ -793,18 +810,18 @@ WebInspector.TextEditor.prototype = {
 
         var linesCount = this._textModel.linesCount;
         for (var i = 0; i < linesCount; ++i) {
-            var divDecoration = this._textModel.getAttribute(i, "div-decoration");
-            if (divDecoration)
-                this._positionDivDecoration(i, divDecoration, i > firstLine && i < lastLine);
+            var element = this._textModel.getAttribute(i, "div-decoration");
+            if (element)
+                this._positionDivDecoration(i, element, i > firstLine && i < lastLine);
         }
     },
 
-    _positionDivDecoration: function(lineNumber, divDecoration, visible)
+    _positionDivDecoration: function(lineNumber, element, visible)
     {
-        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 + "px");
+        element.style.position = "absolute";
+        element.style.top = this._lineToOffset(lineNumber) - this._scrollTop + this._textLineHeight + "px";
+        element.style.left = this._lineNumberWidth + "px";
+        element.style.setProperty("max-width", this._canvas.width + "px");
     },
 
     _updateCursor: function(line, column)
@@ -1072,7 +1089,7 @@ WebInspector.TextEditor.prototype = {
 
     _changeFont: function(sansSerif, fontSize) {
         this._initFont(sansSerif, fontSize);
-        this._updateSize(0, this._textModel.linesCount);
+        this._updatePreferredSize(0, this._textModel.linesCount);
         this.repaintAll();
     },
 
diff --git a/WebCore/inspector/front-end/TextEditorHighlighter.js b/WebCore/inspector/front-end/TextEditorHighlighter.js
index 8097302..9a7a050 100644
--- a/WebCore/inspector/front-end/TextEditorHighlighter.js
+++ b/WebCore/inspector/front-end/TextEditorHighlighter.js
@@ -188,7 +188,7 @@ WebInspector.TextEditorHighlighter.prototype = {
              var newColumn = this._tokenizer.nextToken(column);
              var tokenType = this._tokenizer.tokenType;
              if (tokenType)
-                 attributes[column] = { length: newColumn - column, style: this._styles[tokenType] };
+                 attributes[column] = { length: newColumn - column, tokenType: tokenType, style: this._styles[tokenType] };
              column = newColumn;
          } while (column < line.length)
     }
diff --git a/WebCore/inspector/front-end/WebKit.qrc b/WebCore/inspector/front-end/WebKit.qrc
index 1d37d36..20e9aa2 100644
--- a/WebCore/inspector/front-end/WebKit.qrc
+++ b/WebCore/inspector/front-end/WebKit.qrc
@@ -37,6 +37,7 @@
     <file>InspectorFrontendHostStub.js</file>
     <file>KeyboardShortcut.js</file>
     <file>MetricsSidebarPane.js</file>
+    <file>NativeTextViewer.js</file>
     <file>Object.js</file>
     <file>ObjectPropertiesSection.js</file>
     <file>ObjectProxy.js</file>
diff --git a/WebCore/inspector/front-end/inspector.css b/WebCore/inspector/front-end/inspector.css
index b9bae61..8771493 100644
--- a/WebCore/inspector/front-end/inspector.css
+++ b/WebCore/inspector/front-end/inspector.css
@@ -3815,7 +3815,6 @@ ol.breakpoint-list {
 }
 
 .source-breakpoint-condition {
-    position: absolute;
     z-index: 30;
     padding: 4px;
     background-color: rgb(203, 226, 255);
diff --git a/WebCore/inspector/front-end/inspector.html b/WebCore/inspector/front-end/inspector.html
index 1e2082c..26264dc 100644
--- a/WebCore/inspector/front-end/inspector.html
+++ b/WebCore/inspector/front-end/inspector.html
@@ -97,6 +97,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="TextEditorModel.js"></script>
     <script type="text/javascript" src="TextEditor.js"></script>
     <script type="text/javascript" src="TextEditorHighlighter.js"></script>
+    <script type="text/javascript" src="NativeTextViewer.js"></script>
     <script type="text/javascript" src="SourceTokenizer.js"></script>
     <script type="text/javascript" src="SourceCSSTokenizer.js"></script>
     <script type="text/javascript" src="SourceHTMLTokenizer.js"></script>
diff --git a/WebCore/inspector/front-end/textEditor.css b/WebCore/inspector/front-end/textEditor.css
index 5ebfe5f..9629a07 100644
--- a/WebCore/inspector/front-end/textEditor.css
+++ b/WebCore/inspector/front-end/textEditor.css
@@ -44,6 +44,11 @@
     pointer-events: none;
 }
 
+.native-text-editor-line {
+    height: 14px;
+    white-space: pre;
+}
+
 .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