diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-07-18 08:24:24 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-07-18 08:24:24 +0200 |
commit | fc61780b35af913801d72086456f493f63197da6 (patch) | |
tree | f85891288a7bd988da9f0f15ae64e5c63f00d493 /application/palemoon/base/content/tabbrowser.xml | |
parent | 69f7f9e5f1475891ce11cc4f431692f965b0cd30 (diff) | |
parent | 50d3e596bbe89c95615f96eb71f6bc5be737a1db (diff) | |
download | UXP-fc61780b35af913801d72086456f493f63197da6.tar UXP-fc61780b35af913801d72086456f493f63197da6.tar.gz UXP-fc61780b35af913801d72086456f493f63197da6.tar.lz UXP-fc61780b35af913801d72086456f493f63197da6.tar.xz UXP-fc61780b35af913801d72086456f493f63197da6.zip |
Merge commit '50d3e596bbe89c95615f96eb71f6bc5be737a1db' into Basilisk-releasev2018.07.18
# Conflicts:
# browser/app/profile/firefox.js
# browser/components/preferences/jar.mn
Diffstat (limited to 'application/palemoon/base/content/tabbrowser.xml')
-rw-r--r-- | application/palemoon/base/content/tabbrowser.xml | 149 |
1 files changed, 111 insertions, 38 deletions
diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml index 10f109ce8..ea68d00ad 100644 --- a/application/palemoon/base/content/tabbrowser.xml +++ b/application/palemoon/base/content/tabbrowser.xml @@ -128,6 +128,10 @@ false </field> + <field name="_lastFindValue"> + "" + </field> + <property name="_numPinnedTabs" readonly="true"> <getter><![CDATA[ for (var i = 0; i < this.tabs.length; i++) { @@ -154,6 +158,43 @@ ]]></getter> </property> + <method name="isFindBarInitialized"> + <parameter name="aTab"/> + <body><![CDATA[ + return (aTab || this.selectedTab)._findBar != undefined; + ]]></body> + </method> + + <method name="getFindBar"> + <parameter name="aTab"/> + <body><![CDATA[ + if (!aTab) + aTab = this.selectedTab; + + if (aTab._findBar) + return aTab._findBar; + + let findBar = document.createElementNS(this.namespaceURI, "findbar"); + let browser = this.getBrowserForTab(aTab); + let browserContainer = this.getBrowserContainer(browser); + browserContainer.appendChild(findBar); + + // Force a style flush to ensure that our binding is attached. + findBar.clientTop; + + findBar.browser = browser; + findBar._findField.value = this._lastFindValue; + + aTab._findBar = findBar; + + let event = document.createEvent("Events"); + event.initEvent("TabFindInitialized", true, false); + aTab.dispatchEvent(event); + + return findBar; + ]]></body> + </method> + <method name="updateWindowResizers"> <body><![CDATA[ if (!window.gShowPageResizers) @@ -1063,9 +1104,11 @@ this.mCurrentTab.removeAttribute("unread"); this.selectedTab.lastAccessed = Date.now(); - // Bug 666816 - TypeAheadFind support for e10s - if (!gMultiProcessBrowser) - this._fastFind.setDocShell(this.mCurrentBrowser.docShell); + let oldFindBar = oldTab._findBar; + if (oldFindBar && + oldFindBar.findMode == oldFindBar.FIND_NORMAL && + !oldFindBar.hidden) + this._lastFindValue = oldFindBar._findField.value; this.updateTitlebar(); @@ -1116,6 +1159,11 @@ // Adjust focus oldBrowser._urlbarFocused = (gURLBar && gURLBar.focused); + if (this.isFindBarInitialized(oldTab)) { + let findBar = this.getFindBar(oldTab); + oldTab._findBarFocused = (!findBar.hidden && + findBar._findField.getAttribute("focused") == "true"); + } do { // When focus is in the tab bar, retain it there. if (document.activeElement == oldTab) { @@ -1151,11 +1199,12 @@ } } - // If the find bar is focused, keep it focused. - if (gFindBarInitialized && - !gFindBar.hidden && - gFindBar.getElement("findbar-textbox").getAttribute("focused") == "true") + // Focus the find bar if it was previously focused for that tab. + if (gFindBarInitialized && !gFindBar.hidden && + this.selectedTab._findBarFocused) { + gFindBar._findField.focus(); break; + } // Otherwise, focus the content area. let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager); @@ -1445,9 +1494,6 @@ t.setAttribute("label", aURI); t.setAttribute("crop", "end"); - t.style.maxWidth = this.tabContainer.mTabMaxWidth + "px"; - t.style.minWidth = this.tabContainer.mTabMinWidth + "px"; - t.width = 0; t.setAttribute("validate", "never"); //PMed t.setAttribute("onerror", "this.removeAttribute('image');"); t.className = "tabbrowser-tab"; @@ -1561,7 +1607,6 @@ this.mTabListeners[position] = tabListener; this.mTabFilters[position] = filter; - b._fastFind = this.fastFind; b.droppedLinkHandler = handleDroppedLink; // If we just created a new tab that loads the default @@ -1672,8 +1717,22 @@ var tabsToClose; switch (aCloseTabs) { case this.closingTabsEnum.ALL: - tabsToClose = this.tabs.length - this._removingTabs.length - - gBrowser._numPinnedTabs; + // If there are multiple windows, pinned tabs will be closed, so + // we warn about them, too; if there is just one window, pinned + // tabs should come back on restart, so exclude them from warning. + var numberOfWindows = 0; + var browserEnum = Services.wm.getEnumerator("navigator:browser"); + while (browserEnum.hasMoreElements() && numberOfWindows < 2) { + numberOfWindows++; + browserEnum.getNext(); + } + if (numberOfWindows > 1) { + tabsToClose = this.tabs.length - this._removingTabs.length + } + else { + tabsToClose = this.tabs.length - this._removingTabs.length - + gBrowser._numPinnedTabs; + } break; case this.closingTabsEnum.OTHER: tabsToClose = this.visibleTabs.length - 1 - gBrowser._numPinnedTabs; @@ -2225,6 +2284,17 @@ this._swapBrowserDocShells(aOurTab, otherBrowser); } + // Handle findbar data (if any) + let otherFindBar = aOtherTab._findBar; + if (otherFindBar && + otherFindBar.findMode == otherFindBar.FIND_NORMAL) { + let ourFindBar = this.getFindBar(aOurTab); + ourFindBar._findField.value = otherFindBar._findField.value; + if (!otherFindBar.hidden) { + ourFindBar.onFindCommand(); + } + } + // Finish tearing down the tab that's going away. remoteBrowser._endRemoveTab(aOtherTab); @@ -2777,21 +2847,6 @@ onget="return this.mCurrentBrowser.currentURI;" readonly="true"/> - <field name="_fastFind">null</field> - <property name="fastFind" - readonly="true"> - <getter> - <![CDATA[ - if (!this._fastFind) { - this._fastFind = Components.classes["@mozilla.org/typeaheadfind;1"] - .createInstance(Components.interfaces.nsITypeAheadFind); - this._fastFind.init(this.docShell); - } - return this._fastFind; - ]]> - </getter> - </property> - <field name="_lastSearchString">null</field> <field name="_lastSearchHighlight">false</field> @@ -3096,13 +3151,27 @@ break; } case "Findbar:Keypress": - if (!gFindBarInitialized) { - // If the find bar for this tab is not yet alive, change that, - // and make sure we return the result: - return gFindBar.receiveMessage(aMessage); + let tab = this.getTabForBrowser(browser); + // If the find bar for this tab is not yet alive, only initialize + // it if there's a possibility FindAsYouType will be used. + // There's no point in doing it for most random keypresses. + if (!this.isFindBarInitialized(tab) && + aMessage.data.shouldFastFind) { + let shouldFastFind = this._findAsYouType; + if (!shouldFastFind) { + // Please keep in sync with toolkit/content/widgets/findbar.xml + const FAYT_LINKS_KEY = "'"; + const FAYT_TEXT_KEY = "/"; + let charCode = aMessage.data.fakeEvent.charCode; + let key = charCode ? String.fromCharCode(charCode) : null; + shouldFastFind = key == FAYT_LINKS_KEY || key == FAYT_TEXT_KEY; + } + if (shouldFastFind) { + // Make sure we return the result. + return this.getFindBar(tab).receiveMessage(aMessage); + } } break; - } ]]></body> </method> @@ -3169,6 +3238,10 @@ this.mCurrentBrowser); } messageManager.addMessageListener("DOMWebNotificationClicked", this); + + // To correctly handle keypresses for potential FindAsYouType, while + // the tab's find bar is not yet initialized. + this._findAsYouType = Services.prefs.getBoolPref("accessibility.typeaheadfind"); messageManager.addMessageListener("Findbar:Keypress", this); ]]> </constructor> @@ -3413,8 +3486,6 @@ <implementation implements="nsIDOMEventListener"> <constructor> <![CDATA[ - this.mTabMinWidth = Services.prefs.getIntPref("browser.tabs.tabMinWidth"); - this.mTabMaxWidth = Services.prefs.getIntPref("browser.tabs.tabMaxWidth"); this.mTabClipWidth = Services.prefs.getIntPref("browser.tabs.tabClipWidth"); this.mCloseButtons = Services.prefs.getIntPref("browser.tabs.closeButtons"); this._closeWindowWithLastTab = Services.prefs.getBoolPref("browser.tabs.closeWindowWithLastTab"); @@ -3422,13 +3493,11 @@ var tab = this.firstChild; tab.setAttribute("label", this.tabbrowser.mStringBundle.getString("tabs.emptyTabTitle")); - tab.style.minWidth = this.mTabMinWidth + "px"; - tab.style.maxWidth = this.mTabMaxWidth + "px"; - tab.width = 0; tab.setAttribute("crop", "end"); tab.setAttribute("onerror", "this.removeAttribute('image');"); this.adjustTabstrip(); + Services.prefs.addObserver("accessibility.typeaheadfind", this._prefObserver, false); Services.prefs.addObserver("browser.tabs.", this._prefObserver, false); window.addEventListener("resize", this, false); window.addEventListener("load", this, false); @@ -3444,6 +3513,7 @@ <destructor> <![CDATA[ + Services.prefs.removeObserver("accessibility.typeaheadfind", this._prefObserver); Services.prefs.removeObserver("browser.tabs.", this._prefObserver); ]]> </destructor> @@ -3509,6 +3579,9 @@ observe: function (subject, topic, data) { switch (data) { + case "accessibility.typeaheadfind": + this._findAsYouType = Services.prefs.getBoolPref(data); + break; case "browser.tabs.closeButtons": this.tabContainer.mCloseButtons = Services.prefs.getIntPref(data); this.tabContainer.adjustTabstrip(); |