Web Inspector: [Overrides] Command-Z doesn't undo changes after page reload
authorpecoraro@apple.com <pecoraro@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Sep 2019 08:15:58 +0000 (08:15 +0000)
committerpecoraro@apple.com <pecoraro@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Sep 2019 08:15:58 +0000 (08:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=201698
<rdar://problem/55276645>

Reviewed by Devin Rousso.

* UserInterface/Views/ContentViewContainer.js:
(WI.ContentViewContainer.prototype.closeAllContentViews):
Provide a filter to opt out of closing some content views.

* UserInterface/Views/SourcesNavigationSidebarPanel.js:
(WI.SourcesNavigationSidebarPanel.prototype._closeContentViewsFilter):
(WI.SourcesNavigationSidebarPanel.prototype._updateMainFrameTreeElement):
Avoid closing ContentViews for local resource overrides. This keeps the
SourceCodeTextEditor around and thus its undo/redo stack.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249828 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/ContentViewContainer.js
Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js

index 119692b..9fddc23 100644 (file)
@@ -1,3 +1,21 @@
+2019-09-13  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: [Overrides] Command-Z doesn't undo changes after page reload
+        https://bugs.webkit.org/show_bug.cgi?id=201698
+        <rdar://problem/55276645>
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Views/ContentViewContainer.js:
+        (WI.ContentViewContainer.prototype.closeAllContentViews):
+        Provide a filter to opt out of closing some content views.
+
+        * UserInterface/Views/SourcesNavigationSidebarPanel.js:
+        (WI.SourcesNavigationSidebarPanel.prototype._closeContentViewsFilter):
+        (WI.SourcesNavigationSidebarPanel.prototype._updateMainFrameTreeElement):
+        Avoid closing ContentViews for local resource overrides. This keeps the
+        SourceCodeTextEditor around and thus its undo/redo stack.
+
 2019-09-12  Joseph Pecoraro  <pecoraro@apple.com>
 
         Uncaught Exception: TypeError: null is not an object (evaluating 'selectedTreeElement.representedObject')
index 34f06f5..5985d2d 100644 (file)
@@ -274,8 +274,10 @@ WI.ContentViewContainer = class ContentViewContainer extends WI.View
         }
     }
 
-    closeAllContentViews()
+    closeAllContentViews(filter)
     {
+        console.assert(!filter || typeof filter === "function");
+
         if (!this._backForwardList.length) {
             console.assert(this._currentIndex === -1);
             return;
@@ -284,10 +286,14 @@ WI.ContentViewContainer = class ContentViewContainer extends WI.View
         var visibleContentView = this.currentContentView;
 
         // Hide and disassociate with all the content views.
-        for (var i = 0; i < this._backForwardList.length; ++i) {
-            var entry = this._backForwardList[i];
+        for (let i = 0; i < this._backForwardList.length; ++i) {
+            let entry = this._backForwardList[i];
+            if (filter && !filter(entry.contentView))
+                continue;
+
             if (entry.contentView === visibleContentView)
                 this._hideEntry(entry);
+
             this._disassociateFromContentView(entry.contentView, entry.tombstone);
         }
 
index c7dd3c5..77b083b 100644 (file)
@@ -737,10 +737,19 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
         return a.mainTitle.extendedLocaleCompare(b.mainTitle) || a.subtitle.extendedLocaleCompare(b.subtitle);
     }
 
+    _closeContentViewsFilter(contentView)
+    {
+        // Local Resource Override content views do not need to be closed across page navigations.
+        if (contentView.representedObject instanceof WI.LocalResource && contentView.representedObject.isLocalResourceOverride)
+            return false;
+
+        return true;
+    }
+
     _updateMainFrameTreeElement(mainFrame)
     {
         if (this.didInitialLayout)
-            this.contentBrowser.contentViewContainer.closeAllContentViews();
+            this.contentBrowser.contentViewContainer.closeAllContentViews(this._closeContentViewsFilter);
 
         let oldMainFrameTreeElement = this._mainFrameTreeElement;
         if (this._mainFrameTreeElement) {