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 */ |
| 8 WebInspector.DebuggerPausedMessage = function() |
| 9 { |
| 10 this._element = createElementWithClass("div", "paused-message flex-none"); |
| 11 var root = WebInspector.createShadowRootWithCoreStyles(this._element, "sourc
es/debuggerPausedMessage.css"); |
| 12 this._contentElement = root.createChild("div", "paused-status"); |
| 13 } |
| 14 |
| 15 WebInspector.DebuggerPausedMessage.prototype = { |
| 16 /** |
| 17 * @return {!Element} |
| 18 */ |
| 19 element: function() |
| 20 { |
| 21 return this._element; |
| 22 }, |
| 23 |
| 24 /** |
| 25 * @param {?WebInspector.DebuggerPausedDetails} details |
| 26 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding |
| 27 * @param {!WebInspector.BreakpointManager} breakpointManager |
| 28 */ |
| 29 render: function(details, debuggerWorkspaceBinding, breakpointManager) |
| 30 { |
| 31 var status = this._contentElement; |
| 32 status.hidden = !details; |
| 33 status.removeChildren(); |
| 34 if (!details) |
| 35 return; |
| 36 |
| 37 var messageWrapper; |
| 38 if (details.reason === WebInspector.DebuggerModel.BreakReason.DOM) { |
| 39 messageWrapper = WebInspector.DOMBreakpointsSidebarPane.createBreakp
ointHitMessage(details); |
| 40 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Eve
ntListener) { |
| 41 var eventName = details.auxData["eventName"]; |
| 42 var eventNameForUI = WebInspector.EventListenerBreakpointsSidebarPan
e.eventNameForUI(eventName, details.auxData); |
| 43 messageWrapper = buildWrapper(WebInspector.UIString("Paused on event
listener"), eventNameForUI); |
| 44 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.XHR
) { |
| 45 messageWrapper = buildWrapper(WebInspector.UIString("Paused on XMLHt
tpRequest"), details.auxData["url"] || ""); |
| 46 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Exc
eption) { |
| 47 var description = details.auxData["description"] || details.auxData[
"value"] || ""; |
| 48 var descriptionFirstLine = description.split("\n", 1)[0]; |
| 49 messageWrapper = buildWrapper(WebInspector.UIString("Paused on excep
tion"), descriptionFirstLine, description); |
| 50 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Pro
miseRejection) { |
| 51 var description = details.auxData["description"] || details.auxData[
"value"] || ""; |
| 52 var descriptionFirstLine = description.split("\n", 1)[0]; |
| 53 messageWrapper = buildWrapper(WebInspector.UIString("Paused on promi
se rejection"), descriptionFirstLine, description); |
| 54 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Ass
ert) { |
| 55 messageWrapper = buildWrapper(WebInspector.UIString("Paused on asser
tion")); |
| 56 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Deb
ugCommand) { |
| 57 messageWrapper = buildWrapper(WebInspector.UIString("Paused on debug
ged function")); |
| 58 } else if (details.callFrames.length) { |
| 59 var uiLocation = debuggerWorkspaceBinding.rawLocationToUILocation(de
tails.callFrames[0].location()); |
| 60 var breakpoint = uiLocation ? breakpointManager.findBreakpointOnLine
(uiLocation.uiSourceCode, uiLocation.lineNumber) : null; |
| 61 var defaultText = breakpoint ? WebInspector.UIString("Paused on brea
kpoint") : WebInspector.UIString("Debugger paused"); |
| 62 messageWrapper = buildWrapper(defaultText); |
| 63 } else { |
| 64 console.warn("ScriptsPanel paused, but callFrames.length is zero.");
// TODO remove this once we understand this case better |
| 65 } |
| 66 |
| 67 var errorLike = details.reason === WebInspector.DebuggerModel.BreakReaso
n.Exception || details.reason === WebInspector.DebuggerModel.BreakReason.Promise
Rejection || details.reason === WebInspector.DebuggerModel.BreakReason.Assert; |
| 68 status.classList.toggle("error-reason", errorLike); |
| 69 if (messageWrapper) |
| 70 status.appendChild(messageWrapper); |
| 71 |
| 72 /** |
| 73 * @param {string} mainText |
| 74 * @param {string=} subText |
| 75 * @param {string=} title |
| 76 * @return {!Element} |
| 77 */ |
| 78 function buildWrapper(mainText, subText, title) |
| 79 { |
| 80 var messageWrapper = createElement("span"); |
| 81 var mainElement = messageWrapper.createChild("div", "status-main"); |
| 82 mainElement.textContent = mainText; |
| 83 if (subText) { |
| 84 var subElement = messageWrapper.createChild("div", "status-sub")
; |
| 85 subElement.textContent = subText; |
| 86 } |
| 87 if (title) |
| 88 messageWrapper.title = title; |
| 89 return messageWrapper; |
| 90 } |
| 91 } |
| 92 } |
OLD | NEW |