Skip to content

Commit 3a037ad

Browse files
hanselfmu-chromiumDevtools-frontend LUCI CQ
authored andcommitted
Remove unnecessary changes hints in the Styles tab code
Bug: 406453050 Change-Id: If12eb77019be34ab8f62c903009766ce57d85c3e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6400619 Commit-Queue: Changhao Han <[email protected]> Reviewed-by: Benedikt Meurer <[email protected]>
1 parent 05b6ebf commit 3a037ad

File tree

2 files changed

+6
-74
lines changed

2 files changed

+6
-74
lines changed

front_end/panels/elements/StylePropertiesSection.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export class StylePropertiesSection {
161161
private sectionIdx = 0;
162162

163163
#customHeaderText: string|undefined;
164-
readonly #specificiyTooltips: HTMLSpanElement;
164+
readonly #specificityTooltips: HTMLSpanElement;
165165
static #nextSpecificityTooltipId = 0;
166166

167167
constructor(
@@ -227,7 +227,7 @@ export class StylePropertiesSection {
227227
selectorContainer.appendChild(this.selectorElement);
228228
this.selectorElement.addEventListener('mouseenter', this.onMouseEnterSelector.bind(this), false);
229229
this.selectorElement.addEventListener('mouseleave', this.onMouseOutSelector.bind(this), false);
230-
this.#specificiyTooltips = selectorContainer.createChild('span');
230+
this.#specificityTooltips = selectorContainer.createChild('span');
231231

232232
// We only add braces for style rules with selectors and non-style rules, which create their own sections.
233233
if (headerText.length > 0 || !(rule instanceof SDK.CSSRule.CSSStyleRule)) {
@@ -1173,7 +1173,7 @@ export class StylePropertiesSection {
11731173
selectors: Array<{text: string, specificity?: Protocol.CSS.Specificity}>, matchingSelectors: boolean[],
11741174
elementToSelectorIndex: WeakMap<Element, number>): void {
11751175
this.selectorElement.removeChildren();
1176-
this.#specificiyTooltips.removeChildren();
1176+
this.#specificityTooltips.removeChildren();
11771177
for (const [i, selector] of selectors.entries()) {
11781178
if (i > 0) {
11791179
this.selectorElement.append(', ');
@@ -1186,7 +1186,7 @@ export class StylePropertiesSection {
11861186
if (specificityTooltipId && selector.specificity) {
11871187
span.setAttribute('aria-details', specificityTooltipId);
11881188
const PH1 = `(${selector.specificity.a},${selector.specificity.b},${selector.specificity.c})`;
1189-
const tooltip = this.#specificiyTooltips.appendChild(new Tooltips.Tooltip.Tooltip({
1189+
const tooltip = this.#specificityTooltips.appendChild(new Tooltips.Tooltip.Tooltip({
11901190
id: specificityTooltipId,
11911191
anchor: span,
11921192
variant: 'rich',
@@ -1468,7 +1468,7 @@ export class StylePropertiesSection {
14681468
// Reset selector marks in group, and normalize whitespace.
14691469
const textContent = element.textContent;
14701470
if (textContent !== null) {
1471-
this.#specificiyTooltips.querySelectorAll('devtools-tooltip')?.forEach(tooltip => tooltip.hidePopover());
1471+
this.#specificityTooltips.querySelectorAll('devtools-tooltip')?.forEach(tooltip => tooltip.hidePopover());
14721472
element.textContent = textContent.replace(/\s+/g, ' ').trim();
14731473
}
14741474

front_end/panels/elements/StylesSidebarPane.ts

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ import * as Protocol from '../../generated/protocol.js';
4444
import * as Bindings from '../../models/bindings/bindings.js';
4545
import type * as Formatter from '../../models/formatter/formatter.js';
4646
import * as TextUtils from '../../models/text_utils/text_utils.js';
47-
import * as Workspace from '../../models/workspace/workspace.js';
47+
import type * as Workspace from '../../models/workspace/workspace.js';
4848
import * as WorkspaceDiff from '../../models/workspace_diff/workspace_diff.js';
4949
import {PanelUtils} from '../../panels/utils/utils.js';
50-
import * as DiffView from '../../ui/components/diff_view/diff_view.js';
5150
import * as IconButton from '../../ui/components/icon_button/icon_button.js';
5251
import * as InlineEditor from '../../ui/legacy/components/inline_editor/inline_editor.js';
5352
import * as Components from '../../ui/legacy/components/utils/utils.js';
@@ -1325,73 +1324,6 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
13251324
return sections;
13261325
}
13271326

1328-
async trackURLForChanges(url: Platform.DevToolsPath.UrlString): Promise<void> {
1329-
const currentTracker = this.#urlToChangeTracker.get(url);
1330-
if (currentTracker) {
1331-
WorkspaceDiff.WorkspaceDiff.workspaceDiff().unsubscribeFromDiffChange(
1332-
currentTracker.uiSourceCode, currentTracker.diffChangeCallback);
1333-
}
1334-
1335-
// We get a refreshed uiSourceCode each time because the underlying instance may be recreated.
1336-
const uiSourceCode = Workspace.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(url);
1337-
if (!uiSourceCode) {
1338-
return;
1339-
}
1340-
const diffChangeCallback = this.refreshChangedLines.bind(this, uiSourceCode);
1341-
WorkspaceDiff.WorkspaceDiff.workspaceDiff().subscribeToDiffChange(uiSourceCode, diffChangeCallback);
1342-
const newTracker = {
1343-
uiSourceCode,
1344-
changedLines: new Set<number>(),
1345-
diffChangeCallback,
1346-
};
1347-
this.#urlToChangeTracker.set(url, newTracker);
1348-
await this.refreshChangedLines(newTracker.uiSourceCode);
1349-
}
1350-
1351-
isPropertyChanged(property: SDK.CSSProperty.CSSProperty): boolean {
1352-
const url = property.ownerStyle.parentRule?.resourceURL();
1353-
if (!url) {
1354-
return false;
1355-
}
1356-
const changeTracker = this.#urlToChangeTracker.get(url);
1357-
if (!changeTracker) {
1358-
return false;
1359-
}
1360-
const {changedLines, formattedCurrentMapping} = changeTracker;
1361-
const uiLocation = Bindings.CSSWorkspaceBinding.CSSWorkspaceBinding.instance().propertyUILocation(property, true);
1362-
if (!uiLocation) {
1363-
return false;
1364-
}
1365-
if (!formattedCurrentMapping) {
1366-
// UILocation's lineNumber starts at 0, but changedLines start at 1.
1367-
return changedLines.has(uiLocation.lineNumber + 1);
1368-
}
1369-
const formattedLineNumber =
1370-
formattedCurrentMapping.originalToFormatted(uiLocation.lineNumber, uiLocation.columnNumber)[0];
1371-
return changedLines.has(formattedLineNumber + 1);
1372-
}
1373-
1374-
private async refreshChangedLines(uiSourceCode: Workspace.UISourceCode.UISourceCode): Promise<void> {
1375-
const changeTracker = this.#urlToChangeTracker.get(uiSourceCode.url());
1376-
if (!changeTracker) {
1377-
return;
1378-
}
1379-
const diffResponse = await WorkspaceDiff.WorkspaceDiff.workspaceDiff().requestDiff(uiSourceCode);
1380-
const changedLines = new Set<number>();
1381-
changeTracker.changedLines = changedLines;
1382-
if (!diffResponse) {
1383-
return;
1384-
}
1385-
const {diff, formattedCurrentMapping} = diffResponse;
1386-
const {rows} = DiffView.DiffView.buildDiffRows(diff);
1387-
for (const row of rows) {
1388-
if (row.type === DiffView.DiffView.RowType.ADDITION) {
1389-
changedLines.add(row.currentLineNumber);
1390-
}
1391-
}
1392-
changeTracker.formattedCurrentMapping = formattedCurrentMapping;
1393-
}
1394-
13951327
async getFormattedChanges(): Promise<string> {
13961328
let allChanges = '';
13971329
for (const [url, {uiSourceCode}] of this.#urlToChangeTracker) {

0 commit comments

Comments
 (0)