Bug 1524106 - Disconnect l10n root when destroying the document. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D18774

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Zibi Braniecki 2019-02-07 14:37:26 +00:00
Родитель 9719483cc6
Коммит aee876626a
4 изменённых файлов: 15 добавлений и 0 удалений

Просмотреть файл

@ -7498,6 +7498,10 @@ void Document::Destroy() {
mIsGoingAway = true;
if (mDocumentL10n) {
mDocumentL10n->Destroy();
}
ScriptLoader()->Destroy();
SetScriptGlobalObject(nullptr);
RemovedFromDocShell();

Просмотреть файл

@ -112,6 +112,15 @@ bool DocumentL10n::Init(nsTArray<nsString>& aResourceIds) {
return true;
}
void DocumentL10n::Destroy() {
if (mDOMLocalization) {
Element* elem = mDocument->GetDocumentElement();
if (elem) {
mDOMLocalization->DisconnectRoot(elem);
}
}
}
JSObject* DocumentL10n::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return DocumentL10n_Binding::Wrap(aCx, this, aGivenProto);

Просмотреть файл

@ -65,6 +65,7 @@ class DocumentL10n final : public nsWrapperCache {
public:
explicit DocumentL10n(Document* aDocument);
bool Init(nsTArray<nsString>& aResourceIds);
void Destroy();
protected:
virtual ~DocumentL10n();

Просмотреть файл

@ -24,6 +24,7 @@ interface mozIDOMLocalization : nsISupports
Promise translateElements(in Array<Element> aElements);
void connectRoot(in Element aElement);
void disconnectRoot(in Element aElement);
Promise translateRoots();
readonly attribute Promise ready;
};