Skip to content

Commit

Permalink
Use the variable name "window" only for DOMWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Feb 2, 2024
1 parent 15c9505 commit 1022cb3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion webextensions/background/background-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export async function reserveToCacheTree(windowId) {
return;

const win = TabsStore.windows.get(windowId);
if (!window)
if (!win)
return;

// If there is any opening (but not resolved its unique id yet) tab,
Expand Down
16 changes: 8 additions & 8 deletions webextensions/background/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,11 @@ export async function moveTabsWithStructure(tabs, params = {}) {
}

if (params.import) {
const window = TabsStore.windows.get(destinationWindowId);
const win = TabsStore.windows.get(destinationWindowId);
const initialIndex = params.insertBefore ? params.insertBefore.index :
params.insertAfter ? params.insertAfter.index+1 :
window.tabs.size;
window.toBeOpenedOrphanTabs += tabs.length;
win.tabs.size;
win.toBeOpenedOrphanTabs += tabs.length;
movedTabs = [];
let index = 0;
for (const tab of tabs) {
Expand Down Expand Up @@ -919,8 +919,8 @@ export async function openTabInWindow(tab, options = {}) {
tabId: tab.id,
...getWindowParamsFromSource(sourceWindow, options),
};
const window = await browser.windows.create(windowParams).catch(ApiTabs.createErrorHandler());
return window.id;
const win = await browser.windows.create(windowParams).catch(ApiTabs.createErrorHandler());
return win.id;
}
}

Expand Down Expand Up @@ -1286,9 +1286,9 @@ Sync.onMessage.addListener(async message => {
});

const windowId = TabsStore.getCurrentWindowId() || (await browser.windows.getCurrent()).id;
const window = TabsStore.windows.get(windowId);
const initialIndex = window.tabs.size;
window.toBeOpenedOrphanTabs += data.tabs.length;
const win = TabsStore.windows.get(windowId);
const initialIndex = win.tabs.size;
win.toBeOpenedOrphanTabs += data.tabs.length;
let index = 0;
const tabs = [];
for (const tab of data.tabs) {
Expand Down
28 changes: 14 additions & 14 deletions webextensions/common/tabs-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ export function queryAll(query) {
const startAt = Date.now();
if (query.windowId || query.ordered) {
let tabs = [];
for (const window of windows.values()) {
if (query.windowId && !matched(window.id, query.windowId))
for (const win of windows.values()) {
if (query.windowId && !matched(win.id, query.windowId))
continue;
const [sourceTabs, offset] = sourceTabsForQuery(query, window);
const [sourceTabs, offset] = sourceTabsForQuery(query, win);
tabs = tabs.concat(query.iterator ? getMatchedTabsIterator(sourceTabs, query, offset) : extractMatchedTabs(sourceTabs, query, offset));
}
query.elapsed = Date.now() - startAt;
Expand All @@ -106,30 +106,30 @@ export function queryAll(query) {
}
}

function sourceTabsForQuery(query, window) {
function sourceTabsForQuery(query, win) {
let offset = 0;
if (!query.ordered)
return [query.tabs && query.tabs.values() || window.tabs.values(), offset];
return [query.tabs && query.tabs.values() || win.tabs.values(), offset];
let fromId;
let toId = query.toId;
if (typeof query.index == 'number') {
fromId = window.order[query.index];
fromId = win.order[query.index];
offset = query.index;
}
if (typeof query.fromIndex == 'number') {
fromId = window.order[query.fromIndex];
fromId = win.order[query.fromIndex];
offset = query.fromIndex;
}
if (typeof query.toIndex == 'number') {
toId = window.order[query.toIndex];
toId = win.order[query.toIndex];
}
if (typeof fromId != 'number') {
fromId = query.fromId;
offset = window.order.indexOf(query.fromId);
offset = win.order.indexOf(query.fromId);
}
if (query.last || query.reversed)
return [window.getReversedOrderedTabs(fromId, toId, query.tabs), offset];
return [window.getOrderedTabs(fromId, toId, query.tabs), offset];
return [win.getReversedOrderedTabs(fromId, toId, query.tabs), offset];
return [win.getOrderedTabs(fromId, toId, query.tabs), offset];
}

function extractMatchedTabs(tabs, query, offset) {
Expand Down Expand Up @@ -283,10 +283,10 @@ export function query(query) {
const startAt = Date.now();
let tabs = [];
if (query.windowId || query.ordered) {
for (const window of windows.values()) {
if (query.windowId && !matched(window.id, query.windowId))
for (const win of windows.values()) {
if (query.windowId && !matched(win.id, query.windowId))
continue;
const [sourceTabs, offset] = sourceTabsForQuery(query, window);
const [sourceTabs, offset] = sourceTabsForQuery(query, win);
tabs = tabs.concat(extractMatchedTabs(sourceTabs, query, offset));
if (tabs.length > 0)
break;
Expand Down
4 changes: 2 additions & 2 deletions webextensions/sidebar/gap-canceller.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ function updateOffset() {
}
mLastWindowDimension = dimension;
mLastMozInnerScreenY = window.mozInnerScreenY;
browser.windows.get(mWindowId).then(window => {
mDataset.ownerWindowState = window.state;
browser.windows.get(mWindowId).then(win => {
mDataset.ownerWindowState = win.state;
});
}

Expand Down

0 comments on commit 1022cb3

Please sign in to comment.