зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1569897 - Only keep weak references on the active element from FormAutofillContent r=MattN
Depends on D39716 Differential Revision: https://phabricator.services.mozilla.com/D39854 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
4d7909d785
Коммит
8070e9389c
|
@ -587,14 +587,8 @@ var FormAutofillContent = {
|
|||
this._activeItems = {};
|
||||
return;
|
||||
}
|
||||
let handler = this._getFormHandler(element);
|
||||
if (handler) {
|
||||
handler.focusedInput = element;
|
||||
}
|
||||
this._activeItems = {
|
||||
handler,
|
||||
elementWeakRef: Cu.getWeakReference(element),
|
||||
section: handler ? handler.activeSection : null,
|
||||
fieldDetail: null,
|
||||
};
|
||||
},
|
||||
|
@ -605,11 +599,25 @@ var FormAutofillContent = {
|
|||
},
|
||||
|
||||
get activeHandler() {
|
||||
return this._activeItems.handler;
|
||||
const activeInput = this.activeInput;
|
||||
if (!activeInput) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// XXX: We are recomputing the activeHandler every time to avoid keeping a
|
||||
// reference on the active element. This might be called quite frequently
|
||||
// so if _getFormHandler/findRootForField become more costly, we should
|
||||
// look into caching this result (eg by adding a weakmap).
|
||||
let handler = this._getFormHandler(activeInput);
|
||||
if (handler) {
|
||||
handler.focusedInput = activeInput;
|
||||
}
|
||||
return handler;
|
||||
},
|
||||
|
||||
get activeSection() {
|
||||
return this._activeItems.section;
|
||||
let formHandler = this.activeHandler;
|
||||
return formHandler ? formHandler.activeSection : null;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -78,10 +78,6 @@ var FormAutofillFrameScript = {
|
|||
this.onFocusIn(evt);
|
||||
break;
|
||||
}
|
||||
case "focusout": {
|
||||
this.onFocusOut();
|
||||
break;
|
||||
}
|
||||
case "DOMFormBeforeSubmit": {
|
||||
this.onDOMFormBeforeSubmit(evt);
|
||||
break;
|
||||
|
@ -120,12 +116,6 @@ var FormAutofillFrameScript = {
|
|||
this._doIdentifyAutofillFields();
|
||||
},
|
||||
|
||||
onFocusOut() {
|
||||
// Update active input on blur to release references on the previously
|
||||
// focused element in FormAutofillContent.
|
||||
FormAutofillContent.updateActiveInput();
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle the DOMFormBeforeSubmit event.
|
||||
* @param {Event} evt
|
||||
|
|
|
@ -50,6 +50,6 @@ add_task(async function() {
|
|||
"The .focusme input is the active element"
|
||||
);
|
||||
|
||||
// Stop the test without blurring the input, the cleanup should still prevent
|
||||
// leaks in the test.
|
||||
info("Remove the focused input");
|
||||
focusMeInput.remove();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче