Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/sources/DebuggerPausedMessage.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/sources/DebuggerPausedMessage.js b/third_party/WebKit/Source/devtools/front_end/sources/DebuggerPausedMessage.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2593e29395a4f17f6b5f7800ed493ea7e9170778 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/devtools/front_end/sources/DebuggerPausedMessage.js |
| @@ -0,0 +1,86 @@ |
| +// Copyright 2016 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. |
| + |
| +/** |
| + * @constructor |
| + * @extends {WebInspector.VBox} |
| + */ |
| +WebInspector.DebuggerPausedMessage = function() |
| +{ |
| + WebInspector.VBox.call(this); |
|
dgozman
2016/10/13 03:39:13
Please don't make something a widget if you just w
|
| + this.registerRequiredCSS("sources/debuggerPausedMessage.css"); |
| + this.contentElement = this.element.createChild("div", "paused-status"); |
| + this.element.className = "paused-container"; |
| +} |
| + |
| +WebInspector.DebuggerPausedMessage.prototype = { |
| + /** |
| + * @param {?WebInspector.DebuggerPausedDetails} details |
| + */ |
| + render: function(details) |
| + { |
| + var status = this.contentElement; |
| + status.hidden = !details; |
| + status.removeChildren(); |
| + if (!details) |
| + return; |
| + |
| + var messageWrapper; |
| + if (details.reason === WebInspector.DebuggerModel.BreakReason.DOM) { |
| + messageWrapper = WebInspector.domBreakpointsSidebarPane.createBreakpointHitMessage(details); |
| + } else if (details.reason === WebInspector.DebuggerModel.BreakReason.EventListener) { |
| + var eventName = details.auxData["eventName"]; |
| + var eventNameForUI = WebInspector.EventListenerBreakpointsSidebarPane.eventNameForUI(eventName, details.auxData); |
| + messageWrapper = buildWrapper(WebInspector.UIString("Paused on event listener"), eventNameForUI); |
| + } else if (details.reason === WebInspector.DebuggerModel.BreakReason.XHR) { |
| + messageWrapper = buildWrapper(WebInspector.UIString("Paused on XMLHttpRequest"), details.auxData["url"] || ""); |
| + } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Exception) { |
| + var description = details.auxData["description"] || details.auxData["value"] || ""; |
| + var descriptionFirstLine = description.split("\n", 1)[0]; |
| + messageWrapper = buildWrapper(WebInspector.UIString("Paused on exception"), descriptionFirstLine, description); |
| + } else if (details.reason === WebInspector.DebuggerModel.BreakReason.PromiseRejection) { |
| + var description = details.auxData["description"] || details.auxData["value"] || ""; |
| + var descriptionFirstLine = description.split("\n", 1)[0]; |
| + messageWrapper = buildWrapper(WebInspector.UIString("Paused on promise rejection"), descriptionFirstLine, description); |
| + } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Assert) { |
| + messageWrapper = buildWrapper(WebInspector.UIString("Paused on assertion")); |
| + } else if (details.reason === WebInspector.DebuggerModel.BreakReason.DebugCommand) { |
| + messageWrapper = buildWrapper(WebInspector.UIString("Paused on debugged function")); |
| + } else if (details.callFrames.length) { |
| + var uiLocation = WebInspector.debuggerWorkspaceBinding.rawLocationToUILocation(details.callFrames[0].location()); |
| + var breakpoint = uiLocation ? WebInspector.breakpointManager.findBreakpointOnLine(uiLocation.uiSourceCode, uiLocation.lineNumber) : null; |
| + var defaultText = breakpoint ? WebInspector.UIString("Paused on breakpoint") : WebInspector.UIString("Debugger paused"); |
| + messageWrapper = buildWrapper(defaultText); |
| + } else { |
| + console.warn("ScriptsPanel paused, but callFrames.length is zero."); // TODO remove this once we understand this case better |
| + } |
| + |
| + var errorLike = details.reason === WebInspector.DebuggerModel.BreakReason.Exception || details.reason === WebInspector.DebuggerModel.BreakReason.PromiseRejection || details.reason === WebInspector.DebuggerModel.BreakReason.Assert; |
| + status.classList.toggle("error-reason", errorLike); |
| + if (messageWrapper) |
| + status.appendChild(messageWrapper); |
| + |
| + /** |
| + * @param {string} mainText |
| + * @param {string=} subText |
| + * @param {string=} title |
| + * @return {!Element} |
| + */ |
| + function buildWrapper(mainText, subText, title) |
| + { |
| + var messageWrapper = createElement("span"); |
| + var mainElement = messageWrapper.createChild("div", "status-main"); |
| + mainElement.textContent = mainText; |
| + if (subText) { |
| + var subElement = messageWrapper.createChild("div", "status-sub"); |
| + subElement.textContent = subText; |
| + } |
| + if (title) |
| + messageWrapper.title = title; |
| + return messageWrapper; |
| + } |
| + }, |
| + |
| + __proto__: WebInspector.VBox.prototype |
| +} |