Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @constructor | |
| 7 * @extends {HTMLDivElement} | |
| 8 */ | |
| 9 WebInspector.DebuggerPausedMessage = function() | |
| 10 { | |
| 11 } | |
| 12 | |
| 13 /** | |
| 14 * @return {!WebInspector.DebuggerPausedMessage} | |
| 15 */ | |
| 16 WebInspector.DebuggerPausedMessage.create = function() | |
| 17 { | |
| 18 if (!WebInspector.DebuggerPausedMessage._constructor) | |
| 19 WebInspector.DebuggerPausedMessage._constructor = registerCustomElement( "div", "paused-message", WebInspector.DebuggerPausedMessage.prototype); | |
| 20 | |
| 21 return /** @type {!WebInspector.DebuggerPausedMessage} */(new WebInspector.D ebuggerPausedMessage._constructor()); | |
| 22 } | |
| 23 | |
| 24 WebInspector.DebuggerPausedMessage.prototype = { | |
| 25 createdCallback: function() | |
| 26 { | |
| 27 this.classList.add("flex-none"); | |
| 28 var root = WebInspector.createShadowRootWithCoreStyles(this, "sources/de buggerPausedMessage.css"); | |
| 29 this.contentElement = root.createChild("div", "paused-status"); | |
| 30 }, | |
| 31 | |
| 32 /** | |
| 33 * @param {?WebInspector.DebuggerPausedDetails} details | |
| 34 */ | |
| 35 render: function(details) | |
|
lushnikov
2016/10/14 00:16:53
let's pass all the singletons we rely on here
luoe
2016/10/17 19:27:41
Done.
| |
| 36 { | |
| 37 var status = this.contentElement; | |
| 38 status.hidden = !details; | |
| 39 status.removeChildren(); | |
| 40 if (!details) | |
| 41 return; | |
| 42 | |
| 43 var messageWrapper; | |
| 44 if (details.reason === WebInspector.DebuggerModel.BreakReason.DOM) { | |
| 45 messageWrapper = WebInspector.domBreakpointsSidebarPane.createBreakp ointHitMessage(details); | |
|
lushnikov
2016/10/14 00:16:53
let's use static method?
luoe
2016/10/17 19:27:41
Done.
| |
| 46 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Eve ntListener) { | |
| 47 var eventName = details.auxData["eventName"]; | |
| 48 var eventNameForUI = WebInspector.EventListenerBreakpointsSidebarPan e.eventNameForUI(eventName, details.auxData); | |
| 49 messageWrapper = buildWrapper(WebInspector.UIString("Paused on event listener"), eventNameForUI); | |
| 50 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.XHR ) { | |
| 51 messageWrapper = buildWrapper(WebInspector.UIString("Paused on XMLHt tpRequest"), details.auxData["url"] || ""); | |
| 52 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Exc eption) { | |
| 53 var description = details.auxData["description"] || details.auxData[ "value"] || ""; | |
| 54 var descriptionFirstLine = description.split("\n", 1)[0]; | |
| 55 messageWrapper = buildWrapper(WebInspector.UIString("Paused on excep tion"), descriptionFirstLine, description); | |
| 56 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Pro miseRejection) { | |
| 57 var description = details.auxData["description"] || details.auxData[ "value"] || ""; | |
| 58 var descriptionFirstLine = description.split("\n", 1)[0]; | |
| 59 messageWrapper = buildWrapper(WebInspector.UIString("Paused on promi se rejection"), descriptionFirstLine, description); | |
| 60 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Ass ert) { | |
| 61 messageWrapper = buildWrapper(WebInspector.UIString("Paused on asser tion")); | |
| 62 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Deb ugCommand) { | |
| 63 messageWrapper = buildWrapper(WebInspector.UIString("Paused on debug ged function")); | |
| 64 } else if (details.callFrames.length) { | |
| 65 var uiLocation = WebInspector.debuggerWorkspaceBinding.rawLocationTo UILocation(details.callFrames[0].location()); | |
| 66 var breakpoint = uiLocation ? WebInspector.breakpointManager.findBre akpointOnLine(uiLocation.uiSourceCode, uiLocation.lineNumber) : null; | |
| 67 var defaultText = breakpoint ? WebInspector.UIString("Paused on brea kpoint") : WebInspector.UIString("Debugger paused"); | |
| 68 messageWrapper = buildWrapper(defaultText); | |
| 69 } else { | |
| 70 console.warn("ScriptsPanel paused, but callFrames.length is zero."); // TODO remove this once we understand this case better | |
| 71 } | |
| 72 | |
| 73 var errorLike = details.reason === WebInspector.DebuggerModel.BreakReaso n.Exception || details.reason === WebInspector.DebuggerModel.BreakReason.Promise Rejection || details.reason === WebInspector.DebuggerModel.BreakReason.Assert; | |
| 74 status.classList.toggle("error-reason", errorLike); | |
| 75 if (messageWrapper) | |
| 76 status.appendChild(messageWrapper); | |
| 77 | |
| 78 /** | |
| 79 * @param {string} mainText | |
| 80 * @param {string=} subText | |
| 81 * @param {string=} title | |
| 82 * @return {!Element} | |
| 83 */ | |
| 84 function buildWrapper(mainText, subText, title) | |
| 85 { | |
| 86 var messageWrapper = createElement("span"); | |
| 87 var mainElement = messageWrapper.createChild("div", "status-main"); | |
| 88 mainElement.textContent = mainText; | |
| 89 if (subText) { | |
| 90 var subElement = messageWrapper.createChild("div", "status-sub") ; | |
| 91 subElement.textContent = subText; | |
| 92 } | |
| 93 if (title) | |
| 94 messageWrapper.title = title; | |
| 95 return messageWrapper; | |
| 96 } | |
| 97 }, | |
| 98 | |
| 99 __proto__: HTMLDivElement.prototype | |
| 100 } | |
| OLD | NEW |