Files
react-native-devtools-frontend/front_end/elements/NodeStackTraceWidget.js
T
Tim van der Lippe 2e38eeaf9f Remove all comments with only the unrestricted annotation
The unrestricted annotation is Closure-specific and can be removed.
This patch removes all comments with only the unrestricted annotation
in them.

R=szuend@chromium.org

No-Presubmit: True
Bug: 1011811
Change-Id: Iba0723644f53f5307c3077d341271af86becc32a
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2569758
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Simon Zünd <szuend@chromium.org>
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
2020-12-02 15:25:32 +00:00

88 lines
2.7 KiB
JavaScript

// Copyright 2019 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 Components from '../components/components.js';
import * as SDK from '../sdk/sdk.js';
import * as UI from '../ui/ui.js';
/** @type {!NodeStackTraceWidget} */
let nodeStackTraceWidgetInstance;
export class NodeStackTraceWidget extends UI.ThrottledWidget.ThrottledWidget {
constructor() {
super(true /* isWebComponent */);
this.registerRequiredCSS('elements/nodeStackTraceWidget.css', {enableLegacyPatching: false});
this._noStackTraceElement = this.contentElement.createChild('div', 'gray-info-message');
this._noStackTraceElement.textContent = ls`No stack trace available`;
this._creationStackTraceElement = this.contentElement.createChild('div', 'stack-trace');
this._linkifier = new Components.Linkifier.Linkifier(MaxLengthForLinks);
}
/**
* @param {{forceNew: ?boolean}=} opts
* @return {!NodeStackTraceWidget}
*/
static instance(opts = {forceNew: null}) {
const {forceNew} = opts;
if (!nodeStackTraceWidgetInstance || forceNew) {
nodeStackTraceWidgetInstance = new NodeStackTraceWidget();
}
return nodeStackTraceWidgetInstance;
}
/**
* @override
*/
wasShown() {
UI.Context.Context.instance().addFlavorChangeListener(SDK.DOMModel.DOMNode, this.update, this);
this.update();
}
/**
* @override
*/
willHide() {
UI.Context.Context.instance().removeFlavorChangeListener(SDK.DOMModel.DOMNode, this.update, this);
}
/**
* @override
* @protected
* @return {!Promise<void>}
*/
async doUpdate() {
const node = UI.Context.Context.instance().flavor(SDK.DOMModel.DOMNode);
if (!node) {
this._noStackTraceElement.classList.remove('hidden');
this._creationStackTraceElement.classList.add('hidden');
return;
}
const creationStackTrace = await node.creationStackTrace();
if (creationStackTrace) {
this._noStackTraceElement.classList.add('hidden');
this._creationStackTraceElement.classList.remove('hidden');
const stackTracePreview = Components.JSPresentationUtils.buildStackTracePreviewContents(
node.domModel().target(), this._linkifier,
{stackTrace: creationStackTrace, contentUpdated: undefined, tabStops: undefined});
this._creationStackTraceElement.removeChildren();
this._creationStackTraceElement.appendChild(stackTracePreview.element);
} else {
this._noStackTraceElement.classList.remove('hidden');
this._creationStackTraceElement.classList.add('hidden');
}
}
}
/**
* @const
* @type {number}
*/
export const MaxLengthForLinks = 40;