Skip to content

Commit

Permalink
Update sidebar to 1.0.3.
Browse files Browse the repository at this point in the history
* Fix "Autohide" behavior of the Waterfox Sidebar for full screen mode
    It was caused by the difference of the spec of -moz-bool-pref between ESR115 and ESR128. Now codes have been renewed for ESR128.
* Fix an error opening option page
    It failed to run the initializer function on some cases. Now the initializer is retried with delay.
* Fix "Bookmark Selected Tabs" command
    It was caused by the difference of the Places modules between ESR115 and ESR128. Now codes have been renewed for ESR128.
* Fix Tab preview feature with browser.tabs.hoverPreview.enabled=true
    It was largely reconstructured on Firefox, thus I've updated codes for the current implementation.
* Fix behavior of F1 key not to toggle the Waterfox Sidebar
    It happened when the "key" XUL element is re-inserted dynamically. Now the first inserted element is reused after reinstallation of the sidebar module.
* Fix the behavior of "Reset to default" operation in the toolbar customization
    It was caused by an unhandled error in Firefox's toolbar customization module. I've implemented a mechanism to reset toolbar customizations until insertion of the tabs sidebar button succeed.
  • Loading branch information
MrAlex94 committed Sep 23, 2024
1 parent 724c888 commit 94020c2
Show file tree
Hide file tree
Showing 52 changed files with 1,653 additions and 1,046 deletions.
3 changes: 3 additions & 0 deletions waterfox/browser/components/sidebar/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@
"config_groupTabTemporaryStateForNewTabsFromBookmarks_label": { "message": "For tabs opened from bookmarks:" },
"config_groupTabTemporaryStateForNewTabsFromOthers_label": { "message": "For tabs opened at a time from non-bookmark triggers:" },
"config_groupTabTemporaryStateForOrphanedTabs_label": { "message": "Opened to replace a closed parent tab:" },
"config_groupTabTemporaryStateForAPI_label": { "message": "Opened to group tabs from other addons via API:" },

"config_inheritContextualIdentityToChildTabMode_label": { "message": "Container:" },
"config_inheritContextualIdentityToChildTabMode_default": { "message": "(no control)" },
Expand Down Expand Up @@ -730,6 +731,7 @@
"config_insertDroppedTabsAt_first": { "message": "The top of the tree (next to the parent)" },
"config_insertDroppedTabsAt_end": { "message": "The end of the tree" },

"config_autoCreateFolderForBookmarksFromTree_label": { "message": "Auto-group bookmark items under a folder when they are guessed to be created from multiple tree item tabs (ex. drag and drop of multiselected tabs)" },
"config_autoExpandOnLongHoverDelay_before": { "message": "Expand collapsed tree with hovering over " },
"config_autoExpandOnLongHoverDelay_after": { "message": "msec while dragging" },
"config_autoExpandOnLongHoverRestoreIniitalState_label": { "message": "Collapse such trees automatically after a drag action is finished" },
Expand Down Expand Up @@ -892,6 +894,7 @@
"tabContextMenu_shareTabURL_more_label": { "message": "More…" },


"tabContextMenu_closeDuplicatedTabs_label": { "message": "Close D&uplicate Tabs" },
"tabContextMenu_closeMultipleTabs_label": { "message": "Close &Multiple Tabs" },
"tabContextMenu_closeTabsToTop_label": { "message": "Close Tabs to the &Top" },
"tabContextMenu_closeTabsToBottom_label": { "message": "Close Tabs to the &Bottom" },
Expand Down
3 changes: 3 additions & 0 deletions waterfox/browser/components/sidebar/_locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@
"config_groupTabTemporaryStateForNewTabsFromBookmarks_label": { "message": "ブックマークから開かれたタブをグループ化した場合:" },
"config_groupTabTemporaryStateForNewTabsFromOthers_label": { "message": "ブックマーク以外から連続して開かれたタブをグループ化した場合:" },
"config_groupTabTemporaryStateForOrphanedTabs_label": { "message": "閉じられた親タブを置き換える形で開かれた場合:" },
"config_groupTabTemporaryStateForAPI_label": { "message": "他の拡張機能からAPI経由でタブをグループ化した場合:" },

"config_inheritContextualIdentityToChildTabMode_label": { "message": "コンテナー:" },
"config_inheritContextualIdentityToChildTabMode_default": { "message": "(制御しない)" },
Expand Down Expand Up @@ -727,6 +728,7 @@
"config_insertDroppedTabsAt_first": { "message": "ツリーの先頭(親タブの隣)" },
"config_insertDroppedTabsAt_end": { "message": "ツリーの末尾" },

"config_autoCreateFolderForBookmarksFromTree_label": { "message": "ツリー構造を持ったタブを複数選択してのドラッグ&ドロップなどの操作で複数のブックマークが作成されたと推測できる場合に、作成されたブックマークを自動的に1つのフォルダーにまとめる" },
"config_autoExpandOnLongHoverDelay_before": { "message": "ドラッグ操作中、折りたたまれたツリーの上で" },
"config_autoExpandOnLongHoverDelay_after": { "message": "ミリ秒以上経過したらツリーを展開する" },
"config_autoExpandOnLongHoverRestoreIniitalState_label": { "message": "ドラッグ操作の終了後、ツリーを折りたたんだ状態に自動的に戻す" },
Expand Down Expand Up @@ -888,6 +890,7 @@
"tabContextMenu_shareTabURL_label": { "message": "共有(&H)" },
"tabContextMenu_shareTabURL_more_label": { "message": "その他..." },

"tabContextMenu_closeDuplicatedTabs_label": { "message": "重複タブを閉じる(&U)" },
"tabContextMenu_closeMultipleTabs_label": { "message": "複数のタブを閉じる(&M)" },
"tabContextMenu_closeTabsToTop_label": { "message": "上のタブをすべて閉じる(&T)" },
"tabContextMenu_closeTabsToBottom_label": { "message": "下のタブをすべて閉じる(&B)" },
Expand Down
89 changes: 47 additions & 42 deletions waterfox/browser/components/sidebar/background/api-tabs-listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,12 @@ async function onActivated(activeInfo) {
try {
const win = Window.init(activeInfo.windowId);

const byInternalOperation = win.internalFocusCount > 0;
if (byInternalOperation)
win.internalFocusCount--;
const byMouseOperation = win.internalByMouseFocusCount > 0;
if (byMouseOperation)
win.internalByMouseFocusCount--;
const silently = win.internalSilentlyFocusCount > 0;
if (silently)
win.internalSilentlyFocusCount--;
const byInternalOperation = win.internallyFocusingTabs.has(activeInfo.tabId);
win.internallyFocusingTabs.delete(activeInfo.tabId);
const byMouseOperation = win.internallyFocusingByMouseTabs.has(activeInfo.tabId);
win.internallyFocusingByMouseTabs.delete(activeInfo.tabId);
const silently = win.internallyFocusingSilentlyTabs.has(activeInfo.tabId);
win.internallyFocusingSilentlyTabs.delete(activeInfo.tabId);
const byTabDuplication = parseInt(win.duplicatingTabsCount) > 0;

if (!Tab.isTracked(activeInfo.tabId))
Expand Down Expand Up @@ -272,6 +269,7 @@ async function onUpdated(tabId, changeInfo, tab) {
}
}
/*
Workaround for Firefox 130 and olders.
Updated openerTabId is not notified via tabs.onUpdated due to
https://bugzilla.mozilla.org/show_bug.cgi?id=1409262 , so it can be
notified with delay as a part of the complete tabs.Tab object,
Expand All @@ -284,8 +282,11 @@ async function onUpdated(tabId, changeInfo, tab) {
continue;
if ('key' in updatedTab)
oldState[key] = updatedTab[key];
if (key == 'openerTabId')
if (key == 'openerTabId') {
if (changeInfo.openerTabId == updatedTab.openerTabId) // already processed
continue;
log(`openerTabId of ${tabId} is changed by someone (notified via changeInfo)!: ${updatedTab.openerTabId} (original) => ${changeInfo[key]} (changed by someone)`, configs.debug && new Error().stack);
}
updatedTab[key] = changeInfo[key];
}
if (changeInfo.url ||
Expand Down Expand Up @@ -788,10 +789,8 @@ async function onNewTabTracked(tab, info) {
}

tab.$TST.memorizeNeighbors('newly tracked');
if (tab.$TST.unsafePreviousTab)
tab.$TST.unsafePreviousTab.$TST.memorizeNeighbors('unsafePreviousTab');
if (tab.$TST.unsafeNextTab)
tab.$TST.unsafeNextTab.$TST.memorizeNeighbors('unsafeNextTab');
tab.$TST.unsafePreviousTab?.$TST?.memorizeNeighbors('unsafePreviousTab');
tab.$TST.unsafeNextTab?.$TST?.memorizeNeighbors('unsafeNextTab');

Tree.onAttached.removeListener(onTreeModified);
metric.add('Tree.onAttached proceeded');
Expand Down Expand Up @@ -839,11 +838,18 @@ async function onRemoved(tabId, removeInfo) {
log('tabs.onRemoved: ', tabId, removeInfo);
const win = Window.init(removeInfo.windowId);
const byInternalOperation = win.internalClosingTabs.has(tabId);
if (byInternalOperation)
win.internalClosingTabs.delete(tabId);
const preventEntireTreeBehavior = win.keepDescendantsTabs.has(tabId);
if (preventEntireTreeBehavior)
win.keepDescendantsTabs.delete(tabId);

win.internalMovingTabs.delete(tabId);
win.alreadyMovedTabs.delete(tabId);
win.internalClosingTabs.delete(tabId);
win.keepDescendantsTabs.delete(tabId);
win.highlightingTabs.delete(tabId);
win.tabsToBeHighlightedAlone.delete(tabId);

win.internallyFocusingTabs.delete(tabId);
win.internallyFocusingByMouseTabs.delete(tabId);
win.internallyFocusingSilentlyTabs.delete(tabId);

if (Tab.needToWaitTracked(removeInfo.windowId))
await Tab.waitUntilTrackedAll(removeInfo.windowId);
Expand Down Expand Up @@ -925,9 +931,7 @@ async function onRemoved(tabId, removeInfo) {
oldTab.$TST.destroy();

for (const tab of nearestTabs) {
if (!tab || !tab.$TST)
continue;
tab.$TST.memorizeNeighbors('neighbor of closed tab');
tab?.$TST?.memorizeNeighbors('neighbor of closed tab');
}

onCompleted();
Expand Down Expand Up @@ -956,7 +960,10 @@ async function onMoved(tabId, moveInfo) {
// and other fixup operations around tabs moved by foreign triggers, on such
// cases. Don't mind, the tab will be rearranged again by delayed
// TabsMove.syncTabsPositionToApiTabs() anyway!
const maybeInternalOperation = win.internalMovingTabs.has(tabId);
const internalExpectedIndex = win.internalMovingTabs.get(tabId);
const maybeInternalOperation = internalExpectedIndex < 0 || internalExpectedIndex == moveInfo.toIndex;
if (maybeInternalOperation)
log(`tabs.onMoved: ${tabId} is detected as moved internally`);

if (!Tab.isTracked(tabId))
await Tab.waitUntilTracked(tabId);
Expand All @@ -979,7 +986,7 @@ async function onMoved(tabId, moveInfo) {
do following processes after the tab is completely pinned. */
const movedTab = Tab.get(tabId);
if (!movedTab) {
if (maybeInternalOperation)
if (win.internalMovingTabs.has(tabId))
win.internalMovingTabs.delete(tabId);
completelyMoved();
warnTabDestroyedWhileWaiting(tabId, movedTab);
Expand All @@ -989,30 +996,32 @@ async function onMoved(tabId, moveInfo) {
let oldPreviousTab = movedTab.hidden ? movedTab.$TST.unsafePreviousTab : movedTab.$TST.previousTab;
let oldNextTab = movedTab.hidden ? movedTab.$TST.unsafeNextTab : movedTab.$TST.nextTab;
if (movedTab.index != moveInfo.toIndex ||
(oldPreviousTab && oldPreviousTab.index == movedTab.index - 1) ||
(oldNextTab && oldNextTab.index == movedTab.index + 1)) {
(oldPreviousTab?.index == movedTab.index - 1) ||
(oldNextTab?.index == movedTab.index + 1)) {
// already moved
oldPreviousTab = Tab.getTabAt(moveInfo.windowId, moveInfo.toIndex < moveInfo.fromIndex ? moveInfo.fromIndex : moveInfo.fromIndex - 1);
oldNextTab = Tab.getTabAt(moveInfo.windowId, moveInfo.toIndex < moveInfo.fromIndex ? moveInfo.fromIndex + 1 : moveInfo.fromIndex);
if (oldPreviousTab && oldPreviousTab.id == movedTab.id)
if (oldPreviousTab?.id == movedTab.id)
oldPreviousTab = Tab.getTabAt(moveInfo.windowId, moveInfo.toIndex < moveInfo.fromIndex ? moveInfo.fromIndex - 1 : moveInfo.fromIndex - 2);
if (oldNextTab && oldNextTab.id == movedTab.id)
if (oldNextTab?.id == movedTab.id)
oldNextTab = Tab.getTabAt(moveInfo.windowId, moveInfo.toIndex < moveInfo.fromIndex ? moveInfo.fromIndex : moveInfo.fromIndex - 1);
}

let alreadyMoved = false;
if (win.alreadyMovedTabs.has(tabId)) {
const expectedIndex = win.alreadyMovedTabs.get(tabId);
const alreadyMoved = expectedIndex < 0 || expectedIndex == moveInfo.toIndex;
if (win.alreadyMovedTabs.has(tabId))
win.alreadyMovedTabs.delete(tabId);
alreadyMoved = true;
}

const extendedMoveInfo = {
...moveInfo,
byInternalOperation: maybeInternalOperation,
alreadyMoved,
oldPreviousTab,
oldNextTab,
isSubstantiallyMoved: movedTab.$TST.isSubstantiallyMoved
// Multiselected tabs can be moved together in bulk, by drag and drop
// in the horizontal tab bar, or addons like
// https://addons.mozilla.org/firefox/addon/move-tab-hotkeys/
movedInBulk: !maybeInternalOperation && (movedTab.$TST.multiselected || movedTab.$TST.movedInBulk),
};
log('tabs.onMoved: ', movedTab, extendedMoveInfo);

Expand Down Expand Up @@ -1060,20 +1069,16 @@ async function onMoved(tabId, moveInfo) {
nextTabId: nextTab && nextTab.id
});
}
if (maybeInternalOperation)
if (win.internalMovingTabs.has(tabId))
win.internalMovingTabs.delete(tabId);
completelyMoved();

movedTab.$TST.memorizeNeighbors('moved');
if (movedTab.$TST.unsafePreviousTab)
movedTab.$TST.unsafePreviousTab.$TST.memorizeNeighbors('unsafePreviousTab');
if (movedTab.$TST.unsafeNextTab)
movedTab.$TST.unsafeNextTab.$TST.memorizeNeighbors('unsafeNextTab');

if (oldPreviousTab)
oldPreviousTab.$TST.memorizeNeighbors('oldPreviousTab');
if (oldNextTab)
oldNextTab.$TST.memorizeNeighbors('oldNextTab');
movedTab.$TST.unsafePreviousTab?.$TST?.memorizeNeighbors('unsafePreviousTab');
movedTab.$TST.unsafeNextTab?.$TST?.memorizeNeighbors('unsafeNextTab');

oldPreviousTab?.$TST?.memorizeNeighbors('oldPreviousTab');
oldNextTab?.$TST?.memorizeNeighbors('oldNextTab');
}
catch(e) {
console.log(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ async function updateWindowCache(owner, key, value) {
});
return;
}
catch(_error) {
catch(error) {
console.log(`BackgroundCache.updateWindowCache for ${owner.windowId}/${key} failed: `, error.message, error.stack, error);
}
}

Expand Down Expand Up @@ -372,7 +373,8 @@ async function getWindowCache(owner, key) {
});
return value;
}
catch(_error) {
catch(error) {
console.log(`BackgroundCache.getWindowCache for ${owner.windowId}/${key} failed: `, error.message, error.stack, error);
}
}

Expand Down
15 changes: 13 additions & 2 deletions waterfox/browser/components/sidebar/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,23 @@ async function rebuildAll(windows) {
try {
log(`build tabs for ${win.id} from scratch`);
Window.init(win.id);
const promises = [];
for (let tab of win.tabs) {
tab = Tab.get(tab.id);
tab.$TST.clear(); // clear dirty restored states
TabsUpdate.updateTab(tab, tab, { forceApply: true });
promises.push(
tab.$TST.getPermanentStates()
.then(states => {
tab.$TST.states = new Set(states);
})
.catch(console.error)
.then(() => {
TabsUpdate.updateTab(tab, tab, { forceApply: true });
})
);
tryStartHandleAccelKeyOnTab(tab);
}
await Promise.all(promises);
}
catch(e) {
log(`failed to build tabs for ${win.id}`, e);
Expand Down Expand Up @@ -774,7 +785,7 @@ Tab.onTabInternallyMoved.addListener((tab, info = {}) => {
});

Tab.onMoved.addListener((tab, moveInfo) => {
if (!moveInfo.isSubstantiallyMoved)
if (moveInfo.movedInBulk)
return;
reserveToUpdateInsertionPosition([
tab,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1298,8 +1298,32 @@ const mItems = [
type: 'radio'
}
]
}
]
},
{
title: indent() + browser.i18n.getMessage('config_groupTabTemporaryStateForAPI_label'),
expert: true,
children: [
{
title: browser.i18n.getMessage('config_groupTabTemporaryState_option_default'),
key: 'groupTabTemporaryStateForAPI',
value: Constants.kGROUP_TAB_TEMPORARY_STATE_NOTHING,
type: 'radio'
},
{
title: `${browser.i18n.getMessage('config_groupTabTemporaryState_option_checked_before')}${browser.i18n.getMessage('groupTab_temporary_label')}${browser.i18n.getMessage('config_groupTabTemporaryState_option_checked_after')}`,
key: 'groupTabTemporaryStateForAPI',
value: Constants.kGROUP_TAB_TEMPORARY_STATE_PASSIVE,
type: 'radio'
},
{
title: `${browser.i18n.getMessage('config_groupTabTemporaryState_option_checked_before')}${browser.i18n.getMessage('groupTab_temporaryAggressive_label')}${browser.i18n.getMessage('config_groupTabTemporaryState_option_checked_after')}`,
key: 'groupTabTemporaryStateForAPI',
value: Constants.kGROUP_TAB_TEMPORARY_STATE_AGGRESSIVE,
type: 'radio'
},
],
},
],
},
{
title: browser.i18n.getMessage('config_treeBehavior_caption'),
Expand Down
Loading

0 comments on commit 94020c2

Please sign in to comment.