豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 748db09

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
Extract common var in UI helpers
Let' a avoid comment about sync. We have multiple places that do that and are not currently in sync. We can do this if we have infra to track this. Bug: none Change-Id: Ie6cfba8eebe12b33b4da51507383de0d003eb0cb Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7581708 Auto-Submit: Nikolay Vitkov <nvitkov@chromium.org> Commit-Queue: Simon Zünd <szuend@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org>
1 parent c26d0ba commit 748db09

File tree

6 files changed

+5
-18
lines changed

6 files changed

+5
-18
lines changed

front_end/panels/console/ConsoleView.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ import {
7272
ConsoleTableMessageView,
7373
ConsoleViewMessage,
7474
getMessageForElement,
75-
MaxLengthForLinks,
7675
} from './ConsoleViewMessage.js';
7776
import {ConsoleViewport, type ConsoleViewportElement, type ConsoleViewportProvider} from './ConsoleViewport.js';
7877

@@ -549,7 +548,7 @@ export class ConsoleView extends UI.Widget.VBox implements
549548
// the linkifiers live location change event.
550549
const throttler = new Common.Throttler.Throttler(100);
551550
const refilterMessages = (): Promise<void> => throttler.schedule(async () => this.onFilterChanged());
552-
this.linkifier = new Components.Linkifier.Linkifier(MaxLengthForLinks);
551+
this.linkifier = new Components.Linkifier.Linkifier(UI.UIUtils.MaxLengthForDisplayedURLsInConsole);
553552
this.linkifier.addEventListener(Components.Linkifier.Events.LIVE_LOCATION_UPDATED, refilterMessages);
554553

555554
this.consoleMessages = [];

front_end/panels/console/ConsoleViewMessage.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,11 +2363,6 @@ export class ConsoleTableMessageView extends ConsoleViewMessage {
23632363
*/
23642364
const MaxLengthToIgnoreHighlighter = 10000;
23652365

2366-
/**
2367-
* @constant
2368-
*/
2369-
export const MaxLengthForLinks = 40;
2370-
23712366
let maxTokenizableStringLength = 10000;
23722367
let longStringVisibleLength = 5000;
23732368

front_end/panels/elements/NodeStackTraceWidget.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
4545
};
4646

4747
export class NodeStackTraceWidget extends UI.Widget.VBox {
48-
readonly #linkifier = new Components.Linkifier.Linkifier(MaxLengthForLinks);
48+
readonly #linkifier = new Components.Linkifier.Linkifier(UI.UIUtils.MaxLengthForDisplayedURLsInConsole);
4949
readonly #view: View;
5050

5151
constructor(view = DEFAULT_VIEW) {
@@ -81,5 +81,3 @@ export class NodeStackTraceWidget extends UI.Widget.VBox {
8181
this.#view(input, {}, this.contentElement);
8282
}
8383
}
84-
85-
export const MaxLengthForLinks = 40;

front_end/panels/issues/AffectedResourcesView.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,7 @@ export abstract class AffectedResourcesView extends UI.TreeOutline.TreeElement {
253253
const sourceCodeLocation = document.createElement('td');
254254
sourceCodeLocation.classList.add('affected-source-location');
255255
if (sourceLocation) {
256-
const maxLengthForDisplayedURLs = 40; // Same as console messages.
257-
const linkifier = new Components.Linkifier.Linkifier(maxLengthForDisplayedURLs);
256+
const linkifier = new Components.Linkifier.Linkifier(UI.UIUtils.MaxLengthForDisplayedURLsInConsole);
258257
const sourceAnchor = linkifier.linkifyScriptLocation(
259258
target || null, sourceLocation.scriptId || null, sourceLocation.url as Platform.DevToolsPath.UrlString,
260259
sourceLocation.lineNumber, {columnNumber: sourceLocation.columnNumber, inlineFrameIndex: 0});

front_end/ui/legacy/UIUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,7 @@ export function createFileSelectorElement(callback: (arg0: File) => void, accept
15531553
}
15541554

15551555
export const MaxLengthForDisplayedURLs = 150;
1556+
export const MaxLengthForDisplayedURLsInConsole = 40;
15561557

15571558
export class MessageDialog {
15581559
static async show(header: string, message: string, where?: Element|Document, jslogContext?: string): Promise<void> {

front_end/ui/legacy/components/utils/JSPresentationUtils.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ const UIStrings = {
7171
const str_ = i18n.i18n.registerUIStrings('ui/legacy/components/utils/JSPresentationUtils.ts', UIStrings);
7272
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
7373

74-
/**
75-
* Keep consistent with ConsoleViewMessage.MaxLengthForLinks.
76-
*/
77-
const MAX_LINK_LENGTH = 40;
78-
7974
function populateContextMenu(link: Element, event: Event): void {
8075
const contextMenu = new UI.ContextMenu.ContextMenu(event);
8176
event.consume(true);
@@ -193,7 +188,7 @@ function buildStackTraceRows(
193188
tabStop: Boolean(tabStops),
194189
inlineFrameIndex: 0,
195190
revealBreakpoint: previousStackFrameWasBreakpointCondition,
196-
maxLength: MAX_LINK_LENGTH,
191+
maxLength: UI.UIUtils.MaxLengthForDisplayedURLsInConsole,
197192
});
198193
link.setAttribute('jslog', `${VisualLogging.link('stack-trace').track({click: true})}`);
199194
link.addEventListener('contextmenu', populateContextMenu.bind(null, link));

0 commit comments

Comments
 (0)