NodeStackTraceWidget.js 1.6 KB

123456
  1. export default class NodeStackTraceWidget extends UI.ThrottledWidget{constructor(){super(true);this.registerRequiredCSS('elements/nodeStackTraceWidget.css');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(MaxLengthForLinks);}
  2. wasShown(){UI.context.addFlavorChangeListener(SDK.DOMNode,this.update,this);this.update();}
  3. willHide(){UI.context.removeFlavorChangeListener(SDK.DOMNode,this.update,this);}
  4. async doUpdate(){const node=UI.context.flavor(SDK.DOMNode);if(!node){this._noStackTraceElement.classList.remove('hidden');this._creationStackTraceElement.classList.add('hidden');return;}
  5. 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,creationStackTrace);this._creationStackTraceElement.removeChildren();this._creationStackTraceElement.appendChild(stackTracePreview.element);}else{this._noStackTraceElement.classList.remove('hidden');this._creationStackTraceElement.classList.add('hidden');}}}
  6. export const MaxLengthForLinks=40;self.Elements=self.Elements||{};Elements=Elements||{};Elements.NodeStackTraceWidget=NodeStackTraceWidget;Elements.NodeStackTraceWidget.MaxLengthForLinks=MaxLengthForLinks;