[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:35:17 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 53d391b6b5deb808bf52a8f1d8ca4eb26a4f1fa7
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Feb 1 14:05:54 2010 +0000
2010-02-01 Pavel Feldman <pfeldman at 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: http://svn.webkit.org/repository/webkit/trunk@54133 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 5425140..894d9d3 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,28 @@
+2010-02-01 Pavel Feldman <pfeldman at 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 at google.com>
Reviewed by Ariya Hidayat.
diff --git a/WebCore/inspector/front-end/NativeTextViewer.js b/WebCore/inspector/front-end/NativeTextViewer.js
index 53b213d..3b9650c 100644
--- a/WebCore/inspector/front-end/NativeTextViewer.js
+++ b/WebCore/inspector/front-end/NativeTextViewer.js
@@ -31,10 +31,10 @@
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();
+ this._selectionColor = "rgb(241, 234, 0)";
}
WebInspector.NativeTextViewer.prototype = {
@@ -52,7 +52,10 @@ WebInspector.NativeTextViewer.prototype = {
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);
+ var text = this._textModel.line(i);
+ lineDiv.textContent = text;
+ if (!text)
+ lineDiv.style.minHeight = this._textLineHeight + "px";
this._sheet.appendChild(lineDiv);
this._textModel.setAttribute(i, "line-div", lineDiv);
}
@@ -68,7 +71,7 @@ WebInspector.NativeTextViewer.prototype = {
var newLineNumberDigits = this._decimalDigits(this._textModel.linesCount);
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.repaintAll();
@@ -86,7 +89,8 @@ WebInspector.NativeTextViewer.prototype = {
_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()
@@ -99,44 +103,48 @@ WebInspector.NativeTextViewer.prototype = {
// 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)
{
- if (e.offsetX + e.target.offsetTop >= this._lineNumberWidth && this._lineNumberDecorator)
+ if (e.target !== this.element || e.button === 2 || (this._isMac && e.ctrlKey))
return;
-
- if (e.button === 2 || (this._isMac && e.ctrlKey))
- return;
-
- var location = this._caretForMouseEvent(e);
- this._lineNumberDecorator.mouseDown(location.line, e);
+ this._lineNumberDecorator.mouseDown(this._lineForMouseEvent(e), e);
},
_contextMenu: function(e)
{
- // Override editor's implementation to add the line's offsets.
- if (e.offsetX + e.target.offsetTop >= this._lineNumberWidth && this._lineNumberDecorator)
+ if (e.target !== this.element)
return;
+ this._lineNumberDecorator.contextMenu(this._lineForMouseEvent(e), e);
+ },
- var location = this._caretForMouseEvent(e);
- this._lineNumberDecorator.contextMenu(location.line, e);
+ _lineForMouseEvent: function(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.
- 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) };
+ // Use cached value first.
+ if (this._lineOffsetsCache[lineNumber + 1])
+ return this._lineOffsetsCache[lineNumber + 1] - this._lineOffsetsCache[lineNumber];
+
+ // 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)
@@ -203,6 +211,16 @@ WebInspector.NativeTextViewer.prototype = {
this._textModel.setAttribute(lineNumber, "div-decoration", element);
}
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";
+ }
}
}
diff --git a/WebCore/inspector/front-end/Settings.js b/WebCore/inspector/front-end/Settings.js
index 1838068..bc0daa5 100644
--- a/WebCore/inspector/front-end/Settings.js
+++ b/WebCore/inspector/front-end/Settings.js
@@ -39,7 +39,7 @@ var Preferences = {
showMissingLocalizedStrings: false,
samplingCPUProfiler: false,
showColorNicknames: true,
- useCanvasBasedEditor: true
+ useCanvasBasedEditor: false
}
WebInspector.populateFrontendSettings = function(settingsString)
diff --git a/WebCore/inspector/front-end/SourceFrame.js b/WebCore/inspector/front-end/SourceFrame.js
index 1e1bd0c..ffb2bc3 100644
--- a/WebCore/inspector/front-end/SourceFrame.js
+++ b/WebCore/inspector/front-end/SourceFrame.js
@@ -144,6 +144,7 @@ WebInspector.SourceFrame.prototype = {
this._element = this._editor.element;
this._element.addEventListener("keydown", this._keyDown.bind(this), true);
this._parentElement.appendChild(this._element);
+ this._editor._initFontMetrics();
this._editor.mimeType = this._mimeType;
diff --git a/WebCore/inspector/front-end/TextEditor.js b/WebCore/inspector/front-end/TextEditor.js
index afa97c1..73b5aab 100644
--- a/WebCore/inspector/front-end/TextEditor.js
+++ b/WebCore/inspector/front-end/TextEditor.js
@@ -35,7 +35,8 @@ WebInspector.TextEditor = function(textModel, platform)
this._highlighter = new WebInspector.TextEditorHighlighter(this._textModel, this._highlightChanged.bind(this));
this.element = document.createElement("div");
- this.element.className = "text-editor";
+ this.element.className = "text-editor monospace";
+ this.element.tabIndex = 0;
this._canvas = document.createElement("canvas");
this._canvas.className = "text-editor-canvas";
@@ -43,7 +44,6 @@ 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");
@@ -55,7 +55,6 @@ WebInspector.TextEditor = function(textModel, platform)
this._cursor = new WebInspector.TextCursor(cursorElement);
this._container.addEventListener("scroll", this._scroll.bind(this), false);
- this._sheet.addEventListener("contextmenu", this._contextMenu.bind(this), false);
this._registerMouseListeners();
this._registerKeyboardListeners();
@@ -69,9 +68,6 @@ WebInspector.TextEditor = function(textModel, platform)
this._selection = new WebInspector.TextSelectionModel(this._selectionChanged.bind(this));
this._isMac = platform && (platform.indexOf("mac") === 0);
-
- this._initFont();
-
this._paintCoalescingLevel = 0;
this._registerShortcuts();
@@ -84,6 +80,7 @@ WebInspector.TextEditor = function(textModel, platform)
this._lineOffsetsCache = [0];
this._readOnly = false;
+ this._selectionColor = "rgb(181, 213, 255)";
}
WebInspector.TextEditor.prototype = {
@@ -152,11 +149,12 @@ WebInspector.TextEditor.prototype = {
_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);
+ this.element.addEventListener("contextmenu", this._contextMenu.bind(this), false);
+ this.element.addEventListener("mouseup", this._mouseUp.bind(this), false);
+ this.element.addEventListener("mousedown", this._mouseDown.bind(this), false);
+ this.element.addEventListener("mousemove", this._mouseMove.bind(this), false);
+ this.element.addEventListener("mouseout", this._mouseOut.bind(this), false);
+ this.element.addEventListener("dblclick", this._dblClick.bind(this), false);
},
_registerKeyboardListeners: function()
@@ -180,7 +178,7 @@ WebInspector.TextEditor.prototype = {
if (offset > this._lineOffsetsCache[this._lineOffsetsCache.length - 1]) {
// Seeking outside cached area. Fill the cache.
var lineNumber = this._lineOffsetsCache.length;
- while (this._lineToOffset(lineNumber) < offset)
+ while (lineNumber < this._textModel.linesCount && this._lineToOffset(lineNumber) < offset)
lineNumber++;
return lineNumber;
}
@@ -217,6 +215,10 @@ WebInspector.TextEditor.prototype = {
_lineHeight: function(lineNumber)
{
+ // Use cached value first.
+ if (this._lineOffsetsCache[lineNumber + 1])
+ return this._lineOffsetsCache[lineNumber + 1] - this._lineOffsetsCache[lineNumber];
+
var element = this._textModel.getAttribute(lineNumber, "div-decoration");
if (element)
return 2 * this._textLineHeight + element.clientHeight;
@@ -225,6 +227,9 @@ WebInspector.TextEditor.prototype = {
reveal: function(line, column)
{
+ this._scrollTop = this._container.scrollTop;
+ this._scrollLeft = this._container.scrollLeft;
+
var maxScrollTop = this._lineToOffset(line);
var minScrollTop = maxScrollTop + this._lineHeight(line) - this._canvas.height;
if (this._scrollTop > maxScrollTop)
@@ -237,8 +242,10 @@ WebInspector.TextEditor.prototype = {
var minScrollLeft = maxScrollLeft - this._container.clientWidth + this._lineNumberWidth;
if (this._scrollLeft < minScrollLeft)
this._container.scrollLeft = minScrollLeft + 100;
- if (this._scrollLeft > maxScrollLeft)
+ else if (this._scrollLeft > maxScrollLeft)
this._container.scrollLeft = maxScrollLeft;
+ else if (minScrollLeft < 0 && maxScrollLeft > 0)
+ this._container.scrollLeft = 0;
},
// WebInspector.TextModel listener
@@ -326,8 +333,9 @@ WebInspector.TextEditor.prototype = {
var newLineNumberDigits = this._decimalDigits(this._textModel.linesCount);
this._lineNumberWidth = (newLineNumberDigits + 2) * this._digitWidth;
+ this._container.style.left = this._lineNumberWidth + "px";
- var newWidth = this._textWidth + this._lineNumberWidth + "px";
+ var newWidth = this._textWidth + "px";
var newHeight = this._lineToOffset(this._textModel.linesCount) + "px";
this._sheet.style.width = newWidth;
this._sheet.style.height = newHeight;
@@ -345,7 +353,7 @@ WebInspector.TextEditor.prototype = {
resize: function()
{
if (this._canvas.width !== this._container.clientWidth || this._canvas.height !== this._container.clientHeight) {
- this._canvas.width = this._container.clientWidth;
+ this._canvas.width = this._container.clientWidth + this._lineNumberWidth;
this._canvas.height = this._container.clientHeight;
this.repaintAll();
}
@@ -376,16 +384,20 @@ WebInspector.TextEditor.prototype = {
_paint: function()
{
+ this._scrollTop = this._container.scrollTop;
+ this._scrollLeft = this._container.scrollLeft;
+
if (this._paintCoalescingLevel)
return;
+ this._updateDivDecorations();
+
this.paintLineNumbers();
for (var i = 0; this._damage && i < this._damage.length; ++i)
this._paintLines(this._damage[i].startLine, this._damage[i].endLine);
delete this._damage;
- this._updateDivDecorations();
this._updateCursor(this._selection.endLine, this._selection.endColumn);
},
@@ -556,7 +568,7 @@ WebInspector.TextEditor.prototype = {
var location = this._caretForMouseEvent(e);
- if (e.offsetX < this._lineNumberWidth && this._lineNumberDecorator) {
+ if (e.target === this.element && this._lineNumberDecorator) {
if (this._lineNumberDecorator.mouseDown(location.line, e))
return;
}
@@ -590,7 +602,7 @@ WebInspector.TextEditor.prototype = {
_contextMenu: function(e)
{
- if (e.offsetX < this._lineNumberWidth && this._lineNumberDecorator) {
+ if (e.target === this.element && this._lineNumberDecorator) {
var location = this._caretForMouseEvent(e);
if (this._lineNumberDecorator.contextMenu(location.line, e))
return;
@@ -607,8 +619,8 @@ WebInspector.TextEditor.prototype = {
_caretForMouseEvent: function(e)
{
- var lineNumber = Math.max(0, this._offsetToLine(e.offsetY) - 1);
- var offset = e.offsetX + this._scrollLeft - this._lineNumberWidth;
+ var lineNumber = Math.max(0, this._offsetToLine(e.offsetY + (e.target === this.element ? this._scrollTop : 0)) - 1);
+ var offset = e.offsetX + this._scrollLeft;
return { line: lineNumber, column: this._columnForOffset(lineNumber, offset) };
},
@@ -811,8 +823,10 @@ WebInspector.TextEditor.prototype = {
var linesCount = this._textModel.linesCount;
for (var i = 0; i < linesCount; ++i) {
var element = this._textModel.getAttribute(i, "div-decoration");
- if (element)
+ if (element) {
+ this._lineOffsetsCache.length = Math.min(this._lineOffsetsCache.length, i + 1);
this._positionDivDecoration(i, element, i > firstLine && i < lastLine);
+ }
}
},
@@ -848,7 +862,7 @@ WebInspector.TextEditor.prototype = {
if (this._selection.isEmpty())
return;
var range = this._selection.range();
- this._ctx.fillStyle = "rgb(181, 213, 255)";
+ this._ctx.fillStyle = this._selectionColor;
firstLine = Math.max(firstLine, range.startLine);
endLine = Math.min(lastLine, range.endLine + 1);
@@ -962,34 +976,14 @@ WebInspector.TextEditor.prototype = {
this._updateCursor(this._selection.endLine, this._selection.endColumn);
},
- _initFont: function(sansSerif)
+ _initFontMetrics: function()
{
- if (!WebInspector.TextEditor.PlatformFonts) {
- WebInspector.TextEditor.PlatformFonts = {};
- WebInspector.TextEditor.PlatformFonts[WebInspector.OS.Windows] = {size: 12, face: "Lucida Console"};
- WebInspector.TextEditor.PlatformFonts[WebInspector.OS.WindowsVistaOrLater] = {size: 12, face: "Courier"};
- WebInspector.TextEditor.PlatformFonts[WebInspector.OS.MacSnowLeopard] = {size: 11, face: "Menlo"};
- WebInspector.TextEditor.PlatformFonts[WebInspector.OS.MacLeopard] = {size: 10, face: "Monaco"};
- WebInspector.TextEditor.PlatformFonts[WebInspector.OS.MacTiger] = {size: 10, face: "Monaco"};
- }
-
- if (sansSerif) {
- this._isMonospace = false;
- this._fontSize = 11;
- this._font = this._fontSize + "px sans-serif";
- } else {
- this._isMonospace = true;
- const platform = WebInspector.platform;
- const fontInfo = WebInspector.TextEditor.PlatformFonts[platform] || {size: 10, face: "monospace"};
- this._fontSize = fontInfo.size;
- this._font = this._fontSize + "px " + fontInfo.face;
- }
+ var computedStyle = window.getComputedStyle(this.element);
+ this._font = computedStyle.fontSize + " " + computedStyle.fontFamily;
this._ctx.font = this._font;
this._digitWidth = this._ctx.measureText("0").width;
-
- this._textLineHeight = Math.floor(this._fontSize * 1.4);
+ this._textLineHeight = Math.floor(parseInt(this._ctx.font) * 1.4);
this._cursor.setTextLineHeight(this._textLineHeight);
- this._lineOffsetsCache = [0];
},
_registerShortcuts: function()
@@ -999,9 +993,6 @@ WebInspector.TextEditor.prototype = {
this._shortcuts[WebInspector.KeyboardShortcut.makeKey("z", this._isMac ? modifiers.Meta : modifiers.Ctrl)] = this._handleUndo.bind(this);
this._shortcuts[WebInspector.KeyboardShortcut.makeKey("z", modifiers.Shift | (this._isMac ? modifiers.Meta : modifiers.Ctrl))] = this._handleRedo.bind(this);
this._shortcuts[WebInspector.KeyboardShortcut.makeKey("a", this._isMac ? modifiers.Meta : modifiers.Ctrl)] = this._selectAll.bind(this);
- this._shortcuts[WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.Plus, this._isMac ? modifiers.Meta : modifiers.Ctrl)] = this._handleZoomIn.bind(this);
- this._shortcuts[WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.Minus, this._isMac ? modifiers.Meta : modifiers.Ctrl)] = this._handleZoomOut.bind(this);
- this._shortcuts[WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.Zero, this._isMac ? modifiers.Meta : modifiers.Ctrl)] = this._handleZoomReset.bind(this);
if (this._isMac)
this._shortcuts[WebInspector.KeyboardShortcut.makeKey("d", modifiers.Ctrl)] = this._handleDeleteKey.bind(this);
@@ -1065,34 +1056,6 @@ WebInspector.TextEditor.prototype = {
this._debugMode = !this._debugMode;
},
- _handleZoomIn: function()
- {
- if (this._fontSize < 25)
- this._changeFont(!this._isMonospace, this._fontSize + 1);
- },
-
- _handleZoomOut: function()
- {
- if (this._fontSize > 1)
- this._changeFont(!this._isMonospace, this._fontSize - 1);
- },
-
- _handleZoomReset: function()
- {
- this._changeFont(!this._isMonospace);
- },
-
- _handleToggleMonospaceMode: function()
- {
- this._changeFont(this._isMonospace, this._fontSize);
- },
-
- _changeFont: function(sansSerif, fontSize) {
- this._initFont(sansSerif, fontSize);
- this._updatePreferredSize(0, this._textModel.linesCount);
- this.repaintAll();
- },
-
_handleToggleHighlightMode: function()
{
this._highlightingEnabled = !this._highlightingEnabled;
diff --git a/WebCore/inspector/front-end/inspector.css b/WebCore/inspector/front-end/inspector.css
index 501915d..55804f3 100644
--- a/WebCore/inspector/front-end/inspector.css
+++ b/WebCore/inspector/front-end/inspector.css
@@ -505,7 +505,6 @@ body.drawer-visible #drawer {
body.platform-mac-tiger .monospace, body.platform-mac-leopard .monospace,
body.platform-mac-tiger .source-code, body.platform-mac-leopard .source-code {
- font-size: 10px;
font-family: Monaco, monospace;
}
diff --git a/WebCore/inspector/front-end/textEditor.css b/WebCore/inspector/front-end/textEditor.css
index 9629a07..93495f2 100644
--- a/WebCore/inspector/front-end/textEditor.css
+++ b/WebCore/inspector/front-end/textEditor.css
@@ -45,7 +45,6 @@
}
.native-text-editor-line {
- height: 14px;
white-space: pre;
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list