diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:50 +0000 |
commit | def92d1b8e9d373e2f6f27c366d578d97d8960c6 (patch) | |
tree | 2ef34b9ad8bb9a9220e05d60352558b15f513894 /devtools/client/debugger/src/utils | |
parent | Adding debian version 125.0.3-1. (diff) | |
download | firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.tar.xz firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/src/utils')
4 files changed, 28 insertions, 7 deletions
diff --git a/devtools/client/debugger/src/utils/editor/index.js b/devtools/client/debugger/src/utils/editor/index.js index d12e2f29f1..e729388acf 100644 --- a/devtools/client/debugger/src/utils/editor/index.js +++ b/devtools/client/debugger/src/utils/editor/index.js @@ -11,6 +11,7 @@ import { createEditor } from "./create-editor"; import { isWasm, lineToWasmOffset, wasmOffsetToLine } from "../wasm"; import { createLocation } from "../location"; +import { features } from "../prefs"; let editor; @@ -65,6 +66,10 @@ export function toEditorLine(sourceId, lineOrOffset) { return wasmOffsetToLine(sourceId, lineOrOffset) || 0; } + if (features.codemirrorNext) { + return lineOrOffset; + } + return lineOrOffset ? lineOrOffset - 1 : 1; } @@ -73,6 +78,10 @@ export function fromEditorLine(sourceId, line, sourceIsWasm) { return lineToWasmOffset(sourceId, line) || 0; } + if (features.codemirrorNext) { + return line; + } + return line + 1; } @@ -88,7 +97,13 @@ export function toEditorPosition(location) { } export function toSourceLine(sourceId, line) { - return isWasm(sourceId) ? lineToWasmOffset(sourceId, line) : line + 1; + if (isWasm(sourceId)) { + return lineToWasmOffset(sourceId, line); + } + if (features.codemirrorNext) { + return line; + } + return line + 1; } export function scrollToPosition(codeMirror, line, column) { diff --git a/devtools/client/debugger/src/utils/editor/source-documents.js b/devtools/client/debugger/src/utils/editor/source-documents.js index 53ee4f2f35..cc9f44d82a 100644 --- a/devtools/client/debugger/src/utils/editor/source-documents.js +++ b/devtools/client/debugger/src/utils/editor/source-documents.js @@ -4,7 +4,11 @@ import { isWasm, getWasmLineNumberFormatter, renderWasmText } from "../wasm"; import { isMinified } from "../isMinified"; -import { resizeBreakpointGutter, resizeToggleButton } from "../ui"; +import { + resizeBreakpointGutter, + resizeToggleButton, + getLineNumberWidth, +} from "../ui"; import { javascriptLikeExtensions } from "../source"; const sourceDocs = new Map(); @@ -39,7 +43,7 @@ export function resetLineNumberFormat(editor) { const cm = editor.codeMirror; cm.setOption("lineNumberFormatter", number => number); resizeBreakpointGutter(cm); - resizeToggleButton(cm); + resizeToggleButton(getLineNumberWidth(cm)); } function updateLineNumberFormat(editor, sourceId) { @@ -51,7 +55,7 @@ function updateLineNumberFormat(editor, sourceId) { const lineNumberFormatter = getWasmLineNumberFormatter(sourceId); cm.setOption("lineNumberFormatter", lineNumberFormatter); resizeBreakpointGutter(cm); - resizeToggleButton(cm); + resizeToggleButton(getLineNumberWidth(cm)); } const contentTypeModeMap = new Map([ diff --git a/devtools/client/debugger/src/utils/editor/tokens.js b/devtools/client/debugger/src/utils/editor/tokens.js index f8783c02fe..3c6875f9cd 100644 --- a/devtools/client/debugger/src/utils/editor/tokens.js +++ b/devtools/client/debugger/src/utils/editor/tokens.js @@ -50,6 +50,8 @@ function _isInvalidTarget(target) { target.closest(".CodeMirror-widget") || // exclude in-line "empty" space, as well as the gutter target.matches(".CodeMirror-line, .CodeMirror-gutter-elt") || + // exclude items that are not in a line + !target.closest(".CodeMirror-line") || target.getBoundingClientRect().top == 0 ) { return true; diff --git a/devtools/client/debugger/src/utils/ui.js b/devtools/client/debugger/src/utils/ui.js index eab5bb1e07..3ad221f465 100644 --- a/devtools/client/debugger/src/utils/ui.js +++ b/devtools/client/debugger/src/utils/ui.js @@ -38,11 +38,11 @@ export function resizeBreakpointGutter(editor) { * Forces the left toggle button in source header to be the same size * as the line numbers gutter. */ -export function resizeToggleButton(editor) { +export function resizeToggleButton(newSize) { const toggleButton = document.querySelector( - ".source-header .toggle-button-start" + ".source-header .toggle-button.start" ); if (toggleButton) { - toggleButton.style.width = `${getLineNumberWidth(editor)}px`; + toggleButton.style.width = `${newSize}px`; } } |