diff --git a/resources/unpacked/devtools/BUILD.gn b/resources/unpacked/devtools/BUILD.gn index d22f2bd0a3..8fad27f559 100644 --- a/resources/unpacked/devtools/BUILD.gn +++ b/resources/unpacked/devtools/BUILD.gn @@ -464,12 +464,14 @@ all_devtools_modules = [ "front_end/accessibility/ARIAMetadata.js", "front_end/accessibility/AXBreadcrumbsPane.js", "front_end/animation/animation.js", + "front_end/animation/animation-legacy.js", "front_end/animation/AnimationGroupPreviewUI.js", "front_end/animation/AnimationModel.js", "front_end/animation/AnimationScreenshotPopover.js", "front_end/animation/AnimationTimeline.js", "front_end/animation/AnimationUI.js", "front_end/audits/audits.js", + "front_end/audits/audits-legacy.js", "front_end/audits/AuditsController.js", "front_end/audits/AuditsPanel.js", "front_end/audits/AuditsProtocolService.js", @@ -481,6 +483,7 @@ all_devtools_modules = [ "front_end/audits/lighthouse/report.js", "front_end/audits/RadioSetting.js", "front_end/bindings/bindings.js", + "front_end/bindings/bindings-legacy.js", "front_end/bindings/BlackboxManager.js", "front_end/bindings/BreakpointManager.js", "front_end/bindings/CompilerScriptMapping.js", @@ -499,6 +502,7 @@ all_devtools_modules = [ "front_end/bindings/StylesSourceMapping.js", "front_end/bindings/TempFile.js", "front_end/browser_debugger/browser_debugger.js", + "front_end/browser_debugger/browser_debugger-legacy.js", "front_end/browser_debugger/DOMBreakpointsSidebarPane.js", "front_end/browser_debugger/EventListenerBreakpointsSidebarPane.js", "front_end/browser_debugger/ObjectEventListenersSidebarPane.js", @@ -595,13 +599,16 @@ all_devtools_modules = [ "front_end/console/ConsoleViewMessage.js", "front_end/console/ConsoleViewport.js", "front_end/cookie_table/cookie_table.js", + "front_end/cookie_table/cookie_table-legacy.js", "front_end/cookie_table/CookiesTable.js", "front_end/coverage/coverage.js", + "front_end/coverage/coverage-legacy.js", "front_end/coverage/CoverageDecorationManager.js", "front_end/coverage/CoverageListView.js", "front_end/coverage/CoverageModel.js", "front_end/coverage/CoverageView.js", "front_end/css_overview/css_overview.js", + "front_end/css_overview/css_overview-legacy.js", "front_end/css_overview/CSSOverviewCompletedView.js", "front_end/css_overview/CSSOverviewController.js", "front_end/css_overview/CSSOverviewModel.js", @@ -611,12 +618,14 @@ all_devtools_modules = [ "front_end/css_overview/CSSOverviewStartView.js", "front_end/css_overview/CSSOverviewUnusedDeclarations.js", "front_end/data_grid/data_grid.js", + "front_end/data_grid/data_grid-legacy.js", "front_end/data_grid/DataGrid.js", "front_end/data_grid/ShowMoreDataGridNode.js", "front_end/data_grid/SortableDataGrid.js", "front_end/data_grid/ViewportDataGrid.js", "front_end/diff/diff_match_patch.js", "front_end/diff/diff.js", + "front_end/diff/diff-legacy.js", "front_end/diff/DiffWrapper.js", "front_end/dom_extension/dom_extension.js", "front_end/dom_extension/DOMExtension.js", @@ -653,6 +662,7 @@ all_devtools_modules = [ "front_end/emulation/DevicesSettingsTab.js", "front_end/emulation/EmulatedDevices.js", "front_end/emulation/emulation.js", + "front_end/emulation/emulation-legacy.js", "front_end/emulation/GeolocationsSettingsTab.js", "front_end/emulation/InspectedPagePlaceholder.js", "front_end/emulation/MediaQueryInspector.js", @@ -681,6 +691,7 @@ all_devtools_modules = [ "front_end/formatter_worker/JavaScriptOutline.js", "front_end/formatter_worker/RelaxedJSONParser.js", "front_end/formatter/formatter.js", + "front_end/formatter/formatter-legacy.js", "front_end/formatter/FormatterWorkerPool.js", "front_end/formatter/ScriptFormatter.js", "front_end/formatter/SourceFormatter.js", @@ -1322,12 +1333,14 @@ copied_devtools_modules = [ "$resources_out_dir/accessibility/ARIAMetadata.js", "$resources_out_dir/accessibility/AXBreadcrumbsPane.js", "$resources_out_dir/animation/animation.js", + "$resources_out_dir/animation/animation-legacy.js", "$resources_out_dir/animation/AnimationGroupPreviewUI.js", "$resources_out_dir/animation/AnimationModel.js", "$resources_out_dir/animation/AnimationScreenshotPopover.js", "$resources_out_dir/animation/AnimationTimeline.js", "$resources_out_dir/animation/AnimationUI.js", "$resources_out_dir/audits/audits.js", + "$resources_out_dir/audits/audits-legacy.js", "$resources_out_dir/audits/AuditsController.js", "$resources_out_dir/audits/AuditsPanel.js", "$resources_out_dir/audits/AuditsProtocolService.js", @@ -1339,6 +1352,7 @@ copied_devtools_modules = [ "$resources_out_dir/audits/lighthouse/report.js", "$resources_out_dir/audits/RadioSetting.js", "$resources_out_dir/bindings/bindings.js", + "$resources_out_dir/bindings/bindings-legacy.js", "$resources_out_dir/bindings/BlackboxManager.js", "$resources_out_dir/bindings/BreakpointManager.js", "$resources_out_dir/bindings/CompilerScriptMapping.js", @@ -1357,6 +1371,7 @@ copied_devtools_modules = [ "$resources_out_dir/bindings/StylesSourceMapping.js", "$resources_out_dir/bindings/TempFile.js", "$resources_out_dir/browser_debugger/browser_debugger.js", + "$resources_out_dir/browser_debugger/browser_debugger-legacy.js", "$resources_out_dir/browser_debugger/DOMBreakpointsSidebarPane.js", "$resources_out_dir/browser_debugger/EventListenerBreakpointsSidebarPane.js", "$resources_out_dir/browser_debugger/ObjectEventListenersSidebarPane.js", @@ -1453,13 +1468,16 @@ copied_devtools_modules = [ "$resources_out_dir/console/ConsoleViewMessage.js", "$resources_out_dir/console/ConsoleViewport.js", "$resources_out_dir/cookie_table/cookie_table.js", + "$resources_out_dir/cookie_table/cookie_table-legacy.js", "$resources_out_dir/cookie_table/CookiesTable.js", "$resources_out_dir/coverage/coverage.js", + "$resources_out_dir/coverage/coverage-legacy.js", "$resources_out_dir/coverage/CoverageDecorationManager.js", "$resources_out_dir/coverage/CoverageListView.js", "$resources_out_dir/coverage/CoverageModel.js", "$resources_out_dir/coverage/CoverageView.js", "$resources_out_dir/css_overview/css_overview.js", + "$resources_out_dir/css_overview/css_overview-legacy.js", "$resources_out_dir/css_overview/CSSOverviewCompletedView.js", "$resources_out_dir/css_overview/CSSOverviewController.js", "$resources_out_dir/css_overview/CSSOverviewModel.js", @@ -1469,12 +1487,14 @@ copied_devtools_modules = [ "$resources_out_dir/css_overview/CSSOverviewStartView.js", "$resources_out_dir/css_overview/CSSOverviewUnusedDeclarations.js", "$resources_out_dir/data_grid/data_grid.js", + "$resources_out_dir/data_grid/data_grid-legacy.js", "$resources_out_dir/data_grid/DataGrid.js", "$resources_out_dir/data_grid/ShowMoreDataGridNode.js", "$resources_out_dir/data_grid/SortableDataGrid.js", "$resources_out_dir/data_grid/ViewportDataGrid.js", "$resources_out_dir/diff/diff_match_patch.js", "$resources_out_dir/diff/diff.js", + "$resources_out_dir/diff/diff-legacy.js", "$resources_out_dir/diff/DiffWrapper.js", "$resources_out_dir/dom_extension/dom_extension.js", "$resources_out_dir/dom_extension/DOMExtension.js", @@ -1511,6 +1531,7 @@ copied_devtools_modules = [ "$resources_out_dir/emulation/DevicesSettingsTab.js", "$resources_out_dir/emulation/EmulatedDevices.js", "$resources_out_dir/emulation/emulation.js", + "$resources_out_dir/emulation/emulation-legacy.js", "$resources_out_dir/emulation/GeolocationsSettingsTab.js", "$resources_out_dir/emulation/InspectedPagePlaceholder.js", "$resources_out_dir/emulation/MediaQueryInspector.js", @@ -1525,6 +1546,7 @@ copied_devtools_modules = [ "$resources_out_dir/extensions/ExtensionTraceProvider.js", "$resources_out_dir/extensions/ExtensionView.js", "$resources_out_dir/formatter/formatter.js", + "$resources_out_dir/formatter/formatter-legacy.js", "$resources_out_dir/formatter/FormatterWorkerPool.js", "$resources_out_dir/formatter/ScriptFormatter.js", "$resources_out_dir/formatter/SourceFormatter.js", @@ -2215,8 +2237,11 @@ action("generate_devtools_grd") { "front_end", ] - args = ["--file-list", "{{response_file_name}}", "--relative_path_dirs" ] + - rebase_path(relative_path_dirs, root_build_dir) + + args = [ + "--file-list", + "{{response_file_name}}", + "--relative_path_dirs", + ] + rebase_path(relative_path_dirs, root_build_dir) + [ "--images", rebase_path("front_end/Images", root_build_dir), diff --git a/resources/unpacked/devtools/DEPS b/resources/unpacked/devtools/DEPS index cfbb121c6c..0d798ae429 100644 --- a/resources/unpacked/devtools/DEPS +++ b/resources/unpacked/devtools/DEPS @@ -10,10 +10,10 @@ vars = { 'buildtools_revision': '8d2132841536523249669813b928e29144d487f9', 'depot_tools_url': 'https://chromium.googlesource.com/chromium/tools/depot_tools.git', - 'depot_tools_revision': '081c5b5979689733fe4bd1a7618943a061cc353f', + 'depot_tools_revision': '13928b7e7f1a37e5e70cae53aba089f88bbbccfc', 'inspector_protocol_url': 'https://chromium.googlesource.com/deps/inspector_protocol', - 'inspector_protocol_revision': 'dee0c0c65cc2df6284e75ae9fca083dc604c9fca', + 'inspector_protocol_revision': '32a87e9a751db8f2903532134a7c8fc6932620ba', 'clang_format_url': 'https://chromium.googlesource.com/chromium/llvm-project/cfe/tools/clang-format.git', 'clang_format_revision': '96636aa0e9f047f17447f2d45a094d0b59ed7917', diff --git a/resources/unpacked/devtools/front_end/animation/AnimationGroupPreviewUI.js b/resources/unpacked/devtools/front_end/animation/AnimationGroupPreviewUI.js index 54f0e3305f..aea8a8af9b 100644 --- a/resources/unpacked/devtools/front_end/animation/AnimationGroupPreviewUI.js +++ b/resources/unpacked/devtools/front_end/animation/AnimationGroupPreviewUI.js @@ -1,12 +1,16 @@ // Copyright (c) 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + +import {AnimationGroup} from './AnimationModel.js'; // eslint-disable-line no-unused-vars +import {AnimationUI} from './AnimationUI.js'; + /** * @unrestricted */ -export default class AnimationGroupPreviewUI { +export class AnimationGroupPreviewUI { /** - * @param {!Animation.AnimationModel.AnimationGroup} model + * @param {!AnimationGroup} model */ constructor(model) { this._model = model; @@ -68,19 +72,7 @@ export default class AnimationGroupPreviewUI { const y = Math.floor(this._viewBoxHeight / Math.max(6, numberOfAnimations) * i + 1); line.setAttribute('y1', y); line.setAttribute('y2', y); - line.style.stroke = Animation.AnimationUI.Color(this._model.animations()[i]); + line.style.stroke = AnimationUI.Color(this._model.animations()[i]); } } } - -/* Legacy exported object */ -self.Animation = self.Animation || {}; - -/* Legacy exported object */ -Animation = Animation || {}; - -/** - * @constructor - * @unrestricted - */ -Animation.AnimationGroupPreviewUI = AnimationGroupPreviewUI; diff --git a/resources/unpacked/devtools/front_end/animation/AnimationModel.js b/resources/unpacked/devtools/front_end/animation/AnimationModel.js index f765e27a02..b5d4a81b7f 100644 --- a/resources/unpacked/devtools/front_end/animation/AnimationModel.js +++ b/resources/unpacked/devtools/front_end/animation/AnimationModel.js @@ -5,7 +5,7 @@ /** * @unrestricted */ -export default class AnimationModel extends SDK.SDKModel { +export class AnimationModel extends SDK.SDKModel { /** * @param {!SDK.Target} target */ @@ -13,10 +13,10 @@ export default class AnimationModel extends SDK.SDKModel { super(target); this._runtimeModel = /** @type {!SDK.RuntimeModel} */ (target.model(SDK.RuntimeModel)); this._agent = target.animationAgent(); - target.registerAnimationDispatcher(new Animation.AnimationDispatcher(this)); - /** @type {!Map.} */ + target.registerAnimationDispatcher(new AnimationDispatcher(this)); + /** @type {!Map.} */ this._animationsById = new Map(); - /** @type {!Map.} */ + /** @type {!Map.} */ this._animationGroups = new Map(); /** @type {!Array.} */ this._pendingAnimations = []; @@ -88,7 +88,7 @@ export default class AnimationModel extends SDK.SDKModel { } /** - * @param {!Animation.AnimationModel.AnimationGroup} incomingGroup + * @param {!AnimationGroup} incomingGroup * @return {boolean} */ _matchExistingGroups(incomingGroup) { @@ -112,7 +112,7 @@ export default class AnimationModel extends SDK.SDKModel { } /** - * @return {!Animation.AnimationModel.AnimationGroup} + * @return {!AnimationGroup} */ _createGroupFromPendingAnimations() { console.assert(this._pendingAnimations.length); @@ -185,7 +185,7 @@ export const Events = { */ export class AnimationImpl { /** - * @param {!Animation.AnimationModel} animationModel + * @param {!AnimationModel} animationModel * @param {!Protocol.Animation.Animation} payload */ constructor(animationModel, payload) { @@ -196,9 +196,9 @@ export class AnimationImpl { } /** - * @param {!Animation.AnimationModel} animationModel + * @param {!AnimationModel} animationModel * @param {!Protocol.Animation.Animation} payload - * @return {!Animation.AnimationModel.Animation} + * @return {!AnimationImpl} */ static parsePayload(animationModel, payload) { return new AnimationImpl(animationModel, payload); @@ -287,21 +287,22 @@ export class AnimationImpl { } /** - * @return {!Animation.AnimationModel.AnimationEffect} + * @return {!AnimationEffect} */ source() { return this._source; } /** - * @return {!Animation.AnimationModel.Animation.Type} + * @return {!Type} */ type() { - return /** @type {!Animation.AnimationModel.Animation.Type} */ (this._payload.type); + return ( + /** @type {!Type} */ (this._payload.type)); } /** - * @param {!Animation.AnimationModel.Animation} animation + * @param {!AnimationImpl} animation * @return {boolean} */ overlaps(animation) { @@ -374,7 +375,7 @@ export const Type = { */ export class AnimationEffect { /** - * @param {!Animation.AnimationModel} animationModel + * @param {!AnimationModel} animationModel * @param {!Protocol.Animation.AnimationEffect} payload */ constructor(animationModel, payload) { @@ -465,7 +466,7 @@ export class AnimationEffect { } /** - * @return {?Animation.AnimationModel.KeyframesRule} + * @return {?KeyframesRule} */ keyframesRule() { return this._keyframesRule; @@ -510,7 +511,7 @@ export class KeyframesRule { } /** - * @return {!Array.} + * @return {!Array.} */ keyframes() { return this._keyframes; @@ -563,9 +564,9 @@ export class KeyframeStyle { */ export class AnimationGroup { /** - * @param {!Animation.AnimationModel} animationModel + * @param {!AnimationModel} animationModel * @param {string} id - * @param {!Array.} animations + * @param {!Array.} animations */ constructor(animationModel, id, animations) { this._animationModel = animationModel; @@ -584,7 +585,7 @@ export class AnimationGroup { } /** - * @return {!Array.} + * @return {!Array.} */ animations() { return this._animations; @@ -600,7 +601,7 @@ export class AnimationGroup { */ _animationIds() { /** - * @param {!Animation.AnimationModel.Animation} animation + * @param {!AnimationImpl} animation * @return {string} */ function extractId(animation) { @@ -667,12 +668,12 @@ export class AnimationGroup { } /** - * @param {!Animation.AnimationModel.AnimationGroup} group + * @param {!AnimationGroup} group * @return {boolean} */ _matches(group) { /** - * @param {!Animation.AnimationModel.Animation} anim + * @param {!AnimationImpl} anim * @return {string} */ function extractId(anim) { @@ -697,7 +698,7 @@ export class AnimationGroup { } /** - * @param {!Animation.AnimationModel.AnimationGroup} group + * @param {!AnimationGroup} group */ _update(group) { this._animationModel._releaseAnimations(this._animationIds()); @@ -757,7 +758,7 @@ export class AnimationDispatcher { */ export class ScreenshotCapture { /** - * @param {!Animation.AnimationModel} animationModel + * @param {!AnimationModel} animationModel * @param {!SDK.ScreenCaptureModel} screenCaptureModel */ constructor(animationModel, screenCaptureModel) { @@ -829,58 +830,3 @@ export class ScreenshotCapture { } SDK.SDKModel.register(AnimationModel, SDK.Target.Capability.DOM, false); - -/* Legacy exported object */ -self.Animation = self.Animation || {}; - -/* Legacy exported object */ -Animation = Animation || {}; - -/** - * @constructor - */ -Animation.AnimationModel = AnimationModel; - -/** @enum {symbol} */ -Animation.AnimationModel.Events = Events; - -/** - * @constructor - */ -Animation.AnimationModel.Animation = AnimationImpl; - -/** @enum {string} */ -Animation.AnimationModel.Animation.Type = Type; - -/** - * @constructor - */ -Animation.AnimationModel.AnimationEffect = AnimationEffect; - -/** - * @constructor - */ -Animation.AnimationModel.KeyframesRule = KeyframesRule; - -/** - * @constructor - */ -Animation.AnimationModel.KeyframeStyle = KeyframeStyle; - -/** - * @constructor - */ -Animation.AnimationModel.AnimationGroup = AnimationGroup; - -/** - * @constructor - */ -Animation.AnimationModel.ScreenshotCapture = ScreenshotCapture; - -/** @typedef {{ endTime: number, screenshots: !Array.}} */ -Animation.AnimationModel.ScreenshotCapture.Request; - -/** - * @constructor - */ -Animation.AnimationDispatcher = AnimationDispatcher; diff --git a/resources/unpacked/devtools/front_end/animation/AnimationScreenshotPopover.js b/resources/unpacked/devtools/front_end/animation/AnimationScreenshotPopover.js index 82596f1159..d4b1d8af14 100644 --- a/resources/unpacked/devtools/front_end/animation/AnimationScreenshotPopover.js +++ b/resources/unpacked/devtools/front_end/animation/AnimationScreenshotPopover.js @@ -4,7 +4,7 @@ /** * @unrestricted */ -export default class AnimationScreenshotPopover extends UI.VBox { +export class AnimationScreenshotPopover extends UI.VBox { /** * @param {!Array.} images */ @@ -60,15 +60,3 @@ export default class AnimationScreenshotPopover extends UI.VBox { this._progressBar.style.width = (this._currentFrame % numFrames + 1) / numFrames * 100 + '%'; } } - -/* Legacy exported object */ -self.Animation = self.Animation || {}; - -/* Legacy exported object */ -Animation = Animation || {}; - -/** - * @unrestricted - * @constructor - */ -Animation.AnimationScreenshotPopover = AnimationScreenshotPopover; diff --git a/resources/unpacked/devtools/front_end/animation/AnimationTimeline.js b/resources/unpacked/devtools/front_end/animation/AnimationTimeline.js index e42a1b3c23..29981b1457 100644 --- a/resources/unpacked/devtools/front_end/animation/AnimationTimeline.js +++ b/resources/unpacked/devtools/front_end/animation/AnimationTimeline.js @@ -1,11 +1,17 @@ // Copyright (c) 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + +import {AnimationGroupPreviewUI} from './AnimationGroupPreviewUI.js'; +import {AnimationEffect, AnimationGroup, AnimationImpl, AnimationModel, Events} from './AnimationModel.js'; // eslint-disable-line no-unused-vars +import {AnimationScreenshotPopover} from './AnimationScreenshotPopover.js'; +import {AnimationUI} from './AnimationUI.js'; + /** - * @implements {SDK.SDKModelObserver} + * @implements {SDK.SDKModelObserver} * @unrestricted */ -export default class AnimationTimeline extends UI.VBox { +export class AnimationTimeline extends UI.VBox { constructor() { super(true); this.registerRequiredCSS('animation/animationTimeline.css'); @@ -23,17 +29,17 @@ export default class AnimationTimeline extends UI.VBox { /** @const */ this._defaultDuration = 100; this._duration = this._defaultDuration; /** @const */ this._timelineControlsWidth = 150; - /** @type {!Map.} */ + /** @type {!Map.} */ this._nodesMap = new Map(); this._uiAnimations = []; this._groupBuffer = []; - /** @type {!Map.} */ + /** @type {!Map.} */ this._previewMap = new Map(); this._symbol = Symbol('animationTimeline'); - /** @type {!Map.} */ + /** @type {!Map.} */ this._animationsMap = new Map(); SDK.targetManager.addModelListener(SDK.DOMModel, SDK.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); - SDK.targetManager.observeModels(Animation.AnimationModel, this); + SDK.targetManager.observeModels(AnimationModel, this); UI.context.addFlavorChangeListener(SDK.DOMNode, this._nodeChanged, this); } @@ -41,7 +47,7 @@ export default class AnimationTimeline extends UI.VBox { * @override */ wasShown() { - for (const animationModel of SDK.targetManager.models(Animation.AnimationModel)) { + for (const animationModel of SDK.targetManager.models(AnimationModel)) { this._addEventListeners(animationModel); } } @@ -50,7 +56,7 @@ export default class AnimationTimeline extends UI.VBox { * @override */ willHide() { - for (const animationModel of SDK.targetManager.models(Animation.AnimationModel)) { + for (const animationModel of SDK.targetManager.models(AnimationModel)) { this._removeEventListeners(animationModel); } this._popoverHelper.hidePopover(); @@ -58,7 +64,7 @@ export default class AnimationTimeline extends UI.VBox { /** * @override - * @param {!Animation.AnimationModel} animationModel + * @param {!AnimationModel} animationModel */ modelAdded(animationModel) { if (this.isShowing()) { @@ -68,29 +74,27 @@ export default class AnimationTimeline extends UI.VBox { /** * @override - * @param {!Animation.AnimationModel} animationModel + * @param {!AnimationModel} animationModel */ modelRemoved(animationModel) { this._removeEventListeners(animationModel); } /** - * @param {!Animation.AnimationModel} animationModel + * @param {!AnimationModel} animationModel */ _addEventListeners(animationModel) { animationModel.ensureEnabled(); - animationModel.addEventListener( - Animation.AnimationModel.Events.AnimationGroupStarted, this._animationGroupStarted, this); - animationModel.addEventListener(Animation.AnimationModel.Events.ModelReset, this._reset, this); + animationModel.addEventListener(Events.AnimationGroupStarted, this._animationGroupStarted, this); + animationModel.addEventListener(Events.ModelReset, this._reset, this); } /** - * @param {!Animation.AnimationModel} animationModel + * @param {!AnimationModel} animationModel */ _removeEventListeners(animationModel) { - animationModel.removeEventListener( - Animation.AnimationModel.Events.AnimationGroupStarted, this._animationGroupStarted, this); - animationModel.removeEventListener(Animation.AnimationModel.Events.ModelReset, this._reset, this); + animationModel.removeEventListener(Events.AnimationGroupStarted, this._animationGroupStarted, this); + animationModel.removeEventListener(Events.ModelReset, this._reset, this); } _nodeChanged() { @@ -125,7 +129,7 @@ export default class AnimationTimeline extends UI.VBox { const playbackRateControl = toolbarContainer.createChild('div', 'animation-playback-rate-control'); playbackRateControl.addEventListener('keydown', this._handlePlaybackRateControlKeyDown.bind(this)); this._playbackRateButtons = []; - for (const playbackRate of Animation.AnimationTimeline.GlobalPlaybackRates) { + for (const playbackRate of GlobalPlaybackRates) { const button = playbackRateControl.createChild('button', 'animation-playback-rate-button'); button.textContent = playbackRate ? ls`${playbackRate * 100}%` : ls`Pause`; button.playbackRate = playbackRate; @@ -148,7 +152,7 @@ export default class AnimationTimeline extends UI.VBox { const toolbar = new UI.Toolbar('animation-controls-toolbar', controls); this._controlButton = new UI.ToolbarToggle(ls`Replay timeline`, 'largeicon-replay-animation'); - this._controlState = Animation.AnimationTimeline._ControlState.Replay; + this._controlState = _ControlState.Replay; this._controlButton.setToggled(true); this._controlButton.addEventListener(UI.ToolbarButton.Events.Click, this._controlButtonToggle.bind(this)); toolbar.appendToolbarItem(this._controlButton); @@ -236,7 +240,7 @@ export default class AnimationTimeline extends UI.VBox { * @param {!Array.} screenshots */ function onFirstScreenshotLoaded(screenshots) { - new Animation.AnimationScreenshotPopover(screenshots).show(popover.contentElement); + new AnimationScreenshotPopover(screenshots).show(popover.contentElement); fulfill(true); } } @@ -255,7 +259,7 @@ export default class AnimationTimeline extends UI.VBox { */ _setPlaybackRate(playbackRate) { this._playbackRate = playbackRate; - for (const animationModel of SDK.targetManager.models(Animation.AnimationModel)) { + for (const animationModel of SDK.targetManager.models(AnimationModel)) { animationModel.setPlaybackRate(this._allPaused ? 0 : this._playbackRate); } Host.userMetrics.actionTaken(Host.UserMetrics.Action.AnimationsPlaybackRateChanged); @@ -275,9 +279,9 @@ export default class AnimationTimeline extends UI.VBox { } _controlButtonToggle() { - if (this._controlState === Animation.AnimationTimeline._ControlState.Play) { + if (this._controlState === _ControlState.Play) { this._togglePause(false); - } else if (this._controlState === Animation.AnimationTimeline._ControlState.Replay) { + } else if (this._controlState === _ControlState.Replay) { this._replay(); } else { this._togglePause(true); @@ -287,17 +291,17 @@ export default class AnimationTimeline extends UI.VBox { _updateControlButton() { this._controlButton.setEnabled(!!this._selectedGroup); if (this._selectedGroup && this._selectedGroup.paused()) { - this._controlState = Animation.AnimationTimeline._ControlState.Play; + this._controlState = _ControlState.Play; this._controlButton.setToggled(true); this._controlButton.setTitle(ls`Play timeline`); this._controlButton.setGlyph('largeicon-play-animation'); } else if (!this._scrubberPlayer || this._scrubberPlayer.currentTime >= this.duration()) { - this._controlState = Animation.AnimationTimeline._ControlState.Replay; + this._controlState = _ControlState.Replay; this._controlButton.setToggled(true); this._controlButton.setTitle(ls`Replay timeline`); this._controlButton.setGlyph('largeicon-replay-animation'); } else { - this._controlState = Animation.AnimationTimeline._ControlState.Pause; + this._controlState = _ControlState.Pause; this._controlButton.setToggled(false); this._controlButton.setTitle(ls`Pause timeline`); this._controlButton.setGlyph('largeicon-pause-animation'); @@ -385,15 +389,15 @@ export default class AnimationTimeline extends UI.VBox { * @param {!Common.Event} event */ _animationGroupStarted(event) { - this._addAnimationGroup(/** @type {!Animation.AnimationModel.AnimationGroup} */ (event.data)); + this._addAnimationGroup(/** @type {!AnimationGroup} */ (event.data)); } /** - * @param {!Animation.AnimationModel.AnimationGroup} group + * @param {!AnimationGroup} group */ _addAnimationGroup(group) { /** - * @param {!Animation.AnimationModel.AnimationGroup} left + * @param {!AnimationGroup} left * @param {!Animation.AnimationModel.AnimationGroup} right */ function startTimeComparator(left, right) { @@ -422,7 +426,7 @@ export default class AnimationTimeline extends UI.VBox { g.release(); } // Generate preview - const preview = new Animation.AnimationGroupPreviewUI(group); + const preview = new AnimationGroupPreviewUI(group); this._groupBuffer.push(group); this._previewMap.set(group, preview); this._previewContainer.appendChild(preview.element); @@ -435,7 +439,7 @@ export default class AnimationTimeline extends UI.VBox { } /** - * @param {!Animation.AnimationModel.AnimationGroup} group + * @param {!AnimationGroup} group * @param {!Event} event */ _handleAnimationGroupKeyDown(group, event) { @@ -459,7 +463,7 @@ export default class AnimationTimeline extends UI.VBox { } /** - * @param {!Animation.AnimationModel.AnimationGroup} group + * @param {!AnimationGroup} group * @param {!EventTarget|null} target * @param {boolean=} focusPrevious */ @@ -476,7 +480,7 @@ export default class AnimationTimeline extends UI.VBox { } /** - * @param {!Animation.AnimationModel.AnimationGroup} group + * @param {!AnimationGroup} group * @param {!Event} event */ _removeAnimationGroup(group, event) { @@ -506,13 +510,13 @@ export default class AnimationTimeline extends UI.VBox { } /** - * @param {!Animation.AnimationModel.AnimationGroup} group + * @param {!AnimationGroup} group */ _selectAnimationGroup(group) { /** - * @param {!Animation.AnimationGroupPreviewUI} ui - * @param {!Animation.AnimationModel.AnimationGroup} group - * @this {!Animation.AnimationTimeline} + * @param {!AnimationGroupPreviewUI} ui + * @param {!AnimationGroup} group + * @this {!AnimationTimeline} */ function applySelectionClass(ui, group) { ui.element.classList.toggle('selected', this._selectedGroup === group); @@ -537,12 +541,12 @@ export default class AnimationTimeline extends UI.VBox { } /** - * @param {!Animation.AnimationModel.Animation} animation + * @param {!AnimationImpl} animation */ _addAnimation(animation) { /** * @param {?SDK.DOMNode} node - * @this {Animation.AnimationTimeline} + * @this {AnimationTimeline} */ function nodeResolved(node) { nodeUI.nodeResolved(node); @@ -554,12 +558,12 @@ export default class AnimationTimeline extends UI.VBox { let nodeUI = this._nodesMap.get(animation.source().backendNodeId()); if (!nodeUI) { - nodeUI = new Animation.AnimationTimeline.NodeUI(animation.source()); + nodeUI = new NodeUI(animation.source()); this._animationsContainer.appendChild(nodeUI.element); this._nodesMap.set(animation.source().backendNodeId(), nodeUI); } const nodeRow = nodeUI.createNewRow(); - const uiAnimation = new Animation.AnimationUI(animation, this, nodeRow); + const uiAnimation = new AnimationUI(animation, this, nodeRow); animation.source().deferredNode().resolve(nodeResolved.bind(this)); this._uiAnimations.push(uiAnimation); this._animationsMap.set(animation.id(), animation); @@ -649,7 +653,7 @@ export default class AnimationTimeline extends UI.VBox { } /** - * @param {!Animation.AnimationModel.Animation} animation + * @param {!AnimationImpl} animation * @return {boolean} */ _resizeWindow(animation) { @@ -792,7 +796,7 @@ export const _ControlState = { */ export class NodeUI { /** - * @param {!Animation.AnimationModel.AnimationEffect} animationEffect + * @param {!AnimationEffect} animationEffect */ constructor(animationEffect) { this.element = createElementWithClass('div', 'animation-node-row'); @@ -858,47 +862,17 @@ export class StepTimingFunction { /** * @param {string} text - * @return {?Animation.AnimationTimeline.StepTimingFunction} + * @return {?StepTimingFunction} */ static parse(text) { let match = text.match(/^steps\((\d+), (start|middle)\)$/); if (match) { - return new Animation.AnimationTimeline.StepTimingFunction(parseInt(match[1], 10), match[2]); + return new StepTimingFunction(parseInt(match[1], 10), match[2]); } match = text.match(/^steps\((\d+)\)$/); if (match) { - return new Animation.AnimationTimeline.StepTimingFunction(parseInt(match[1], 10), 'end'); + return new StepTimingFunction(parseInt(match[1], 10), 'end'); } return null; } } - -/* Legacy exported object */ -self.Animation = self.Animation || {}; - -/* Legacy exported object */ -Animation = Animation || {}; - -/** - * @implements {SDK.SDKModelObserver} - * @constructor - * @unrestricted - */ -Animation.AnimationTimeline = AnimationTimeline; - -Animation.AnimationTimeline.GlobalPlaybackRates = GlobalPlaybackRates; - -/** @enum {string} */ -Animation.AnimationTimeline._ControlState = _ControlState; - -/** - * @unrestricted - * @constructor - */ -Animation.AnimationTimeline.NodeUI = NodeUI; - -/** - * @unrestricted - * @constructor - */ -Animation.AnimationTimeline.StepTimingFunction = StepTimingFunction; diff --git a/resources/unpacked/devtools/front_end/animation/AnimationUI.js b/resources/unpacked/devtools/front_end/animation/AnimationUI.js index 8b508c2411..4b911b86ed 100644 --- a/resources/unpacked/devtools/front_end/animation/AnimationUI.js +++ b/resources/unpacked/devtools/front_end/animation/AnimationUI.js @@ -1,13 +1,17 @@ // Copyright (c) 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + +import {AnimationImpl} from './AnimationModel.js'; // eslint-disable-line no-unused-vars +import {AnimationTimeline, StepTimingFunction} from './AnimationTimeline.js'; // eslint-disable-line no-unused-vars + /** * @unrestricted */ -export default class AnimationUI { +export class AnimationUI { /** - * @param {!Animation.AnimationModel.Animation} animation - * @param {!Animation.AnimationTimeline} timeline + * @param {!AnimationImpl} animation + * @param {!AnimationTimeline} timeline * @param {!Element} parentElement */ constructor(animation, timeline, parentElement) { @@ -23,34 +27,33 @@ export default class AnimationUI { this._nameElement.textContent = this._animation.name(); this._svg = parentElement.createSVGChild('svg', 'animation-ui'); - this._svg.setAttribute('height', Animation.AnimationUI.Options.AnimationSVGHeight); - this._svg.style.marginLeft = '-' + Animation.AnimationUI.Options.AnimationMargin + 'px'; + this._svg.setAttribute('height', Options.AnimationSVGHeight); + this._svg.style.marginLeft = '-' + Options.AnimationMargin + 'px'; this._svg.addEventListener('contextmenu', this._onContextMenu.bind(this)); this._activeIntervalGroup = this._svg.createSVGChild('g'); UI.installDragHandle( - this._activeIntervalGroup, this._mouseDown.bind(this, Animation.AnimationUI.MouseEvents.AnimationDrag, null), + this._activeIntervalGroup, this._mouseDown.bind(this, MouseEvents.AnimationDrag, null), this._mouseMove.bind(this), this._mouseUp.bind(this), '-webkit-grabbing', '-webkit-grab'); /** @type {!Array.<{group: ?Element, animationLine: ?Element, keyframePoints: !Object., keyframeRender: !Object.}>} */ this._cachedElements = []; this._movementInMs = 0; - this._color = Animation.AnimationUI.Color(this._animation); + this._color = AnimationUI.Color(this._animation); } /** - * @param {!Animation.AnimationModel.Animation} animation + * @param {!AnimationImpl} animation * @return {string} */ static Color(animation) { - const names = Object.keys(Animation.AnimationUI.Colors); - const color = - Animation.AnimationUI.Colors[names[String.hashCode(animation.name() || animation.id()) % names.length]]; + const names = Object.keys(Colors); + const color = Colors[names[String.hashCode(animation.name() || animation.id()) % names.length]]; return color.asString(Common.Color.Format.RGB); } /** - * @return {!Animation.AnimationModel.Animation} + * @return {!AnimationImpl} */ animation() { return this._animation; @@ -69,9 +72,9 @@ export default class AnimationUI { */ _createLine(parentElement, className) { const line = parentElement.createSVGChild('line', className); - line.setAttribute('x1', Animation.AnimationUI.Options.AnimationMargin); - line.setAttribute('y1', Animation.AnimationUI.Options.AnimationHeight); - line.setAttribute('y2', Animation.AnimationUI.Options.AnimationHeight); + line.setAttribute('x1', Options.AnimationMargin); + line.setAttribute('y1', Options.AnimationHeight); + line.setAttribute('y2', Options.AnimationHeight); line.style.stroke = this._color; return line; } @@ -86,8 +89,7 @@ export default class AnimationUI { cache.animationLine = this._createLine(parentElement, 'animation-line'); } cache.animationLine.setAttribute( - 'x2', - (this._duration() * this._timeline.pixelMsRatio() + Animation.AnimationUI.Options.AnimationMargin).toFixed(2)); + 'x2', (this._duration() * this._timeline.pixelMsRatio() + Options.AnimationMargin).toFixed(2)); } /** @@ -100,7 +102,7 @@ export default class AnimationUI { } const fill = this._animation.source().fill(); this._delayLine.classList.toggle('animation-fill', fill === 'backwards' || fill === 'both'); - const margin = Animation.AnimationUI.Options.AnimationMargin; + const margin = Options.AnimationMargin; this._delayLine.setAttribute('x1', margin); this._delayLine.setAttribute('x2', (this._delay() * this._timeline.pixelMsRatio() + margin).toFixed(2)); const forwardsFill = fill === 'forwards' || fill === 'both'; @@ -131,9 +133,9 @@ export default class AnimationUI { const circle = parentElement.createSVGChild('circle', keyframeIndex <= 0 ? 'animation-endpoint' : 'animation-keyframe-point'); circle.setAttribute('cx', x.toFixed(2)); - circle.setAttribute('cy', Animation.AnimationUI.Options.AnimationHeight); + circle.setAttribute('cy', Options.AnimationHeight); circle.style.stroke = this._color; - circle.setAttribute('r', Animation.AnimationUI.Options.AnimationMargin / 2); + circle.setAttribute('r', Options.AnimationMargin / 2); if (keyframeIndex <= 0) { circle.style.fill = this._color; @@ -147,11 +149,11 @@ export default class AnimationUI { let eventType; if (keyframeIndex === 0) { - eventType = Animation.AnimationUI.MouseEvents.StartEndpointMove; + eventType = MouseEvents.StartEndpointMove; } else if (keyframeIndex === -1) { - eventType = Animation.AnimationUI.MouseEvents.FinishEndpointMove; + eventType = MouseEvents.FinishEndpointMove; } else { - eventType = Animation.AnimationUI.MouseEvents.KeyframeMove; + eventType = MouseEvents.KeyframeMove; } UI.installDragHandle( circle, this._mouseDown.bind(this, eventType, keyframeIndex), this._mouseMove.bind(this), @@ -176,8 +178,8 @@ export default class AnimationUI { const line = parentElement.createSVGChild('line'); line.setAttribute('x1', x); line.setAttribute('x2', x); - line.setAttribute('y1', Animation.AnimationUI.Options.AnimationMargin); - line.setAttribute('y2', Animation.AnimationUI.Options.AnimationHeight); + line.setAttribute('y1', Options.AnimationMargin); + line.setAttribute('y2', Options.AnimationHeight); line.style.stroke = strokeColor; } @@ -199,7 +201,7 @@ export default class AnimationUI { group.style.fill = this._color; InlineEditor.BezierUI.drawVelocityChart(bezier, group, width); } else { - const stepFunction = Animation.AnimationTimeline.StepTimingFunction.parse(easing); + const stepFunction = StepTimingFunction.parse(easing); group.removeChildren(); /** @const */ const offsetMap = {'start': 0, 'middle': 0.5, 'end': 1}; /** @const */ const offsetWeight = offsetMap[stepFunction.stepAtPosition]; @@ -210,15 +212,14 @@ export default class AnimationUI { } redraw() { - const maxWidth = this._timeline.width() - Animation.AnimationUI.Options.AnimationMargin; + const maxWidth = this._timeline.width() - Options.AnimationMargin; - this._svg.setAttribute('width', (maxWidth + 2 * Animation.AnimationUI.Options.AnimationMargin).toFixed(2)); + this._svg.setAttribute('width', (maxWidth + 2 * Options.AnimationMargin).toFixed(2)); this._activeIntervalGroup.style.transform = 'translateX(' + (this._delay() * this._timeline.pixelMsRatio()).toFixed(2) + 'px)'; - this._nameElement.style.transform = 'translateX(' + - (this._delay() * this._timeline.pixelMsRatio() + Animation.AnimationUI.Options.AnimationMargin).toFixed(2) + - 'px)'; + this._nameElement.style.transform = + 'translateX(' + (this._delay() * this._timeline.pixelMsRatio() + Options.AnimationMargin).toFixed(2) + 'px)'; this._nameElement.style.width = (this._duration() * this._timeline.pixelMsRatio()).toFixed(2) + 'px'; this._drawDelayLine(this._svg); @@ -249,12 +250,12 @@ export default class AnimationUI { } this._drawAnimationLine(0, this._activeIntervalGroup); this._renderKeyframe( - 0, 0, this._activeIntervalGroup, Animation.AnimationUI.Options.AnimationMargin, - this._duration() * this._timeline.pixelMsRatio(), this._animation.source().easing()); - this._drawPoint(0, this._activeIntervalGroup, Animation.AnimationUI.Options.AnimationMargin, 0, true); + 0, 0, this._activeIntervalGroup, Options.AnimationMargin, this._duration() * this._timeline.pixelMsRatio(), + this._animation.source().easing()); + this._drawPoint(0, this._activeIntervalGroup, Options.AnimationMargin, 0, true); this._drawPoint( - 0, this._activeIntervalGroup, - this._duration() * this._timeline.pixelMsRatio() + Animation.AnimationUI.Options.AnimationMargin, -1, true); + 0, this._activeIntervalGroup, this._duration() * this._timeline.pixelMsRatio() + Options.AnimationMargin, -1, + true); } /** @@ -272,8 +273,7 @@ export default class AnimationUI { this._drawAnimationLine(iteration, group); console.assert(this._keyframes.length > 1); for (let i = 0; i < this._keyframes.length - 1; i++) { - const leftDistance = this._offset(i) * this._duration() * this._timeline.pixelMsRatio() + - Animation.AnimationUI.Options.AnimationMargin; + const leftDistance = this._offset(i) * this._duration() * this._timeline.pixelMsRatio() + Options.AnimationMargin; const width = this._duration() * (this._offset(i + 1) - this._offset(i)) * this._timeline.pixelMsRatio(); this._renderKeyframe(iteration, i, group, leftDistance, width, this._keyframes[i].easing()); if (i || (!i && iteration === 0)) { @@ -281,8 +281,7 @@ export default class AnimationUI { } } this._drawPoint( - iteration, group, - this._duration() * this._timeline.pixelMsRatio() + Animation.AnimationUI.Options.AnimationMargin, -1, + iteration, group, this._duration() * this._timeline.pixelMsRatio() + Options.AnimationMargin, -1, iteration === 0); } @@ -291,8 +290,7 @@ export default class AnimationUI { */ _delay() { let delay = this._animation.source().delay(); - if (this._mouseEventType === Animation.AnimationUI.MouseEvents.AnimationDrag || - this._mouseEventType === Animation.AnimationUI.MouseEvents.StartEndpointMove) { + if (this._mouseEventType === MouseEvents.AnimationDrag || this._mouseEventType === MouseEvents.StartEndpointMove) { delay += this._movementInMs; } // FIXME: add support for negative start delay @@ -304,9 +302,9 @@ export default class AnimationUI { */ _duration() { let duration = this._animation.source().duration(); - if (this._mouseEventType === Animation.AnimationUI.MouseEvents.FinishEndpointMove) { + if (this._mouseEventType === MouseEvents.FinishEndpointMove) { duration += this._movementInMs; - } else if (this._mouseEventType === Animation.AnimationUI.MouseEvents.StartEndpointMove) { + } else if (this._mouseEventType === MouseEvents.StartEndpointMove) { duration -= Math.max(this._movementInMs, -this._animation.source().delay()); } // Cannot have negative delay return Math.max(0, duration); @@ -318,7 +316,7 @@ export default class AnimationUI { */ _offset(i) { let offset = this._keyframes[i].offsetAsNumber(); - if (this._mouseEventType === Animation.AnimationUI.MouseEvents.KeyframeMove && i === this._keyframeMoved) { + if (this._mouseEventType === MouseEvents.KeyframeMove && i === this._keyframeMoved) { console.assert(i > 0 && i < this._keyframes.length - 1, 'First and last keyframe cannot be moved'); offset += this._movementInMs / this._animation.source().duration(); offset = Math.max(offset, this._keyframes[i - 1].offsetAsNumber()); @@ -328,7 +326,7 @@ export default class AnimationUI { } /** - * @param {!Animation.AnimationUI.MouseEvents} mouseEventType + * @param {!MouseEvents} mouseEventType * @param {?number} keyframeIndex * @param {!Event} event */ @@ -367,7 +365,7 @@ export default class AnimationUI { this._movementInMs = (event.clientX - this._downMouseX) / this._timeline.pixelMsRatio(); // Commit changes - if (this._mouseEventType === Animation.AnimationUI.MouseEvents.KeyframeMove) { + if (this._mouseEventType === MouseEvents.KeyframeMove) { this._keyframes[this._keyframeMoved].setOffset(this._offset(this._keyframeMoved)); } else { this._animation.setTiming(this._duration(), this._delay()); @@ -432,23 +430,3 @@ export const Colors = { 'Brown': Common.Color.parse('#795548'), 'Cyan': Common.Color.parse('#00BCD4') }; - -/* Legacy exported object */ -self.Animation = self.Animation || {}; - -/* Legacy exported object */ -Animation = Animation || {}; - -/** - * @constructor - */ -Animation.AnimationUI = AnimationUI; - -/** - * @enum {string} - */ -Animation.AnimationUI.MouseEvents = MouseEvents; - -Animation.AnimationUI.Options = Options; - -Animation.AnimationUI.Colors = Colors; diff --git a/resources/unpacked/devtools/front_end/animation/animation-legacy.js b/resources/unpacked/devtools/front_end/animation/animation-legacy.js new file mode 100644 index 0000000000..acfa4a3720 --- /dev/null +++ b/resources/unpacked/devtools/front_end/animation/animation-legacy.js @@ -0,0 +1,104 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import * as AnimationModule from './animation.js'; + +self.Animation = self.Animation || {}; +Animation = Animation || {}; + +/** + * @constructor + * @unrestricted + */ +Animation.AnimationGroupPreviewUI = AnimationModule.AnimationGroupPreviewUI.AnimationGroupPreviewUI; + +/** + * @constructor + */ +Animation.AnimationModel = AnimationModule.AnimationModel.AnimationModel; + +/** @enum {symbol} */ +Animation.AnimationModel.Events = AnimationModule.AnimationModel.Events; + +/** + * @constructor + */ +Animation.AnimationModel.Animation = AnimationModule.AnimationModel.AnimationImpl; + +/** @enum {string} */ +Animation.AnimationModel.Animation.Type = AnimationModule.AnimationModel.Type; + +/** + * @constructor + */ +Animation.AnimationModel.AnimationEffect = AnimationModule.AnimationModel.AnimationEffect; + +/** + * @constructor + */ +Animation.AnimationModel.KeyframesRule = AnimationModule.AnimationModel.KeyframesRule; + +/** + * @constructor + */ +Animation.AnimationModel.KeyframeStyle = AnimationModule.AnimationModel.KeyframeStyle; + +/** + * @constructor + */ +Animation.AnimationModel.AnimationGroup = AnimationModule.AnimationModel.AnimationGroup; + +/** + * @constructor + */ +Animation.AnimationModel.ScreenshotCapture = AnimationModule.AnimationModel.ScreenshotCapture; + +/** + * @constructor + */ +Animation.AnimationDispatcher = AnimationModule.AnimationModel.AnimationDispatcher; + +/** + * @unrestricted + * @constructor + */ +Animation.AnimationScreenshotPopover = AnimationModule.AnimationScreenshotPopover.AnimationScreenshotPopover; + +/** + * @implements {SDK.SDKModelObserver} + * @constructor + * @unrestricted + */ +Animation.AnimationTimeline = AnimationModule.AnimationTimeline.AnimationTimeline; + +Animation.AnimationTimeline.GlobalPlaybackRates = AnimationModule.AnimationTimeline.GlobalPlaybackRates; + +/** + * @unrestricted + * @constructor + */ +Animation.AnimationTimeline.NodeUI = AnimationModule.AnimationTimeline.NodeUI; + +/** + * @unrestricted + * @constructor + */ +Animation.AnimationTimeline.StepTimingFunction = AnimationModule.AnimationTimeline.StepTimingFunction; + +/** + * @constructor + */ +Animation.AnimationUI = AnimationModule.AnimationUI.AnimationUI; + +/** + * @enum {string} + */ +Animation.AnimationUI.MouseEvents = AnimationModule.AnimationUI.MouseEvents; + +Animation.AnimationUI.Options = AnimationModule.AnimationUI.Options; + +Animation.AnimationUI.Colors = AnimationModule.AnimationUI.Colors; + +/** @typedef {{ endTime: number, screenshots: !Array.}} */ +Animation.AnimationModel.ScreenshotCapture.Request; diff --git a/resources/unpacked/devtools/front_end/animation/animation.js b/resources/unpacked/devtools/front_end/animation/animation.js index d746976fc0..c85e0a43b5 100644 --- a/resources/unpacked/devtools/front_end/animation/animation.js +++ b/resources/unpacked/devtools/front_end/animation/animation.js @@ -2,12 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import './AnimationModel.js'; -import './AnimationGroupPreviewUI.js'; -import './AnimationScreenshotPopover.js'; -import './AnimationTimeline.js'; -import './AnimationUI.js'; - import * as AnimationGroupPreviewUI from './AnimationGroupPreviewUI.js'; import * as AnimationModel from './AnimationModel.js'; import * as AnimationScreenshotPopover from './AnimationScreenshotPopover.js'; diff --git a/resources/unpacked/devtools/front_end/animation/module.json b/resources/unpacked/devtools/front_end/animation/module.json index 1fbb1c89eb..a58b01325e 100644 --- a/resources/unpacked/devtools/front_end/animation/module.json +++ b/resources/unpacked/devtools/front_end/animation/module.json @@ -16,6 +16,7 @@ "scripts": [], "modules": [ "animation.js", + "animation-legacy.js", "AnimationModel.js", "AnimationGroupPreviewUI.js", "AnimationScreenshotPopover.js", diff --git a/resources/unpacked/devtools/front_end/audits/AuditsController.js b/resources/unpacked/devtools/front_end/audits/AuditsController.js index cf152107c1..fd1f5fe29e 100644 --- a/resources/unpacked/devtools/front_end/audits/AuditsController.js +++ b/resources/unpacked/devtools/front_end/audits/AuditsController.js @@ -6,14 +6,14 @@ * @implements {SDK.SDKModelObserver} * @unrestricted */ -class AuditController extends Common.Object { +export class AuditController extends Common.Object { constructor(protocolService) { super(); protocolService.registerStatusCallback( - message => this.dispatchEventToListeners(Audits.Events.AuditProgressChanged, {message})); + message => this.dispatchEventToListeners(Events.AuditProgressChanged, {message})); - for (const preset of Audits.Presets) { + for (const preset of Presets) { preset.setting.addChangeListener(this.recomputePageAuditability.bind(this)); } @@ -90,7 +90,7 @@ class AuditController extends Common.Object { * @return {boolean} */ _hasAtLeastOneCategory() { - return Audits.Presets.some(preset => preset.setting.get()); + return Presets.some(preset => preset.setting.get()); } /** @@ -155,7 +155,7 @@ class AuditController extends Common.Object { // DevTools handles all the emulation. This tells Lighthouse to not bother with emulation. internalDisableDeviceScreenEmulation: true }; - for (const runtimeSetting of Audits.RuntimeSettings) { + for (const runtimeSetting of RuntimeSettings) { runtimeSetting.setFlags(flags, runtimeSetting.setting.get()); } return flags; @@ -166,7 +166,7 @@ class AuditController extends Common.Object { */ getCategoryIDs() { const categoryIDs = []; - for (const preset of Audits.Presets) { + for (const preset of Presets) { if (preset.setting.get()) { categoryIDs.push(preset.configID); } @@ -200,7 +200,7 @@ class AuditController extends Common.Object { helpText = unauditablePageMessage; } - this.dispatchEventToListeners(Audits.Events.PageAuditabilityChanged, {helpText}); + this.dispatchEventToListeners(Events.PageAuditabilityChanged, {helpText}); } } @@ -287,28 +287,3 @@ export const Events = { RequestAuditStart: Symbol('RequestAuditStart'), RequestAuditCancel: Symbol('RequestAuditCancel'), }; - -/* Legacy exported object */ -self.Audits = self.Audits || {}; - -/* Legacy exported object */ -Audits = Audits || {}; - -/** - * @constructor - */ -Audits.AuditController = AuditController; - -/** @typedef {{setting: !Common.Setting, configID: string, title: string, description: string}} */ -Audits.Preset; - -Audits.Events = Events; - -/** @typedef {{setting: !Common.Setting, description: string, setFlags: function(!Object, string), options: (!Array|undefined), title: (string|undefined)}} */ -Audits.RuntimeSetting; - -/** @type {!Array.} */ -Audits.RuntimeSettings = RuntimeSettings; - -/** @type {!Array.} */ -Audits.Presets = Presets; diff --git a/resources/unpacked/devtools/front_end/audits/AuditsPanel.js b/resources/unpacked/devtools/front_end/audits/AuditsPanel.js index 5a2dd72f39..2cdb8ae8ae 100644 --- a/resources/unpacked/devtools/front_end/audits/AuditsPanel.js +++ b/resources/unpacked/devtools/front_end/audits/AuditsPanel.js @@ -2,19 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {AuditController, Events} from './AuditsController.js'; +import {ProtocolService} from './AuditsProtocolService.js'; +import {AuditsReportRenderer, AuditsReportUIFeatures} from './AuditsReportRenderer.js'; +import {Item, ReportSelector} from './AuditsReportSelector.js'; +import {StartView} from './AuditsStartView.js'; +import {StatusView} from './AuditsStatusView.js'; + /** * @unrestricted */ -export default class AuditsPanel extends UI.Panel { +export class AuditsPanel extends UI.Panel { constructor() { super('audits'); this.registerRequiredCSS('audits/lighthouse/report.css'); this.registerRequiredCSS('audits/auditsPanel.css'); - this._protocolService = new Audits.ProtocolService(); - this._controller = new Audits.AuditController(this._protocolService); - this._startView = new Audits.StartView(this._controller); - this._statusView = new Audits.StatusView(this._controller); + this._protocolService = new ProtocolService(); + this._controller = new AuditController(this._protocolService); + this._startView = new StartView(this._controller); + this._statusView = new StatusView(this._controller); this._unauditableExplanation = null; this._cachedRenderedReports = new Map(); @@ -23,10 +30,10 @@ export default class AuditsPanel extends UI.Panel { this.contentElement, [UI.DropTarget.Type.File], Common.UIString('Drop audit file here'), this._handleDrop.bind(this)); - this._controller.addEventListener(Audits.Events.PageAuditabilityChanged, this._refreshStartAuditUI.bind(this)); - this._controller.addEventListener(Audits.Events.AuditProgressChanged, this._refreshStatusUI.bind(this)); - this._controller.addEventListener(Audits.Events.RequestAuditStart, this._startAudit.bind(this)); - this._controller.addEventListener(Audits.Events.RequestAuditCancel, this._cancelAudit.bind(this)); + this._controller.addEventListener(Events.PageAuditabilityChanged, this._refreshStartAuditUI.bind(this)); + this._controller.addEventListener(Events.AuditProgressChanged, this._refreshStatusUI.bind(this)); + this._controller.addEventListener(Events.RequestAuditStart, this._startAudit.bind(this)); + this._controller.addEventListener(Events.RequestAuditCancel, this._cancelAudit.bind(this)); this._renderToolbar(); this._auditResultsElement = this.contentElement.createChild('div', 'audits-results-container'); @@ -77,7 +84,7 @@ export default class AuditsPanel extends UI.Panel { toolbar.appendSeparator(); - this._reportSelector = new Audits.ReportSelector(() => this._renderStartView()); + this._reportSelector = new ReportSelector(() => this._renderStartView()); toolbar.appendToolbarItem(this._reportSelector.comboBox()); this._clearButton = new UI.ToolbarButton(Common.UIString('Clear all'), 'largeicon-clear'); @@ -175,7 +182,7 @@ export default class AuditsPanel extends UI.Panel { const reportContainer = this._auditResultsElement.createChild('div', 'lh-vars lh-root lh-devtools'); const dom = new DOM(/** @type {!Document} */ (this._auditResultsElement.ownerDocument)); - const renderer = new Audits.ReportRenderer(dom); + const renderer = new AuditsReportRenderer(dom); const templatesHTML = Root.Runtime.cachedResources['audits/lighthouse/templates.html']; const templatesDOM = new DOMParser().parseFromString(templatesHTML, 'text/html'); @@ -185,17 +192,17 @@ export default class AuditsPanel extends UI.Panel { renderer.setTemplateContext(templatesDOM); const el = renderer.renderReport(lighthouseResult, reportContainer); - Audits.ReportRenderer.addViewTraceButton(el, artifacts); + AuditsReportRenderer.addViewTraceButton(el, artifacts); // Linkifying requires the target be loaded. Do not block the report // from rendering, as this is just an embellishment and the main target // could take awhile to load. this._waitForMainTargetLoad().then(() => { - Audits.ReportRenderer.linkifyNodeDetails(el); - Audits.ReportRenderer.linkifySourceLocationDetails(el); + AuditsReportRenderer.linkifyNodeDetails(el); + AuditsReportRenderer.linkifySourceLocationDetails(el); }); - Audits.ReportRenderer.handleDarkMode(el); + AuditsReportRenderer.handleDarkMode(el); - const features = new Audits.ReportUIFeatures(dom); + const features = new AuditsReportUIFeatures(dom); features.setBeforePrint(this._beforePrint.bind(this)); features.setAfterPrint(this._afterPrint.bind(this)); features.setTemplateContext(templatesDOM); @@ -219,7 +226,7 @@ export default class AuditsPanel extends UI.Panel { return; } - const optionElement = new Audits.ReportSelector.Item( + const optionElement = new Item( lighthouseResult, () => this._renderReport(lighthouseResult, artifacts), this._renderStartView.bind(this)); this._reportSelector.prepend(optionElement); this._refreshToolbarUI(); @@ -374,14 +381,3 @@ export default class AuditsPanel extends UI.Panel { await resourceTreeModel.navigate(inspectedURL); } } - -/* Legacy exported object */ -self.Audits = self.Audits || {}; - -/* Legacy exported object */ -Audits = Audits || {}; - -/** - * @constructor - */ -Audits.AuditsPanel = AuditsPanel; diff --git a/resources/unpacked/devtools/front_end/audits/AuditsProtocolService.js b/resources/unpacked/devtools/front_end/audits/AuditsProtocolService.js index 23544bc359..f8344ebd68 100644 --- a/resources/unpacked/devtools/front_end/audits/AuditsProtocolService.js +++ b/resources/unpacked/devtools/front_end/audits/AuditsProtocolService.js @@ -91,14 +91,3 @@ export class ProtocolService extends Common.Object { return this._backendPromise.then(_ => this._backend.send(method, params)); } } - -/* Legacy exported object */ -self.Audits = self.Audits || {}; - -/* Legacy exported object */ -Audits = Audits || {}; - -/** - * @constructor - */ -Audits.ProtocolService = ProtocolService; diff --git a/resources/unpacked/devtools/front_end/audits/AuditsReportRenderer.js b/resources/unpacked/devtools/front_end/audits/AuditsReportRenderer.js index 77b89413ea..e47618e98f 100644 --- a/resources/unpacked/devtools/front_end/audits/AuditsReportRenderer.js +++ b/resources/unpacked/devtools/front_end/audits/AuditsReportRenderer.js @@ -157,7 +157,7 @@ export class AuditsReportUIFeatures extends ReportUIFeatures { printWindow.document.head.appendChild(style); printWindow.document.body.replaceWith(clonedReport); // Linkified nodes are shadow elements, which aren't exposed via `cloneNode`. - await Audits.ReportRenderer.linkifyNodeDetails(clonedReport); + await AuditsReportRenderer.linkifyNodeDetails(clonedReport); if (this._beforePrint) { this._beforePrint(); @@ -185,20 +185,3 @@ export class AuditsReportUIFeatures extends ReportUIFeatures { this._resetUIState(); } } - - -/* Legacy exported object */ -self.Audits = self.Audits || {}; - -/* Legacy exported object */ -Audits = Audits || {}; - -/** - * @constructor - */ -Audits.ReportRenderer = AuditsReportRenderer; - -/** - * @constructor - */ -Audits.ReportUIFeatures = AuditsReportUIFeatures; diff --git a/resources/unpacked/devtools/front_end/audits/AuditsReportSelector.js b/resources/unpacked/devtools/front_end/audits/AuditsReportSelector.js index 6d1e6d48d5..0eddc83d8d 100644 --- a/resources/unpacked/devtools/front_end/audits/AuditsReportSelector.js +++ b/resources/unpacked/devtools/front_end/audits/AuditsReportSelector.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -export default class ReportSelector { +export class ReportSelector { constructor(renderNewAuditView) { this._renderNewAuditView = renderNewAuditView; this._newAuditItem = createElement('option'); @@ -36,7 +36,7 @@ export default class ReportSelector { } /** - * @return {!Audits.ReportSelector.Item} + * @return {!Item} */ _selectedItem() { const option = this._comboBox.selectedOption(); @@ -65,7 +65,7 @@ export default class ReportSelector { } /** - * @param {!Audits.ReportSelector.Item} item + * @param {!Item} item */ prepend(item) { const optionEl = item.optionElement(); @@ -131,19 +131,3 @@ export class Item { this._showLandingCallback(); } } - -/* Legacy exported object */ -self.Audits = self.Audits || {}; - -/* Legacy exported object */ -Audits = Audits || {}; - -/** - * @constructor - */ -Audits.ReportSelector = ReportSelector; - -/** - * @constructor - */ -Audits.ReportSelector.Item = Item; diff --git a/resources/unpacked/devtools/front_end/audits/AuditsStartView.js b/resources/unpacked/devtools/front_end/audits/AuditsStartView.js index 0f0109b043..0137ba239c 100644 --- a/resources/unpacked/devtools/front_end/audits/AuditsStartView.js +++ b/resources/unpacked/devtools/front_end/audits/AuditsStartView.js @@ -2,12 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {AuditController, Events, Presets, RuntimeSettings} from './AuditsController.js'; // eslint-disable-line no-unused-vars +import {RadioSetting} from './RadioSetting.js'; + /** * @unrestricted */ -export default class StartView extends UI.Widget { +export class StartView extends UI.Widget { /** - * @param {!Audits.AuditController} controller + * @param {!AuditController} controller */ constructor(controller) { super(); @@ -30,12 +33,12 @@ export default class StartView extends UI.Widget { * @param {!Element} parentElement */ _populateRuntimeSettingAsRadio(settingName, label, parentElement) { - const runtimeSetting = Audits.RuntimeSettings.find(item => item.setting.name === settingName); + const runtimeSetting = RuntimeSettings.find(item => item.setting.name === settingName); if (!runtimeSetting || !runtimeSetting.options) { throw new Error(`${settingName} is not a setting with options`); } - const control = new Audits.RadioSetting(runtimeSetting.options, runtimeSetting.setting, runtimeSetting.description); + const control = new RadioSetting(runtimeSetting.options, runtimeSetting.setting, runtimeSetting.description); parentElement.appendChild(control.element); UI.ARIAUtils.setAccessibleName(control.element, label); } @@ -45,7 +48,7 @@ export default class StartView extends UI.Widget { * @param {!UI.Toolbar} toolbar */ _populateRuntimeSettingAsToolbarCheckbox(settingName, toolbar) { - const runtimeSetting = Audits.RuntimeSettings.find(item => item.setting.name === settingName); + const runtimeSetting = RuntimeSettings.find(item => item.setting.name === settingName); if (!runtimeSetting || !runtimeSetting.title) { throw new Error(`${settingName} is not a setting with a title`); } @@ -71,7 +74,7 @@ export default class StartView extends UI.Widget { // Populate the categories const categoryFormElements = fragment.$('categories-form-elements'); const pluginFormElements = fragment.$('plugins-form-elements'); - for (const preset of Audits.Presets) { + for (const preset of Presets) { const formElements = preset.plugin ? pluginFormElements : categoryFormElements; preset.setting.setTitle(preset.title); const checkbox = new UI.ToolbarSettingCheckbox(preset.setting); @@ -92,7 +95,7 @@ export default class StartView extends UI.Widget { this._startButton = UI.createTextButton( ls`Generate report`, () => this._controller.dispatchEventToListeners( - Audits.Events.RequestAuditStart, + Events.RequestAuditStart, /* keyboardInitiated */ UI.elementIsFocusedByKeyboard(this._startButton)), /* className */ '', /* primary */ true); this.setDefaultFocusedElement(this._startButton); @@ -180,14 +183,3 @@ export default class StartView extends UI.Widget { } } } - -/* Legacy exported object */ -self.Audits = self.Audits || {}; - -/* Legacy exported object */ -Audits = Audits || {}; - -/** - * @constructor - */ -Audits.StartView = StartView; diff --git a/resources/unpacked/devtools/front_end/audits/AuditsStatusView.js b/resources/unpacked/devtools/front_end/audits/AuditsStatusView.js index d5090b65ea..d3d55346a4 100644 --- a/resources/unpacked/devtools/front_end/audits/AuditsStatusView.js +++ b/resources/unpacked/devtools/front_end/audits/AuditsStatusView.js @@ -2,9 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -export default class StatusView { +import {AuditController, Events, RuntimeSettings} from './AuditsController.js'; // eslint-disable-line no-unused-vars + +export class StatusView { /** - * @param {!Audits.AuditController} controller + * @param {!AuditController} controller */ constructor(controller) { this._controller = controller; @@ -56,7 +58,7 @@ export default class StatusView { this._progressBar = fragment.$('progress-bar'); this._statusText = fragment.$('status-text'); // Use StatusPhases array index as progress bar value - UI.ARIAUtils.markAsProgressBar(this._progressBar, 0, Audits.StatusView.StatusPhases.length - 1); + UI.ARIAUtils.markAsProgressBar(this._progressBar, 0, StatusPhases.length - 1); this._cancelButton = cancelButton; UI.ARIAUtils.markAsStatus(this._statusText); @@ -125,8 +127,8 @@ export default class StatusView { } const nextPhase = this._getPhaseForMessage(message); - const nextPhaseIndex = Audits.StatusView.StatusPhases.indexOf(nextPhase); - const currentPhaseIndex = Audits.StatusView.StatusPhases.indexOf(this._currentPhase); + const nextPhaseIndex = StatusPhases.indexOf(nextPhase); + const currentPhaseIndex = StatusPhases.indexOf(this._currentPhase); if (!nextPhase && !this._currentPhase) { this._commitTextChange(Common.UIString('Lighthouse is warming up\u2026')); clearTimeout(this._scheduledFastFactTimeout); @@ -142,11 +144,11 @@ export default class StatusView { } _cancel() { - this._controller.dispatchEventToListeners(Audits.Events.RequestAuditCancel); + this._controller.dispatchEventToListeners(Events.RequestAuditCancel); } /** - * @param {!Audits.StatusView.StatusPhases} phase + * @param {!StatusPhases} phase * @return {string} */ _getMessageForPhase(phase) { @@ -154,8 +156,8 @@ export default class StatusView { return phase.message; } - const deviceType = Audits.RuntimeSettings.find(item => item.setting.name === 'audits.device_type').setting.get(); - const throttling = Audits.RuntimeSettings.find(item => item.setting.name === 'audits.throttling').setting.get(); + const deviceType = RuntimeSettings.find(item => item.setting.name === 'audits.device_type').setting.get(); + const throttling = RuntimeSettings.find(item => item.setting.name === 'audits.throttling').setting.get(); const match = LoadingMessages.find(item => { return item.deviceType === deviceType && item.throttling === throttling; }); @@ -165,7 +167,7 @@ export default class StatusView { /** * @param {string} message - * @return {?Audits.StatusView.StatusPhases} + * @return {?StatusPhases} */ _getPhaseForMessage(message) { return StatusPhases.find(phase => message.startsWith(phase.statusMessagePrefix)); @@ -375,17 +377,3 @@ const FastFacts = [ ls`70% of mobile pages weigh over 1MB, 36% over 2MB, and 12% over 4MB. [Source: Think with Google]`, ls `Lighthouse only simulates mobile performance; to measure performance on a real device, try WebPageTest.org [Source: Lighthouse team]`, ]; - - /* Legacy exported object */ - self.Audits = self.Audits || {}; - - /* Legacy exported object */ - Audits = Audits || {}; - - /** -* @constructor -*/ - Audits.StatusView = StatusView; - - /** @typedef {{message: string, progressBarClass: string, order: number}} */ - Audits.StatusView.StatusPhases = StatusPhases; diff --git a/resources/unpacked/devtools/front_end/audits/RadioSetting.js b/resources/unpacked/devtools/front_end/audits/RadioSetting.js index 07f9567b8e..eb43526ca4 100644 --- a/resources/unpacked/devtools/front_end/audits/RadioSetting.js +++ b/resources/unpacked/devtools/front_end/audits/RadioSetting.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -export default class RadioSetting { +export class RadioSetting { /** * @param {!Array} options * @param {!Common.Setting} setting @@ -66,12 +66,3 @@ export default class RadioSetting { this._setting.set(selectedRadio.value); } } - -/* Legacy exported object */ -self.Audits = self.Audits || {}; - -/* Legacy exported object */ -Audits = Audits || {}; - -// TODO(http://crbug.com/1006759): Add type information if necessary -Audits.RadioSetting = RadioSetting; diff --git a/resources/unpacked/devtools/front_end/audits/audits-legacy.js b/resources/unpacked/devtools/front_end/audits/audits-legacy.js new file mode 100644 index 0000000000..318f946725 --- /dev/null +++ b/resources/unpacked/devtools/front_end/audits/audits-legacy.js @@ -0,0 +1,72 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import * as AuditsModule from './audits.js'; + +self.Audits = self.Audits || {}; +Audits = Audits || {}; + +/** + * @constructor + */ +Audits.AuditController = AuditsModule.AuditsController.AuditController; + +Audits.Events = AuditsModule.AuditsController.Events; + +/** @type {!Array.} */ +Audits.RuntimeSettings = AuditsModule.AuditsController.RuntimeSettings; + +/** @type {!Array.} */ +Audits.Presets = AuditsModule.AuditsController.Presets; + +/** + * @constructor + */ +Audits.AuditsPanel = AuditsModule.AuditsPanel.AuditsPanel; + +/** + * @constructor + */ +Audits.ProtocolService = AuditsModule.AuditsProtocolService.ProtocolService; + +/** + * @constructor + */ +Audits.ReportRenderer = AuditsModule.AuditsReportRenderer.AuditsReportRenderer; + +/** + * @constructor + */ +Audits.ReportUIFeatures = AuditsModule.AuditsReportRenderer.AuditsReportUIFeatures; + +/** + * @constructor + */ +Audits.ReportSelector = AuditsModule.AuditsReportSelector.ReportSelector; + +/** + * @constructor + */ +Audits.ReportSelector.Item = AuditsModule.AuditsReportSelector.Item; + +/** + * @constructor + */ +Audits.StartView = AuditsModule.AuditsStartView.StartView; + +/** +* @constructor +*/ +Audits.StatusView = AuditsModule.AuditsStatusView.StatusView; + +/** @typedef {{message: string, progressBarClass: string, order: number}} */ +Audits.StatusView.StatusPhases = AuditsModule.AuditsStatusView.StatusPhases; + +Audits.RadioSetting = AuditsModule.RadioSetting.RadioSetting; + +/** @typedef {{setting: !Common.Setting, configID: string, title: string, description: string}} */ +Audits.Preset; + +/** @typedef {{setting: !Common.Setting, description: string, setFlags: function(!Object, string), options: (!Array|undefined), title: (string|undefined)}} */ +Audits.RuntimeSetting; diff --git a/resources/unpacked/devtools/front_end/audits/audits.js b/resources/unpacked/devtools/front_end/audits/audits.js index 2ad97b3ea3..acb0639c12 100644 --- a/resources/unpacked/devtools/front_end/audits/audits.js +++ b/resources/unpacked/devtools/front_end/audits/audits.js @@ -4,14 +4,6 @@ import './lighthouse/report.js'; import './lighthouse/report-generator.js'; -import './RadioSetting.js'; -import './AuditsPanel.js'; -import './AuditsController.js'; -import './AuditsReportSelector.js'; -import './AuditsReportRenderer.js'; -import './AuditsStartView.js'; -import './AuditsStatusView.js'; -import './AuditsProtocolService.js'; import * as AuditsController from './AuditsController.js'; import * as AuditsPanel from './AuditsPanel.js'; diff --git a/resources/unpacked/devtools/front_end/audits/module.json b/resources/unpacked/devtools/front_end/audits/module.json index 2b6bcb43bb..82fb6ef2dd 100644 --- a/resources/unpacked/devtools/front_end/audits/module.json +++ b/resources/unpacked/devtools/front_end/audits/module.json @@ -22,6 +22,7 @@ "scripts": [], "modules": [ "audits.js", + "audits-legacy.js", "lighthouse/report.js", "lighthouse/report-generator.js", "RadioSetting.js", diff --git a/resources/unpacked/devtools/front_end/bindings/BlackboxManager.js b/resources/unpacked/devtools/front_end/bindings/BlackboxManager.js index 90f6f242f7..ec2fa260af 100644 --- a/resources/unpacked/devtools/front_end/bindings/BlackboxManager.js +++ b/resources/unpacked/devtools/front_end/bindings/BlackboxManager.js @@ -1,13 +1,16 @@ // Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + +import {DebuggerWorkspaceBinding} from './DebuggerWorkspaceBinding.js'; // eslint-disable-line no-unused-vars + /** * @unrestricted * @implements {SDK.SDKModelObserver} */ -export default class BlackboxManager { +export class BlackboxManager { /** - * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding + * @param {!DebuggerWorkspaceBinding} debuggerWorkspaceBinding */ constructor(debuggerWorkspaceBinding) { this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; @@ -347,15 +350,3 @@ export default class BlackboxManager { } const _blackboxedRanges = Symbol('blackboxedRanged'); - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @constructor */ -Bindings.BlackboxManager = BlackboxManager; - -/** @type {!BlackboxManager} */ -Bindings.blackboxManager; diff --git a/resources/unpacked/devtools/front_end/bindings/BreakpointManager.js b/resources/unpacked/devtools/front_end/bindings/BreakpointManager.js index 36d1de0cb4..f408d4feeb 100644 --- a/resources/unpacked/devtools/front_end/bindings/BreakpointManager.js +++ b/resources/unpacked/devtools/front_end/bindings/BreakpointManager.js @@ -27,14 +27,18 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +import {DebuggerWorkspaceBinding} from './DebuggerWorkspaceBinding.js'; // eslint-disable-line no-unused-vars +import {LiveLocation, LiveLocationPool} from './LiveLocation.js'; // eslint-disable-line no-unused-vars + /** * @unrestricted */ -export default class BreakpointManager extends Common.Object { +export class BreakpointManager extends Common.Object { /** * @param {!Workspace.Workspace} workspace * @param {!SDK.TargetManager} targetManager - * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding + * @param {!DebuggerWorkspaceBinding} debuggerWorkspaceBinding */ constructor(workspace, targetManager, debuggerWorkspaceBinding) { super(); @@ -498,20 +502,20 @@ export class Breakpoint { /** * @unrestricted */ -class ModelBreakpoint { +export class ModelBreakpoint { /** * @param {!SDK.DebuggerModel} debuggerModel * @param {!Breakpoint} breakpoint - * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding + * @param {!DebuggerWorkspaceBinding} debuggerWorkspaceBinding */ constructor(debuggerModel, breakpoint, debuggerWorkspaceBinding) { this._debuggerModel = debuggerModel; this._breakpoint = breakpoint; this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; - this._liveLocations = new Bindings.LiveLocationPool(); + this._liveLocations = new LiveLocationPool(); - /** @type {!Map} */ + /** @type {!Map} */ this._uiLocations = new Map(); this._debuggerModel.addEventListener( SDK.DebuggerModel.Events.DebuggerWasDisabled, this._cleanUpAfterDebuggerIsGone, this); @@ -699,7 +703,7 @@ class ModelBreakpoint { } /** - * @param {!Bindings.LiveLocation} liveLocation + * @param {!LiveLocation} liveLocation */ _locationUpdated(liveLocation) { const oldUILocation = this._uiLocations.get(liveLocation); @@ -867,30 +871,3 @@ Storage.Item = class { this.enabled = breakpoint.enabled(); } }; - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @constructor */ -Bindings.BreakpointManager = BreakpointManager; - -/** @enum {symbol} */ -Bindings.BreakpointManager.Events = Events; - -/** @constructor */ -Bindings.BreakpointManager.Breakpoint = Breakpoint; - -Bindings.BreakpointManager.ModelBreakpoint = ModelBreakpoint; - -/** @typedef {{ - * breakpoint: !Breakpoint, - * uiLocation: !Workspace.UILocation - * }} - */ -Bindings.BreakpointManager.BreakpointLocation; - -/** @type {!Bindings.BreakpointManager} */ -Bindings.breakpointManager; diff --git a/resources/unpacked/devtools/front_end/bindings/CSSWorkspaceBinding.js b/resources/unpacked/devtools/front_end/bindings/CSSWorkspaceBinding.js index 7f7ee07bdf..4a88058e7b 100644 --- a/resources/unpacked/devtools/front_end/bindings/CSSWorkspaceBinding.js +++ b/resources/unpacked/devtools/front_end/bindings/CSSWorkspaceBinding.js @@ -2,10 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {LiveLocation as LiveLocationInterface, LiveLocationPool, LiveLocationWithPool} from './LiveLocation.js'; // eslint-disable-line no-unused-vars +import {SASSSourceMapping} from './SASSSourceMapping.js'; +import {StylesSourceMapping} from './StylesSourceMapping.js'; + /** * @implements {SDK.SDKModelObserver} */ -export default class CSSWorkspaceBinding { +export class CSSWorkspaceBinding { /** * @param {!SDK.TargetManager} targetManager * @param {!Workspace.Workspace} workspace @@ -46,8 +50,8 @@ export default class CSSWorkspaceBinding { /** * @param {!SDK.CSSLocation} rawLocation - * @param {function(!Bindings.LiveLocation)} updateDelegate - * @param {!Bindings.LiveLocationPool} locationPool + * @param {function(!LiveLocationInterface)} updateDelegate + * @param {!LiveLocationPool} locationPool * @return {!LiveLocation} */ createLiveLocation(rawLocation, updateDelegate, locationPool) { @@ -124,7 +128,7 @@ export default class CSSWorkspaceBinding { /** * @interface */ -class SourceMapping { +export class SourceMapping { /** * @param {!SDK.CSSLocation} rawLocation * @return {?Workspace.UILocation} @@ -140,7 +144,7 @@ class SourceMapping { } } -class ModelInfo { +export class ModelInfo { /** * @param {!SDK.CSSModel} cssModel * @param {!Workspace.Workspace} workspace @@ -151,9 +155,9 @@ class ModelInfo { cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetRemoved, this._styleSheetRemoved, this) ]; - this._stylesSourceMapping = new Bindings.StylesSourceMapping(cssModel, workspace); + this._stylesSourceMapping = new StylesSourceMapping(cssModel, workspace); const sourceMapManager = cssModel.sourceMapManager(); - this._sassSourceMapping = new Bindings.SASSSourceMapping(cssModel.target(), sourceMapManager, workspace); + this._sassSourceMapping = new SASSSourceMapping(cssModel.target(), sourceMapManager, workspace); /** @type {!Platform.Multimap} */ this._locations = new Platform.Multimap(); @@ -163,8 +167,8 @@ class ModelInfo { /** * @param {!SDK.CSSLocation} rawLocation - * @param {function(!Bindings.LiveLocation)} updateDelegate - * @param {!Bindings.LiveLocationPool} locationPool + * @param {function(!LiveLocationInterface)} updateDelegate + * @param {!LiveLocationPool} locationPool * @return {!LiveLocation} */ _createLiveLocation(rawLocation, updateDelegate, locationPool) { @@ -268,12 +272,12 @@ class ModelInfo { /** * @unrestricted */ -class LiveLocation extends Bindings.LiveLocationWithPool { +export class LiveLocation extends LiveLocationWithPool { /** * @param {!SDK.CSSLocation} rawLocation * @param {!ModelInfo} info - * @param {function(!Bindings.LiveLocation)} updateDelegate - * @param {!Bindings.LiveLocationPool} locationPool + * @param {function(!LiveLocationInterface)} updateDelegate + * @param {!LiveLocationPool} locationPool */ constructor(rawLocation, info, updateDelegate, locationPool) { super(updateDelegate, locationPool); @@ -312,23 +316,3 @@ class LiveLocation extends Bindings.LiveLocationWithPool { return false; } } - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @constructor */ -Bindings.CSSWorkspaceBinding = CSSWorkspaceBinding; - -/** @interface */ -Bindings.CSSWorkspaceBinding.SourceMapping = SourceMapping; - -/** @constructor */ -Bindings.CSSWorkspaceBinding.ModelInfo = ModelInfo; - -/** - * @type {!CSSWorkspaceBinding} - */ -Bindings.cssWorkspaceBinding; diff --git a/resources/unpacked/devtools/front_end/bindings/CompilerScriptMapping.js b/resources/unpacked/devtools/front_end/bindings/CompilerScriptMapping.js index ad20ad264b..01f2f876e2 100644 --- a/resources/unpacked/devtools/front_end/bindings/CompilerScriptMapping.js +++ b/resources/unpacked/devtools/front_end/bindings/CompilerScriptMapping.js @@ -27,15 +27,21 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +import {ContentProviderBasedProject} from './ContentProviderBasedProject.js'; +import {DebuggerSourceMapping, DebuggerWorkspaceBinding} from './DebuggerWorkspaceBinding.js'; // eslint-disable-line no-unused-vars +import {NetworkProject} from './NetworkProject.js'; +import {frameIdForScript} from './ResourceUtils.js'; + /** - * @implements {Bindings.DebuggerSourceMapping} + * @implements {DebuggerSourceMapping} * @unrestricted */ -export default class CompilerScriptMapping { +export class CompilerScriptMapping { /** * @param {!SDK.DebuggerModel} debuggerModel * @param {!Workspace.Workspace} workspace - * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding + * @param {!DebuggerWorkspaceBinding} debuggerWorkspaceBinding */ constructor(debuggerModel, workspace, debuggerWorkspaceBinding) { this._debuggerModel = debuggerModel; @@ -44,13 +50,13 @@ export default class CompilerScriptMapping { this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; const target = debuggerModel.target(); - this._regularProject = new Bindings.ContentProviderBasedProject( + this._regularProject = new ContentProviderBasedProject( workspace, 'jsSourceMaps::' + target.id(), Workspace.projectTypes.Network, '', false /* isServiceProject */); - this._contentScriptsProject = new Bindings.ContentProviderBasedProject( + this._contentScriptsProject = new ContentProviderBasedProject( workspace, 'jsSourceMaps:extensions:' + target.id(), Workspace.projectTypes.ContentScripts, '', false /* isServiceProject */); - Bindings.NetworkProject.setTargetForProject(this._regularProject, target); - Bindings.NetworkProject.setTargetForProject(this._contentScriptsProject, target); + NetworkProject.setTargetForProject(this._regularProject, target); + NetworkProject.setTargetForProject(this._contentScriptsProject, target); /** @type {!Map} */ this._regularBindings = new Map(); @@ -60,7 +66,7 @@ export default class CompilerScriptMapping { /** @type {!Map} */ this._stubUISourceCodes = new Map(); - this._stubProject = new Bindings.ContentProviderBasedProject( + this._stubProject = new ContentProviderBasedProject( workspace, 'jsSourceMaps:stub:' + target.id(), Workspace.projectTypes.Service, '', true /* isServiceProject */); this._eventListeners = [ this._sourceMapManager.addEventListener( @@ -271,7 +277,7 @@ export default class CompilerScriptMapping { * @param {!SDK.SourceMap} sourceMap */ _populateSourceMapSources(script, sourceMap) { - const frameId = Bindings.frameIdForScript(script); + const frameId = frameIdForScript(script); script[_frameIdSymbol] = frameId; const project = script.isContentScript() ? this._contentScriptsProject : this._regularProject; const bindings = script.isContentScript() ? this._contentScriptsBindings : this._regularBindings; @@ -312,7 +318,7 @@ const _sourceMapSymbol = Symbol('_sourceMapSymbol'); class Binding { /** - * @param {!Bindings.ContentProviderBasedProject} project + * @param {!ContentProviderBasedProject} project * @param {string} url */ constructor(project, url) { @@ -344,10 +350,10 @@ class Binding { typeof embeddedContent === 'string' ? new Workspace.UISourceCodeMetadata(null, embeddedContent.length) : null; if (this._uiSourceCode) { - Bindings.NetworkProject.cloneInitialFrameAttribution(this._uiSourceCode, newUISourceCode); + NetworkProject.cloneInitialFrameAttribution(this._uiSourceCode, newUISourceCode); this._project.removeFile(this._uiSourceCode.url()); } else { - Bindings.NetworkProject.setInitialFrameAttribution(newUISourceCode, frameId); + NetworkProject.setInitialFrameAttribution(newUISourceCode, frameId); } this._uiSourceCode = newUISourceCode; this._project.addUISourceCodeWithProvider(this._uiSourceCode, contentProvider, metadata, mimeType); @@ -359,7 +365,7 @@ class Binding { */ addSourceMap(sourceMap, frameId) { if (this._uiSourceCode) { - Bindings.NetworkProject.addFrameAttribution(this._uiSourceCode, frameId); + NetworkProject.addFrameAttribution(this._uiSourceCode, frameId); } this._referringSourceMaps.push(sourceMap); this._recreateUISourceCodeIfNeeded(frameId); @@ -370,7 +376,7 @@ class Binding { * @param {string} frameId */ removeSourceMap(sourceMap, frameId) { - Bindings.NetworkProject.removeFrameAttribution( + NetworkProject.removeFrameAttribution( /** @type {!Workspace.UISourceCode} */ (this._uiSourceCode), frameId); const lastIndex = this._referringSourceMaps.lastIndexOf(sourceMap); if (lastIndex !== -1) { @@ -384,12 +390,3 @@ class Binding { } } } - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @constructor */ -Bindings.CompilerScriptMapping = CompilerScriptMapping; diff --git a/resources/unpacked/devtools/front_end/bindings/ContentProviderBasedProject.js b/resources/unpacked/devtools/front_end/bindings/ContentProviderBasedProject.js index 62d5ffcf11..b435d8bf9b 100644 --- a/resources/unpacked/devtools/front_end/bindings/ContentProviderBasedProject.js +++ b/resources/unpacked/devtools/front_end/bindings/ContentProviderBasedProject.js @@ -32,7 +32,7 @@ * @implements {Workspace.Project} * @unrestricted */ -export default class ContentProviderBasedProject extends Workspace.ProjectStore { +export class ContentProviderBasedProject extends Workspace.ProjectStore { /** * @param {!Workspace.Workspace} workspace * @param {string} id @@ -319,12 +319,3 @@ export default class ContentProviderBasedProject extends Workspace.ProjectStore const _metadata = Symbol('ContentProviderBasedProject.Metadata'); const _mimeType = Symbol('ContentProviderBasedProject.MimeType'); - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @constructor */ -Bindings.ContentProviderBasedProject = ContentProviderBasedProject; diff --git a/resources/unpacked/devtools/front_end/bindings/DebuggerWorkspaceBinding.js b/resources/unpacked/devtools/front_end/bindings/DebuggerWorkspaceBinding.js index b8d293c8f8..106bd44e80 100644 --- a/resources/unpacked/devtools/front_end/bindings/DebuggerWorkspaceBinding.js +++ b/resources/unpacked/devtools/front_end/bindings/DebuggerWorkspaceBinding.js @@ -2,11 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {CompilerScriptMapping} from './CompilerScriptMapping.js'; +import {DefaultScriptMapping} from './DefaultScriptMapping.js'; +import {LiveLocation, LiveLocationPool, LiveLocationWithPool} from './LiveLocation.js'; // eslint-disable-line no-unused-vars +import {ResourceScriptFile, ResourceScriptMapping} from './ResourceScriptMapping.js'; // eslint-disable-line no-unused-vars + /** * @unrestricted * @implements {SDK.SDKModelObserver} */ -export default class DebuggerWorkspaceBinding { +export class DebuggerWorkspaceBinding { /** * @param {!SDK.TargetManager} targetManager * @param {!Workspace.Workspace} workspace @@ -63,8 +68,8 @@ export default class DebuggerWorkspaceBinding { /** * @param {!SDK.DebuggerModel.Location} rawLocation - * @param {function(!Bindings.LiveLocation)} updateDelegate - * @param {!Bindings.LiveLocationPool} locationPool + * @param {function(!LiveLocation)} updateDelegate + * @param {!LiveLocationPool} locationPool * @return {!Location} */ createLiveLocation(rawLocation, updateDelegate, locationPool) { @@ -74,8 +79,8 @@ export default class DebuggerWorkspaceBinding { /** * @param {!Array} rawLocations - * @param {function(!Bindings.LiveLocation)} updateDelegate - * @param {!Bindings.LiveLocationPool} locationPool + * @param {function(!LiveLocation)} updateDelegate + * @param {!LiveLocationPool} locationPool * @return {!Bindings.LiveLocation} */ createStackTraceTopFrameLiveLocation(rawLocations, updateDelegate, locationPool) { @@ -87,8 +92,8 @@ export default class DebuggerWorkspaceBinding { /** * @param {!SDK.DebuggerModel.Location} location - * @param {function(!Bindings.LiveLocation)} updateDelegate - * @param {!Bindings.LiveLocationPool} locationPool + * @param {function(!LiveLocation)} updateDelegate + * @param {!LiveLocationPool} locationPool * @return {?Location} */ createCallFrameLiveLocation(location, updateDelegate, locationPool) { @@ -184,7 +189,7 @@ export default class DebuggerWorkspaceBinding { /** * @param {!Workspace.UISourceCode} uiSourceCode * @param {!SDK.DebuggerModel} debuggerModel - * @return {?Bindings.ResourceScriptFile} + * @return {?ResourceScriptFile} */ scriptFile(uiSourceCode, debuggerModel) { const modelData = this._debuggerModelToData.get(debuggerModel); @@ -274,9 +279,9 @@ class ModelData { const workspace = debuggerWorkspaceBinding._workspace; - this._defaultMapping = new Bindings.DefaultScriptMapping(debuggerModel, workspace, debuggerWorkspaceBinding); - this._resourceMapping = new Bindings.ResourceScriptMapping(debuggerModel, workspace, debuggerWorkspaceBinding); - this._compilerMapping = new Bindings.CompilerScriptMapping(debuggerModel, workspace, debuggerWorkspaceBinding); + this._defaultMapping = new DefaultScriptMapping(debuggerModel, workspace, debuggerWorkspaceBinding); + this._resourceMapping = new ResourceScriptMapping(debuggerModel, workspace, debuggerWorkspaceBinding); + this._compilerMapping = new CompilerScriptMapping(debuggerModel, workspace, debuggerWorkspaceBinding); /** @type {!Platform.Multimap} */ this._locations = new Platform.Multimap(); @@ -286,8 +291,8 @@ class ModelData { /** * @param {!SDK.DebuggerModel.Location} rawLocation - * @param {function(!Bindings.LiveLocation)} updateDelegate - * @param {!Bindings.LiveLocationPool} locationPool + * @param {function(!LiveLocation)} updateDelegate + * @param {!LiveLocationPool} locationPool * @return {!Location} */ _createLiveLocation(rawLocation, updateDelegate, locationPool) { @@ -384,13 +389,13 @@ class ModelData { /** * @unrestricted */ -class Location extends Bindings.LiveLocationWithPool { +class Location extends LiveLocationWithPool { /** * @param {!SDK.Script} script * @param {!SDK.DebuggerModel.Location} rawLocation * @param {!DebuggerWorkspaceBinding} binding - * @param {function(!Bindings.LiveLocation)} updateDelegate - * @param {!Bindings.LiveLocationPool} locationPool + * @param {function(!LiveLocation)} updateDelegate + * @param {!LiveLocationPool} locationPool */ constructor(script, rawLocation, binding, updateDelegate, locationPool) { super(updateDelegate, locationPool); @@ -426,12 +431,12 @@ class Location extends Bindings.LiveLocationWithPool { } } -class StackTraceTopFrameLocation extends Bindings.LiveLocationWithPool { +class StackTraceTopFrameLocation extends LiveLocationWithPool { /** * @param {!Array} rawLocations * @param {!DebuggerWorkspaceBinding} binding - * @param {function(!Bindings.LiveLocation)} updateDelegate - * @param {!Bindings.LiveLocationPool} locationPool + * @param {function(!LiveLocation)} updateDelegate + * @param {!LiveLocationPool} locationPool */ constructor(rawLocations, binding, updateDelegate, locationPool) { super(updateDelegate, locationPool); @@ -508,20 +513,3 @@ export class DebuggerSourceMapping { uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber) { } } - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @constructor */ -Bindings.DebuggerWorkspaceBinding = DebuggerWorkspaceBinding; - -/** @interface */ -Bindings.DebuggerSourceMapping = DebuggerSourceMapping; - -/** - * @type {!DebuggerWorkspaceBinding} - */ -Bindings.debuggerWorkspaceBinding; diff --git a/resources/unpacked/devtools/front_end/bindings/DefaultScriptMapping.js b/resources/unpacked/devtools/front_end/bindings/DefaultScriptMapping.js index c45aa9c551..de0b2d6e8b 100644 --- a/resources/unpacked/devtools/front_end/bindings/DefaultScriptMapping.js +++ b/resources/unpacked/devtools/front_end/bindings/DefaultScriptMapping.js @@ -27,20 +27,24 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +import {ContentProviderBasedProject} from './ContentProviderBasedProject.js'; +import {DebuggerSourceMapping, DebuggerWorkspaceBinding} from './DebuggerWorkspaceBinding.js'; // eslint-disable-line no-unused-vars + /** - * @implements {Bindings.DebuggerSourceMapping} + * @implements {DebuggerSourceMapping} * @unrestricted */ -export default class DefaultScriptMapping { +export class DefaultScriptMapping { /** * @param {!SDK.DebuggerModel} debuggerModel * @param {!Workspace.Workspace} workspace - * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding + * @param {!DebuggerWorkspaceBinding} debuggerWorkspaceBinding */ constructor(debuggerModel, workspace, debuggerWorkspaceBinding) { this._debuggerModel = debuggerModel; this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; - this._project = new Bindings.ContentProviderBasedProject( + this._project = new ContentProviderBasedProject( workspace, 'debugger:' + debuggerModel.target().id(), Workspace.projectTypes.Debugger, '', true /* isServiceProject */); this._eventListeners = [ @@ -150,12 +154,3 @@ export default class DefaultScriptMapping { const _scriptsSymbol = Symbol('symbol'); const _uiSourceCodeSymbol = Symbol('uiSourceCodeSymbol'); - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @constructor */ -Bindings.DefaultScriptMapping = DefaultScriptMapping; diff --git a/resources/unpacked/devtools/front_end/bindings/FileUtils.js b/resources/unpacked/devtools/front_end/bindings/FileUtils.js index c6ab65672d..8d8aa6f5aa 100644 --- a/resources/unpacked/devtools/front_end/bindings/FileUtils.js +++ b/resources/unpacked/devtools/front_end/bindings/FileUtils.js @@ -250,18 +250,3 @@ export class FileOutputStream { Workspace.fileManager.close(this._fileName); } } - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @interface */ -Bindings.ChunkedReader = ChunkedReader; - -/** @constructor */ -Bindings.ChunkedFileReader = ChunkedFileReader; - -/** @constructor */ -Bindings.FileOutputStream = FileOutputStream; diff --git a/resources/unpacked/devtools/front_end/bindings/LiveLocation.js b/resources/unpacked/devtools/front_end/bindings/LiveLocation.js index e6fe900f8b..5a40d140c5 100644 --- a/resources/unpacked/devtools/front_end/bindings/LiveLocation.js +++ b/resources/unpacked/devtools/front_end/bindings/LiveLocation.js @@ -3,7 +3,7 @@ // found in the LICENSE file. /** @interface */ -export default class LiveLocation { +export class LiveLocation { update() { } @@ -97,18 +97,3 @@ export class LiveLocationPool { } } } - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @interface */ -Bindings.LiveLocation = LiveLocation; - -/** @constructor */ -Bindings.LiveLocationWithPool = LiveLocationWithPool; - -/** @constructor */ -Bindings.LiveLocationPool = LiveLocationPool; diff --git a/resources/unpacked/devtools/front_end/bindings/NetworkProject.js b/resources/unpacked/devtools/front_end/bindings/NetworkProject.js index 95e9ad23ac..19c545caff 100644 --- a/resources/unpacked/devtools/front_end/bindings/NetworkProject.js +++ b/resources/unpacked/devtools/front_end/bindings/NetworkProject.js @@ -37,7 +37,7 @@ export const Events = { /** * @unrestricted */ -export default class NetworkProject { +export class NetworkProject { /** * @param {!Workspace.UISourceCode} uiSourceCode * @param {string} frameId @@ -156,17 +156,3 @@ export default class NetworkProject { const _targetSymbol = Symbol('target'); const _frameAttributionSymbol = Symbol('_frameAttributionSymbol'); - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @constructor */ -Bindings.NetworkProjectManager = NetworkProjectManager; - -Bindings.NetworkProjectManager.Events = Events; - -/** @constructor */ -Bindings.NetworkProject = NetworkProject; diff --git a/resources/unpacked/devtools/front_end/bindings/PresentationConsoleMessageHelper.js b/resources/unpacked/devtools/front_end/bindings/PresentationConsoleMessageHelper.js index 67b29bcf04..5e914a4a65 100644 --- a/resources/unpacked/devtools/front_end/bindings/PresentationConsoleMessageHelper.js +++ b/resources/unpacked/devtools/front_end/bindings/PresentationConsoleMessageHelper.js @@ -28,6 +28,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import {LiveLocation, LiveLocationPool} from './LiveLocation.js'; // eslint-disable-line no-unused-vars + /** * @implements {SDK.SDKModelObserver} */ @@ -79,7 +81,7 @@ export class PresentationConsoleMessageManager { PresentationConsoleMessageManager._symbol = Symbol('PresentationConsoleMessageHelper'); -export default class PresentationConsoleMessageHelper { +export class PresentationConsoleMessageHelper { /** * @param {!SDK.DebuggerModel} debuggerModel */ @@ -97,7 +99,7 @@ export default class PresentationConsoleMessageHelper { SDK.DebuggerModel.Events.ParsedScriptSource, event => setImmediate(this._parsedScriptSource.bind(this, event))); debuggerModel.addEventListener(SDK.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this); - this._locationPool = new Bindings.LiveLocationPool(); + this._locationPool = new LiveLocationPool(); } /** @@ -205,7 +207,7 @@ export class PresentationConsoleMessage { /** * @param {!SDK.ConsoleMessage} message * @param {!SDK.DebuggerModel.Location} rawLocation - * @param {!Bindings.LiveLocationPool} locationPool + * @param {!LiveLocationPool} locationPool */ constructor(message, rawLocation, locationPool) { this._text = message.messageText; @@ -216,7 +218,7 @@ export class PresentationConsoleMessage { } /** - * @param {!Bindings.LiveLocation} liveLocation + * @param {!LiveLocation} liveLocation */ _updateLocation(liveLocation) { if (this._uiMessage) { @@ -236,15 +238,3 @@ export class PresentationConsoleMessage { } } } - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @constructor */ -Bindings.PresentationConsoleMessageManager = PresentationConsoleMessageManager; - -/** @constructor */ -Bindings.PresentationConsoleMessage = PresentationConsoleMessage; diff --git a/resources/unpacked/devtools/front_end/bindings/ResourceMapping.js b/resources/unpacked/devtools/front_end/bindings/ResourceMapping.js index 7ae8db867f..d530d4afb7 100644 --- a/resources/unpacked/devtools/front_end/bindings/ResourceMapping.js +++ b/resources/unpacked/devtools/front_end/bindings/ResourceMapping.js @@ -2,10 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {ContentProviderBasedProject} from './ContentProviderBasedProject.js'; +import {NetworkProject} from './NetworkProject.js'; +import {resourceMetadata} from './ResourceUtils.js'; + /** * @implements {SDK.SDKModelObserver} */ -export default class ResourceMapping { +export class ResourceMapping { /** * @param {!SDK.TargetManager} targetManager * @param {!Workspace.Workspace} workspace @@ -62,8 +66,7 @@ export default class ResourceMapping { if (!uiSourceCode) { return null; } - const offset = - header[_offsetSymbol] || TextUtils.TextRange.createFromLocation(header.startLine, header.startColumn); + const offset = header[offsetSymbol] || TextUtils.TextRange.createFromLocation(header.startLine, header.startColumn); const lineNumber = cssLocation.lineNumber + offset.startLine - header.startLine; let columnNumber = cssLocation.columnNumber; if (cssLocation.lineNumber === header.startLine) { @@ -90,7 +93,7 @@ export default class ResourceMapping { return null; } const offset = - script[_offsetSymbol] || TextUtils.TextRange.createFromLocation(script.lineOffset, script.columnOffset); + script[offsetSymbol] || TextUtils.TextRange.createFromLocation(script.lineOffset, script.columnOffset); const lineNumber = jsLocation.lineNumber + offset.startLine - script.lineOffset; let columnNumber = jsLocation.columnNumber; if (jsLocation.lineNumber === script.lineOffset) { @@ -106,10 +109,10 @@ export default class ResourceMapping { * @return {!Array} */ uiLocationToJSLocations(uiSourceCode, lineNumber, columnNumber) { - if (!uiSourceCode[_symbol]) { + if (!uiSourceCode[symbol]) { return []; } - const target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); + const target = NetworkProject.targetForUISourceCode(uiSourceCode); if (!target) { return []; } @@ -129,10 +132,10 @@ export default class ResourceMapping { * @return {!Array} */ uiLocationToCSSLocations(uiLocation) { - if (!uiLocation.uiSourceCode[_symbol]) { + if (!uiLocation.uiSourceCode[symbol]) { return []; } - const target = Bindings.NetworkProject.targetForUISourceCode(uiLocation.uiSourceCode); + const target = NetworkProject.targetForUISourceCode(uiLocation.uiSourceCode); if (!target) { return []; } @@ -163,9 +166,9 @@ class ModelInfo { */ constructor(workspace, resourceTreeModel) { const target = resourceTreeModel.target(); - this._project = new Bindings.ContentProviderBasedProject( + this._project = new ContentProviderBasedProject( workspace, 'resources:' + target.id(), Workspace.projectTypes.Network, '', false /* isServiceProject */); - Bindings.NetworkProject.setTargetForProject(this._project, target); + NetworkProject.setTargetForProject(this._project, target); /** @type {!Map} */ this._bindings = new Map(); @@ -294,17 +297,16 @@ class ModelInfo { */ class Binding { /** - * @param {!Bindings.ContentProviderBasedProject} project + * @param {!ContentProviderBasedProject} project * @param {!SDK.Resource} resource */ constructor(project, resource) { this._resources = new Set([resource]); this._project = project; this._uiSourceCode = this._project.createUISourceCode(resource.url, resource.contentType()); - this._uiSourceCode[_symbol] = true; - Bindings.NetworkProject.setInitialFrameAttribution(this._uiSourceCode, resource.frameId); - this._project.addUISourceCodeWithProvider( - this._uiSourceCode, this, Bindings.resourceMetadata(resource), resource.mimeType); + this._uiSourceCode[symbol] = true; + NetworkProject.setInitialFrameAttribution(this._uiSourceCode, resource.frameId); + this._project.addUISourceCodeWithProvider(this._uiSourceCode, this, resourceMetadata(resource), resource.mimeType); /** @type {!Array<{stylesheet: !SDK.CSSStyleSheetHeader, edit: ?SDK.CSSModel.Edit}>} */ this._edits = []; } @@ -313,7 +315,7 @@ class Binding { * @return {!Array} */ _inlineStyles() { - const target = Bindings.NetworkProject.targetForUISourceCode(this._uiSourceCode); + const target = NetworkProject.targetForUISourceCode(this._uiSourceCode); const cssModel = target.model(SDK.CSSModel); const stylesheets = []; if (cssModel) { @@ -331,7 +333,7 @@ class Binding { * @return {!Array} */ _inlineScripts() { - const target = Bindings.NetworkProject.targetForUISourceCode(this._uiSourceCode); + const target = NetworkProject.targetForUISourceCode(this._uiSourceCode); const debuggerModel = target.model(SDK.DebuggerModel); if (!debuggerModel) { return []; @@ -369,7 +371,7 @@ class Binding { continue; } const stylesheet = data.stylesheet; - const startLocation = stylesheet[_offsetSymbol] || + const startLocation = stylesheet[offsetSymbol] || TextUtils.TextRange.createFromLocation(stylesheet.startLine, stylesheet.startColumn); const oldRange = edit.oldRange.relativeFrom(startLocation.startLine, startLocation.startColumn); @@ -377,20 +379,20 @@ class Binding { text = new TextUtils.Text(text.replaceRange(oldRange, edit.newText)); for (const script of scripts) { const scriptOffset = - script[_offsetSymbol] || TextUtils.TextRange.createFromLocation(script.lineOffset, script.columnOffset); + script[offsetSymbol] || TextUtils.TextRange.createFromLocation(script.lineOffset, script.columnOffset); if (!scriptOffset.follows(oldRange)) { continue; } - script[_offsetSymbol] = scriptOffset.rebaseAfterTextEdit(oldRange, newRange); + script[offsetSymbol] = scriptOffset.rebaseAfterTextEdit(oldRange, newRange); Bindings.debuggerWorkspaceBinding.updateLocations(script); } for (const style of styles) { const styleOffset = - style[_offsetSymbol] || TextUtils.TextRange.createFromLocation(style.startLine, style.startColumn); + style[offsetSymbol] || TextUtils.TextRange.createFromLocation(style.startLine, style.startColumn); if (!styleOffset.follows(oldRange)) { continue; } - style[_offsetSymbol] = styleOffset.rebaseAfterTextEdit(oldRange, newRange); + style[offsetSymbol] = styleOffset.rebaseAfterTextEdit(oldRange, newRange); Bindings.cssWorkspaceBinding.updateLocations(style); } } @@ -402,7 +404,7 @@ class Binding { */ addResource(resource) { this._resources.add(resource); - Bindings.NetworkProject.addFrameAttribution(this._uiSourceCode, resource.frameId); + NetworkProject.addFrameAttribution(this._uiSourceCode, resource.frameId); } /** @@ -410,7 +412,7 @@ class Binding { */ removeResource(resource) { this._resources.delete(resource); - Bindings.NetworkProject.removeFrameAttribution(this._uiSourceCode, resource.frameId); + NetworkProject.removeFrameAttribution(this._uiSourceCode, resource.frameId); } dispose() { @@ -461,17 +463,5 @@ class Binding { } } -export const _symbol = Symbol('Bindings.ResourceMapping._symbol'); -export const _offsetSymbol = Symbol('Bindings.ResourceMapping._offsetSymbol'); - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @constructor */ -Bindings.ResourceMapping = ResourceMapping; - -Bindings.ResourceMapping._symbol = _symbol; -Bindings.ResourceMapping._offsetSymbol = _offsetSymbol; +export const symbol = Symbol('Bindings.ResourceMapping._symbol'); +export const offsetSymbol = Symbol('Bindings.ResourceMapping._offsetSymbol'); diff --git a/resources/unpacked/devtools/front_end/bindings/ResourceScriptMapping.js b/resources/unpacked/devtools/front_end/bindings/ResourceScriptMapping.js index ee5dcb9ac3..839f419d06 100644 --- a/resources/unpacked/devtools/front_end/bindings/ResourceScriptMapping.js +++ b/resources/unpacked/devtools/front_end/bindings/ResourceScriptMapping.js @@ -27,15 +27,21 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +import {ContentProviderBasedProject} from './ContentProviderBasedProject.js'; +import {DebuggerSourceMapping, DebuggerWorkspaceBinding} from './DebuggerWorkspaceBinding.js'; // eslint-disable-line no-unused-vars +import {NetworkProject} from './NetworkProject.js'; +import {frameIdForScript, metadataForURL} from './ResourceUtils.js'; + /** - * @implements {Bindings.DebuggerSourceMapping} + * @implements {DebuggerSourceMapping} * @unrestricted */ -export default class ResourceScriptMapping { +export class ResourceScriptMapping { /** * @param {!SDK.DebuggerModel} debuggerModel * @param {!Workspace.Workspace} workspace - * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding + * @param {!DebuggerWorkspaceBinding} debuggerWorkspaceBinding */ constructor(debuggerModel, workspace, debuggerWorkspaceBinding) { this._debuggerModel = debuggerModel; @@ -44,7 +50,7 @@ export default class ResourceScriptMapping { /** @type {!Map.} */ this._uiSourceCodeToScriptFile = new Map(); - /** @type {!Map} */ + /** @type {!Map} */ this._projects = new Map(); /** @type {!Set} */ @@ -61,7 +67,7 @@ export default class ResourceScriptMapping { /** * @param {!SDK.Script} script - * @return {!Bindings.ContentProviderBasedProject} + * @return {!ContentProviderBasedProject} */ _project(script) { const frameId = script[_frameIdSymbol]; @@ -71,9 +77,9 @@ export default class ResourceScriptMapping { if (!project) { const projectType = script.isContentScript() ? Workspace.projectTypes.ContentScripts : Workspace.projectTypes.Network; - project = new Bindings.ContentProviderBasedProject( + project = new ContentProviderBasedProject( this._workspace, projectId, projectType, '' /* displayName */, false /* isServiceProject */); - Bindings.NetworkProject.setTargetForProject(project, this._debuggerModel.target()); + NetworkProject.setTargetForProject(project, this._debuggerModel.target()); this._projects.set(projectId, project); } return project; @@ -165,7 +171,7 @@ export default class ResourceScriptMapping { } this._acceptedScripts.add(script); const originalContentProvider = script.originalContentProvider(); - const frameId = Bindings.frameIdForScript(script); + const frameId = frameIdForScript(script); script[_frameIdSymbol] = frameId; const url = script.sourceURL; @@ -180,8 +186,8 @@ export default class ResourceScriptMapping { // Create UISourceCode. const uiSourceCode = project.createUISourceCode(url, originalContentProvider.contentType()); - Bindings.NetworkProject.setInitialFrameAttribution(uiSourceCode, frameId); - const metadata = Bindings.metadataForURL(this._debuggerModel.target(), frameId, url); + NetworkProject.setInitialFrameAttribution(uiSourceCode, frameId); + const metadata = metadataForURL(this._debuggerModel.target(), frameId, url); // Bind UISourceCode to scripts. const scriptFile = new ResourceScriptFile(this, uiSourceCode, [script]); @@ -467,15 +473,3 @@ ResourceScriptFile.Events = { DidMergeToVM: Symbol('DidMergeToVM'), DidDivergeFromVM: Symbol('DidDivergeFromVM'), }; - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @constructor */ -Bindings.ResourceScriptMapping = ResourceScriptMapping; - -/** @constructor */ -Bindings.ResourceScriptFile = ResourceScriptFile; diff --git a/resources/unpacked/devtools/front_end/bindings/ResourceUtils.js b/resources/unpacked/devtools/front_end/bindings/ResourceUtils.js index 1467d1f714..38d7645831 100644 --- a/resources/unpacked/devtools/front_end/bindings/ResourceUtils.js +++ b/resources/unpacked/devtools/front_end/bindings/ResourceUtils.js @@ -50,7 +50,7 @@ export function displayNameForURL(url) { return ''; } - const resource = Bindings.resourceForURL(url); + const resource = resourceForURL(url); if (resource) { return resource.displayName; } @@ -99,7 +99,7 @@ export function metadataForURL(target, frameId, url) { if (!frame) { return null; } - return Bindings.resourceMetadata(frame.resourceForURL(url)); + return resourceMetadata(frame.resourceForURL(url)); } /** @@ -129,15 +129,3 @@ export function frameIdForScript(script) { } return resourceTreeModel.mainFrame.id; } - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -Bindings.resourceForURL = resourceForURL; -Bindings.displayNameForURL = displayNameForURL; -Bindings.metadataForURL = metadataForURL; -Bindings.resourceMetadata = resourceMetadata; -Bindings.frameIdForScript = frameIdForScript; diff --git a/resources/unpacked/devtools/front_end/bindings/SASSSourceMapping.js b/resources/unpacked/devtools/front_end/bindings/SASSSourceMapping.js index 3be1b4eb3c..7bba5b21f6 100644 --- a/resources/unpacked/devtools/front_end/bindings/SASSSourceMapping.js +++ b/resources/unpacked/devtools/front_end/bindings/SASSSourceMapping.js @@ -28,10 +28,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import {ContentProviderBasedProject} from './ContentProviderBasedProject.js'; +import {SourceMapping} from './CSSWorkspaceBinding.js'; // eslint-disable-line no-unused-vars +import {NetworkProject} from './NetworkProject.js'; + /** - * @implements {Bindings.CSSWorkspaceBinding.SourceMapping} + * @implements {SourceMapping} */ -export default class SASSSourceMapping { +export class SASSSourceMapping { /** * @param {!SDK.Target} target * @param {!SDK.SourceMapManager} sourceMapManager @@ -39,9 +43,9 @@ export default class SASSSourceMapping { */ constructor(target, sourceMapManager, workspace) { this._sourceMapManager = sourceMapManager; - this._project = new Bindings.ContentProviderBasedProject( + this._project = new ContentProviderBasedProject( workspace, 'cssSourceMaps:' + target.id(), Workspace.projectTypes.Network, '', false /* isServiceProject */); - Bindings.NetworkProject.setTargetForProject(this._project, target); + NetworkProject.setTargetForProject(this._project, target); this._eventListeners = [ this._sourceMapManager.addEventListener( @@ -68,7 +72,7 @@ export default class SASSSourceMapping { for (const sassURL of sourceMap.sourceURLs()) { let uiSourceCode = this._project.uiSourceCodeForURL(sassURL); if (uiSourceCode) { - Bindings.NetworkProject.addFrameAttribution(uiSourceCode, header.frameId); + NetworkProject.addFrameAttribution(uiSourceCode, header.frameId); continue; } @@ -78,7 +82,7 @@ export default class SASSSourceMapping { const metadata = typeof embeddedContent === 'string' ? new Workspace.UISourceCodeMetadata(null, embeddedContent.length) : null; uiSourceCode = this._project.createUISourceCode(sassURL, contentProvider.contentType()); - Bindings.NetworkProject.setInitialFrameAttribution(uiSourceCode, header.frameId); + NetworkProject.setInitialFrameAttribution(uiSourceCode, header.frameId); uiSourceCode[_sourceMapSymbol] = sourceMap; this._project.addUISourceCodeWithProvider(uiSourceCode, contentProvider, metadata, mimeType); } @@ -96,7 +100,7 @@ export default class SASSSourceMapping { for (const sassURL of sourceMap.sourceURLs()) { if (headers.length) { const uiSourceCode = /** @type {!Workspace.UISourceCode} */ (this._project.uiSourceCodeForURL(sassURL)); - Bindings.NetworkProject.removeFrameAttribution(uiSourceCode, header.frameId); + NetworkProject.removeFrameAttribution(uiSourceCode, header.frameId); } else { this._project.removeFile(sassURL); } @@ -177,12 +181,3 @@ export default class SASSSourceMapping { } const _sourceMapSymbol = Symbol('sourceMap'); - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @constructor */ -Bindings.SASSSourceMapping = SASSSourceMapping; diff --git a/resources/unpacked/devtools/front_end/bindings/StylesSourceMapping.js b/resources/unpacked/devtools/front_end/bindings/StylesSourceMapping.js index fbd06788b9..71f3fd8120 100644 --- a/resources/unpacked/devtools/front_end/bindings/StylesSourceMapping.js +++ b/resources/unpacked/devtools/front_end/bindings/StylesSourceMapping.js @@ -28,11 +28,16 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import {ContentProviderBasedProject} from './ContentProviderBasedProject.js'; +import {SourceMapping} from './CSSWorkspaceBinding.js'; // eslint-disable-line no-unused-vars +import {NetworkProject} from './NetworkProject.js'; +import {metadataForURL} from './ResourceUtils.js'; + /** - * @implements {Bindings.CSSWorkspaceBinding.SourceMapping} + * @implements {SourceMapping} * @unrestricted */ -export default class StylesSourceMapping { +export class StylesSourceMapping { /** * @param {!SDK.CSSModel} cssModel * @param {!Workspace.Workspace} workspace @@ -40,9 +45,9 @@ export default class StylesSourceMapping { constructor(cssModel, workspace) { this._cssModel = cssModel; const target = this._cssModel.target(); - this._project = new Bindings.ContentProviderBasedProject( + this._project = new ContentProviderBasedProject( workspace, 'css:' + target.id(), Workspace.projectTypes.Network, '', false /* isServiceProject */); - Bindings.NetworkProject.setTargetForProject(this._project, target); + NetworkProject.setTargetForProject(this._project, target); /** @type {!Map.} */ this._styleFiles = new Map(); @@ -178,7 +183,7 @@ export default class StylesSourceMapping { export class StyleFile { /** * @param {!SDK.CSSModel} cssModel - * @param {!Bindings.ContentProviderBasedProject} project + * @param {!ContentProviderBasedProject} project * @param {!SDK.CSSStyleSheetHeader} header */ constructor(cssModel, project, header) { @@ -190,11 +195,11 @@ export class StyleFile { const target = cssModel.target(); const url = header.resourceURL(); - const metadata = Bindings.metadataForURL(target, header.frameId, url); + const metadata = metadataForURL(target, header.frameId, url); this._uiSourceCode = this._project.createUISourceCode(url, header.contentType()); this._uiSourceCode[StyleFile._symbol] = this; - Bindings.NetworkProject.setInitialFrameAttribution(this._uiSourceCode, header.frameId); + NetworkProject.setInitialFrameAttribution(this._uiSourceCode, header.frameId); this._project.addUISourceCodeWithProvider(this._uiSourceCode, this, metadata, 'text/css'); this._eventListeners = [ @@ -212,7 +217,7 @@ export class StyleFile { */ addHeader(header) { this._headers.add(header); - Bindings.NetworkProject.addFrameAttribution(this._uiSourceCode, header.frameId); + NetworkProject.addFrameAttribution(this._uiSourceCode, header.frameId); } /** @@ -220,7 +225,7 @@ export class StyleFile { */ removeHeader(header) { this._headers.delete(header); - Bindings.NetworkProject.removeFrameAttribution(this._uiSourceCode, header.frameId); + NetworkProject.removeFrameAttribution(this._uiSourceCode, header.frameId); } /** @@ -360,15 +365,3 @@ export class StyleFile { StyleFile._symbol = Symbol('Bindings.StyleFile._symbol'); StyleFile.updateTimeout = 200; - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @constructor */ -Bindings.StylesSourceMapping = StylesSourceMapping; - -/** @constructor */ -Bindings.StyleFile = StyleFile; diff --git a/resources/unpacked/devtools/front_end/bindings/TempFile.js b/resources/unpacked/devtools/front_end/bindings/TempFile.js index cc1fdee81d..99d548032e 100644 --- a/resources/unpacked/devtools/front_end/bindings/TempFile.js +++ b/resources/unpacked/devtools/front_end/bindings/TempFile.js @@ -28,7 +28,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -export default class TempFile { +import {ChunkedFileReader, ChunkedReader} from './FileUtils.js'; // eslint-disable-line no-unused-vars + +export class TempFile { constructor() { /** @type {?Blob} */ this._lastBlob = null; @@ -88,7 +90,7 @@ export default class TempFile { /** * @param {!Common.OutputStream} outputStream - * @param {function(!Bindings.ChunkedReader)=} progress + * @param {function(!ChunkedReader)=} progress * @return {!Promise} */ copyToOutputStream(outputStream, progress) { @@ -96,7 +98,7 @@ export default class TempFile { outputStream.close(); return Promise.resolve(/** @type {?FileError} */ (null)); } - const reader = new Bindings.ChunkedFileReader(/** @type {!Blob} */ (this._lastBlob), 10 * 1000 * 1000, progress); + const reader = new ChunkedFileReader(/** @type {!Blob} */ (this._lastBlob), 10 * 1000 * 1000, progress); return reader.read(outputStream).then(success => success ? null : reader.error()); } @@ -184,23 +186,3 @@ export class TempFileBackingStorage { return this._file ? this._file.copyToOutputStream(outputStream) : Promise.resolve(null); } } - -/* Legacy exported object */ -self.Bindings = self.Bindings || {}; - -/* Legacy exported object */ -Bindings = Bindings || {}; - -/** @constructor */ -Bindings.TempFile = TempFile; - -/** @constructor */ -Bindings.TempFileBackingStorage = TempFileBackingStorage; - -/** - * @typedef {{ - * startOffset: number, - * endOffset: number - * }} - */ -Bindings.TempFileBackingStorage.Chunk; diff --git a/resources/unpacked/devtools/front_end/bindings/bindings-legacy.js b/resources/unpacked/devtools/front_end/bindings/bindings-legacy.js new file mode 100644 index 0000000000..b5d2ec1805 --- /dev/null +++ b/resources/unpacked/devtools/front_end/bindings/bindings-legacy.js @@ -0,0 +1,143 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import * as BindingsModule from './bindings.js'; + +self.Bindings = self.Bindings || {}; +Bindings = Bindings || {}; + +/** @constructor */ +Bindings.BlackboxManager = BindingsModule.BlackboxManager.BlackboxManager; + +/** @constructor */ +Bindings.BreakpointManager = BindingsModule.BreakpointManager.BreakpointManager; + +/** @enum {symbol} */ +Bindings.BreakpointManager.Events = BindingsModule.BreakpointManager.Events; + +/** @constructor */ +Bindings.BreakpointManager.Breakpoint = BindingsModule.BreakpointManager.Breakpoint; + +Bindings.BreakpointManager.ModelBreakpoint = BindingsModule.BreakpointManager.ModelBreakpoint; + +/** @constructor */ +Bindings.CSSWorkspaceBinding = BindingsModule.CSSWorkspaceBinding.CSSWorkspaceBinding; + +/** @interface */ +Bindings.CSSWorkspaceBinding.SourceMapping = BindingsModule.CSSWorkspaceBinding.SourceMapping; + +/** @constructor */ +Bindings.CSSWorkspaceBinding.ModelInfo = BindingsModule.CSSWorkspaceBinding.ModelInfo; + +/** @constructor */ +Bindings.CompilerScriptMapping = BindingsModule.CompilerScriptMapping.CompilerScriptMapping; + +/** @constructor */ +Bindings.ContentProviderBasedProject = BindingsModule.ContentProviderBasedProject.ContentProviderBasedProject; + +/** @constructor */ +Bindings.DebuggerWorkspaceBinding = BindingsModule.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding; + +/** @interface */ +Bindings.DebuggerSourceMapping = BindingsModule.DebuggerWorkspaceBinding.DebuggerSourceMapping; + +/** @constructor */ +Bindings.DefaultScriptMapping = BindingsModule.DefaultScriptMapping.DefaultScriptMapping; + +/** @interface */ +Bindings.ChunkedReader = BindingsModule.FileUtils.ChunkedReader; + +/** @constructor */ +Bindings.ChunkedFileReader = BindingsModule.FileUtils.ChunkedFileReader; + +/** @constructor */ +Bindings.FileOutputStream = BindingsModule.FileUtils.FileOutputStream; + +/** @interface */ +Bindings.LiveLocation = BindingsModule.LiveLocation.LiveLocation; + +/** @constructor */ +Bindings.LiveLocationWithPool = BindingsModule.LiveLocation.LiveLocationWithPool; + +/** @constructor */ +Bindings.LiveLocationPool = BindingsModule.LiveLocation.LiveLocationPool; + +/** @constructor */ +Bindings.NetworkProjectManager = BindingsModule.NetworkProject.NetworkProjectManager; + +Bindings.NetworkProjectManager.Events = BindingsModule.NetworkProject.Events; + +/** @constructor */ +Bindings.NetworkProject = BindingsModule.NetworkProject.NetworkProject; + +/** @constructor */ +Bindings.PresentationConsoleMessageManager = + BindingsModule.PresentationConsoleMessageHelper.PresentationConsoleMessageManager; + +/** @constructor */ +Bindings.PresentationConsoleMessage = BindingsModule.PresentationConsoleMessageHelper.PresentationConsoleMessage; + +/** @constructor */ +Bindings.ResourceMapping = BindingsModule.ResourceMapping.ResourceMapping; + +Bindings.ResourceMapping._symbol = BindingsModule.ResourceMapping.symbol; +Bindings.ResourceMapping._offsetSymbol = BindingsModule.ResourceMapping.offsetSymbol; + +/** @constructor */ +Bindings.ResourceScriptMapping = BindingsModule.ResourceScriptMapping.ResourceScriptMapping; + +/** @constructor */ +Bindings.ResourceScriptFile = BindingsModule.ResourceScriptMapping.ResourceScriptFile; + +Bindings.resourceForURL = BindingsModule.ResourceUtils.resourceForURL; +Bindings.displayNameForURL = BindingsModule.ResourceUtils.displayNameForURL; +Bindings.metadataForURL = BindingsModule.ResourceUtils.metadataForURL; +Bindings.resourceMetadata = BindingsModule.ResourceUtils.resourceMetadata; +Bindings.frameIdForScript = BindingsModule.ResourceUtils.frameIdForScript; + +/** @constructor */ +Bindings.SASSSourceMapping = BindingsModule.SASSSourceMapping.SASSSourceMapping; + +/** @constructor */ +Bindings.StylesSourceMapping = BindingsModule.StylesSourceMapping.StylesSourceMapping; + +/** @constructor */ +Bindings.StyleFile = BindingsModule.StylesSourceMapping.StyleFile; + +/** @constructor */ +Bindings.TempFile = BindingsModule.TempFile.TempFile; + +/** @constructor */ +Bindings.TempFileBackingStorage = BindingsModule.TempFile.TempFileBackingStorage; + +/** @type {!BindingsModule.BlackboxManager.BlackboxManager} */ +Bindings.blackboxManager; + +/** @typedef {{ + * breakpoint: !BindingsModule.BreakpointManager.Breakpoint, + * uiLocation: !Workspace.UILocation + * }} + */ +Bindings.BreakpointManager.BreakpointLocation; + +/** @type {!BindingsModule.BreakpointManager.BreakpointManager} */ +Bindings.breakpointManager; + +/** + * @type {!BindingsModule.CSSWorkspaceBinding.CSSWorkspaceBinding} + */ +Bindings.cssWorkspaceBinding; + +/** + * @type {!BindingsModule.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding} + */ +Bindings.debuggerWorkspaceBinding; + +/** + * @typedef {{ + * startOffset: number, + * endOffset: number + * }} + */ +Bindings.TempFileBackingStorage.Chunk; diff --git a/resources/unpacked/devtools/front_end/bindings/bindings.js b/resources/unpacked/devtools/front_end/bindings/bindings.js index ad6fd2fcad..34ffda9e9b 100644 --- a/resources/unpacked/devtools/front_end/bindings/bindings.js +++ b/resources/unpacked/devtools/front_end/bindings/bindings.js @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import './LiveLocation.js'; -import './ResourceMapping.js'; - import * as BlackboxManager from './BlackboxManager.js'; import * as BreakpointManager from './BreakpointManager.js'; import * as CompilerScriptMapping from './CompilerScriptMapping.js'; diff --git a/resources/unpacked/devtools/front_end/bindings/module.json b/resources/unpacked/devtools/front_end/bindings/module.json index eb6f9ef7a2..2a047eb8fd 100644 --- a/resources/unpacked/devtools/front_end/bindings/module.json +++ b/resources/unpacked/devtools/front_end/bindings/module.json @@ -8,6 +8,7 @@ "scripts": [], "modules": [ "bindings.js", + "bindings-legacy.js", "LiveLocation.js", "ResourceMapping.js", "CompilerScriptMapping.js", diff --git a/resources/unpacked/devtools/front_end/browser_debugger/DOMBreakpointsSidebarPane.js b/resources/unpacked/devtools/front_end/browser_debugger/DOMBreakpointsSidebarPane.js index 0a0d43f7bd..eabd0f7a49 100644 --- a/resources/unpacked/devtools/front_end/browser_debugger/DOMBreakpointsSidebarPane.js +++ b/resources/unpacked/devtools/front_end/browser_debugger/DOMBreakpointsSidebarPane.js @@ -95,7 +95,7 @@ export class DOMBreakpointsSidebarPane extends UI.VBox { }); const description = createElement('div'); - const breakpointTypeLabel = BrowserDebugger.DOMBreakpointsSidebarPane.BreakpointTypeLabels.get(item.type); + const breakpointTypeLabel = BreakpointTypeLabels.get(item.type); description.textContent = breakpointTypeLabel; const linkifiedNode = createElementWithClass('monospace'); linkifiedNode.style.display = 'block'; @@ -348,21 +348,3 @@ export class ContextMenuProvider { } } } - -/* Legacy exported object */ -self.BrowserDebugger = self.BrowserDebugger || {}; - -/* Legacy exported object */ -BrowserDebugger = BrowserDebugger || {}; - -/** - * @constructor - */ -BrowserDebugger.DOMBreakpointsSidebarPane = DOMBreakpointsSidebarPane; - -BrowserDebugger.DOMBreakpointsSidebarPane.BreakpointTypeLabels = BreakpointTypeLabels; - -/** @typedef {!{element: !Element, checkbox: !Element, breakpoint: !SDK.DOMDebuggerModel.DOMBreakpoint}} */ -BrowserDebugger.DOMBreakpointsSidebarPane.Item; - -BrowserDebugger.DOMBreakpointsSidebarPane.ContextMenuProvider = ContextMenuProvider; diff --git a/resources/unpacked/devtools/front_end/browser_debugger/EventListenerBreakpointsSidebarPane.js b/resources/unpacked/devtools/front_end/browser_debugger/EventListenerBreakpointsSidebarPane.js index 6a6a4ffa18..e12ffaaede 100644 --- a/resources/unpacked/devtools/front_end/browser_debugger/EventListenerBreakpointsSidebarPane.js +++ b/resources/unpacked/devtools/front_end/browser_debugger/EventListenerBreakpointsSidebarPane.js @@ -160,17 +160,3 @@ export class EventListenerBreakpointsSidebarPane extends UI.VBox { } } } - -/* Legacy exported object */ -self.BrowserDebugger = self.BrowserDebugger || {}; - -/* Legacy exported object */ -BrowserDebugger = BrowserDebugger || {}; - -/** - * @constructor - */ -BrowserDebugger.EventListenerBreakpointsSidebarPane = EventListenerBreakpointsSidebarPane; - -/** @typedef {!{element: !UI.TreeElement, checkbox: !Element}} */ -BrowserDebugger.EventListenerBreakpointsSidebarPane.Item; diff --git a/resources/unpacked/devtools/front_end/browser_debugger/ObjectEventListenersSidebarPane.js b/resources/unpacked/devtools/front_end/browser_debugger/ObjectEventListenersSidebarPane.js index 873538fcb6..f4ffba5928 100644 --- a/resources/unpacked/devtools/front_end/browser_debugger/ObjectEventListenersSidebarPane.js +++ b/resources/unpacked/devtools/front_end/browser_debugger/ObjectEventListenersSidebarPane.js @@ -27,7 +27,7 @@ export class ObjectEventListenersSidebarPane extends UI.VBox { update() { if (this._lastRequestedContext) { - this._lastRequestedContext.runtimeModel.releaseObjectGroup(_objectGroupName); + this._lastRequestedContext.runtimeModel.releaseObjectGroup(objectGroupName); delete this._lastRequestedContext; } const executionContext = UI.context.flavor(SDK.ExecutionContext); @@ -69,7 +69,7 @@ export class ObjectEventListenersSidebarPane extends UI.VBox { .evaluate( { expression: 'self', - objectGroup: _objectGroupName, + objectGroup: objectGroupName, includeCommandLineAPI: false, silent: true, returnByValue: false, @@ -89,17 +89,4 @@ export class ObjectEventListenersSidebarPane extends UI.VBox { } } -export const _objectGroupName = 'object-event-listeners-sidebar-pane'; - -/* Legacy exported object */ -self.BrowserDebugger = self.BrowserDebugger || {}; - -/* Legacy exported object */ -BrowserDebugger = BrowserDebugger || {}; - -/** - * @constructor - */ -BrowserDebugger.ObjectEventListenersSidebarPane = ObjectEventListenersSidebarPane; - -BrowserDebugger.ObjectEventListenersSidebarPane._objectGroupName = _objectGroupName; +export const objectGroupName = 'object-event-listeners-sidebar-pane'; diff --git a/resources/unpacked/devtools/front_end/browser_debugger/XHRBreakpointsSidebarPane.js b/resources/unpacked/devtools/front_end/browser_debugger/XHRBreakpointsSidebarPane.js index 601ec7b2d1..484d1e2328 100644 --- a/resources/unpacked/devtools/front_end/browser_debugger/XHRBreakpointsSidebarPane.js +++ b/resources/unpacked/devtools/front_end/browser_debugger/XHRBreakpointsSidebarPane.js @@ -61,7 +61,7 @@ export class XHRBreakpointsSidebarPane extends UI.VBox { * @param {boolean} accept * @param {!Element} e * @param {string} text - * @this {BrowserDebugger.XHRBreakpointsSidebarPane} + * @this {XHRBreakpointsSidebarPane} */ function finishEditing(accept, e, text) { this._removeListElement(inputElementContainer); @@ -242,7 +242,7 @@ export class XHRBreakpointsSidebarPane extends UI.VBox { const contextMenu = new UI.ContextMenu(event); /** - * @this {BrowserDebugger.XHRBreakpointsSidebarPane} + * @this {XHRBreakpointsSidebarPane} */ function removeBreakpoint() { SDK.domDebuggerManager.removeXHRBreakpoint(url); @@ -250,7 +250,7 @@ export class XHRBreakpointsSidebarPane extends UI.VBox { } /** - * @this {BrowserDebugger.XHRBreakpointsSidebarPane} + * @this {XHRBreakpointsSidebarPane} */ function removeAllBreakpoints() { for (const url of this._breakpointElements.keys()) { @@ -295,7 +295,7 @@ export class XHRBreakpointsSidebarPane extends UI.VBox { * @param {boolean} accept * @param {!Element} e * @param {string} text - * @this {BrowserDebugger.XHRBreakpointsSidebarPane} + * @this {XHRBreakpointsSidebarPane} */ function finishEditing(accept, e, text) { this._removeListElement(inputElement); @@ -356,14 +356,3 @@ export class XHRBreakpointsSidebarPane extends UI.VBox { } } } - -/* Legacy exported object */ -self.BrowserDebugger = self.BrowserDebugger || {}; - -/* Legacy exported object */ -BrowserDebugger = BrowserDebugger || {}; - -/** - * @constructor - */ -BrowserDebugger.XHRBreakpointsSidebarPane = XHRBreakpointsSidebarPane; diff --git a/resources/unpacked/devtools/front_end/browser_debugger/browser_debugger-legacy.js b/resources/unpacked/devtools/front_end/browser_debugger/browser_debugger-legacy.js new file mode 100644 index 0000000000..d092f7c5fe --- /dev/null +++ b/resources/unpacked/devtools/front_end/browser_debugger/browser_debugger-legacy.js @@ -0,0 +1,45 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import * as BrowserDebuggerModule from './browser_debugger.js'; + +self.BrowserDebugger = self.BrowserDebugger || {}; +BrowserDebugger = BrowserDebugger || {}; + +/** + * @constructor + */ +BrowserDebugger.DOMBreakpointsSidebarPane = BrowserDebuggerModule.DOMBreakpointsSidebarPane.DOMBreakpointsSidebarPane; + +BrowserDebugger.DOMBreakpointsSidebarPane.BreakpointTypeLabels = + BrowserDebuggerModule.DOMBreakpointsSidebarPane.BreakpointTypeLabels; + +BrowserDebugger.DOMBreakpointsSidebarPane.ContextMenuProvider = + BrowserDebuggerModule.DOMBreakpointsSidebarPane.ContextMenuProvider; + +/** + * @constructor + */ +BrowserDebugger.EventListenerBreakpointsSidebarPane = + BrowserDebuggerModule.EventListenerBreakpointsSidebarPane.EventListenerBreakpointsSidebarPane; + +/** + * @constructor + */ +BrowserDebugger.ObjectEventListenersSidebarPane = + BrowserDebuggerModule.ObjectEventListenersSidebarPane.ObjectEventListenersSidebarPane; + +BrowserDebugger.ObjectEventListenersSidebarPane._objectGroupName = + BrowserDebuggerModule.ObjectEventListenersSidebarPane.objectGroupName; + +/** + * @constructor + */ +BrowserDebugger.XHRBreakpointsSidebarPane = BrowserDebuggerModule.XHRBreakpointsSidebarPane.XHRBreakpointsSidebarPane; + +/** @typedef {!{element: !Element, checkbox: !Element, breakpoint: !SDK.DOMDebuggerModel.DOMBreakpoint}} */ +BrowserDebugger.DOMBreakpointsSidebarPane.Item; + +/** @typedef {!{element: !UI.TreeElement, checkbox: !Element}} */ +BrowserDebugger.EventListenerBreakpointsSidebarPane.Item; diff --git a/resources/unpacked/devtools/front_end/browser_debugger/module.json b/resources/unpacked/devtools/front_end/browser_debugger/module.json index 346a793cdb..b3e9a11b6d 100644 --- a/resources/unpacked/devtools/front_end/browser_debugger/module.json +++ b/resources/unpacked/devtools/front_end/browser_debugger/module.json @@ -120,6 +120,7 @@ ], "modules": [ "browser_debugger.js", + "browser_debugger-legacy.js", "DOMBreakpointsSidebarPane.js", "EventListenerBreakpointsSidebarPane.js", "ObjectEventListenersSidebarPane.js", diff --git a/resources/unpacked/devtools/front_end/cookie_table/CookiesTable.js b/resources/unpacked/devtools/front_end/cookie_table/CookiesTable.js index b4674242cb..8b8f706b2d 100644 --- a/resources/unpacked/devtools/front_end/cookie_table/CookiesTable.js +++ b/resources/unpacked/devtools/front_end/cookie_table/CookiesTable.js @@ -28,6 +28,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +const expiresSessionValue = Common.UIString('Session'); + /** * @unrestricted */ @@ -52,7 +54,7 @@ export class CookiesTable extends UI.VBox { const editable = !!saveCallback; - const columns = /** @type {!Array} */ ([ + const columns = /** @type {!Array} */ ([ { id: SDK.Cookie.Attributes.Name, title: ls`Name`, @@ -428,12 +430,12 @@ export class CookiesTable extends UI.VBox { data[SDK.Cookie.Attributes.Expires] = Number.secondsToString(parseInt(cookie.maxAge(), 10)); } else if (cookie.expires()) { if (cookie.expires() < 0) { - data[SDK.Cookie.Attributes.Expires] = _expiresSessionValue; + data[SDK.Cookie.Attributes.Expires] = expiresSessionValue; } else { data[SDK.Cookie.Attributes.Expires] = new Date(cookie.expires()).toISOString(); } } else { - data[SDK.Cookie.Attributes.Expires] = cookie.type() === SDK.Cookie.Type.Request ? ls`N/A` : _expiresSessionValue; + data[SDK.Cookie.Attributes.Expires] = cookie.type() === SDK.Cookie.Type.Request ? ls`N/A` : expiresSessionValue; } data[SDK.Cookie.Attributes.Size] = cookie.size(); @@ -491,7 +493,7 @@ export class CookiesTable extends UI.VBox { node.data[SDK.Cookie.Attributes.Path] = '/'; } if (node.data[SDK.Cookie.Attributes.Expires] === null) { - node.data[SDK.Cookie.Attributes.Expires] = _expiresSessionValue; + node.data[SDK.Cookie.Attributes.Expires] = expiresSessionValue; } } @@ -522,7 +524,7 @@ export class CookiesTable extends UI.VBox { cookie.addAttribute(SDK.Cookie.Attributes.Domain, data[SDK.Cookie.Attributes.Domain]); cookie.addAttribute(SDK.Cookie.Attributes.Path, data[SDK.Cookie.Attributes.Path]); - if (data.expires && data.expires !== _expiresSessionValue) { + if (data.expires && data.expires !== expiresSessionValue) { cookie.addAttribute(SDK.Cookie.Attributes.Expires, (new Date(data[SDK.Cookie.Attributes.Expires])).toUTCString()); } if (data[SDK.Cookie.Attributes.HttpOnly]) { @@ -573,7 +575,7 @@ export class CookiesTable extends UI.VBox { * @returns {boolean} */ _isValidDate(date) { - return date === '' || date === _expiresSessionValue || !isNaN(Date.parse(date)); + return date === '' || date === expiresSessionValue || !isNaN(Date.parse(date)); } _refresh() { @@ -660,23 +662,3 @@ export class DataGridNode extends DataGrid.DataGridNode { return cell; } } - -/** @const */ -export const _expiresSessionValue = Common.UIString('Session'); - -/* Legacy exported object */ -self.CookieTable = self.CookieTable || {}; - -/* Legacy exported object */ -CookieTable = CookieTable || {}; - -/** @constructor */ -CookieTable.CookiesTable = CookiesTable; - -CookieTable.CookiesTable._expiresSessionValue = _expiresSessionValue; - -/** @constructor */ -CookieTable.DataGridNode = DataGridNode; - -/** @typedef {!{uiString: string, attribute: ?SDK.Cookie.Attributes}} */ -CookieTable.BlockedReason; diff --git a/resources/unpacked/devtools/front_end/cookie_table/cookie_table-legacy.js b/resources/unpacked/devtools/front_end/cookie_table/cookie_table-legacy.js new file mode 100644 index 0000000000..1dcfb5082f --- /dev/null +++ b/resources/unpacked/devtools/front_end/cookie_table/cookie_table-legacy.js @@ -0,0 +1,17 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import * as CookieTableModule from './cookie_table.js'; + +self.CookieTable = self.CookieTable || {}; +CookieTable = CookieTable || {}; + +/** @constructor */ +CookieTable.CookiesTable = CookieTableModule.CookiesTable.CookiesTable; + +/** @constructor */ +CookieTable.DataGridNode = CookieTableModule.CookiesTable.DataGridNode; + +/** @typedef {!{uiString: string, attribute: ?SDK.Cookie.Attributes}} */ +CookieTable.BlockedReason; diff --git a/resources/unpacked/devtools/front_end/cookie_table/module.json b/resources/unpacked/devtools/front_end/cookie_table/module.json index b36876e1a1..77925d6efc 100644 --- a/resources/unpacked/devtools/front_end/cookie_table/module.json +++ b/resources/unpacked/devtools/front_end/cookie_table/module.json @@ -7,6 +7,7 @@ "scripts": [], "modules": [ "cookie_table.js", + "cookie_table-legacy.js", "CookiesTable.js" ], "resources": [ diff --git a/resources/unpacked/devtools/front_end/coverage/CoverageDecorationManager.js b/resources/unpacked/devtools/front_end/coverage/CoverageDecorationManager.js index c5c98e4da1..3fa7cccb34 100644 --- a/resources/unpacked/devtools/front_end/coverage/CoverageDecorationManager.js +++ b/resources/unpacked/devtools/front_end/coverage/CoverageDecorationManager.js @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -export const _decoratorType = 'coverage'; +import {CoverageInfo, CoverageModel} from './CoverageModel.js'; // eslint-disable-line no-unused-vars -export default class CoverageDecorationManager { +export const decoratorType = 'coverage'; + +export class CoverageDecorationManager { /** - * @param {!Coverage.CoverageModel} coverageModel + * @param {!CoverageModel} coverageModel */ constructor(coverageModel) { this._coverageModel = coverageModel; @@ -16,14 +18,14 @@ export default class CoverageDecorationManager { this._uiSourceCodeByContentProvider = new Platform.Multimap(); for (const uiSourceCode of Workspace.workspace.uiSourceCodes()) { - uiSourceCode.addLineDecoration(0, _decoratorType, this); + uiSourceCode.addLineDecoration(0, decoratorType, this); } Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeAdded, this._onUISourceCodeAdded, this); } reset() { for (const uiSourceCode of Workspace.workspace.uiSourceCodes()) { - uiSourceCode.removeDecorationsForType(_decoratorType); + uiSourceCode.removeDecorationsForType(decoratorType); } } @@ -34,13 +36,13 @@ export default class CoverageDecorationManager { } /** - * @param {!Array} updatedEntries + * @param {!Array} updatedEntries */ update(updatedEntries) { for (const entry of updatedEntries) { for (const uiSourceCode of this._uiSourceCodeByContentProvider.get(entry.contentProvider())) { - uiSourceCode.removeDecorationsForType(_decoratorType); - uiSourceCode.addLineDecoration(0, _decoratorType, this); + uiSourceCode.removeDecorationsForType(decoratorType); + uiSourceCode.addLineDecoration(0, decoratorType, this); } } } @@ -64,13 +66,14 @@ export default class CoverageDecorationManager { result.push(undefined); continue; } - const startLocations = this._rawLocationsForSourceLocation(uiSourceCode, line, 0); - const endLocations = this._rawLocationsForSourceLocation(uiSourceCode, line, lineLength); + const startLocationsPromise = this._rawLocationsForSourceLocation(uiSourceCode, line, 0); + const endLocationsPromise = this._rawLocationsForSourceLocation(uiSourceCode, line, lineLength); + const [startLocations, endLocations] = await Promise.all([startLocationsPromise, endLocationsPromise]); let used = undefined; for (let startIndex = 0, endIndex = 0; startIndex < startLocations.length; ++startIndex) { const start = startLocations[startIndex]; while (endIndex < endLocations.length && - Coverage.CoverageDecorationManager._compareLocations(start, endLocations[endIndex]) >= 0) { + CoverageDecorationManager._compareLocations(start, endLocations[endIndex]) >= 0) { ++endIndex; } if (endIndex >= endLocations.length || endLocations[endIndex].id !== start.id) { @@ -107,10 +110,10 @@ export default class CoverageDecorationManager { * @param {!TextUtils.Text} text * @return {!Promise} */ - _updateTexts(uiSourceCode, text) { + async _updateTexts(uiSourceCode, text) { const promises = []; for (let line = 0; line < text.lineCount(); ++line) { - for (const entry of this._rawLocationsForSourceLocation(uiSourceCode, line, 0)) { + for (const entry of await this._rawLocationsForSourceLocation(uiSourceCode, line, 0)) { if (this._textByProvider.has(entry.contentProvider)) { continue; } @@ -135,13 +138,13 @@ export default class CoverageDecorationManager { * @param {!Workspace.UISourceCode} uiSourceCode * @param {number} line * @param {number} column - * @return {!Array} + * @return {!Promise>} */ - _rawLocationsForSourceLocation(uiSourceCode, line, column) { + async _rawLocationsForSourceLocation(uiSourceCode, line, column) { const result = []; const contentType = uiSourceCode.contentType(); if (contentType.hasScripts()) { - let locations = Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiSourceCode, line, column); + let locations = await Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiSourceCode, line, column); locations = locations.filter(location => !!location.script()); for (const location of locations) { const script = location.script(); @@ -181,7 +184,7 @@ export default class CoverageDecorationManager { }); } } - return result.sort(Coverage.CoverageDecorationManager._compareLocations); + return result.sort(CoverageDecorationManager._compareLocations); } /** @@ -197,30 +200,6 @@ export default class CoverageDecorationManager { */ _onUISourceCodeAdded(event) { const uiSourceCode = /** @type !Workspace.UISourceCode */ (event.data); - uiSourceCode.addLineDecoration(0, _decoratorType, this); + uiSourceCode.addLineDecoration(0, decoratorType, this); } } - -/* Legacy exported object */ -self.Coverage = self.Coverage || {}; - -/* Legacy exported object */ -Coverage = Coverage || {}; - -/** - * @typedef {!{ - * id: string, - * contentProvider: !Common.ContentProvider, - * line: number, - * column: number - * }} - */ -Coverage.RawLocation; - -/** - * @constructor - */ -Coverage.CoverageDecorationManager = CoverageDecorationManager; - -/** @public */ -Coverage.CoverageDecorationManager.decoratorType = _decoratorType; diff --git a/resources/unpacked/devtools/front_end/coverage/CoverageListView.js b/resources/unpacked/devtools/front_end/coverage/CoverageListView.js index 0829a1b3d0..db08674cbb 100644 --- a/resources/unpacked/devtools/front_end/coverage/CoverageListView.js +++ b/resources/unpacked/devtools/front_end/coverage/CoverageListView.js @@ -2,13 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -export default class CoverageListView extends UI.VBox { +import {CoverageType, URLCoverageInfo} from './CoverageModel.js'; // eslint-disable-line no-unused-vars + +export class CoverageListView extends UI.VBox { /** - * @param {function(!Coverage.URLCoverageInfo):boolean} filterCallback + * @param {function(!URLCoverageInfo):boolean} filterCallback */ constructor(filterCallback) { super(true); - /** @type {!Map} */ + /** @type {!Map} */ this._nodeForCoverageInfo = new Map(); this._filterCallback = filterCallback; /** @type {?RegExp} */ @@ -47,7 +49,7 @@ export default class CoverageListView extends UI.VBox { } /** - * @param {!Array} coverageInfo + * @param {!Array} coverageInfo */ update(coverageInfo) { let hadUpdates = false; @@ -134,7 +136,7 @@ export default class CoverageListView extends UI.VBox { if (!node) { return; } - const coverageInfo = /** @type {!Coverage.CoverageListView.GridNode} */ (node)._coverageInfo; + const coverageInfo = /** @type {!GridNode} */ (node)._coverageInfo; let sourceCode = Workspace.workspace.uiSourceCodeForURL(coverageInfo.url()); if (!sourceCode) { return; @@ -182,8 +184,8 @@ export default class CoverageListView extends UI.VBox { * @return {number} */ function compareURL(a, b) { - const nodeA = /** @type {!Coverage.CoverageListView.GridNode} */ (a); - const nodeB = /** @type {!Coverage.CoverageListView.GridNode} */ (b); + const nodeA = /** @type {!GridNode} */ (a); + const nodeB = /** @type {!GridNode} */ (b); return nodeA._url.localeCompare(nodeB._url); } @@ -195,8 +197,8 @@ export default class CoverageListView extends UI.VBox { * @return {number} */ function compareNumericField(fieldName, a, b) { - const nodeA = /** @type {!Coverage.CoverageListView.GridNode} */ (a); - const nodeB = /** @type {!Coverage.CoverageListView.GridNode} */ (b); + const nodeA = /** @type {!GridNode} */ (a); + const nodeB = /** @type {!GridNode} */ (b); return nodeA._coverageInfo[fieldName]() - nodeB._coverageInfo[fieldName]() || compareURL(a, b); } @@ -207,25 +209,25 @@ export default class CoverageListView extends UI.VBox { * @return {number} */ function compareType(a, b) { - const nodeA = /** @type {!Coverage.CoverageListView.GridNode} */ (a); - const nodeB = /** @type {!Coverage.CoverageListView.GridNode} */ (b); - const typeA = Coverage.CoverageListView._typeToString(nodeA._coverageInfo.type()); - const typeB = Coverage.CoverageListView._typeToString(nodeB._coverageInfo.type()); + const nodeA = /** @type {!GridNode} */ (a); + const nodeB = /** @type {!GridNode} */ (b); + const typeA = CoverageListView._typeToString(nodeA._coverageInfo.type()); + const typeB = CoverageListView._typeToString(nodeB._coverageInfo.type()); return typeA.localeCompare(typeB) || compareURL(a, b); } } /** - * @param {!Coverage.CoverageType} type + * @param {!CoverageType} type */ static _typeToString(type) { const types = []; - if (type & Coverage.CoverageType.CSS) { + if (type & CoverageType.CSS) { types.push(Common.UIString('CSS')); } - if (type & Coverage.CoverageType.JavaScriptPerFunction) { + if (type & CoverageType.JavaScriptPerFunction) { types.push(Common.UIString('JS (per function)')); - } else if (type & Coverage.CoverageType.JavaScript) { + } else if (type & CoverageType.JavaScript) { types.push(Common.UIString('JS (per block)')); } return types.join('+'); @@ -234,7 +236,7 @@ export default class CoverageListView extends UI.VBox { export class GridNode extends DataGrid.SortableDataGridNode { /** - * @param {!Coverage.URLCoverageInfo} coverageInfo + * @param {!URLCoverageInfo} coverageInfo * @param {number} maxSize */ constructor(coverageInfo, maxSize) { @@ -296,11 +298,11 @@ export class GridNode extends DataGrid.SortableDataGridNode { this.setCellAccessibleName(this._url, cell, columnId); break; case 'type': - cell.textContent = Coverage.CoverageListView._typeToString(this._coverageInfo.type()); - if (this._coverageInfo.type() & Coverage.CoverageType.JavaScriptPerFunction) { + cell.textContent = CoverageListView._typeToString(this._coverageInfo.type()); + if (this._coverageInfo.type() & CoverageType.JavaScriptPerFunction) { cell.title = ls `JS coverage with per function granularity: Once a function was executed, the whole function is marked as covered.`; - } else if (this._coverageInfo.type() & Coverage.CoverageType.JavaScript) { + } else if (this._coverageInfo.type() & CoverageType.JavaScript) { cell.title = ls `JS coverage with per block granularity: Once a block of JavaScript was executed, that block is marked as covered.`; } @@ -330,10 +332,10 @@ export class GridNode extends DataGrid.SortableDataGridNode { if (this._coverageInfo.unusedSize() > 0) { const unusedSizeBar = barContainer.createChild('div', 'bar bar-unused-size'); unusedSizeBar.style.width = ((this._coverageInfo.unusedSize() / this._maxSize) * 100 || 0) + '%'; - if (this._coverageInfo.type() & Coverage.CoverageType.JavaScriptPerFunction) { + if (this._coverageInfo.type() & CoverageType.JavaScriptPerFunction) { unusedSizeBar.title = ls`${this._coverageInfo.unusedSize()} bytes (${ unusedPercent} %) belong to functions that have not (yet) been executed.`; - } else if (this._coverageInfo.type() & Coverage.CoverageType.JavaScript) { + } else if (this._coverageInfo.type() & CoverageType.JavaScript) { unusedSizeBar.title = ls`${this._coverageInfo.unusedSize()} bytes (${ unusedPercent} %) belong to blocks of JavaScript that have not (yet) been executed.`; } @@ -341,10 +343,10 @@ export class GridNode extends DataGrid.SortableDataGridNode { if (this._coverageInfo.usedSize() > 0) { const usedSizeBar = barContainer.createChild('div', 'bar bar-used-size'); usedSizeBar.style.width = ((this._coverageInfo.usedSize() / this._maxSize) * 100 || 0) + '%'; - if (this._coverageInfo.type() & Coverage.CoverageType.JavaScriptPerFunction) { + if (this._coverageInfo.type() & CoverageType.JavaScriptPerFunction) { usedSizeBar.title = ls`${this._coverageInfo.usedSize()} bytes (${ usedPercent} %) belong to functions that have executed at least once.`; - } else if (this._coverageInfo.type() & Coverage.CoverageType.JavaScript) { + } else if (this._coverageInfo.type() & CoverageType.JavaScript) { usedSizeBar.title = ls`${this._coverageInfo.usedSize()} bytes (${ usedPercent} %) belong to blocks of JavaScript that have executed at least once.`; } @@ -376,19 +378,3 @@ export class GridNode extends DataGrid.SortableDataGridNode { UI.highlightRangesWithStyleClass(element, [range], 'filter-highlight'); } } - -/* Legacy exported object */ -self.Coverage = self.Coverage || {}; - -/* Legacy exported object */ -Coverage = Coverage || {}; - -/** - * @constructor - */ -Coverage.CoverageListView = CoverageListView; - -/** - * @constructor - */ -Coverage.CoverageListView.GridNode = GridNode; diff --git a/resources/unpacked/devtools/front_end/coverage/CoverageModel.js b/resources/unpacked/devtools/front_end/coverage/CoverageModel.js index 4e705a0354..18ae6956d8 100644 --- a/resources/unpacked/devtools/front_end/coverage/CoverageModel.js +++ b/resources/unpacked/devtools/front_end/coverage/CoverageModel.js @@ -1,13 +1,7 @@ -// Copyright (c) 2017 The Chromium Authors. All rights reserved. +// Copyright (c) 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -/** @typedef {{startOffset: number, endOffset: number, count: number}} */ -Coverage.RangeUseCount; - -/** @typedef {{end: number, count: (number|undefined)}} */ -Coverage.CoverageSegment; - /** * @enum {number} */ @@ -33,7 +27,7 @@ export const Events = { /** @type {number} */ const _coveragePollingPeriodMs = 200; -export default class CoverageModel extends SDK.SDKModel { +export class CoverageModel extends SDK.SDKModel { /** * @param {!SDK.Target} target */ @@ -43,12 +37,12 @@ export default class CoverageModel extends SDK.SDKModel { this._cssModel = target.model(SDK.CSSModel); this._debuggerModel = target.model(SDK.DebuggerModel); - /** @type {!Map} */ + /** @type {!Map} */ this._coverageByURL = new Map(); - /** @type {!Map} */ + /** @type {!Map} */ this._coverageByContentProvider = new Map(); - /** @type {!Coverage.SuspensionState} */ + /** @type {!SuspensionState} */ this._suspensionState = SuspensionState.Active; /** @type {?number} */ this._pollTimer = null; @@ -221,7 +215,7 @@ export default class CoverageModel extends SDK.SDKModel { } /** - * @return {!Array} + * @return {!Array} */ entries() { return Array.from(this._coverageByURL.values()); @@ -230,7 +224,7 @@ export default class CoverageModel extends SDK.SDKModel { /** * * @param {string} url - * @return {?Coverage.URLCoverageInfo} + * @return {?URLCoverageInfo} */ getCoverageForUrl(url) { return this._coverageByURL.get(url); @@ -271,7 +265,7 @@ export default class CoverageModel extends SDK.SDKModel { } /** - * @return {!Promise>} + * @return {!Promise>} */ async _takeAllCoverage() { const [updatesCSS, updatesJS] = await Promise.all([this._takeCSSCoverage(), this._takeJSCoverage()]); @@ -279,7 +273,7 @@ export default class CoverageModel extends SDK.SDKModel { } /** - * @return {!Promise>} + * @return {!Promise>} */ async _takeJSCoverage() { if (!this._cpuProfilerModel) { @@ -308,7 +302,7 @@ export default class CoverageModel extends SDK.SDKModel { /** * @param {!Array} scriptsCoverage - * @return {!Array} + * @return {!Array} */ _processJSCoverage(scriptsCoverage, stamp) { const updatedEntries = []; @@ -334,7 +328,7 @@ export default class CoverageModel extends SDK.SDKModel { } const subentry = this._addCoverage( script, script.contentLength, script.lineOffset, script.columnOffset, ranges, - /** @type {!Coverage.CoverageType} */ (type), stamp); + /** @type {!CoverageType} */ (type), stamp); if (subentry) { updatedEntries.push(subentry); } @@ -349,7 +343,7 @@ export default class CoverageModel extends SDK.SDKModel { } /** - * @return {!Promise>} + * @return {!Promise>} */ async _takeCSSCoverage() { // Don't poll if we have no model, or are suspended. @@ -379,7 +373,7 @@ export default class CoverageModel extends SDK.SDKModel { /** * @param {!Array} ruleUsageList - * @return {!Array} + * @return {!Array} */ _processCSSCoverage(ruleUsageList, stamp) { const updatedEntries = []; @@ -471,8 +465,8 @@ export default class CoverageModel extends SDK.SDKModel { * @param {number} startLine * @param {number} startColumn * @param {!Array} ranges - * @param {!Coverage.CoverageType} type - * @return {?Coverage.CoverageInfo} + * @param {!CoverageType} type + * @return {?CoverageInfo} */ _addCoverage(contentProvider, contentLength, startLine, startColumn, ranges, type, stamp) { const url = contentProvider.contentURL(); @@ -483,13 +477,13 @@ export default class CoverageModel extends SDK.SDKModel { let isNewUrlCoverage = false; if (!urlCoverage) { isNewUrlCoverage = true; - urlCoverage = new Coverage.URLCoverageInfo(url); + urlCoverage = new URLCoverageInfo(url); this._coverageByURL.set(url, urlCoverage); } const coverageInfo = urlCoverage._ensureEntry(contentProvider, contentLength, startLine, startColumn, type); this._coverageByContentProvider.set(contentProvider, coverageInfo); - const segments = Coverage.CoverageModel._convertToDisjointSegments(ranges, stamp); + const segments = CoverageModel._convertToDisjointSegments(ranges, stamp); if (segments.length && segments.peekLast().end < contentLength) { segments.push({end: contentLength, stamp: stamp}); } @@ -590,11 +584,11 @@ export class URLCoverageInfo extends Common.Object { super(); this._url = url; - /** @type {!Map} */ + /** @type {!Map} */ this._coverageInfoByLocation = new Map(); this._size = 0; this._usedSize = 0; - /** @type {!Coverage.CoverageType} */ + /** @type {!CoverageType} */ this._type; this._isContentScript = false; } @@ -607,7 +601,7 @@ export class URLCoverageInfo extends Common.Object { } /** - * @return {!Coverage.CoverageType} + * @return {!CoverageType} */ type() { return this._type; @@ -672,7 +666,7 @@ export class URLCoverageInfo extends Common.Object { this._size += size; if (usedSize !== 0 || size !== 0) { - this.dispatchEventToListeners(Coverage.URLCoverageInfo.Events.SizesChanged); + this.dispatchEventToListeners(URLCoverageInfo.Events.SizesChanged); } } @@ -681,8 +675,8 @@ export class URLCoverageInfo extends Common.Object { * @param {number} contentLength * @param {number} lineOffset * @param {number} columnOffset - * @param {!Coverage.CoverageType} type - * @return {!Coverage.CoverageInfo} + * @param {!CoverageType} type + * @return {!CoverageInfo} */ _ensureEntry(contentProvider, contentLength, lineOffset, columnOffset, type) { const key = `${lineOffset}:${columnOffset}`; @@ -702,7 +696,7 @@ export class URLCoverageInfo extends Common.Object { this._isContentScript = /** @type {!SDK.Script} */ (contentProvider).isContentScript(); } - entry = new Coverage.CoverageInfo(contentProvider, contentLength, lineOffset, columnOffset, type); + entry = new CoverageInfo(contentProvider, contentLength, lineOffset, columnOffset, type); this._coverageInfoByLocation.set(key, entry); this._addToSizes(0, contentLength); @@ -724,7 +718,7 @@ export class CoverageInfo { * @param {number} size * @param {number} lineOffset * @param {number} columnOffset - * @param {!Coverage.CoverageType} type + * @param {!CoverageType} type */ constructor(contentProvider, size, lineOffset, columnOffset, type) { this._contentProvider = contentProvider; @@ -754,7 +748,7 @@ export class CoverageInfo { } /** - * @return {!Coverage.CoverageType} + * @return {!CoverageType} */ type() { return this._coverageType; @@ -764,7 +758,7 @@ export class CoverageInfo { * @param {!Array} segments */ mergeCoverage(segments) { - this._segments = Coverage.CoverageInfo._mergeCoverage(this._segments, segments); + this._segments = CoverageInfo._mergeCoverage(this._segments, segments); this._updateStats(); } @@ -849,35 +843,3 @@ export class CoverageInfo { } } } - -/* Legacy exported object */ -self.Coverage = self.Coverage || {}; - -/* Legacy exported object */ -Coverage = Coverage || {}; - -/** - * @constructor - */ -Coverage.CoverageModel = CoverageModel; - -/** @enum {symbol} */ -Coverage.CoverageModel.Events = Events; - -/** - * @enum {number} - */ -Coverage.CoverageType = CoverageType; - -/** @enum {symbol} */ -Coverage.SuspensionState = SuspensionState; - -/** - * @constructor - */ -Coverage.URLCoverageInfo = URLCoverageInfo; - -/** - * @constructor - */ -Coverage.CoverageInfo = CoverageInfo; diff --git a/resources/unpacked/devtools/front_end/coverage/CoverageView.js b/resources/unpacked/devtools/front_end/coverage/CoverageView.js index dfa256dc5a..b0a52d40fa 100644 --- a/resources/unpacked/devtools/front_end/coverage/CoverageView.js +++ b/resources/unpacked/devtools/front_end/coverage/CoverageView.js @@ -2,13 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {CoverageDecorationManager, decoratorType} from './CoverageDecorationManager.js'; +import {CoverageListView} from './CoverageListView.js'; +import {CoverageInfo, CoverageModel, CoverageType, Events, URLCoverageInfo} from './CoverageModel.js'; // eslint-disable-line no-unused-vars + export class CoverageView extends UI.VBox { constructor() { super(true); - /** @type {?Coverage.CoverageModel} */ + /** @type {?CoverageModel} */ this._model = null; - /** @type {?Coverage.CoverageDecorationManager} */ + /** @type {?CoverageDecorationManager} */ this._decorationManager = null; /** @type {?SDK.ResourceTreeModel} */ this._resourceTreeModel = null; @@ -24,11 +28,11 @@ export class CoverageView extends UI.VBox { const coverageTypes = [ { label: ls`Per function`, - value: Coverage.CoverageType.JavaScript | Coverage.CoverageType.JavaScriptPerFunction, + value: CoverageType.JavaScript | CoverageType.JavaScriptPerFunction, }, { label: ls`Per block`, - value: Coverage.CoverageType.JavaScript, + value: CoverageType.JavaScript, }, ]; for (const type of coverageTypes) { @@ -82,11 +86,11 @@ export class CoverageView extends UI.VBox { }, { label: ls`CSS`, - value: Coverage.CoverageType.CSS, + value: CoverageType.CSS, }, { label: ls`JavaScript`, - value: Coverage.CoverageType.JavaScript | Coverage.CoverageType.JavaScriptPerFunction, + value: CoverageType.JavaScript | CoverageType.JavaScriptPerFunction, }, ]; for (const option of options) { @@ -107,7 +111,7 @@ export class CoverageView extends UI.VBox { this._coverageResultsElement = this.contentElement.createChild('div', 'coverage-results'); this._landingPage = this._buildLandingPage(); - this._listView = new Coverage.CoverageListView(this._isVisible.bind(this, false)); + this._listView = new CoverageListView(this._isVisible.bind(this, false)); this._statusToolbarElement = this.contentElement.createChild('div', 'coverage-toolbar-summary'); this._statusMessageElement = this._statusToolbarElement.createChild('div', 'coverage-message'); @@ -170,7 +174,7 @@ export class CoverageView extends UI.VBox { isBlockCoverageSelected() { const coverageType = Number(this._coverageTypeComboBox.selectedOption().value); // Check that Coverage.CoverageType.JavaScriptPerFunction is not present. - return coverageType === Coverage.CoverageType.JavaScript; + return coverageType === CoverageType.JavaScript; } /** @@ -206,7 +210,7 @@ export class CoverageView extends UI.VBox { const {reload, jsCoveragePerBlock} = {reload: false, jsCoveragePerBlock: false, ...options}; if (!this._model || reload) { - this._model = mainTarget.model(Coverage.CoverageModel); + this._model = mainTarget.model(CoverageModel); } Host.userMetrics.actionTaken(Host.UserMetrics.Action.CoverageStarted); if (jsCoveragePerBlock) { @@ -218,14 +222,13 @@ export class CoverageView extends UI.VBox { } this._selectCoverageType(jsCoveragePerBlock); - this._model.addEventListener(Coverage.CoverageModel.Events.CoverageUpdated, this._onCoverageDataReceived, this); + this._model.addEventListener(Events.CoverageUpdated, this._onCoverageDataReceived, this); this._resourceTreeModel = /** @type {?SDK.ResourceTreeModel} */ (mainTarget.model(SDK.ResourceTreeModel)); if (this._resourceTreeModel) { this._resourceTreeModel.addEventListener( SDK.ResourceTreeModel.Events.MainFrameNavigated, this._onMainFrameNavigated, this); } - this._decorationManager = - new Coverage.CoverageDecorationManager(/** @type {!Coverage.CoverageModel} */ (this._model)); + this._decorationManager = new CoverageDecorationManager(/** @type {!CoverageModel} */ (this._model)); this._toggleRecordAction.setToggled(true); this._clearButton.setEnabled(false); if (this._startWithReloadButton) { @@ -260,7 +263,7 @@ export class CoverageView extends UI.VBox { } // Stopping the model triggers one last poll to get the final data. await this._model.stop(); - this._model.removeEventListener(Coverage.CoverageModel.Events.CoverageUpdated, this._onCoverageDataReceived, this); + this._model.removeEventListener(Events.CoverageUpdated, this._onCoverageDataReceived, this); this._toggleRecordAction.setToggled(false); this._coverageTypeComboBox.setEnabled(true); if (this._startWithReloadButton) { @@ -280,7 +283,7 @@ export class CoverageView extends UI.VBox { } /** - * @param {!Array} updatedEntries + * @param {!Array} updatedEntries */ _updateViews(updatedEntries) { this._updateStats(); @@ -331,12 +334,12 @@ export class CoverageView extends UI.VBox { /** * @param {boolean} ignoreTextFilter - * @param {!Coverage.URLCoverageInfo} coverageInfo + * @param {!URLCoverageInfo} coverageInfo * @return {boolean} */ _isVisible(ignoreTextFilter, coverageInfo) { const url = coverageInfo.url(); - if (url.startsWith(Coverage.CoverageView._extensionBindingsURLPrefix)) { + if (url.startsWith(CoverageView._extensionBindingsURLPrefix)) { return false; } if (coverageInfo.isContentScript() && !this._showContentScriptsSetting.get()) { @@ -380,13 +383,13 @@ export class ActionDelegate { const coverageViewId = 'coverage'; UI.viewManager.showView(coverageViewId) .then(() => UI.viewManager.view(coverageViewId).widget()) - .then(widget => this._innerHandleAction(/** @type !Coverage.CoverageView} */ (widget), actionId)); + .then(widget => this._innerHandleAction(/** @type !CoverageView} */ (widget), actionId)); return true; } /** - * @param {!Coverage.CoverageView} coverageView + * @param {!CoverageView} coverageView * @param {string} actionId */ _innerHandleAction(coverageView, actionId) { @@ -418,13 +421,13 @@ export class LineDecorator { * @param {!TextEditor.CodeMirrorTextEditor} textEditor */ decorate(uiSourceCode, textEditor) { - const decorations = uiSourceCode.decorationsForType(Coverage.CoverageDecorationManager.decoratorType); + const decorations = uiSourceCode.decorationsForType(decoratorType); if (!decorations || !decorations.size) { this._uninstallGutter(textEditor); return; } const decorationManager = - /** @type {!Coverage.CoverageDecorationManager} */ (decorations.values().next().value.data()); + /** @type {!CoverageDecorationManager} */ (decorations.values().next().value.data()); decorationManager.usageByLine(uiSourceCode).then(lineUsage => { textEditor.operation(() => this._innerDecorate(uiSourceCode, textEditor, lineUsage)); }); @@ -436,7 +439,7 @@ export class LineDecorator { * @param {!Array} lineUsage */ _innerDecorate(uiSourceCode, textEditor, lineUsage) { - const gutterType = Coverage.CoverageView.LineDecorator._gutterType; + const gutterType = LineDecorator._gutterType; this._uninstallGutter(textEditor); if (lineUsage.length) { this._installGutter(textEditor, uiSourceCode.url()); @@ -459,7 +462,7 @@ export class LineDecorator { makeGutterClickHandler(url) { function handleGutterClick(event) { const eventData = /** @type {!SourceFrame.SourcesTextEditor.GutterClickEventData} */ (event.data); - if (eventData.gutterType !== Coverage.CoverageView.LineDecorator._gutterType) { + if (eventData.gutterType !== LineDecorator._gutterType) { return; } const coverageViewId = 'coverage'; @@ -482,7 +485,7 @@ export class LineDecorator { listener = this.makeGutterClickHandler(url); this._listeners.set(textEditor, listener); } - textEditor.installGutter(Coverage.CoverageView.LineDecorator._gutterType, false); + textEditor.installGutter(LineDecorator._gutterType, false); textEditor.addEventListener(SourceFrame.SourcesTextEditor.Events.GutterClick, listener, this); } @@ -490,7 +493,7 @@ export class LineDecorator { * @param {!TextEditor.CodeMirrorTextEditor} textEditor - the text editor to uninstall the gutter from */ _uninstallGutter(textEditor) { - textEditor.uninstallGutter(Coverage.CoverageView.LineDecorator._gutterType); + textEditor.uninstallGutter(LineDecorator._gutterType); const listener = this._listeners.get(textEditor); if (listener) { textEditor.removeEventListener(SourceFrame.SourcesTextEditor.Events.GutterClick, listener, this); @@ -500,24 +503,3 @@ export class LineDecorator { } LineDecorator._gutterType = 'CodeMirror-gutter-coverage'; - -/* Legacy exported object */ -self.Coverage = self.Coverage || {}; - -/* Legacy exported object */ -Coverage = Coverage || {}; - -/** - * @constructor - */ -Coverage.CoverageView = CoverageView; - -/** - * @constructor - */ -Coverage.CoverageView.LineDecorator = LineDecorator; - -/** - * @constructor - */ -Coverage.CoverageView.ActionDelegate = ActionDelegate; diff --git a/resources/unpacked/devtools/front_end/coverage/coverage-legacy.js b/resources/unpacked/devtools/front_end/coverage/coverage-legacy.js new file mode 100644 index 0000000000..21018ccdd4 --- /dev/null +++ b/resources/unpacked/devtools/front_end/coverage/coverage-legacy.js @@ -0,0 +1,87 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import * as CoverageModule from './coverage.js'; + +self.Coverage = self.Coverage || {}; +Coverage = Coverage || {}; + +/** + * @constructor + */ +Coverage.CoverageDecorationManager = CoverageModule.CoverageDecorationManager.CoverageDecorationManager; + +/** @public */ +Coverage.CoverageDecorationManager.decoratorType = CoverageModule.CoverageDecorationManager.decoratorType; + +/** + * @constructor + */ +Coverage.CoverageListView = CoverageModule.CoverageListView.CoverageListView; + +/** + * @constructor + */ +Coverage.CoverageListView.GridNode = CoverageModule.CoverageListView.GridNode; + +/** + * @constructor + */ +Coverage.CoverageModel = CoverageModule.CoverageModel.CoverageModel; + +/** @enum {symbol} */ +Coverage.CoverageModel.Events = CoverageModule.CoverageModel.Events; + +/** + * @enum {number} + */ +Coverage.CoverageType = CoverageModule.CoverageModel.CoverageType; + +/** @enum {symbol} */ +Coverage.SuspensionState = CoverageModule.CoverageModel.SuspensionState; + +/** + * @constructor + */ +Coverage.URLCoverageInfo = CoverageModule.CoverageModel.URLCoverageInfo; + +/** + * @constructor + */ +Coverage.CoverageInfo = CoverageModule.CoverageModel.CoverageInfo; + +/** + * @constructor + */ +Coverage.CoverageView = CoverageModule.CoverageView.CoverageView; + +/** + * @constructor + */ +Coverage.CoverageView.LineDecorator = CoverageModule.CoverageView.LineDecorator; + +/** + * @constructor + */ +Coverage.CoverageView.ActionDelegate = CoverageModule.CoverageView.ActionDelegate; + +/** + * @typedef {!{ + * id: string, + * contentProvider: !Common.ContentProvider, + * line: number, + * column: number + * }} + */ +Coverage.RawLocation; + +// Copyright (c) 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/** @typedef {{startOffset: number, endOffset: number, count: number}} */ +Coverage.RangeUseCount; + +/** @typedef {{end: number, count: (number|undefined)}} */ +Coverage.CoverageSegment; diff --git a/resources/unpacked/devtools/front_end/coverage/module.json b/resources/unpacked/devtools/front_end/coverage/module.json index f72a99dc37..68e7ce51ba 100644 --- a/resources/unpacked/devtools/front_end/coverage/module.json +++ b/resources/unpacked/devtools/front_end/coverage/module.json @@ -52,6 +52,8 @@ ], "scripts": [], "modules": [ + "coverage.js", + "coverage-legacy.js", "CoverageModel.js", "CoverageListView.js", "CoverageView.js", diff --git a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewCompletedView.js b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewCompletedView.js index 572195a726..428cb41777 100644 --- a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewCompletedView.js +++ b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewCompletedView.js @@ -2,10 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Events} from './CSSOverviewController.js'; +import {CSSOverviewSidebarPanel, SidebarEvents} from './CSSOverviewSidebarPanel.js'; + /** * @unrestricted */ -export default class CSSOverviewCompletedView extends UI.PanelWithSidebar { +export class CSSOverviewCompletedView extends UI.PanelWithSidebar { constructor(controller, target) { super('css_overview_completed_view'); this.registerRequiredCSS('css_overview/cssOverviewCompletedView.css'); @@ -33,7 +36,7 @@ export default class CSSOverviewCompletedView extends UI.PanelWithSidebar { this._mainContainer.setSecondIsSidebar(true); this._mainContainer.setSidebarMinimized(true); - this._sideBar = new CssOverview.CSSOverviewSidebarPanel(); + this._sideBar = new CSSOverviewSidebarPanel(); this.splitWidget().setSidebarWidget(this._sideBar); this.splitWidget().setMainWidget(this._mainContainer); @@ -51,10 +54,10 @@ export default class CSSOverviewCompletedView extends UI.PanelWithSidebar { this._sideBar.addItem(ls`Media queries`, 'media-queries'); this._sideBar.select('summary'); - this._sideBar.addEventListener(CssOverview.SidebarEvents.ItemSelected, this._sideBarItemSelected, this); - this._sideBar.addEventListener(CssOverview.SidebarEvents.Reset, this._sideBarReset, this); - this._controller.addEventListener(CssOverview.Events.Reset, this._reset, this); - this._controller.addEventListener(CssOverview.Events.PopulateNodes, this._createElementsView, this); + this._sideBar.addEventListener(SidebarEvents.ItemSelected, this._sideBarItemSelected, this); + this._sideBar.addEventListener(SidebarEvents.Reset, this._sideBarReset, this); + this._controller.addEventListener(Events.Reset, this._reset, this); + this._controller.addEventListener(Events.PopulateNodes, this._createElementsView, this); this._resultsContainer.element.addEventListener('click', this._onClick.bind(this)); this._data = null; @@ -80,7 +83,7 @@ export default class CSSOverviewCompletedView extends UI.PanelWithSidebar { } _sideBarReset() { - this._controller.dispatchEventToListeners(CssOverview.Events.Reset); + this._controller.dispatchEventToListeners(Events.Reset); } _reset() { @@ -175,7 +178,7 @@ export default class CSSOverviewCompletedView extends UI.PanelWithSidebar { } evt.consume(); - this._controller.dispatchEventToListeners(CssOverview.Events.PopulateNodes, payload); + this._controller.dispatchEventToListeners(Events.PopulateNodes, payload); this._mainContainer.setSidebarMinimized(false); } @@ -188,7 +191,7 @@ export default class CSSOverviewCompletedView extends UI.PanelWithSidebar { } const backendNodeId = Number(node.dataset.backendNodeId); - this._controller.dispatchEventToListeners(CssOverview.Events.RequestNodeHighlight, backendNodeId); + this._controller.dispatchEventToListeners(Events.RequestNodeHighlight, backendNodeId); } async _render(data) { @@ -528,7 +531,7 @@ export class ElementDetailsView extends UI.Widget { } const backendNodeId = Number(node.dataset.backendNodeId); - this._controller.dispatchEventToListeners(CssOverview.Events.RequestNodeHighlight, backendNodeId); + this._controller.dispatchEventToListeners(Events.RequestNodeHighlight, backendNodeId); } async populateNodes(data) { @@ -550,11 +553,11 @@ export class ElementDetailsView extends UI.Widget { // Grab the nodes from the frontend, but only those that have not been // retrieved already. const nodeIds = data.reduce((prev, curr) => { - if (CssOverview.CSSOverviewCompletedView.pushedNodes.has(curr.nodeId)) { + if (CSSOverviewCompletedView.pushedNodes.has(curr.nodeId)) { return prev; } - CssOverview.CSSOverviewCompletedView.pushedNodes.add(curr.nodeId); + CSSOverviewCompletedView.pushedNodes.add(curr.nodeId); return prev.add(curr.nodeId); }, new Set()); relatedNodesMap = await this._domModel.pushNodesByBackendIdsToFrontend(nodeIds); @@ -645,27 +648,3 @@ export class ElementNode extends DataGrid.SortableDataGridNode { return linkifier.linkifyCSSLocation(matchingSelectorLocation); } } - -/* Legacy exported object */ -self.CssOverview = self.CssOverview || {}; - -/* Legacy exported object */ -CssOverview = CssOverview || {}; - -/** - * @constructor - */ -CssOverview.CSSOverviewCompletedView = CSSOverviewCompletedView; - - -/** - * @constructor - */ -CssOverview.CSSOverviewCompletedView.DetailsView = DetailsView; - -/** - * @constructor - */ -CssOverview.CSSOverviewCompletedView.ElementDetailsView = ElementDetailsView; - -CssOverview.CSSOverviewCompletedView.ElementNode = ElementNode; diff --git a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewController.js b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewController.js index f80abfc578..7eaf6d3537 100644 --- a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewController.js +++ b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewController.js @@ -32,16 +32,3 @@ export const Events = { OverviewCompleted: Symbol('OverviewCompleted'), Reset: Symbol('Reset'), }; - -/* Legacy exported object */ -self.CssOverview = self.CssOverview || {}; - -/* Legacy exported object */ -CssOverview = CssOverview || {}; - -/** - * @constructor - */ -CssOverview.OverviewController = OverviewController; - -CssOverview.Events = Events; diff --git a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewModel.js b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewModel.js index 114f15e875..bb22293586 100644 --- a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewModel.js +++ b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewModel.js @@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {CSSOverviewUnusedDeclarations} from './CSSOverviewUnusedDeclarations.js'; + /** * @unrestricted */ -export default class CSSOverviewModel extends SDK.SDKModel { +export class CSSOverviewModel extends SDK.SDKModel { /** * @param {!SDK.Target} target */ @@ -191,18 +193,18 @@ export default class CSSOverviewModel extends SDK.SDKModel { fontInfo.set(fontFamily, fontFamilyInfo); } - CssOverview.CSSOverviewUnusedDeclarations.checkForUnusedPositionValues( + CSSOverviewUnusedDeclarations.checkForUnusedPositionValues( unusedDeclarations, nodeId, strings, positionIdx, topIdx, leftIdx, rightIdx, bottomIdx); // Ignore SVG elements as, despite being inline by default, they can have width & height specified. // Also ignore replaced content, for similar reasons. if (!isSVGNode(strings[nodeName]) && !isReplacedContent(strings[nodeName])) { - CssOverview.CSSOverviewUnusedDeclarations.checkForUnusedWidthAndHeightValues( + CSSOverviewUnusedDeclarations.checkForUnusedWidthAndHeightValues( unusedDeclarations, nodeId, strings, displayIdx, widthIdx, heightIdx); } if (verticalAlignIdx !== -1 && !isTableElementWithDefaultStyles(strings[nodeName], strings[displayIdx])) { - CssOverview.CSSOverviewUnusedDeclarations.checkForInvalidVerticalAlignment( + CSSOverviewUnusedDeclarations.checkForInvalidVerticalAlignment( unusedDeclarations, nodeId, strings, displayIdx, verticalAlignIdx); } } @@ -336,14 +338,3 @@ export default class CSSOverviewModel extends SDK.SDKModel { } SDK.SDKModel.register(CSSOverviewModel, SDK.Target.Capability.DOM, false); - -/* Legacy exported object */ -self.CssOverview = self.CssOverview || {}; - -/* Legacy exported object */ -CssOverview = CssOverview || {}; - -/** - * @constructor - */ -CssOverview.CSSOverviewModel = CSSOverviewModel; diff --git a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewPanel.js b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewPanel.js index d111007f0d..51d8699a57 100644 --- a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewPanel.js +++ b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewPanel.js @@ -2,6 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {CSSOverviewCompletedView} from './CSSOverviewCompletedView.js'; +import {Events, OverviewController} from './CSSOverviewController.js'; +import {CSSOverviewModel} from './CSSOverviewModel.js'; +import {CSSOverviewProcessingView} from './CSSOverviewProcessingView.js'; +import {CSSOverviewStartView} from './CSSOverviewStartView.js'; + /** * @unrestricted */ @@ -11,19 +17,19 @@ export class CSSOverviewPanel extends UI.Panel { this.registerRequiredCSS('css_overview/cssOverview.css'); this.element.classList.add('css-overview-panel'); - const [model] = SDK.targetManager.models(CssOverview.CSSOverviewModel); + const [model] = SDK.targetManager.models(CSSOverviewModel); this._model = model; - this._controller = new CssOverview.OverviewController(); - this._startView = new CssOverview.CSSOverviewStartView(this._controller); - this._processingView = new CssOverview.CSSOverviewProcessingView(this._controller); - this._completedView = new CssOverview.CSSOverviewCompletedView(this._controller, model.target()); + this._controller = new OverviewController(); + this._startView = new CSSOverviewStartView(this._controller); + this._processingView = new CSSOverviewProcessingView(this._controller); + this._completedView = new CSSOverviewCompletedView(this._controller, model.target()); - this._controller.addEventListener(CssOverview.Events.RequestOverviewStart, this._startOverview, this); - this._controller.addEventListener(CssOverview.Events.RequestOverviewCancel, this._cancelOverview, this); - this._controller.addEventListener(CssOverview.Events.OverviewCompleted, this._overviewCompleted, this); - this._controller.addEventListener(CssOverview.Events.Reset, this._reset, this); - this._controller.addEventListener(CssOverview.Events.RequestNodeHighlight, this._requestNodeHighlight, this); + this._controller.addEventListener(Events.RequestOverviewStart, this._startOverview, this); + this._controller.addEventListener(Events.RequestOverviewCancel, this._cancelOverview, this); + this._controller.addEventListener(Events.OverviewCompleted, this._overviewCompleted, this); + this._controller.addEventListener(Events.Reset, this._reset, this); + this._controller.addEventListener(Events.RequestNodeHighlight, this._requestNodeHighlight, this); this._reset(); } @@ -138,7 +144,7 @@ export class CSSOverviewPanel extends UI.Panel { this._unusedDeclarations = unusedDeclarations; } - this._controller.dispatchEventToListeners(CssOverview.Events.OverviewCompleted); + this._controller.dispatchEventToListeners(Events.OverviewCompleted); } _getStyleValue(styles, name) { @@ -158,14 +164,3 @@ export class CSSOverviewPanel extends UI.Panel { this._renderOverviewCompletedView(); } } - -/* Legacy exported object */ -self.CssOverview = self.CssOverview || {}; - -/* Legacy exported object */ -CssOverview = CssOverview || {}; - -/** - * @constructor - */ -CssOverview.CSSOverviewPanel = CSSOverviewPanel; diff --git a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewProcessingView.js b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewProcessingView.js index 2eea8ebec9..7df91f8d27 100644 --- a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewProcessingView.js +++ b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewProcessingView.js @@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Events} from './CSSOverviewController.js'; + /** * @unrestricted */ -export default class CSSOverviewProcessingView extends UI.Widget { +export class CSSOverviewProcessingView extends UI.Widget { constructor(controller) { super(); this.registerRequiredCSS('css_overview/cssOverviewProcessingView.css'); @@ -17,7 +19,7 @@ export default class CSSOverviewProcessingView extends UI.Widget { _render() { const cancelButton = UI.createTextButton( - ls`Cancel`, () => this._controller.dispatchEventToListeners(CssOverview.Events.RequestOverviewCancel), '', + ls`Cancel`, () => this._controller.dispatchEventToListeners(Events.RequestOverviewCancel), '', true /* primary */); this.setDefaultFocusedElement(cancelButton); @@ -32,14 +34,3 @@ export default class CSSOverviewProcessingView extends UI.Widget { this.contentElement.style.overflow = 'auto'; } } - -/* Legacy exported object */ -self.CssOverview = self.CssOverview || {}; - -/* Legacy exported object */ -CssOverview = CssOverview || {}; - -/** - * @constructor - */ -CssOverview.CSSOverviewProcessingView = CSSOverviewProcessingView; diff --git a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewSidebarPanel.js b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewSidebarPanel.js index e5950ac726..c135809f7a 100644 --- a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewSidebarPanel.js +++ b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewSidebarPanel.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -export default class CSSOverviewSidebarPanel extends UI.VBox { +export class CSSOverviewSidebarPanel extends UI.VBox { static get ITEM_CLASS_NAME() { return 'overview-sidebar-panel-item'; } @@ -29,7 +29,7 @@ export default class CSSOverviewSidebarPanel extends UI.VBox { } addItem(name, id) { - const item = this.contentElement.createChild('div', CssOverview.CSSOverviewSidebarPanel.ITEM_CLASS_NAME); + const item = this.contentElement.createChild('div', CSSOverviewSidebarPanel.ITEM_CLASS_NAME); item.textContent = name; item.dataset.id = id; } @@ -39,15 +39,15 @@ export default class CSSOverviewSidebarPanel extends UI.VBox { } _deselectAllItems() { - const items = this.contentElement.querySelectorAll(`.${CssOverview.CSSOverviewSidebarPanel.ITEM_CLASS_NAME}`); + const items = this.contentElement.querySelectorAll(`.${CSSOverviewSidebarPanel.ITEM_CLASS_NAME}`); for (const item of items) { - item.classList.remove(CssOverview.CSSOverviewSidebarPanel.SELECTED); + item.classList.remove(CSSOverviewSidebarPanel.SELECTED); } } _onItemClick(event) { const target = event.path[0]; - if (!target.classList.contains(CssOverview.CSSOverviewSidebarPanel.ITEM_CLASS_NAME)) { + if (!target.classList.contains(CSSOverviewSidebarPanel.ITEM_CLASS_NAME)) { return; } @@ -62,12 +62,12 @@ export default class CSSOverviewSidebarPanel extends UI.VBox { return; } - if (target.classList.contains(CssOverview.CSSOverviewSidebarPanel.SELECTED)) { + if (target.classList.contains(CSSOverviewSidebarPanel.SELECTED)) { return; } this._deselectAllItems(); - target.classList.add(CssOverview.CSSOverviewSidebarPanel.SELECTED); + target.classList.add(CSSOverviewSidebarPanel.SELECTED); } } @@ -75,16 +75,3 @@ export const SidebarEvents = { ItemSelected: Symbol('ItemSelected'), Reset: Symbol('Reset') }; - -/* Legacy exported object */ -self.CssOverview = self.CssOverview || {}; - -/* Legacy exported object */ -CssOverview = CssOverview || {}; - -/** - * @constructor - */ -CssOverview.CSSOverviewSidebarPanel = CSSOverviewSidebarPanel; - -CssOverview.SidebarEvents = SidebarEvents; diff --git a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewStartView.js b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewStartView.js index eb85fa59e6..b06f5e6e43 100644 --- a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewStartView.js +++ b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewStartView.js @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Events} from './CSSOverviewController.js'; + /** * @unrestricted */ @@ -16,8 +18,8 @@ export class CSSOverviewStartView extends UI.Widget { _render() { const startButton = UI.createTextButton( - ls`Capture overview`, () => this._controller.dispatchEventToListeners(CssOverview.Events.RequestOverviewStart), - '', true /* primary */); + ls`Capture overview`, () => this._controller.dispatchEventToListeners(Events.RequestOverviewStart), '', + true /* primary */); this.setDefaultFocusedElement(startButton); @@ -32,14 +34,3 @@ export class CSSOverviewStartView extends UI.Widget { this.contentElement.style.overflow = 'auto'; } } - -/* Legacy exported object */ -self.CssOverview = self.CssOverview || {}; - -/* Legacy exported object */ -CssOverview = CssOverview || {}; - -/** - * @constructor - */ -CssOverview.CSSOverviewStartView = CSSOverviewStartView; diff --git a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewUnusedDeclarations.js b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewUnusedDeclarations.js index 4c37a470bf..ff68bb99b5 100644 --- a/resources/unpacked/devtools/front_end/css_overview/CSSOverviewUnusedDeclarations.js +++ b/resources/unpacked/devtools/front_end/css_overview/CSSOverviewUnusedDeclarations.js @@ -87,11 +87,3 @@ export class CSSOverviewUnusedDeclarations { } } } - -/* Legacy exported object */ -self.CssOverview = self.CssOverview || {}; - -/* Legacy exported object */ -CssOverview = CssOverview || {}; - -CssOverview.CSSOverviewUnusedDeclarations = CSSOverviewUnusedDeclarations; diff --git a/resources/unpacked/devtools/front_end/css_overview/css_overview-legacy.js b/resources/unpacked/devtools/front_end/css_overview/css_overview-legacy.js new file mode 100644 index 0000000000..d98d163b99 --- /dev/null +++ b/resources/unpacked/devtools/front_end/css_overview/css_overview-legacy.js @@ -0,0 +1,63 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import * as CssOverviewModule from './css_overview.js'; + +self.CssOverview = self.CssOverview || {}; +CssOverview = CssOverview || {}; + +/** + * @constructor + */ +CssOverview.CSSOverviewCompletedView = CssOverviewModule.CSSOverviewCompletedView.CSSOverviewCompletedView; + + +/** + * @constructor + */ +CssOverview.CSSOverviewCompletedView.DetailsView = CssOverviewModule.CSSOverviewCompletedView.DetailsView; + +/** + * @constructor + */ +CssOverview.CSSOverviewCompletedView.ElementDetailsView = CssOverviewModule.CSSOverviewCompletedView.ElementDetailsView; + +CssOverview.CSSOverviewCompletedView.ElementNode = CssOverviewModule.CSSOverviewCompletedView.ElementNode; + +/** + * @constructor + */ +CssOverview.OverviewController = CssOverviewModule.CSSOverviewController.OverviewController; + +CssOverview.Events = CssOverviewModule.CSSOverviewController.Events; + +/** + * @constructor + */ +CssOverview.CSSOverviewModel = CssOverviewModule.CSSOverviewModel.CSSOverviewModel; + +/** + * @constructor + */ +CssOverview.CSSOverviewPanel = CssOverviewModule.CSSOverviewPanel.CSSOverviewPanel; + +/** + * @constructor + */ +CssOverview.CSSOverviewProcessingView = CssOverviewModule.CSSOverviewProcessingView.CSSOverviewProcessingView; + +/** + * @constructor + */ +CssOverview.CSSOverviewSidebarPanel = CssOverviewModule.CSSOverviewSidebarPanel.CSSOverviewSidebarPanel; + +CssOverview.SidebarEvents = CssOverviewModule.CSSOverviewSidebarPanel.SidebarEvents; + +/** + * @constructor + */ +CssOverview.CSSOverviewStartView = CssOverviewModule.CSSOverviewStartView.CSSOverviewStartView; + +CssOverview.CSSOverviewUnusedDeclarations = + CssOverviewModule.CSSOverviewUnusedDeclarations.CSSOverviewUnusedDeclarations; diff --git a/resources/unpacked/devtools/front_end/css_overview/module.json b/resources/unpacked/devtools/front_end/css_overview/module.json index 466ae92887..b0464fc302 100644 --- a/resources/unpacked/devtools/front_end/css_overview/module.json +++ b/resources/unpacked/devtools/front_end/css_overview/module.json @@ -18,6 +18,8 @@ "extensions" ], "modules": [ + "css_overview.js", + "css_overview-legacy.js", "CSSOverviewController.js", "CSSOverviewUnusedDeclarations.js", "CSSOverviewModel.js", diff --git a/resources/unpacked/devtools/front_end/data_grid/DataGrid.js b/resources/unpacked/devtools/front_end/data_grid/DataGrid.js index 7b3484f047..27369bce70 100644 --- a/resources/unpacked/devtools/front_end/data_grid/DataGrid.js +++ b/resources/unpacked/devtools/front_end/data_grid/DataGrid.js @@ -27,9 +27,9 @@ * @unrestricted * @template NODE_TYPE */ -export default class DataGridImpl extends Common.Object { +export class DataGridImpl extends Common.Object { /** - * @param {!DataGrid.DataGrid.Parameters} dataGridParameters + * @param {!DataGrid.Parameters} dataGridParameters */ constructor(dataGridParameters) { super(); @@ -82,11 +82,11 @@ export default class DataGridImpl extends Common.Object { /** @type {boolean} */ this._inline = false; - /** @type {!Array.} */ + /** @type {!Array.} */ this._columnsArray = []; - /** @type {!Object.} */ + /** @type {!Object.} */ this._columns = {}; - /** @type {!Array.} */ + /** @type {!Array.} */ this.visibleColumnsArray = columnsArray; columnsArray.forEach(column => this._innerAddColumn(column)); @@ -243,7 +243,7 @@ export default class DataGridImpl extends Common.Object { } /** - * @param {!DataGrid.DataGrid.ColumnDescriptor} column + * @param {!DataGrid.ColumnDescriptor} column * @param {number=} position */ _innerAddColumn(column, position) { @@ -290,7 +290,7 @@ export default class DataGridImpl extends Common.Object { } /** - * @param {!DataGrid.DataGrid.ColumnDescriptor} column + * @param {!DataGrid.ColumnDescriptor} column * @param {number=} position */ addColumn(column, position) { @@ -514,7 +514,7 @@ export default class DataGridImpl extends Common.Object { /** * @param {boolean} wasChange - * @this {DataGrid.DataGrid} + * @this {DataGridImpl} */ function moveToNextIfNeeded(wasChange) { if (!moveDirection) { @@ -563,7 +563,7 @@ export default class DataGridImpl extends Common.Object { } // Show trimmed text after editing. - DataGrid.DataGrid.setElementText(element, newText, !!column.longText); + DataGridImpl.setElementText(element, newText, !!column.longText); if (textBeforeEditing === newText) { this._editingCancelled(element); @@ -944,7 +944,7 @@ export default class DataGridImpl extends Common.Object { for (const column in this._columns) { emptyData[column] = null; } - this.creationNode = new DataGrid.CreationDataGridNode(emptyData, hasChildren); + this.creationNode = new CreationDataGridNode(emptyData, hasChildren); this.rootNode().appendChild(this.creationNode); } @@ -1507,7 +1507,7 @@ export class DataGridNode extends Common.Object { this._hasChildren = hasChildren || false; /** @type {!Array.} */ this.children = []; - /** @type {?DataGrid.DataGrid} */ + /** @type {?DataGridImpl} */ this.dataGrid = null; /** @type {?NODE_TYPE} */ this.parent = null; @@ -1870,7 +1870,7 @@ export class DataGridNode extends Common.Object { if (data instanceof Node) { cell.appendChild(data); } else if (data !== null) { - DataGrid.DataGrid.setElementText(cell, /** @type {string} */ (data), !!this.dataGrid._columns[columnId].longText); + DataGridImpl.setElementText(cell, /** @type {string} */ (data), !!this.dataGrid._columns[columnId].longText); } return cell; @@ -2371,7 +2371,7 @@ export class CreationDataGridNode extends DataGridNode { */ export class DataGridWidget extends UI.VBox { /** - * @param {!DataGrid.DataGrid} dataGrid + * @param {!DataGridImpl} dataGrid */ constructor(dataGrid) { super(); @@ -2419,105 +2419,3 @@ export class DataGridWidget extends UI.VBox { this._dataGrids = []; } } - -/* Legacy exported object */ -self.DataGrid = self.DataGrid || {}; - -/* Legacy exported object */ -DataGrid = DataGrid || {}; - -/** - * @typedef {{ - * displayName: string, - * columns: !Array., - * editCallback: (function(!Object, string, string, string)|undefined), - * deleteCallback: (function(!Object)|undefined|function(string)), - * refreshCallback: (function()|undefined) - * }} - */ -DataGrid.Parameters; - -/** - * @typedef {{ - * id: string, - * title: (string|undefined), - * titleDOMFragment: (?DocumentFragment|undefined), - * sortable: boolean, - * sort: (?Order|undefined), - * align: (?Align|undefined), - * fixedWidth: (boolean|undefined), - * editable: (boolean|undefined), - * nonSelectable: (boolean|undefined), - * longText: (boolean|undefined), - * disclosure: (boolean|undefined), - * weight: (number|undefined), - * allowInSortByEvenWhenHidden: (boolean|undefined) - * }} - */ -DataGrid.ColumnDescriptor; - -DataGrid._preferredWidthSymbol = Symbol('preferredWidth'); -DataGrid._columnIdSymbol = Symbol('columnId'); -DataGrid._sortIconSymbol = Symbol('sortIcon'); -DataGrid._longTextSymbol = Symbol('longText'); - -/** - * @unrestricted - * @constructor - */ -DataGrid.DataGrid = DataGridImpl; - -/** - * @unrestricted - * @constructor - */ -DataGrid.CreationDataGridNode = CreationDataGridNode; - -/** - * @unrestricted - * @constructor - */ -DataGrid.DataGridNode = DataGridNode; -DataGrid.DataGridWidget = DataGridWidget; - -/** @enum {symbol} */ -DataGrid.DataGrid.Events = Events; - -/** @enum {string} */ -DataGrid.DataGrid.Order = Order; - -/** @enum {string} */ -DataGrid.DataGrid.Align = Align; - -/** @enum {string} */ -DataGrid.DataGrid.ResizeMethod = ResizeMethod; - -/** - * @typedef {{ - * displayName: string, - * columns: !Array., - * editCallback: (function(!Object, string, string, string)|undefined), - * deleteCallback: (function(!Object)|undefined|function(string)), - * refreshCallback: (function()|undefined) - * }} - */ -DataGrid.DataGrid.Parameters = DataGrid.Parameters; - -/** - * @typedef {{ - * id: string, - * title: (string|undefined), - * titleDOMFragment: (?DocumentFragment|undefined), - * sortable: boolean, - * sort: (?Order|undefined), - * align: (?Align|undefined), - * fixedWidth: (boolean|undefined), - * editable: (boolean|undefined), - * nonSelectable: (boolean|undefined), - * longText: (boolean|undefined), - * disclosure: (boolean|undefined), - * weight: (number|undefined), - * allowInSortByEvenWhenHidden: (boolean|undefined) - * }} - */ -DataGrid.DataGrid.ColumnDescriptor = DataGrid.ColumnDescriptor; diff --git a/resources/unpacked/devtools/front_end/data_grid/ShowMoreDataGridNode.js b/resources/unpacked/devtools/front_end/data_grid/ShowMoreDataGridNode.js index 7fd7546c13..30534e9dba 100644 --- a/resources/unpacked/devtools/front_end/data_grid/ShowMoreDataGridNode.js +++ b/resources/unpacked/devtools/front_end/data_grid/ShowMoreDataGridNode.js @@ -28,10 +28,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import {DataGridNode} from './DataGrid.js'; + /** * @unrestricted */ -export default class ShowMoreDataGridNode extends DataGrid.DataGridNode { +export class ShowMoreDataGridNode extends DataGridNode { /** * @param {function(number, number)} callback * @param {number} startPosition @@ -143,14 +145,3 @@ export default class ShowMoreDataGridNode extends DataGrid.DataGridNode { dispose() { } } - -/* Legacy exported object */ -self.DataGrid = self.DataGrid || {}; - -/* Legacy exported object */ -DataGrid = DataGrid || {}; - -/** - * @constructor - */ -DataGrid.ShowMoreDataGridNode = ShowMoreDataGridNode; diff --git a/resources/unpacked/devtools/front_end/data_grid/SortableDataGrid.js b/resources/unpacked/devtools/front_end/data_grid/SortableDataGrid.js index b9110807b2..c48893819e 100644 --- a/resources/unpacked/devtools/front_end/data_grid/SortableDataGrid.js +++ b/resources/unpacked/devtools/front_end/data_grid/SortableDataGrid.js @@ -1,24 +1,28 @@ // Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + +import {Events} from './DataGrid.js'; +import {ViewportDataGrid, ViewportDataGridNode} from './ViewportDataGrid.js'; + /** * @unrestricted - * @extends {DataGrid.ViewportDataGrid} + * @extends {ViewportDataGrid} * @template NODE_TYPE */ -export default class SortableDataGrid extends DataGrid.ViewportDataGrid { +export class SortableDataGrid extends ViewportDataGrid { /** - * @param {!DataGrid.DataGrid.Parameters} dataGridParameters + * @param {!DataGrid.Parameters} dataGridParameters */ constructor(dataGridParameters) { super(dataGridParameters); /** @type {function(!NODE_TYPE, !NODE_TYPE):number} */ - this._sortingFunction = DataGrid.SortableDataGrid.TrivialComparator; - this.setRootNode(/** @type {!DataGrid.SortableDataGridNode} */ (new DataGrid.SortableDataGridNode())); + this._sortingFunction = SortableDataGrid.TrivialComparator; + this.setRootNode(/** @type {!SortableDataGridNode} */ (new SortableDataGridNode())); } /** - * @param {!DataGrid.SortableDataGridNode} a + * @param {!SortableDataGridNode} a * @param {!DataGrid.SortableDataGridNode} b * @return {number} */ @@ -28,7 +32,7 @@ export default class SortableDataGrid extends DataGrid.ViewportDataGrid { /** * @param {string} columnId - * @param {!DataGrid.SortableDataGridNode} a + * @param {!SortableDataGridNode} a * @param {!DataGrid.SortableDataGridNode} b * @return {number} */ @@ -42,7 +46,7 @@ export default class SortableDataGrid extends DataGrid.ViewportDataGrid { /** * @param {string} columnId - * @param {!DataGrid.SortableDataGridNode} a + * @param {!SortableDataGridNode} a * @param {!DataGrid.SortableDataGridNode} b * @return {number} */ @@ -70,7 +74,7 @@ export default class SortableDataGrid extends DataGrid.ViewportDataGrid { * @param {!Array.} columnNames * @param {!Array.} values * @param {string} displayName - * @return {?DataGrid.SortableDataGrid} + * @return {?SortableDataGrid} */ static create(columnNames, values, displayName) { const numColumns = columnNames.length; @@ -78,7 +82,7 @@ export default class SortableDataGrid extends DataGrid.ViewportDataGrid { return null; } - const columns = /** @type {!Array} */ ([]); + const columns = /** @type {!Array} */ ([]); for (let i = 0; i < columnNames.length; ++i) { columns.push({id: String(i), title: columnNames[i], width: columnNames[i].length, sortable: true}); } @@ -90,19 +94,19 @@ export default class SortableDataGrid extends DataGrid.ViewportDataGrid { data[j] = values[numColumns * i + j]; } - const node = new DataGrid.SortableDataGridNode(data); + const node = new SortableDataGridNode(data); node.selectable = false; nodes.push(node); } - const dataGrid = new DataGrid.SortableDataGrid({displayName, columns}); + const dataGrid = new SortableDataGrid({displayName, columns}); const length = nodes.length; const rootNode = dataGrid.rootNode(); for (let i = 0; i < length; ++i) { rootNode.appendChild(nodes[i]); } - dataGrid.addEventListener(DataGrid.DataGrid.Events.SortingChanged, sortDataGrid); + dataGrid.addEventListener(Events.SortingChanged, sortDataGrid); function sortDataGrid() { const nodes = dataGrid.rootNode().children; @@ -120,8 +124,7 @@ export default class SortableDataGrid extends DataGrid.ViewportDataGrid { } } - const comparator = - columnIsNumeric ? DataGrid.SortableDataGrid.NumericComparator : DataGrid.SortableDataGrid.StringComparator; + const comparator = columnIsNumeric ? SortableDataGrid.NumericComparator : SortableDataGrid.StringComparator; dataGrid.sortNodes(comparator.bind(null, sortColumnId), !dataGrid.isSortOrderAscending()); } return dataGrid; @@ -131,7 +134,7 @@ export default class SortableDataGrid extends DataGrid.ViewportDataGrid { * @param {!NODE_TYPE} node */ insertChild(node) { - const root = /** @type {!DataGrid.SortableDataGridNode} */ (this.rootNode()); + const root = /** @type {!SortableDataGridNode} */ (this.rootNode()); root.insertChildOrdered(node); } @@ -140,7 +143,7 @@ export default class SortableDataGrid extends DataGrid.ViewportDataGrid { * @param {boolean} reverseMode */ sortNodes(comparator, reverseMode) { - this._sortingFunction = DataGrid.SortableDataGrid.Comparator.bind(null, comparator, reverseMode); + this._sortingFunction = SortableDataGrid.Comparator.bind(null, comparator, reverseMode); this.rootNode().recalculateSiblings(0); this.rootNode()._sortChildren(reverseMode); this.scheduleUpdateStructure(); @@ -149,10 +152,10 @@ export default class SortableDataGrid extends DataGrid.ViewportDataGrid { /** * @unrestricted - * @extends {DataGrid.ViewportDataGridNode} + * @extends {ViewportDataGridNode} * @template NODE_TYPE */ -export class SortableDataGridNode extends DataGrid.ViewportDataGridNode { +export class SortableDataGridNode extends ViewportDataGridNode { /** * @param {?Object.=} data * @param {boolean=} hasChildren @@ -178,22 +181,3 @@ export class SortableDataGridNode extends DataGrid.ViewportDataGridNode { } } } - -/* Legacy exported object */ -self.DataGrid = self.DataGrid || {}; - -/* Legacy exported object */ -DataGrid = DataGrid || {}; - -/** - * @unrestricted - * @constructor - */ -DataGrid.SortableDataGrid = SortableDataGrid; - -/** - * @unrestricted - * @constructor - * @extends {DataGrid.ViewportDataGridNode} - */ -DataGrid.SortableDataGridNode = SortableDataGridNode; diff --git a/resources/unpacked/devtools/front_end/data_grid/ViewportDataGrid.js b/resources/unpacked/devtools/front_end/data_grid/ViewportDataGrid.js index 9538d2e74b..d7dda18345 100644 --- a/resources/unpacked/devtools/front_end/data_grid/ViewportDataGrid.js +++ b/resources/unpacked/devtools/front_end/data_grid/ViewportDataGrid.js @@ -1,14 +1,17 @@ // Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + +import {DataGridImpl, DataGridNode} from './DataGrid.js'; + /** * @unrestricted - * @extends {DataGrid.DataGrid} + * @extends {DataGridImpl} * @template NODE_TYPE */ -export default class ViewportDataGrid extends DataGrid.DataGrid { +export class ViewportDataGrid extends DataGridImpl { /** - * @param {!DataGrid.DataGrid.Parameters} dataGridParameters + * @param {!DataGrid.Parameters} dataGridParameters */ constructor(dataGridParameters) { super(dataGridParameters); @@ -16,7 +19,7 @@ export default class ViewportDataGrid extends DataGrid.DataGrid { this._onScrollBound = this._onScroll.bind(this); this.scrollContainer.addEventListener('scroll', this._onScrollBound, true); - /** @type {!Array.} */ + /** @type {!Array.} */ this._visibleNodes = []; /** * @type {boolean} @@ -29,7 +32,7 @@ export default class ViewportDataGrid extends DataGrid.DataGrid { this._firstVisibleIsStriped = false; this._isStriped = false; - this.setRootNode(new DataGrid.ViewportDataGridNode()); + this.setRootNode(new ViewportDataGridNode()); } /** @@ -134,7 +137,7 @@ export default class ViewportDataGrid extends DataGrid.DataGrid { /** * @param {number} clientHeight * @param {number} scrollTop - * @return {{topPadding: number, bottomPadding: number, contentHeight: number, visibleNodes: !Array., offset: number}} + * @return {{topPadding: number, bottomPadding: number, contentHeight: number, visibleNodes: !Array., offset: number}} */ _calculateVisibleNodes(clientHeight, scrollTop) { const nodes = this.rootNode().flatChildren(); @@ -253,7 +256,7 @@ export default class ViewportDataGrid extends DataGrid.DataGrid { } /** - * @param {!DataGrid.ViewportDataGridNode} node + * @param {!ViewportDataGridNode} node */ _revealViewportNode(node) { const nodes = this.rootNode().flatChildren(); @@ -287,10 +290,10 @@ export const Events = { /** * @unrestricted - * @extends {DataGrid.DataGridNode} + * @extends {DataGridNode} * @template NODE_TYPE */ -export class ViewportDataGridNode extends DataGrid.DataGridNode { +export class ViewportDataGridNode extends DataGridNode { /** * @param {?Object.=} data * @param {boolean=} hasChildren @@ -299,7 +302,7 @@ export class ViewportDataGridNode extends DataGrid.DataGridNode { super(data, hasChildren); /** @type {boolean} */ this._stale = false; - /** @type {?Array} */ + /** @type {?Array} */ this._flatNodes = null; this._isStriped = false; } @@ -338,22 +341,22 @@ export class ViewportDataGridNode extends DataGrid.DataGridNode { */ clearFlatNodes() { this._flatNodes = null; - const parent = /** @type {!DataGrid.ViewportDataGridNode} */ (this.parent); + const parent = /** @type {!ViewportDataGridNode} */ (this.parent); if (parent) { parent.clearFlatNodes(); } } /** - * @return {!Array} + * @return {!Array} */ flatChildren() { if (this._flatNodes) { return this._flatNodes; } - /** @type {!Array} */ + /** @type {!Array} */ const flatNodes = []; - /** @type {!Array>} */ + /** @type {!Array>} */ const children = [this.children]; /** @type {!Array} */ const counters = [0]; @@ -533,28 +536,3 @@ export class ViewportDataGridNode extends DataGrid.DataGridNode { super.recalculateSiblings(index); } } - -/* Legacy exported object */ -self.DataGrid = self.DataGrid || {}; - -/* Legacy exported object */ -DataGrid = DataGrid || {}; - -/** - * @unrestricted - * @extends {DataGrid.DataGrid} - * @constructor - */ -DataGrid.ViewportDataGrid = ViewportDataGrid; - -/** - * @override @suppress {checkPrototypalTypes} @enum {symbol} - */ -DataGrid.ViewportDataGrid.Events = Events; - -/** - * @unrestricted - * @extends {DataGrid.DataGridNode} - * @constructor - */ -DataGrid.ViewportDataGridNode = ViewportDataGridNode; diff --git a/resources/unpacked/devtools/front_end/data_grid/data_grid-legacy.js b/resources/unpacked/devtools/front_end/data_grid/data_grid-legacy.js new file mode 100644 index 0000000000..e39b7b2b76 --- /dev/null +++ b/resources/unpacked/devtools/front_end/data_grid/data_grid-legacy.js @@ -0,0 +1,111 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import * as DataGridModule from './data_grid.js'; + +self.DataGrid = self.DataGrid || {}; +DataGrid = DataGrid || {}; + +DataGrid._preferredWidthSymbol = Symbol('preferredWidth'); +DataGrid._columnIdSymbol = Symbol('columnId'); +DataGrid._sortIconSymbol = Symbol('sortIcon'); +DataGrid._longTextSymbol = Symbol('longText'); + +/** + * @unrestricted + * @constructor + */ +DataGrid.DataGrid = DataGridModule.DataGrid.DataGridImpl; + +/** + * @unrestricted + * @constructor + */ +DataGrid.CreationDataGridNode = DataGridModule.DataGrid.CreationDataGridNode; + +/** + * @unrestricted + * @constructor + */ +DataGrid.DataGridNode = DataGridModule.DataGrid.DataGridNode; +DataGrid.DataGridWidget = DataGridModule.DataGrid.DataGridWidget; + +/** @enum {symbol} */ +DataGrid.DataGrid.Events = DataGridModule.DataGrid.Events; + +/** @enum {string} */ +DataGrid.DataGrid.Order = DataGridModule.DataGrid.Order; + +/** @enum {string} */ +DataGrid.DataGrid.Align = DataGridModule.DataGrid.Align; + +/** @enum {string} */ +DataGrid.DataGrid.ResizeMethod = DataGridModule.DataGrid.ResizeMethod; + +/** + * @typedef {{ + * displayName: string, + * columns: !Array., + * editCallback: (function(!Object, string, string, string)|undefined), + * deleteCallback: (function(!Object)|undefined|function(string)), + * refreshCallback: (function()|undefined) + * }} + */ +DataGrid.Parameters = DataGridModule.Parameters; + +/** + * @typedef {{ + * id: string, + * title: (string|undefined), + * titleDOMFragment: (?DocumentFragment|undefined), + * sortable: boolean, + * sort: (?DataGrid.DataGrid.Order|undefined), + * align: (?DataGrid.DataGrid.Align|undefined), + * fixedWidth: (boolean|undefined), + * editable: (boolean|undefined), + * nonSelectable: (boolean|undefined), + * longText: (boolean|undefined), + * disclosure: (boolean|undefined), + * weight: (number|undefined), + * allowInSortByEvenWhenHidden: (boolean|undefined) + * }} + */ +DataGrid.ColumnDescriptor = DataGridModule.ColumnDescriptor; + +/** + * @constructor + */ +DataGrid.ShowMoreDataGridNode = DataGridModule.ShowMoreDataGridNode.ShowMoreDataGridNode; + +/** + * @unrestricted + * @constructor + */ +DataGrid.SortableDataGrid = DataGridModule.SortableDataGrid.SortableDataGrid; + +/** + * @unrestricted + * @constructor + * @extends {DataGrid.ViewportDataGridNode} + */ +DataGrid.SortableDataGridNode = DataGridModule.SortableDataGrid.SortableDataGridNode; + +/** + * @unrestricted + * @extends {DataGrid.DataGrid} + * @constructor + */ +DataGrid.ViewportDataGrid = DataGridModule.ViewportDataGrid.ViewportDataGrid; + +/** + * @override @suppress {checkPrototypalTypes} @enum {symbol} + */ +DataGrid.ViewportDataGrid.Events = DataGridModule.ViewportDataGrid.Events; + +/** + * @unrestricted + * @extends {DataGrid.DataGridNode} + * @constructor + */ +DataGrid.ViewportDataGridNode = DataGridModule.ViewportDataGrid.ViewportDataGridNode; diff --git a/resources/unpacked/devtools/front_end/data_grid/data_grid.js b/resources/unpacked/devtools/front_end/data_grid/data_grid.js index 018ff34b0b..7573a721e6 100644 --- a/resources/unpacked/devtools/front_end/data_grid/data_grid.js +++ b/resources/unpacked/devtools/front_end/data_grid/data_grid.js @@ -12,4 +12,34 @@ import * as ShowMoreDataGridNode from './ShowMoreDataGridNode.js'; import * as SortableDataGrid from './SortableDataGrid.js'; import * as ViewportDataGrid from './ViewportDataGrid.js'; +/** + * @typedef {{ + * displayName: string, + * columns: !Array., + * editCallback: (function(!Object, string, string, string)|undefined), + * deleteCallback: (function(!Object)|undefined|function(string)), + * refreshCallback: (function()|undefined) + * }} + */ +export let Parameters; + +/** + * @typedef {{ + * id: string, + * title: (string|undefined), + * titleDOMFragment: (?DocumentFragment|undefined), + * sortable: boolean, + * sort: (?DataGrid.Order|undefined), + * align: (?DataGrid.Align|undefined), + * fixedWidth: (boolean|undefined), + * editable: (boolean|undefined), + * nonSelectable: (boolean|undefined), + * longText: (boolean|undefined), + * disclosure: (boolean|undefined), + * weight: (number|undefined), + * allowInSortByEvenWhenHidden: (boolean|undefined) + * }} + */ +export let ColumnDescriptor; + export {DataGrid, ShowMoreDataGridNode, SortableDataGrid, ViewportDataGrid}; diff --git a/resources/unpacked/devtools/front_end/data_grid/module.json b/resources/unpacked/devtools/front_end/data_grid/module.json index 162fe26a8e..7010ed9773 100644 --- a/resources/unpacked/devtools/front_end/data_grid/module.json +++ b/resources/unpacked/devtools/front_end/data_grid/module.json @@ -8,6 +8,7 @@ ], "modules": [ "data_grid.js", + "data_grid-legacy.js", "DataGrid.js", "ViewportDataGrid.js", "SortableDataGrid.js", diff --git a/resources/unpacked/devtools/front_end/diff/DiffWrapper.js b/resources/unpacked/devtools/front_end/diff/DiffWrapper.js index 531b7a0ec9..2b4bd7c4d6 100644 --- a/resources/unpacked/devtools/front_end/diff/DiffWrapper.js +++ b/resources/unpacked/devtools/front_end/diff/DiffWrapper.js @@ -90,17 +90,3 @@ export const Operation = { Delete: -1, Edit: 2 }; - -/* Legacy exported object */ -self.Diff = self.Diff || {}; - -/* Legacy exported object */ -Diff = Diff || {}; - -Diff.Diff = DiffWrapper; - -/** @enum {number} */ -Diff.Diff.Operation = Operation; - -/** @typedef {!Array}>} */ -Diff.Diff.DiffArray; diff --git a/resources/unpacked/devtools/front_end/diff/diff-legacy.js b/resources/unpacked/devtools/front_end/diff/diff-legacy.js new file mode 100644 index 0000000000..ad92f6202a --- /dev/null +++ b/resources/unpacked/devtools/front_end/diff/diff-legacy.js @@ -0,0 +1,16 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import * as DiffModule from './diff.js'; + +self.Diff = self.Diff || {}; +Diff = Diff || {}; + +Diff.Diff = DiffModule.Diff.DiffWrapper; + +/** @enum {number} */ +Diff.Diff.Operation = DiffModule.Diff.Operation; + +/** @typedef {!Array}>} */ +Diff.Diff.DiffArray; diff --git a/resources/unpacked/devtools/front_end/diff/module.json b/resources/unpacked/devtools/front_end/diff/module.json index 42e87d7da6..994bbce4a3 100644 --- a/resources/unpacked/devtools/front_end/diff/module.json +++ b/resources/unpacked/devtools/front_end/diff/module.json @@ -5,6 +5,7 @@ "scripts": [], "modules": [ "diff.js", + "diff-legacy.js", "DiffWrapper.js", "diff_match_patch.js" ], diff --git a/resources/unpacked/devtools/front_end/elements/StylesSidebarPane.js b/resources/unpacked/devtools/front_end/elements/StylesSidebarPane.js index 19dfb25bd0..f20f6ed8b0 100644 --- a/resources/unpacked/devtools/front_end/elements/StylesSidebarPane.js +++ b/resources/unpacked/devtools/front_end/elements/StylesSidebarPane.js @@ -1836,7 +1836,10 @@ export class StylePropertiesSection { // This gets deleted in finishOperation(), which is called both on success and failure. this._parentPane.setUserOperation(true); - this._parentPane.cssModel().setMediaText(media.styleSheetId, media.range, newContent).then(userCallback.bind(this)); + const cssModel = this._parentPane.cssModel(); + if (cssModel) { + cssModel.setMediaText(media.styleSheetId, media.range, newContent).then(userCallback.bind(this)); + } } _editingMediaTextCommittedForTest() { @@ -1865,6 +1868,9 @@ export class StylePropertiesSection { */ _navigateToSelectorSource(index, focus) { const cssModel = this._parentPane.cssModel(); + if (!cssModel) { + return; + } const rule = this._style.parentRule; const header = cssModel.styleSheetHeaderForId(/** @type {string} */ (rule.styleSheetId)); if (!header) { @@ -2159,7 +2165,9 @@ export class BlankStylePropertiesSection extends StylePropertiesSection { const cssModel = this._parentPane.cssModel(); const ruleText = this._rulePrefix() + newContent + ' {}'; - cssModel.addRule(this._styleSheetId, ruleText, this._ruleLocation).then(onRuleAdded.bind(this)); + if (cssModel) { + cssModel.addRule(this._styleSheetId, ruleText, this._ruleLocation).then(onRuleAdded.bind(this)); + } } /** diff --git a/resources/unpacked/devtools/front_end/emulation/AdvancedApp.js b/resources/unpacked/devtools/front_end/emulation/AdvancedApp.js index bfa4609ae8..89f1994e44 100644 --- a/resources/unpacked/devtools/front_end/emulation/AdvancedApp.js +++ b/resources/unpacked/devtools/front_end/emulation/AdvancedApp.js @@ -1,24 +1,31 @@ // Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + +import {DeviceModeWrapper} from './DeviceModeWrapper.js'; +import {Events, instance} from './InspectedPagePlaceholder.js'; + +/** @type {!AdvancedApp} */ +let _appInstance; + /** * @implements {Common.App} * @unrestricted */ -export default class AdvancedApp { +export class AdvancedApp { constructor() { Components.dockController.addEventListener( Components.DockController.Events.BeforeDockSideChanged, this._openToolboxWindow, this); } /** - * @return {!Emulation.AdvancedApp} + * @return {!AdvancedApp} */ static _instance() { - if (!Emulation.AdvancedApp._appInstance) { - Emulation.AdvancedApp._appInstance = new Emulation.AdvancedApp(); + if (!_appInstance) { + _appInstance = new AdvancedApp(); } - return Emulation.AdvancedApp._appInstance; + return _appInstance; } /** @@ -34,10 +41,9 @@ export default class AdvancedApp { this._rootSplitWidget.setDefaultFocusedChild(UI.inspectorView); UI.inspectorView.setOwnerSplit(this._rootSplitWidget); - this._inspectedPagePlaceholder = Emulation.InspectedPagePlaceholder.instance(); - this._inspectedPagePlaceholder.addEventListener( - Emulation.InspectedPagePlaceholder.Events.Update, this._onSetInspectedPageBounds.bind(this), this); - this._deviceModeView = new Emulation.DeviceModeWrapper(this._inspectedPagePlaceholder); + this._inspectedPagePlaceholder = instance(); + this._inspectedPagePlaceholder.addEventListener(Events.Update, this._onSetInspectedPageBounds.bind(this), this); + this._deviceModeView = new DeviceModeWrapper(this._inspectedPagePlaceholder); Components.dockController.addEventListener( Components.DockController.Events.BeforeDockSideChanged, this._onBeforeDockSideChange, this); @@ -201,25 +207,6 @@ export class AdvancedAppProvider { * @return {!Common.App} */ createApp() { - return Emulation.AdvancedApp._instance(); + return AdvancedApp._instance(); } } - -/* Legacy exported object */ -self.Emulation = self.Emulation || {}; - -/* Legacy exported object */ -Emulation = Emulation || {}; - -/** - * @constructor - */ -Emulation.AdvancedApp = AdvancedApp; - -/** @type {!Emulation.AdvancedApp} */ -Emulation.AdvancedApp._appInstance; - -/** - * @constructor - */ -Emulation.AdvancedAppProvider = AdvancedAppProvider; diff --git a/resources/unpacked/devtools/front_end/emulation/DeviceModeModel.js b/resources/unpacked/devtools/front_end/emulation/DeviceModeModel.js index 365bd28b40..9584b4b825 100644 --- a/resources/unpacked/devtools/front_end/emulation/DeviceModeModel.js +++ b/resources/unpacked/devtools/front_end/emulation/DeviceModeModel.js @@ -1,12 +1,15 @@ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + +import {EmulatedDevice, Horizontal} from './EmulatedDevices.js'; // eslint-disable-line no-unused-vars + /** * @implements {SDK.SDKModelObserver} * @extends {Common.Object} * @unrestricted */ -export default class DeviceModeModel extends Common.Object { +export class DeviceModeModel extends Common.Object { constructor() { super(); this._screenRect = new UI.Rect(0, 0, 1, 1); @@ -56,7 +59,7 @@ export default class DeviceModeModel extends Common.Object { /** @type {!Type} */ this._type = Type.None; - /** @type {?Emulation.EmulatedDevice} */ + /** @type {?EmulatedDevice} */ this._device = null; /** @type {?Emulation.EmulatedDevice.Mode} */ this._mode = null; @@ -151,7 +154,7 @@ export default class DeviceModeModel extends Common.Object { /** * @param {!Type} type - * @param {?Emulation.EmulatedDevice} device + * @param {?EmulatedDevice} device * @param {?Emulation.EmulatedDevice.Mode} mode * @param {number=} scale */ @@ -228,7 +231,7 @@ export default class DeviceModeModel extends Common.Object { } /** - * @return {?Emulation.EmulatedDevice} + * @return {?EmulatedDevice} */ device() { return this._device; @@ -508,9 +511,9 @@ export default class DeviceModeModel extends Common.Object { } this._applyDeviceMetrics( new UI.Size(orientation.width, orientation.height), insets, outline, this._scaleSetting.get(), - this._device.deviceScaleFactor, mobile, this._mode.orientation === Emulation.EmulatedDevice.Horizontal ? - Protocol.Emulation.ScreenOrientationType.LandscapePrimary : - Protocol.Emulation.ScreenOrientationType.PortraitPrimary, + this._device.deviceScaleFactor, mobile, + this._mode.orientation === Horizontal ? Protocol.Emulation.ScreenOrientationType.LandscapePrimary : + Protocol.Emulation.ScreenOrientationType.PortraitPrimary, resetPageScaleFactor); this._applyUserAgent(this._device.userAgent); this._applyTouch(this._device.touch(), mobile); @@ -727,7 +730,7 @@ export default class DeviceModeModel extends Common.Object { clip = {x: 0, y: 0, width: deviceMetrics.width, height: deviceMetrics.height, scale: 1}; if (this._device) { - const screenOrientation = this._mode.orientation === Emulation.EmulatedDevice.Horizontal ? + const screenOrientation = this._mode.orientation === Horizontal ? Protocol.Emulation.ScreenOrientationType.LandscapePrimary : Protocol.Emulation.ScreenOrientationType.PortraitPrimary; const screenOrientationAngle = @@ -796,31 +799,3 @@ const _mobileUserAgent = 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Mobile Safari/537.36'; export const _defaultMobileUserAgent = SDK.MultitargetNetworkManager.patchUserAgentWithChromeVersion(_mobileUserAgent); export const defaultMobileScaleFactor = 2; - -/* Legacy exported object */ -self.Emulation = self.Emulation || {}; - -/* Legacy exported object */ -Emulation = Emulation || {}; - -/** - * @constructor - */ -Emulation.DeviceModeModel = DeviceModeModel; - -/** @enum {string} */ -Emulation.DeviceModeModel.Events = Events; - -/** @enum {string} */ -Emulation.DeviceModeModel.Type = Type; - -/** @enum {string} */ -Emulation.DeviceModeModel.UA = UA; - -Emulation.DeviceModeModel.MinDeviceSize = MinDeviceSize; -Emulation.DeviceModeModel.MaxDeviceSize = MaxDeviceSize; -Emulation.DeviceModeModel.MinDeviceScaleFactor = MinDeviceScaleFactor; -Emulation.DeviceModeModel.MaxDeviceScaleFactor = MaxDeviceScaleFactor; -Emulation.DeviceModeModel.MaxDeviceNameLength = MaxDeviceNameLength; -Emulation.DeviceModeModel._defaultMobileUserAgent = _defaultMobileUserAgent; -Emulation.DeviceModeModel.defaultMobileScaleFactor = defaultMobileScaleFactor; diff --git a/resources/unpacked/devtools/front_end/emulation/DeviceModeToolbar.js b/resources/unpacked/devtools/front_end/emulation/DeviceModeToolbar.js index ef6807f980..980b1a2a57 100644 --- a/resources/unpacked/devtools/front_end/emulation/DeviceModeToolbar.js +++ b/resources/unpacked/devtools/front_end/emulation/DeviceModeToolbar.js @@ -1,12 +1,16 @@ // Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + +import {defaultMobileScaleFactor, DeviceModeModel, Type, UA} from './DeviceModeModel.js'; +import {EmulatedDevice, EmulatedDevicesList, Events, Horizontal, Vertical} from './EmulatedDevices.js'; + /** * @unrestricted */ -export default class DeviceModeToolbar { +export class DeviceModeToolbar { /** - * @param {!Emulation.DeviceModeModel} model + * @param {!DeviceModeModel} model * @param {!Common.Setting} showMediaInspectorSetting * @param {!Common.Setting} showRulersSetting */ @@ -24,7 +28,7 @@ export default class DeviceModeToolbar { this._autoAdjustScaleSetting = Common.settings.createSetting('emulation.autoAdjustScale', true); - /** @type {!Map} */ + /** @type {!Map} */ this._lastMode = new Map(); this._element = createElementWithClass('div', 'device-mode-toolbar'); @@ -51,11 +55,9 @@ export default class DeviceModeToolbar { optionsToolbar.makeWrappable(); this._fillOptionsToolbar(optionsToolbar); - this._emulatedDevicesList = Emulation.EmulatedDevicesList.instance(); - this._emulatedDevicesList.addEventListener( - Emulation.EmulatedDevicesList.Events.CustomDevicesUpdated, this._deviceListChanged, this); - this._emulatedDevicesList.addEventListener( - Emulation.EmulatedDevicesList.Events.StandardDevicesUpdated, this._deviceListChanged, this); + this._emulatedDevicesList = EmulatedDevicesList.instance(); + this._emulatedDevicesList.addEventListener(Events.CustomDevicesUpdated, this._deviceListChanged, this); + this._emulatedDevicesList.addEventListener(Events.StandardDevicesUpdated, this._deviceListChanged, this); this._persistenceSetting = Common.settings.createSetting('emulation.deviceModeValue', {device: '', orientation: '', mode: ''}); @@ -94,7 +96,7 @@ export default class DeviceModeToolbar { widthInput.maxLength = 4; widthInput.title = Common.UIString('Width'); this._updateWidthInput = - UI.bindInput(widthInput, this._applyWidth.bind(this), Emulation.DeviceModeModel.widthValidator, true); + UI.bindInput(widthInput, this._applyWidth.bind(this), DeviceModeModel.widthValidator, true); this._widthInput = widthInput; this._widthItem = this._wrapToolbarItem(widthInput); toolbar.appendToolbarItem(this._widthItem); @@ -120,7 +122,7 @@ export default class DeviceModeToolbar { if (!value) { return {valid: true}; } - return Emulation.DeviceModeModel.heightValidator(value); + return DeviceModeModel.heightValidator(value); } } @@ -203,7 +205,7 @@ export default class DeviceModeToolbar { * @param {!UI.ContextMenu} contextMenu */ _appendScaleMenuItems(contextMenu) { - if (this._model.type() === Emulation.DeviceModeModel.Type.Device) { + if (this._model.type() === Type.Device) { contextMenu.footerSection().appendItem( Common.UIString('Fit to window (%.0f%%)', this._model.fitScale() * 100), this._onScaleMenuChanged.bind(this, this._model.fitScale()), false); @@ -220,7 +222,7 @@ export default class DeviceModeToolbar { /** * @param {string} title * @param {number} value - * @this {!Emulation.DeviceModeToolbar} + * @this {!DeviceModeToolbar} */ function appendScaleItem(title, value) { contextMenu.defaultSection().appendCheckboxItem( @@ -244,9 +246,9 @@ export default class DeviceModeToolbar { */ _appendDeviceScaleMenuItems(contextMenu) { const deviceScaleFactorSetting = this._model.deviceScaleFactorSetting(); - const defaultValue = this._model.uaSetting().get() === Emulation.DeviceModeModel.UA.Mobile || - this._model.uaSetting().get() === Emulation.DeviceModeModel.UA.MobileNoTouch ? - Emulation.DeviceModeModel.defaultMobileScaleFactor : + const defaultValue = + this._model.uaSetting().get() === UA.Mobile || this._model.uaSetting().get() === UA.MobileNoTouch ? + defaultMobileScaleFactor : window.devicePixelRatio; appendDeviceScaleFactorItem(contextMenu.headerSection(), Common.UIString('Default: %.1f', defaultValue), 0); appendDeviceScaleFactorItem(contextMenu.defaultSection(), Common.UIString('1'), 1); @@ -270,14 +272,14 @@ export default class DeviceModeToolbar { */ _appendUserAgentMenuItems(contextMenu) { const uaSetting = this._model.uaSetting(); - appendUAItem(Emulation.DeviceModeModel.UA.Mobile, Emulation.DeviceModeModel.UA.Mobile); - appendUAItem(Emulation.DeviceModeModel.UA.MobileNoTouch, Emulation.DeviceModeModel.UA.MobileNoTouch); - appendUAItem(Emulation.DeviceModeModel.UA.Desktop, Emulation.DeviceModeModel.UA.Desktop); - appendUAItem(Emulation.DeviceModeModel.UA.DesktopTouch, Emulation.DeviceModeModel.UA.DesktopTouch); + appendUAItem(UA.Mobile, UA.Mobile); + appendUAItem(UA.MobileNoTouch, UA.MobileNoTouch); + appendUAItem(UA.Desktop, UA.Desktop); + appendUAItem(UA.DesktopTouch, UA.DesktopTouch); /** * @param {string} title - * @param {!Emulation.DeviceModeModel.UA} value + * @param {!UA} value */ function appendUAItem(title, value) { contextMenu.defaultSection().appendCheckboxItem( @@ -292,7 +294,7 @@ export default class DeviceModeToolbar { const model = this._model; appendToggleItem( contextMenu.headerSection(), this._deviceOutlineSetting, Common.UIString('Hide device frame'), - Common.UIString('Show device frame'), model.type() !== Emulation.DeviceModeModel.Type.Device); + Common.UIString('Show device frame'), model.type() !== Type.Device); appendToggleItem( contextMenu.headerSection(), this._showMediaInspectorSetting, Common.UIString('Hide media queries'), Common.UIString('Show media queries')); @@ -319,7 +321,7 @@ export default class DeviceModeToolbar { */ function appendToggleItem(section, setting, title1, title2, disabled) { if (typeof disabled === 'undefined') { - disabled = model.type() === Emulation.DeviceModeModel.Type.None; + disabled = model.type() === Type.None; } section.appendItem(setting.get() ? title1 : title2, setting.set.bind(setting, !setting.get()), disabled); } @@ -346,46 +348,45 @@ export default class DeviceModeToolbar { } /** - * @param {!Emulation.EmulatedDevice} device + * @param {!EmulatedDevice} device */ _emulateDevice(device) { const scale = this._autoAdjustScaleSetting.get() ? undefined : this._model.scaleSetting().get(); - this._model.emulate( - Emulation.DeviceModeModel.Type.Device, device, this._lastMode.get(device) || device.modes[0], scale); + this._model.emulate(Type.Device, device, this._lastMode.get(device) || device.modes[0], scale); } _switchToResponsive() { - this._model.emulate(Emulation.DeviceModeModel.Type.Responsive, null, null); + this._model.emulate(Type.Responsive, null, null); } /** - * @param {!Array} devices + * @param {!Array} devices * @return {!Array} */ _filterDevices(devices) { devices = devices.filter(function(d) { return d.show(); }); - devices.sort(Emulation.EmulatedDevice.deviceComparator); + devices.sort(EmulatedDevice.deviceComparator); return devices; } /** - * @return {!Array} + * @return {!Array} */ _standardDevices() { return this._filterDevices(this._emulatedDevicesList.standard()); } /** - * @return {!Array} + * @return {!Array} */ _customDevices() { return this._filterDevices(this._emulatedDevicesList.custom()); } /** - * @return {!Array} + * @return {!Array} */ _allDevices() { return this._standardDevices().concat(this._customDevices()); @@ -396,8 +397,8 @@ export default class DeviceModeToolbar { */ _appendDeviceMenuItems(contextMenu) { contextMenu.headerSection().appendCheckboxItem( - Common.UIString('Responsive'), this._switchToResponsive.bind(this), - this._model.type() === Emulation.DeviceModeModel.Type.Responsive, false); + Common.UIString('Responsive'), this._switchToResponsive.bind(this), this._model.type() === Type.Responsive, + false); appendGroup.call(this, this._standardDevices()); appendGroup.call(this, this._customDevices()); contextMenu.footerSection().appendItem( @@ -405,8 +406,8 @@ export default class DeviceModeToolbar { false); /** - * @param {!Array} devices - * @this {Emulation.DeviceModeToolbar} + * @param {!Array} devices + * @this {DeviceModeToolbar} */ function appendGroup(devices) { if (!devices.length) { @@ -421,7 +422,7 @@ export default class DeviceModeToolbar { } /** - * @this {Emulation.DeviceModeToolbar} + * @this {DeviceModeToolbar} */ _deviceListChanged() { const device = this._model.device(); @@ -434,7 +435,7 @@ export default class DeviceModeToolbar { if (devices.length) { this._emulateDevice(devices[0]); } else { - this._model.emulate(Emulation.DeviceModeModel.Type.Responsive, null, null); + this._model.emulate(Type.Responsive, null, null); } } } @@ -455,7 +456,7 @@ export default class DeviceModeToolbar { const model = this._model; const autoAdjustScaleSetting = this._autoAdjustScaleSetting; - if (model.type() === Emulation.DeviceModeModel.Type.Responsive) { + if (model.type() === Type.Responsive) { const appliedSize = model.appliedDeviceSize(); if (autoAdjustScaleSetting.get()) { model.setSizeAndScaleToFit(appliedSize.height, appliedSize.width); @@ -476,8 +477,8 @@ export default class DeviceModeToolbar { const contextMenu = new UI.ContextMenu( /** @type {!Event} */ (event.data), false, this._modeButton.element.totalOffsetLeft(), this._modeButton.element.totalOffsetTop() + this._modeButton.element.offsetHeight); - addOrientation(Emulation.EmulatedDevice.Vertical, Common.UIString('Portrait')); - addOrientation(Emulation.EmulatedDevice.Horizontal, Common.UIString('Landscape')); + addOrientation(Vertical, Common.UIString('Portrait')); + addOrientation(Horizontal, Common.UIString('Landscape')); contextMenu.show(); /** @@ -525,11 +526,11 @@ export default class DeviceModeToolbar { update() { if (this._model.type() !== this._cachedModelType) { this._cachedModelType = this._model.type(); - this._widthInput.disabled = this._model.type() !== Emulation.DeviceModeModel.Type.Responsive; - this._heightInput.disabled = this._model.type() !== Emulation.DeviceModeModel.Type.Responsive; - this._deviceScaleItem.setEnabled(this._model.type() === Emulation.DeviceModeModel.Type.Responsive); - this._uaItem.setEnabled(this._model.type() === Emulation.DeviceModeModel.Type.Responsive); - if (this._model.type() === Emulation.DeviceModeModel.Type.Responsive) { + this._widthInput.disabled = this._model.type() !== Type.Responsive; + this._heightInput.disabled = this._model.type() !== Type.Responsive; + this._deviceScaleItem.setEnabled(this._model.type() === Type.Responsive); + this._uaItem.setEnabled(this._model.type() === Type.Responsive); + if (this._model.type() === Type.Responsive) { this._modeButton.setEnabled(true); this._modeButton.setTitle(ls`Rotate`); } else { @@ -539,9 +540,7 @@ export default class DeviceModeToolbar { const size = this._model.appliedDeviceSize(); this._updateHeightInput( - this._model.type() === Emulation.DeviceModeModel.Type.Responsive && this._model.isFullHeight() ? - '' : - String(size.height)); + this._model.type() === Type.Responsive && this._model.isFullHeight() ? '' : String(size.height)); this._updateWidthInput(String(size.width)); this._heightInput.placeholder = size.height; @@ -563,10 +562,10 @@ export default class DeviceModeToolbar { } let deviceItemTitle = Common.UIString('None'); - if (this._model.type() === Emulation.DeviceModeModel.Type.Responsive) { + if (this._model.type() === Type.Responsive) { deviceItemTitle = Common.UIString('Responsive'); } - if (this._model.type() === Emulation.DeviceModeModel.Type.Device) { + if (this._model.type() === Type.Device) { deviceItemTitle = this._model.device().title; } this._deviceSelectItem.setText(deviceItemTitle); @@ -581,13 +580,13 @@ export default class DeviceModeToolbar { this._cachedModelDevice = device; } - if (this._model.type() === Emulation.DeviceModeModel.Type.Device) { + if (this._model.type() === Type.Device) { this._lastMode.set( - /** @type {!Emulation.EmulatedDevice} */ (this._model.device()), + /** @type {!EmulatedDevice} */ (this._model.device()), /** @type {!Emulation.EmulatedDevice.Mode} */ (this._model.mode())); } - if (this._model.mode() !== this._cachedModelMode && this._model.type() !== Emulation.DeviceModeModel.Type.None) { + if (this._model.mode() !== this._cachedModelMode && this._model.type() !== Type.None) { this._cachedModelMode = this._model.mode(); const value = this._persistenceSetting.get(); if (this._model.device()) { @@ -617,17 +616,6 @@ export default class DeviceModeToolbar { } } - this._model.emulate(Emulation.DeviceModeModel.Type.Responsive, null, null); + this._model.emulate(Type.Responsive, null, null); } } - -/* Legacy exported object */ -self.Emulation = self.Emulation || {}; - -/* Legacy exported object */ -Emulation = Emulation || {}; - -/** - * @constructor - */ -Emulation.DeviceModeToolbar = DeviceModeToolbar; diff --git a/resources/unpacked/devtools/front_end/emulation/DeviceModeView.js b/resources/unpacked/devtools/front_end/emulation/DeviceModeView.js index d0cc86c575..572e0bcdac 100644 --- a/resources/unpacked/devtools/front_end/emulation/DeviceModeView.js +++ b/resources/unpacked/devtools/front_end/emulation/DeviceModeView.js @@ -1,37 +1,45 @@ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + +import {DeviceModeModel, Events, MaxDeviceSize, MinDeviceSize, Type} from './DeviceModeModel.js'; +import {DeviceModeToolbar} from './DeviceModeToolbar.js'; +import {MediaQueryInspector} from './MediaQueryInspector.js'; + /** * @unrestricted */ -export default class DeviceModeView extends UI.VBox { +export class DeviceModeView extends UI.VBox { constructor() { super(true); + + /** @type {?UI.VBox} */ + this.wrapperInstance; + this.setMinimumSize(150, 150); this.element.classList.add('device-mode-view'); this.registerRequiredCSS('emulation/deviceModeView.css'); UI.Tooltip.addNativeOverrideContainer(this.contentElement); - this._model = self.singleton(Emulation.DeviceModeModel); - this._model.addEventListener(Emulation.DeviceModeModel.Events.Updated, this._updateUI, this); - this._mediaInspector = new Emulation.MediaQueryInspector( - () => this._model.appliedDeviceSize().width, this._model.setWidth.bind(this._model)); + this._model = self.singleton(DeviceModeModel); + this._model.addEventListener(Events.Updated, this._updateUI, this); + this._mediaInspector = + new MediaQueryInspector(() => this._model.appliedDeviceSize().width, this._model.setWidth.bind(this._model)); this._showMediaInspectorSetting = Common.settings.moduleSetting('showMediaQueryInspector'); this._showMediaInspectorSetting.addChangeListener(this._updateUI, this); this._showRulersSetting = Common.settings.moduleSetting('emulation.showRulers'); this._showRulersSetting.addChangeListener(this._updateUI, this); - this._topRuler = new Emulation.DeviceModeView.Ruler(true, this._model.setWidthAndScaleToFit.bind(this._model)); + this._topRuler = new Ruler(true, this._model.setWidthAndScaleToFit.bind(this._model)); this._topRuler.element.classList.add('device-mode-ruler-top'); - this._leftRuler = new Emulation.DeviceModeView.Ruler(false, this._model.setHeightAndScaleToFit.bind(this._model)); + this._leftRuler = new Ruler(false, this._model.setHeightAndScaleToFit.bind(this._model)); this._leftRuler.element.classList.add('device-mode-ruler-left'); this._createUI(); UI.zoomManager.addEventListener(UI.ZoomManager.Events.ZoomChanged, this._zoomChanged, this); } _createUI() { - this._toolbar = - new Emulation.DeviceModeToolbar(this._model, this._showMediaInspectorSetting, this._showRulersSetting); + this._toolbar = new DeviceModeToolbar(this._model, this._showMediaInspectorSetting, this._showRulersSetting); this.contentElement.appendChild(this._toolbar.element()); this._contentClip = this.contentElement.createChild('div', 'device-mode-content-clip vbox'); @@ -97,10 +105,10 @@ export default class DeviceModeView extends UI.VBox { /** * @param {number} width * @param {!Event} e - * @this {Emulation.DeviceModeView} + * @this {DeviceModeView} */ function applySize(width, e) { - this._model.emulate(Emulation.DeviceModeModel.Type.Responsive, null, null); + this._model.emulate(Type.Responsive, null, null); this._model.setWidthAndScaleToFit(width); e.consume(); } @@ -162,7 +170,7 @@ export default class DeviceModeView extends UI.VBox { const dipOffsetX = cssOffsetX * UI.zoomManager.zoomFactor(); let newWidth = this._resizeStart.width + dipOffsetX * widthFactor; newWidth = Math.round(newWidth / this._model.scale()); - if (newWidth >= Emulation.DeviceModeModel.MinDeviceSize && newWidth <= Emulation.DeviceModeModel.MaxDeviceSize) { + if (newWidth >= MinDeviceSize && newWidth <= MaxDeviceSize) { this._model.setWidth(newWidth); } } @@ -171,8 +179,7 @@ export default class DeviceModeView extends UI.VBox { const dipOffsetY = cssOffsetY * UI.zoomManager.zoomFactor(); let newHeight = this._resizeStart.height + dipOffsetY * heightFactor; newHeight = Math.round(newHeight / this._model.scale()); - if (newHeight >= Emulation.DeviceModeModel.MinDeviceSize && - newHeight <= Emulation.DeviceModeModel.MaxDeviceSize) { + if (newHeight >= MinDeviceSize && newHeight <= MaxDeviceSize) { this._model.setHeight(newHeight); } } @@ -204,7 +211,7 @@ export default class DeviceModeView extends UI.VBox { const zoomFactor = UI.zoomManager.zoomFactor(); let callDoResize = false; - const showRulers = this._showRulersSetting.get() && this._model.type() !== Emulation.DeviceModeModel.Type.None; + const showRulers = this._showRulersSetting.get() && this._model.type() !== Type.None; let contentAreaResized = false; let updateRulers = false; @@ -231,7 +238,7 @@ export default class DeviceModeView extends UI.VBox { } this._contentClip.classList.toggle('device-mode-outline-visible', !!this._model.outlineImage()); - const resizable = this._model.type() === Emulation.DeviceModeModel.Type.Responsive; + const resizable = this._model.type() === Type.Responsive; if (resizable !== this._cachedResizable) { this._rightResizerElement.classList.toggle('hidden', !resizable); this._leftResizerElement.classList.toggle('hidden', !resizable); @@ -241,8 +248,7 @@ export default class DeviceModeView extends UI.VBox { this._cachedResizable = resizable; } - const mediaInspectorVisible = - this._showMediaInspectorSetting.get() && this._model.type() !== Emulation.DeviceModeModel.Type.None; + const mediaInspectorVisible = this._showMediaInspectorSetting.get() && this._model.type() !== Type.None; if (mediaInspectorVisible !== this._cachedMediaInspectorVisible) { if (mediaInspectorVisible) { this._mediaInspector.show(this._mediaInspectorContainer); @@ -325,7 +331,7 @@ export default class DeviceModeView extends UI.VBox { * @param {!Element} element */ setNonEmulatedAvailableSize(element) { - if (this._model.type() !== Emulation.DeviceModeModel.Type.None) { + if (this._model.type() !== Type.None) { return; } const zoomFactor = UI.zoomManager.zoomFactor(); @@ -384,7 +390,7 @@ export default class DeviceModeView extends UI.VBox { * @override */ willHide() { - this._model.emulate(Emulation.DeviceModeModel.Type.None, null, null); + this._model.emulate(Type.None, null, null); } /** @@ -488,7 +494,7 @@ export default class DeviceModeView extends UI.VBox { _saveScreenshot(canvas) { const url = this._model.inspectedURL(); let fileName = url ? url.trimURL().removeURLFragment() : ''; - if (this._model.type() === Emulation.DeviceModeModel.Type.Device) { + if (this._model.type() === Type.Device) { fileName += Common.UIString('(%s)', this._model.device().title); } const link = createElement('a'); @@ -609,19 +615,3 @@ export class Ruler extends UI.VBox { this._applyCallback.call(null, size); } } - -/* Legacy exported object */ -self.Emulation = self.Emulation || {}; - -/* Legacy exported object */ -Emulation = Emulation || {}; - -/** - * @constructor - */ -Emulation.DeviceModeView = DeviceModeView; - -/** - * @constructor - */ -Emulation.DeviceModeView.Ruler = Ruler; diff --git a/resources/unpacked/devtools/front_end/emulation/DeviceModeWrapper.js b/resources/unpacked/devtools/front_end/emulation/DeviceModeWrapper.js index 360145e25b..b72e53d612 100644 --- a/resources/unpacked/devtools/front_end/emulation/DeviceModeWrapper.js +++ b/resources/unpacked/devtools/front_end/emulation/DeviceModeWrapper.js @@ -1,21 +1,26 @@ // Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + +import {DeviceModeModel} from './DeviceModeModel.js'; +import {DeviceModeView} from './DeviceModeView.js'; +import {InspectedPagePlaceholder} from './InspectedPagePlaceholder.js'; // eslint-disable-line no-unused-vars + /** * @unrestricted */ -export default class DeviceModeWrapper extends UI.VBox { +export class DeviceModeWrapper extends UI.VBox { /** - * @param {!Emulation.InspectedPagePlaceholder} inspectedPagePlaceholder + * @param {!InspectedPagePlaceholder} inspectedPagePlaceholder */ constructor(inspectedPagePlaceholder) { super(); - Emulation.DeviceModeView._wrapperInstance = this; + DeviceModeView.wrapperInstance = this; this._inspectedPagePlaceholder = inspectedPagePlaceholder; - /** @type {?Emulation.DeviceModeView} */ + /** @type {?DeviceModeView} */ this._deviceModeView = null; this._toggleDeviceModeAction = UI.actionRegistry.action('emulation.toggle-device-mode'); - const model = self.singleton(Emulation.DeviceModeModel); + const model = self.singleton(DeviceModeModel); this._showDeviceModeSetting = model.enabledSetting(); this._showDeviceModeSetting.setRequiresUserAction(!!Root.Runtime.queryParam('hasOtherClients')); this._showDeviceModeSetting.addChangeListener(this._update.bind(this, false)); @@ -35,7 +40,7 @@ export default class DeviceModeWrapper extends UI.VBox { */ _captureScreenshot(fullSize, clip) { if (!this._deviceModeView) { - this._deviceModeView = new Emulation.DeviceModeView(); + this._deviceModeView = new DeviceModeView(); } this._deviceModeView.setNonEmulatedAvailableSize(this._inspectedPagePlaceholder.element); if (fullSize) { @@ -70,7 +75,7 @@ export default class DeviceModeWrapper extends UI.VBox { if (this._showDeviceModeSetting.get()) { if (!this._deviceModeView) { - this._deviceModeView = new Emulation.DeviceModeView(); + this._deviceModeView = new DeviceModeView(); } this._deviceModeView.show(this.element); this._inspectedPagePlaceholder.clearMinimumSize(); @@ -85,9 +90,6 @@ export default class DeviceModeWrapper extends UI.VBox { } } -/** @type {!Emulation.DeviceModeWrapper} */ -Emulation.DeviceModeView._wrapperInstance; - /** * @implements {UI.ActionDelegate} * @unrestricted @@ -100,10 +102,10 @@ export class ActionDelegate { * @return {boolean} */ handleAction(context, actionId) { - if (Emulation.DeviceModeView._wrapperInstance) { + if (DeviceModeView.wrapperInstance) { switch (actionId) { case 'emulation.capture-screenshot': - return Emulation.DeviceModeView._wrapperInstance._captureScreenshot(); + return DeviceModeView.wrapperInstance._captureScreenshot(); case 'emulation.capture-node-screenshot': { const node = UI.context.flavor(SDK.DOMNode); @@ -131,36 +133,20 @@ export class ActionDelegate { clip.y *= page_zoom; clip.width *= page_zoom; clip.height *= page_zoom; - Emulation.DeviceModeView._wrapperInstance._captureScreenshot(false, clip); + DeviceModeView.wrapperInstance._captureScreenshot(false, clip); } captureClip(); return true; } case 'emulation.capture-full-height-screenshot': - return Emulation.DeviceModeView._wrapperInstance._captureScreenshot(true); + return DeviceModeView.wrapperInstance._captureScreenshot(true); case 'emulation.toggle-device-mode': - Emulation.DeviceModeView._wrapperInstance._toggleDeviceMode(); + DeviceModeView.wrapperInstance._toggleDeviceMode(); return true; } } return false; } } - -/* Legacy exported object */ -self.Emulation = self.Emulation || {}; - -/* Legacy exported object */ -Emulation = Emulation || {}; - -/** - * @constructor - */ -Emulation.DeviceModeWrapper = DeviceModeWrapper; - -/** - * @constructor - */ -Emulation.DeviceModeWrapper.ActionDelegate = ActionDelegate; diff --git a/resources/unpacked/devtools/front_end/emulation/DevicesSettingsTab.js b/resources/unpacked/devtools/front_end/emulation/DevicesSettingsTab.js index d5e2a94657..3eb494b930 100644 --- a/resources/unpacked/devtools/front_end/emulation/DevicesSettingsTab.js +++ b/resources/unpacked/devtools/front_end/emulation/DevicesSettingsTab.js @@ -1,11 +1,15 @@ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + +import {DeviceModeModel, MaxDeviceNameLength, UA} from './DeviceModeModel.js'; +import {Capability, EmulatedDevice, EmulatedDevicesList, Events, Horizontal, Vertical,} from './EmulatedDevices.js'; + /** * @implements {UI.ListWidget.Delegate} * @unrestricted */ -export default class DevicesSettingsTab extends UI.VBox { +export class DevicesSettingsTab extends UI.VBox { constructor() { super(); this.element.classList.add('settings-tab-container'); @@ -28,11 +32,9 @@ export default class DevicesSettingsTab extends UI.VBox { this._list.show(this.containerElement); this._muteUpdate = false; - this._emulatedDevicesList = Emulation.EmulatedDevicesList.instance(); - this._emulatedDevicesList.addEventListener( - Emulation.EmulatedDevicesList.Events.CustomDevicesUpdated, this._devicesUpdated, this); - this._emulatedDevicesList.addEventListener( - Emulation.EmulatedDevicesList.Events.StandardDevicesUpdated, this._devicesUpdated, this); + this._emulatedDevicesList = EmulatedDevicesList.instance(); + this._emulatedDevicesList.addEventListener(Events.CustomDevicesUpdated, this._devicesUpdated, this); + this._emulatedDevicesList.addEventListener(Events.StandardDevicesUpdated, this._devicesUpdated, this); this.setDefaultFocusedElement(this._addCustomButton); } @@ -60,7 +62,7 @@ export default class DevicesSettingsTab extends UI.VBox { this._list.appendSeparator(); devices = this._emulatedDevicesList.standard().slice(); - devices.sort(Emulation.EmulatedDevice.deviceComparator); + devices.sort(EmulatedDevice.deviceComparator); for (let i = 0; i < devices.length; ++i) { this._list.appendItem(devices[i], false); } @@ -80,7 +82,7 @@ export default class DevicesSettingsTab extends UI.VBox { } _addCustomDevice() { - const device = new Emulation.EmulatedDevice(); + const device = new EmulatedDevice(); device.deviceScaleFactor = 0; device.horizontal.width = 700; device.horizontal.height = 400; @@ -104,7 +106,7 @@ export default class DevicesSettingsTab extends UI.VBox { * @return {!Element} */ renderItem(item, editable) { - const device = /** @type {!Emulation.EmulatedDevice} */ (item); + const device = /** @type {!EmulatedDevice} */ (item); const element = createElementWithClass('div', 'devices-list-item'); const checkbox = element.createChild('input', 'devices-list-checkbox'); checkbox.type = 'checkbox'; @@ -116,7 +118,7 @@ export default class DevicesSettingsTab extends UI.VBox { /** * @param {!Event} event - * @this {Emulation.DevicesSettingsTab} + * @this {DevicesSettingsTab} */ function onItemClicked(event) { const show = !checkbox.checked; @@ -133,7 +135,7 @@ export default class DevicesSettingsTab extends UI.VBox { * @param {number} index */ removeItemRequested(item, index) { - this._emulatedDevicesList.removeCustomDevice(/** @type {!Emulation.EmulatedDevice} */ (item)); + this._emulatedDevicesList.removeCustomDevice(/** @type {!EmulatedDevice} */ (item)); } /** @@ -143,7 +145,7 @@ export default class DevicesSettingsTab extends UI.VBox { * @param {boolean} isNew */ commitEdit(item, editor, isNew) { - const device = /** @type {!Emulation.EmulatedDevice} */ (item); + const device = /** @type {!EmulatedDevice} */ (item); device.title = editor.control('title').value.trim(); device.vertical.width = editor.control('width').value ? parseInt(editor.control('width').value, 10) : 0; device.vertical.height = editor.control('height').value ? parseInt(editor.control('height').value, 10) : 0; @@ -152,17 +154,15 @@ export default class DevicesSettingsTab extends UI.VBox { device.deviceScaleFactor = editor.control('scale').value ? parseFloat(editor.control('scale').value) : 0; device.userAgent = editor.control('user-agent').value; device.modes = []; - device.modes.push( - {title: '', orientation: Emulation.EmulatedDevice.Vertical, insets: new UI.Insets(0, 0, 0, 0), image: null}); - device.modes.push( - {title: '', orientation: Emulation.EmulatedDevice.Horizontal, insets: new UI.Insets(0, 0, 0, 0), image: null}); + device.modes.push({title: '', orientation: Vertical, insets: new UI.Insets(0, 0, 0, 0), image: null}); + device.modes.push({title: '', orientation: Horizontal, insets: new UI.Insets(0, 0, 0, 0), image: null}); device.capabilities = []; const uaType = editor.control('ua-type').value; - if (uaType === Emulation.DeviceModeModel.UA.Mobile || uaType === Emulation.DeviceModeModel.UA.MobileNoTouch) { - device.capabilities.push(Emulation.EmulatedDevice.Capability.Mobile); + if (uaType === UA.Mobile || uaType === UA.MobileNoTouch) { + device.capabilities.push(Capability.Mobile); } - if (uaType === Emulation.DeviceModeModel.UA.Mobile || uaType === Emulation.DeviceModeModel.UA.DesktopTouch) { - device.capabilities.push(Emulation.EmulatedDevice.Capability.Touch); + if (uaType === UA.Mobile || uaType === UA.DesktopTouch) { + device.capabilities.push(Capability.Touch); } if (isNew) { this._emulatedDevicesList.addCustomDevice(device); @@ -179,7 +179,7 @@ export default class DevicesSettingsTab extends UI.VBox { * @return {!UI.ListWidget.Editor} */ beginEdit(item) { - const device = /** @type {!Emulation.EmulatedDevice} */ (item); + const device = /** @type {!EmulatedDevice} */ (item); const editor = this._createEditor(); editor.control('title').value = device.title; editor.control('width').value = this._toNumericInputValue(device.vertical.width); @@ -188,9 +188,9 @@ export default class DevicesSettingsTab extends UI.VBox { editor.control('user-agent').value = device.userAgent; let uaType; if (device.mobile()) { - uaType = device.touch() ? Emulation.DeviceModeModel.UA.Mobile : Emulation.DeviceModeModel.UA.MobileNoTouch; + uaType = device.touch() ? UA.Mobile : UA.MobileNoTouch; } else { - uaType = device.touch() ? Emulation.DeviceModeModel.UA.DesktopTouch : Emulation.DeviceModeModel.UA.Desktop; + uaType = device.touch() ? UA.DesktopTouch : UA.Desktop; } editor.control('ua-type').value = uaType; return editor; @@ -220,10 +220,7 @@ export default class DevicesSettingsTab extends UI.VBox { ua.appendChild(editor.createInput('user-agent', 'text', ls`User agent string`, () => { return {valid: true}; })); - const uaTypeOptions = [ - Emulation.DeviceModeModel.UA.Mobile, Emulation.DeviceModeModel.UA.MobileNoTouch, - Emulation.DeviceModeModel.UA.Desktop, Emulation.DeviceModeModel.UA.DesktopTouch - ]; + const uaTypeOptions = [UA.Mobile, UA.MobileNoTouch, UA.Desktop, UA.DesktopTouch]; const uaType = editor.createSelect('ua-type', uaTypeOptions, () => { return {valid: true}; }, ls`User agent type`); @@ -243,8 +240,8 @@ export default class DevicesSettingsTab extends UI.VBox { let errorMessage; const value = input.value.trim(); - if (value.length >= Emulation.DeviceModeModel.MaxDeviceNameLength) { - errorMessage = ls`Device name must be less than ${Emulation.DeviceModeModel.MaxDeviceNameLength} characters.`; + if (value.length >= MaxDeviceNameLength) { + errorMessage = ls`Device name must be less than ${MaxDeviceNameLength} characters.`; } else if (value.length === 0) { errorMessage = ls`Device name cannot be empty.`; } else { @@ -261,7 +258,7 @@ export default class DevicesSettingsTab extends UI.VBox { * @return {!UI.ListWidget.ValidatorResult} */ function widthValidator(item, index, input) { - return Emulation.DeviceModeModel.widthValidator(input.value); + return DeviceModeModel.widthValidator(input.value); } /** @@ -271,7 +268,7 @@ export default class DevicesSettingsTab extends UI.VBox { * @return {!UI.ListWidget.ValidatorResult} */ function heightValidator(item, index, input) { - return Emulation.DeviceModeModel.heightValidator(input.value); + return DeviceModeModel.heightValidator(input.value); } /** @@ -281,18 +278,7 @@ export default class DevicesSettingsTab extends UI.VBox { * @return {!UI.ListWidget.ValidatorResult} */ function scaleValidator(item, index, input) { - return Emulation.DeviceModeModel.scaleValidator(input.value); + return DeviceModeModel.scaleValidator(input.value); } } } - -/* Legacy exported object */ -self.Emulation = self.Emulation || {}; - -/* Legacy exported object */ -Emulation = Emulation || {}; - -/** - * @constructor - */ -Emulation.DevicesSettingsTab = DevicesSettingsTab; diff --git a/resources/unpacked/devtools/front_end/emulation/EmulatedDevices.js b/resources/unpacked/devtools/front_end/emulation/EmulatedDevices.js index 291882320c..1b77f923f9 100644 --- a/resources/unpacked/devtools/front_end/emulation/EmulatedDevices.js +++ b/resources/unpacked/devtools/front_end/emulation/EmulatedDevices.js @@ -1,6 +1,9 @@ // Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + +import {MaxDeviceSize, MinDeviceSize} from './DeviceModeModel.js'; + /** * @unrestricted */ @@ -90,14 +93,12 @@ export class EmulatedDevice { const result = {}; result.width = parseIntValue(json, 'width'); - if (result.width < 0 || result.width > Emulation.DeviceModeModel.MaxDeviceSize || - result.width < Emulation.DeviceModeModel.MinDeviceSize) { + if (result.width < 0 || result.width > MaxDeviceSize || result.width < MinDeviceSize) { throw new Error('Emulated device has wrong width: ' + result.width); } result.height = parseIntValue(json, 'height'); - if (result.height < 0 || result.height > Emulation.DeviceModeModel.MaxDeviceSize || - result.height < Emulation.DeviceModeModel.MinDeviceSize) { + if (result.height < 0 || result.height > MaxDeviceSize || result.height < MinDeviceSize) { throw new Error('Emulated device has wrong height: ' + result.height); } @@ -372,6 +373,9 @@ export const _Show = { Never: 'Never' }; +/** @type {!EmulatedDevicesList} */ +let _instance; + /** * @unrestricted */ @@ -399,10 +403,10 @@ export class EmulatedDevicesList extends Common.Object { * @return {!EmulatedDevicesList} */ static instance() { - if (!this._instance) { - this._instance = new EmulatedDevicesList(); + if (!_instance) { + _instance = new EmulatedDevicesList(); } - return /** @type {!EmulatedDevicesList} */ (this._instance); + return _instance; } _updateStandardDevices() { @@ -517,37 +521,3 @@ export const Events = { CustomDevicesUpdated: Symbol('CustomDevicesUpdated'), StandardDevicesUpdated: Symbol('StandardDevicesUpdated') }; - -/* Legacy exported object */ -self.Emulation = self.Emulation || {}; - -/* Legacy exported object */ -Emulation = Emulation || {}; - -/** - * @constructor - */ -Emulation.EmulatedDevice = EmulatedDevice; - -/** @typedef {!{title: string, orientation: string, insets: !UI.Insets, image: ?string}} */ -Emulation.EmulatedDevice.Mode; - -/** @typedef {!{width: number, height: number, outlineInsets: ?UI.Insets, outlineImage: ?string}} */ -Emulation.EmulatedDevice.Orientation; - -Emulation.EmulatedDevice.Horizontal = Horizontal; -Emulation.EmulatedDevice.Vertical = Vertical; -Emulation.EmulatedDevice.Type = Type; -Emulation.EmulatedDevice.Capability = Capability; -Emulation.EmulatedDevice._Show = _Show; - -/** - * @constructor - */ -Emulation.EmulatedDevicesList = EmulatedDevicesList; - -/** @type {?EmulatedDevicesList} */ -Emulation.EmulatedDevicesList._instance; - -/** @enum {symbol} */ -Emulation.EmulatedDevicesList.Events = Events; diff --git a/resources/unpacked/devtools/front_end/emulation/GeolocationsSettingsTab.js b/resources/unpacked/devtools/front_end/emulation/GeolocationsSettingsTab.js index 6398abcd1d..7eda4f9bb1 100644 --- a/resources/unpacked/devtools/front_end/emulation/GeolocationsSettingsTab.js +++ b/resources/unpacked/devtools/front_end/emulation/GeolocationsSettingsTab.js @@ -6,7 +6,7 @@ * @implements {UI.ListWidget.Delegate} * @unrestricted */ -export default class GeolocationsSettingsTab extends UI.VBox { +export class GeolocationsSettingsTab extends UI.VBox { constructor() { super(true); this.registerRequiredCSS('emulation/geolocationsSettingsTab.css'); @@ -268,17 +268,3 @@ export default class GeolocationsSettingsTab extends UI.VBox { } } } - -/* Legacy exported object */ -self.Emulation = self.Emulation || {}; - -/* Legacy exported object */ -Emulation = Emulation || {}; - -/** - * @constructor - */ -Emulation.GeolocationsSettingsTab = GeolocationsSettingsTab; - -/** @typedef {{title: string, lat: number, long: number}} */ -Emulation.GeolocationsSettingsTab.Item; diff --git a/resources/unpacked/devtools/front_end/emulation/InspectedPagePlaceholder.js b/resources/unpacked/devtools/front_end/emulation/InspectedPagePlaceholder.js index 9f44777e64..c81df022cb 100644 --- a/resources/unpacked/devtools/front_end/emulation/InspectedPagePlaceholder.js +++ b/resources/unpacked/devtools/front_end/emulation/InspectedPagePlaceholder.js @@ -5,7 +5,7 @@ /** * @unrestricted */ -export default class InspectedPagePlaceholder extends UI.Widget { +export class InspectedPagePlaceholder extends UI.Widget { constructor() { super(true); this.registerRequiredCSS('emulation/inspectedPagePlaceholder.css'); @@ -77,22 +77,3 @@ export const instance = function() { export const Events = { Update: Symbol('Update') }; - -/* Legacy exported object */ -self.Emulation = self.Emulation || {}; - -/* Legacy exported object */ -Emulation = Emulation || {}; - -/** - * @constructor - */ -Emulation.InspectedPagePlaceholder = InspectedPagePlaceholder; - -/** - * @return {!InspectedPagePlaceholder} - */ -Emulation.InspectedPagePlaceholder.instance = instance; - -/** @enum {symbol} */ -Emulation.InspectedPagePlaceholder.Events = Events; diff --git a/resources/unpacked/devtools/front_end/emulation/MediaQueryInspector.js b/resources/unpacked/devtools/front_end/emulation/MediaQueryInspector.js index 87ab0c561d..7edb1f1acf 100644 --- a/resources/unpacked/devtools/front_end/emulation/MediaQueryInspector.js +++ b/resources/unpacked/devtools/front_end/emulation/MediaQueryInspector.js @@ -1,11 +1,12 @@ // Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + /** * @implements {SDK.SDKModelObserver} * @unrestricted */ -export default class MediaQueryInspector extends UI.Widget { +export class MediaQueryInspector extends UI.Widget { /** * @param {function():number} getWidthCallback * @param {function(number)} setWidthCallback @@ -489,24 +490,3 @@ export class MediaQueryUIModel { return this._active; } } - -/* Legacy exported object */ -self.Emulation = self.Emulation || {}; - -/* Legacy exported object */ -Emulation = Emulation || {}; - -/** - * @constructor - */ -Emulation.MediaQueryInspector = MediaQueryInspector; - -/** - * @enum {number} - */ -Emulation.MediaQueryInspector.Section = Section; - -/** - * @constructor - */ -Emulation.MediaQueryInspector.MediaQueryUIModel = MediaQueryUIModel; diff --git a/resources/unpacked/devtools/front_end/emulation/SensorsView.js b/resources/unpacked/devtools/front_end/emulation/SensorsView.js index b913502d7d..2143e7457b 100644 --- a/resources/unpacked/devtools/front_end/emulation/SensorsView.js +++ b/resources/unpacked/devtools/front_end/emulation/SensorsView.js @@ -1,10 +1,11 @@ // Copyright (c) 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + /** * @unrestricted */ -export default class SensorsView extends UI.VBox { +export class SensorsView extends UI.VBox { constructor() { super(true); this.registerRequiredCSS('emulation/sensors.css'); @@ -561,29 +562,3 @@ export class ShowActionDelegate { } export const ShiftDragOrientationSpeed = 16; - -/* Legacy exported object */ -self.Emulation = self.Emulation || {}; - -/* Legacy exported object */ -Emulation = Emulation || {}; - -/** - * @constructor - */ -Emulation.SensorsView = SensorsView; - -/** @enum {string} */ -Emulation.SensorsView.DeviceOrientationModificationSource = DeviceOrientationModificationSource; - -/** {string} */ -Emulation.SensorsView.NonPresetOptions = NonPresetOptions; - -/** @type {!Array.<{title: string, value: !Array.<{title: string, orientation: string}>}>} */ -Emulation.SensorsView.PresetOrientations = PresetOrientations; - -/** - * @constructor - */ -Emulation.SensorsView.ShowActionDelegate = ShowActionDelegate; -Emulation.SensorsView.ShiftDragOrientationSpeed = ShiftDragOrientationSpeed; diff --git a/resources/unpacked/devtools/front_end/emulation/emulation-legacy.js b/resources/unpacked/devtools/front_end/emulation/emulation-legacy.js new file mode 100644 index 0000000000..0f7321a8ef --- /dev/null +++ b/resources/unpacked/devtools/front_end/emulation/emulation-legacy.js @@ -0,0 +1,147 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import * as EmulationModule from './emulation.js'; + +self.Emulation = self.Emulation || {}; +Emulation = Emulation || {}; + +/** + * @constructor + */ +Emulation.AdvancedApp = EmulationModule.AdvancedApp.AdvancedApp; + +/** + * @constructor + */ +Emulation.AdvancedAppProvider = EmulationModule.AdvancedApp.AdvancedAppProvider; + +/** + * @constructor + */ +Emulation.DeviceModeModel = EmulationModule.DeviceModeModel.DeviceModeModel; + +/** @enum {string} */ +Emulation.DeviceModeModel.Events = EmulationModule.DeviceModeModel.Events; + +/** @enum {string} */ +Emulation.DeviceModeModel.Type = EmulationModule.DeviceModeModel.Type; + +/** @enum {string} */ +Emulation.DeviceModeModel.UA = EmulationModule.DeviceModeModel.UA; + +Emulation.DeviceModeModel.MinDeviceSize = EmulationModule.DeviceModeModel.MinDeviceSize; +Emulation.DeviceModeModel.MaxDeviceSize = EmulationModule.DeviceModeModel.MaxDeviceSize; +Emulation.DeviceModeModel.MinDeviceScaleFactor = EmulationModule.DeviceModeModel.MinDeviceScaleFactor; +Emulation.DeviceModeModel.MaxDeviceScaleFactor = EmulationModule.DeviceModeModel.MaxDeviceScaleFactor; +Emulation.DeviceModeModel.MaxDeviceNameLength = EmulationModule.DeviceModeModel.MaxDeviceNameLength; +Emulation.DeviceModeModel.defaultMobileScaleFactor = EmulationModule.DeviceModeModel.defaultMobileScaleFactor; + +/** + * @constructor + */ +Emulation.DeviceModeToolbar = EmulationModule.DeviceModeToolbar.DeviceModeToolbar; + +/** + * @constructor + */ +Emulation.DeviceModeView = EmulationModule.DeviceModeView.DeviceModeView; + +/** + * @constructor + */ +Emulation.DeviceModeView.Ruler = EmulationModule.DeviceModeView.Ruler; + +/** + * @constructor + */ +Emulation.DeviceModeWrapper = EmulationModule.DeviceModeWrapper.DeviceModeWrapper; + +/** + * @constructor + */ +Emulation.DeviceModeWrapper.ActionDelegate = EmulationModule.DeviceModeWrapper.ActionDelegate; + +/** + * @constructor + */ +Emulation.DevicesSettingsTab = EmulationModule.DevicesSettingsTab.DevicesSettingsTab; + +/** + * @constructor + */ +Emulation.EmulatedDevice = EmulationModule.EmulatedDevices.EmulatedDevice; + +Emulation.EmulatedDevice.Horizontal = EmulationModule.EmulatedDevices.Horizontal; +Emulation.EmulatedDevice.Vertical = EmulationModule.EmulatedDevices.Vertical; +Emulation.EmulatedDevice.Type = EmulationModule.EmulatedDevices.Type; +Emulation.EmulatedDevice.Capability = EmulationModule.EmulatedDevices.Capability; + +/** + * @constructor + */ +Emulation.EmulatedDevicesList = EmulationModule.EmulatedDevices.EmulatedDevicesList; + +/** @enum {symbol} */ +Emulation.EmulatedDevicesList.Events = EmulationModule.EmulatedDevices.Events; + +/** + * @constructor + */ +Emulation.GeolocationsSettingsTab = EmulationModule.GeolocationsSettingsTab.GeolocationsSettingsTab; + +/** + * @constructor + */ +Emulation.InspectedPagePlaceholder = EmulationModule.InspectedPagePlaceholder.InspectedPagePlaceholder; + +Emulation.InspectedPagePlaceholder.instance = EmulationModule.InspectedPagePlaceholder.instance; + +/** @enum {symbol} */ +Emulation.InspectedPagePlaceholder.Events = EmulationModule.InspectedPagePlaceholder.Events; + +/** + * @constructor + */ +Emulation.MediaQueryInspector = EmulationModule.MediaQueryInspector.MediaQueryInspector; + +/** + * @enum {number} + */ +Emulation.MediaQueryInspector.Section = EmulationModule.MediaQueryInspector.Section; + +/** + * @constructor + */ +Emulation.MediaQueryInspector.MediaQueryUIModel = EmulationModule.MediaQueryInspector.MediaQueryUIModel; + +/** + * @constructor + */ +Emulation.SensorsView = EmulationModule.SensorsView.SensorsView; + +/** @enum {string} */ +Emulation.SensorsView.DeviceOrientationModificationSource = + EmulationModule.SensorsView.DeviceOrientationModificationSource; + +/** {string} */ +Emulation.SensorsView.NonPresetOptions = EmulationModule.SensorsView.NonPresetOptions; + +/** @type {!Array.<{title: string, value: !Array.<{title: string, orientation: string}>}>} */ +Emulation.SensorsView.PresetOrientations = EmulationModule.SensorsView.PresetOrientations; + +/** + * @constructor + */ +Emulation.SensorsView.ShowActionDelegate = EmulationModule.SensorsView.ShowActionDelegate; +Emulation.SensorsView.ShiftDragOrientationSpeed = EmulationModule.SensorsView.ShiftDragOrientationSpeed; + +/** @typedef {!{title: string, orientation: string, insets: !UI.Insets, image: ?string}} */ +Emulation.EmulatedDevice.Mode; + +/** @typedef {!{width: number, height: number, outlineInsets: ?UI.Insets, outlineImage: ?string}} */ +Emulation.EmulatedDevice.Orientation; + +/** @typedef {{title: string, lat: number, long: number}} */ +Emulation.GeolocationsSettingsTab.Item; diff --git a/resources/unpacked/devtools/front_end/emulation/module.json b/resources/unpacked/devtools/front_end/emulation/module.json index 22310ca297..1e72287395 100644 --- a/resources/unpacked/devtools/front_end/emulation/module.json +++ b/resources/unpacked/devtools/front_end/emulation/module.json @@ -186,6 +186,7 @@ "scripts": [], "modules": [ "emulation.js", + "emulation-legacy.js", "AdvancedApp.js", "EmulatedDevices.js", "DevicesSettingsTab.js", diff --git a/resources/unpacked/devtools/front_end/formatter/FormatterWorkerPool.js b/resources/unpacked/devtools/front_end/formatter/FormatterWorkerPool.js index 3ab730e13d..0dc7e0f4ec 100644 --- a/resources/unpacked/devtools/front_end/formatter/FormatterWorkerPool.js +++ b/resources/unpacked/devtools/front_end/formatter/FormatterWorkerPool.js @@ -366,38 +366,3 @@ export function formatterWorkerPool() { } return Formatter._formatterWorkerPool; } - -/* Legacy exported object */ -self.Formatter = self.Formatter || {}; - -/* Legacy exported object */ -Formatter = Formatter || {}; - -/** @constructor */ -Formatter.FormatterWorkerPool = FormatterWorkerPool; - -Formatter.formatterWorkerPool = formatterWorkerPool; - -/** @constructor */ -Formatter.FormatterWorkerPool.FormatResult = FormatResult; - -/** @typedef {{original: !Array, formatted: !Array}} */ -Formatter.FormatterWorkerPool.FormatMapping; - -/** @typedef {{line: number, column: number, title: string, subtitle: (string|undefined) }} */ -Formatter.FormatterWorkerPool.OutlineItem; - -/** - * @typedef {{atRule: string, lineNumber: number, columnNumber: number}} - */ -Formatter.FormatterWorkerPool.CSSAtRule; - -/** - * @typedef {(CSSStyleRule|Formatter.FormatterWorkerPool.CSSAtRule)} - */ -Formatter.FormatterWorkerPool.CSSRule; - -/** - * @typedef {{startLine: number, startColumn: number, endLine: number, endColumn: number}} - */ -Formatter.FormatterWorkerPool.TextRange; diff --git a/resources/unpacked/devtools/front_end/formatter/ScriptFormatter.js b/resources/unpacked/devtools/front_end/formatter/ScriptFormatter.js index c99522ee8e..89dd103e39 100644 --- a/resources/unpacked/devtools/front_end/formatter/ScriptFormatter.js +++ b/resources/unpacked/devtools/front_end/formatter/ScriptFormatter.js @@ -27,6 +27,9 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +import {FormatResult, formatterWorkerPool} from './FormatterWorkerPool.js'; // eslint-disable-line no-unused-vars + /** * @interface */ @@ -87,13 +90,13 @@ export class ScriptFormatter { this._callback = callback; this._originalContent = content; - Formatter.formatterWorkerPool() + formatterWorkerPool() .format(mimeType, content, Common.moduleSetting('textEditorIndent').get()) .then(this._didFormatContent.bind(this)); } /** - * @param {!Formatter.FormatterWorkerPool.FormatResult} formatResult + * @param {!FormatResult} formatResult */ _didFormatContent(formatResult) { const sourceMapping = new FormatterSourceMappingImpl( @@ -221,18 +224,3 @@ class FormatterSourceMappingImpl { return convertedPosition; } } - -/* Legacy exported object */ -self.Formatter = self.Formatter || {}; - -/* Legacy exported object */ -Formatter = Formatter || {}; - -/** @interface */ -Formatter.Formatter = FormatterInterface; - -/** @constructor */ -Formatter.ScriptFormatter = ScriptFormatter; - -/** @interface */ -Formatter.FormatterSourceMapping = FormatterSourceMapping; diff --git a/resources/unpacked/devtools/front_end/formatter/SourceFormatter.js b/resources/unpacked/devtools/front_end/formatter/SourceFormatter.js index 4637747122..b5da6166f1 100644 --- a/resources/unpacked/devtools/front_end/formatter/SourceFormatter.js +++ b/resources/unpacked/devtools/front_end/formatter/SourceFormatter.js @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {FormatterInterface, FormatterSourceMapping} from './ScriptFormatter.js'; // eslint-disable-line no-unused-vars + export class SourceFormatData { /** * @param {!Workspace.UISourceCode} originalSourceCode * @param {!Workspace.UISourceCode} formattedSourceCode - * @param {!Formatter.FormatterSourceMapping} mapping + * @param {!FormatterSourceMapping} mapping */ constructor(originalSourceCode, formattedSourceCode, mapping) { this.originalSourceCode = originalSourceCode; @@ -118,14 +120,14 @@ export class SourceFormatter { this._formattedSourceCodes.set(uiSourceCode, {promise: resultPromise, formatData: null}); const {content} = await uiSourceCode.requestContent(); // ------------ ASYNC ------------ - Formatter.Formatter.format( + FormatterInterface.format( uiSourceCode.contentType(), uiSourceCode.mimeType(), content || '', formatDone.bind(this)); return resultPromise; /** * @this SourceFormatter * @param {string} formattedContent - * @param {!Formatter.FormatterSourceMapping} formatterMapping + * @param {!FormatterSourceMapping} formatterMapping */ function formatDone(formattedContent, formatterMapping) { const cacheEntry = this._formattedSourceCodes.get(uiSourceCode); @@ -368,15 +370,3 @@ class StyleMapping { return []; } } - -/* Legacy exported object */ -self.Formatter = self.Formatter || {}; - -/* Legacy exported object */ -Formatter = Formatter || {}; - -/** @constructor */ -Formatter.SourceFormatter = SourceFormatter; - -/** @type {!SourceFormatter} */ -Formatter.sourceFormatter = new SourceFormatter(); diff --git a/resources/unpacked/devtools/front_end/formatter/formatter-legacy.js b/resources/unpacked/devtools/front_end/formatter/formatter-legacy.js new file mode 100644 index 0000000000..59e18d83a0 --- /dev/null +++ b/resources/unpacked/devtools/front_end/formatter/formatter-legacy.js @@ -0,0 +1,52 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import * as FormatterModule from './formatter.js'; + +self.Formatter = self.Formatter || {}; +Formatter = Formatter || {}; + +/** @constructor */ +Formatter.FormatterWorkerPool = FormatterModule.FormatterWorkerPool.FormatterWorkerPool; + +Formatter.formatterWorkerPool = FormatterModule.FormatterWorkerPool.formatterWorkerPool; + +/** @constructor */ +Formatter.FormatterWorkerPool.FormatResult = FormatterModule.FormatterWorkerPool.FormatResult; + +/** @interface */ +Formatter.Formatter = FormatterModule.ScriptFormatter.FormatterInterface; + +/** @constructor */ +Formatter.ScriptFormatter = FormatterModule.ScriptFormatter.ScriptFormatter; + +/** @interface */ +Formatter.FormatterSourceMapping = FormatterModule.ScriptFormatter.FormatterSourceMapping; + +/** @constructor */ +Formatter.SourceFormatter = FormatterModule.SourceFormatter.SourceFormatter; + +/** @type {!Formatter.SourceFormatter} */ +Formatter.sourceFormatter = FormatterModule.sourceFormatter; + +/** @typedef {{original: !Array, formatted: !Array}} */ +Formatter.FormatterWorkerPool.FormatMapping; + +/** @typedef {{line: number, column: number, title: string, subtitle: (string|undefined) }} */ +Formatter.FormatterWorkerPool.OutlineItem; + +/** + * @typedef {{atRule: string, lineNumber: number, columnNumber: number}} + */ +Formatter.FormatterWorkerPool.CSSAtRule; + +/** + * @typedef {(CSSStyleRule|Formatter.FormatterWorkerPool.CSSAtRule)} + */ +Formatter.FormatterWorkerPool.CSSRule; + +/** + * @typedef {{startLine: number, startColumn: number, endLine: number, endColumn: number}} + */ +Formatter.FormatterWorkerPool.TextRange; diff --git a/resources/unpacked/devtools/front_end/formatter/formatter.js b/resources/unpacked/devtools/front_end/formatter/formatter.js index e978e9eeda..efe49ee3d3 100644 --- a/resources/unpacked/devtools/front_end/formatter/formatter.js +++ b/resources/unpacked/devtools/front_end/formatter/formatter.js @@ -6,4 +6,6 @@ import * as FormatterWorkerPool from './FormatterWorkerPool.js'; import * as ScriptFormatter from './ScriptFormatter.js'; import * as SourceFormatter from './SourceFormatter.js'; +export const sourceFormatter = new SourceFormatter.SourceFormatter(); + export {FormatterWorkerPool, ScriptFormatter, SourceFormatter}; diff --git a/resources/unpacked/devtools/front_end/formatter/module.json b/resources/unpacked/devtools/front_end/formatter/module.json index 53d08e6d6d..f4ca59a229 100644 --- a/resources/unpacked/devtools/front_end/formatter/module.json +++ b/resources/unpacked/devtools/front_end/formatter/module.json @@ -5,6 +5,7 @@ "scripts": [], "modules": [ "formatter.js", + "formatter-legacy.js", "FormatterWorkerPool.js", "ScriptFormatter.js", "SourceFormatter.js" diff --git a/resources/unpacked/devtools/front_end/media/EventDisplayTable.js b/resources/unpacked/devtools/front_end/media/EventDisplayTable.js index 076e57a71f..e0cdcdc519 100644 --- a/resources/unpacked/devtools/front_end/media/EventDisplayTable.js +++ b/resources/unpacked/devtools/front_end/media/EventDisplayTable.js @@ -140,10 +140,10 @@ Media.EventDisplayTable = class extends UI.VBox { /** * @param {!Media.EventDisplayColumnConfig} columnConfig - * @return {!DataGrid.DataGrid.ColumnDescriptor} + * @return {!DataGrid.ColumnDescriptor} */ static _convertToGridDescriptor(columnConfig) { - return /** @type {!DataGrid.DataGrid.ColumnDescriptor} */ ({ + return /** @type {!DataGrid.ColumnDescriptor} */ ({ id: columnConfig.id, title: columnConfig.title, sortable: columnConfig.sortable, diff --git a/resources/unpacked/devtools/front_end/network/EventSourceMessagesView.js b/resources/unpacked/devtools/front_end/network/EventSourceMessagesView.js index 5ad013db36..0e482832c0 100644 --- a/resources/unpacked/devtools/front_end/network/EventSourceMessagesView.js +++ b/resources/unpacked/devtools/front_end/network/EventSourceMessagesView.js @@ -14,7 +14,7 @@ export default class EventSourceMessagesView extends UI.VBox { this.element.classList.add('event-source-messages-view'); this._request = request; - const columns = /** @type {!Array} */ ([ + const columns = /** @type {!Array} */ ([ {id: 'id', title: Common.UIString('Id'), sortable: true, weight: 8}, {id: 'type', title: Common.UIString('Type'), sortable: true, weight: 8}, {id: 'data', title: Common.UIString('Data'), sortable: false, weight: 88}, diff --git a/resources/unpacked/devtools/front_end/network/NetworkLogViewColumns.js b/resources/unpacked/devtools/front_end/network/NetworkLogViewColumns.js index 84966eaa34..b40e3b81d6 100644 --- a/resources/unpacked/devtools/front_end/network/NetworkLogViewColumns.js +++ b/resources/unpacked/devtools/front_end/network/NetworkLogViewColumns.js @@ -48,10 +48,10 @@ export default class NetworkLogViewColumns { /** * @param {!Network.NetworkLogViewColumns.Descriptor} columnConfig - * @return {!DataGrid.DataGrid.ColumnDescriptor} + * @return {!DataGrid.ColumnDescriptor} */ static _convertToDataGridDescriptor(columnConfig) { - return /** @type {!DataGrid.DataGrid.ColumnDescriptor} */ ({ + return /** @type {!DataGrid.ColumnDescriptor} */ ({ id: columnConfig.id, title: columnConfig.title, sortable: columnConfig.sortable, diff --git a/resources/unpacked/devtools/front_end/network/ResourceWebSocketFrameView.js b/resources/unpacked/devtools/front_end/network/ResourceWebSocketFrameView.js index d02707c18e..efe608fa17 100644 --- a/resources/unpacked/devtools/front_end/network/ResourceWebSocketFrameView.js +++ b/resources/unpacked/devtools/front_end/network/ResourceWebSocketFrameView.js @@ -32,7 +32,7 @@ export class ResourceWebSocketFrameView extends UI.VBox { this._splitWidget = new UI.SplitWidget(false, true, 'resourceWebSocketFrameSplitViewState'); this._splitWidget.show(this.element); - const columns = /** @type {!Array} */ ([ + const columns = /** @type {!Array} */ ([ {id: 'data', title: Common.UIString('Data'), sortable: false, weight: 88}, { id: 'length', title: Common.UIString('Length'), diff --git a/resources/unpacked/devtools/front_end/profiler/HeapSnapshotDataGrids.js b/resources/unpacked/devtools/front_end/profiler/HeapSnapshotDataGrids.js index 12b7155ff4..be1a07d812 100644 --- a/resources/unpacked/devtools/front_end/profiler/HeapSnapshotDataGrids.js +++ b/resources/unpacked/devtools/front_end/profiler/HeapSnapshotDataGrids.js @@ -35,7 +35,7 @@ export class HeapSnapshotSortableDataGrid extends DataGrid.DataGrid { /** * @param {?SDK.HeapProfilerModel} heapProfilerModel * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate - * @param {!DataGrid.DataGrid.Parameters} dataGridParameters + * @param {!DataGrid.Parameters} dataGridParameters */ constructor(heapProfilerModel, dataDisplayDelegate, dataGridParameters) { // TODO(allada) This entire class needs to be converted to use the templates in DataGridNode. @@ -336,7 +336,7 @@ export class HeapSnapshotViewportDataGrid extends HeapSnapshotSortableDataGrid { /** * @param {?SDK.HeapProfilerModel} heapProfilerModel * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate - * @param {!DataGrid.DataGrid.Parameters} dataGridParameters + * @param {!DataGrid.Parameters} dataGridParameters */ constructor(heapProfilerModel, dataDisplayDelegate, dataGridParameters) { super(heapProfilerModel, dataDisplayDelegate, dataGridParameters); @@ -628,10 +628,10 @@ export class HeapSnapshotContainmentDataGrid extends HeapSnapshotSortableDataGri * @param {?SDK.HeapProfilerModel} heapProfilerModel * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate * @param {string} displayName - * @param {!Array.=} columns + * @param {!Array.=} columns */ constructor(heapProfilerModel, dataDisplayDelegate, displayName, columns) { - columns = columns || (/** @type {!Array} */ ([ + columns = columns || (/** @type {!Array} */ ([ {id: 'object', title: ls`Object`, disclosure: true, sortable: true}, {id: 'distance', title: ls`Distance`, width: '70px', sortable: true, fixedWidth: true}, {id: 'shallowSize', title: ls`Shallow Size`, width: '110px', sortable: true, fixedWidth: true}, { @@ -683,7 +683,7 @@ export class HeapSnapshotRetainmentDataGrid extends HeapSnapshotContainmentDataG * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate */ constructor(heapProfilerModel, dataDisplayDelegate) { - const columns = /** @type {!Array} */ ([ + const columns = /** @type {!Array} */ ([ {id: 'object', title: ls`Object`, disclosure: true, sortable: true}, { id: 'distance', title: ls`Distance`, @@ -745,7 +745,7 @@ export class HeapSnapshotConstructorsDataGrid extends HeapSnapshotViewportDataGr * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate */ constructor(heapProfilerModel, dataDisplayDelegate) { - const columns = /** @type {!Array} */ ([ + const columns = /** @type {!Array} */ ([ {id: 'object', title: ls`Constructor`, disclosure: true, sortable: true}, {id: 'distance', title: ls`Distance`, width: '70px', sortable: true, fixedWidth: true}, {id: 'shallowSize', title: ls`Shallow Size`, width: '110px', sortable: true, fixedWidth: true}, { @@ -904,7 +904,7 @@ export class HeapSnapshotDiffDataGrid extends HeapSnapshotViewportDataGrid { * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate */ constructor(heapProfilerModel, dataDisplayDelegate) { - const columns = /** @type {!Array} */ ([ + const columns = /** @type {!Array} */ ([ {id: 'object', title: ls`Constructor`, disclosure: true, sortable: true}, {id: 'addedCount', title: ls`# New`, width: '75px', sortable: true, fixedWidth: true}, {id: 'removedCount', title: ls`# Deleted`, width: '75px', sortable: true, fixedWidth: true}, @@ -984,7 +984,7 @@ export class AllocationDataGrid extends HeapSnapshotViewportDataGrid { * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate */ constructor(heapProfilerModel, dataDisplayDelegate) { - const columns = /** @type {!Array} */ ([ + const columns = /** @type {!Array} */ ([ {id: 'liveCount', title: ls`Live Count`, width: '75px', sortable: true, fixedWidth: true}, {id: 'count', title: ls`Count`, width: '65px', sortable: true, fixedWidth: true}, {id: 'liveSize', title: ls`Live Size`, width: '75px', sortable: true, fixedWidth: true}, diff --git a/resources/unpacked/devtools/front_end/profiler/ProfileView.js b/resources/unpacked/devtools/front_end/profiler/ProfileView.js index aaf9199698..0dd9cc845b 100644 --- a/resources/unpacked/devtools/front_end/profiler/ProfileView.js +++ b/resources/unpacked/devtools/front_end/profiler/ProfileView.js @@ -16,7 +16,7 @@ export default class ProfileView extends UI.SimpleView { this._searchableView.setPlaceholder(Common.UIString('Find by cost (>50ms), name or file')); this._searchableView.show(this.element); - const columns = /** @type {!Array} */ ([]); + const columns = /** @type {!Array} */ ([]); columns.push({ id: 'self', title: this.columnHeader('self'), diff --git a/resources/unpacked/devtools/front_end/resources/ApplicationCacheItemsView.js b/resources/unpacked/devtools/front_end/resources/ApplicationCacheItemsView.js index a0af95d03d..94b46c0f47 100644 --- a/resources/unpacked/devtools/front_end/resources/ApplicationCacheItemsView.js +++ b/resources/unpacked/devtools/front_end/resources/ApplicationCacheItemsView.js @@ -184,7 +184,7 @@ export default class ApplicationCacheItemsView extends UI.SimpleView { } _createDataGrid() { - const columns = /** @type {!Array} */ ([ + const columns = /** @type {!Array} */ ([ {id: 'resource', title: Common.UIString('Resource'), sort: DataGrid.DataGrid.Order.Ascending, sortable: true}, {id: 'type', title: Common.UIString('Type'), sortable: true}, {id: 'size', title: Common.UIString('Size'), align: DataGrid.DataGrid.Align.Right, sortable: true} diff --git a/resources/unpacked/devtools/front_end/resources/BackgroundServiceView.js b/resources/unpacked/devtools/front_end/resources/BackgroundServiceView.js index 472585ea3d..6e98c085e7 100644 --- a/resources/unpacked/devtools/front_end/resources/BackgroundServiceView.js +++ b/resources/unpacked/devtools/front_end/resources/BackgroundServiceView.js @@ -211,7 +211,7 @@ export default class BackgroundServiceView extends UI.VBox { * @return {!DataGrid.DataGrid} */ _createDataGrid() { - const columns = /** @type {!Array} */ ([ + const columns = /** @type {!Array} */ ([ {id: 'id', title: ls`#`, weight: 1}, {id: 'timestamp', title: ls`Timestamp`, weight: 8}, {id: 'eventName', title: ls`Event`, weight: 10}, diff --git a/resources/unpacked/devtools/front_end/resources/DOMStorageItemsView.js b/resources/unpacked/devtools/front_end/resources/DOMStorageItemsView.js index 7a152d1809..66f0727d28 100644 --- a/resources/unpacked/devtools/front_end/resources/DOMStorageItemsView.js +++ b/resources/unpacked/devtools/front_end/resources/DOMStorageItemsView.js @@ -35,7 +35,7 @@ export default class DOMStorageItemsView extends Resources.StorageItemsView { this.element.classList.add('storage-view', 'table'); - const columns = /** @type {!Array} */ ([ + const columns = /** @type {!Array} */ ([ {id: 'key', title: Common.UIString('Key'), sortable: false, editable: true, longText: true, weight: 50}, {id: 'value', title: Common.UIString('Value'), sortable: false, editable: true, longText: true, weight: 50} ]); diff --git a/resources/unpacked/devtools/front_end/resources/IndexedDBViews.js b/resources/unpacked/devtools/front_end/resources/IndexedDBViews.js index 6f0dd52371..5f2d1fc433 100644 --- a/resources/unpacked/devtools/front_end/resources/IndexedDBViews.js +++ b/resources/unpacked/devtools/front_end/resources/IndexedDBViews.js @@ -147,7 +147,7 @@ export class IDBDataView extends UI.SimpleView { _createDataGrid() { const keyPath = this._isIndex ? this._index.keyPath : this._objectStore.keyPath; - const columns = /** @type {!Array} */ ([]); + const columns = /** @type {!Array} */ ([]); columns.push({id: 'number', title: Common.UIString('#'), sortable: false, width: '50px'}); columns.push( {id: 'key', titleDOMFragment: this._keyColumnHeaderFragment(Common.UIString('Key'), keyPath), sortable: false}); diff --git a/resources/unpacked/devtools/front_end/resources/ServiceWorkerCacheViews.js b/resources/unpacked/devtools/front_end/resources/ServiceWorkerCacheViews.js index d16341433e..f7f5c77112 100644 --- a/resources/unpacked/devtools/front_end/resources/ServiceWorkerCacheViews.js +++ b/resources/unpacked/devtools/front_end/resources/ServiceWorkerCacheViews.js @@ -107,7 +107,7 @@ export class ServiceWorkerCacheView extends UI.SimpleView { * @return {!DataGrid.DataGrid} */ _createDataGrid() { - const columns = /** @type {!Array} */ ([ + const columns = /** @type {!Array} */ ([ {id: 'number', title: '#', sortable: false, width: '3px'}, {id: 'name', title: Common.UIString('Name'), weight: 4, sortable: true}, {id: 'responseType', title: ls`Response-Type`, weight: 1, align: DataGrid.DataGrid.Align.Right, sortable: true}, diff --git a/resources/unpacked/devtools/front_end/root.js b/resources/unpacked/devtools/front_end/root.js index c7c5f381b5..23bab27f0b 100644 --- a/resources/unpacked/devtools/front_end/root.js +++ b/resources/unpacked/devtools/front_end/root.js @@ -13,7 +13,7 @@ import './ui/ui-legacy.js'; import './services/services.js'; import './workspace/workspace.js'; -import './bindings/bindings.js'; +import './bindings/bindings-legacy.js'; import './components/components.js'; import './persistence/persistence.js'; import './browser_sdk/browser_sdk.js'; diff --git a/resources/unpacked/devtools/front_end/sources/SourcesPanel.js b/resources/unpacked/devtools/front_end/sources/SourcesPanel.js index ccc1c183f2..54392289c0 100644 --- a/resources/unpacked/devtools/front_end/sources/SourcesPanel.js +++ b/resources/unpacked/devtools/front_end/sources/SourcesPanel.js @@ -533,16 +533,13 @@ export default class SourcesPanel extends UI.Panel { */ _switchToPausedTarget(debuggerModel) { delete this._switchToPausedTargetTimeout; - if (this._paused) { - return; - } - if (debuggerModel.isPaused()) { + if (this._paused || debuggerModel.isPaused()) { return; } - const debuggerModels = SDK.targetManager.models(SDK.DebuggerModel); - for (let i = 0; i < debuggerModels.length; ++i) { - if (debuggerModels[i].isPaused()) { - UI.context.setFlavor(SDK.Target, debuggerModels[i].target()); + + for (const debuggerModel of SDK.targetManager.models(SDK.DebuggerModel)) { + if (debuggerModel.isPaused()) { + UI.context.setFlavor(SDK.Target, debuggerModel.target()); break; } } @@ -554,10 +551,9 @@ export default class SourcesPanel extends UI.Panel { _runSnippet() { const uiSourceCode = this._sourcesView.currentUISourceCode(); - if (!uiSourceCode) { - return; + if (uiSourceCode) { + Snippets.evaluateScriptSnippet(uiSourceCode); } - Snippets.evaluateScriptSnippet(uiSourceCode); } /** @@ -615,12 +611,10 @@ export default class SourcesPanel extends UI.Panel { */ _longResume(event) { const debuggerModel = this._prepareToResume(); - if (!debuggerModel) { - return; + if (debuggerModel) { + debuggerModel.skipAllPausesUntilReloadOrTimeout(500); + debuggerModel.resume(); } - - debuggerModel.skipAllPausesUntilReloadOrTimeout(500); - debuggerModel.resume(); } /** @@ -628,11 +622,10 @@ export default class SourcesPanel extends UI.Panel { */ _terminateExecution(event) { const debuggerModel = this._prepareToResume(); - if (!debuggerModel) { - return; + if (debuggerModel) { + debuggerModel.runtimeModel().terminateExecution(); + debuggerModel.resume(); } - debuggerModel.runtimeModel().terminateExecution(); - debuggerModel.resume(); } /** @@ -640,11 +633,9 @@ export default class SourcesPanel extends UI.Panel { */ _stepOver() { const debuggerModel = this._prepareToResume(); - if (!debuggerModel) { - return true; + if (debuggerModel) { + debuggerModel.stepOver(); } - - debuggerModel.stepOver(); return true; } @@ -653,11 +644,9 @@ export default class SourcesPanel extends UI.Panel { */ _stepInto() { const debuggerModel = this._prepareToResume(); - if (!debuggerModel) { - return true; + if (debuggerModel) { + debuggerModel.stepInto(); } - - debuggerModel.stepInto(); return true; } @@ -666,10 +655,9 @@ export default class SourcesPanel extends UI.Panel { */ _stepIntoAsync() { const debuggerModel = this._prepareToResume(); - if (!debuggerModel) { - return true; + if (debuggerModel) { + debuggerModel.scheduleStepIntoAsync(); } - debuggerModel.scheduleStepIntoAsync(); return true; } @@ -678,34 +666,27 @@ export default class SourcesPanel extends UI.Panel { */ _stepOut() { const debuggerModel = this._prepareToResume(); - if (!debuggerModel) { - return true; + if (debuggerModel) { + debuggerModel.stepOut(); } - - debuggerModel.stepOut(); return true; } /** * @param {!Workspace.UILocation} uiLocation */ - _continueToLocation(uiLocation) { + async _continueToLocation(uiLocation) { const executionContext = UI.context.flavor(SDK.ExecutionContext); if (!executionContext) { return; } // Always use 0 column. - const rawLocations = - Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiLocation.uiSourceCode, uiLocation.lineNumber, 0); + const rawLocations = await Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations( + uiLocation.uiSourceCode, uiLocation.lineNumber, 0); const rawLocation = rawLocations.find(location => location.debuggerModel === executionContext.debuggerModel); - if (!rawLocation) { - return; - } - if (!this._prepareToResume()) { - return; + if (rawLocation && this._prepareToResume()) { + rawLocation.continueToLocation(); } - - rawLocation.continueToLocation(); } _toggleBreakpointsActive() { @@ -887,12 +868,7 @@ export default class SourcesPanel extends UI.Panel { return; } - const location = response.location; - if (!location) { - return; - } - - const uiLocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(location); + const uiLocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(response.location); if (uiLocation) { this.showUILocation(uiLocation); } diff --git a/resources/unpacked/devtools/front_end/timeline/EventsTimelineTreeView.js b/resources/unpacked/devtools/front_end/timeline/EventsTimelineTreeView.js index dccee91496..068f609510 100644 --- a/resources/unpacked/devtools/front_end/timeline/EventsTimelineTreeView.js +++ b/resources/unpacked/devtools/front_end/timeline/EventsTimelineTreeView.js @@ -104,7 +104,7 @@ export default class EventsTimelineTreeView extends Timeline.TimelineTreeView { /** * @override - * @param {!Array} columns + * @param {!Array} columns */ populateColumns(columns) { columns.push( diff --git a/resources/unpacked/devtools/front_end/timeline/TimelineTreeView.js b/resources/unpacked/devtools/front_end/timeline/TimelineTreeView.js index a61b54248a..154e97bf0e 100644 --- a/resources/unpacked/devtools/front_end/timeline/TimelineTreeView.js +++ b/resources/unpacked/devtools/front_end/timeline/TimelineTreeView.js @@ -74,7 +74,7 @@ export default class TimelineTreeView extends UI.VBox { this._currentThreadSetting = Common.settings.createSetting('timelineTreeCurrentThread', 0); this._currentThreadSetting.addChangeListener(this.refreshTree, this); - const columns = /** @type {!Array} */ ([]); + const columns = /** @type {!Array} */ ([]); this.populateColumns(columns); this._splitWidget = new UI.SplitWidget(true, true, 'timelineTreeViewDetailsSplitWidget'); @@ -290,7 +290,7 @@ export default class TimelineTreeView extends UI.VBox { /** * @protected - * @param {!Array} columns + * @param {!Array} columns */ populateColumns(columns) { columns.push({id: 'self', title: Common.UIString('Self Time'), width: '120px', fixedWidth: true, sortable: true}); @@ -1020,7 +1020,7 @@ export class TimelineStackView extends UI.VBox { const header = this.element.createChild('div', 'timeline-stack-view-header'); header.textContent = Common.UIString('Heaviest stack'); this._treeView = treeView; - const columns = /** @type {!Array} */ ([ + const columns = /** @type {!Array} */ ([ {id: 'total', title: Common.UIString('Total Time'), fixedWidth: true, width: '110px'}, {id: 'activity', title: Common.UIString('Activity')} ]); diff --git a/resources/unpacked/devtools/scripts/migration/get-mappings.ts b/resources/unpacked/devtools/scripts/migration/get-mappings.ts index e26afa20fe..608213dcab 100644 --- a/resources/unpacked/devtools/scripts/migration/get-mappings.ts +++ b/resources/unpacked/devtools/scripts/migration/get-mappings.ts @@ -42,7 +42,8 @@ export async function getMappings(namespace: string, mappings: Map, if (isMemberExpressionOnLeftAndRight) { // Rename FooModule back to Foo because we know we will want to use the latter when doing replacements. - if (statement.expression.right.object && statement.expression.right.object.object.type === 'Identifier') { + if (statement.expression.right.object && statement.expression.right.object.object && + statement.expression.right.object.object.type === 'Identifier') { statement.expression.right.object.object.name = statement.expression.right.object.object.name.replace(/Module$/, ''); } diff --git a/resources/unpacked/devtools/scripts/migration/move-side-effects-to-legacy.ts b/resources/unpacked/devtools/scripts/migration/move-side-effects-to-legacy.ts index 03cdedd8e4..a59c138a68 100644 --- a/resources/unpacked/devtools/scripts/migration/move-side-effects-to-legacy.ts +++ b/resources/unpacked/devtools/scripts/migration/move-side-effects-to-legacy.ts @@ -56,6 +56,11 @@ function rewriteSource(source: string, fileName: string) { if (statement.expression.left.type === 'MemberExpression') { // Remove self.Foo = self.Foo || {} if (statement.expression.left.object.name === 'self') { + // Make sure to only grab the statement if it follows the self.X = self.X || {} pattern. + if (statement.expression.right.type !== 'LogicalExpression' || statement.expression.right.operator !== '||') { + break; + } + // Grab the namespace from the RHS of self.[Namespace] if (statement.expression.right.type === 'LogicalExpression') { targetNamespace = statement.expression.right.left.property.name; diff --git a/resources/unpacked/devtools/test/unittests/front_end/ui/Icon.ts b/resources/unpacked/devtools/test/unittests/front_end/ui/Icon.ts new file mode 100644 index 0000000000..ba89d01db4 --- /dev/null +++ b/resources/unpacked/devtools/test/unittests/front_end/ui/Icon.ts @@ -0,0 +1,17 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const {assert} = chai; + +import {Icon} from '/front_end/ui/Icon.js'; + +describe('Icon', () => { + it('can create an empty instance without issues', () => { + const icon = Icon.create(); + assert.equal(icon.tagName, 'SPAN', 'icon span element was not created correctly'); + assert.equal(icon.getAttribute('is'), 'ui-icon', 'icon span element "is" attribute was not set correctly'); + }); + + // TODO continue writing tests here or use another describe block +}); diff --git a/resources/unpacked/devtools/test/unittests/front_end/ui/ListModel.ts b/resources/unpacked/devtools/test/unittests/front_end/ui/ListModel.ts new file mode 100644 index 0000000000..3bed7aabe5 --- /dev/null +++ b/resources/unpacked/devtools/test/unittests/front_end/ui/ListModel.ts @@ -0,0 +1,24 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const {assert} = chai; + +import '/front_end/common/common-legacy.js' +import {ListModel} from '/front_end/ui/ListModel.js'; + +describe('ListModel', () => { + after(() => { + // Clean up polluted globals. + // TODO(https://crbug.com/1006759): These need removing once the ESM migration is complete. + const globalObj = (self as any); + delete globalObj.Common; + }); + + it('can be instantiated correctly without a list of items', () => { + const listModel = new ListModel(); + assert.equal(listModel.length, 0, 'length of list model should be 0'); + }); + + // TODO continue writing tests here or use another describe block +}); diff --git a/resources/unpacked/devtools/test/unittests/front_end/ui/SyntaxHighlighter.ts b/resources/unpacked/devtools/test/unittests/front_end/ui/SyntaxHighlighter.ts new file mode 100644 index 0000000000..2b5a919d8f --- /dev/null +++ b/resources/unpacked/devtools/test/unittests/front_end/ui/SyntaxHighlighter.ts @@ -0,0 +1,19 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const {assert} = chai; + +import {SyntaxHighlighter} from '/front_end/ui/SyntaxHighlighter.js'; + +describe('SyntaxHighlighter', () => { + it('can be instantiated correctly', () => { + const syntaxHighlighter = new SyntaxHighlighter('TestMimeType', true); + const result = syntaxHighlighter.createSpan('TestContent', 'TestClass'); + assert.equal(result.tagName, 'SPAN', 'span element was not created correctly'); + assert.equal(result.getAttribute('class'), 'cm-TestClass', 'class was not set correctly'); + assert.equal(result.innerHTML, 'TestContent', 'content was not set correctly'); + }); + + // TODO continue writing tests here or use another describe block +}); diff --git a/resources/unpacked/devtools/test/unittests/front_end/ui/Widget.ts b/resources/unpacked/devtools/test/unittests/front_end/ui/Widget.ts new file mode 100644 index 0000000000..eb20da0a08 --- /dev/null +++ b/resources/unpacked/devtools/test/unittests/front_end/ui/Widget.ts @@ -0,0 +1,24 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const {assert} = chai; + +import '/front_end/root.js' +import {Widget} from '/front_end/ui/Widget.js'; + +describe('Widget', () => { + after(() => { + // Clean up polluted globals. + // TODO(https://crbug.com/1006759): These need removing once the ESM migration is complete. + const globalObj = (self as any); + delete globalObj.Root; + }); + + it('can be instantiated correctly', () => { + const widget = new Widget(false, false); + assert.isFalse(widget.isShowing(), 'widget should not be showing upon creation'); + }); + + // TODO continue writing tests here or use another describe block +}); diff --git a/resources/unpacked/devtools/test/unittests/front_end/ui/XWidget.ts b/resources/unpacked/devtools/test/unittests/front_end/ui/XWidget.ts new file mode 100644 index 0000000000..cb0315a3af --- /dev/null +++ b/resources/unpacked/devtools/test/unittests/front_end/ui/XWidget.ts @@ -0,0 +1,16 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const {assert} = chai; + +import {XWidget} from '/front_end/ui/XWidget.js'; + +describe('XWidget', () => { + it('can be instantiated correctly', () => { + const xWidget = new XWidget(); + assert.isFalse(xWidget.isShowing(), 'xwidget should not be showing upon initialization'); + }); + + // TODO continue writing tests here or use another describe block +});