Commit 8c4e41ea authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

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

        Reviewed by Timothy Hatcher.

        Web Inspector: No need to render background sources
        when performing search.

        https://bugs.webkit.org/show_bug.cgi?id=34263

        * inspector/front-end/ScriptView.js:
        (WebInspector.ScriptView):
        (WebInspector.ScriptView.prototype.show):
        * inspector/front-end/SourceFrame.js:
        (WebInspector.SourceFrame):
        (WebInspector.SourceFrame.prototype.set visible):
        (WebInspector.SourceFrame.prototype.set executionLine):
        (WebInspector.SourceFrame.prototype.revealLine):
        (WebInspector.SourceFrame.prototype.clearMessages):
        (WebInspector.SourceFrame.prototype.sizeToFitContentHeight):
        (WebInspector.SourceFrame.prototype.setContent):
        (WebInspector.SourceFrame.prototype._createEditorIfNeeded):
        (WebInspector.SourceFrame.prototype.setSelection):
        (WebInspector.SourceFrame.prototype.clearSelection):
        (WebInspector.SourceFrame.prototype._contextMenu.addConditionalBreakpoint):
        (WebInspector.SourceFrame.prototype._contextMenu):
        (WebInspector.SourceFrame.prototype._toggleBreakpoint):
        (WebInspector.SourceFrame.prototype.resize):
        (WebInspector.BreakpointLineNumberDecorator):
        * inspector/front-end/SourceView.js:
        (WebInspector.SourceView):
        (WebInspector.SourceView.prototype.show):
        (WebInspector.SourceView.prototype.hide):
        (WebInspector.SourceView.prototype.resize):
        * inspector/front-end/TextEditor.js:
        (WebInspector.TextEditor):
        * inspector/front-end/TextEditorHighlighter.js:
        (WebInspector.TextEditorHighlighter):
        * inspector/front-end/TextEditorModel.js:
        (WebInspector.TextEditorModel):
        (WebInspector.TextEditorModel.prototype.set changeListener):
        (WebInspector.TextEditorModel.prototype.setText):


git-svn-id: svn://svn.chromium.org/blink/trunk@54052 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 921f0e81
2010-01-29 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Timothy Hatcher.
Web Inspector: No need to render background sources
when performing search.
https://bugs.webkit.org/show_bug.cgi?id=34263
* inspector/front-end/ScriptView.js:
(WebInspector.ScriptView):
(WebInspector.ScriptView.prototype.show):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame):
(WebInspector.SourceFrame.prototype.set visible):
(WebInspector.SourceFrame.prototype.set executionLine):
(WebInspector.SourceFrame.prototype.revealLine):
(WebInspector.SourceFrame.prototype.clearMessages):
(WebInspector.SourceFrame.prototype.sizeToFitContentHeight):
(WebInspector.SourceFrame.prototype.setContent):
(WebInspector.SourceFrame.prototype._createEditorIfNeeded):
(WebInspector.SourceFrame.prototype.setSelection):
(WebInspector.SourceFrame.prototype.clearSelection):
(WebInspector.SourceFrame.prototype._contextMenu.addConditionalBreakpoint):
(WebInspector.SourceFrame.prototype._contextMenu):
(WebInspector.SourceFrame.prototype._toggleBreakpoint):
(WebInspector.SourceFrame.prototype.resize):
(WebInspector.BreakpointLineNumberDecorator):
* inspector/front-end/SourceView.js:
(WebInspector.SourceView):
(WebInspector.SourceView.prototype.show):
(WebInspector.SourceView.prototype.hide):
(WebInspector.SourceView.prototype.resize):
* inspector/front-end/TextEditor.js:
(WebInspector.TextEditor):
* inspector/front-end/TextEditorHighlighter.js:
(WebInspector.TextEditorHighlighter):
* inspector/front-end/TextEditorModel.js:
(WebInspector.TextEditorModel):
(WebInspector.TextEditorModel.prototype.set changeListener):
(WebInspector.TextEditorModel.prototype.setText):
2010-01-29 Yury Semikhatsky <yurys@chromium.org>
Reviewed by Adam Barth.
......@@ -160,6 +160,7 @@ WebInspector.Drawer.prototype = {
function animationFinished()
{
WebInspector.currentPanel.resize();
var mainStatusBar = document.getElementById("main-status-bar");
mainStatusBar.insertBefore(anchoredItems, mainStatusBar.firstChild);
mainStatusBar.style.removeProperty("padding-left");
......
......@@ -33,9 +33,7 @@ WebInspector.ScriptView = function(script)
this._frameNeedsSetup = true;
this._sourceFrameSetup = false;
this.sourceFrame = new WebInspector.SourceFrame(this._addBreakpoint.bind(this));
this.element.appendChild(this.sourceFrame.element);
this.sourceFrame = new WebInspector.SourceFrame(this.element, this._addBreakpoint.bind(this));
}
WebInspector.ScriptView.prototype = {
......@@ -43,6 +41,7 @@ WebInspector.ScriptView.prototype = {
{
WebInspector.View.prototype.show.call(this, parentElement);
this.setupSourceFrameIfNeeded();
this.sourceFrame.visible = true;
this.resize();
},
......
......@@ -28,27 +28,31 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
WebInspector.SourceFrame = function(addBreakpointDelegate)
WebInspector.SourceFrame = function(parentElement, addBreakpointDelegate)
{
this._editor = new WebInspector.TextEditor(WebInspector.platform);
this._textModel = this._editor.textModel;
this._editor.lineNumberDecorator = new WebInspector.BreakpointLineNumberDecorator(this);
this._editor.lineDecorator = new WebInspector.ExecutionLineDecorator(this);
this._editor.readOnly = true;
this._parentElement = parentElement;
this._textModel = new WebInspector.TextEditorModel();
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;
this._addBreakpointDelegate = addBreakpointDelegate;
}
WebInspector.SourceFrame.prototype = {
set visible(visible)
{
this._visible = visible;
this._createEditorIfNeeded();
},
get executionLine()
{
return this._executionLine;
......@@ -59,15 +63,16 @@ WebInspector.SourceFrame.prototype = {
if (this._executionLine === x)
return;
this._executionLine = x;
this._editor.repaintAll();
if (this._editor)
this._editor.repaintAll();
},
revealLine: function(lineNumber)
{
if (!this._loaded)
this._lineNumberToReveal = lineNumber;
else
if (this._editor)
this._editor.reveal(lineNumber - 1, 0);
else
this._lineNumberToReveal = lineNumber;
},
addBreakpoint: function(breakpoint)
......@@ -93,8 +98,9 @@ WebInspector.SourceFrame.prototype = {
// Don't add the message if there is no message or valid line or if the msg isn't an error or warning.
if (!msg.message || msg.line <= 0 || !msg.isErrorOrWarning())
return;
this._messages.push(msg);
this._addMessageToSource(msg);
this._messages.push(msg)
if (this._editor)
this._addMessageToSource(msg);
},
clearMessages: function()
......@@ -107,22 +113,46 @@ WebInspector.SourceFrame.prototype = {
this._messages = [];
this._rowMessages = {};
this._messageBubbles = {};
this._editor.packAndRepaintAll();
if (this._editor)
this._editor.packAndRepaintAll();
},
sizeToFitContentHeight: function()
{
this._editor.packAndRepaintAll();
if (this._editor)
this._editor.packAndRepaintAll();
},
setContent: function(mimeType, content)
{
this._loaded = true;
this._editor.mimeType = mimeType;
this._editor.text = content;
this._textModel.setText(null, content);
this._mimeType = mimeType;
this._createEditorIfNeeded();
},
_createEditorIfNeeded: function()
{
if (!this._visible || !this._loaded || this._editor)
return;
this._editor = new WebInspector.TextEditor(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;
this._element = this._editor.element;
this._element.addEventListener("keydown", this._keyDown.bind(this), true);
this._parentElement.appendChild(this._element);
this._editor.mimeType = this._mimeType;
this._addExistingMessagesToSource();
this._addExistingBreakpointsToSource();
this._editor.setCoalescingUpdate(true);
this._editor.updateCanvasSize();
this._editor.packAndRepaintAll();
if (this._executionLine)
this.revealLine(this._executionLine);
......@@ -130,9 +160,12 @@ WebInspector.SourceFrame.prototype = {
this.revealLine(this._lineNumberToReveal);
delete this._lineNumberToReveal;
}
this._editor.setCoalescingUpdate(true);
this._editor.updateCanvasSize();
this._editor.packAndRepaintAll();
if (this._pendingSelectionRange) {
var range = this._pendingSelectionRange;
this._editor.setSelection(range.startLine, range.startColumn, range.endLine, range.endColumn);
delete this._pendingSelectionRange;
}
this._editor.setCoalescingUpdate(false);
},
......@@ -180,13 +213,19 @@ WebInspector.SourceFrame.prototype = {
setSelection: function(range)
{
this._editor.setSelection(range.startLine, range.startColumn, range.endLine, range.endColumn);
if (this._editor)
this._editor.setSelection(range.startLine, range.startColumn, range.endLine, range.endColumn);
else
this._pendingSelectionRange = range;
},
clearSelection: function()
{
var range = this._editor.selection;
this._editor.setSelection(range.endLine, range.endColumn, range.endLine, range.endColumn);
if (this._editor) {
var range = this._editor.selection;
this._editor.setSelection(range.endLine, range.endColumn, range.endLine, range.endColumn);
} else
delete this._pendingSelectionRange;
},
_incrementMessageRepeatCount: function(msg, repeatDelta)
......@@ -289,7 +328,7 @@ WebInspector.SourceFrame.prototype = {
_contextMenu: function(lineNumber, event)
{
if (!this.addBreakpointDelegate)
if (!this._addBreakpointDelegate)
return;
var contextMenu = new WebInspector.ContextMenu();
......@@ -297,11 +336,11 @@ WebInspector.SourceFrame.prototype = {
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));
contextMenu.appendItem(WebInspector.UIString("Add Breakpoint"), this._addBreakpointDelegate.bind(this, lineNumber + 1));
function addConditionalBreakpoint()
{
this.addBreakpointDelegate(lineNumber + 1);
this._addBreakpointDelegate(lineNumber + 1);
var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
if (breakpoint)
this._editBreakpointCondition(breakpoint);
......@@ -327,8 +366,8 @@ WebInspector.SourceFrame.prototype = {
var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
if (breakpoint)
WebInspector.panels.scripts.removeBreakpoint(breakpoint);
else if (this.addBreakpointDelegate)
this.addBreakpointDelegate(lineNumber + 1);
else if (this._addBreakpointDelegate)
this._addBreakpointDelegate(lineNumber + 1);
event.preventDefault();
},
......@@ -421,16 +460,17 @@ WebInspector.SourceFrame.prototype = {
resize: function()
{
this._editor.updateCanvasSize();
if (this._editor)
this._editor.updateCanvasSize();
}
}
WebInspector.SourceFrame.prototype.__proto__ = WebInspector.Object.prototype;
WebInspector.BreakpointLineNumberDecorator = function(sourceFrame)
WebInspector.BreakpointLineNumberDecorator = function(sourceFrame, textModel)
{
this._sourceFrame = sourceFrame;
this._textModel = sourceFrame._editor.textModel;
this._textModel = textModel;
}
WebInspector.BreakpointLineNumberDecorator.prototype = {
......
......@@ -30,19 +30,11 @@ WebInspector.SourceView = function(resource)
{
WebInspector.ResourceView.call(this, resource);
this.sourceFrame = new WebInspector.SourceFrame(this._addBreakpoint.bind(this));
resource.addEventListener("finished", this._resourceLoadingFinished, this);
this.element.addStyleClass("source");
this.sourceFrame = new WebInspector.SourceFrame(this.contentElement, this._addBreakpoint.bind(this));
resource.addEventListener("finished", this._resourceLoadingFinished, this);
this._frameNeedsSetup = true;
this.contentElement.appendChild(this.sourceFrame.element);
var gutterElement = document.createElement("div");
gutterElement.className = "webkit-line-gutter-backdrop";
this.contentElement.appendChild(gutterElement);
}
WebInspector.SourceView.prototype = {
......@@ -50,18 +42,20 @@ WebInspector.SourceView.prototype = {
{
WebInspector.ResourceView.prototype.show.call(this, parentElement);
this.setupSourceFrameIfNeeded();
this.sourceFrame.visible = true;
this.resize();
},
hide: function()
{
WebInspector.View.prototype.hide.call(this);
this.sourceFrame.visible = false;
this._currentSearchResultIndex = -1;
},
resize: function()
{
if (this._sourceFrameSetup)
if (this.sourceFrame)
this.sourceFrame.resize();
},
......
......@@ -28,9 +28,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
WebInspector.TextEditor = function(platform)
WebInspector.TextEditor = function(textModel, platform)
{
this._textModel = new WebInspector.TextEditorModel(this._textChanged.bind(this));
this._textModel = textModel;
this._textModel.changeListener = this._textChanged.bind(this);
this._highlighter = new WebInspector.TextEditorHighlighter(this._textModel, this._highlightChanged.bind(this));
this.element = document.createElement("div");
......
......@@ -62,7 +62,8 @@ WebInspector.TextEditorHighlighter = function(textModel, damageCallback)
this._tokenizerConstructors = {
"text/css": WebInspector.SourceCSSTokenizer,
"text/html": WebInspector.SourceHTMLTokenizer,
"text/javascript": WebInspector.SourceJavaScriptTokenizer
"text/javascript": WebInspector.SourceJavaScriptTokenizer,
"application/x-javascript": WebInspector.SourceJavaScriptTokenizer
};
this.mimeType = "text/html";
......
......@@ -53,9 +53,8 @@ WebInspector.TextRange.prototype = {
}
}
WebInspector.TextEditorModel = function(changeListener)
WebInspector.TextEditorModel = function()
{
this._changeListener = changeListener;
this._lines = [""];
this._attributes = [];
this._undoStack = [];
......@@ -63,6 +62,10 @@ WebInspector.TextEditorModel = function(changeListener)
}
WebInspector.TextEditorModel.prototype = {
set changeListener(changeListener)
{
this._changeListener = changeListener;
},
get linesCount()
{
......@@ -89,7 +92,8 @@ WebInspector.TextEditorModel.prototype = {
var newRange = this._innerSetText(range, text);
command.range = newRange.clone();
this._changeListener(range, newRange, command.text, text);
if (this._changeListener)
this._changeListener(range, newRange, command.text, text);
return newRange;
},
......
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