Changeset 195522 in webkit


Ignore:
Timestamp:
Jan 24, 2016, 8:00:36 PM (10 years ago)
Author:
Matt Baker
Message:

Web Inspector: add support for placing Views in DataGrid column headers
https://bugs.webkit.org/show_bug.cgi?id=153387
<rdar://problem/24310797>

Reviewed by Timothy Hatcher.

This patch adds a new DataGrid column property, headerView, allowing a
custom View object to be placed in a column's header cell. The grid ensures
that the left and right edges of the view are kept in sync as columns are
resized. As most views use absolute positioning and are styled in CSS, the
vertical position and height of the view isn't set by the grid.

  • UserInterface/Views/DataGrid.js:

(WebInspector.DataGrid.prototype.insertColumn):
If the new column includes the headerView column data property,
it should take priority over titleDOMFragment and title text.
The specified View object is inserted into the DOM under the
column's <th> element, and added as a subview of the data grid.
(WebInspector.DataGrid.prototype.layout):
Update header views after performing default layout.
(WebInspector.DataGrid.prototype._showColumn):
Set hidden column property false instead of deleting it.
(WebInspector.DataGrid.prototype._positionHeaderViews):
Update the left and right style positions for all Views embedded in
column header cells, then update their layouts.
(WebInspector.DataGrid.prototype.resizerDragging):
Update header views after column resizers are repositioned.

Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r195519 r195522  
     12016-01-24  Matt Baker  <mattbaker@apple.com>
     2
     3        Web Inspector: add support for placing Views in DataGrid column headers
     4        https://bugs.webkit.org/show_bug.cgi?id=153387
     5        <rdar://problem/24310797>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        This patch adds a new DataGrid column property, `headerView`, allowing a
     10        custom View object to be placed in a column's header cell. The grid ensures
     11        that the left and right edges of the view are kept in sync as columns are
     12        resized. As most views use absolute positioning and are styled in CSS, the
     13        vertical position and height of the view isn't set by the grid.
     14
     15        * UserInterface/Views/DataGrid.js:
     16        (WebInspector.DataGrid.prototype.insertColumn):
     17        If the new column includes the `headerView` column data property,
     18        it should take priority over `titleDOMFragment` and title text.
     19        The specified View object is inserted into the DOM under the
     20        column's <th> element, and added as a subview of the data grid.
     21        (WebInspector.DataGrid.prototype.layout):
     22        Update header views after performing default layout.
     23        (WebInspector.DataGrid.prototype._showColumn):
     24        Set `hidden` column property false instead of deleting it.
     25        (WebInspector.DataGrid.prototype._positionHeaderViews):
     26        Update the left and right style positions for all Views embedded in
     27        column header cells, then update their layouts.
     28        (WebInspector.DataGrid.prototype.resizerDragging):
     29        Update header views after column resizers are repositioned.
     30
    1312016-01-24  Nikita Vasilyev  <nvasilyev@apple.com>
    232
  • trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js

    r194906 r195522  
    475475        this._headerTableRowElement.insertBefore(headerCellElement, referenceElement);
    476476
    477         var div = headerCellElement.createChild("div");
    478         if (column["titleDOMFragment"])
    479             div.appendChild(column["titleDOMFragment"]);
    480         else
    481             div.textContent = column["title"] || "";
     477        if (column["headerView"]) {
     478            let headerView = column["headerView"];
     479            console.assert(headerView instanceof WebInspector.View);
     480
     481            headerCellElement.appendChild(headerView.element);
     482            this.addSubview(headerView);
     483        } else {
     484            let titleElement = headerCellElement.createChild("div");
     485            if (column["titleDOMFragment"])
     486                titleElement.appendChild(column["titleDOMFragment"]);
     487            else
     488                titleElement.textContent = column["title"] || "";
     489        }
    482490
    483491        if (column["sortable"]) {
     
    610618
    611619        this._positionResizerElements();
     620        this._positionHeaderViews();
    612621    }
    613622
     
    641650    _showColumn(columnIdentifier)
    642651    {
    643         delete this.columns.get(columnIdentifier)["hidden"];
     652        this.columns.get(columnIdentifier)["hidden"] = false;
    644653    }
    645654
     
    707716        if (previousResizer)
    708717            previousResizer[WebInspector.DataGrid.NextColumnOrdinalSymbol] = this.orderedColumns.length - 1;
     718    }
     719
     720    _positionHeaderViews()
     721    {
     722        let visibleHeaderViews = false;
     723        for (let column of this.columns.values()) {
     724            if (column["headerView"] && !column["hidden"]) {
     725                visibleHeaderViews = true;
     726                break;
     727            }
     728        }
     729
     730        if (!visibleHeaderViews)
     731            return;
     732
     733        let left = 0;
     734        for (let columnIdentifier of this.orderedColumns) {
     735            let column = this.columns.get(columnIdentifier);
     736            console.assert(column, "Missing column data for header cell with columnIdentifier " + columnIdentifier);
     737            if (!column)
     738                continue;
     739
     740            let columnWidth = this._headerTableCellElements.get(columnIdentifier).offsetWidth;
     741            let headerView = column["headerView"];
     742            if (headerView) {
     743                headerView.element.style.left = left + "px";
     744                headerView.element.style.width = columnWidth + "px";
     745                headerView.updateLayout();
     746            }
     747
     748            left += columnWidth;
     749        }
    709750    }
    710751
     
    12861327
    12871328        this._positionResizerElements();
     1329        this._positionHeaderViews();
    12881330        event.preventDefault();
    12891331    }
Note: See TracChangeset for help on using the changeset viewer.