diff options
author | Shimeng (Simon) Wang <swang@google.com> | 2010-12-07 17:22:45 -0800 |
---|---|---|
committer | Shimeng (Simon) Wang <swang@google.com> | 2010-12-22 14:15:40 -0800 |
commit | 4576aa36e9a9671459299c7963ac95aa94beaea9 (patch) | |
tree | 3863574e050f168c0126ecb47c83319fab0972d8 /WebCore/inspector/front-end/SourceView.js | |
parent | 55323ac613cc31553107b68603cb627264d22bb0 (diff) | |
download | external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.zip external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.gz external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.bz2 |
Merge WebKit at r73109: Initial merge by git.
Change-Id: I61f1a66d9642e3d8405d3ac6ccab2a53421c75d8
Diffstat (limited to 'WebCore/inspector/front-end/SourceView.js')
-rw-r--r-- | WebCore/inspector/front-end/SourceView.js | 72 |
1 files changed, 33 insertions, 39 deletions
diff --git a/WebCore/inspector/front-end/SourceView.js b/WebCore/inspector/front-end/SourceView.js index c7a35f7..9616321 100644 --- a/WebCore/inspector/front-end/SourceView.js +++ b/WebCore/inspector/front-end/SourceView.js @@ -33,7 +33,7 @@ WebInspector.SourceView = function(resource) this.element.addStyleClass("source"); var canEditScripts = WebInspector.panels.scripts && WebInspector.panels.scripts.canEditScripts() && resource.type === WebInspector.Resource.Type.Script; - this.sourceFrame = new WebInspector.SourceFrame(this.contentElement, this._addBreakpoint.bind(this), canEditScripts ? this._editLine.bind(this) : null, this._continueToLine.bind(this)); + this.sourceFrame = new WebInspector.SourceFrame(this.element, this._addBreakpoint.bind(this), canEditScripts ? this._editLine.bind(this) : null, this._continueToLine.bind(this)); resource.addEventListener("finished", this._resourceLoadingFinished, this); this._frameNeedsSetup = true; } @@ -50,9 +50,8 @@ WebInspector.SourceView.prototype = { show: function(parentElement) { WebInspector.ResourceView.prototype.show.call(this, parentElement); + this.setupSourceFrameIfNeeded(); this.sourceFrame.visible = true; - if (this.localSourceFrame) - this.localSourceFrame.visible = true; this.resize(); }, @@ -62,8 +61,6 @@ WebInspector.SourceView.prototype = { if (!this._frameNeedsSetup) this.sourceFrame.clearLineHighlight(); WebInspector.View.prototype.hide.call(this); - if (this.localSourceFrame) - this.localSourceFrame.visible = false; this._currentSearchResultIndex = -1; }, @@ -71,32 +68,33 @@ WebInspector.SourceView.prototype = { { if (this.sourceFrame) this.sourceFrame.resize(); - if (this.localSourceFrame) - this.localSourceFrame.resize(); - WebInspector.ResourceView.prototype.resize.call(this); }, + get scrollTop() + { + return this.sourceFrame.scrollTop; + }, + + set scrollTop(scrollTop) + { + this.sourceFrame.scrollTop = scrollTop; + }, + + setupSourceFrameIfNeeded: function() { if (!this._frameNeedsSetup) return; - this.attach(); - delete this._frameNeedsSetup; this.resource.requestContent(this._contentLoaded.bind(this)); }, - hasContentTab: function() + hasContent: function() { return true; }, - contentTabSelected: function() - { - this.setupSourceFrameIfNeeded(); - }, - _contentLoaded: function(content) { var mimeType = this._canonicalMimeType(this.resource); @@ -149,13 +147,28 @@ WebInspector.SourceView.prototype = { lines.push(textModel.line(i)); } - var linesCountToShift = newContent.split("\n").length - 1; - WebInspector.panels.scripts.editScriptSource(this._sourceIDForLine(line), lines.join("\n"), line, linesCountToShift, this._editLineComplete.bind(this), cancelEditingCallback); + var editData = {}; + editData.sourceID = this._sourceIDForLine(line); + editData.content = lines.join("\n"); + editData.line = line; + editData.linesCountToShift = newContent.split("\n").length - 1; + + WebInspector.panels.scripts.editScriptSource(editData, this._editLineComplete.bind(this, editData), cancelEditingCallback); + }, + + _editLineComplete: function(editData, newContent) + { + this.resource.setContent(newContent, this._revertEditLine.bind(this, editData)); }, - _editLineComplete: function(newBody) + _revertEditLine: function(editData, contentToRevertTo) { - this.sourceFrame.updateContent(newBody); + var newEditData = {}; + newEditData.sourceID = editData.sourceID; + newEditData.content = editData.content; + newEditData.line = editData.line; + newEditData.linesCountToShift = -editData.linesCountToShift; + WebInspector.panels.scripts.editScriptSource(newEditData, this._editLineComplete.bind(this, newEditData)); }, _sourceIDForLine: function(line) @@ -208,25 +221,6 @@ WebInspector.SourceView.prototype = { findSearchMatches.call(this, query, finishedCallback); }, - updateLocalContent: function(content, mimeType) - { - if (!this.localContentElement) { - this.localContentElement = document.createElement("div"); - this.localContentElement.className = "resource-view-content"; - this.tabbedPane.appendTab("local", WebInspector.UIString("Local"), this.localContentElement, this.selectLocalContentTab.bind(this)); - this.localSourceFrame = new WebInspector.SourceFrame(this.localContentElement, this._addBreakpoint.bind(this), null, this._continueToLine.bind(this)); - } - this.localSourceFrame.setContent(mimeType, content, ""); - }, - - selectLocalContentTab: function() - { - this.tabbedPane.selectTabById("local"); - this.localSourceFrame.visible = true; - if ("resize" in this) - this.resize(); - }, - jumpToFirstSearchResult: function() { if (!this._searchResults || !this._searchResults.length) |