Title: [200605] trunk/Source/WebInspectorUI
Revision
200605
Author
[email protected]
Date
2016-05-09 18:40:26 -0700 (Mon, 09 May 2016)

Log Message

REGRESSION: Web Inspector: DOM path bar blinks when modifying inline styles
https://bugs.webkit.org/show_bug.cgi?id=149258
<rdar://problem/22737843>

Reviewed by Timothy Hatcher.

* UserInterface/Base/Utilities.js:
(Array.shallowEqual):
* UserInterface/Views/ContentBrowser.js:
(WebInspector.ContentBrowser.prototype._updateContentViewNavigationItems):
(WebInspector.ContentBrowser.prototype._removeAllNavigationItems):
Don't re-render the navigation bar when all new navigation items match the previous ones.

* UserInterface/Views/HierarchicalPathNavigationItem.js:
(WebInspector.HierarchicalPathNavigationItem.set components.let.componentsEqual):
(WebInspector.HierarchicalPathNavigationItem.prototype.set components):
Don't re-render HierarchicalPathComponent when all new path components match the previous ones.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (200604 => 200605)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-05-10 01:35:48 UTC (rev 200604)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-05-10 01:40:26 UTC (rev 200605)
@@ -1,3 +1,23 @@
+2016-05-09  Nikita Vasilyev  <[email protected]>
+
+        REGRESSION: Web Inspector: DOM path bar blinks when modifying inline styles
+        https://bugs.webkit.org/show_bug.cgi?id=149258
+        <rdar://problem/22737843>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Base/Utilities.js:
+        (Array.shallowEqual):
+        * UserInterface/Views/ContentBrowser.js:
+        (WebInspector.ContentBrowser.prototype._updateContentViewNavigationItems):
+        (WebInspector.ContentBrowser.prototype._removeAllNavigationItems):
+        Don't re-render the navigation bar when all new navigation items match the previous ones.
+
+        * UserInterface/Views/HierarchicalPathNavigationItem.js:
+        (WebInspector.HierarchicalPathNavigationItem.set components.let.componentsEqual):
+        (WebInspector.HierarchicalPathNavigationItem.prototype.set components):
+        Don't re-render HierarchicalPathComponent when all new path components match the previous ones.
+
 2016-05-09  Matt Baker  <[email protected]>
 
         Web Inspector: Remove Global Breakpoints folder

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js (200604 => 200605)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2016-05-10 01:35:48 UTC (rev 200604)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js	2016-05-10 01:40:26 UTC (rev 200605)
@@ -424,6 +424,27 @@
     value: Element.prototype.createChild
 });
 
+Object.defineProperty(Array, "shallowEqual",
+{
+    value: function(a, b)
+    {
+        if (a === b)
+            return true;
+
+        let length = a.length;
+
+        if (length !== b.length)
+            return false;
+
+        for (var i = 0; i < length; ++i) {
+            if (a[i] !== b[i])
+                return false;
+        }
+
+        return true;
+    }
+});
+
 Object.defineProperty(Array.prototype, "lastValue",
 {
     get: function()

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowser.js (200604 => 200605)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowser.js	2016-05-10 01:35:48 UTC (rev 200604)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowser.js	2016-05-10 01:40:26 UTC (rev 200605)
@@ -365,30 +365,33 @@
 
     _updateContentViewNavigationItems()
     {
-        var navigationBar = this.navigationBar;
-
-        // First, we remove the navigation items added by the previous content view.
-        this._currentContentViewNavigationItems.forEach(function(navigationItem) {
-            navigationBar.removeNavigationItem(navigationItem);
-        });
-
         var currentContentView = this.currentContentView;
         if (!currentContentView) {
+            this._removeAllNavigationItems();
             this._currentContentViewNavigationItems = [];
             return;
         }
 
-        var insertionIndex = navigationBar.navigationItems.indexOf(this._dividingFlexibleSpaceNavigationItem) + 1;
+        let previousItems = this._currentContentViewNavigationItems.filter((item) => !(item instanceof WebInspector.DividerNavigationItem));
+        let isUnchanged = Array.shallowEqual(previousItems, currentContentView.navigationItems);
+
+        if (isUnchanged)
+            return;
+
+        this._removeAllNavigationItems();
+
+        let navigationBar = this.navigationBar;
+        let insertionIndex = navigationBar.navigationItems.indexOf(this._dividingFlexibleSpaceNavigationItem) + 1;
         console.assert(insertionIndex >= 0);
 
         // Keep track of items we'll be adding to the navigation bar.
-        var newNavigationItems = [];
+        let newNavigationItems = [];
 
         // Go through each of the items of the new content view and add a divider before them.
         currentContentView.navigationItems.forEach(function(navigationItem, index) {
             // Add dividers before items unless it's the first item and not a button.
             if (index !== 0 || navigationItem instanceof WebInspector.ButtonNavigationItem) {
-                var divider = new WebInspector.DividerNavigationItem;
+                let divider = new WebInspector.DividerNavigationItem;
                 navigationBar.insertNavigationItem(divider, insertionIndex++);
                 newNavigationItems.push(divider);
             }
@@ -401,6 +404,12 @@
         this._currentContentViewNavigationItems = newNavigationItems;
     }
 
+    _removeAllNavigationItems()
+    {
+        for (let navigationItem of this._currentContentViewNavigationItems)
+            this.navigationBar.removeNavigationItem(navigationItem);
+    }
+
     _updateFindBanner(currentContentView)
     {
         if (!this._findBanner)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HierarchicalPathNavigationItem.js (200604 => 200605)


--- trunk/Source/WebInspectorUI/UserInterface/Views/HierarchicalPathNavigationItem.js	2016-05-10 01:35:48 UTC (rev 200604)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HierarchicalPathNavigationItem.js	2016-05-10 01:40:26 UTC (rev 200605)
@@ -44,6 +44,16 @@
         if (!newComponents)
             newComponents = [];
 
+        let componentsEqual = function(a, b) {
+            let getRepresentedObjects = (component) => component.representedObject;
+            let representedObjectsA = a.map(getRepresentedObjects);
+            let representedObjectsB = b.map(getRepresentedObjects);
+            return Array.shallowEqual(representedObjectsA, representedObjectsB);
+        };
+
+        if (this._components && componentsEqual(this._components, newComponents))
+            return;
+
         for (var i = 0; this._components && i < this._components.length; ++i)
             this._components[i].removeEventListener(WebInspector.HierarchicalPathComponent.Event.SiblingWasSelected, this._siblingPathComponentWasSelected, this);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to