Bug 1496685 - Implement UrlbarController::viewContextChanged. r=dao

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Marco Bonardo 2019-02-26 15:30:10 +00:00
Родитель f663d791e3
Коммит d012deb395
4 изменённых файлов: 28 добавлений и 11 удалений

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

@ -92,9 +92,8 @@ class UrlbarController {
*/
async startQuery(queryContext) {
// Cancel any running query.
if (this._lastQueryContext) {
this.cancelQuery(this._lastQueryContext);
}
this.cancelQuery();
this._lastQueryContext = queryContext;
queryContext.lastResultCount = 0;
@ -174,11 +173,14 @@ class UrlbarController {
}
/**
* When switching tabs, clear some internal caches to handle cases like
* backspace, autofill or repeated searches.
* When the containing context changes (for example when switching tabs),
* clear any caches that connects consecutive searches in the same context.
* For example it can be used to clear information used to improve autofill
* or save resourced on repeated searches.
*/
tabContextChanged() {
// TODO: implementation needed (bug 1496685)
viewContextChanged() {
this.cancelQuery();
this._notify("onViewContextChanged");
}
/**

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

@ -1107,7 +1107,7 @@ class UrlbarInput {
}
_on_TabSelect(event) {
this.controller.tabContextChanged();
this.controller.viewContextChanged();
}
_on_keydown(event) {

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

@ -272,6 +272,16 @@ class UrlbarView {
}
}
/**
* Notified when the view context changes, for example when switching tabs.
* It can be used to reset internal state tracking.
*/
onViewContextChanged() {
// Clear rows, so that when reusing results we don't visually leak them
// across different contexts.
this._rows.textContent = "";
}
/**
* Passes DOM events for the view to the _on_<event type> methods.
* @param {Event} event

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

@ -259,9 +259,9 @@ View (e.g. showing/hiding a panel). It is also responsible for reporting Telemet
// Used by the View to listen for results.
addQueryListener(listener);
removeQueryListener(listener);
// Used to indicate the View context changed, as such any cached information
// should be reset.
tabContextChanged();
// Used to indicate the View context changed, so that cached information
// about the latest search is no more relevant and can be dropped.
viewContextChanged();
}
@ -347,8 +347,12 @@ Represents the base *View* implementation, communicates with the *Controller*.
onQueryCancelled(queryContext);
// Invoked when the query is done.
onQueryFinished(queryContext);
// Invoked when the view context changed, so that cached information about
// the latest search is no more relevant and can be dropped.
onViewContextChanged();
}
UrlbarResult
===========
@ -399,6 +403,7 @@ The following RESULT_TYPEs are supported:
// Payload: { icon, url, device, title }
REMOTE_TAB: 6,
Shared Modules
==============