Changeset 200605 in webkit


Ignore:
Timestamp:
May 9, 2016 6:40:26 PM (8 years ago)
Author:
Nikita Vasilyev
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.

Location:
trunk/Source/WebInspectorUI
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r200600 r200605  
     12016-05-09  Nikita Vasilyev  <nvasilyev@apple.com>
     2
     3        REGRESSION: Web Inspector: DOM path bar blinks when modifying inline styles
     4        https://bugs.webkit.org/show_bug.cgi?id=149258
     5        <rdar://problem/22737843>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        * UserInterface/Base/Utilities.js:
     10        (Array.shallowEqual):
     11        * UserInterface/Views/ContentBrowser.js:
     12        (WebInspector.ContentBrowser.prototype._updateContentViewNavigationItems):
     13        (WebInspector.ContentBrowser.prototype._removeAllNavigationItems):
     14        Don't re-render the navigation bar when all new navigation items match the previous ones.
     15
     16        * UserInterface/Views/HierarchicalPathNavigationItem.js:
     17        (WebInspector.HierarchicalPathNavigationItem.set components.let.componentsEqual):
     18        (WebInspector.HierarchicalPathNavigationItem.prototype.set components):
     19        Don't re-render HierarchicalPathComponent when all new path components match the previous ones.
     20
    1212016-05-09  Matt Baker  <mattbaker@apple.com>
    222
  • trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js

    r199897 r200605  
    425425});
    426426
     427Object.defineProperty(Array, "shallowEqual",
     428{
     429    value: function(a, b)
     430    {
     431        if (a === b)
     432            return true;
     433
     434        let length = a.length;
     435
     436        if (length !== b.length)
     437            return false;
     438
     439        for (var i = 0; i < length; ++i) {
     440            if (a[i] !== b[i])
     441                return false;
     442        }
     443
     444        return true;
     445    }
     446});
     447
    427448Object.defineProperty(Array.prototype, "lastValue",
    428449{
  • trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowser.js

    r199790 r200605  
    366366    _updateContentViewNavigationItems()
    367367    {
    368         var navigationBar = this.navigationBar;
    369 
    370         // First, we remove the navigation items added by the previous content view.
    371         this._currentContentViewNavigationItems.forEach(function(navigationItem) {
    372             navigationBar.removeNavigationItem(navigationItem);
    373         });
    374 
    375368        var currentContentView = this.currentContentView;
    376369        if (!currentContentView) {
     370            this._removeAllNavigationItems();
    377371            this._currentContentViewNavigationItems = [];
    378372            return;
    379373        }
    380374
    381         var insertionIndex = navigationBar.navigationItems.indexOf(this._dividingFlexibleSpaceNavigationItem) + 1;
     375        let previousItems = this._currentContentViewNavigationItems.filter((item) => !(item instanceof WebInspector.DividerNavigationItem));
     376        let isUnchanged = Array.shallowEqual(previousItems, currentContentView.navigationItems);
     377
     378        if (isUnchanged)
     379            return;
     380
     381        this._removeAllNavigationItems();
     382
     383        let navigationBar = this.navigationBar;
     384        let insertionIndex = navigationBar.navigationItems.indexOf(this._dividingFlexibleSpaceNavigationItem) + 1;
    382385        console.assert(insertionIndex >= 0);
    383386
    384387        // Keep track of items we'll be adding to the navigation bar.
    385         var newNavigationItems = [];
     388        let newNavigationItems = [];
    386389
    387390        // Go through each of the items of the new content view and add a divider before them.
     
    389392            // Add dividers before items unless it's the first item and not a button.
    390393            if (index !== 0 || navigationItem instanceof WebInspector.ButtonNavigationItem) {
    391                 var divider = new WebInspector.DividerNavigationItem;
     394                let divider = new WebInspector.DividerNavigationItem;
    392395                navigationBar.insertNavigationItem(divider, insertionIndex++);
    393396                newNavigationItems.push(divider);
     
    402405    }
    403406
     407    _removeAllNavigationItems()
     408    {
     409        for (let navigationItem of this._currentContentViewNavigationItems)
     410            this.navigationBar.removeNavigationItem(navigationItem);
     411    }
     412
    404413    _updateFindBanner(currentContentView)
    405414    {
  • trunk/Source/WebInspectorUI/UserInterface/Views/HierarchicalPathNavigationItem.js

    r196275 r200605  
    4545            newComponents = [];
    4646
     47        let componentsEqual = function(a, b) {
     48            let getRepresentedObjects = (component) => component.representedObject;
     49            let representedObjectsA = a.map(getRepresentedObjects);
     50            let representedObjectsB = b.map(getRepresentedObjects);
     51            return Array.shallowEqual(representedObjectsA, representedObjectsB);
     52        };
     53
     54        if (this._components && componentsEqual(this._components, newComponents))
     55            return;
     56
    4757        for (var i = 0; this._components && i < this._components.length; ++i)
    4858            this._components[i].removeEventListener(WebInspector.HierarchicalPathComponent.Event.SiblingWasSelected, this._siblingPathComponentWasSelected, this);
Note: See TracChangeset for help on using the changeset viewer.