Skip to content

Commit

Permalink
merge n clench (central)
Browse files Browse the repository at this point in the history
  • Loading branch information
i3roly committed Sep 3, 2024
2 parents 0749043 + 3591e24 commit 49606c4
Show file tree
Hide file tree
Showing 279 changed files with 6,815 additions and 3,275 deletions.
11 changes: 3 additions & 8 deletions browser/base/content/browser-box.inc.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@
<browser id="sidebar" autoscroll="false" disablehistory="true" disablefullscreen="true" tooltip="aHTMLTooltip"/>
</vbox>
<splitter id="sidebar-splitter" class="chromeclass-extrachrome sidebar-splitter" resizebefore="sibling" resizeafter="none" hidden="true"/>
<vbox id="appcontent" flex="1">
<!-- gNotificationBox will be added here lazily. -->
<tabbox id="tabbrowser-tabbox"
flex="1" tabcontainer="tabbrowser-tabs">
<tabpanels id="tabbrowser-tabpanels"
flex="1" selectedIndex="0"/>
</tabbox>
</vbox>
<tabbox id="tabbrowser-tabbox" flex="1" tabcontainer="tabbrowser-tabs">
<tabpanels id="tabbrowser-tabpanels" flex="1" selectedIndex="0"/>
</tabbox>
</hbox>
5 changes: 3 additions & 2 deletions browser/base/content/test/performance/browser_tabclose.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ add_task(async function () {
AppConstants.DEBUG &&
// In the content area
r.y1 >=
document.getElementById("appcontent").getBoundingClientRect()
.top,
document
.getElementById("tabbrowser-tabbox")
.getBoundingClientRect().top,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ add_task(async function () {
condition: r =>
// In the content area
r.y1 >=
document.getElementById("appcontent").getBoundingClientRect().top,
document.getElementById("tabbrowser-tabbox").getBoundingClientRect()
.top,
},
],
};
Expand Down
5 changes: 3 additions & 2 deletions browser/base/content/test/performance/browser_tabswitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ add_task(async function () {
AppConstants.DEBUG &&
// In the content area
r.y1 >=
document.getElementById("appcontent").getBoundingClientRect()
.top,
document
.getElementById("tabbrowser-tabbox")
.getBoundingClientRect().top,
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions browser/base/content/test/sidebar/browser_sidebar_move.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ const EXPECTED_START_ORDINALS = [
["sidebar-main", 1],
["sidebar-box", 2],
["sidebar-splitter", 3],
["appcontent", 4],
["tabbrowser-tabbox", 4],
];

const EXPECTED_END_ORDINALS = [
["sidebar-main", 5],
["sidebar-box", 4],
["sidebar-splitter", 3],
["appcontent", 2],
["tabbrowser-tabbox", 2],
];

function getBrowserChildrenWithOrdinals() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,8 @@ add_task(async function test_createRegionWithKeyboard() {
} else {
const sidebar = document.querySelector("sidebar-main");
const sidebarWidth = sidebar.offsetWidth;
// Add 1 to account for #appcontent border
window100X =
(100 + window.mozInnerScreenX + sidebarWidth + 1) *
(100 + window.mozInnerScreenX + sidebarWidth) *
window.devicePixelRatio;
}
const contentTop =
Expand Down Expand Up @@ -458,9 +457,8 @@ add_task(async function test_createRegionWithKeyboardWithShift() {
} else {
const sidebar = document.querySelector("sidebar-main");
const sidebarWidth = sidebar.offsetWidth;
// Add 1 to account for #appcontent border
window100X =
(100 + window.mozInnerScreenX + sidebarWidth + 1) *
(100 + window.mozInnerScreenX + sidebarWidth) *
window.devicePixelRatio;
}
const contentTop =
Expand Down
12 changes: 8 additions & 4 deletions browser/components/search/SearchOneOffs.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,9 @@ export class SearchOneOffs {
}

if (!this.textbox.value) {
if (event.shiftKey) {
this.popup.openSearchForm(event, engine);
}
return;
}
// Select the clicked button so that consumers can easily tell which
Expand Down Expand Up @@ -1014,13 +1017,14 @@ export class SearchOneOffs {
}

if (target.classList.contains("search-one-offs-context-open-in-new-tab")) {
if (!this.textbox.value) {
return;
}
// Select the context-clicked button so that consumers can easily
// tell which button was acted on.
this.selectedButton = target.closest("menupopup")._triggerButton;
this.handleSearchCommand(event, this.selectedButton.engine, true);
if (this.textbox.value) {
this.handleSearchCommand(event, this.selectedButton.engine, true);
} else {
this.popup.openSearchForm(event, this.selectedButton.engine, true);
}
}

const isPrivateButton = target.classList.contains(
Expand Down
16 changes: 12 additions & 4 deletions browser/components/search/content/autocomplete-popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@
if (!engine) {
return;
}
// At this point, the click must have happened on the header.
if (!this.searchbar.value) {
return;
if (this.searchbar.value) {
this.oneOffButtons.handleSearchCommand(event, engine);
} else if (event.shiftKey) {
this.openSearchForm(event, engine);
}
this.oneOffButtons.handleSearchCommand(event, engine);
});

this._bundle = null;
Expand Down Expand Up @@ -262,6 +262,14 @@
this.searchbar.handleSearchCommandWhere(event, engine, where, params);
}

openSearchForm(event, engine, forceNewTab = false) {
let { where, params } = this.oneOffButtons._whereToOpen(
event,
forceNewTab
);
this.searchbar.openSearchFormWhere(event, engine, where, params);
}

/**
* Passes DOM events for the popup to the _on_<event type> methods.
*
Expand Down
142 changes: 100 additions & 42 deletions browser/components/search/content/searchbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,52 +306,14 @@
}

handleSearchCommand(aEvent, aEngine, aForceNewTab) {
let where = "current";
let params;
const newTabPref = Services.prefs.getBoolPref("browser.search.openintab");

// Open ctrl/cmd clicks on one-off buttons in a new background tab.
if (
aEvent &&
aEvent.originalTarget.classList.contains("search-go-button")
aEvent.originalTarget.classList.contains("search-go-button") &&
aEvent.button == 2
) {
if (aEvent.button == 2) {
return;
}
where = lazy.BrowserUtils.whereToOpenLink(aEvent, false, true);
if (
newTabPref &&
!aEvent.altKey &&
!aEvent.getModifierState("AltGraph") &&
where == "current" &&
!gBrowser.selectedTab.isEmpty
) {
where = "tab";
}
} else if (aForceNewTab) {
where = "tab";
if (Services.prefs.getBoolPref("browser.tabs.loadInBackground")) {
where += "-background";
}
} else {
if (
(KeyboardEvent.isInstance(aEvent) &&
(aEvent.altKey || aEvent.getModifierState("AltGraph"))) ^
newTabPref &&
!gBrowser.selectedTab.isEmpty
) {
where = "tab";
}
if (
MouseEvent.isInstance(aEvent) &&
(aEvent.button == 1 || aEvent.getModifierState("Accel"))
) {
where = "tab";
params = {
inBackground: true,
};
}
return;
}
let { where, params } = this._whereToOpen(aEvent, aForceNewTab);
this.handleSearchCommandWhere(aEvent, aEngine, where, params);
}

Expand Down Expand Up @@ -449,6 +411,97 @@
openTrustedLinkIn(submission.uri.spec, aWhere, params);
}

/**
* Returns information on where a search results page should be loaded: in the
* current tab or a new tab.
*
* @param {event} aEvent
* The event that triggered the page load.
* @param {boolean} [aForceNewTab]
* True to force the load in a new tab.
* @returns {object} An object { where, params }. `where` is a string:
* "current" or "tab". `params` is an object further describing how
* the page should be loaded.
*/
_whereToOpen(aEvent, aForceNewTab = false) {
let where = "current";
let params = {};
const newTabPref = Services.prefs.getBoolPref("browser.search.openintab");

// Open ctrl/cmd clicks on one-off buttons in a new background tab.
if (aEvent?.originalTarget.classList.contains("search-go-button")) {
where = lazy.BrowserUtils.whereToOpenLink(aEvent, false, true);
if (
newTabPref &&
!aEvent.altKey &&
!aEvent.getModifierState("AltGraph") &&
where == "current" &&
!gBrowser.selectedTab.isEmpty
) {
where = "tab";
}
} else if (aForceNewTab) {
where = "tab";
if (Services.prefs.getBoolPref("browser.tabs.loadInBackground")) {
params = {
inBackground: true,
};
}
} else {
if (
(KeyboardEvent.isInstance(aEvent) &&
(aEvent.altKey || aEvent.getModifierState("AltGraph"))) ^
newTabPref &&
!gBrowser.selectedTab.isEmpty
) {
where = "tab";
}
if (
MouseEvent.isInstance(aEvent) &&
(aEvent.button == 1 || aEvent.getModifierState("Accel"))
) {
where = "tab";
params = {
inBackground: true,
};
}
}

return { where, params };
}

/**
* Opens the search form of the provided engine or the current engine
* if no engine was provided.
*
* @param {event} aEvent
* The event causing the searchForm to be opened.
* @param {nsISearchEngine} [aEngine]
* The search engine or undefined to use the current engine.
* @param {string} where
* Where the search form should be opened.
* @param {object} [params]
* Parameters for URILoadingHelper.openLinkIn.
*/
openSearchFormWhere(aEvent, aEngine, where, params = {}) {
let engine = aEngine || this.currentEngine;
let searchForm = engine.wrappedJSObject.searchForm;

if (where === "tab" && !!params.inBackground) {
// Keep the focus in the search bar.
params.avoidBrowserFocus = true;
} else if (
where !== "window" &&
aEvent.keyCode === KeyEvent.DOM_VK_RETURN
) {
// Move the focus to the selected browser when keyup the Enter.
params.avoidBrowserFocus = true;
this._needBrowserFocusAtEnterKeyUp = true;
}

openTrustedLinkIn(searchForm, where, params);
}

disconnectedCallback() {
this.destroy();
while (this.firstChild) {
Expand Down Expand Up @@ -807,6 +860,11 @@
)
)
) {
if (event.shiftKey) {
let engine = this.textbox.selectedButton?.engine;
let { where, params } = this._whereToOpen(event);
this.openSearchFormWhere(event, engine, where, params);
}
return true;
}
// Otherwise, "call super": do what the autocomplete binding's
Expand Down
Loading

0 comments on commit 49606c4

Please sign in to comment.