зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1771841 - use HTMLInputElement.isInstance(field) instead of ChromeUtils.getClassName(field) === "HTMLInputElement". r=dimi
Differential Revision: https://phabricator.services.mozilla.com/D147712
This commit is contained in:
Родитель
70ac5cb57a
Коммит
6c05dd488e
|
@ -876,7 +876,7 @@ var FormAutofillContent = {
|
|||
_markAsAutofillField(field) {
|
||||
// Since Form Autofill popup is only for input element, any non-Input
|
||||
// element should be excluded here.
|
||||
if (!field || ChromeUtils.getClassName(field) !== "HTMLInputElement") {
|
||||
if (!HTMLInputElement.isInstance(field)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ class FormAutofillSection {
|
|||
}
|
||||
|
||||
let element = fieldDetail.elementWeakRef.get();
|
||||
if (ChromeUtils.getClassName(element) !== "HTMLSelectElement") {
|
||||
if (!HTMLSelectElement.isInstance(element)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,7 @@ class FormAutofillSection {
|
|||
if (fieldDetail.transform) {
|
||||
value = fieldDetail.transform(value);
|
||||
}
|
||||
if (ChromeUtils.getClassName(element) === "HTMLInputElement" && value) {
|
||||
if (HTMLInputElement.isInstance(element) && value) {
|
||||
// For the focused input element, it will be filled with a valid value
|
||||
// anyway.
|
||||
// For the others, the fields should be only filled when their values are empty
|
||||
|
@ -392,7 +392,7 @@ class FormAutofillSection {
|
|||
element.setUserInput(value);
|
||||
this._changeFieldState(fieldDetail, FIELD_STATES.AUTO_FILLED);
|
||||
}
|
||||
} else if (ChromeUtils.getClassName(element) === "HTMLSelectElement") {
|
||||
} else if (HTMLSelectElement.isInstance(element)) {
|
||||
let cache = this._cacheValue.matchingSelectOption.get(element) || {};
|
||||
let option = cache[value] && cache[value].get();
|
||||
if (!option) {
|
||||
|
@ -441,7 +441,7 @@ class FormAutofillSection {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (ChromeUtils.getClassName(element) === "HTMLSelectElement") {
|
||||
if (HTMLSelectElement.isInstance(element)) {
|
||||
// Unlike text input, select element is always previewed even if
|
||||
// the option is already selected.
|
||||
if (value) {
|
||||
|
@ -502,9 +502,9 @@ class FormAutofillSection {
|
|||
}
|
||||
|
||||
if (fieldDetail.state == FIELD_STATES.AUTO_FILLED) {
|
||||
if (ChromeUtils.getClassName(element) === "HTMLInputElement") {
|
||||
if (HTMLInputElement.isInstance(element)) {
|
||||
element.setUserInput("");
|
||||
} else if (ChromeUtils.getClassName(element) === "HTMLSelectElement") {
|
||||
} else if (HTMLSelectElement.isInstance(element)) {
|
||||
// If we can't find a selected option, then we should just reset to the first option's value
|
||||
this._resetSelectElementValue(element);
|
||||
}
|
||||
|
@ -677,7 +677,7 @@ class FormAutofillSection {
|
|||
// If the user manually blanks a credit card field, then
|
||||
// we want the popup to be activated.
|
||||
if (
|
||||
ChromeUtils.getClassName(target) !== "HTMLSelectElement" &&
|
||||
!HTMLSelectElement.isInstance(target) &&
|
||||
isCreditCardField &&
|
||||
target.value === ""
|
||||
) {
|
||||
|
@ -702,7 +702,7 @@ class FormAutofillSection {
|
|||
for (const fieldDetail of this.fieldDetails) {
|
||||
const element = fieldDetail.elementWeakRef.get();
|
||||
|
||||
if (ChromeUtils.getClassName(element) === "HTMLSelectElement") {
|
||||
if (HTMLSelectElement.isInstance(element)) {
|
||||
// Dim fields are those we don't attempt to revert their value
|
||||
// when clear the target set, such as <select>.
|
||||
dimFieldDetails.push(fieldDetail);
|
||||
|
@ -813,8 +813,7 @@ class FormAutofillAddressSection extends FormAutofillSection {
|
|||
let streetAddressDetail = this.getFieldDetailByName("street-address");
|
||||
if (
|
||||
streetAddressDetail &&
|
||||
ChromeUtils.getClassName(streetAddressDetail.elementWeakRef.get()) ===
|
||||
"HTMLInputElement"
|
||||
HTMLInputElement.isInstance(streetAddressDetail.elementWeakRef.get())
|
||||
) {
|
||||
profile["street-address"] = profile["-moz-street-address-one-line"];
|
||||
}
|
||||
|
@ -907,7 +906,7 @@ class FormAutofillAddressSection extends FormAutofillSection {
|
|||
// Try to abbreviate the value of select element.
|
||||
if (
|
||||
fieldDetail.fieldName == "address-level1" &&
|
||||
ChromeUtils.getClassName(element) === "HTMLSelectElement"
|
||||
HTMLSelectElement.isInstance(element)
|
||||
) {
|
||||
// Don't save the record when the option value is empty *OR* there
|
||||
// are multiple options being selected. The empty option is usually
|
||||
|
@ -1256,7 +1255,7 @@ class FormAutofillCreditCardSection extends FormAutofillSection {
|
|||
computeFillingValue(value, fieldDetail, element) {
|
||||
if (
|
||||
fieldDetail.fieldName != "cc-type" ||
|
||||
ChromeUtils.getClassName(element) !== "HTMLSelectElement"
|
||||
!HTMLSelectElement.isInstance(element)
|
||||
) {
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -595,7 +595,7 @@ FormAutofillHeuristics = {
|
|||
* the current element.
|
||||
*/
|
||||
_isExpirationMonthLikely(element) {
|
||||
if (ChromeUtils.getClassName(element) !== "HTMLSelectElement") {
|
||||
if (!HTMLSelectElement.isInstance(element)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -631,7 +631,7 @@ FormAutofillHeuristics = {
|
|||
* the current element.
|
||||
*/
|
||||
_isExpirationYearLikely(element) {
|
||||
if (ChromeUtils.getClassName(element) !== "HTMLSelectElement") {
|
||||
if (!HTMLSelectElement.isInstance(element)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -894,7 +894,7 @@ FormAutofillHeuristics = {
|
|||
|
||||
// If we didn't auto-discover type field, check every select for options that
|
||||
// match credit card network names in value or label.
|
||||
if (ChromeUtils.getClassName(element) == "HTMLSelectElement") {
|
||||
if (HTMLSelectElement.isInstance(element)) {
|
||||
for (let option of element.querySelectorAll("option")) {
|
||||
if (
|
||||
CreditCard.getNetworkFromName(option.value) ||
|
||||
|
|
|
@ -153,9 +153,8 @@ const CreditCardTelemetry = {
|
|||
let state = profile[fieldDetail.fieldName] ? "filled" : "not_filled";
|
||||
if (
|
||||
fieldDetail.state == FIELD_STATES.NORMAL &&
|
||||
(ChromeUtils.getClassName(element) == "HTMLSelectElement" ||
|
||||
(ChromeUtils.getClassName(element) == "HTMLInputElement" &&
|
||||
element.value.length))
|
||||
(HTMLSelectElement.isInstance(element) ||
|
||||
(HTMLInputElement.isInstance(element) && element.value.length))
|
||||
) {
|
||||
state = "user_filled";
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ const InsecurePasswordUtils = {
|
|||
_checkFormSecurity(aForm) {
|
||||
let isFormSubmitHTTP = false,
|
||||
isFormSubmitSecure = false;
|
||||
if (ChromeUtils.getClassName(aForm.rootElement) === "HTMLFormElement") {
|
||||
if (HTMLFormElement.isInstance(aForm.rootElement)) {
|
||||
let uri = Services.io.newURI(
|
||||
aForm.rootElement.action || aForm.rootElement.baseURI
|
||||
);
|
||||
|
|
|
@ -94,7 +94,7 @@ const LoginFormFactory = {
|
|||
*/
|
||||
createFromField(aField) {
|
||||
if (
|
||||
ChromeUtils.getClassName(aField) !== "HTMLInputElement" ||
|
||||
!HTMLInputElement.isInstance(aField) ||
|
||||
(!aField.hasBeenTypePassword &&
|
||||
!LoginHelper.isUsernameFieldType(aField)) ||
|
||||
!aField.ownerDocument
|
||||
|
|
|
@ -1249,7 +1249,7 @@ const LoginHelper = {
|
|||
* be treated as a password input
|
||||
*/
|
||||
isPasswordFieldType(element, { ignoreConnect = false } = {}) {
|
||||
if (ChromeUtils.getClassName(element) !== "HTMLInputElement") {
|
||||
if (!HTMLInputElement.isInstance(element)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1287,7 +1287,7 @@ const LoginHelper = {
|
|||
* of the username types.
|
||||
*/
|
||||
isUsernameFieldType(element, { ignoreConnect = false } = {}) {
|
||||
if (ChromeUtils.getClassName(element) !== "HTMLInputElement") {
|
||||
if (!HTMLInputElement.isInstance(element)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ class FormHistoryChild extends JSWindowActorChild {
|
|||
|
||||
let entries = [];
|
||||
for (let input of form.elements) {
|
||||
if (ChromeUtils.getClassName(input) !== "HTMLInputElement") {
|
||||
if (!HTMLInputElement.isInstance(input)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ let FormLikeFactory = {
|
|||
* @throws Error if aForm isn't an HTMLFormElement
|
||||
*/
|
||||
createFromForm(aForm) {
|
||||
if (ChromeUtils.getClassName(aForm) !== "HTMLFormElement") {
|
||||
if (!HTMLFormElement.isInstance(aForm)) {
|
||||
throw new Error("createFromForm: aForm must be a HTMLFormElement");
|
||||
}
|
||||
|
||||
|
@ -62,15 +62,15 @@ let FormLikeFactory = {
|
|||
*/
|
||||
createFromField(aField) {
|
||||
if (
|
||||
(ChromeUtils.getClassName(aField) !== "HTMLInputElement" &&
|
||||
ChromeUtils.getClassName(aField) !== "HTMLSelectElement") ||
|
||||
(!HTMLInputElement.isInstance(aField) &&
|
||||
!HTMLSelectElement.isInstance(aField)) ||
|
||||
!aField.ownerDocument
|
||||
) {
|
||||
throw new Error("createFromField requires a field in a document");
|
||||
}
|
||||
|
||||
let rootElement = this.findRootForField(aField);
|
||||
if (ChromeUtils.getClassName(rootElement) === "HTMLFormElement") {
|
||||
if (HTMLFormElement.isInstance(rootElement)) {
|
||||
return this.createFromForm(rootElement);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ let FormLikeFactory = {
|
|||
let current = aField;
|
||||
while (!form) {
|
||||
let shadowRoot = current.getRootNode();
|
||||
if (ChromeUtils.getClassName(shadowRoot) !== "ShadowRoot") {
|
||||
if (!ShadowRoot.isInstance(shadowRoot)) {
|
||||
break;
|
||||
}
|
||||
let host = shadowRoot.host;
|
||||
|
|
Загрузка…
Ссылка в новой задаче