Changeset 156675 in webkit


Ignore:
Timestamp:
Sep 30, 2013 1:10:14 PM (11 years ago)
Author:
Antoine Quint
Message:

Web Inspector: rows in the Layer sidebar panel may have the incorrect background color
https://bugs.webkit.org/show_bug.cgi?id=122108

Reviewed by Darin Adler.

The LayerTreeDataGrid is a custom DataGrid subclass which exposes a .setChildren() method
used to sort chidren without DOM order manipulation, for performance reason. However, since
the way the alternating background color is usually implemented is based on the built-in
CSS pseudo-classes working with DOM order, the background colors of nodes in the LayerTreeDataGrid
can be incorrect depending on the sort order and the number of nodes. To fix this, we now manually
set "even" and "odd" CSS classes on those nodes when they're sorted such that we have a chance
to style them as intended.

  • UserInterface/LayerTreeDataGrid.js:

(WebInspector.LayerTreeDataGrid.prototype._updateChildren):
Check if the data grid node index is even or odd and reflect this via an exclusive "even"
or "odd" CSS class name.

  • UserInterface/LayerTreeSidebarPanel.css:

(.layer-tree.panel .data-container tbody > tr.even):
(.layer-tree.panel .data-container tbody > tr.odd):
Apply alternating colors based on the exclusive "even" and "odd" CSS class names as applied in
WebInspector.LayerTreeDataGrid.prototype._updateChildren().

Location:
trunk/Source/WebInspectorUI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r156673 r156675  
     12013-09-30  Antoine Quint  <graouts@apple.com>
     2
     3        Web Inspector: rows in the Layer sidebar panel may have the incorrect background color
     4        https://bugs.webkit.org/show_bug.cgi?id=122108
     5
     6        Reviewed by Darin Adler.
     7
     8        The LayerTreeDataGrid is a custom DataGrid subclass which exposes a .setChildren() method
     9        used to sort chidren without DOM order manipulation, for performance reason. However, since
     10        the way the alternating background color is usually implemented is based on the built-in
     11        CSS pseudo-classes working with DOM order, the background colors of nodes in the LayerTreeDataGrid
     12        can be incorrect depending on the sort order and the number of nodes. To fix this, we now manually
     13        set "even" and "odd" CSS classes on those nodes when they're sorted such that we have a chance
     14        to style them as intended.
     15
     16        * UserInterface/LayerTreeDataGrid.js:
     17        (WebInspector.LayerTreeDataGrid.prototype._updateChildren):
     18        Check if the data grid node index is even or odd and reflect this via an exclusive "even"
     19        or "odd" CSS class name.
     20
     21        * UserInterface/LayerTreeSidebarPanel.css:
     22        (.layer-tree.panel .data-container tbody > tr.even):
     23        (.layer-tree.panel .data-container tbody > tr.odd):
     24        Apply alternating colors based on the exclusive "even" and "odd" CSS class names as applied in
     25        WebInspector.LayerTreeDataGrid.prototype._updateChildren().
     26
    1272013-09-30  Antoine Quint  <graouts@apple.com>
    228
  • trunk/Source/WebInspectorUI/UserInterface/LayerTreeDataGrid.js

    r151453 r156675  
    9393            var ty = (i - child._domIndex) * 100;
    9494            child.element.style.webkitTransform = "translateY(" + ty + "%)";
     95
     96            // Since the DOM order won't necessarily match the visual order of the
     97            // children in the data grid we manually set "even" and "odd" and CSS
     98            // class names on the data grid nodes so that they may be styled with
     99            // a different mechanism than the built-in CSS pseudo-classes.
     100            var classList = child.element.classList;
     101            if (i % 2) {
     102                classList.remove("odd");
     103                classList.add("even");
     104            } else {
     105                classList.remove("even");
     106                classList.add("odd");
     107            }
    95108        }
    96109
  • trunk/Source/WebInspectorUI/UserInterface/LayerTreeSidebarPanel.css

    r155241 r156675  
    167167}
    168168
     169.layer-tree.panel .data-container tbody > tr.even {
     170    background-color: white;
     171}
     172
     173.layer-tree.panel .data-container tbody > tr.odd {
     174    background-color: rgb(243, 246, 250);
     175}
     176
    169177/* Bottom bar */
    170178
Note: See TracChangeset for help on using the changeset viewer.