Bug 1404773 - Part 1. Add form autofill clear form button binding.
MozReview-Commit-ID: 7lDi5zsf1QI
--- a/browser/extensions/formautofill/content/formautofill.css
+++ b/browser/extensions/formautofill/content/formautofill.css
@@ -1,15 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#PopupAutoComplete > richlistbox > richlistitem[originaltype="autofill-profile"],
#PopupAutoComplete > richlistbox > richlistitem[originaltype="autofill-footer"],
-#PopupAutoComplete > richlistbox > richlistitem[originaltype="autofill-insecureWarning"] {
+#PopupAutoComplete > richlistbox > richlistitem[originaltype="autofill-insecureWarning"],
+#PopupAutoComplete > richlistbox > richlistitem[originaltype="autofill-clear-button"] {
display: block;
margin: 0;
padding: 0;
height: auto;
min-height: auto;
}
#PopupAutoComplete > richlistbox > richlistitem[originaltype="autofill-profile"] {
@@ -19,21 +20,25 @@
#PopupAutoComplete > richlistbox > richlistitem[originaltype="autofill-footer"] {
-moz-binding: url("chrome://formautofill/content/formautofill.xml#autocomplete-profile-listitem-footer");
}
#PopupAutoComplete > richlistbox > richlistitem[originaltype="autofill-insecureWarning"] {
-moz-binding: url("chrome://formautofill/content/formautofill.xml#autocomplete-creditcard-insecure-field");
}
+#PopupAutoComplete > richlistbox > richlistitem[originaltype="autofill-clear-button"] {
+ -moz-binding: url("chrome://formautofill/content/formautofill.xml#autocomplete-profile-listitem-clear-button");
+}
/* Treat @collpased="true" as display: none similar to how it is for XUL elements.
* https://developer.mozilla.org/en-US/docs/Web/CSS/visibility#Values */
#PopupAutoComplete > richlistbox > richlistitem[originaltype="autofill-profile"][collapsed="true"],
#PopupAutoComplete > richlistbox > richlistitem[originaltype="autofill-footer"][collapsed="true"],
-#PopupAutoComplete > richlistbox > richlistitem[originaltype="autofill-insecureWarning"][collapsed="true"] {
+#PopupAutoComplete > richlistbox > richlistitem[originaltype="autofill-insecureWarning"][collapsed="true"],
+#PopupAutoComplete > richlistbox > richlistitem[originaltype="autofill-clear-button"][collapsed="true"] {
display: none;
}
#PopupAutoComplete[firstresultstyle="autofill-profile"] {
min-width: 150px !important;
}
#PopupAutoComplete[firstresultstyle="autofill-insecureWarning"] {
--- a/browser/extensions/formautofill/content/formautofill.xml
+++ b/browser/extensions/formautofill/content/formautofill.xml
@@ -148,17 +148,17 @@
</implementation>
</binding>
<binding id="autocomplete-profile-listitem-footer" extends="chrome://formautofill/content/formautofill.xml#autocomplete-profile-listitem-base">
<xbl:content xmlns="http://www.w3.org/1999/xhtml">
<div anonid="autofill-footer" class="autofill-item-box autofill-footer">
<div anonid="autofill-warning" class="autofill-footer-row autofill-warning">
</div>
- <div anonid="autofill-option-button" class="autofill-footer-row autofill-option-button">
+ <div anonid="autofill-option-button" class="autofill-footer-row autofill-button">
</div>
</div>
</xbl:content>
<handlers>
<handler event="click" button="0"><![CDATA[
window.openPreferences("panePrivacy", {origin: "autofillFooter"});
]]></handler>
@@ -302,9 +302,53 @@
this._itemBox.textContent = value;
]]>
</body>
</method>
</implementation>
</binding>
+ <binding id="autocomplete-profile-listitem-clear-button" extends="chrome://formautofill/content/formautofill.xml#autocomplete-profile-listitem-base">
+ <xbl:content xmlns="http://www.w3.org/1999/xhtml">
+ <div anonid="autofill-item-box" class="autofill-item-box autofill-footer">
+ <div anonid="autofill-clear-button" class="autofill-footer-row autofill-button">
+ Clear Form
+ </div>
+ </div>
+ </xbl:content>
+
+ <handlers>
+ <handler event="click" button="0"><![CDATA[
+ /* global Cu */
+ let {AutoCompletePopup} = Cu.import("resource://gre/modules/AutoCompletePopup.jsm", {});
+
+ AutoCompletePopup.sendMessageToBrowser("FormAutofill:ClearForm");
+ ]]></handler>
+ </handlers>
+
+ <implementation implements="nsIDOMXULSelectControlItemElement">
+ <constructor>
+ <![CDATA[
+ this._itemBox = document.getAnonymousElementByAttribute(
+ this, "anonid", "autofill-item-box"
+ );
+
+ this._adjustAcItem();
+ ]]>
+ </constructor>
+
+ <method name="_adjustAcItem">
+ <body>
+ <![CDATA[
+ this._adjustAutofillItemLayout();
+ this.setAttribute("formautofillattached", "true");
+
+ // let value = this.getAttribute("ac-value");
+ // this._itemBox.textContent = value;
+ ]]>
+ </body>
+ </method>
+
+ </implementation>
+ </binding>
+
</bindings>
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -1305,22 +1305,28 @@ extends="chrome://global/content/binding
if (itemExists) {
item = this.richlistbox.childNodes[this._currentIndex];
// Url may be a modified version of value, see _adjustACItem().
originalValue = item.getAttribute("url") || item.getAttribute("ac-value");
originalText = item.getAttribute("ac-text");
originalType = item.getAttribute("originaltype");
- // All of types are reusable except for autofill-profile,
- // which has different structure of <content> and overrides
+ // All of types are reusable except for form autofill bindings
+ // which have different structure of <content> and overrided
// _adjustAcItem().
+ let formAutofillStyles = [
+ "autofill-profile",
+ "autofill-footer",
+ "autofill-clear-button",
+ "autofill-insecureWarning",
+ ];
reusable = originalType === style ||
- (style !== "autofill-profile" && originalType !== "autofill-profile" &&
- style !== "autofill-footer" && originalType !== "autofill-footer");
+ !(formAutofillStyles.includes(style) || formAutofillStyles.includes(originalType));
+
} else {
// need to create a new item
item = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "richlistitem");
}
item.setAttribute("dir", this.style.direction);
item.setAttribute("ac-image", image);
item.setAttribute("ac-value", value);