OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). | 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). |
4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
11 * notice, this list of conditions and the following disclaimer. | 11 * notice, this list of conditions and the following disclaimer. |
12 * 2. Redistributions in binary form must reproduce the above copyright | 12 * 2. Redistributions in binary form must reproduce the above copyright |
13 * notice, this list of conditions and the following disclaimer in the | 13 * notice, this list of conditions and the following disclaimer in the |
14 * documentation and/or other materials provided with the distribution. | 14 * documentation and/or other materials provided with the distribution. |
15 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | 15 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
16 * its contributors may be used to endorse or promote products derived | 16 * its contributors may be used to endorse or promote products derived |
17 * from this software without specific prior written permission. | 17 * from this software without specific prior written permission. |
18 * | 18 * |
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 /** |
31 /** | 31 * @unrestricted |
32 * @constructor | 32 */ |
33 * @suppressGlobalPropertiesCheck | 33 WebInspector.Main = class { |
34 */ | 34 /** |
35 WebInspector.Main = function() | 35 * @suppressGlobalPropertiesCheck |
36 { | 36 */ |
| 37 constructor() { |
37 WebInspector.Main._instanceForTest = this; | 38 WebInspector.Main._instanceForTest = this; |
38 runOnWindowLoad(this._loaded.bind(this)); | 39 runOnWindowLoad(this._loaded.bind(this)); |
39 }; | 40 } |
40 | 41 |
41 WebInspector.Main.prototype = { | 42 /** |
42 _loaded: function() | 43 * @param {boolean} hard |
43 { | 44 */ |
44 console.timeStamp("Main._loaded"); | 45 static _reloadPage(hard) { |
45 | 46 var mainTarget = WebInspector.targetManager.mainTarget(); |
46 if (InspectorFrontendHost.isUnderTest()) | 47 if (mainTarget && mainTarget.hasBrowserCapability()) |
47 self.runtime.useTestBase(); | 48 WebInspector.targetManager.reloadPage(hard); |
48 Runtime.setPlatform(WebInspector.platform()); | 49 } |
49 InspectorFrontendHost.getPreferences(this._gotPreferences.bind(this)); | 50 |
50 }, | 51 _loaded() { |
| 52 console.timeStamp('Main._loaded'); |
| 53 |
| 54 if (InspectorFrontendHost.isUnderTest()) |
| 55 self.runtime.useTestBase(); |
| 56 Runtime.setPlatform(WebInspector.platform()); |
| 57 InspectorFrontendHost.getPreferences(this._gotPreferences.bind(this)); |
| 58 } |
| 59 |
| 60 /** |
| 61 * @param {!Object<string, string>} prefs |
| 62 */ |
| 63 _gotPreferences(prefs) { |
| 64 console.timeStamp('Main._gotPreferences'); |
| 65 this._createSettings(prefs); |
| 66 this._createAppUI(); |
| 67 } |
| 68 |
| 69 /** |
| 70 * @param {!Object<string, string>} prefs |
| 71 * Note: this function is called from testSettings in Tests.js. |
| 72 */ |
| 73 _createSettings(prefs) { |
| 74 this._initializeExperiments(prefs); |
| 75 WebInspector.settings = new WebInspector.Settings(new WebInspector.SettingsS
torage( |
| 76 prefs, InspectorFrontendHost.setPreference, InspectorFrontendHost.remove
Preference, |
| 77 InspectorFrontendHost.clearPreferences)); |
| 78 |
| 79 if (!InspectorFrontendHost.isUnderTest()) |
| 80 new WebInspector.VersionController().updateVersion(); |
| 81 } |
| 82 |
| 83 /** |
| 84 * @param {!Object<string, string>} prefs |
| 85 */ |
| 86 _initializeExperiments(prefs) { |
| 87 Runtime.experiments.register('accessibilityInspection', 'Accessibility Inspe
ction'); |
| 88 Runtime.experiments.register('applyCustomStylesheet', 'Allow custom UI theme
s'); |
| 89 Runtime.experiments.register('audits2', 'Audits 2.0', true); |
| 90 Runtime.experiments.register('autoAttachToCrossProcessSubframes', 'Auto-atta
ch to cross-process subframes', true); |
| 91 Runtime.experiments.register('blackboxJSFramesOnTimeline', 'Blackbox JavaScr
ipt frames on Timeline', true); |
| 92 Runtime.experiments.register('canvasNetworkTimeline', 'Canvas based timeline
in Network panel', true); |
| 93 Runtime.experiments.register('colorContrastRatio', 'Contrast ratio line in c
olor picker', true); |
| 94 Runtime.experiments.register('continueToFirstInvocation', 'Continue to first
invocation', true); |
| 95 Runtime.experiments.register('emptySourceMapAutoStepping', 'Empty sourcemap
auto-stepping'); |
| 96 Runtime.experiments.register('inputEventsOnTimelineOverview', 'Input events
on Timeline overview', true); |
| 97 Runtime.experiments.register('layersPanel', 'Layers panel'); |
| 98 Runtime.experiments.register('layoutEditor', 'Layout editor', true); |
| 99 Runtime.experiments.register('inspectTooltip', 'Dark inspect element tooltip
'); |
| 100 Runtime.experiments.register('liveSASS', 'Live SASS'); |
| 101 Runtime.experiments.register('nodeDebugging', 'Node debugging', true); |
| 102 Runtime.experiments.register('persistence2', 'Persistence 2.0', true); |
| 103 Runtime.experiments.register('privateScriptInspection', 'Private script insp
ection'); |
| 104 Runtime.experiments.register('requestBlocking', 'Request blocking', true); |
| 105 Runtime.experiments.register('resolveVariableNames', 'Resolve variable names
'); |
| 106 Runtime.experiments.register('timelineShowAllEvents', 'Show all events on Ti
meline', true); |
| 107 Runtime.experiments.register('timelineShowAllProcesses', 'Show all processes
on Timeline', true); |
| 108 Runtime.experiments.register('securityPanel', 'Security panel'); |
| 109 Runtime.experiments.register('sourceDiff', 'Source diff'); |
| 110 Runtime.experiments.register('terminalInDrawer', 'Terminal in drawer', true)
; |
| 111 Runtime.experiments.register('timelineFlowEvents', 'Timeline flow events', t
rue); |
| 112 Runtime.experiments.register('timelineInvalidationTracking', 'Timeline inval
idation tracking', true); |
| 113 Runtime.experiments.register('timelineRecordingPerspectives', 'Timeline reco
rding perspectives UI'); |
| 114 Runtime.experiments.register('timelineTracingJSProfile', 'Timeline tracing b
ased JS profiler', true); |
| 115 Runtime.experiments.register('timelineV8RuntimeCallStats', 'V8 Runtime Call
Stats on Timeline', true); |
| 116 |
| 117 Runtime.experiments.cleanUpStaleExperiments(); |
| 118 |
| 119 if (InspectorFrontendHost.isUnderTest()) { |
| 120 var testPath = JSON.parse(prefs['testPath'] || '""'); |
| 121 // Enable experiments for testing. |
| 122 if (testPath.indexOf('layers/') !== -1) |
| 123 Runtime.experiments.enableForTest('layersPanel'); |
| 124 if (testPath.indexOf('timeline/') !== -1 || testPath.indexOf('layers/') !=
= -1) |
| 125 Runtime.experiments.enableForTest('layersPanel'); |
| 126 if (testPath.indexOf('security/') !== -1) |
| 127 Runtime.experiments.enableForTest('securityPanel'); |
| 128 if (testPath.indexOf('accessibility/') !== -1) |
| 129 Runtime.experiments.enableForTest('accessibilityInspection'); |
| 130 } |
| 131 |
| 132 Runtime.experiments.setDefaultExperiments(['inspectTooltip', 'securityPanel'
, 'resolveVariableNames']); |
| 133 } |
| 134 |
| 135 /** |
| 136 * @suppressGlobalPropertiesCheck |
| 137 */ |
| 138 _createAppUI() { |
| 139 console.time('Main._createAppUI'); |
| 140 |
| 141 WebInspector.viewManager = new WebInspector.ViewManager(); |
| 142 |
| 143 // Request filesystems early, we won't create connections until callback is
fired. Things will happen in parallel. |
| 144 WebInspector.isolatedFileSystemManager = new WebInspector.IsolatedFileSystem
Manager(); |
| 145 |
| 146 var themeSetting = WebInspector.settings.createSetting('uiTheme', 'default')
; |
| 147 WebInspector.initializeUIUtils(document, themeSetting); |
| 148 themeSetting.addChangeListener(WebInspector.reload.bind(WebInspector)); |
| 149 |
| 150 WebInspector.installComponentRootStyles(/** @type {!Element} */ (document.bo
dy)); |
| 151 |
| 152 this._addMainEventListeners(document); |
| 153 |
| 154 var canDock = !!Runtime.queryParam('can_dock'); |
| 155 WebInspector.zoomManager = new WebInspector.ZoomManager(window, InspectorFro
ntendHost); |
| 156 WebInspector.inspectorView = WebInspector.InspectorView.instance(); |
| 157 WebInspector.ContextMenu.initialize(); |
| 158 WebInspector.ContextMenu.installHandler(document); |
| 159 WebInspector.Tooltip.installHandler(document); |
| 160 WebInspector.dockController = new WebInspector.DockController(canDock); |
| 161 WebInspector.multitargetConsoleModel = new WebInspector.MultitargetConsoleMo
del(); |
| 162 WebInspector.multitargetNetworkManager = new WebInspector.MultitargetNetwork
Manager(); |
| 163 WebInspector.targetManager.addEventListener( |
| 164 WebInspector.TargetManager.Events.SuspendStateChanged, this._onSuspendSt
ateChanged.bind(this)); |
| 165 |
| 166 WebInspector.shortcutsScreen = new WebInspector.ShortcutsScreen(); |
| 167 // set order of some sections explicitly |
| 168 WebInspector.shortcutsScreen.section(WebInspector.UIString('Elements Panel')
); |
| 169 WebInspector.shortcutsScreen.section(WebInspector.UIString('Styles Pane')); |
| 170 WebInspector.shortcutsScreen.section(WebInspector.UIString('Debugger')); |
| 171 WebInspector.shortcutsScreen.section(WebInspector.UIString('Console')); |
| 172 |
| 173 WebInspector.fileManager = new WebInspector.FileManager(); |
| 174 WebInspector.workspace = new WebInspector.Workspace(); |
| 175 WebInspector.formatterWorkerPool = new WebInspector.FormatterWorkerPool(); |
| 176 WebInspector.fileSystemMapping = new WebInspector.FileSystemMapping(); |
| 177 |
| 178 var fileSystemWorkspaceBinding = |
| 179 new WebInspector.FileSystemWorkspaceBinding(WebInspector.isolatedFileSys
temManager, WebInspector.workspace); |
| 180 WebInspector.networkMapping = new WebInspector.NetworkMapping( |
| 181 WebInspector.targetManager, WebInspector.workspace, fileSystemWorkspaceB
inding, WebInspector.fileSystemMapping); |
| 182 WebInspector.networkProjectManager = |
| 183 new WebInspector.NetworkProjectManager(WebInspector.targetManager, WebIn
spector.workspace); |
| 184 WebInspector.presentationConsoleMessageHelper = |
| 185 new WebInspector.PresentationConsoleMessageHelper(WebInspector.workspace
); |
| 186 WebInspector.cssWorkspaceBinding = new WebInspector.CSSWorkspaceBinding( |
| 187 WebInspector.targetManager, WebInspector.workspace, WebInspector.network
Mapping); |
| 188 WebInspector.debuggerWorkspaceBinding = new WebInspector.DebuggerWorkspaceBi
nding( |
| 189 WebInspector.targetManager, WebInspector.workspace, WebInspector.network
Mapping); |
| 190 WebInspector.breakpointManager = new WebInspector.BreakpointManager( |
| 191 null, WebInspector.workspace, WebInspector.targetManager, WebInspector.d
ebuggerWorkspaceBinding); |
| 192 WebInspector.extensionServer = new WebInspector.ExtensionServer(); |
| 193 |
| 194 WebInspector.persistence = new WebInspector.Persistence( |
| 195 WebInspector.workspace, WebInspector.breakpointManager, WebInspector.fil
eSystemMapping); |
| 196 |
| 197 new WebInspector.OverlayController(); |
| 198 new WebInspector.ExecutionContextSelector(WebInspector.targetManager, WebIns
pector.context); |
| 199 WebInspector.blackboxManager = new WebInspector.BlackboxManager(WebInspector
.debuggerWorkspaceBinding); |
| 200 |
| 201 var autoselectPanel = WebInspector.UIString('auto'); |
| 202 var openAnchorLocationSetting = WebInspector.settings.createSetting('openLin
kHandler', autoselectPanel); |
| 203 WebInspector.openAnchorLocationRegistry = new WebInspector.HandlerRegistry(o
penAnchorLocationSetting); |
| 204 WebInspector.openAnchorLocationRegistry.registerHandler(autoselectPanel, fun
ction() { |
| 205 return false; |
| 206 }); |
| 207 WebInspector.Linkifier.setLinkHandler(new WebInspector.HandlerRegistry.LinkH
andler()); |
| 208 |
| 209 new WebInspector.Main.PauseListener(); |
| 210 new WebInspector.Main.InspectedNodeRevealer(); |
| 211 new WebInspector.NetworkPanelIndicator(); |
| 212 new WebInspector.SourcesPanelIndicator(); |
| 213 new WebInspector.BackendSettingsSync(); |
| 214 WebInspector.domBreakpointsSidebarPane = new WebInspector.DOMBreakpointsSide
barPane(); |
| 215 |
| 216 WebInspector.actionRegistry = new WebInspector.ActionRegistry(); |
| 217 WebInspector.shortcutRegistry = new WebInspector.ShortcutRegistry(WebInspect
or.actionRegistry, document); |
| 218 WebInspector.ShortcutsScreen.registerShortcuts(); |
| 219 this._registerForwardedShortcuts(); |
| 220 this._registerMessageSinkListener(); |
| 221 new WebInspector.Main.InspectorDomainObserver(); |
| 222 |
| 223 self.runtime.extension(WebInspector.AppProvider).instance().then(this._showA
ppUI.bind(this)); |
| 224 console.timeEnd('Main._createAppUI'); |
| 225 } |
| 226 |
| 227 /** |
| 228 * @param {!Object} appProvider |
| 229 * @suppressGlobalPropertiesCheck |
| 230 */ |
| 231 _showAppUI(appProvider) { |
| 232 console.time('Main._showAppUI'); |
| 233 var app = /** @type {!WebInspector.AppProvider} */ (appProvider).createApp()
; |
| 234 // It is important to kick controller lifetime after apps are instantiated. |
| 235 WebInspector.dockController.initialize(); |
| 236 app.presentUI(document); |
| 237 |
| 238 var toggleSearchNodeAction = WebInspector.actionRegistry.action('elements.to
ggle-element-search'); |
| 239 // TODO: we should not access actions from other modules. |
| 240 if (toggleSearchNodeAction) |
| 241 InspectorFrontendHost.events.addEventListener( |
| 242 InspectorFrontendHostAPI.Events.EnterInspectElementMode, |
| 243 toggleSearchNodeAction.execute.bind(toggleSearchNodeAction), this); |
| 244 WebInspector.inspectorView.createToolbars(); |
| 245 InspectorFrontendHost.loadCompleted(); |
| 246 |
| 247 InspectorFrontendHost.events.addEventListener( |
| 248 InspectorFrontendHostAPI.Events.ReloadInspectedPage, this._reloadInspect
edPage, this); |
| 249 |
| 250 var extensions = self.runtime.extensions(WebInspector.QueryParamHandler); |
| 251 for (var extension of extensions) { |
| 252 var value = Runtime.queryParam(extension.descriptor()['name']); |
| 253 if (value !== null) |
| 254 extension.instance().then(handleQueryParam.bind(null, value)); |
| 255 } |
51 | 256 |
52 /** | 257 /** |
53 * @param {!Object<string, string>} prefs | 258 * @param {string} value |
| 259 * @param {!WebInspector.QueryParamHandler} handler |
54 */ | 260 */ |
55 _gotPreferences: function(prefs) | 261 function handleQueryParam(value, handler) { |
56 { | 262 handler.handleQueryParam(value); |
57 console.timeStamp("Main._gotPreferences"); | 263 } |
58 this._createSettings(prefs); | 264 |
59 this._createAppUI(); | 265 // Allow UI cycles to repaint prior to creating connection. |
60 }, | 266 setTimeout(this._initializeTarget.bind(this), 0); |
61 | 267 console.timeEnd('Main._showAppUI'); |
62 /** | 268 } |
63 * @param {!Object<string, string>} prefs | 269 |
64 * Note: this function is called from testSettings in Tests.js. | 270 _initializeTarget() { |
65 */ | 271 console.time('Main._initializeTarget'); |
66 _createSettings: function(prefs) | 272 WebInspector.targetManager.connectToMainTarget(webSocketConnectionLost); |
67 { | 273 |
68 this._initializeExperiments(prefs); | 274 InspectorFrontendHost.readyForTest(); |
69 WebInspector.settings = new WebInspector.Settings(new WebInspector.Setti
ngsStorage(prefs, | 275 // Asynchronously run the extensions. |
70 InspectorFrontendHost.setPreference, InspectorFrontendHost.removePre
ference, InspectorFrontendHost.clearPreferences)); | 276 setTimeout(this._lateInitialization.bind(this), 100); |
71 | 277 console.timeEnd('Main._initializeTarget'); |
72 if (!InspectorFrontendHost.isUnderTest()) | 278 |
73 new WebInspector.VersionController().updateVersion(); | 279 function webSocketConnectionLost() { |
74 }, | 280 if (!WebInspector._disconnectedScreenWithReasonWasShown) |
75 | 281 WebInspector.RemoteDebuggingTerminatedScreen.show('WebSocket disconnecte
d'); |
76 /** | 282 } |
77 * @param {!Object<string, string>} prefs | 283 } |
78 */ | 284 |
79 _initializeExperiments: function(prefs) | 285 _lateInitialization() { |
80 { | 286 console.timeStamp('Main._lateInitialization'); |
81 Runtime.experiments.register("accessibilityInspection", "Accessibility I
nspection"); | 287 this._registerShortcuts(); |
82 Runtime.experiments.register("applyCustomStylesheet", "Allow custom UI t
hemes"); | 288 WebInspector.extensionServer.initializeExtensions(); |
83 Runtime.experiments.register("audits2", "Audits 2.0", true); | 289 } |
84 Runtime.experiments.register("autoAttachToCrossProcessSubframes", "Auto-
attach to cross-process subframes", true); | 290 |
85 Runtime.experiments.register("blackboxJSFramesOnTimeline", "Blackbox Jav
aScript frames on Timeline", true); | 291 _registerForwardedShortcuts() { |
86 Runtime.experiments.register("canvasNetworkTimeline", "Canvas based time
line in Network panel", true); | 292 /** @const */ var forwardedActions = |
87 Runtime.experiments.register("colorContrastRatio", "Contrast ratio line
in color picker", true); | 293 ['main.toggle-dock', 'debugger.toggle-breakpoints-active', 'debugger.tog
gle-pause', 'commandMenu.show']; |
88 Runtime.experiments.register("continueToFirstInvocation", "Continue to f
irst invocation", true); | 294 var actionKeys = WebInspector.shortcutRegistry.keysForActions(forwardedActio
ns) |
89 Runtime.experiments.register("emptySourceMapAutoStepping", "Empty source
map auto-stepping"); | 295 .map(WebInspector.KeyboardShortcut.keyCodeAndModifiersF
romKey); |
90 Runtime.experiments.register("inputEventsOnTimelineOverview", "Input eve
nts on Timeline overview", true); | 296 InspectorFrontendHost.setWhitelistedShortcuts(JSON.stringify(actionKeys)); |
91 Runtime.experiments.register("layersPanel", "Layers panel"); | 297 } |
92 Runtime.experiments.register("layoutEditor", "Layout editor", true); | 298 |
93 Runtime.experiments.register("inspectTooltip", "Dark inspect element too
ltip"); | 299 _registerMessageSinkListener() { |
94 Runtime.experiments.register("liveSASS", "Live SASS"); | 300 WebInspector.console.addEventListener(WebInspector.Console.Events.MessageAdd
ed, messageAdded); |
95 Runtime.experiments.register("nodeDebugging", "Node debugging", true); | |
96 Runtime.experiments.register("persistence2", "Persistence 2.0", true); | |
97 Runtime.experiments.register("privateScriptInspection", "Private script
inspection"); | |
98 Runtime.experiments.register("requestBlocking", "Request blocking", true
); | |
99 Runtime.experiments.register("resolveVariableNames", "Resolve variable n
ames"); | |
100 Runtime.experiments.register("timelineShowAllEvents", "Show all events o
n Timeline", true); | |
101 Runtime.experiments.register("timelineShowAllProcesses", "Show all proce
sses on Timeline", true); | |
102 Runtime.experiments.register("securityPanel", "Security panel"); | |
103 Runtime.experiments.register("sourceDiff", "Source diff"); | |
104 Runtime.experiments.register("terminalInDrawer", "Terminal in drawer", t
rue); | |
105 Runtime.experiments.register("timelineFlowEvents", "Timeline flow events
", true); | |
106 Runtime.experiments.register("timelineInvalidationTracking", "Timeline i
nvalidation tracking", true); | |
107 Runtime.experiments.register("timelineRecordingPerspectives", "Timeline
recording perspectives UI"); | |
108 Runtime.experiments.register("timelineTracingJSProfile", "Timeline traci
ng based JS profiler", true); | |
109 Runtime.experiments.register("timelineV8RuntimeCallStats", "V8 Runtime C
all Stats on Timeline", true); | |
110 | |
111 Runtime.experiments.cleanUpStaleExperiments(); | |
112 | |
113 if (InspectorFrontendHost.isUnderTest()) { | |
114 var testPath = JSON.parse(prefs["testPath"] || "\"\""); | |
115 // Enable experiments for testing. | |
116 if (testPath.indexOf("layers/") !== -1) | |
117 Runtime.experiments.enableForTest("layersPanel"); | |
118 if (testPath.indexOf("timeline/") !== -1 || testPath.indexOf("layers
/") !== -1) | |
119 Runtime.experiments.enableForTest("layersPanel"); | |
120 if (testPath.indexOf("security/") !== -1) | |
121 Runtime.experiments.enableForTest("securityPanel"); | |
122 if (testPath.indexOf("accessibility/") !== -1) | |
123 Runtime.experiments.enableForTest("accessibilityInspection"); | |
124 } | |
125 | |
126 Runtime.experiments.setDefaultExperiments([ | |
127 "inspectTooltip", | |
128 "securityPanel", | |
129 "resolveVariableNames" | |
130 ]); | |
131 }, | |
132 | |
133 /** | |
134 * @suppressGlobalPropertiesCheck | |
135 */ | |
136 _createAppUI: function() | |
137 { | |
138 console.time("Main._createAppUI"); | |
139 | |
140 WebInspector.viewManager = new WebInspector.ViewManager(); | |
141 | |
142 // Request filesystems early, we won't create connections until callback
is fired. Things will happen in parallel. | |
143 WebInspector.isolatedFileSystemManager = new WebInspector.IsolatedFileSy
stemManager(); | |
144 | |
145 var themeSetting = WebInspector.settings.createSetting("uiTheme", "defau
lt"); | |
146 WebInspector.initializeUIUtils(document, themeSetting); | |
147 themeSetting.addChangeListener(WebInspector.reload.bind(WebInspector)); | |
148 | |
149 WebInspector.installComponentRootStyles(/** @type {!Element} */ (documen
t.body)); | |
150 | |
151 this._addMainEventListeners(document); | |
152 | |
153 var canDock = !!Runtime.queryParam("can_dock"); | |
154 WebInspector.zoomManager = new WebInspector.ZoomManager(window, Inspecto
rFrontendHost); | |
155 WebInspector.inspectorView = WebInspector.InspectorView.instance(); | |
156 WebInspector.ContextMenu.initialize(); | |
157 WebInspector.ContextMenu.installHandler(document); | |
158 WebInspector.Tooltip.installHandler(document); | |
159 WebInspector.dockController = new WebInspector.DockController(canDock); | |
160 WebInspector.multitargetConsoleModel = new WebInspector.MultitargetConso
leModel(); | |
161 WebInspector.multitargetNetworkManager = new WebInspector.MultitargetNet
workManager(); | |
162 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.E
vents.SuspendStateChanged, this._onSuspendStateChanged.bind(this)); | |
163 | |
164 WebInspector.shortcutsScreen = new WebInspector.ShortcutsScreen(); | |
165 // set order of some sections explicitly | |
166 WebInspector.shortcutsScreen.section(WebInspector.UIString("Elements Pan
el")); | |
167 WebInspector.shortcutsScreen.section(WebInspector.UIString("Styles Pane"
)); | |
168 WebInspector.shortcutsScreen.section(WebInspector.UIString("Debugger")); | |
169 WebInspector.shortcutsScreen.section(WebInspector.UIString("Console")); | |
170 | |
171 WebInspector.fileManager = new WebInspector.FileManager(); | |
172 WebInspector.workspace = new WebInspector.Workspace(); | |
173 WebInspector.formatterWorkerPool = new WebInspector.FormatterWorkerPool(
); | |
174 WebInspector.fileSystemMapping = new WebInspector.FileSystemMapping(); | |
175 | |
176 var fileSystemWorkspaceBinding = new WebInspector.FileSystemWorkspaceBin
ding(WebInspector.isolatedFileSystemManager, WebInspector.workspace); | |
177 WebInspector.networkMapping = new WebInspector.NetworkMapping(WebInspect
or.targetManager, WebInspector.workspace, fileSystemWorkspaceBinding, WebInspect
or.fileSystemMapping); | |
178 WebInspector.networkProjectManager = new WebInspector.NetworkProjectMana
ger(WebInspector.targetManager, WebInspector.workspace); | |
179 WebInspector.presentationConsoleMessageHelper = new WebInspector.Present
ationConsoleMessageHelper(WebInspector.workspace); | |
180 WebInspector.cssWorkspaceBinding = new WebInspector.CSSWorkspaceBinding(
WebInspector.targetManager, WebInspector.workspace, WebInspector.networkMapping)
; | |
181 WebInspector.debuggerWorkspaceBinding = new WebInspector.DebuggerWorkspa
ceBinding(WebInspector.targetManager, WebInspector.workspace, WebInspector.netwo
rkMapping); | |
182 WebInspector.breakpointManager = new WebInspector.BreakpointManager(null
, WebInspector.workspace, WebInspector.targetManager, WebInspector.debuggerWorks
paceBinding); | |
183 WebInspector.extensionServer = new WebInspector.ExtensionServer(); | |
184 | |
185 WebInspector.persistence = new WebInspector.Persistence(WebInspector.wor
kspace, WebInspector.breakpointManager, WebInspector.fileSystemMapping); | |
186 | |
187 new WebInspector.OverlayController(); | |
188 new WebInspector.ExecutionContextSelector(WebInspector.targetManager, We
bInspector.context); | |
189 WebInspector.blackboxManager = new WebInspector.BlackboxManager(WebInspe
ctor.debuggerWorkspaceBinding); | |
190 | |
191 var autoselectPanel = WebInspector.UIString("auto"); | |
192 var openAnchorLocationSetting = WebInspector.settings.createSetting("ope
nLinkHandler", autoselectPanel); | |
193 WebInspector.openAnchorLocationRegistry = new WebInspector.HandlerRegist
ry(openAnchorLocationSetting); | |
194 WebInspector.openAnchorLocationRegistry.registerHandler(autoselectPanel,
function() { return false; }); | |
195 WebInspector.Linkifier.setLinkHandler(new WebInspector.HandlerRegistry.L
inkHandler()); | |
196 | |
197 new WebInspector.Main.PauseListener(); | |
198 new WebInspector.Main.InspectedNodeRevealer(); | |
199 new WebInspector.NetworkPanelIndicator(); | |
200 new WebInspector.SourcesPanelIndicator(); | |
201 new WebInspector.BackendSettingsSync(); | |
202 WebInspector.domBreakpointsSidebarPane = new WebInspector.DOMBreakpoints
SidebarPane(); | |
203 | |
204 WebInspector.actionRegistry = new WebInspector.ActionRegistry(); | |
205 WebInspector.shortcutRegistry = new WebInspector.ShortcutRegistry(WebIns
pector.actionRegistry, document); | |
206 WebInspector.ShortcutsScreen.registerShortcuts(); | |
207 this._registerForwardedShortcuts(); | |
208 this._registerMessageSinkListener(); | |
209 new WebInspector.Main.InspectorDomainObserver(); | |
210 | |
211 self.runtime.extension(WebInspector.AppProvider).instance().then(this._s
howAppUI.bind(this)); | |
212 console.timeEnd("Main._createAppUI"); | |
213 }, | |
214 | |
215 /** | |
216 * @param {!Object} appProvider | |
217 * @suppressGlobalPropertiesCheck | |
218 */ | |
219 _showAppUI: function(appProvider) | |
220 { | |
221 console.time("Main._showAppUI"); | |
222 var app = /** @type {!WebInspector.AppProvider} */ (appProvider).createA
pp(); | |
223 // It is important to kick controller lifetime after apps are instantiat
ed. | |
224 WebInspector.dockController.initialize(); | |
225 app.presentUI(document); | |
226 | |
227 var toggleSearchNodeAction = WebInspector.actionRegistry.action("element
s.toggle-element-search"); | |
228 // TODO: we should not access actions from other modules. | |
229 if (toggleSearchNodeAction) | |
230 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostA
PI.Events.EnterInspectElementMode, toggleSearchNodeAction.execute.bind(toggleSea
rchNodeAction), this); | |
231 WebInspector.inspectorView.createToolbars(); | |
232 InspectorFrontendHost.loadCompleted(); | |
233 | |
234 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.E
vents.ReloadInspectedPage, this._reloadInspectedPage, this); | |
235 | |
236 var extensions = self.runtime.extensions(WebInspector.QueryParamHandler)
; | |
237 for (var extension of extensions) { | |
238 var value = Runtime.queryParam(extension.descriptor()["name"]); | |
239 if (value !== null) | |
240 extension.instance().then(handleQueryParam.bind(null, value)); | |
241 } | |
242 | |
243 /** | |
244 * @param {string} value | |
245 * @param {!WebInspector.QueryParamHandler} handler | |
246 */ | |
247 function handleQueryParam(value, handler) | |
248 { | |
249 handler.handleQueryParam(value); | |
250 } | |
251 | |
252 // Allow UI cycles to repaint prior to creating connection. | |
253 setTimeout(this._initializeTarget.bind(this), 0); | |
254 console.timeEnd("Main._showAppUI"); | |
255 }, | |
256 | |
257 _initializeTarget: function() | |
258 { | |
259 console.time("Main._initializeTarget"); | |
260 WebInspector.targetManager.connectToMainTarget(webSocketConnectionLost); | |
261 | |
262 InspectorFrontendHost.readyForTest(); | |
263 // Asynchronously run the extensions. | |
264 setTimeout(this._lateInitialization.bind(this), 100); | |
265 console.timeEnd("Main._initializeTarget"); | |
266 | |
267 function webSocketConnectionLost() | |
268 { | |
269 if (!WebInspector._disconnectedScreenWithReasonWasShown) | |
270 WebInspector.RemoteDebuggingTerminatedScreen.show("WebSocket dis
connected"); | |
271 } | |
272 }, | |
273 | |
274 _lateInitialization: function() | |
275 { | |
276 console.timeStamp("Main._lateInitialization"); | |
277 this._registerShortcuts(); | |
278 WebInspector.extensionServer.initializeExtensions(); | |
279 }, | |
280 | |
281 _registerForwardedShortcuts: function() | |
282 { | |
283 /** @const */ var forwardedActions = ["main.toggle-dock", "debugger.togg
le-breakpoints-active", "debugger.toggle-pause", "commandMenu.show"]; | |
284 var actionKeys = WebInspector.shortcutRegistry.keysForActions(forwardedA
ctions).map(WebInspector.KeyboardShortcut.keyCodeAndModifiersFromKey); | |
285 InspectorFrontendHost.setWhitelistedShortcuts(JSON.stringify(actionKeys)
); | |
286 }, | |
287 | |
288 _registerMessageSinkListener: function() | |
289 { | |
290 WebInspector.console.addEventListener(WebInspector.Console.Events.Messag
eAdded, messageAdded); | |
291 | |
292 /** | |
293 * @param {!WebInspector.Event} event | |
294 */ | |
295 function messageAdded(event) | |
296 { | |
297 var message = /** @type {!WebInspector.Console.Message} */ (event.da
ta); | |
298 if (message.show) | |
299 WebInspector.console.show(); | |
300 } | |
301 }, | |
302 | |
303 _documentClick: function(event) | |
304 { | |
305 var target = event.target; | |
306 if (target.shadowRoot) | |
307 target = event.deepElementFromPoint(); | |
308 if (!target) | |
309 return; | |
310 | |
311 var anchor = target.enclosingNodeOrSelfWithNodeName("a"); | |
312 if (!anchor || !anchor.href) | |
313 return; | |
314 | |
315 // Prevent the link from navigating, since we don't do any navigation by
following links normally. | |
316 event.consume(true); | |
317 | |
318 if (anchor.preventFollow) | |
319 return; | |
320 | |
321 function followLink() | |
322 { | |
323 if (WebInspector.isBeingEdited(target)) | |
324 return; | |
325 if (WebInspector.openAnchorLocationRegistry.dispatch({ url: anchor.h
ref, lineNumber: anchor.lineNumber})) | |
326 return; | |
327 | |
328 var uiSourceCode = WebInspector.networkMapping.uiSourceCodeForURLFor
AnyTarget(anchor.href); | |
329 if (uiSourceCode) { | |
330 WebInspector.Revealer.reveal(uiSourceCode.uiLocation(anchor.line
Number || 0, anchor.columnNumber || 0)); | |
331 return; | |
332 } | |
333 | |
334 var resource = WebInspector.resourceForURL(anchor.href); | |
335 if (resource) { | |
336 WebInspector.Revealer.reveal(resource); | |
337 return; | |
338 } | |
339 | |
340 var request = WebInspector.NetworkLog.requestForURL(anchor.href); | |
341 if (request) { | |
342 WebInspector.Revealer.reveal(request); | |
343 return; | |
344 } | |
345 InspectorFrontendHost.openInNewTab(anchor.href); | |
346 } | |
347 | |
348 if (WebInspector.followLinkTimeout) | |
349 clearTimeout(WebInspector.followLinkTimeout); | |
350 | |
351 if (anchor.preventFollowOnDoubleClick) { | |
352 // Start a timeout if this is the first click, if the timeout is can
celed | |
353 // before it fires, then a double clicked happened or another link w
as clicked. | |
354 if (event.detail === 1) | |
355 WebInspector.followLinkTimeout = setTimeout(followLink, 333); | |
356 return; | |
357 } | |
358 | |
359 if (!anchor.classList.contains("webkit-html-external-link")) | |
360 followLink(); | |
361 else | |
362 InspectorFrontendHost.openInNewTab(anchor.href); | |
363 }, | |
364 | |
365 _registerShortcuts: function() | |
366 { | |
367 var shortcut = WebInspector.KeyboardShortcut; | |
368 var section = WebInspector.shortcutsScreen.section(WebInspector.UIString
("All Panels")); | |
369 var keys = [ | |
370 shortcut.makeDescriptor("[", shortcut.Modifiers.CtrlOrMeta), | |
371 shortcut.makeDescriptor("]", shortcut.Modifiers.CtrlOrMeta) | |
372 ]; | |
373 section.addRelatedKeys(keys, WebInspector.UIString("Go to the panel to t
he left/right")); | |
374 | |
375 keys = [ | |
376 shortcut.makeDescriptor("[", shortcut.Modifiers.CtrlOrMeta | shortcu
t.Modifiers.Alt), | |
377 shortcut.makeDescriptor("]", shortcut.Modifiers.CtrlOrMeta | shortcu
t.Modifiers.Alt) | |
378 ]; | |
379 section.addRelatedKeys(keys, WebInspector.UIString("Go back/forward in p
anel history")); | |
380 | |
381 var toggleConsoleLabel = WebInspector.UIString("Show console"); | |
382 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Tilde, shortcut.Mod
ifiers.Ctrl), toggleConsoleLabel); | |
383 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Esc), WebInspector.
UIString("Toggle drawer")); | |
384 if (WebInspector.dockController.canDock()) { | |
385 section.addKey(shortcut.makeDescriptor("M", shortcut.Modifiers.CtrlO
rMeta | shortcut.Modifiers.Shift), WebInspector.UIString("Toggle device mode")); | |
386 section.addKey(shortcut.makeDescriptor("D", shortcut.Modifiers.CtrlO
rMeta | shortcut.Modifiers.Shift), WebInspector.UIString("Toggle dock side")); | |
387 } | |
388 section.addKey(shortcut.makeDescriptor("f", shortcut.Modifiers.CtrlOrMet
a), WebInspector.UIString("Search")); | |
389 | |
390 var advancedSearchShortcutModifier = WebInspector.isMac() | |
391 ? WebInspector.KeyboardShortcut.Modifiers.Meta | WebInspector.Ke
yboardShortcut.Modifiers.Alt | |
392 : WebInspector.KeyboardShortcut.Modifiers.Ctrl | WebInspector.Ke
yboardShortcut.Modifiers.Shift; | |
393 var advancedSearchShortcut = shortcut.makeDescriptor("f", advancedSearch
ShortcutModifier); | |
394 section.addKey(advancedSearchShortcut, WebInspector.UIString("Search acr
oss all sources")); | |
395 | |
396 var inspectElementModeShortcuts = WebInspector.shortcutRegistry.shortcut
DescriptorsForAction("elements.toggle-element-search"); | |
397 if (inspectElementModeShortcuts.length) | |
398 section.addKey(inspectElementModeShortcuts[0], WebInspector.UIString
("Select node to inspect")); | |
399 | |
400 var openResourceShortcut = WebInspector.KeyboardShortcut.makeDescriptor(
"p", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta); | |
401 section.addKey(openResourceShortcut, WebInspector.UIString("Go to source
")); | |
402 | |
403 if (WebInspector.isMac()) { | |
404 keys = [ | |
405 shortcut.makeDescriptor("g", shortcut.Modifiers.Meta), | |
406 shortcut.makeDescriptor("g", shortcut.Modifiers.Meta | shortcut.
Modifiers.Shift) | |
407 ]; | |
408 section.addRelatedKeys(keys, WebInspector.UIString("Find next/previo
us")); | |
409 } | |
410 }, | |
411 | |
412 _postDocumentKeyDown: function(event) | |
413 { | |
414 if (event.handled) | |
415 return; | |
416 | |
417 var document = event.target && event.target.ownerDocument; | |
418 var target = document ? document.deepActiveElement() : null; | |
419 if (target) { | |
420 var anchor = target.enclosingNodeOrSelfWithNodeName("a"); | |
421 if (anchor && anchor.preventFollow) | |
422 event.preventDefault(); | |
423 } | |
424 | |
425 if (!WebInspector.Dialog.hasInstance() && WebInspector.inspectorView.cur
rentPanelDeprecated()) { | |
426 WebInspector.inspectorView.currentPanelDeprecated().handleShortcut(e
vent); | |
427 if (event.handled) { | |
428 event.consume(true); | |
429 return; | |
430 } | |
431 } | |
432 | |
433 WebInspector.shortcutRegistry.handleShortcut(event); | |
434 }, | |
435 | |
436 /** | |
437 * @param {!Event} event | |
438 */ | |
439 _redispatchClipboardEvent: function(event) | |
440 { | |
441 var eventCopy = new CustomEvent("clipboard-" + event.type); | |
442 eventCopy["original"] = event; | |
443 var document = event.target && event.target.ownerDocument; | |
444 var target = document ? document.deepActiveElement() : null; | |
445 if (target) | |
446 target.dispatchEvent(eventCopy); | |
447 if (eventCopy.handled) | |
448 event.preventDefault(); | |
449 }, | |
450 | |
451 _contextMenuEventFired: function(event) | |
452 { | |
453 if (event.handled || event.target.classList.contains("popup-glasspane")) | |
454 event.preventDefault(); | |
455 }, | |
456 | |
457 /** | |
458 * @param {!Document} document | |
459 */ | |
460 _addMainEventListeners: function(document) | |
461 { | |
462 document.addEventListener("keydown", this._postDocumentKeyDown.bind(this
), false); | |
463 document.addEventListener("beforecopy", this._redispatchClipboardEvent.b
ind(this), true); | |
464 document.addEventListener("copy", this._redispatchClipboardEvent.bind(th
is), false); | |
465 document.addEventListener("cut", this._redispatchClipboardEvent.bind(thi
s), false); | |
466 document.addEventListener("paste", this._redispatchClipboardEvent.bind(t
his), false); | |
467 document.addEventListener("contextmenu", this._contextMenuEventFired.bin
d(this), true); | |
468 document.addEventListener("click", this._documentClick.bind(this), false
); | |
469 }, | |
470 | 301 |
471 /** | 302 /** |
472 * @param {!WebInspector.Event} event | 303 * @param {!WebInspector.Event} event |
473 */ | 304 */ |
474 _reloadInspectedPage: function(event) | 305 function messageAdded(event) { |
475 { | 306 var message = /** @type {!WebInspector.Console.Message} */ (event.data); |
476 var hard = /** @type {boolean} */ (event.data); | 307 if (message.show) |
477 WebInspector.Main._reloadPage(hard); | 308 WebInspector.console.show(); |
478 }, | 309 } |
479 | 310 } |
480 _onSuspendStateChanged: function() | 311 |
481 { | 312 _documentClick(event) { |
482 var suspended = WebInspector.targetManager.allTargetsSuspended(); | 313 var target = event.target; |
483 WebInspector.inspectorView.onSuspendStateChanged(suspended); | 314 if (target.shadowRoot) |
484 } | 315 target = event.deepElementFromPoint(); |
485 }; | 316 if (!target) |
486 | 317 return; |
487 /** | 318 |
488 * @constructor | 319 var anchor = target.enclosingNodeOrSelfWithNodeName('a'); |
| 320 if (!anchor || !anchor.href) |
| 321 return; |
| 322 |
| 323 // Prevent the link from navigating, since we don't do any navigation by fol
lowing links normally. |
| 324 event.consume(true); |
| 325 |
| 326 if (anchor.preventFollow) |
| 327 return; |
| 328 |
| 329 function followLink() { |
| 330 if (WebInspector.isBeingEdited(target)) |
| 331 return; |
| 332 if (WebInspector.openAnchorLocationRegistry.dispatch({url: anchor.href, li
neNumber: anchor.lineNumber})) |
| 333 return; |
| 334 |
| 335 var uiSourceCode = WebInspector.networkMapping.uiSourceCodeForURLForAnyTar
get(anchor.href); |
| 336 if (uiSourceCode) { |
| 337 WebInspector.Revealer.reveal(uiSourceCode.uiLocation(anchor.lineNumber |
| 0, anchor.columnNumber || 0)); |
| 338 return; |
| 339 } |
| 340 |
| 341 var resource = WebInspector.resourceForURL(anchor.href); |
| 342 if (resource) { |
| 343 WebInspector.Revealer.reveal(resource); |
| 344 return; |
| 345 } |
| 346 |
| 347 var request = WebInspector.NetworkLog.requestForURL(anchor.href); |
| 348 if (request) { |
| 349 WebInspector.Revealer.reveal(request); |
| 350 return; |
| 351 } |
| 352 InspectorFrontendHost.openInNewTab(anchor.href); |
| 353 } |
| 354 |
| 355 if (WebInspector.followLinkTimeout) |
| 356 clearTimeout(WebInspector.followLinkTimeout); |
| 357 |
| 358 if (anchor.preventFollowOnDoubleClick) { |
| 359 // Start a timeout if this is the first click, if the timeout is canceled |
| 360 // before it fires, then a double clicked happened or another link was cli
cked. |
| 361 if (event.detail === 1) |
| 362 WebInspector.followLinkTimeout = setTimeout(followLink, 333); |
| 363 return; |
| 364 } |
| 365 |
| 366 if (!anchor.classList.contains('webkit-html-external-link')) |
| 367 followLink(); |
| 368 else |
| 369 InspectorFrontendHost.openInNewTab(anchor.href); |
| 370 } |
| 371 |
| 372 _registerShortcuts() { |
| 373 var shortcut = WebInspector.KeyboardShortcut; |
| 374 var section = WebInspector.shortcutsScreen.section(WebInspector.UIString('Al
l Panels')); |
| 375 var keys = [ |
| 376 shortcut.makeDescriptor('[', shortcut.Modifiers.CtrlOrMeta), |
| 377 shortcut.makeDescriptor(']', shortcut.Modifiers.CtrlOrMeta) |
| 378 ]; |
| 379 section.addRelatedKeys(keys, WebInspector.UIString('Go to the panel to the l
eft/right')); |
| 380 |
| 381 keys = [ |
| 382 shortcut.makeDescriptor('[', shortcut.Modifiers.CtrlOrMeta | shortcut.Modi
fiers.Alt), |
| 383 shortcut.makeDescriptor(']', shortcut.Modifiers.CtrlOrMeta | shortcut.Modi
fiers.Alt) |
| 384 ]; |
| 385 section.addRelatedKeys(keys, WebInspector.UIString('Go back/forward in panel
history')); |
| 386 |
| 387 var toggleConsoleLabel = WebInspector.UIString('Show console'); |
| 388 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Tilde, shortcut.Modifie
rs.Ctrl), toggleConsoleLabel); |
| 389 section.addKey(shortcut.makeDescriptor(shortcut.Keys.Esc), WebInspector.UISt
ring('Toggle drawer')); |
| 390 if (WebInspector.dockController.canDock()) { |
| 391 section.addKey( |
| 392 shortcut.makeDescriptor('M', shortcut.Modifiers.CtrlOrMeta | shortcut.
Modifiers.Shift), |
| 393 WebInspector.UIString('Toggle device mode')); |
| 394 section.addKey( |
| 395 shortcut.makeDescriptor('D', shortcut.Modifiers.CtrlOrMeta | shortcut.
Modifiers.Shift), |
| 396 WebInspector.UIString('Toggle dock side')); |
| 397 } |
| 398 section.addKey(shortcut.makeDescriptor('f', shortcut.Modifiers.CtrlOrMeta),
WebInspector.UIString('Search')); |
| 399 |
| 400 var advancedSearchShortcutModifier = WebInspector.isMac() ? |
| 401 WebInspector.KeyboardShortcut.Modifiers.Meta | WebInspector.KeyboardShor
tcut.Modifiers.Alt : |
| 402 WebInspector.KeyboardShortcut.Modifiers.Ctrl | WebInspector.KeyboardShor
tcut.Modifiers.Shift; |
| 403 var advancedSearchShortcut = shortcut.makeDescriptor('f', advancedSearchShor
tcutModifier); |
| 404 section.addKey(advancedSearchShortcut, WebInspector.UIString('Search across
all sources')); |
| 405 |
| 406 var inspectElementModeShortcuts = |
| 407 WebInspector.shortcutRegistry.shortcutDescriptorsForAction('elements.tog
gle-element-search'); |
| 408 if (inspectElementModeShortcuts.length) |
| 409 section.addKey(inspectElementModeShortcuts[0], WebInspector.UIString('Sele
ct node to inspect')); |
| 410 |
| 411 var openResourceShortcut = |
| 412 WebInspector.KeyboardShortcut.makeDescriptor('p', WebInspector.KeyboardS
hortcut.Modifiers.CtrlOrMeta); |
| 413 section.addKey(openResourceShortcut, WebInspector.UIString('Go to source')); |
| 414 |
| 415 if (WebInspector.isMac()) { |
| 416 keys = [ |
| 417 shortcut.makeDescriptor('g', shortcut.Modifiers.Meta), |
| 418 shortcut.makeDescriptor('g', shortcut.Modifiers.Meta | shortcut.Modifier
s.Shift) |
| 419 ]; |
| 420 section.addRelatedKeys(keys, WebInspector.UIString('Find next/previous')); |
| 421 } |
| 422 } |
| 423 |
| 424 _postDocumentKeyDown(event) { |
| 425 if (event.handled) |
| 426 return; |
| 427 |
| 428 var document = event.target && event.target.ownerDocument; |
| 429 var target = document ? document.deepActiveElement() : null; |
| 430 if (target) { |
| 431 var anchor = target.enclosingNodeOrSelfWithNodeName('a'); |
| 432 if (anchor && anchor.preventFollow) |
| 433 event.preventDefault(); |
| 434 } |
| 435 |
| 436 if (!WebInspector.Dialog.hasInstance() && WebInspector.inspectorView.current
PanelDeprecated()) { |
| 437 WebInspector.inspectorView.currentPanelDeprecated().handleShortcut(event); |
| 438 if (event.handled) { |
| 439 event.consume(true); |
| 440 return; |
| 441 } |
| 442 } |
| 443 |
| 444 WebInspector.shortcutRegistry.handleShortcut(event); |
| 445 } |
| 446 |
| 447 /** |
| 448 * @param {!Event} event |
| 449 */ |
| 450 _redispatchClipboardEvent(event) { |
| 451 var eventCopy = new CustomEvent('clipboard-' + event.type); |
| 452 eventCopy['original'] = event; |
| 453 var document = event.target && event.target.ownerDocument; |
| 454 var target = document ? document.deepActiveElement() : null; |
| 455 if (target) |
| 456 target.dispatchEvent(eventCopy); |
| 457 if (eventCopy.handled) |
| 458 event.preventDefault(); |
| 459 } |
| 460 |
| 461 _contextMenuEventFired(event) { |
| 462 if (event.handled || event.target.classList.contains('popup-glasspane')) |
| 463 event.preventDefault(); |
| 464 } |
| 465 |
| 466 /** |
| 467 * @param {!Document} document |
| 468 */ |
| 469 _addMainEventListeners(document) { |
| 470 document.addEventListener('keydown', this._postDocumentKeyDown.bind(this), f
alse); |
| 471 document.addEventListener('beforecopy', this._redispatchClipboardEvent.bind(
this), true); |
| 472 document.addEventListener('copy', this._redispatchClipboardEvent.bind(this),
false); |
| 473 document.addEventListener('cut', this._redispatchClipboardEvent.bind(this),
false); |
| 474 document.addEventListener('paste', this._redispatchClipboardEvent.bind(this)
, false); |
| 475 document.addEventListener('contextmenu', this._contextMenuEventFired.bind(th
is), true); |
| 476 document.addEventListener('click', this._documentClick.bind(this), false); |
| 477 } |
| 478 |
| 479 /** |
| 480 * @param {!WebInspector.Event} event |
| 481 */ |
| 482 _reloadInspectedPage(event) { |
| 483 var hard = /** @type {boolean} */ (event.data); |
| 484 WebInspector.Main._reloadPage(hard); |
| 485 } |
| 486 |
| 487 _onSuspendStateChanged() { |
| 488 var suspended = WebInspector.targetManager.allTargetsSuspended(); |
| 489 WebInspector.inspectorView.onSuspendStateChanged(suspended); |
| 490 } |
| 491 }; |
| 492 |
| 493 /** |
489 * @implements {WebInspector.TargetManager.Observer} | 494 * @implements {WebInspector.TargetManager.Observer} |
490 */ | 495 * @unrestricted |
491 WebInspector.Main.InspectorDomainObserver = function() | 496 */ |
492 { | 497 WebInspector.Main.InspectorDomainObserver = class { |
| 498 constructor() { |
493 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili
ty.Browser); | 499 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili
ty.Browser); |
494 }; | 500 } |
495 | 501 |
496 WebInspector.Main.InspectorDomainObserver.prototype = { | 502 /** |
| 503 * @override |
| 504 * @param {!WebInspector.Target} target |
| 505 */ |
| 506 targetAdded(target) { |
| 507 target.registerInspectorDispatcher(new WebInspector.Main.InspectorDomainDisp
atcher(target)); |
| 508 target.inspectorAgent().enable(); |
| 509 } |
| 510 |
| 511 /** |
| 512 * @override |
| 513 * @param {!WebInspector.Target} target |
| 514 */ |
| 515 targetRemoved(target) { |
| 516 } |
| 517 }; |
| 518 |
| 519 /** |
| 520 * @implements {InspectorAgent.Dispatcher} |
| 521 * @unrestricted |
| 522 */ |
| 523 WebInspector.Main.InspectorDomainDispatcher = class { |
| 524 /** |
| 525 * @param {!WebInspector.Target} target |
| 526 */ |
| 527 constructor(target) { |
| 528 this._target = target; |
| 529 } |
| 530 |
| 531 /** |
| 532 * @override |
| 533 * @param {string} reason |
| 534 */ |
| 535 detached(reason) { |
| 536 WebInspector._disconnectedScreenWithReasonWasShown = true; |
| 537 WebInspector.RemoteDebuggingTerminatedScreen.show(reason); |
| 538 } |
| 539 |
| 540 /** |
| 541 * @override |
| 542 */ |
| 543 targetCrashed() { |
| 544 var debuggerModel = WebInspector.DebuggerModel.fromTarget(this._target); |
| 545 if (debuggerModel) |
| 546 WebInspector.TargetCrashedScreen.show(debuggerModel); |
| 547 } |
| 548 }; |
| 549 |
| 550 /** |
| 551 * @implements {WebInspector.ActionDelegate} |
| 552 * @unrestricted |
| 553 */ |
| 554 WebInspector.Main.ReloadActionDelegate = class { |
| 555 /** |
| 556 * @override |
| 557 * @param {!WebInspector.Context} context |
| 558 * @param {string} actionId |
| 559 * @return {boolean} |
| 560 */ |
| 561 handleAction(context, actionId) { |
| 562 switch (actionId) { |
| 563 case 'main.reload': |
| 564 WebInspector.Main._reloadPage(false); |
| 565 return true; |
| 566 case 'main.hard-reload': |
| 567 WebInspector.Main._reloadPage(true); |
| 568 return true; |
| 569 case 'main.debug-reload': |
| 570 WebInspector.reload(); |
| 571 return true; |
| 572 } |
| 573 return false; |
| 574 } |
| 575 }; |
| 576 |
| 577 /** |
| 578 * @implements {WebInspector.ActionDelegate} |
| 579 * @unrestricted |
| 580 */ |
| 581 WebInspector.Main.ZoomActionDelegate = class { |
| 582 /** |
| 583 * @override |
| 584 * @param {!WebInspector.Context} context |
| 585 * @param {string} actionId |
| 586 * @return {boolean} |
| 587 */ |
| 588 handleAction(context, actionId) { |
| 589 if (InspectorFrontendHost.isHostedMode()) |
| 590 return false; |
| 591 |
| 592 switch (actionId) { |
| 593 case 'main.zoom-in': |
| 594 InspectorFrontendHost.zoomIn(); |
| 595 return true; |
| 596 case 'main.zoom-out': |
| 597 InspectorFrontendHost.zoomOut(); |
| 598 return true; |
| 599 case 'main.zoom-reset': |
| 600 InspectorFrontendHost.resetZoom(); |
| 601 return true; |
| 602 } |
| 603 return false; |
| 604 } |
| 605 }; |
| 606 |
| 607 /** |
| 608 * @implements {WebInspector.ActionDelegate} |
| 609 * @unrestricted |
| 610 */ |
| 611 WebInspector.Main.SearchActionDelegate = class { |
| 612 /** |
| 613 * @override |
| 614 * @param {!WebInspector.Context} context |
| 615 * @param {string} actionId |
| 616 * @return {boolean} |
| 617 * @suppressGlobalPropertiesCheck |
| 618 */ |
| 619 handleAction(context, actionId) { |
| 620 var searchableView = WebInspector.SearchableView.fromElement(document.deepAc
tiveElement()) || |
| 621 WebInspector.inspectorView.currentPanelDeprecated().searchableView(); |
| 622 if (!searchableView) |
| 623 return false; |
| 624 switch (actionId) { |
| 625 case 'main.search-in-panel.find': |
| 626 return searchableView.handleFindShortcut(); |
| 627 case 'main.search-in-panel.cancel': |
| 628 return searchableView.handleCancelSearchShortcut(); |
| 629 case 'main.search-in-panel.find-next': |
| 630 return searchableView.handleFindNextShortcut(); |
| 631 case 'main.search-in-panel.find-previous': |
| 632 return searchableView.handleFindPreviousShortcut(); |
| 633 } |
| 634 return false; |
| 635 } |
| 636 }; |
| 637 |
| 638 |
| 639 /** |
| 640 * @implements {WebInspector.ToolbarItem.Provider} |
| 641 * @unrestricted |
| 642 */ |
| 643 WebInspector.Main.WarningErrorCounter = class { |
| 644 constructor() { |
| 645 WebInspector.Main.WarningErrorCounter._instanceForTest = this; |
| 646 |
| 647 this._counter = createElement('div'); |
| 648 this._counter.addEventListener('click', WebInspector.console.show.bind(WebIn
spector.console), false); |
| 649 this._toolbarItem = new WebInspector.ToolbarItem(this._counter); |
| 650 var shadowRoot = WebInspector.createShadowRootWithCoreStyles(this._counter,
'main/errorWarningCounter.css'); |
| 651 |
| 652 this._errors = this._createItem(shadowRoot, 'error-icon'); |
| 653 this._revokedErrors = this._createItem(shadowRoot, 'revokedError-icon'); |
| 654 this._warnings = this._createItem(shadowRoot, 'warning-icon'); |
| 655 this._titles = []; |
| 656 |
| 657 WebInspector.multitargetConsoleModel.addEventListener( |
| 658 WebInspector.ConsoleModel.Events.ConsoleCleared, this._update, this); |
| 659 WebInspector.multitargetConsoleModel.addEventListener( |
| 660 WebInspector.ConsoleModel.Events.MessageAdded, this._update, this); |
| 661 WebInspector.multitargetConsoleModel.addEventListener( |
| 662 WebInspector.ConsoleModel.Events.MessageUpdated, this._update, this); |
| 663 this._update(); |
| 664 } |
| 665 |
| 666 /** |
| 667 * @param {!Node} shadowRoot |
| 668 * @param {string} iconType |
| 669 * @return {!{item: !Element, text: !Element}} |
| 670 */ |
| 671 _createItem(shadowRoot, iconType) { |
| 672 var item = createElementWithClass('span', 'counter-item'); |
| 673 var icon = item.createChild('label', '', 'dt-icon-label'); |
| 674 icon.type = iconType; |
| 675 var text = icon.createChild('span'); |
| 676 shadowRoot.appendChild(item); |
| 677 return {item: item, text: text}; |
| 678 } |
| 679 |
| 680 /** |
| 681 * @param {!{item: !Element, text: !Element}} item |
| 682 * @param {number} count |
| 683 * @param {boolean} first |
| 684 * @param {string} title |
| 685 */ |
| 686 _updateItem(item, count, first, title) { |
| 687 item.item.classList.toggle('hidden', !count); |
| 688 item.item.classList.toggle('counter-item-first', first); |
| 689 item.text.textContent = count; |
| 690 if (count) |
| 691 this._titles.push(title); |
| 692 } |
| 693 |
| 694 _update() { |
| 695 var errors = 0; |
| 696 var revokedErrors = 0; |
| 697 var warnings = 0; |
| 698 var targets = WebInspector.targetManager.targets(); |
| 699 for (var i = 0; i < targets.length; ++i) { |
| 700 errors += targets[i].consoleModel.errors(); |
| 701 revokedErrors += targets[i].consoleModel.revokedErrors(); |
| 702 warnings += targets[i].consoleModel.warnings(); |
| 703 } |
| 704 |
| 705 this._titles = []; |
| 706 this._toolbarItem.setVisible(!!(errors || revokedErrors || warnings)); |
| 707 this._updateItem( |
| 708 this._errors, errors, false, WebInspector.UIString(errors === 1 ? '%d er
ror' : '%d errors', errors)); |
| 709 this._updateItem( |
| 710 this._revokedErrors, revokedErrors, !errors, |
| 711 WebInspector.UIString( |
| 712 revokedErrors === 1 ? '%d handled promise rejection' : '%d handled p
romise rejections', revokedErrors)); |
| 713 this._updateItem( |
| 714 this._warnings, warnings, !errors && !revokedErrors, |
| 715 WebInspector.UIString(warnings === 1 ? '%d warning' : '%d warnings', war
nings)); |
| 716 this._counter.title = this._titles.join(', '); |
| 717 WebInspector.inspectorView.toolbarItemResized(); |
| 718 } |
| 719 |
| 720 /** |
| 721 * @override |
| 722 * @return {?WebInspector.ToolbarItem} |
| 723 */ |
| 724 item() { |
| 725 return this._toolbarItem; |
| 726 } |
| 727 }; |
| 728 |
| 729 /** |
| 730 * @implements {WebInspector.ToolbarItem.Provider} |
| 731 * @unrestricted |
| 732 */ |
| 733 WebInspector.Main.MainMenuItem = class { |
| 734 constructor() { |
| 735 this._item = |
| 736 new WebInspector.ToolbarButton(WebInspector.UIString('Customize and cont
rol DevTools'), 'menu-toolbar-item'); |
| 737 this._item.addEventListener('mousedown', this._mouseDown, this); |
| 738 } |
| 739 |
| 740 /** |
| 741 * @override |
| 742 * @return {?WebInspector.ToolbarItem} |
| 743 */ |
| 744 item() { |
| 745 return this._item; |
| 746 } |
| 747 |
| 748 /** |
| 749 * @param {!WebInspector.Event} event |
| 750 */ |
| 751 _mouseDown(event) { |
| 752 var contextMenu = new WebInspector.ContextMenu( |
| 753 /** @type {!Event} */ (event.data), true, this._item.element.totalOffset
Left(), |
| 754 this._item.element.totalOffsetTop() + this._item.element.offsetHeight); |
| 755 |
| 756 if (WebInspector.dockController.canDock()) { |
| 757 var dockItemElement = createElementWithClass('div', 'flex-centered flex-au
to'); |
| 758 var titleElement = dockItemElement.createChild('span', 'flex-auto'); |
| 759 titleElement.textContent = WebInspector.UIString('Dock side'); |
| 760 var toggleDockSideShorcuts = WebInspector.shortcutRegistry.shortcutDescrip
torsForAction('main.toggle-dock'); |
| 761 titleElement.title = WebInspector.UIString( |
| 762 'Placement of DevTools relative to the page. (%s to restore last posit
ion)', toggleDockSideShorcuts[0].name); |
| 763 dockItemElement.appendChild(titleElement); |
| 764 var dockItemToolbar = new WebInspector.Toolbar('', dockItemElement); |
| 765 dockItemToolbar.makeBlueOnHover(); |
| 766 var undock = new WebInspector.ToolbarToggle( |
| 767 WebInspector.UIString('Undock into separate window'), 'dock-toolbar-it
em-undock'); |
| 768 var bottom = new WebInspector.ToolbarToggle(WebInspector.UIString('Dock to
bottom'), 'dock-toolbar-item-bottom'); |
| 769 var right = new WebInspector.ToolbarToggle(WebInspector.UIString('Dock to
right'), 'dock-toolbar-item-right'); |
| 770 undock.addEventListener('mouseup', setDockSide.bind(null, WebInspector.Doc
kController.State.Undocked)); |
| 771 bottom.addEventListener('mouseup', setDockSide.bind(null, WebInspector.Doc
kController.State.DockedToBottom)); |
| 772 right.addEventListener('mouseup', setDockSide.bind(null, WebInspector.Dock
Controller.State.DockedToRight)); |
| 773 undock.setToggled(WebInspector.dockController.dockSide() === WebInspector.
DockController.State.Undocked); |
| 774 bottom.setToggled(WebInspector.dockController.dockSide() === WebInspector.
DockController.State.DockedToBottom); |
| 775 right.setToggled(WebInspector.dockController.dockSide() === WebInspector.D
ockController.State.DockedToRight); |
| 776 dockItemToolbar.appendToolbarItem(undock); |
| 777 dockItemToolbar.appendToolbarItem(bottom); |
| 778 dockItemToolbar.appendToolbarItem(right); |
| 779 contextMenu.appendCustomItem(dockItemElement); |
| 780 contextMenu.appendSeparator(); |
| 781 } |
| 782 |
497 /** | 783 /** |
498 * @override | 784 * @param {string} side |
499 * @param {!WebInspector.Target} target | |
500 */ | 785 */ |
501 targetAdded: function(target) | 786 function setDockSide(side) { |
502 { | 787 WebInspector.dockController.setDockSide(side); |
503 target.registerInspectorDispatcher(new WebInspector.Main.InspectorDomain
Dispatcher(target)); | 788 contextMenu.discard(); |
504 target.inspectorAgent().enable(); | 789 } |
505 }, | 790 |
506 | 791 contextMenu.appendAction( |
507 /** | 792 'main.toggle-drawer', WebInspector.inspectorView.drawerVisible() ? |
508 * @override | 793 WebInspector.UIString('Hide console drawer') : |
509 * @param {!WebInspector.Target} target | 794 WebInspector.UIString('Show console drawer')); |
510 */ | 795 contextMenu.appendItemsAtLocation('mainMenu'); |
511 targetRemoved: function(target) | 796 var moreTools = contextMenu.namedSubMenu('mainMenuMoreTools'); |
512 { | 797 var extensions = self.runtime.extensions('view', undefined, true); |
513 }, | 798 for (var extension of extensions) { |
514 }; | 799 var descriptor = extension.descriptor(); |
515 | 800 if (descriptor['persistence'] !== 'closeable') |
516 /** | 801 continue; |
517 * @constructor | 802 if (descriptor['location'] !== 'drawer-view' && descriptor['location'] !==
'panel') |
518 * @implements {InspectorAgent.Dispatcher} | 803 continue; |
519 * @param {!WebInspector.Target} target | 804 moreTools.appendItem( |
520 */ | 805 extension.title(), WebInspector.viewManager.showView.bind(WebInspector
.viewManager, descriptor['id'])); |
521 WebInspector.Main.InspectorDomainDispatcher = function(target) | 806 } |
522 { | 807 |
523 this._target = target; | 808 contextMenu.show(); |
524 }; | 809 } |
525 | 810 }; |
526 WebInspector.Main.InspectorDomainDispatcher.prototype = { | 811 |
527 /** | 812 /** |
528 * @override | 813 * @unrestricted |
529 * @param {string} reason | 814 */ |
530 */ | 815 WebInspector.NetworkPanelIndicator = class { |
531 detached: function(reason) | 816 constructor() { |
532 { | |
533 WebInspector._disconnectedScreenWithReasonWasShown = true; | |
534 WebInspector.RemoteDebuggingTerminatedScreen.show(reason); | |
535 }, | |
536 | |
537 /** | |
538 * @override | |
539 */ | |
540 targetCrashed: function() | |
541 { | |
542 var debuggerModel = WebInspector.DebuggerModel.fromTarget(this._target); | |
543 if (debuggerModel) | |
544 WebInspector.TargetCrashedScreen.show(debuggerModel); | |
545 } | |
546 }; | |
547 | |
548 | |
549 /** | |
550 * @constructor | |
551 * @implements {WebInspector.ActionDelegate} | |
552 */ | |
553 WebInspector.Main.ReloadActionDelegate = function() | |
554 { | |
555 }; | |
556 | |
557 WebInspector.Main.ReloadActionDelegate.prototype = { | |
558 /** | |
559 * @override | |
560 * @param {!WebInspector.Context} context | |
561 * @param {string} actionId | |
562 * @return {boolean} | |
563 */ | |
564 handleAction: function(context, actionId) | |
565 { | |
566 switch (actionId) { | |
567 case "main.reload": | |
568 WebInspector.Main._reloadPage(false); | |
569 return true; | |
570 case "main.hard-reload": | |
571 WebInspector.Main._reloadPage(true); | |
572 return true; | |
573 case "main.debug-reload": | |
574 WebInspector.reload(); | |
575 return true; | |
576 } | |
577 return false; | |
578 } | |
579 }; | |
580 | |
581 /** | |
582 * @constructor | |
583 * @implements {WebInspector.ActionDelegate} | |
584 */ | |
585 WebInspector.Main.ZoomActionDelegate = function() | |
586 { | |
587 }; | |
588 | |
589 WebInspector.Main.ZoomActionDelegate.prototype = { | |
590 /** | |
591 * @override | |
592 * @param {!WebInspector.Context} context | |
593 * @param {string} actionId | |
594 * @return {boolean} | |
595 */ | |
596 handleAction: function(context, actionId) | |
597 { | |
598 if (InspectorFrontendHost.isHostedMode()) | |
599 return false; | |
600 | |
601 switch (actionId) { | |
602 case "main.zoom-in": | |
603 InspectorFrontendHost.zoomIn(); | |
604 return true; | |
605 case "main.zoom-out": | |
606 InspectorFrontendHost.zoomOut(); | |
607 return true; | |
608 case "main.zoom-reset": | |
609 InspectorFrontendHost.resetZoom(); | |
610 return true; | |
611 } | |
612 return false; | |
613 } | |
614 }; | |
615 | |
616 /** | |
617 * @constructor | |
618 * @implements {WebInspector.ActionDelegate} | |
619 */ | |
620 WebInspector.Main.SearchActionDelegate = function() | |
621 { | |
622 }; | |
623 | |
624 WebInspector.Main.SearchActionDelegate.prototype = { | |
625 /** | |
626 * @override | |
627 * @param {!WebInspector.Context} context | |
628 * @param {string} actionId | |
629 * @return {boolean} | |
630 * @suppressGlobalPropertiesCheck | |
631 */ | |
632 handleAction: function(context, actionId) | |
633 { | |
634 var searchableView = WebInspector.SearchableView.fromElement(document.de
epActiveElement()) || WebInspector.inspectorView.currentPanelDeprecated().search
ableView(); | |
635 if (!searchableView) | |
636 return false; | |
637 switch (actionId) { | |
638 case "main.search-in-panel.find": | |
639 return searchableView.handleFindShortcut(); | |
640 case "main.search-in-panel.cancel": | |
641 return searchableView.handleCancelSearchShortcut(); | |
642 case "main.search-in-panel.find-next": | |
643 return searchableView.handleFindNextShortcut(); | |
644 case "main.search-in-panel.find-previous": | |
645 return searchableView.handleFindPreviousShortcut(); | |
646 } | |
647 return false; | |
648 } | |
649 }; | |
650 | |
651 /** | |
652 * @param {boolean} hard | |
653 */ | |
654 WebInspector.Main._reloadPage = function(hard) | |
655 { | |
656 var mainTarget = WebInspector.targetManager.mainTarget(); | |
657 if (mainTarget && mainTarget.hasBrowserCapability()) | |
658 WebInspector.targetManager.reloadPage(hard); | |
659 }; | |
660 | |
661 /** | |
662 * @constructor | |
663 * @implements {WebInspector.ToolbarItem.Provider} | |
664 */ | |
665 WebInspector.Main.WarningErrorCounter = function() | |
666 { | |
667 WebInspector.Main.WarningErrorCounter._instanceForTest = this; | |
668 | |
669 this._counter = createElement("div"); | |
670 this._counter.addEventListener("click", WebInspector.console.show.bind(WebIn
spector.console), false); | |
671 this._toolbarItem = new WebInspector.ToolbarItem(this._counter); | |
672 var shadowRoot = WebInspector.createShadowRootWithCoreStyles(this._counter,
"main/errorWarningCounter.css"); | |
673 | |
674 this._errors = this._createItem(shadowRoot, "error-icon"); | |
675 this._revokedErrors = this._createItem(shadowRoot, "revokedError-icon"); | |
676 this._warnings = this._createItem(shadowRoot, "warning-icon"); | |
677 this._titles = []; | |
678 | |
679 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleMo
del.Events.ConsoleCleared, this._update, this); | |
680 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleMo
del.Events.MessageAdded, this._update, this); | |
681 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleMo
del.Events.MessageUpdated, this._update, this); | |
682 this._update(); | |
683 }; | |
684 | |
685 WebInspector.Main.WarningErrorCounter.prototype = { | |
686 /** | |
687 * @param {!Node} shadowRoot | |
688 * @param {string} iconType | |
689 * @return {!{item: !Element, text: !Element}} | |
690 */ | |
691 _createItem: function(shadowRoot, iconType) | |
692 { | |
693 var item = createElementWithClass("span", "counter-item"); | |
694 var icon = item.createChild("label", "", "dt-icon-label"); | |
695 icon.type = iconType; | |
696 var text = icon.createChild("span"); | |
697 shadowRoot.appendChild(item); | |
698 return {item: item, text: text}; | |
699 }, | |
700 | |
701 /** | |
702 * @param {!{item: !Element, text: !Element}} item | |
703 * @param {number} count | |
704 * @param {boolean} first | |
705 * @param {string} title | |
706 */ | |
707 _updateItem: function(item, count, first, title) | |
708 { | |
709 item.item.classList.toggle("hidden", !count); | |
710 item.item.classList.toggle("counter-item-first", first); | |
711 item.text.textContent = count; | |
712 if (count) | |
713 this._titles.push(title); | |
714 }, | |
715 | |
716 _update: function() | |
717 { | |
718 var errors = 0; | |
719 var revokedErrors = 0; | |
720 var warnings = 0; | |
721 var targets = WebInspector.targetManager.targets(); | |
722 for (var i = 0; i < targets.length; ++i) { | |
723 errors += targets[i].consoleModel.errors(); | |
724 revokedErrors += targets[i].consoleModel.revokedErrors(); | |
725 warnings += targets[i].consoleModel.warnings(); | |
726 } | |
727 | |
728 this._titles = []; | |
729 this._toolbarItem.setVisible(!!(errors || revokedErrors || warnings)); | |
730 this._updateItem(this._errors, errors, false, WebInspector.UIString(erro
rs === 1 ? "%d error" : "%d errors", errors)); | |
731 this._updateItem(this._revokedErrors, revokedErrors, !errors, WebInspect
or.UIString(revokedErrors === 1 ? "%d handled promise rejection" : "%d handled p
romise rejections", revokedErrors)); | |
732 this._updateItem(this._warnings, warnings, !errors && !revokedErrors, We
bInspector.UIString(warnings === 1 ? "%d warning" : "%d warnings", warnings)); | |
733 this._counter.title = this._titles.join(", "); | |
734 WebInspector.inspectorView.toolbarItemResized(); | |
735 }, | |
736 | |
737 /** | |
738 * @override | |
739 * @return {?WebInspector.ToolbarItem} | |
740 */ | |
741 item: function() | |
742 { | |
743 return this._toolbarItem; | |
744 } | |
745 }; | |
746 | |
747 /** | |
748 * @constructor | |
749 * @implements {WebInspector.ToolbarItem.Provider} | |
750 */ | |
751 WebInspector.Main.MainMenuItem = function() | |
752 { | |
753 this._item = new WebInspector.ToolbarButton(WebInspector.UIString("Customize
and control DevTools"), "menu-toolbar-item"); | |
754 this._item.addEventListener("mousedown", this._mouseDown, this); | |
755 }; | |
756 | |
757 WebInspector.Main.MainMenuItem.prototype = { | |
758 /** | |
759 * @override | |
760 * @return {?WebInspector.ToolbarItem} | |
761 */ | |
762 item: function() | |
763 { | |
764 return this._item; | |
765 }, | |
766 | |
767 /** | |
768 * @param {!WebInspector.Event} event | |
769 */ | |
770 _mouseDown: function(event) | |
771 { | |
772 var contextMenu = new WebInspector.ContextMenu(/** @type {!Event} */(eve
nt.data), | |
773 true, | |
774 this._item.element.totalOffsetLeft(), | |
775 this._item.element.totalOffsetTop() + this._item.element.offsetHeigh
t); | |
776 | |
777 if (WebInspector.dockController.canDock()) { | |
778 var dockItemElement = createElementWithClass("div", "flex-centered f
lex-auto"); | |
779 var titleElement = dockItemElement.createChild("span", "flex-auto"); | |
780 titleElement.textContent = WebInspector.UIString("Dock side"); | |
781 var toggleDockSideShorcuts = WebInspector.shortcutRegistry.shortcutD
escriptorsForAction("main.toggle-dock"); | |
782 titleElement.title = WebInspector.UIString("Placement of DevTools re
lative to the page. (%s to restore last position)", toggleDockSideShorcuts[0].na
me); | |
783 dockItemElement.appendChild(titleElement); | |
784 var dockItemToolbar = new WebInspector.Toolbar("", dockItemElement); | |
785 dockItemToolbar.makeBlueOnHover(); | |
786 var undock = new WebInspector.ToolbarToggle(WebInspector.UIString("U
ndock into separate window"), "dock-toolbar-item-undock"); | |
787 var bottom = new WebInspector.ToolbarToggle(WebInspector.UIString("D
ock to bottom"), "dock-toolbar-item-bottom"); | |
788 var right = new WebInspector.ToolbarToggle(WebInspector.UIString("Do
ck to right"), "dock-toolbar-item-right"); | |
789 undock.addEventListener("mouseup", setDockSide.bind(null, WebInspect
or.DockController.State.Undocked)); | |
790 bottom.addEventListener("mouseup", setDockSide.bind(null, WebInspect
or.DockController.State.DockedToBottom)); | |
791 right.addEventListener("mouseup", setDockSide.bind(null, WebInspecto
r.DockController.State.DockedToRight)); | |
792 undock.setToggled(WebInspector.dockController.dockSide() === WebInsp
ector.DockController.State.Undocked); | |
793 bottom.setToggled(WebInspector.dockController.dockSide() === WebInsp
ector.DockController.State.DockedToBottom); | |
794 right.setToggled(WebInspector.dockController.dockSide() === WebInspe
ctor.DockController.State.DockedToRight); | |
795 dockItemToolbar.appendToolbarItem(undock); | |
796 dockItemToolbar.appendToolbarItem(bottom); | |
797 dockItemToolbar.appendToolbarItem(right); | |
798 contextMenu.appendCustomItem(dockItemElement); | |
799 contextMenu.appendSeparator(); | |
800 } | |
801 | |
802 /** | |
803 * @param {string} side | |
804 */ | |
805 function setDockSide(side) | |
806 { | |
807 WebInspector.dockController.setDockSide(side); | |
808 contextMenu.discard(); | |
809 } | |
810 | |
811 contextMenu.appendAction("main.toggle-drawer", WebInspector.inspectorVie
w.drawerVisible() ? WebInspector.UIString("Hide console drawer") : WebInspector.
UIString("Show console drawer")); | |
812 contextMenu.appendItemsAtLocation("mainMenu"); | |
813 var moreTools = contextMenu.namedSubMenu("mainMenuMoreTools"); | |
814 var extensions = self.runtime.extensions("view", undefined, true); | |
815 for (var extension of extensions) { | |
816 var descriptor = extension.descriptor(); | |
817 if (descriptor["persistence"] !== "closeable") | |
818 continue; | |
819 if (descriptor["location"] !== "drawer-view" && descriptor["location
"] !== "panel") | |
820 continue; | |
821 moreTools.appendItem(extension.title(), WebInspector.viewManager.sho
wView.bind(WebInspector.viewManager, descriptor["id"])); | |
822 } | |
823 | |
824 contextMenu.show(); | |
825 } | |
826 }; | |
827 | |
828 /** | |
829 * @constructor | |
830 */ | |
831 WebInspector.NetworkPanelIndicator = function() | |
832 { | |
833 // TODO: we should not access network from other modules. | 817 // TODO: we should not access network from other modules. |
834 if (!WebInspector.inspectorView.hasPanel("network")) | 818 if (!WebInspector.inspectorView.hasPanel('network')) |
835 return; | 819 return; |
836 var manager = WebInspector.multitargetNetworkManager; | 820 var manager = WebInspector.multitargetNetworkManager; |
837 manager.addEventListener(WebInspector.MultitargetNetworkManager.Events.Condi
tionsChanged, updateVisibility); | 821 manager.addEventListener(WebInspector.MultitargetNetworkManager.Events.Condi
tionsChanged, updateVisibility); |
838 var blockedURLsSetting = WebInspector.moduleSetting("blockedURLs"); | 822 var blockedURLsSetting = WebInspector.moduleSetting('blockedURLs'); |
839 blockedURLsSetting.addChangeListener(updateVisibility); | 823 blockedURLsSetting.addChangeListener(updateVisibility); |
840 updateVisibility(); | 824 updateVisibility(); |
841 | 825 |
842 function updateVisibility() | 826 function updateVisibility() { |
843 { | 827 if (manager.isThrottling()) { |
844 if (manager.isThrottling()) { | 828 WebInspector.inspectorView.setPanelIcon( |
845 WebInspector.inspectorView.setPanelIcon("network", "warning-icon", W
ebInspector.UIString("Network throttling is enabled")); | 829 'network', 'warning-icon', WebInspector.UIString('Network throttling
is enabled')); |
846 } else if (blockedURLsSetting.get().length) { | 830 } else if (blockedURLsSetting.get().length) { |
847 WebInspector.inspectorView.setPanelIcon("network", "warning-icon", W
ebInspector.UIString("Requests may be blocked")); | 831 WebInspector.inspectorView.setPanelIcon( |
848 } else { | 832 'network', 'warning-icon', WebInspector.UIString('Requests may be bl
ocked')); |
849 WebInspector.inspectorView.setPanelIcon("network", "", ""); | 833 } else { |
850 } | 834 WebInspector.inspectorView.setPanelIcon('network', '', ''); |
851 } | 835 } |
852 }; | 836 } |
853 | 837 } |
854 /** | 838 }; |
855 * @constructor | 839 |
856 */ | 840 /** |
857 WebInspector.SourcesPanelIndicator = function() | 841 * @unrestricted |
858 { | 842 */ |
859 WebInspector.moduleSetting("javaScriptDisabled").addChangeListener(javaScrip
tDisabledChanged); | 843 WebInspector.SourcesPanelIndicator = class { |
| 844 constructor() { |
| 845 WebInspector.moduleSetting('javaScriptDisabled').addChangeListener(javaScrip
tDisabledChanged); |
860 javaScriptDisabledChanged(); | 846 javaScriptDisabledChanged(); |
861 | 847 |
862 function javaScriptDisabledChanged() | 848 function javaScriptDisabledChanged() { |
863 { | 849 var javaScriptDisabled = WebInspector.moduleSetting('javaScriptDisabled').
get(); |
864 var javaScriptDisabled = WebInspector.moduleSetting("javaScriptDisabled"
).get(); | 850 if (javaScriptDisabled) { |
865 if (javaScriptDisabled) { | 851 WebInspector.inspectorView.setPanelIcon( |
866 WebInspector.inspectorView.setPanelIcon("sources", "warning-icon", W
ebInspector.UIString("JavaScript is disabled")); | 852 'sources', 'warning-icon', WebInspector.UIString('JavaScript is disa
bled')); |
867 } else { | 853 } else { |
868 WebInspector.inspectorView.setPanelIcon("sources", "", ""); | 854 WebInspector.inspectorView.setPanelIcon('sources', '', ''); |
869 } | 855 } |
870 } | 856 } |
871 }; | 857 } |
872 | 858 }; |
873 /** | 859 |
874 * @constructor | 860 /** |
875 */ | 861 * @unrestricted |
876 WebInspector.Main.PauseListener = function() | 862 */ |
877 { | 863 WebInspector.Main.PauseListener = class { |
878 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI
nspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this); | 864 constructor() { |
879 }; | 865 WebInspector.targetManager.addModelListener( |
880 | 866 WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerPa
used, this._debuggerPaused, this); |
881 WebInspector.Main.PauseListener.prototype = { | 867 } |
882 /** | 868 |
883 * @param {!WebInspector.Event} event | 869 /** |
884 */ | 870 * @param {!WebInspector.Event} event |
885 _debuggerPaused: function(event) | 871 */ |
886 { | 872 _debuggerPaused(event) { |
887 WebInspector.targetManager.removeModelListener(WebInspector.DebuggerMode
l, WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this)
; | 873 WebInspector.targetManager.removeModelListener( |
888 var debuggerPausedDetails = /** @type {!WebInspector.DebuggerPausedDetai
ls} */ (event.data); | 874 WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.DebuggerPa
used, this._debuggerPaused, this); |
889 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.ta
rget); | 875 var debuggerPausedDetails = /** @type {!WebInspector.DebuggerPausedDetails}
*/ (event.data); |
890 WebInspector.context.setFlavor(WebInspector.Target, debuggerModel.target
()); | 876 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.target
); |
891 WebInspector.Revealer.reveal(debuggerPausedDetails); | 877 WebInspector.context.setFlavor(WebInspector.Target, debuggerModel.target()); |
892 } | 878 WebInspector.Revealer.reveal(debuggerPausedDetails); |
893 }; | 879 } |
894 | 880 }; |
895 /** | 881 |
896 * @constructor | 882 /** |
897 */ | 883 * @unrestricted |
898 WebInspector.Main.InspectedNodeRevealer = function() | 884 */ |
899 { | 885 WebInspector.Main.InspectedNodeRevealer = class { |
900 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspec
tor.DOMModel.Events.NodeInspected, this._inspectNode, this); | 886 constructor() { |
901 }; | 887 WebInspector.targetManager.addModelListener( |
902 | 888 WebInspector.DOMModel, WebInspector.DOMModel.Events.NodeInspected, this.
_inspectNode, this); |
903 WebInspector.Main.InspectedNodeRevealer.prototype = { | 889 } |
904 /** | 890 |
905 * @param {!WebInspector.Event} event | 891 /** |
906 */ | 892 * @param {!WebInspector.Event} event |
907 _inspectNode: function(event) | 893 */ |
908 { | 894 _inspectNode(event) { |
909 var deferredNode = /** @type {!WebInspector.DeferredDOMNode} */ (event.d
ata); | 895 var deferredNode = /** @type {!WebInspector.DeferredDOMNode} */ (event.data)
; |
910 WebInspector.Revealer.reveal(deferredNode); | 896 WebInspector.Revealer.reveal(deferredNode); |
911 } | 897 } |
912 }; | 898 }; |
913 | 899 |
914 /** | 900 /** |
915 * @param {string} method | 901 * @param {string} method |
916 * @param {?Object} params | 902 * @param {?Object} params |
917 * @return {!Promise} | 903 * @return {!Promise} |
918 */ | 904 */ |
919 WebInspector.sendOverProtocol = function(method, params) | 905 WebInspector.sendOverProtocol = function(method, params) { |
920 { | 906 return new Promise((resolve, reject) => { |
921 return new Promise((resolve, reject) => { | 907 InspectorBackendClass.sendRawMessageForTesting(method, params, (err, result)
=> { |
922 InspectorBackendClass.sendRawMessageForTesting(method, params, (err, res
ult) => { | 908 if (err) |
923 if (err) | 909 return reject(err); |
924 return reject(err); | 910 return resolve(result); |
925 return resolve(result); | |
926 }); | |
927 }); | 911 }); |
| 912 }); |
928 }; | 913 }; |
929 | 914 |
930 /** | 915 /** |
931 * @constructor | 916 * @unrestricted |
932 * @extends {WebInspector.VBox} | |
933 * @param {string} reason | |
934 */ | 917 */ |
935 WebInspector.RemoteDebuggingTerminatedScreen = function(reason) | 918 WebInspector.RemoteDebuggingTerminatedScreen = class extends WebInspector.VBox { |
936 { | 919 /** |
937 WebInspector.VBox.call(this, true); | 920 * @param {string} reason |
938 this.registerRequiredCSS("main/remoteDebuggingTerminatedScreen.css"); | 921 */ |
939 var message = this.contentElement.createChild("div", "message"); | 922 constructor(reason) { |
940 message.createChild("span").textContent = WebInspector.UIString("Debugging c
onnection was closed. Reason: "); | 923 super(true); |
941 message.createChild("span", "reason").textContent = reason; | 924 this.registerRequiredCSS('main/remoteDebuggingTerminatedScreen.css'); |
942 this.contentElement.createChild("div", "message").textContent = WebInspector
.UIString("Reconnect when ready by reopening DevTools."); | 925 var message = this.contentElement.createChild('div', 'message'); |
943 var button = createTextButton(WebInspector.UIString("Reconnect DevTools"), (
) => window.location.reload()); | 926 message.createChild('span').textContent = WebInspector.UIString('Debugging c
onnection was closed. Reason: '); |
944 this.contentElement.createChild("div", "button").appendChild(button); | 927 message.createChild('span', 'reason').textContent = reason; |
945 }; | 928 this.contentElement.createChild('div', 'message').textContent = |
| 929 WebInspector.UIString('Reconnect when ready by reopening DevTools.'); |
| 930 var button = createTextButton(WebInspector.UIString('Reconnect DevTools'), (
) => window.location.reload()); |
| 931 this.contentElement.createChild('div', 'button').appendChild(button); |
| 932 } |
946 | 933 |
947 /** | 934 /** |
948 * @param {string} reason | 935 * @param {string} reason |
949 */ | 936 */ |
950 WebInspector.RemoteDebuggingTerminatedScreen.show = function(reason) | 937 static show(reason) { |
951 { | |
952 var dialog = new WebInspector.Dialog(); | 938 var dialog = new WebInspector.Dialog(); |
953 dialog.setWrapsContent(true); | 939 dialog.setWrapsContent(true); |
954 dialog.addCloseButton(); | 940 dialog.addCloseButton(); |
955 dialog.setDimmed(true); | 941 dialog.setDimmed(true); |
956 new WebInspector.RemoteDebuggingTerminatedScreen(reason).show(dialog.element
); | 942 new WebInspector.RemoteDebuggingTerminatedScreen(reason).show(dialog.element
); |
957 dialog.show(); | 943 dialog.show(); |
| 944 } |
958 }; | 945 }; |
959 | 946 |
960 WebInspector.RemoteDebuggingTerminatedScreen.prototype = { | |
961 __proto__: WebInspector.VBox.prototype | |
962 }; | |
963 | 947 |
964 /** | 948 /** |
965 * @constructor | 949 * @unrestricted |
966 * @param {function()} hideCallback | |
967 * @extends {WebInspector.VBox} | |
968 */ | 950 */ |
969 WebInspector.TargetCrashedScreen = function(hideCallback) | 951 WebInspector.TargetCrashedScreen = class extends WebInspector.VBox { |
970 { | 952 /** |
971 WebInspector.VBox.call(this, true); | 953 * @param {function()} hideCallback |
972 this.registerRequiredCSS("main/targetCrashedScreen.css"); | 954 */ |
973 this.contentElement.createChild("div", "message").textContent = WebInspector
.UIString("DevTools was disconnected from the page."); | 955 constructor(hideCallback) { |
974 this.contentElement.createChild("div", "message").textContent = WebInspector
.UIString("Once page is reloaded, DevTools will automatically reconnect."); | 956 super(true); |
| 957 this.registerRequiredCSS('main/targetCrashedScreen.css'); |
| 958 this.contentElement.createChild('div', 'message').textContent = |
| 959 WebInspector.UIString('DevTools was disconnected from the page.'); |
| 960 this.contentElement.createChild('div', 'message').textContent = |
| 961 WebInspector.UIString('Once page is reloaded, DevTools will automaticall
y reconnect.'); |
975 this._hideCallback = hideCallback; | 962 this._hideCallback = hideCallback; |
976 }; | 963 } |
977 | 964 |
978 /** | 965 /** |
979 * @param {!WebInspector.DebuggerModel} debuggerModel | 966 * @param {!WebInspector.DebuggerModel} debuggerModel |
980 */ | 967 */ |
981 WebInspector.TargetCrashedScreen.show = function(debuggerModel) | 968 static show(debuggerModel) { |
982 { | |
983 var dialog = new WebInspector.Dialog(); | 969 var dialog = new WebInspector.Dialog(); |
984 dialog.setWrapsContent(true); | 970 dialog.setWrapsContent(true); |
985 dialog.addCloseButton(); | 971 dialog.addCloseButton(); |
986 dialog.setDimmed(true); | 972 dialog.setDimmed(true); |
987 var hideBound = dialog.detach.bind(dialog); | 973 var hideBound = dialog.detach.bind(dialog); |
988 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjec
tCleared, hideBound); | 974 debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjec
tCleared, hideBound); |
989 | 975 |
990 new WebInspector.TargetCrashedScreen(onHide).show(dialog.element); | 976 new WebInspector.TargetCrashedScreen(onHide).show(dialog.element); |
991 dialog.show(); | 977 dialog.show(); |
992 | 978 |
993 function onHide() | 979 function onHide() { |
994 { | 980 debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.Global
ObjectCleared, hideBound); |
995 debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.Glob
alObjectCleared, hideBound); | |
996 } | 981 } |
| 982 } |
| 983 |
| 984 /** |
| 985 * @override |
| 986 */ |
| 987 willHide() { |
| 988 this._hideCallback.call(null); |
| 989 } |
997 }; | 990 }; |
998 | 991 |
999 WebInspector.TargetCrashedScreen.prototype = { | |
1000 /** | |
1001 * @override | |
1002 */ | |
1003 willHide: function() | |
1004 { | |
1005 this._hideCallback.call(null); | |
1006 }, | |
1007 | 992 |
1008 __proto__: WebInspector.VBox.prototype | 993 /** |
| 994 * @implements {WebInspector.TargetManager.Observer} |
| 995 * @unrestricted |
| 996 */ |
| 997 WebInspector.BackendSettingsSync = class { |
| 998 constructor() { |
| 999 this._autoAttachSetting = WebInspector.settings.moduleSetting('autoAttachToC
reatedPages'); |
| 1000 this._autoAttachSetting.addChangeListener(this._update, this); |
| 1001 this._disableJavascriptSetting = WebInspector.settings.moduleSetting('javaSc
riptDisabled'); |
| 1002 this._disableJavascriptSetting.addChangeListener(this._update, this); |
| 1003 this._blockedEventsWarningSetting = WebInspector.settings.moduleSetting('blo
ckedEventsWarningEnabled'); |
| 1004 this._blockedEventsWarningSetting.addChangeListener(this._update, this); |
| 1005 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili
ty.Browser); |
| 1006 } |
| 1007 |
| 1008 /** |
| 1009 * @param {!WebInspector.Target} target |
| 1010 */ |
| 1011 _updateTarget(target) { |
| 1012 var blockedEventsWarningThresholdSeconds = 0.1; |
| 1013 target.pageAgent().setBlockedEventsWarningThreshold( |
| 1014 this._blockedEventsWarningSetting.get() ? blockedEventsWarningThresholdS
econds : 0); |
| 1015 target.pageAgent().setAutoAttachToCreatedPages(this._autoAttachSetting.get()
); |
| 1016 target.emulationAgent().setScriptExecutionDisabled(this._disableJavascriptSe
tting.get()); |
| 1017 } |
| 1018 |
| 1019 _update() { |
| 1020 WebInspector.targetManager.targets(WebInspector.Target.Capability.Browser).f
orEach(this._updateTarget, this); |
| 1021 } |
| 1022 |
| 1023 /** |
| 1024 * @param {!WebInspector.Target} target |
| 1025 * @override |
| 1026 */ |
| 1027 targetAdded(target) { |
| 1028 this._updateTarget(target); |
| 1029 target.renderingAgent().setShowViewportSizeOnResize(true); |
| 1030 } |
| 1031 |
| 1032 /** |
| 1033 * @param {!WebInspector.Target} target |
| 1034 * @override |
| 1035 */ |
| 1036 targetRemoved(target) { |
| 1037 } |
1009 }; | 1038 }; |
1010 | 1039 |
1011 /** | 1040 /** |
1012 * @constructor | 1041 * @implements {WebInspector.SettingUI} |
1013 * @implements {WebInspector.TargetManager.Observer} | 1042 * @unrestricted |
1014 */ | 1043 */ |
1015 WebInspector.BackendSettingsSync = function() | 1044 WebInspector.ShowMetricsRulersSettingUI = class { |
1016 { | 1045 /** |
1017 this._autoAttachSetting = WebInspector.settings.moduleSetting("autoAttachToC
reatedPages"); | 1046 * @override |
1018 this._autoAttachSetting.addChangeListener(this._update, this); | 1047 * @return {?Element} |
1019 this._disableJavascriptSetting = WebInspector.settings.moduleSetting("javaSc
riptDisabled"); | 1048 */ |
1020 this._disableJavascriptSetting.addChangeListener(this._update, this); | 1049 settingElement() { |
1021 this._blockedEventsWarningSetting = WebInspector.settings.moduleSetting("blo
ckedEventsWarningEnabled"); | 1050 return WebInspector.SettingsUI.createSettingCheckbox( |
1022 this._blockedEventsWarningSetting.addChangeListener(this._update, this); | 1051 WebInspector.UIString('Show rulers'), WebInspector.moduleSetting('showMe
tricsRulers')); |
1023 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili
ty.Browser); | 1052 } |
1024 }; | |
1025 | |
1026 WebInspector.BackendSettingsSync.prototype = { | |
1027 /** | |
1028 * @param {!WebInspector.Target} target | |
1029 */ | |
1030 _updateTarget: function(target) | |
1031 { | |
1032 var blockedEventsWarningThresholdSeconds = 0.1; | |
1033 target.pageAgent().setBlockedEventsWarningThreshold(this._blockedEventsW
arningSetting.get() ? blockedEventsWarningThresholdSeconds : 0); | |
1034 target.pageAgent().setAutoAttachToCreatedPages(this._autoAttachSetting.g
et()); | |
1035 target.emulationAgent().setScriptExecutionDisabled(this._disableJavascri
ptSetting.get()); | |
1036 }, | |
1037 | |
1038 _update: function() | |
1039 { | |
1040 WebInspector.targetManager.targets(WebInspector.Target.Capability.Browse
r).forEach(this._updateTarget, this); | |
1041 }, | |
1042 | |
1043 /** | |
1044 * @param {!WebInspector.Target} target | |
1045 * @override | |
1046 */ | |
1047 targetAdded: function(target) | |
1048 { | |
1049 this._updateTarget(target); | |
1050 target.renderingAgent().setShowViewportSizeOnResize(true); | |
1051 }, | |
1052 | |
1053 /** | |
1054 * @param {!WebInspector.Target} target | |
1055 * @override | |
1056 */ | |
1057 targetRemoved: function(target) | |
1058 { | |
1059 } | |
1060 }; | |
1061 | |
1062 /** | |
1063 * @constructor | |
1064 * @implements {WebInspector.SettingUI} | |
1065 */ | |
1066 WebInspector.ShowMetricsRulersSettingUI = function() | |
1067 { | |
1068 }; | |
1069 | |
1070 WebInspector.ShowMetricsRulersSettingUI.prototype = { | |
1071 /** | |
1072 * @override | |
1073 * @return {?Element} | |
1074 */ | |
1075 settingElement: function() | |
1076 { | |
1077 return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIStri
ng("Show rulers"), WebInspector.moduleSetting("showMetricsRulers")); | |
1078 } | |
1079 }; | 1053 }; |
1080 | 1054 |
1081 new WebInspector.Main(); | 1055 new WebInspector.Main(); |
OLD | NEW |