Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/DebuggerPausedMessage.js

Issue 2389883003: DevTools: hoist debugger paused reason to top (Closed)
Patch Set: address comments; new widget Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 {WebInspector.VBox}
8 */
9 WebInspector.DebuggerPausedMessage = function()
10 {
11 WebInspector.VBox.call(this);
dgozman 2016/10/13 03:39:13 Please don't make something a widget if you just w
12 this.registerRequiredCSS("sources/debuggerPausedMessage.css");
13 this.contentElement = this.element.createChild("div", "paused-status");
14 this.element.className = "paused-container";
15 }
16
17 WebInspector.DebuggerPausedMessage.prototype = {
18 /**
19 * @param {?WebInspector.DebuggerPausedDetails} details
20 */
21 render: function(details)
22 {
23 var status = this.contentElement;
24 status.hidden = !details;
25 status.removeChildren();
26 if (!details)
27 return;
28
29 var messageWrapper;
30 if (details.reason === WebInspector.DebuggerModel.BreakReason.DOM) {
31 messageWrapper = WebInspector.domBreakpointsSidebarPane.createBreakp ointHitMessage(details);
32 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Eve ntListener) {
33 var eventName = details.auxData["eventName"];
34 var eventNameForUI = WebInspector.EventListenerBreakpointsSidebarPan e.eventNameForUI(eventName, details.auxData);
35 messageWrapper = buildWrapper(WebInspector.UIString("Paused on event listener"), eventNameForUI);
36 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.XHR ) {
37 messageWrapper = buildWrapper(WebInspector.UIString("Paused on XMLHt tpRequest"), details.auxData["url"] || "");
38 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Exc eption) {
39 var description = details.auxData["description"] || details.auxData[ "value"] || "";
40 var descriptionFirstLine = description.split("\n", 1)[0];
41 messageWrapper = buildWrapper(WebInspector.UIString("Paused on excep tion"), descriptionFirstLine, description);
42 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Pro miseRejection) {
43 var description = details.auxData["description"] || details.auxData[ "value"] || "";
44 var descriptionFirstLine = description.split("\n", 1)[0];
45 messageWrapper = buildWrapper(WebInspector.UIString("Paused on promi se rejection"), descriptionFirstLine, description);
46 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Ass ert) {
47 messageWrapper = buildWrapper(WebInspector.UIString("Paused on asser tion"));
48 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Deb ugCommand) {
49 messageWrapper = buildWrapper(WebInspector.UIString("Paused on debug ged function"));
50 } else if (details.callFrames.length) {
51 var uiLocation = WebInspector.debuggerWorkspaceBinding.rawLocationTo UILocation(details.callFrames[0].location());
52 var breakpoint = uiLocation ? WebInspector.breakpointManager.findBre akpointOnLine(uiLocation.uiSourceCode, uiLocation.lineNumber) : null;
53 var defaultText = breakpoint ? WebInspector.UIString("Paused on brea kpoint") : WebInspector.UIString("Debugger paused");
54 messageWrapper = buildWrapper(defaultText);
55 } else {
56 console.warn("ScriptsPanel paused, but callFrames.length is zero."); // TODO remove this once we understand this case better
57 }
58
59 var errorLike = details.reason === WebInspector.DebuggerModel.BreakReaso n.Exception || details.reason === WebInspector.DebuggerModel.BreakReason.Promise Rejection || details.reason === WebInspector.DebuggerModel.BreakReason.Assert;
60 status.classList.toggle("error-reason", errorLike);
61 if (messageWrapper)
62 status.appendChild(messageWrapper);
63
64 /**
65 * @param {string} mainText
66 * @param {string=} subText
67 * @param {string=} title
68 * @return {!Element}
69 */
70 function buildWrapper(mainText, subText, title)
71 {
72 var messageWrapper = createElement("span");
73 var mainElement = messageWrapper.createChild("div", "status-main");
74 mainElement.textContent = mainText;
75 if (subText) {
76 var subElement = messageWrapper.createChild("div", "status-sub") ;
77 subElement.textContent = subText;
78 }
79 if (title)
80 messageWrapper.title = title;
81 return messageWrapper;
82 }
83 },
84
85 __proto__: WebInspector.VBox.prototype
86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698