diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /devtools/client/debugger/src/utils | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/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`; } } |