diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /devtools/client/debugger/src/reducers | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/src/reducers')
-rw-r--r-- | devtools/client/debugger/src/reducers/sources-tree.js | 26 | ||||
-rw-r--r-- | devtools/client/debugger/src/reducers/sources.js | 13 | ||||
-rw-r--r-- | devtools/client/debugger/src/reducers/ui.js | 3 |
3 files changed, 31 insertions, 11 deletions
diff --git a/devtools/client/debugger/src/reducers/sources-tree.js b/devtools/client/debugger/src/reducers/sources-tree.js index 0f0e8dadb3..ee8a8d0ca0 100644 --- a/devtools/client/debugger/src/reducers/sources-tree.js +++ b/devtools/client/debugger/src/reducers/sources-tree.js @@ -25,6 +25,11 @@ const IGNORED_EXTENSIONS = ["css", "svg", "png"]; import { isPretty, getRawSourceURL } from "../utils/source"; import { prefs } from "../utils/prefs"; +const lazy = {}; +ChromeUtils.defineESModuleGetters(lazy, { + BinarySearch: "resource://gre/modules/BinarySearch.sys.mjs", +}); + export function initialSourcesTreeState() { return { // List of all Thread Tree Items. @@ -224,8 +229,10 @@ function addThread(state, thread) { // (this is also used by sortThreadItems to sort the thread as a Tree in the Browser Toolbox) threadItem.thread = thread; - // We have to re-sort all threads because of the new `thread` attribute on current thread item - state.threadItems.sort(sortThreadItems); + // We have to remove and re-insert the thread as its order will be based on the newly set `thread` attribute + state.threadItems = [...state.threadItems]; + state.threadItems.splice(state.threadItems.indexOf(threadItem), 1); + addSortedItem(state.threadItems, threadItem, sortThreadItems); } } @@ -303,13 +310,12 @@ function isSourceVisibleInSourceTree( * The already sorted into which a value should be added. * @param {any} newValue * The value to add in the array while keeping the array sorted. - * @param {Function} sortFunction + * @param {Function} comparator * A function to compare two array values and their ordering. * Follow same behavior as Array sorting function. */ -function addSortedItem(array, newValue, sortFunction) { - let index = array.findIndex(value => sortFunction(value, newValue) === 1); - index = index >= 0 ? index : array.length; +function addSortedItem(array, newValue, comparator) { + const index = lazy.BinarySearch.insertionIndexOf(comparator, array, newValue); array.splice(index, 0, newValue); } @@ -396,12 +402,12 @@ function sortItems(a, b) { return -1; } else if (b.type == "directory" && a.type == "source") { return 1; + } else if (a.type == "group" && b.type == "group") { + return a.groupName.localeCompare(b.groupName); } else if (a.type == "directory" && b.type == "directory") { return a.path.localeCompare(b.path); } else if (a.type == "source" && b.type == "source") { - return a.source.displayURL.filename.localeCompare( - b.source.displayURL.filename - ); + return a.source.longName.localeCompare(b.source.longName); } return 0; } @@ -447,7 +453,7 @@ function sortThreadItems(a, b) { if (a.thread.processID > b.thread.processID) { return 1; } else if (a.thread.processID < b.thread.processID) { - return 0; + return -1; } // Order the frame targets and the worker targets by their target name diff --git a/devtools/client/debugger/src/reducers/sources.js b/devtools/client/debugger/src/reducers/sources.js index 76160b75f2..6d90fd5c91 100644 --- a/devtools/client/debugger/src/reducers/sources.js +++ b/devtools/client/debugger/src/reducers/sources.js @@ -182,6 +182,19 @@ function update(state = initialSourcesState(), action) { }; } + case "SET_DEFAULT_SELECTED_LOCATION": { + if ( + state.shouldSelectOriginalLocation == + action.shouldSelectOriginalLocation + ) { + return state; + } + return { + ...state, + shouldSelectOriginalLocation: action.shouldSelectOriginalLocation, + }; + } + case "SET_PENDING_SELECTED_LOCATION": { const pendingSelectedLocation = { url: action.url, diff --git a/devtools/client/debugger/src/reducers/ui.js b/devtools/client/debugger/src/reducers/ui.js index 7f37d2f54f..3544b3aa5c 100644 --- a/devtools/client/debugger/src/reducers/ui.js +++ b/devtools/client/debugger/src/reducers/ui.js @@ -63,6 +63,7 @@ export const initialUIState = () => ({ }, projectSearchQuery: "", hideIgnoredSources: prefs.hideIgnoredSources, + sourceMapsEnabled: prefs.clientSourceMapsEnabled, sourceMapIgnoreListEnabled: prefs.sourceMapIgnoreListEnabled, }); @@ -93,7 +94,7 @@ function update(state = initialUIState(), action) { case "TOGGLE_SOURCE_MAPS_ENABLED": { prefs.clientSourceMapsEnabled = action.value; - return { ...state }; + return { ...state, sourceMapsEnabled: action.value }; } case "SET_ORIENTATION": { |