Skip to content

Commit 4892a21

Browse files
danilsomsikovDevtools-frontend LUCI CQ
authored andcommitted
Fixed the trivial violations of the no-lit-render-outside-of-view
Fixed: 407940043, 407750767 Change-Id: I3ce8d7da3945c6a83139a8bfd60648742b1eb973 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7084745 Reviewed-by: Nikolay Vitkov <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]> Commit-Queue: Danil Somsikov <[email protected]> Auto-Submit: Danil Somsikov <[email protected]>
1 parent 82285c0 commit 4892a21

File tree

12 files changed

+205
-207
lines changed

12 files changed

+205
-207
lines changed

front_end/panels/ai_assistance/PatchWidget.ts

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright 2025 The Chromium Authors
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
/* eslint-disable @devtools/no-lit-render-outside-of-view */
54

65
import '../../ui/legacy/legacy.js';
76
import '../../ui/components/markdown_view/markdown_view.js';
@@ -187,42 +186,8 @@ export interface ViewOutput {
187186
}
188187

189188
type View = (input: ViewInput, output: ViewOutput, target: HTMLElement) => void;
190-
191-
export class PatchWidget extends UI.Widget.Widget {
192-
changeSummary = '';
193-
changeManager: AiAssistanceModel.ChangeManager.ChangeManager|undefined;
194-
// Whether the user completed first run experience dialog or not.
195-
#aiPatchingFreCompletedSetting =
196-
Common.Settings.Settings.instance().createSetting('ai-assistance-patching-fre-completed', false);
197-
#projectIdSetting =
198-
Common.Settings.Settings.instance().createSetting('ai-assistance-patching-selected-project-id', '');
199-
#view: View;
200-
#viewOutput: ViewOutput = {};
201-
#aidaClient: Host.AidaClient.AidaClient;
202-
#applyPatchAbortController?: AbortController;
203-
#project?: Workspace.Workspace.Project;
204-
#patchSources?: string;
205-
#savedToDisk?: boolean;
206-
#noLogging: boolean; // Whether the enterprise setting is `ALLOW_WITHOUT_LOGGING` or not.
207-
#patchSuggestionState = PatchSuggestionState.INITIAL;
208-
#workspaceDiff = WorkspaceDiff.WorkspaceDiff.workspaceDiff();
209-
#workspace = Workspace.Workspace.WorkspaceImpl.instance();
210-
#automaticFileSystem =
211-
Persistence.AutomaticFileSystemManager.AutomaticFileSystemManager.instance().automaticFileSystem;
212-
#applyToDisconnectedAutomaticWorkspace = false;
213-
// `rpcId` from the `applyPatch` request
214-
#rpcId: Host.AidaClient.RpcGlobalId|null = null;
215-
216-
constructor(element?: HTMLElement, view?: View, opts?: {
217-
aidaClient: Host.AidaClient.AidaClient,
218-
}) {
219-
super(element);
220-
this.#aidaClient = opts?.aidaClient ?? new Host.AidaClient.AidaClient();
221-
this.#noLogging = Root.Runtime.hostConfig.aidaAvailability?.enterprisePolicyValue ===
222-
Root.Runtime.GenAiEnterprisePolicyValue.ALLOW_WITHOUT_LOGGING;
223-
224-
// clang-format off
225-
this.#view = view ?? ((input, output, target) => {
189+
const DEFAULT_VIEW: View =
190+
(input, output, target) => {
226191
if (!input.changeSummary && input.patchSuggestionState === PatchSuggestionState.INITIAL) {
227192
return;
228193
}
@@ -428,9 +393,43 @@ export class PatchWidget extends UI.Widget.Widget {
428393
</details>
429394
`;
430395

431-
render(template, target, {host: target});
432-
});
433-
// clang-format on
396+
render(template, target);
397+
};
398+
399+
export class PatchWidget extends UI.Widget.Widget {
400+
changeSummary = '';
401+
changeManager: AiAssistanceModel.ChangeManager.ChangeManager|undefined;
402+
// Whether the user completed first run experience dialog or not.
403+
#aiPatchingFreCompletedSetting =
404+
Common.Settings.Settings.instance().createSetting('ai-assistance-patching-fre-completed', false);
405+
#projectIdSetting =
406+
Common.Settings.Settings.instance().createSetting('ai-assistance-patching-selected-project-id', '');
407+
#view: View;
408+
#viewOutput: ViewOutput = {};
409+
#aidaClient: Host.AidaClient.AidaClient;
410+
#applyPatchAbortController?: AbortController;
411+
#project?: Workspace.Workspace.Project;
412+
#patchSources?: string;
413+
#savedToDisk?: boolean;
414+
#noLogging: boolean; // Whether the enterprise setting is `ALLOW_WITHOUT_LOGGING` or not.
415+
#patchSuggestionState = PatchSuggestionState.INITIAL;
416+
#workspaceDiff = WorkspaceDiff.WorkspaceDiff.workspaceDiff();
417+
#workspace = Workspace.Workspace.WorkspaceImpl.instance();
418+
#automaticFileSystem =
419+
Persistence.AutomaticFileSystemManager.AutomaticFileSystemManager.instance().automaticFileSystem;
420+
#applyToDisconnectedAutomaticWorkspace = false;
421+
// `rpcId` from the `applyPatch` request
422+
#rpcId: Host.AidaClient.RpcGlobalId|null = null;
423+
424+
constructor(element?: HTMLElement, view = DEFAULT_VIEW, opts?: {
425+
aidaClient: Host.AidaClient.AidaClient,
426+
}) {
427+
super(element);
428+
this.#aidaClient = opts?.aidaClient ?? new Host.AidaClient.AidaClient();
429+
this.#noLogging = Root.Runtime.hostConfig.aidaAvailability?.enterprisePolicyValue ===
430+
Root.Runtime.GenAiEnterprisePolicyValue.ALLOW_WITHOUT_LOGGING;
431+
this.#view = view;
432+
434433
this.requestUpdate();
435434
}
436435

front_end/panels/ai_assistance/components/ExploreWidget.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Copyright 2025 The Chromium Authors
33
// Use of this source code is governed by a BSD-style license that can be
44
// found in the LICENSE file.
5-
/* eslint-disable @devtools/no-lit-render-outside-of-view */
65

76
import * as i18n from '../../../core/i18n/i18n.js';
87
import * as Root from '../../../core/root/root.js';
@@ -105,7 +104,6 @@ export const DEFAULT_VIEW = (
105104
</div>
106105
`,
107106
target,
108-
{ host: target },
109107
);
110108
// clang-format on
111109
};

front_end/panels/autofill/AutofillView.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright 2023 The Chromium Authors
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
/* eslint-disable @devtools/no-lit-render-outside-of-view */
54

65
import '../../ui/components/adorners/adorners.js';
76
import '../../ui/legacy/components/data_grid/data_grid.js';
@@ -250,7 +249,7 @@ const DEFAULT_VIEW: View = (input: ViewInput, _output: ViewOutput, target: HTMLE
250249
</div>
251250
</div>
252251
</main>
253-
`, target, {host: this});
252+
`, target);
254253
// clang-format on
255254
return;
256255
}
@@ -287,7 +286,7 @@ const DEFAULT_VIEW: View = (input: ViewInput, _output: ViewOutput, target: HTMLE
287286
${renderFilledFields()}
288287
</div>
289288
</main>
290-
`, target, {host: this});
289+
`, target);
291290
// clang-format on
292291
};
293292

front_end/panels/changes/CombinedDiffView.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright 2025 The Chromium Authors
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
/* eslint-disable @devtools/no-lit-render-outside-of-view */
54

65
import * as Common from '../../core/common/common.js';
76
import * as i18n from '../../core/i18n/i18n.js';
@@ -101,6 +100,18 @@ function renderSingleDiffView(singleDiffViewInput: SingleDiffViewInput): Lit.Tem
101100
// clang-format on
102101
}
103102

103+
const DEFAULT_VIEW: View = (input, output, target) => {
104+
// clang-format off
105+
Lit.render(
106+
html`
107+
<div class="combined-diff-view">
108+
${input.singleDiffViewInputs.map(singleDiffViewInput => renderSingleDiffView(singleDiffViewInput))}
109+
</div>
110+
`,
111+
target);
112+
// clang-format on
113+
};
114+
104115
export class CombinedDiffView extends UI.Widget.Widget {
105116
/**
106117
* Ignores urls that start with any in the list
@@ -113,19 +124,7 @@ export class CombinedDiffView extends UI.Widget.Widget {
113124
#copiedFiles: Record<string, boolean> = {};
114125
#view: View;
115126
#viewOutput: ViewOutput = {};
116-
constructor(element?: HTMLElement, view: View = (input, output, target) => {
117-
output.scrollToSelectedDiff = () => {
118-
target.querySelector('details.selected')?.scrollIntoView();
119-
};
120-
121-
Lit.render(
122-
html`
123-
<div class="combined-diff-view">
124-
${input.singleDiffViewInputs.map(singleDiffViewInput => renderSingleDiffView(singleDiffViewInput))}
125-
</div>
126-
`,
127-
target, {host: target});
128-
}) {
127+
constructor(element?: HTMLElement, view: View = DEFAULT_VIEW) {
129128
super(element);
130129
this.registerRequiredCSS(combinedDiffViewStyles);
131130
this.#view = view;

front_end/panels/network/components/DirectSocketConnectionView.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ describeWithEnvironment('view', () => {
196196
onCopyRow: () => {}
197197
};
198198

199-
view(viewInput, target);
199+
view(viewInput, undefined, target);
200200
await assertScreenshot('direct_socket_connection_view/all_categories_open.png');
201201
});
202202

@@ -221,7 +221,7 @@ describeWithEnvironment('view', () => {
221221
onCopyRow: () => {}
222222
};
223223

224-
view(viewInput, target);
224+
view(viewInput, undefined, target);
225225
await assertScreenshot('direct_socket_connection_view/all_categories_open_values_absent.png');
226226
});
227227

@@ -247,7 +247,7 @@ describeWithEnvironment('view', () => {
247247
onCopyRow: () => {}
248248
};
249249

250-
view(viewInput, target);
250+
view(viewInput, undefined, target);
251251
await assertScreenshot('direct_socket_connection_view/all_categories_closed.png');
252252
});
253253
});

front_end/panels/network/components/DirectSocketConnectionView.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
/* eslint-disable @devtools/no-lit-render-outside-of-view */
6-
75
import * as Common from '../../../core/common/common.js';
86
import * as Host from '../../../core/host/host.js';
97
import * as i18n from '../../../core/i18n/i18n.js';
@@ -112,9 +110,9 @@ export interface ViewInput {
112110
onCopyRow: () => void;
113111
}
114112

115-
export type View = (input: ViewInput, target: HTMLElement) => void;
113+
export type View = (input: ViewInput, output: undefined, target: HTMLElement) => void;
116114

117-
export const DEFAULT_VIEW: View = (input, target) => {
115+
export const DEFAULT_VIEW: View = (input, _output, target) => {
118116
function isCategoryOpen(name: string): boolean {
119117
return input.openCategories.includes(name);
120118
}
@@ -203,7 +201,7 @@ export const DEFAULT_VIEW: View = (input, target) => {
203201
${renderCategory(CATEGORY_NAME_GENERAL, i18nString(UIStrings.general), generalContent)}
204202
${renderCategory(CATEGORY_NAME_OPTIONS, i18nString(UIStrings.options), optionsContent)}
205203
${socketInfo.openInfo ? renderCategory(CATEGORY_NAME_OPEN_INFO, i18nString(UIStrings.openInfo), openInfoContent) : Lit.nothing}
206-
`, target, {host: input});
204+
`, target);
207205
// clang-format on
208206
};
209207

@@ -278,7 +276,7 @@ export class DirectSocketConnectionView extends UI.Widget.Widget {
278276
Host.userMetrics.actionTaken(Host.UserMetrics.Action.NetworkPanelCopyValue);
279277
}
280278
};
281-
this.#view(viewInput, this.contentElement);
279+
this.#view(viewInput, undefined, this.contentElement);
282280
}
283281

284282
#setIsOpen(categoryName: string, open: boolean): void {

0 commit comments

Comments
 (0)