mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 12:33:47 +08:00
Bug: chromium:1011811 Change-Id: I44a66c10efd317dcb7d5a4f58ab4be0fded4b215 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2466182 Reviewed-by: Alex Rudenko <alexrudenko@chromium.org> Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org> Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
88 lines
2.5 KiB
JavaScript
88 lines
2.5 KiB
JavaScript
// Copyright 2017 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import * as Common from '../common/common.js';
|
|
import * as DataGrid from '../data_grid/data_grid.js'; // eslint-disable-line no-unused-vars
|
|
import * as SDK from '../sdk/sdk.js';
|
|
import * as UI from '../ui/ui.js';
|
|
|
|
import {NetworkGroupNode} from './NetworkDataGridNode.js';
|
|
import {GroupLookupInterface, NetworkLogView} from './NetworkLogView.js'; // eslint-disable-line no-unused-vars
|
|
|
|
/**
|
|
* @implements {GroupLookupInterface}
|
|
*/
|
|
export class NetworkFrameGrouper {
|
|
/**
|
|
* @param {!NetworkLogView} parentView
|
|
*/
|
|
constructor(parentView) {
|
|
this._parentView = parentView;
|
|
/** @type {!Map<!SDK.ResourceTreeModel.ResourceTreeFrame, !FrameGroupNode>} */
|
|
this._activeGroups = new Map();
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @param {!SDK.NetworkRequest.NetworkRequest} request
|
|
* @return {?NetworkGroupNode}
|
|
*/
|
|
groupNodeForRequest(request) {
|
|
const frame = SDK.ResourceTreeModel.ResourceTreeModel.frameForRequest(request);
|
|
if (!frame || frame.isTopFrame()) {
|
|
return null;
|
|
}
|
|
let groupNode = this._activeGroups.get(frame);
|
|
if (groupNode) {
|
|
return groupNode;
|
|
}
|
|
groupNode = new FrameGroupNode(this._parentView, frame);
|
|
this._activeGroups.set(frame, groupNode);
|
|
return groupNode;
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
*/
|
|
reset() {
|
|
this._activeGroups.clear();
|
|
}
|
|
}
|
|
|
|
export class FrameGroupNode extends NetworkGroupNode {
|
|
/**
|
|
* @param {!NetworkLogView} parentView
|
|
* @param {!SDK.ResourceTreeModel.ResourceTreeFrame} frame
|
|
*/
|
|
constructor(parentView, frame) {
|
|
super(parentView);
|
|
this._frame = frame;
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
*/
|
|
displayName() {
|
|
return new Common.ParsedURL.ParsedURL(this._frame.url).domain() || this._frame.name || '<iframe>';
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @param {!Element} cell
|
|
* @param {string} columnId
|
|
*/
|
|
renderCell(/** @type {!HTMLElement} */ cell, columnId) {
|
|
super.renderCell(cell, columnId);
|
|
const columnIndex =
|
|
/** @type {!DataGrid.DataGrid.DataGridImpl<?>} */ (this.dataGrid).indexOfVisibleColumn(columnId);
|
|
if (columnIndex === 0) {
|
|
const name = this.displayName();
|
|
cell.appendChild(UI.Icon.Icon.create('largeicon-navigator-frame', 'network-frame-group-icon'));
|
|
UI.UIUtils.createTextChild(cell, name);
|
|
cell.title = name;
|
|
this.setCellAccessibleName(cell.textContent || '', cell, columnId);
|
|
}
|
|
}
|
|
}
|