Skip to content

Commit d59296a

Browse files
finnurbrekiDevtools-frontend LUCI CQ
authored andcommitted
[GreenDevFloaty]: Minor polish before adding anchors.
Bug: 466071312 Change-Id: I3d3fb623a7ee581e56ec91bc290a41899a8eeeaf Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7557438 Commit-Queue: Alina Varkki <alinavarkki@chromium.org> Auto-Submit: Finnur Thorarinsson <finnur@chromium.org> Reviewed-by: Alina Varkki <alinavarkki@chromium.org> Commit-Queue: Finnur Thorarinsson <finnur@chromium.org>
1 parent 1bf0484 commit d59296a

3 files changed

Lines changed: 21 additions & 22 deletions

File tree

front_end/core/sdk/OverlayModel.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,10 +792,12 @@ export class OverlayModel extends SDKModel<EventTypes> implements ProtocolProxyA
792792
return await this.#windowControls.initializeStyleSheetText(url);
793793
}
794794

795-
inspectPanelShowRequested(_event: Protocol.Overlay.InspectNodeRequestedEvent): void {
795+
inspectPanelShowRequested({backendNodeId}: Protocol.Overlay.InspectPanelShowRequestedEvent): void {
796+
this.dispatchEventToListeners(Events.INSPECT_PANEL_SHOW_REQUESTED, backendNodeId);
796797
}
797798

798-
inspectedElementWindowRestored(_event: Protocol.Overlay.InspectNodeRequestedEvent): void {
799+
inspectedElementWindowRestored({backendNodeId}: Protocol.Overlay.InspectedElementWindowRestoredEvent): void {
800+
this.dispatchEventToListeners(Events.INSPECTED_ELEMENT_WINDOW_RESTORED, backendNodeId);
799801
}
800802
}
801803

front_end/entrypoints/greendev_floaty/FloatyEntrypoint.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import '../../entrypoints/main/main-meta.js';
1212
import * as Common from '../../core/common/common.js';
1313
import * as Host from '../../core/host/host.js';
1414
import * as i18n from '../../core/i18n/i18n.js';
15+
import type * as Platform from '../../core/platform/platform.js';
1516
import type * as ExperimentNames from '../../core/root/ExperimentNames.js';
1617
import * as Root from '../../core/root/root.js';
1718
import * as SDK from '../../core/sdk/sdk.js';
@@ -81,8 +82,8 @@ class GreenDevFloaty {
8182
if (this.#node && this.#backendNodeId) {
8283
const msg = JSON.stringify({
8384
id: 9999,
84-
method: 'Overlay.setShowGreenDevFloatyAnchor',
85-
params: {greenDevFloatyHighlightConfig: {backendNodeId: this.#backendNodeId}}
85+
method: 'Overlay.setShowInspectedElementAnchor',
86+
params: {inspectedElementAnchorConfig: {backendNodeId: this.#backendNodeId}}
8687
});
8788
Host.InspectorFrontendHost.InspectorFrontendHostInstance.sendMessageToBackend(msg);
8889
}
@@ -147,15 +148,8 @@ class GreenDevFloaty {
147148
handlePanelRequest = (event: Common.EventTarget.EventTargetEvent<number>): void => {
148149
pendingActivationSessionId = event.data;
149150
this.#sendActivatePanelMessage(pendingActivationSessionId, 0);
150-
151-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
152-
if ((window as any).DevToolsAPI?.sendMessageToEmbedder) {
153-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
154-
(window as any).DevToolsAPI.sendMessageToEmbedder('openDevTools', [], () => {});
155-
} else {
156-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
157-
(Host.InspectorFrontendHost.InspectorFrontendHostInstance as any).sendMessageToEmbedder('openDevTools', []);
158-
}
151+
Host.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(
152+
'magic:open-devtools' as Platform.DevToolsPath.UrlString);
159153
};
160154

161155
readonly #maxActivationRetries = 10;
@@ -183,13 +177,16 @@ class GreenDevFloaty {
183177
}
184178

185179
handleRestoreEvent(event: Common.EventTarget.EventTargetEvent<number>): void {
180+
const sessionId = event.data;
186181
// Only the main DevTools window (which is NOT a floaty window) should broadcast the restore request.
187182
if (!this.#isFloatyWindow) {
188-
const sessionId = event.data;
189183
this.#syncChannel.postMessage({type: 'restore-floaty', sessionId});
184+
} else if (this.#backendNodeId === sessionId) {
185+
// If a floaty window receives a restore request for its own session,
186+
// it should bring itself to the front.
187+
console.error('[GreenDev] Calling bringToFront for session ' + sessionId);
188+
Host.InspectorFrontendHost.InspectorFrontendHostInstance.bringToFront();
190189
}
191-
// If a floaty window receives a restore request for its own session,
192-
// it should bring itself to the front. This is handled in #onSyncMessage.
193190
}
194191

195192
setNode(node: SDK.DOMModel.DOMNode): void {
@@ -228,8 +225,8 @@ class GreenDevFloaty {
228225
if (this.#backendNodeId) {
229226
const msg = JSON.stringify({
230227
id: 9999,
231-
method: 'Overlay.setShowGreenDevFloatyAnchor',
232-
params: {greenDevFloatyHighlightConfig: {backendNodeId: this.#backendNodeId}}
228+
method: 'Overlay.setShowInspectedElementAnchor',
229+
params: {inspectedElementAnchorConfig: {backendNodeId: this.#backendNodeId}}
233230
});
234231
Host.InspectorFrontendHost.InspectorFrontendHostInstance.sendMessageToBackend(msg);
235232
}

front_end/entrypoints/greendev_floaty/greendev_floaty.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class GreenDevFloaty {
6666
// Refresh the anchor by re-sending the show command.
6767
const msg = JSON.stringify({
6868
id: 9999,
69-
method: 'Overlay.setShowGreenDevFloatyAnchor',
70-
params: {greenDevFloatyHighlightConfig: {backendNodeId: this.#backendNodeId}}
69+
method: 'Overlay.setShowInspectedElementAnchor',
70+
params: {inspectedElementAnchorConfig: {backendNodeId: this.#backendNodeId}}
7171
});
7272
Host.InspectorFrontendHost.InspectorFrontendHostInstance.sendMessageToBackend(msg);
7373
}
@@ -403,8 +403,8 @@ async function init(): Promise<void> {
403403
if (backendNodeId) {
404404
const msg = JSON.stringify({
405405
id: 9999,
406-
method: 'Overlay.setShowGreenDevFloatyAnchor',
407-
params: {greenDevFloatyHighlightConfig: {backendNodeId}}
406+
method: 'Overlay.setShowInspectedElementAnchor',
407+
params: {inspectedElementAnchorConfig: {backendNodeId}}
408408
});
409409
Host.InspectorFrontendHost.InspectorFrontendHostInstance.sendMessageToBackend(msg);
410410
}

0 commit comments

Comments
 (0)