Bug 1407613 - Remove dropmarker from the generic autocomplete binding. r?mak
MozReview-Commit-ID: DIVPqfbkJnL
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1341,17 +1341,16 @@ var gBrowserInit = {
if (width < TARGET_WIDTH && height < TARGET_HEIGHT) {
document.documentElement.setAttribute("sizemode", "maximized");
}
}
if (!window.toolbar.visible) {
// adjust browser UI for popups
gURLBar.setAttribute("readonly", "true");
- gURLBar.setAttribute("enablehistory", "false");
}
// Misc. inits.
TabletModeUpdater.init();
CombinedStopReload.ensureInitialized();
gPrivateBrowsingUI.init();
BrowserPageActions.init();
gAccessibilityServiceIndicator.init();
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -774,17 +774,16 @@
autocompletesearch="unifiedcomplete"
autocompletesearchparam="enable-actions"
autocompletepopup="PopupAutoCompleteRichResult"
completeselectedindex="true"
shrinkdelay="250"
tabscrolling="true"
showcommentcolumn="true"
showimagecolumn="true"
- enablehistory="true"
newlines="stripsurroundingwhitespace"
ontextentered="this.handleCommand(param);"
ontextreverted="return this.handleRevert();"
pageproxystate="invalid">
<!-- Use onclick instead of normal popup= syntax since the popup
code fires onmousedown, and hence eats our favicon drag events. -->
<box id="identity-box" role="button"
align="center"
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -43,20 +43,20 @@ file, You can obtain one at http://mozil
xbl:inherits="tooltiptext=inputtooltiptext,value,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey,focused,textoverflow"/>
</xul:hbox>
<xul:image anonid="urlbar-go-button"
class="urlbar-go-button urlbar-icon"
onclick="gURLBar.handleCommand(event);"
tooltiptext="&goEndCap.tooltip;"
xbl:inherits="pageproxystate,parentfocused=focused,usertyping"/>
<xul:dropmarker anonid="historydropmarker"
- class="autocomplete-history-dropmarker urlbar-history-dropmarker urlbar-icon"
+ class="urlbar-history-dropmarker urlbar-icon chromeclass-toolbar-additional"
tooltiptext="&urlbar.openHistoryPopup.tooltip;"
allowevents="true"
- xbl:inherits="open,enablehistory,parentfocused=focused,usertyping"/>
+ xbl:inherits="open,parentfocused=focused,usertyping"/>
<children includes="hbox"/>
</xul:hbox>
<xul:popupset anonid="popupset"
class="autocomplete-result-popupset"/>
<children includes="toolbarbutton"/>
</content>
<implementation implements="nsIObserver, nsIDOMEventListener">
@@ -124,16 +124,26 @@ file, You can obtain one at http://mozil
"gURLBar.select(); goDoCommand('cmd_paste'); gURLBar.handleCommand();");
cxmenu.insertBefore(pasteAndGo, insertLocation.nextSibling);
}
this.popup.addEventListener("popupshowing", () => {
this._enableOrDisableOneOffSearches();
}, {capturing: true, once: true});
+ // history dropmarker open state
+ this.popup.addEventListener("popupshowing", () => {
+ this.setAttribute("open", "true");
+ });
+ this.popup.addEventListener("popuphidden", () => {
+ requestAnimationFrame(() => {
+ this.removeAttribute("open");
+ });
+ });
+
// The autocomplete controller uses heuristic on some internal caches
// to handle cases like backspace, autofill or repeated searches.
// Ensure to clear those internal caches when switching tabs.
gBrowser.tabContainer.addEventListener("TabSelect", this);
]]></constructor>
<destructor><![CDATA[
this._prefs.removeObserver("", this);
@@ -1506,20 +1516,26 @@ file, You can obtain one at http://mozil
this._pressedNoActionKeys.has(event.keyCode)) {
this._pressedNoActionKeys.delete(event.keyCode);
if (this._pressedNoActionKeys.size == 0)
this._clearNoActions();
}
]]></handler>
<handler event="mousedown"><![CDATA[
- // Eventually show the opt-out notification even if the location bar is
- // empty, focused, and the user clicks on it.
- if (event.button == 0 && this.focused && this.textValue == "") {
- this.maybeShowSearchSuggestionsNotificationOnFocus(true);
+ if (event.button == 0) {
+ if (event.originalTarget.getAttribute("anonid") == "historydropmarker") {
+ this.toggleHistoryPopup();
+ }
+
+ // Eventually show the opt-out notification even if the location bar is
+ // empty, focused, and the user clicks on it.
+ if (this.focused && this.textValue == "") {
+ this.maybeShowSearchSuggestionsNotificationOnFocus(true);
+ }
}
]]></handler>
<handler event="focus"><![CDATA[
if (event.originalTarget == this.inputField) {
this._hideURLTooltip();
this.formatValue();
if (this.getAttribute("pageproxystate") != "valid") {
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -3967,23 +3967,21 @@ var SessionStoreInternal = {
WINDOW_HIDEABLE_FEATURES.forEach(function(aItem) {
aWindow[aItem].visible = hidden.indexOf(aItem) == -1;
});
if (aWinData.isPopup) {
this._windows[aWindow.__SSi].isPopup = true;
if (aWindow.gURLBar) {
aWindow.gURLBar.readOnly = true;
- aWindow.gURLBar.setAttribute("enablehistory", "false");
}
} else {
delete this._windows[aWindow.__SSi].isPopup;
if (aWindow.gURLBar) {
aWindow.gURLBar.readOnly = false;
- aWindow.gURLBar.setAttribute("enablehistory", "true");
}
}
aWindow.setTimeout(() => {
this.restoreDimensions(aWindow,
+(aWinData.width || 0),
+(aWinData.height || 0),
"screenX" in aWinData ? +aWinData.screenX : NaN,
--- a/browser/components/sessionstore/test/browser_495495.js
+++ b/browser/components/sessionstore/test/browser_495495.js
@@ -18,29 +18,25 @@ function test() {
let state2 = ss.getWindowState(newWin);
function testState(state, expected, callback) {
let win = openDialog(location, "_blank", "chrome,all,dialog=no");
promiseWindowLoaded(win).then(() => {
is(win.gURLBar.readOnly, false,
"URL bar should not be read-only before setting the state");
- is(win.gURLBar.getAttribute("enablehistory"), "true",
- "URL bar autocomplete should be enabled before setting the state");
ss.setWindowState(win, state, true);
is(win.gURLBar.readOnly, expected.readOnly,
"URL bar read-only state should be restored correctly");
- is(win.gURLBar.getAttribute("enablehistory"), expected.enablehistory,
- "URL bar autocomplete state should be restored correctly");
BrowserTestUtils.closeWindow(win).then(callback);
});
}
BrowserTestUtils.closeWindow(newWin).then(() => {
- testState(state1, {readOnly: false, enablehistory: "true"}, function() {
- testState(state2, {readOnly: true, enablehistory: "false"}, finish);
+ testState(state1, {readOnly: false}, function() {
+ testState(state2, {readOnly: true}, finish);
});
});
});
});
});
}
--- a/browser/themes/linux/browser.css
+++ b/browser/themes/linux/browser.css
@@ -152,35 +152,29 @@ menuitem.bookmark-item {
list-style-image: url("chrome://global/skin/icons/Restore.gif");
}
#close-button {
list-style-image: url("chrome://global/skin/icons/Close.gif");
}
/* Location bar */
-#urlbar {
- /* override textbox[enablehistory="true"] styling: */
- background-color: -moz-field;
-}
-
%include ../shared/urlbar-searchbar.inc.css
#urlbar:not(:-moz-lwtheme):not([focused="true"]),
.searchbar-textbox:not(:-moz-lwtheme):not([focused="true"]) {
border-color: ThreeDShadow;
}
#urlbar[focused="true"],
.searchbar-textbox[focused="true"] {
border-color: Highlight;
}
.urlbar-textbox-container {
- -moz-appearance: none;
-moz-box-align: stretch;
}
/* ::::: URL Bar Zoom Reset Button ::::: */
@keyframes urlbar-zoom-reset-pulse {
0% {
transform: scale(0);
}
--- a/browser/themes/shared/urlbar-searchbar.inc.css
+++ b/browser/themes/shared/urlbar-searchbar.inc.css
@@ -220,16 +220,21 @@
}
.urlbar-history-dropmarker {
-moz-appearance: none;
list-style-image: url(chrome://global/skin/icons/arrow-dropdown-16.svg);
transition: opacity 0.15s ease;
}
+/* Avoid re-opening the popup when the dropmarker is clicked while the popup is still open. */
+.urlbar-history-dropmarker[open] {
+ pointer-events: none;
+}
+
#urlbar[switchingtabs] > .urlbar-textbox-container > .urlbar-history-dropmarker {
transition: none;
}
#nav-bar:not([customizing="true"]) > #nav-bar-customization-target > #urlbar-container:not(:hover) > #urlbar:not([focused]) > .urlbar-textbox-container > .urlbar-history-dropmarker {
opacity: 0;
}
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -26,20 +26,16 @@
<children/>
<html:input anonid="input" class="autocomplete-textbox textbox-input"
allowevents="true"
xbl:inherits="tooltiptext=inputtooltiptext,value,type=inputtype,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey,mozactionhint"/>
</xul:hbox>
<children includes="hbox"/>
</xul:hbox>
- <xul:dropmarker anonid="historydropmarker" class="autocomplete-history-dropmarker"
- allowevents="true"
- xbl:inherits="open,enablehistory,parentfocused=focused"/>
-
<xul:popupset anonid="popupset" class="autocomplete-result-popupset"/>
<children includes="toolbarbutton"/>
</content>
<implementation implements="nsIAutoCompleteInput, nsIDOMXULMenuListElement">
<field name="mController">null</field>
<field name="mSearchNames">null</field>
@@ -396,33 +392,16 @@
<method name="closePopup">
<body><![CDATA[
this.popup.closePopup();
]]></body>
</method>
<method name="showHistoryPopup">
<body><![CDATA[
- // history dropmarker pushed state
- function cleanup(popup) {
- popup.removeEventListener("popupshowing", onShow);
- }
- function onShow(event) {
- var popup = event.target, input = popup.input;
- cleanup(popup);
- input.setAttribute("open", "true");
- function onHide() {
- input.removeAttribute("open");
- popup.removeEventListener("popuphiding", onHide);
- }
- popup.addEventListener("popuphiding", onHide);
- }
- this.popup.addEventListener("popupshowing", onShow);
- setTimeout(cleanup, 1000, this.popup);
-
// Store our "normal" maxRows on the popup, so that it can reset the
// value when the popup is hidden.
this.popup._normalMaxRows = this.maxRows;
// Increase our maxRows temporarily, since we want the dropdown to
// be bigger in this case. The popup's popupshowing/popuphiding
// handlers will take care of resetting this.
this.maxRows = this.maxDropMarkerRows;
@@ -432,20 +411,17 @@
this.focus();
this.attachController();
this.mController.startSearch("");
]]></body>
</method>
<method name="toggleHistoryPopup">
<body><![CDATA[
- // If this method is called on the same event tick as the popup gets
- // hidden, do nothing to avoid re-opening the popup when the drop
- // marker is clicked while the popup is still open.
- if (!this.popup.isPopupHidingTick && !this.popup.popupOpen)
+ if (!this.popup.popupOpen)
this.showHistoryPopup();
else
this.closePopup();
]]></body>
</method>
<!-- ::::::::::::: event dispatching ::::::::::::: -->
@@ -907,32 +883,28 @@
</implementation>
</binding>
<binding id="autocomplete-base-popup" role="none"
extends="chrome://global/content/bindings/popup.xml#popup">
<implementation implements="nsIAutoCompletePopup">
<field name="mInput">null</field>
<field name="mPopupOpen">false</field>
- <field name="mIsPopupHidingTick">false</field>
<!-- =================== nsIAutoCompletePopup =================== -->
<property name="input" readonly="true"
onget="return this.mInput"/>
<property name="overrideValue" readonly="true"
onget="return null;"/>
<property name="popupOpen" readonly="true"
onget="return this.mPopupOpen;"/>
- <property name="isPopupHidingTick" readonly="true"
- onget="return this.mIsPopupHidingTick;"/>
-
<method name="closePopup">
<body>
<![CDATA[
if (this.mPopupOpen) {
this.hidePopup();
this.removeAttribute("width");
}
]]>
@@ -1029,24 +1001,16 @@ extends="chrome://global/content/binding
if (this.selectedIndex == -1)
isListActive = false;
var controller = this.view.QueryInterface(Components.interfaces.nsIAutoCompleteController);
controller.stopSearch();
this.removeAttribute("autocompleteinput");
this.mPopupOpen = false;
- // Prevent opening popup from historydropmarker mousedown handler
- // on the same event tick the popup is hidden by the same mousedown
- // event.
- this.mIsPopupHidingTick = true;
- setTimeout(() => {
- this.mIsPopupHidingTick = false;
- }, 0);
-
// Reset the maxRows property to the cached "normal" value (if there's
// any), and reset normalMaxRows so that we can detect whether it was set
// by the input when the popupshowing handler runs.
// Null-check this.mInput; see bug 1017914
if (this.mInput && this._normalMaxRows > 0) {
this.mInput.maxRows = this._normalMaxRows;
}
@@ -2605,17 +2569,9 @@ extends="chrome://global/content/binding
<content>
<xul:hbox flex="1" class="tree-bodybox">
<children/>
</xul:hbox>
<xul:scrollbar xbl:inherits="collapsed=hidescrollbar" orient="vertical" class="tree-scrollbar"/>
</content>
</binding>
- <binding id="history-dropmarker" extends="chrome://global/content/bindings/general.xml#dropmarker">
- <handlers>
- <handler event="mousedown" button="0"><![CDATA[
- document.getBindingParent(this).toggleHistoryPopup();
- ]]></handler>
- </handlers>
- </binding>
-
</bindings>
--- a/toolkit/content/xul.css
+++ b/toolkit/content/xul.css
@@ -829,20 +829,16 @@ panel[type="autocomplete"] {
.autocomplete-history-popup {
-moz-binding: url("chrome://global/content/autocomplete.xml#autocomplete-history-popup");
}
.autocomplete-treebody {
-moz-binding: url("chrome://global/content/autocomplete.xml#autocomplete-treebody");
}
-.autocomplete-history-dropmarker {
- -moz-binding: url("chrome://global/content/autocomplete.xml#history-dropmarker");
-}
-
panel[type="autocomplete-richlistbox"] {
-moz-binding: url("chrome://global/content/bindings/autocomplete.xml#autocomplete-rich-result-popup");
}
.autocomplete-richlistbox {
-moz-binding: url("chrome://global/content/bindings/autocomplete.xml#autocomplete-richlistbox");
-moz-user-focus: ignore;
}
@@ -896,25 +892,16 @@ panel[type="autocomplete-richlistbox"] {
-moz-box-orient: vertical;
overflow: -moz-hidden-unscrollable;
}
.autocomplete-treerows {
-moz-binding: url("chrome://global/content/bindings/autocomplete.xml#autocomplete-treerows");
}
-.autocomplete-history-dropmarker {
- display: none;
-}
-
-.autocomplete-history-dropmarker[enablehistory="true"] {
- display: -moz-box;
- -moz-binding: url("chrome://global/content/bindings/autocomplete.xml#history-dropmarker");
-}
-
%endif
/* the C++ implementation of widgets is too eager to make popups visible.
this causes problems (bug 120155 and others), thus this workaround: */
popup[type="autocomplete"][hidden="true"] {
visibility: hidden;
}
--- a/toolkit/themes/linux/global/autocomplete.css
+++ b/toolkit/themes/linux/global/autocomplete.css
@@ -12,34 +12,24 @@
/* ::::: autocomplete ::::: */
/* .padded is used by autocomplete widgets that don't have an icon. Gross. -dwh */
textbox:not(.padded) {
cursor: default;
padding: 0;
}
-textbox[enablehistory="true"] {
- -moz-appearance: none;
- border: 0;
- background-color: transparent;
-}
-
textbox[nomatch="true"][highlightnonmatches="true"] {
color: red;
}
.autocomplete-textbox-container {
-moz-box-align: center;
}
-textbox[enablehistory="true"] > .autocomplete-textbox-container {
- -moz-appearance: menulist-textfield;
-}
-
textbox:not(.padded) .textbox-input-box {
margin: 0 3px;
}
.textbox-input-box {
-moz-box-align: center;
}