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> 2010-01-29 Yury Semikhatsky <yurys@chromium.org>
Reviewed by Adam Barth. Reviewed by Adam Barth.
...@@ -160,6 +160,7 @@ WebInspector.Drawer.prototype = { ...@@ -160,6 +160,7 @@ WebInspector.Drawer.prototype = {
function animationFinished() function animationFinished()
{ {
WebInspector.currentPanel.resize();
var mainStatusBar = document.getElementById("main-status-bar"); var mainStatusBar = document.getElementById("main-status-bar");
mainStatusBar.insertBefore(anchoredItems, mainStatusBar.firstChild); mainStatusBar.insertBefore(anchoredItems, mainStatusBar.firstChild);
mainStatusBar.style.removeProperty("padding-left"); mainStatusBar.style.removeProperty("padding-left");
......
...@@ -33,9 +33,7 @@ WebInspector.ScriptView = function(script) ...@@ -33,9 +33,7 @@ WebInspector.ScriptView = function(script)
this._frameNeedsSetup = true; this._frameNeedsSetup = true;
this._sourceFrameSetup = false; this._sourceFrameSetup = false;
this.sourceFrame = new WebInspector.SourceFrame(this._addBreakpoint.bind(this)); this.sourceFrame = new WebInspector.SourceFrame(this.element, this._addBreakpoint.bind(this));
this.element.appendChild(this.sourceFrame.element);
} }
WebInspector.ScriptView.prototype = { WebInspector.ScriptView.prototype = {
...@@ -43,6 +41,7 @@ WebInspector.ScriptView.prototype = { ...@@ -43,6 +41,7 @@ WebInspector.ScriptView.prototype = {
{ {
WebInspector.View.prototype.show.call(this, parentElement); WebInspector.View.prototype.show.call(this, parentElement);
this.setupSourceFrameIfNeeded(); this.setupSourceFrameIfNeeded();
this.sourceFrame.visible = true;
this.resize(); this.resize();
}, },
......
...@@ -28,27 +28,31 @@ ...@@ -28,27 +28,31 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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._parentElement = parentElement;
this._textModel = this._editor.textModel;
this._editor.lineNumberDecorator = new WebInspector.BreakpointLineNumberDecorator(this); this._textModel = new WebInspector.TextEditorModel();
this._editor.lineDecorator = new WebInspector.ExecutionLineDecorator(this);
this._editor.readOnly = true;
this._messages = []; this._messages = [];
this._rowMessages = {}; this._rowMessages = {};
this._messageBubbles = {}; this._messageBubbles = {};
this.breakpoints = []; this.breakpoints = [];
this._shortcuts = {}; this._shortcuts = {};
this.element = this._editor.element;
this.element.addEventListener("keydown", this._keyDown.bind(this), true);
this._loaded = false; this._loaded = false;
this.addBreakpointDelegate = addBreakpointDelegate; this._addBreakpointDelegate = addBreakpointDelegate;
} }
WebInspector.SourceFrame.prototype = { WebInspector.SourceFrame.prototype = {
set visible(visible)
{
this._visible = visible;
this._createEditorIfNeeded();
},
get executionLine() get executionLine()
{ {
return this._executionLine; return this._executionLine;
...@@ -59,15 +63,16 @@ WebInspector.SourceFrame.prototype = { ...@@ -59,15 +63,16 @@ WebInspector.SourceFrame.prototype = {
if (this._executionLine === x) if (this._executionLine === x)
return; return;
this._executionLine = x; this._executionLine = x;
this._editor.repaintAll(); if (this._editor)
this._editor.repaintAll();
}, },
revealLine: function(lineNumber) revealLine: function(lineNumber)
{ {
if (!this._loaded) if (this._editor)
this._lineNumberToReveal = lineNumber;
else
this._editor.reveal(lineNumber - 1, 0); this._editor.reveal(lineNumber - 1, 0);
else
this._lineNumberToReveal = lineNumber;
}, },
addBreakpoint: function(breakpoint) addBreakpoint: function(breakpoint)
...@@ -93,8 +98,9 @@ WebInspector.SourceFrame.prototype = { ...@@ -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. // 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()) if (!msg.message || msg.line <= 0 || !msg.isErrorOrWarning())
return; return;
this._messages.push(msg); this._messages.push(msg)
this._addMessageToSource(msg); if (this._editor)
this._addMessageToSource(msg);
}, },
clearMessages: function() clearMessages: function()
...@@ -107,22 +113,46 @@ WebInspector.SourceFrame.prototype = { ...@@ -107,22 +113,46 @@ WebInspector.SourceFrame.prototype = {
this._messages = []; this._messages = [];
this._rowMessages = {}; this._rowMessages = {};
this._messageBubbles = {}; this._messageBubbles = {};
this._editor.packAndRepaintAll(); if (this._editor)
this._editor.packAndRepaintAll();
}, },
sizeToFitContentHeight: function() sizeToFitContentHeight: function()
{ {
this._editor.packAndRepaintAll(); if (this._editor)
this._editor.packAndRepaintAll();
}, },
setContent: function(mimeType, content) setContent: function(mimeType, content)
{ {
this._loaded = true; this._loaded = true;
this._editor.mimeType = mimeType; this._textModel.setText(null, content);
this._editor.text = 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._addExistingMessagesToSource();
this._addExistingBreakpointsToSource(); this._addExistingBreakpointsToSource();
this._editor.setCoalescingUpdate(true);
this._editor.updateCanvasSize();
this._editor.packAndRepaintAll();
if (this._executionLine) if (this._executionLine)
this.revealLine(this._executionLine); this.revealLine(this._executionLine);
...@@ -130,9 +160,12 @@ WebInspector.SourceFrame.prototype = { ...@@ -130,9 +160,12 @@ WebInspector.SourceFrame.prototype = {
this.revealLine(this._lineNumberToReveal); this.revealLine(this._lineNumberToReveal);
delete this._lineNumberToReveal; delete this._lineNumberToReveal;
} }
this._editor.setCoalescingUpdate(true);
this._editor.updateCanvasSize(); if (this._pendingSelectionRange) {
this._editor.packAndRepaintAll(); var range = this._pendingSelectionRange;
this._editor.setSelection(range.startLine, range.startColumn, range.endLine, range.endColumn);
delete this._pendingSelectionRange;
}
this._editor.setCoalescingUpdate(false); this._editor.setCoalescingUpdate(false);
}, },
...@@ -180,13 +213,19 @@ WebInspector.SourceFrame.prototype = { ...@@ -180,13 +213,19 @@ WebInspector.SourceFrame.prototype = {
setSelection: function(range) 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() clearSelection: function()
{ {
var range = this._editor.selection; if (this._editor) {
this._editor.setSelection(range.endLine, range.endColumn, range.endLine, range.endColumn); var range = this._editor.selection;
this._editor.setSelection(range.endLine, range.endColumn, range.endLine, range.endColumn);
} else
delete this._pendingSelectionRange;
}, },
_incrementMessageRepeatCount: function(msg, repeatDelta) _incrementMessageRepeatCount: function(msg, repeatDelta)
...@@ -289,7 +328,7 @@ WebInspector.SourceFrame.prototype = { ...@@ -289,7 +328,7 @@ WebInspector.SourceFrame.prototype = {
_contextMenu: function(lineNumber, event) _contextMenu: function(lineNumber, event)
{ {
if (!this.addBreakpointDelegate) if (!this._addBreakpointDelegate)
return; return;
var contextMenu = new WebInspector.ContextMenu(); var contextMenu = new WebInspector.ContextMenu();
...@@ -297,11 +336,11 @@ WebInspector.SourceFrame.prototype = { ...@@ -297,11 +336,11 @@ WebInspector.SourceFrame.prototype = {
var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint"); var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
if (!breakpoint) { if (!breakpoint) {
// This row doesn't have a breakpoint: We want to show Add Breakpoint and Add and Edit 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() function addConditionalBreakpoint()
{ {
this.addBreakpointDelegate(lineNumber + 1); this._addBreakpointDelegate(lineNumber + 1);
var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint"); var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
if (breakpoint) if (breakpoint)
this._editBreakpointCondition(breakpoint); this._editBreakpointCondition(breakpoint);
...@@ -327,8 +366,8 @@ WebInspector.SourceFrame.prototype = { ...@@ -327,8 +366,8 @@ WebInspector.SourceFrame.prototype = {
var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint"); var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
if (breakpoint) if (breakpoint)
WebInspector.panels.scripts.removeBreakpoint(breakpoint); WebInspector.panels.scripts.removeBreakpoint(breakpoint);
else if (this.addBreakpointDelegate) else if (this._addBreakpointDelegate)
this.addBreakpointDelegate(lineNumber + 1); this._addBreakpointDelegate(lineNumber + 1);
event.preventDefault(); event.preventDefault();
}, },
...@@ -421,16 +460,17 @@ WebInspector.SourceFrame.prototype = { ...@@ -421,16 +460,17 @@ WebInspector.SourceFrame.prototype = {
resize: function() resize: function()
{ {
this._editor.updateCanvasSize(); if (this._editor)
this._editor.updateCanvasSize();
} }
} }
WebInspector.SourceFrame.prototype.__proto__ = WebInspector.Object.prototype; WebInspector.SourceFrame.prototype.__proto__ = WebInspector.Object.prototype;
WebInspector.BreakpointLineNumberDecorator = function(sourceFrame) WebInspector.BreakpointLineNumberDecorator = function(sourceFrame, textModel)
{ {
this._sourceFrame = sourceFrame; this._sourceFrame = sourceFrame;
this._textModel = sourceFrame._editor.textModel; this._textModel = textModel;
} }
WebInspector.BreakpointLineNumberDecorator.prototype = { WebInspector.BreakpointLineNumberDecorator.prototype = {
......
...@@ -30,19 +30,11 @@ WebInspector.SourceView = function(resource) ...@@ -30,19 +30,11 @@ WebInspector.SourceView = function(resource)
{ {
WebInspector.ResourceView.call(this, 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.element.addStyleClass("source");
this.sourceFrame = new WebInspector.SourceFrame(this.contentElement, this._addBreakpoint.bind(this));
resource.addEventListener("finished", this._resourceLoadingFinished, this);
this._frameNeedsSetup = true; 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 = { WebInspector.SourceView.prototype = {
...@@ -50,18 +42,20 @@ WebInspector.SourceView.prototype = { ...@@ -50,18 +42,20 @@ WebInspector.SourceView.prototype = {
{ {
WebInspector.ResourceView.prototype.show.call(this, parentElement); WebInspector.ResourceView.prototype.show.call(this, parentElement);
this.setupSourceFrameIfNeeded(); this.setupSourceFrameIfNeeded();
this.sourceFrame.visible = true;
this.resize(); this.resize();
}, },
hide: function() hide: function()
{ {
WebInspector.View.prototype.hide.call(this); WebInspector.View.prototype.hide.call(this);
this.sourceFrame.visible = false;
this._currentSearchResultIndex = -1; this._currentSearchResultIndex = -1;
}, },
resize: function() resize: function()
{ {
if (this._sourceFrameSetup) if (this.sourceFrame)
this.sourceFrame.resize(); this.sourceFrame.resize();
}, },
......
...@@ -28,9 +28,10 @@ ...@@ -28,9 +28,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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._highlighter = new WebInspector.TextEditorHighlighter(this._textModel, this._highlightChanged.bind(this));
this.element = document.createElement("div"); this.element = document.createElement("div");
......
...@@ -62,7 +62,8 @@ WebInspector.TextEditorHighlighter = function(textModel, damageCallback) ...@@ -62,7 +62,8 @@ WebInspector.TextEditorHighlighter = function(textModel, damageCallback)
this._tokenizerConstructors = { this._tokenizerConstructors = {
"text/css": WebInspector.SourceCSSTokenizer, "text/css": WebInspector.SourceCSSTokenizer,
"text/html": WebInspector.SourceHTMLTokenizer, "text/html": WebInspector.SourceHTMLTokenizer,
"text/javascript": WebInspector.SourceJavaScriptTokenizer "text/javascript": WebInspector.SourceJavaScriptTokenizer,
"application/x-javascript": WebInspector.SourceJavaScriptTokenizer
}; };
this.mimeType = "text/html"; this.mimeType = "text/html";
......
...@@ -53,9 +53,8 @@ WebInspector.TextRange.prototype = { ...@@ -53,9 +53,8 @@ WebInspector.TextRange.prototype = {
} }
} }
WebInspector.TextEditorModel = function(changeListener) WebInspector.TextEditorModel = function()
{ {
this._changeListener = changeListener;
this._lines = [""]; this._lines = [""];
this._attributes = []; this._attributes = [];
this._undoStack = []; this._undoStack = [];
...@@ -63,6 +62,10 @@ WebInspector.TextEditorModel = function(changeListener) ...@@ -63,6 +62,10 @@ WebInspector.TextEditorModel = function(changeListener)
} }
WebInspector.TextEditorModel.prototype = { WebInspector.TextEditorModel.prototype = {
set changeListener(changeListener)
{
this._changeListener = changeListener;
},
get linesCount() get linesCount()
{ {
...@@ -89,7 +92,8 @@ WebInspector.TextEditorModel.prototype = { ...@@ -89,7 +92,8 @@ WebInspector.TextEditorModel.prototype = {
var newRange = this._innerSetText(range, text); var newRange = this._innerSetText(range, text);
command.range = newRange.clone(); command.range = newRange.clone();
this._changeListener(range, newRange, command.text, text); if (this._changeListener)
this._changeListener(range, newRange, command.text, text);
return newRange; 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