[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

pfeldman at chromium.org pfeldman at chromium.org
Wed Dec 22 17:48:30 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit d4152cafdb1c4aba8fb0bc8e222c51d9babee7f2
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Nov 30 19:16:56 2010 +0000

    2010-11-30  Pavel Feldman  <pfeldman at chromium.org>
    
            Reviewed by Yury Semikhatsky.
    
            Web Inspector: implement "Revert to this revision" in resources panel.
            https://bugs.webkit.org/show_bug.cgi?id=50107
    
            * inspector/Inspector.idl:
            * inspector/InspectorCSSAgent.cpp:
            (WebCore::InspectorCSSAgent::setStyleSheetText2):
            * inspector/InspectorCSSAgent.h:
            * inspector/InspectorStyleSheet.cpp:
            (WebCore::InspectorStyleSheet::reparseStyleSheet):
            * inspector/front-end/CSSStyleModel.js:
            (WebInspector.CSSStyleModel.prototype._styleSheetChanged.callback):
            (WebInspector.CSSStyleModel.prototype._styleSheetChanged):
            (WebInspector.CSSStyleModel.prototype._onRevert):
            * inspector/front-end/Resource.js:
            (WebInspector.Resource.prototype.get contentTimestamp):
            (WebInspector.Resource.prototype.setInitialContent):
            (WebInspector.Resource.prototype.isLocallyModified):
            (WebInspector.Resource.prototype.setContent.else.finished):
            (WebInspector.Resource.prototype.setContent):
            (WebInspector.Resource.prototype.revertToThis.callback):
            (WebInspector.Resource.prototype.revertToThis):
            (WebInspector.Resource.prototype.get baseRevision):
            (WebInspector.Resource.prototype._innerRequestContent):
            * inspector/front-end/ResourcesPanel.js:
            (WebInspector.ResourcesPanel.prototype._showResourceView):
            (WebInspector.FrameResourceTreeElement.prototype._contentChanged):
            (WebInspector.ResourceRevisionTreeElement):
            (WebInspector.ResourceRevisionTreeElement.prototype.onattach):
            (WebInspector.ResourceRevisionTreeElement.prototype._ondragstart):
            (WebInspector.ResourceRevisionTreeElement.prototype._handleContextMenuEvent):
            * inspector/front-end/ScriptsPanel.js:
            (WebInspector.ScriptsPanel.prototype.editScriptSource.mycallback):
            (WebInspector.ScriptsPanel.prototype.editScriptSource):
            * inspector/front-end/SourceView.js:
            (WebInspector.SourceView.prototype._editLine):
            (WebInspector.SourceView.prototype._editLineComplete):
            (WebInspector.SourceView.prototype._revertEditLine):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72938 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 162b358..d1aeeaa 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,45 @@
+2010-11-30  Pavel Feldman  <pfeldman at chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: implement "Revert to this revision" in resources panel.
+        https://bugs.webkit.org/show_bug.cgi?id=50107
+
+        * inspector/Inspector.idl:
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::setStyleSheetText2):
+        * inspector/InspectorCSSAgent.h:
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyleSheet::reparseStyleSheet):
+        * inspector/front-end/CSSStyleModel.js:
+        (WebInspector.CSSStyleModel.prototype._styleSheetChanged.callback):
+        (WebInspector.CSSStyleModel.prototype._styleSheetChanged):
+        (WebInspector.CSSStyleModel.prototype._onRevert):
+        * inspector/front-end/Resource.js:
+        (WebInspector.Resource.prototype.get contentTimestamp):
+        (WebInspector.Resource.prototype.setInitialContent):
+        (WebInspector.Resource.prototype.isLocallyModified):
+        (WebInspector.Resource.prototype.setContent.else.finished):
+        (WebInspector.Resource.prototype.setContent):
+        (WebInspector.Resource.prototype.revertToThis.callback):
+        (WebInspector.Resource.prototype.revertToThis):
+        (WebInspector.Resource.prototype.get baseRevision):
+        (WebInspector.Resource.prototype._innerRequestContent):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel.prototype._showResourceView):
+        (WebInspector.FrameResourceTreeElement.prototype._contentChanged):
+        (WebInspector.ResourceRevisionTreeElement):
+        (WebInspector.ResourceRevisionTreeElement.prototype.onattach):
+        (WebInspector.ResourceRevisionTreeElement.prototype._ondragstart):
+        (WebInspector.ResourceRevisionTreeElement.prototype._handleContextMenuEvent):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype.editScriptSource.mycallback):
+        (WebInspector.ScriptsPanel.prototype.editScriptSource):
+        * inspector/front-end/SourceView.js:
+        (WebInspector.SourceView.prototype._editLine):
+        (WebInspector.SourceView.prototype._editLineComplete):
+        (WebInspector.SourceView.prototype._revertEditLine):
+
 2010-11-30  Adam Roben  <aroben at apple.com>
 
         Clean up WebCore.vcproj's bindings filter
diff --git a/WebCore/English.lproj/localizedStrings.js b/WebCore/English.lproj/localizedStrings.js
index 5ffe861..2f804cd 100644
Binary files a/WebCore/English.lproj/localizedStrings.js and b/WebCore/English.lproj/localizedStrings.js differ
diff --git a/WebCore/inspector/Inspector.idl b/WebCore/inspector/Inspector.idl
index 6589127..c185d2d 100644
--- a/WebCore/inspector/Inspector.idl
+++ b/WebCore/inspector/Inspector.idl
@@ -216,7 +216,7 @@ module core {
         [handler=CSS] void getAllStyles2(out Array styleSheetIds);
         [handler=CSS] void getStyleSheet2(in String styleSheetId, out Value styleSheet);
         [handler=CSS] void getStyleSheetText2(in String styleSheetId, out String url, out String text);
-        [handler=CSS] void setStyleSheetText2(in String styleSheetId, in String text);
+        [handler=CSS] void setStyleSheetText2(in String styleSheetId, in String text, out boolean success);
         [handler=CSS] void setPropertyText2(in Object styleId, in long propertyIndex, in String text, in boolean overwrite, out Value style);
         [handler=CSS] void toggleProperty2(in Object styleId, in long propertyIndex, in boolean disable, out Value style);
         [handler=CSS] void setRuleSelector2(in Object ruleId, in String selector, out Value rule);
diff --git a/WebCore/inspector/InspectorCSSAgent.cpp b/WebCore/inspector/InspectorCSSAgent.cpp
index fd1deb5..31d951a 100644
--- a/WebCore/inspector/InspectorCSSAgent.cpp
+++ b/WebCore/inspector/InspectorCSSAgent.cpp
@@ -285,14 +285,16 @@ void InspectorCSSAgent::getStyleSheetText2(const String& styleSheetId, String* u
     inspectorStyleSheet->text(result);
 }
 
-void InspectorCSSAgent::setStyleSheetText2(const String& styleSheetId, const String& text)
+void InspectorCSSAgent::setStyleSheetText2(const String& styleSheetId, const String& text, bool* success)
 {
     InspectorStyleSheet* inspectorStyleSheet = styleSheetForId(styleSheetId);
-    if (!inspectorStyleSheet)
+    if (!inspectorStyleSheet) {
+        *success = false;
         return;
+    }
 
-    bool success = inspectorStyleSheet->setText(text);
-    if (success)
+    *success = inspectorStyleSheet->setText(text);
+    if (*success)
         inspectorStyleSheet->reparseStyleSheet(text);
 }
 
diff --git a/WebCore/inspector/InspectorCSSAgent.h b/WebCore/inspector/InspectorCSSAgent.h
index 6e8f244..2d2efb5 100644
--- a/WebCore/inspector/InspectorCSSAgent.h
+++ b/WebCore/inspector/InspectorCSSAgent.h
@@ -66,7 +66,7 @@ public:
     void getAllStyles2(RefPtr<InspectorArray>* styles);
     void getStyleSheet2(const String& styleSheetId, RefPtr<InspectorValue>* result);
     void getStyleSheetText2(const String& styleSheetId, String* url, String* result);
-    void setStyleSheetText2(const String& styleSheetId, const String& text);
+    void setStyleSheetText2(const String& styleSheetId, const String& text, bool* success);
     void setPropertyText2(const RefPtr<InspectorObject>& styleId, long propertyIndex, const String& text, bool overwrite, RefPtr<InspectorValue>* result);
     void toggleProperty2(const RefPtr<InspectorObject>& styleId, long propertyIndex, bool disable, RefPtr<InspectorValue>* result);
     void setRuleSelector2(const RefPtr<InspectorObject>& ruleId, const String& selector, RefPtr<InspectorValue>* result);
diff --git a/WebCore/inspector/InspectorStyleSheet.cpp b/WebCore/inspector/InspectorStyleSheet.cpp
index ec1bb39..5b67a26 100644
--- a/WebCore/inspector/InspectorStyleSheet.cpp
+++ b/WebCore/inspector/InspectorStyleSheet.cpp
@@ -588,6 +588,7 @@ void InspectorStyleSheet::reparseStyleSheet(const String& text)
     for (unsigned i = 0, size = m_pageStyleSheet->length(); i < size; ++i)
         m_pageStyleSheet->remove(i);
     m_pageStyleSheet->parseString(text, m_pageStyleSheet->useStrictParsing());
+    m_pageStyleSheet->styleSheetChanged();
     m_inspectorStyles.clear();
 }
 
diff --git a/WebCore/inspector/front-end/CSSStyleModel.js b/WebCore/inspector/front-end/CSSStyleModel.js
index baf44c9..23ed7a8 100644
--- a/WebCore/inspector/front-end/CSSStyleModel.js
+++ b/WebCore/inspector/front-end/CSSStyleModel.js
@@ -164,9 +164,18 @@ WebInspector.CSSStyleModel.prototype = {
         {
             var resource = WebInspector.resourceManager.resourceForURL(href);
             if (resource && resource.type === WebInspector.Resource.Type.Stylesheet)
-                resource.content = content;
+                resource.setContent(content, this._onRevert.bind(this, styleSheetId));
         }
-        InspectorBackend.getStyleSheetText2(styleSheetId, callback);
+        InspectorBackend.getStyleSheetText2(styleSheetId, callback.bind(this));
+    },
+
+    _onRevert: function(styleSheetId, contentToRevertTo)
+    {
+        function callback(success)
+        {
+            this._styleSheetChanged(styleSheetId, true);
+        }
+        InspectorBackend.setStyleSheetText2(styleSheetId, contentToRevertTo, callback.bind(this));
     }
 }
 
diff --git a/WebCore/inspector/front-end/Resource.js b/WebCore/inspector/front-end/Resource.js
index 9da7f82..aefdd6c 100644
--- a/WebCore/inspector/front-end/Resource.js
+++ b/WebCore/inspector/front-end/Resource.js
@@ -625,22 +625,69 @@ WebInspector.Resource.prototype = {
         return this._content;
     },
 
-    set content(content)
+    get contentTimestamp()
+    {
+        return this._contentTimestamp;
+    },
+
+    setInitialContent: function(content)
     {
-        var data = { oldContent: this._content, oldContentTimestamp: this._contentTimestamp };
         this._content = content;
-        this._contentTimestamp = new Date();
+    },
+
+    isLocallyModified: function()
+    {
+        return !!this._baseRevision;
+    },
+
+    setContent: function(newContent, onRevert)
+    {
+        var revisionResource = new WebInspector.Resource(null, this.url);
+        revisionResource.type = this.type;
+        revisionResource.loader = this.loader;
+        revisionResource.timestamp = this.timestamp;
+        revisionResource._content = this._content;
+        revisionResource._actualResource = this;
+        revisionResource._fireOnRevert = onRevert;
+
+        if (this.finished)
+            revisionResource.finished = true;
+        else {
+            function finished()
+            {
+                this.removeEventListener("finished", finished);
+                revisionResource.finished = true;
+            }
+            this.addEventListener("finished", finished.bind(this));
+        }
+
+        if (!this._baseRevision)
+            this._baseRevision = revisionResource;
+        else
+            revisionResource._baseRevision = this._baseRevision;
+
+        var data = { revision: revisionResource };
+        this._content = newContent;
+        this.timestamp = new Date();
         this.dispatchEventToListeners("content-changed", data);
     },
 
-    get contentTimestamp()
+    revertToThis: function()
     {
-        return this._contentTimestamp;
+        if (!this._actualResource || !this._fireOnRevert)
+            return;
+
+        function callback(content)
+        {
+            if (content)
+                this._fireOnRevert(content);
+        }
+        this.requestContent(callback.bind(this));
     },
 
-    setInitialContent: function(content)
+    get baseRevision()
     {
-        this._content = content;
+        return this._baseRevision;
     },
 
     requestContent: function(callback)
diff --git a/WebCore/inspector/front-end/ResourcesPanel.js b/WebCore/inspector/front-end/ResourcesPanel.js
index 5c5c5d6..d6f7172 100644
--- a/WebCore/inspector/front-end/ResourcesPanel.js
+++ b/WebCore/inspector/front-end/ResourcesPanel.js
@@ -369,13 +369,13 @@ WebInspector.ResourcesPanel.prototype = {
         var view = WebInspector.ResourceManager.resourceViewForResource(resource);
 
         // Consider rendering diff markup here.
-        if (resource._baseRevision && resource.content && view instanceof WebInspector.SourceView) {
+        if (resource.baseRevision && view instanceof WebInspector.SourceView) {
             function callback(baseContent)
             {
                 if (baseContent)
                     this._applyDiffMarkup(view, baseContent, resource.content);
             }
-            resource._baseRevision.requestContent(callback.bind(this));
+            resource.baseRevision.requestContent(callback.bind(this));
         }
         this._innerShowView(view);
     },
@@ -1091,28 +1091,7 @@ WebInspector.FrameResourceTreeElement.prototype = {
 
     _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 (!this._resource._baseRevision)
-            this._resource._baseRevision = revisionResource;
-        else
-            revisionResource._baseRevision = this._resource._baseRevision;
-
-        if (event.data.oldContent)
-            revisionResource.setInitialContent(event.data.oldContent);
-        this.insertChild(new WebInspector.ResourceRevisionTreeElement(this._storagePanel, revisionResource, event.data.oldContentTimestamp), 0);
-
+        this.insertChild(new WebInspector.ResourceRevisionTreeElement(this._storagePanel, event.data.revision), 0);
         var oldView = WebInspector.ResourceManager.existingResourceViewForResource(this._resource);
         if (oldView) {
             var newView = WebInspector.ResourceManager.recreateResourceView(this._resource);
@@ -1246,13 +1225,13 @@ WebInspector.ApplicationCacheTreeElement.prototype = {
 }
 WebInspector.ApplicationCacheTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
 
-WebInspector.ResourceRevisionTreeElement = function(storagePanel, resource, timestamp)
+WebInspector.ResourceRevisionTreeElement = function(storagePanel, revision)
 {
-    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;
+    var title = revision.timestamp ? revision.timestamp.toLocaleTimeString() : "(original)";
+    WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, title, "resource-sidebar-tree-item resources-category-" + revision.category.name);
+    if (revision.timestamp)
+        this.tooltip = revision.timestamp.toLocaleString();
+    this._resource = revision;
 }
 
 WebInspector.ResourceRevisionTreeElement.prototype = {
@@ -1261,6 +1240,7 @@ WebInspector.ResourceRevisionTreeElement.prototype = {
         WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
         this.listItemElement.draggable = true;
         this.listItemElement.addEventListener("dragstart", this._ondragstart.bind(this), false);
+        this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
     },
 
     onselect: function()
@@ -1274,6 +1254,13 @@ WebInspector.ResourceRevisionTreeElement.prototype = {
         event.dataTransfer.setData("text/plain", this._resource.content);
         event.dataTransfer.effectAllowed = "copy";
         return true;
+    },
+
+    _handleContextMenuEvent: function(event)
+    {
+        var contextMenu = new WebInspector.ContextMenu();
+        contextMenu.appendItem(WebInspector.UIString("Revert to this revision"), this._resource.revertToThis.bind(this._resource));
+        contextMenu.show(event);
     }
 }
 
diff --git a/WebCore/inspector/front-end/ScriptsPanel.js b/WebCore/inspector/front-end/ScriptsPanel.js
index 0a3c7a9..61a2f28 100644
--- a/WebCore/inspector/front-end/ScriptsPanel.js
+++ b/WebCore/inspector/front-end/ScriptsPanel.js
@@ -306,7 +306,7 @@ WebInspector.ScriptsPanel.prototype = {
         return Preferences.canEditScriptSource;
     },
 
-    editScriptSource: function(sourceID, newContent, line, linesCountToShift, commitEditingCallback, cancelEditingCallback)
+    editScriptSource: function(editData, commitEditingCallback, cancelEditingCallback)
     {
         if (!this.canEditScripts())
             return;
@@ -323,18 +323,19 @@ WebInspector.ScriptsPanel.prototype = {
                 if (callFrames && callFrames.length)
                     this.debuggerPaused(callFrames);
             } else {
-                cancelEditingCallback();
+                if (cancelEditingCallback)
+                    cancelEditingCallback();
                 WebInspector.log(newBodyOrErrorMessage, WebInspector.ConsoleMessage.MessageLevel.Warning);
             }
             for (var i = 0; i < breakpoints.length; ++i) {
                 var breakpoint = breakpoints[i];
                 var newLine = breakpoint.line;
-                if (success && breakpoint.line >= line)
-                    newLine += linesCountToShift;
-                WebInspector.breakpointManager.setBreakpoint(sourceID, breakpoint.url, newLine, breakpoint.enabled, breakpoint.condition);
+                if (success && breakpoint.line >= editData.line)
+                    newLine += editData.linesCountToShift;
+                WebInspector.breakpointManager.setBreakpoint(editData.sourceID, breakpoint.url, newLine, breakpoint.enabled, breakpoint.condition);
             }
         };
-        InspectorBackend.editScriptSource(sourceID, newContent, mycallback.bind(this));
+        InspectorBackend.editScriptSource(editData.sourceID, editData.content, mycallback.bind(this));
     },
 
     selectedCallFrameId: function()
diff --git a/WebCore/inspector/front-end/SourceView.js b/WebCore/inspector/front-end/SourceView.js
index e764cf8..9616321 100644
--- a/WebCore/inspector/front-end/SourceView.js
+++ b/WebCore/inspector/front-end/SourceView.js
@@ -147,14 +147,28 @@ WebInspector.SourceView.prototype = {
                 lines.push(textModel.line(i));
         }
 
-        var linesCountToShift = newContent.split("\n").length - 1;
-        var newContent = lines.join("\n");
-        WebInspector.panels.scripts.editScriptSource(this._sourceIDForLine(line), newContent, line, linesCountToShift, this._editLineComplete.bind(this, newContent), 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(newContent)
+    _revertEditLine: function(editData, contentToRevertTo)
     {
-        this.resource.content = newContent;
+        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)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list