зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
f663d791e3
Коммит
d012deb395
|
@ -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
|
||||
==============
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче