From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../src/selectors/isSelectedFrameVisible.js | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 devtools/client/debugger/src/selectors/isSelectedFrameVisible.js (limited to 'devtools/client/debugger/src/selectors/isSelectedFrameVisible.js') diff --git a/devtools/client/debugger/src/selectors/isSelectedFrameVisible.js b/devtools/client/debugger/src/selectors/isSelectedFrameVisible.js new file mode 100644 index 0000000000..f4d42ccc1d --- /dev/null +++ b/devtools/client/debugger/src/selectors/isSelectedFrameVisible.js @@ -0,0 +1,37 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at . */ + +import { originalToGeneratedId } from "devtools/client/shared/source-map-loader/index"; +import { getSelectedLocation } from "./sources"; +import { getCurrentThread, getSelectedFrame } from "./pause"; + +function getGeneratedId(source) { + if (source.isOriginal) { + return originalToGeneratedId(source.id); + } + + return source.id; +} + +/* + * Checks to if the selected frame's source is currently + * selected. + */ +export function isSelectedFrameVisible(state) { + const thread = getCurrentThread(state); + const selectedLocation = getSelectedLocation(state); + const selectedFrame = getSelectedFrame(state, thread); + + if (!selectedFrame || !selectedLocation) { + return false; + } + + if (selectedLocation.source.isOriginal) { + return selectedLocation.source.id === selectedFrame.location.source.id; + } + + return ( + selectedLocation.source.id === getGeneratedId(selectedFrame.location.source) + ); +} -- cgit v1.2.3