| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 WebInspector.DebuggerPausedMessage = class { | 7 Sources.DebuggerPausedMessage = class { |
| 8 constructor() { | 8 constructor() { |
| 9 this._element = createElementWithClass('div', 'paused-message flex-none'); | 9 this._element = createElementWithClass('div', 'paused-message flex-none'); |
| 10 var root = WebInspector.createShadowRootWithCoreStyles(this._element, 'sourc
es/debuggerPausedMessage.css'); | 10 var root = UI.createShadowRootWithCoreStyles(this._element, 'sources/debugge
rPausedMessage.css'); |
| 11 this._contentElement = root.createChild('div', 'paused-status'); | 11 this._contentElement = root.createChild('div', 'paused-status'); |
| 12 } | 12 } |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * @return {!Element} | 15 * @return {!Element} |
| 16 */ | 16 */ |
| 17 element() { | 17 element() { |
| 18 return this._element; | 18 return this._element; |
| 19 } | 19 } |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * @param {?WebInspector.DebuggerPausedDetails} details | 22 * @param {?SDK.DebuggerPausedDetails} details |
| 23 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding | 23 * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding |
| 24 * @param {!WebInspector.BreakpointManager} breakpointManager | 24 * @param {!Bindings.BreakpointManager} breakpointManager |
| 25 */ | 25 */ |
| 26 render(details, debuggerWorkspaceBinding, breakpointManager) { | 26 render(details, debuggerWorkspaceBinding, breakpointManager) { |
| 27 var status = this._contentElement; | 27 var status = this._contentElement; |
| 28 status.hidden = !details; | 28 status.hidden = !details; |
| 29 status.removeChildren(); | 29 status.removeChildren(); |
| 30 if (!details) | 30 if (!details) |
| 31 return; | 31 return; |
| 32 | 32 |
| 33 var messageWrapper; | 33 var messageWrapper; |
| 34 if (details.reason === WebInspector.DebuggerModel.BreakReason.DOM) { | 34 if (details.reason === SDK.DebuggerModel.BreakReason.DOM) { |
| 35 messageWrapper = WebInspector.DOMBreakpointsSidebarPane.createBreakpointHi
tMessage(details); | 35 messageWrapper = Components.DOMBreakpointsSidebarPane.createBreakpointHitM
essage(details); |
| 36 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.EventLi
stener) { | 36 } else if (details.reason === SDK.DebuggerModel.BreakReason.EventListener) { |
| 37 var eventName = details.auxData['eventName']; | 37 var eventName = details.auxData['eventName']; |
| 38 var eventNameForUI = WebInspector.EventListenerBreakpointsSidebarPane.even
tNameForUI(eventName, details.auxData); | 38 var eventNameForUI = Sources.EventListenerBreakpointsSidebarPane.eventName
ForUI(eventName, details.auxData); |
| 39 messageWrapper = buildWrapper(WebInspector.UIString('Paused on event liste
ner'), eventNameForUI); | 39 messageWrapper = buildWrapper(Common.UIString('Paused on event listener'),
eventNameForUI); |
| 40 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.XHR) { | 40 } else if (details.reason === SDK.DebuggerModel.BreakReason.XHR) { |
| 41 messageWrapper = buildWrapper(WebInspector.UIString('Paused on XMLHttpRequ
est'), details.auxData['url'] || ''); | 41 messageWrapper = buildWrapper(Common.UIString('Paused on XMLHttpRequest'),
details.auxData['url'] || ''); |
| 42 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Excepti
on) { | 42 } else if (details.reason === SDK.DebuggerModel.BreakReason.Exception) { |
| 43 var description = details.auxData['description'] || details.auxData['value
'] || ''; | 43 var description = details.auxData['description'] || details.auxData['value
'] || ''; |
| 44 var descriptionFirstLine = description.split('\n', 1)[0]; | 44 var descriptionFirstLine = description.split('\n', 1)[0]; |
| 45 messageWrapper = buildWrapper(WebInspector.UIString('Paused on exception')
, descriptionFirstLine, description); | 45 messageWrapper = buildWrapper(Common.UIString('Paused on exception'), desc
riptionFirstLine, description); |
| 46 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Promise
Rejection) { | 46 } else if (details.reason === SDK.DebuggerModel.BreakReason.PromiseRejection
) { |
| 47 var description = details.auxData['description'] || details.auxData['value
'] || ''; | 47 var description = details.auxData['description'] || details.auxData['value
'] || ''; |
| 48 var descriptionFirstLine = description.split('\n', 1)[0]; | 48 var descriptionFirstLine = description.split('\n', 1)[0]; |
| 49 messageWrapper = | 49 messageWrapper = |
| 50 buildWrapper(WebInspector.UIString('Paused on promise rejection'), des
criptionFirstLine, description); | 50 buildWrapper(Common.UIString('Paused on promise rejection'), descripti
onFirstLine, description); |
| 51 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Assert)
{ | 51 } else if (details.reason === SDK.DebuggerModel.BreakReason.Assert) { |
| 52 messageWrapper = buildWrapper(WebInspector.UIString('Paused on assertion')
); | 52 messageWrapper = buildWrapper(Common.UIString('Paused on assertion')); |
| 53 } else if (details.reason === WebInspector.DebuggerModel.BreakReason.DebugCo
mmand) { | 53 } else if (details.reason === SDK.DebuggerModel.BreakReason.DebugCommand) { |
| 54 messageWrapper = buildWrapper(WebInspector.UIString('Paused on debugged fu
nction')); | 54 messageWrapper = buildWrapper(Common.UIString('Paused on debugged function
')); |
| 55 } else if (details.callFrames.length) { | 55 } else if (details.callFrames.length) { |
| 56 var uiLocation = debuggerWorkspaceBinding.rawLocationToUILocation(details.
callFrames[0].location()); | 56 var uiLocation = debuggerWorkspaceBinding.rawLocationToUILocation(details.
callFrames[0].location()); |
| 57 var breakpoint = | 57 var breakpoint = |
| 58 uiLocation ? breakpointManager.findBreakpoint( | 58 uiLocation ? breakpointManager.findBreakpoint( |
| 59 uiLocation.uiSourceCode, uiLocation.lineNumber, uiLocation.columnN
umber) : null; | 59 uiLocation.uiSourceCode, uiLocation.lineNumber, uiLocation.columnN
umber) : null; |
| 60 var defaultText = | 60 var defaultText = |
| 61 breakpoint ? WebInspector.UIString('Paused on breakpoint') : WebInspec
tor.UIString('Debugger paused'); | 61 breakpoint ? Common.UIString('Paused on breakpoint') : Common.UIString
('Debugger paused'); |
| 62 messageWrapper = buildWrapper(defaultText); | 62 messageWrapper = buildWrapper(defaultText); |
| 63 } else { | 63 } else { |
| 64 console.warn( | 64 console.warn( |
| 65 'ScriptsPanel paused, but callFrames.length is zero.'); // TODO remov
e this once we understand this case better | 65 'ScriptsPanel paused, but callFrames.length is zero.'); // TODO remov
e this once we understand this case better |
| 66 } | 66 } |
| 67 | 67 |
| 68 var errorLike = details.reason === WebInspector.DebuggerModel.BreakReason.Ex
ception || | 68 var errorLike = details.reason === SDK.DebuggerModel.BreakReason.Exception |
| |
| 69 details.reason === WebInspector.DebuggerModel.BreakReason.PromiseRejecti
on || | 69 details.reason === SDK.DebuggerModel.BreakReason.PromiseRejection || |
| 70 details.reason === WebInspector.DebuggerModel.BreakReason.Assert; | 70 details.reason === SDK.DebuggerModel.BreakReason.Assert; |
| 71 status.classList.toggle('error-reason', errorLike); | 71 status.classList.toggle('error-reason', errorLike); |
| 72 if (messageWrapper) | 72 if (messageWrapper) |
| 73 status.appendChild(messageWrapper); | 73 status.appendChild(messageWrapper); |
| 74 | 74 |
| 75 /** | 75 /** |
| 76 * @param {string} mainText | 76 * @param {string} mainText |
| 77 * @param {string=} subText | 77 * @param {string=} subText |
| 78 * @param {string=} title | 78 * @param {string=} title |
| 79 * @return {!Element} | 79 * @return {!Element} |
| 80 */ | 80 */ |
| 81 function buildWrapper(mainText, subText, title) { | 81 function buildWrapper(mainText, subText, title) { |
| 82 var messageWrapper = createElement('span'); | 82 var messageWrapper = createElement('span'); |
| 83 var mainElement = messageWrapper.createChild('div', 'status-main'); | 83 var mainElement = messageWrapper.createChild('div', 'status-main'); |
| 84 mainElement.appendChild(WebInspector.Icon.create('smallicon-info', 'status
-icon')); | 84 mainElement.appendChild(UI.Icon.create('smallicon-info', 'status-icon')); |
| 85 mainElement.appendChild(createTextNode(mainText)); | 85 mainElement.appendChild(createTextNode(mainText)); |
| 86 if (subText) { | 86 if (subText) { |
| 87 var subElement = messageWrapper.createChild('div', 'status-sub monospace
'); | 87 var subElement = messageWrapper.createChild('div', 'status-sub monospace
'); |
| 88 subElement.textContent = subText; | 88 subElement.textContent = subText; |
| 89 } | 89 } |
| 90 if (title) | 90 if (title) |
| 91 messageWrapper.title = title; | 91 messageWrapper.title = title; |
| 92 return messageWrapper; | 92 return messageWrapper; |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 }; | 95 }; |
| OLD | NEW |