Commit c5a61334 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

2010-11-24 Pavel Feldman <pfeldman@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: place local modifications to under original
        resource nodes in the resource panel.
        https://bugs.webkit.org/show_bug.cgi?id=50029

        * English.lproj/localizedStrings.js:
        * inspector/Inspector.idl:
        * inspector/InspectorController.cpp:
        (WebCore::InspectorController::resourceRetrievedByXMLHttpRequest):
        (WebCore::InspectorController::scriptImported):
        * inspector/InspectorResourceAgent.cpp:
        (WebCore::InspectorResourceAgent::setInitialContent):
        * inspector/InspectorResourceAgent.h:
        * inspector/front-end/CSSStyleModel.js:
        (WebInspector.CSSStyleModel.prototype.setRuleSelector):
        (WebInspector.CSSStyleModel.prototype.addRule):
        (WebInspector.CSSStyleModel.prototype._styleSheetChanged.callback):
        (WebInspector.CSSStyleModel.prototype._styleSheetChanged):
        (WebInspector.CSSStyleDeclaration.prototype.insertPropertyAt):
        (WebInspector.CSSProperty.prototype.setText):
        (WebInspector.CSSProperty.prototype.setDisabled.callback):
        (WebInspector.CSSProperty.prototype.setDisabled):
        (WebInspector.CSSStyleSheet.prototype.setText):
        * inspector/front-end/NetworkPanel.js:
        (WebInspector.NetworkPanel.prototype.refreshResource):
        * inspector/front-end/Resource.js:
        (WebInspector.Resource.prototype.set content):
        (WebInspector.Resource.prototype.get contentTimestamp):
        (WebInspector.Resource.prototype.setInitialContent):
        * inspector/front-end/ResourceManager.js:
        (WebInspector.ResourceManager):
        (WebInspector.ResourceManager.prototype.setInitialContent):
        * inspector/front-end/ResourcesPanel.js:
        (WebInspector.ResourcesPanel):
        (WebInspector.ResourcesPanel.prototype.reset):
        (WebInspector.ResourcesPanel.prototype._innerShowView):
        (WebInspector.FrameResourceTreeElement):
        (WebInspector.FrameResourceTreeElement.prototype._errorsWarningsUpdated):
        (WebInspector.FrameResourceTreeElement.prototype._contentChanged.else.finished):
        (WebInspector.FrameResourceTreeElement.prototype._contentChanged):
        (WebInspector.ResourceRevisionTreeElement):
        * inspector/front-end/SourceFrame.js:
        (WebInspector.SourceFrame.prototype.get scrollTop):
        (WebInspector.SourceFrame.prototype.set scrollTop):
        * inspector/front-end/SourceView.js:
        (WebInspector.SourceView.prototype.get scrollTop):
        (WebInspector.SourceView.prototype.set scrollTop):
        (WebInspector.SourceView.prototype._editLine):
        (WebInspector.SourceView.prototype._editLineComplete):
        * inspector/front-end/StylesSidebarPane.js:
        (WebInspector.StylePropertyTreeElement.prototype):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72684 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent da50e955
2010-11-24 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: place local modifications to under original
resource nodes in the resource panel.
https://bugs.webkit.org/show_bug.cgi?id=50029
* English.lproj/localizedStrings.js:
* inspector/Inspector.idl:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::resourceRetrievedByXMLHttpRequest):
(WebCore::InspectorController::scriptImported):
* inspector/InspectorResourceAgent.cpp:
(WebCore::InspectorResourceAgent::setInitialContent):
* inspector/InspectorResourceAgent.h:
* inspector/front-end/CSSStyleModel.js:
(WebInspector.CSSStyleModel.prototype.setRuleSelector):
(WebInspector.CSSStyleModel.prototype.addRule):
(WebInspector.CSSStyleModel.prototype._styleSheetChanged.callback):
(WebInspector.CSSStyleModel.prototype._styleSheetChanged):
(WebInspector.CSSStyleDeclaration.prototype.insertPropertyAt):
(WebInspector.CSSProperty.prototype.setText):
(WebInspector.CSSProperty.prototype.setDisabled.callback):
(WebInspector.CSSProperty.prototype.setDisabled):
(WebInspector.CSSStyleSheet.prototype.setText):
* inspector/front-end/NetworkPanel.js:
(WebInspector.NetworkPanel.prototype.refreshResource):
* inspector/front-end/Resource.js:
(WebInspector.Resource.prototype.set content):
(WebInspector.Resource.prototype.get contentTimestamp):
(WebInspector.Resource.prototype.setInitialContent):
* inspector/front-end/ResourceManager.js:
(WebInspector.ResourceManager):
(WebInspector.ResourceManager.prototype.setInitialContent):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.ResourcesPanel):
(WebInspector.ResourcesPanel.prototype.reset):
(WebInspector.ResourcesPanel.prototype._innerShowView):
(WebInspector.FrameResourceTreeElement):
(WebInspector.FrameResourceTreeElement.prototype._errorsWarningsUpdated):
(WebInspector.FrameResourceTreeElement.prototype._contentChanged.else.finished):
(WebInspector.FrameResourceTreeElement.prototype._contentChanged):
(WebInspector.ResourceRevisionTreeElement):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame.prototype.get scrollTop):
(WebInspector.SourceFrame.prototype.set scrollTop):
* inspector/front-end/SourceView.js:
(WebInspector.SourceView.prototype.get scrollTop):
(WebInspector.SourceView.prototype.set scrollTop):
(WebInspector.SourceView.prototype._editLine):
(WebInspector.SourceView.prototype._editLineComplete):
* inspector/front-end/StylesSidebarPane.js:
(WebInspector.StylePropertyTreeElement.prototype):
2010-11-24 Andrey Kosyakov <caseq@chromium.org>
Reviewed by Pavel Feldman.
Bvar localizedStrings = new Object;
......
......@@ -113,7 +113,7 @@ module core {
[notify] void didFinishLoading(out long identifier, out double finishTime);
[notify] void didFailLoading(out long identifier, out double time, out String localizedDescription);
[notify] void didLoadResourceFromMemoryCache(out double time, out Object resource);
[notify] void setOverrideContent(out long identifier, out String sourceString, out String type);
[notify] void setInitialContent(out long identifier, out String sourceString, out String type);
[notify] void didCommitLoadForFrame(out Object frame, out Object loader);
[notify] void frameDetachedFromParent(out unsigned long frameId);
......
......@@ -924,7 +924,7 @@ void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identi
addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, "XHR finished loading: \"" + url + "\".", sendLineNumber, sendURL);
if (m_resourceAgent)
m_resourceAgent->setOverrideContent(identifier, sourceString, "XHR");
m_resourceAgent->setInitialContent(identifier, sourceString, "XHR");
}
void InspectorController::scriptImported(unsigned long identifier, const String& sourceString)
......@@ -933,7 +933,7 @@ void InspectorController::scriptImported(unsigned long identifier, const String&
return;
if (m_resourceAgent)
m_resourceAgent->setOverrideContent(identifier, sourceString, "Script");
m_resourceAgent->setInitialContent(identifier, sourceString, "Script");
}
void InspectorController::ensureSettingsLoaded()
......
......@@ -344,9 +344,9 @@ void InspectorResourceAgent::didLoadResourceFromMemoryCache(DocumentLoader* load
m_frontend->didLoadResourceFromMemoryCache(currentTime(), buildObjectForCachedResource(loader, *resource));
}
void InspectorResourceAgent::setOverrideContent(unsigned long identifier, const String& sourceString, const String& type)
void InspectorResourceAgent::setInitialContent(unsigned long identifier, const String& sourceString, const String& type)
{
m_frontend->setOverrideContent(identifier, sourceString, type);
m_frontend->setInitialContent(identifier, sourceString, type);
}
static PassRefPtr<InspectorObject> buildObjectForFrame(Frame* frame)
......
......@@ -85,7 +85,7 @@ public:
void didFinishLoading(unsigned long identifier, double finishTime);
void didFailLoading(unsigned long identifier, const ResourceError&);
void didLoadResourceFromMemoryCache(DocumentLoader*, const CachedResource*);
void setOverrideContent(unsigned long identifier, const String& sourceString, const String& type);
void setInitialContent(unsigned long identifier, const String& sourceString, const String& type);
void didCommitLoad(DocumentLoader*);
void frameDetachedFromParent(Frame*);
......
......@@ -119,7 +119,7 @@ WebInspector.CSSStyleModel.prototype = {
var doesAffectSelectedNode = (selectedNodeIds.indexOf(nodeId) >= 0);
var rule = WebInspector.CSSRule.parsePayload(rulePayload);
successCallback(rule, doesAffectSelectedNode);
this._styleSheetChanged(rule.id.styleSheetId);
this._styleSheetChanged(rule.id.styleSheetId, true);
}
function callback(nodeId, successCallback, failureCallback, newSelector, rulePayload)
......@@ -140,7 +140,7 @@ WebInspector.CSSStyleModel.prototype = {
var doesAffectSelectedNode = (selectedNodeIds.indexOf(nodeId) >= 0);
var rule = WebInspector.CSSRule.parsePayload(rulePayload);
successCallback(rule, doesAffectSelectedNode);
this._styleSheetChanged(rule.id.styleSheetId);
this._styleSheetChanged(rule.id.styleSheetId, true);
}
function callback(successCallback, failureCallback, selector, rulePayload)
......@@ -155,9 +155,18 @@ WebInspector.CSSStyleModel.prototype = {
InspectorBackend.addRule2(nodeId, selector, callback.bind(this, successCallback, failureCallback, selector));
},
_styleSheetChanged: function(styleSheetId)
_styleSheetChanged: function(styleSheetId, majorChange)
{
// FIXME: use InspectorBackend.getStyleSheetText2 here;
if (!majorChange || !styleSheetId)
return;
function callback(href, content)
{
var resource = WebInspector.resourceManager.resourceForURL(href);
if (resource)
resource.content = content;
}
InspectorBackend.getStyleSheetText2(styleSheetId, callback);
}
}
......@@ -323,7 +332,7 @@ WebInspector.CSSStyleDeclaration.prototype = {
userCallback(null);
else {
userCallback(WebInspector.CSSStyleDeclaration.parsePayload(payload));
WebInspector.cssModel._styleSheetChanged(this.id.styleSheetId);
WebInspector.cssModel._styleSheetChanged(this.id.styleSheetId, true);
}
}
......@@ -433,7 +442,7 @@ WebInspector.CSSProperty.prototype = {
},
// Replaces "propertyName: propertyValue [!important];" in the stylesheet by an arbitrary propertyText.
setText: function(propertyText, userCallback)
setText: function(propertyText, majorChange, userCallback)
{
function callback(stylePayload)
{
......@@ -447,7 +456,7 @@ WebInspector.CSSProperty.prototype = {
else {
var style = WebInspector.CSSStyleDeclaration.parsePayload(stylePayload);
userCallback(style);
WebInspector.cssModel._styleSheetChanged(style.id.styleSheetId);
WebInspector.cssModel._styleSheetChanged(style.id.styleSheetId, majorChange);
}
}
......@@ -480,7 +489,7 @@ WebInspector.CSSProperty.prototype = {
else {
var style = WebInspector.CSSStyleDeclaration.parsePayload(stylePayload);
userCallback(style);
WebInspector.cssModel._styleSheetChanged(this.ownerStyle.id.styleSheetId);
WebInspector.cssModel._styleSheetChanged(this.ownerStyle.id.styleSheetId, false);
}
}
......@@ -532,7 +541,7 @@ WebInspector.CSSStyleSheet.prototype = {
userCallback(null);
else {
userCallback(new WebInspector.CSSStyleSheet(styleSheetPayload));
WebInspector.cssModel._styleSheetChanged(this.id);
WebInspector.cssModel._styleSheetChanged(this.id, true);
}
}
......
......@@ -796,6 +796,7 @@ WebInspector.NetworkPanel.prototype = {
if (WebInspector.ResourceManager.resourceViewTypeMatchesResource(resource, resource._resourcesView))
return;
var newView = WebInspector.ResourceManager.createResourceView(resource);
var oldView = resource._resourcesView;
......
......@@ -624,6 +624,19 @@ WebInspector.Resource.prototype = {
},
set content(content)
{
var data = { oldContent: this._content, oldContentTimestamp: this._contentTimestamp };
this._content = content;
this._contentTimestamp = new Date();
this.dispatchEventToListeners("content-changed", data);
},
get contentTimestamp()
{
return this._contentTimestamp;
},
setInitialContent: function(content)
{
this._content = content;
},
......
......@@ -39,7 +39,7 @@ WebInspector.ResourceManager = function()
"didFinishLoading",
"didFailLoading",
"didLoadResourceFromMemoryCache",
"setOverrideContent",
"setInitialContent",
"didCommitLoadForFrame",
"frameDetachedFromParent",
"didCreateWebSocket",
......@@ -246,14 +246,14 @@ WebInspector.ResourceManager.prototype = {
this._updateResourceWithResponse(resource, cachedResource.response);
},
setOverrideContent: function(identifier, sourceString, type)
setInitialContent: function(identifier, sourceString, type)
{
var resource = WebInspector.panels.network.resources[identifier];
if (!resource)
return;
resource.type = WebInspector.Resource.Type[type];
resource.content = sourceString;
resource.setInitialContent(sourceString);
WebInspector.panels.resources.refreshResource(resource);
WebInspector.panels.network.refreshResource(resource);
},
......
......@@ -56,10 +56,6 @@ WebInspector.ResourcesPanel = function(database)
this.applicationCacheListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Application Cache"), "ApplicationCache", "application-cache-storage-tree-item");
this.sidebarTree.appendChild(this.applicationCacheListTreeElement);
this.locallyModifiedListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Locally Modified"), "LocallyModified", "frame-storage-tree-item");
this.sidebarTree.appendChild(this.locallyModifiedListTreeElement);
this.locallyModifiedListTreeElement.hidden = true;
if (Preferences.fileSystemEnabled) {
this.fileSystemListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("File System"), "FileSystem", "file-system-storage-tree-item");
this.sidebarTree.appendChild(this.fileSystemListTreeElement);
......@@ -78,7 +74,6 @@ WebInspector.ResourcesPanel = function(database)
this._cookieViews = {};
this._origins = {};
this._domains = {};
this._locallyModifiedResources = {};
this.sidebarElement.addEventListener("mousemove", this._onmousemove.bind(this), false);
this.sidebarElement.addEventListener("mouseout", this._onmouseout.bind(this), false);
......@@ -149,7 +144,6 @@ WebInspector.ResourcesPanel.prototype = {
this._domStorage = [];
this._cookieViews = {};
this._locallyModifiedResources = {};
this._fileSystemView = null;
this._applicationCacheView = null;
......@@ -160,7 +154,6 @@ WebInspector.ResourcesPanel.prototype = {
this.sessionStorageListTreeElement.removeChildren();
this.cookieListTreeElement.removeChildren();
this.applicationCacheListTreeElement.removeChildren();
this.locallyModifiedListTreeElement.removeChildren();
if (Preferences.fileSystemEnabled)
this.fileSystemListTreeElement.removeChildren();
this.storageViews.removeChildren();
......@@ -311,20 +304,6 @@ WebInspector.ResourcesPanel.prototype = {
this.sessionStorageListTreeElement.appendChild(domStorageTreeElement);
},
addLocallyModifiedRevision: function(url, resourceType, content)
{
this.locallyModifiedListTreeElement.hidden = false;
var newRevision = new WebInspector.LocallyModifiedRevisionTreeElement(this, url, resourceType, content);
var lastRevision = this._locallyModifiedResources[url];
this._locallyModifiedResources[url] = newRevision;
if (lastRevision)
lastRevision.becomeLogEntry(newRevision);
else
this.locallyModifiedListTreeElement.appendChild(newRevision);
},
selectDatabase: function(databaseId)
{
var database;
......@@ -472,7 +451,7 @@ WebInspector.ResourcesPanel.prototype = {
_innerShowView: function(view)
{
if (this.visibleView)
this.visibleView.detach();
this.visibleView.hide();
view.show(this.storageViews);
this.visibleView = view;
......@@ -960,6 +939,7 @@ WebInspector.FrameResourceTreeElement = function(storagePanel, resource)
WebInspector.BaseStorageTreeElement.call(this, storagePanel, resource, resource.displayName, "resource-sidebar-tree-item resources-category-" + resource.category.name);
this._resource = resource;
this._resource.addEventListener("errors-warnings-updated", this._errorsWarningsUpdated, this);
this._resource.addEventListener("content-changed", this._contentChanged, this);
this.tooltip = resource.url;
}
......@@ -1070,6 +1050,44 @@ WebInspector.FrameResourceTreeElement.prototype = {
if (this._resource.errors)
this._bubbleElement.addStyleClass("error");
},
_contentChanged: function(event)
{
var revisionResource = new WebInspector.Resource(null, this._resource.url);
revisionResource.type = this._resource.type;
revisionResource.loader = this._resource.loader;
if (this._resource.finished)
revisionResource.finished = true;
else {
function finished()
{
revisionResource.finished = true;
}
this._resource.addEventListener("finished", finished);
}
if (event.data.oldContent)
revisionResource.setInitialContent(event.data.oldContent);
this.insertChild(new WebInspector.ResourceRevisionTreeElement(this._storagePanel, revisionResource, event.data.oldContentTimestamp), 0);
var oldView = this._resource._resourcesView;
if (oldView) {
var scrollTop = oldView.scrollTop;
var newView = WebInspector.ResourceManager.createResourceView(this._resource);
var oldViewParentNode = oldView.visible ? oldView.element.parentNode : null;
this._resource._resourcesView.detach();
delete this._resource._resourcesView;
this._resource._resourcesView = newView;
if (oldViewParentNode)
newView.show(oldViewParentNode);
if (oldView === this._storagePanel.visibleView)
this._storagePanel.visibleView = newView;
if (scrollTop)
newView.scrollTop = scrollTop;
}
}
}
......@@ -1197,44 +1215,16 @@ WebInspector.ApplicationCacheTreeElement.prototype = {
}
WebInspector.ApplicationCacheTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
WebInspector.LocallyModifiedRevisionTreeElement = function(storagePanel, url, resourceType, content)
WebInspector.ResourceRevisionTreeElement = function(storagePanel, resource, timestamp)
{
var resource = new WebInspector.Resource(null, url);
resource.type = resourceType;
resource.content = content;
var timestamp = new Date();
WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, resource.displayName, "resource-sidebar-tree-item resources-category-" + resource.category.name);
this.tooltip = resource.url;
this.timestamp = timestamp;
var title = timestamp ? timestamp.toLocaleTimeString() : "(original)";
WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, title, "resource-sidebar-tree-item resources-category-" + resource.category.name);
if (timestamp)
this.tooltip = timestamp.toLocaleString();
this._resource = resource;
}
WebInspector.LocallyModifiedRevisionTreeElement.prototype = {
becomeLogEntry: function(newRevision)
{
var oldChildren = this.children.slice();
var oldExpanded = this.expanded;
var oldIndex = this.parent.children.indexOf(this);
this.removeChildren();
this.titleText = this.timestamp.toLocaleTimeString();
this.toLocaleString();
this.hasChildren = false;
this.parent.insertChild(newRevision, oldIndex);
this.parent.removeChild(this);
const oneMinute = 1000 * 60;
if (newRevision.timestamp - this.timestamp > oneMinute)
newRevision.appendChild(this);
for (var i = 0; i < oldChildren.length; ++i)
newRevision.appendChild(oldChildren[i]);
if (oldExpanded)
newRevision.expand();
},
WebInspector.ResourceRevisionTreeElement.prototype = {
onattach: function()
{
WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
......@@ -1255,7 +1245,8 @@ WebInspector.LocallyModifiedRevisionTreeElement.prototype = {
return true;
}
}
WebInspector.LocallyModifiedRevisionTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
WebInspector.ResourceRevisionTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
WebInspector.FileSystemTreeElement = function(storagePanel, origin)
{
......
......@@ -161,6 +161,17 @@ WebInspector.SourceFrame.prototype = {
return this._textModel;
},
get scrollTop()
{
return this._textViewer ? this._textViewer.element.scrollTop : 0;
},
set scrollTop(scrollTop)
{
if (this._textViewer)
this._textViewer.element.scrollTop = scrollTop;
},
highlightLine: function(line)
{
if (this._textViewer)
......
......@@ -70,6 +70,16 @@ WebInspector.SourceView.prototype = {
this.sourceFrame.resize();
},
get scrollTop()
{
return this.sourceFrame.scrollTop;
},
set scrollTop(scrollTop)
{
this.sourceFrame.scrollTop = scrollTop;
},
setupSourceFrameIfNeeded: function()
{
if (!this._frameNeedsSetup)
......@@ -137,12 +147,13 @@ WebInspector.SourceView.prototype = {
}
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 newContent = lines.join("\n");
WebInspector.panels.scripts.editScriptSource(this._sourceIDForLine(line), newContent, line, linesCountToShift, this._editLineComplete.bind(this, newContent), cancelEditingCallback);
},
_editLineComplete: function(newBody)
_editLineComplete: function(newContent)
{
this.sourceFrame.updateContent(newBody);
this.resource.content = newContent;
},
_sourceIDForLine: function(line)
......
......@@ -1771,7 +1771,7 @@ WebInspector.StylePropertyTreeElement.prototype = {
// FIXME: this does not handle trailing comments.
if (styleText.length && !/;\s*$/.test(styleText))
styleText += ";";
this.property.setText(styleText, callback.bind(this));
this.property.setText(styleText, updateInterface, callback.bind(this));
}
}
......
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