// Copyright 2020 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import '../../ui/legacy/legacy.js'; import * as i18n from '../../core/i18n/i18n.js'; import type * as SDK from '../../core/sdk/sdk.js'; import type * as UI from '../../ui/legacy/legacy.js'; import {html, nothing, render} from '../../ui/lit/lit.js'; import * as VisualLogging from '../../ui/visual_logging/visual_logging.js'; import {AccessibilitySubPane} from './AccessibilitySubPane.js'; const UIStrings = { /** * @description Name of a tool which allows the developer to view the contents of the page in the * 'source order' (the order in which the HTML elements show up in the source code). In the * Accessibility panel. */ sourceOrderViewer: 'Source Order Viewer', /** * @description Text in Source Order Viewer of the Accessibility panel shown when the selected node has no child elements */ noSourceOrderInformation: 'No source order information available', /** * @description Text in Source Order Viewer of the Accessibility panel shown when the selected node has many child elements */ thereMayBeADelayInDisplaying: 'There may be a delay in displaying source order for elements with many children', /** * @description Checkbox label in Source Order Viewer of the Accessibility panel. Source order * means the order in which the HTML elements show up in the source code. */ showSourceOrder: 'Show source order', } as const; const str_ = i18n.i18n.registerUIStrings('panels/accessibility/SourceOrderView.ts', UIStrings); const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); const MAX_CHILD_ELEMENTS_THRESHOLD = 300; interface ViewInput { childCount: number; showSourceOrder: boolean|undefined; onShowSourceOrderChanged: (showSourceOrder: boolean) => void; } type View = (input: ViewInput, output: unknown, target: HTMLElement) => void; const DEFAULT_VIEW: View = (input, _output, target) => { function onShowSourceOrderChanged(event: Event): void { const checkbox = event.currentTarget as UI.UIUtils.CheckboxLabel; input.onShowSourceOrderChanged(checkbox.checked); event.consume(); } // clang-format off render(html` ${input.showSourceOrder === undefined ? html`
` : html` ${input.childCount >= MAX_CHILD_ELEMENTS_THRESHOLD ? html` ` : nothing }