Commit 541880a4 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

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

        Reviewed by Timothy Hatcher.

        Web Inspector: Fix rest of the NativeTextViewer (line numbers,
        conditional breakpoints, selection).

        * inspector/front-end/NativeTextViewer.js:
        (WebInspector.NativeTextViewer):
        (WebInspector.NativeTextViewer.prototype._updatePreferredSize):
        (WebInspector.NativeTextViewer.prototype._registerMouseListeners):
        (WebInspector.NativeTextViewer.prototype._mouseDown):
        (WebInspector.NativeTextViewer.prototype._contextMenu):
        (WebInspector.NativeTextViewer.prototype._lineForMouseEvent):
        (WebInspector.NativeTextViewer.prototype._lineHeight):
        * inspector/front-end/TextEditor.js:
        (WebInspector.TextEditor):
        (WebInspector.TextEditor.prototype._registerMouseListeners):
        (WebInspector.TextEditor.prototype._offsetToLine):
        (WebInspector.TextEditor.prototype._lineHeight):
        (WebInspector.TextEditor.prototype.reveal):
        (WebInspector.TextEditor.prototype._paint):
        (WebInspector.TextEditor.prototype._updateDivDecorations):
        (WebInspector.TextEditor.prototype._paintSelection):


git-svn-id: svn://svn.chromium.org/blink/trunk@54133 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 394a5dfc
2010-02-01 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Timothy Hatcher.
Web Inspector: Fix rest of the NativeTextViewer (line numbers,
conditional breakpoints, selection).
* inspector/front-end/NativeTextViewer.js:
(WebInspector.NativeTextViewer):
(WebInspector.NativeTextViewer.prototype._updatePreferredSize):
(WebInspector.NativeTextViewer.prototype._registerMouseListeners):
(WebInspector.NativeTextViewer.prototype._mouseDown):
(WebInspector.NativeTextViewer.prototype._contextMenu):
(WebInspector.NativeTextViewer.prototype._lineForMouseEvent):
(WebInspector.NativeTextViewer.prototype._lineHeight):
* inspector/front-end/TextEditor.js:
(WebInspector.TextEditor):
(WebInspector.TextEditor.prototype._registerMouseListeners):
(WebInspector.TextEditor.prototype._offsetToLine):
(WebInspector.TextEditor.prototype._lineHeight):
(WebInspector.TextEditor.prototype.reveal):
(WebInspector.TextEditor.prototype._paint):
(WebInspector.TextEditor.prototype._updateDivDecorations):
(WebInspector.TextEditor.prototype._paintSelection):
2010-02-01 Steve Block <steveblock@google.com> 2010-02-01 Steve Block <steveblock@google.com>
Reviewed by Ariya Hidayat. Reviewed by Ariya Hidayat.
......
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
WebInspector.NativeTextViewer = function(textModel, platform) WebInspector.NativeTextViewer = function(textModel, platform)
{ {
WebInspector.TextEditor.call(this, textModel, platform); WebInspector.TextEditor.call(this, textModel, platform);
this._sheet.className = "monospace";
this._sheet.tabIndex = 0; this._sheet.tabIndex = 0;
this._canvas.style.zIndex = 0; this._canvas.style.zIndex = 0;
this._createLineDivs(); this._createLineDivs();
this._selectionColor = "rgb(241, 234, 0)";
} }
WebInspector.NativeTextViewer.prototype = { WebInspector.NativeTextViewer.prototype = {
...@@ -52,7 +52,10 @@ WebInspector.NativeTextViewer.prototype = { ...@@ -52,7 +52,10 @@ WebInspector.NativeTextViewer.prototype = {
for (var i = 0; i < this._textModel.linesCount; ++i) { for (var i = 0; i < this._textModel.linesCount; ++i) {
var lineDiv = document.createElement("div"); var lineDiv = document.createElement("div");
lineDiv.className = "native-text-editor-line"; lineDiv.className = "native-text-editor-line";
lineDiv.textContent = this._textModel.line(i); var text = this._textModel.line(i);
lineDiv.textContent = text;
if (!text)
lineDiv.style.minHeight = this._textLineHeight + "px";
this._sheet.appendChild(lineDiv); this._sheet.appendChild(lineDiv);
this._textModel.setAttribute(i, "line-div", lineDiv); this._textModel.setAttribute(i, "line-div", lineDiv);
} }
...@@ -68,7 +71,7 @@ WebInspector.NativeTextViewer.prototype = { ...@@ -68,7 +71,7 @@ WebInspector.NativeTextViewer.prototype = {
var newLineNumberDigits = this._decimalDigits(this._textModel.linesCount); var newLineNumberDigits = this._decimalDigits(this._textModel.linesCount);
this._lineNumberWidth = (newLineNumberDigits + 2) * this._digitWidth; this._lineNumberWidth = (newLineNumberDigits + 2) * this._digitWidth;
this._sheet.style.paddingLeft = this._textWidth + this._lineNumberWidth + "px"; this._container.style.left = this._lineNumberWidth + "px";
this._lineNumberDigits = newLineNumberDigits; this._lineNumberDigits = newLineNumberDigits;
this.repaintAll(); this.repaintAll();
...@@ -86,7 +89,8 @@ WebInspector.NativeTextViewer.prototype = { ...@@ -86,7 +89,8 @@ WebInspector.NativeTextViewer.prototype = {
_registerMouseListeners: function() _registerMouseListeners: function()
{ {
this._sheet.addEventListener("mousedown", this._mouseDown.bind(this), false); this.element.addEventListener("contextmenu", this._contextMenu.bind(this), false);
this.element.addEventListener("mousedown", this._mouseDown.bind(this), false);
}, },
_registerKeyboardListeners: function() _registerKeyboardListeners: function()
...@@ -99,44 +103,48 @@ WebInspector.NativeTextViewer.prototype = { ...@@ -99,44 +103,48 @@ WebInspector.NativeTextViewer.prototype = {
// Noop - let browser take care of this. // Noop - let browser take care of this.
}, },
_paintSelection: function() _positionDivDecoration: function()
{ {
// Noop - let browser take care of this. // Div decorations have fixed positions in our case.
}, },
_positionDivDecoration: function() _registerShortcuts: function()
{ {
// Div decorations have fixed positions in our case. // Noop.
}, },
_mouseDown: function(e) _mouseDown: function(e)
{ {
if (e.offsetX + e.target.offsetTop >= this._lineNumberWidth && this._lineNumberDecorator) if (e.target !== this.element || e.button === 2 || (this._isMac && e.ctrlKey))
return; return;
this._lineNumberDecorator.mouseDown(this._lineForMouseEvent(e), e);
if (e.button === 2 || (this._isMac && e.ctrlKey))
return;
var location = this._caretForMouseEvent(e);
this._lineNumberDecorator.mouseDown(location.line, e);
}, },
_contextMenu: function(e) _contextMenu: function(e)
{ {
// Override editor's implementation to add the line's offsets. if (e.target !== this.element)
if (e.offsetX + e.target.offsetTop >= this._lineNumberWidth && this._lineNumberDecorator)
return; return;
this._lineNumberDecorator.contextMenu(this._lineForMouseEvent(e), e);
},
var location = this._caretForMouseEvent(e); _lineForMouseEvent: function(e)
this._lineNumberDecorator.contextMenu(location.line, e); {
return Math.max(0, this._offsetToLine(e.offsetY + this._scrollTop) - 1);
}, },
_caretForMouseEvent: function(e) _lineHeight: function(lineNumber)
{ {
// Override editor's implementation to add the line's offsets. // Use cached value first.
var lineNumber = Math.max(0, this._offsetToLine(e.offsetY + e.target.offsetTop) - 1); if (this._lineOffsetsCache[lineNumber + 1])
var offset = e.offsetX + e.target.offsetLeft + this._scrollLeft - this._lineNumberWidth; return this._lineOffsetsCache[lineNumber + 1] - this._lineOffsetsCache[lineNumber];
return { line: lineNumber, column: this._columnForOffset(lineNumber, offset) };
// Get metrics from the browser.
var element = this._textModel.getAttribute(lineNumber, "line-div");
if (lineNumber + 1 < this._textModel.linesCount) {
var nextElement = this._textModel.getAttribute(lineNumber + 1, "line-div");
return nextElement.offsetTop - element.offsetTop;
} else
return element.parentElement.offsetHeight - element.offsetTop;
}, },
_paintLine: function(lineNumber, lineOffset) _paintLine: function(lineNumber, lineOffset)
...@@ -203,6 +211,16 @@ WebInspector.NativeTextViewer.prototype = { ...@@ -203,6 +211,16 @@ WebInspector.NativeTextViewer.prototype = {
this._textModel.setAttribute(lineNumber, "div-decoration", element); this._textModel.setAttribute(lineNumber, "div-decoration", element);
} }
this.revalidateDecorationsAndPaint(); this.revalidateDecorationsAndPaint();
},
_initFontMetrics: function()
{
WebInspector.TextEditor.prototype._initFontMetrics.call(this);
for (var i = 0; i < this._textModel.linesCount; ++i) {
var lineDiv = this._textModel.getAttribute(i, "line-div");
if (!this._textModel.line(i))
lineDiv.style.minHeight = this._textLineHeight + "px";
}
} }
} }
......
...@@ -39,7 +39,7 @@ var Preferences = { ...@@ -39,7 +39,7 @@ var Preferences = {
showMissingLocalizedStrings: false, showMissingLocalizedStrings: false,
samplingCPUProfiler: false, samplingCPUProfiler: false,
showColorNicknames: true, showColorNicknames: true,
useCanvasBasedEditor: true useCanvasBasedEditor: false
} }
WebInspector.populateFrontendSettings = function(settingsString) WebInspector.populateFrontendSettings = function(settingsString)
......
...@@ -144,6 +144,7 @@ WebInspector.SourceFrame.prototype = { ...@@ -144,6 +144,7 @@ WebInspector.SourceFrame.prototype = {
this._element = this._editor.element; this._element = this._editor.element;
this._element.addEventListener("keydown", this._keyDown.bind(this), true); this._element.addEventListener("keydown", this._keyDown.bind(this), true);
this._parentElement.appendChild(this._element); this._parentElement.appendChild(this._element);
this._editor._initFontMetrics();
this._editor.mimeType = this._mimeType; this._editor.mimeType = this._mimeType;
......
...@@ -505,7 +505,6 @@ body.drawer-visible #drawer { ...@@ -505,7 +505,6 @@ body.drawer-visible #drawer {
body.platform-mac-tiger .monospace, body.platform-mac-leopard .monospace, body.platform-mac-tiger .monospace, body.platform-mac-leopard .monospace,
body.platform-mac-tiger .source-code, body.platform-mac-leopard .source-code { body.platform-mac-tiger .source-code, body.platform-mac-leopard .source-code {
font-size: 10px;
font-family: Monaco, monospace; font-family: Monaco, monospace;
} }
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
} }
.native-text-editor-line { .native-text-editor-line {
height: 14px;
white-space: pre; white-space: pre;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment